[llvm] [InstCombine][NFC] Add tests for shifts of constants by common factor (PR #103471)
Kevin McAfee via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 14:24:33 PDT 2024
https://github.com/kalxr created https://github.com/llvm/llvm-project/pull/103471
None
>From c497eacab45d302d85875261df73b48fe7a3b3fa Mon Sep 17 00:00:00 2001
From: Kevin McAfee <kmcafee at nvidia.com>
Date: Tue, 13 Aug 2024 14:23:28 -0700
Subject: [PATCH] [InstCombine][NFC] Add tests for shifts of constants by
common factor
---
.../test/Transforms/InstCombine/shl-factor.ll | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/llvm/test/Transforms/InstCombine/shl-factor.ll b/llvm/test/Transforms/InstCombine/shl-factor.ll
index 38eecaeff8e41e..996b15f27f6d34 100644
--- a/llvm/test/Transforms/InstCombine/shl-factor.ll
+++ b/llvm/test/Transforms/InstCombine/shl-factor.ll
@@ -265,3 +265,27 @@ define i6 @sub_shl_same_amount_partial_nuw2(i6 %x, i6 %y, i6 %z) {
ret i6 %diff
}
+define i8 @add_shl_same_amount_constants(i8 %z) {
+; CHECK-LABEL: @add_shl_same_amount_constants(
+; CHECK-NEXT: [[SUM:%.*]] = shl i8 7, [[Z:%.*]]
+; CHECK-NEXT: ret i8 [[SUM]]
+;
+ %s1 = shl i8 4, %z
+ %s2 = shl i8 3, %z
+ %sum = add i8 %s1, %s2
+ ret i8 %sum
+}
+
+define i8 @add_shl_same_amount_constants_extra_use(i8 %z) {
+; CHECK-LABEL: @add_shl_same_amount_constants_extra_use(
+; CHECK-NEXT: [[S1:%.*]] = shl i8 4, [[Z:%.*]]
+; CHECK-NEXT: [[SUM:%.*]] = shl i8 7, [[Z]]
+; CHECK-NEXT: call void @use8(i8 [[S1]])
+; CHECK-NEXT: ret i8 [[SUM]]
+;
+ %s1 = shl i8 4, %z
+ %s2 = shl i8 3, %z
+ %sum = add i8 %s1, %s2
+ call void @use8(i8 %s1)
+ ret i8 %sum
+}
More information about the llvm-commits
mailing list