[llvm] 33a194b - [InstCombine] Add pre-commit tests for #67915. NFC.
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 05:03:24 PDT 2023
Author: Yingwei Zheng
Date: 2023-10-05T20:01:55+08:00
New Revision: 33a194b158069fdd713665f9cccf5dac0bc8a781
URL: https://github.com/llvm/llvm-project/commit/33a194b158069fdd713665f9cccf5dac0bc8a781
DIFF: https://github.com/llvm/llvm-project/commit/33a194b158069fdd713665f9cccf5dac0bc8a781.diff
LOG: [InstCombine] Add pre-commit tests for #67915. NFC.
Added:
Modified:
llvm/test/Transforms/InstCombine/and.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll
index 90f027010e2aea6..528a4e62c192d0e 100644
--- a/llvm/test/Transforms/InstCombine/and.ll
+++ b/llvm/test/Transforms/InstCombine/and.ll
@@ -2546,3 +2546,39 @@ define i32 @and_zext_eq_zero(i32 %A, i32 %C) {
%5 = and i32 %2, %4
ret i32 %5
}
+
+define i32 @canonicalize_and_add_power2_or_zero(i32 %x, i32 %y) {
+; CHECK-LABEL: @canonicalize_and_add_power2_or_zero(
+; CHECK-NEXT: [[NY:%.*]] = sub i32 0, [[Y:%.*]]
+; CHECK-NEXT: [[P2:%.*]] = and i32 [[NY]], [[Y]]
+; CHECK-NEXT: call void @use32(i32 [[P2]])
+; CHECK-NEXT: [[VAL:%.*]] = add i32 [[P2]], [[X:%.*]]
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[VAL]], [[P2]]
+; CHECK-NEXT: ret i32 [[AND]]
+;
+ %ny = sub i32 0, %y
+ %p2 = and i32 %y, %ny
+ call void @use32(i32 %p2) ; keep p2
+
+ %val = add i32 %x, %p2
+ %and = and i32 %val, %p2
+ ret i32 %and
+}
+
+define i32 @canonicalize_and_sub_power2_or_zero(i32 %x, i32 %y) {
+; CHECK-LABEL: @canonicalize_and_sub_power2_or_zero(
+; CHECK-NEXT: [[NY:%.*]] = sub i32 0, [[Y:%.*]]
+; CHECK-NEXT: [[P2:%.*]] = and i32 [[NY]], [[Y]]
+; CHECK-NEXT: call void @use32(i32 [[P2]])
+; CHECK-NEXT: [[VAL:%.*]] = sub i32 [[X:%.*]], [[P2]]
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[VAL]], [[P2]]
+; CHECK-NEXT: ret i32 [[AND]]
+;
+ %ny = sub i32 0, %y
+ %p2 = and i32 %y, %ny
+ call void @use32(i32 %p2) ; keep p2
+
+ %val = sub i32 %x, %p2
+ %and = and i32 %val, %p2
+ ret i32 %and
+}
More information about the llvm-commits
mailing list