[llvm] e63b7ba - [InstCombine][NFC] Add tests for shifts of constants by common factor (#103471)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 08:50:00 PDT 2024
Author: Kevin McAfee
Date: 2024-08-15T08:49:55-07:00
New Revision: e63b7ba0eb497d10d643aa5e27461c6c1bf8e221
URL: https://github.com/llvm/llvm-project/commit/e63b7ba0eb497d10d643aa5e27461c6c1bf8e221
DIFF: https://github.com/llvm/llvm-project/commit/e63b7ba0eb497d10d643aa5e27461c6c1bf8e221.diff
LOG: [InstCombine][NFC] Add tests for shifts of constants by common factor (#103471)
Added:
Modified:
llvm/test/Transforms/InstCombine/shl-factor.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/shl-factor.ll b/llvm/test/Transforms/InstCombine/shl-factor.ll
index 38eecaeff8e41..996b15f27f6d3 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