[llvm] e331ca5 - [InstSimplify] Add extra tests for #70335 (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 2 03:41:55 PDT 2023
Author: Nikita Popov
Date: 2023-11-02T11:41:47+01:00
New Revision: e331ca5076b5757434b8560743b47895a9319c49
URL: https://github.com/llvm/llvm-project/commit/e331ca5076b5757434b8560743b47895a9319c49
DIFF: https://github.com/llvm/llvm-project/commit/e331ca5076b5757434b8560743b47895a9319c49.diff
LOG: [InstSimplify] Add extra tests for #70335 (NFC)
These were miscompiled with the initial version of the patch.
Added:
Modified:
llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll b/llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll
index db38077e0c51308..b916d899a91b6f8 100644
--- a/llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll
+++ b/llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll
@@ -264,3 +264,62 @@ define i1 @pr69091(i32 %arg, i32 %arg1) {
%or = or i1 %icmp, %icmp2
ret i1 %or
}
+
+declare void @barrier()
+
+define i1 @or_icmp_implies_ub(i32 %x) {
+; CHECK-LABEL: @or_icmp_implies_ub(
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[X:%.*]], 0
+; CHECK-NEXT: call void @barrier()
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp1 = icmp ne i32 %x, 0
+ call void @barrier()
+ %div = udiv i32 2147483647, %x
+ %cmp2 = icmp ugt i32 %x, %div
+ %or = or i1 %cmp1, %cmp2
+ ret i1 %or
+}
+
+define i1 @and_icmp_implies_ub(i32 %x) {
+; CHECK-LABEL: @and_icmp_implies_ub(
+; CHECK-NEXT: call void @barrier()
+; CHECK-NEXT: ret i1 false
+;
+ %cmp1 = icmp eq i32 %x, 0
+ call void @barrier()
+ %div = udiv i32 2147483647, %x
+ %cmp2 = icmp ugt i32 %x, %div
+ %and = and i1 %cmp1, %cmp2
+ ret i1 %and
+}
+
+define i1 @or_icmp_implies_poison(i32 %x) {
+; CHECK-LABEL: @or_icmp_implies_poison(
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[X:%.*]], 32
+; CHECK-NEXT: [[SHL:%.*]] = shl i32 1, [[X]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[X]], [[SHL]]
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT: ret i1 [[OR]]
+;
+ %cmp1 = icmp ne i32 %x, 32
+ %shl = shl i32 1, %x
+ %cmp2 = icmp ugt i32 %x, %shl
+ %or = or i1 %cmp1, %cmp2
+ ret i1 %or
+}
+
+define i1 @and_icmp_implies_poison(i32 %x) {
+; CHECK-LABEL: @and_icmp_implies_poison(
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[X:%.*]], 32
+; CHECK-NEXT: [[SHL:%.*]] = shl i32 1, [[X]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[X]], [[SHL]]
+; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT: ret i1 [[AND]]
+;
+ %cmp1 = icmp eq i32 %x, 32
+ %shl = shl i32 1, %x
+ %cmp2 = icmp ugt i32 %x, %shl
+ %and = and i1 %cmp1, %cmp2
+ ret i1 %and
+}
More information about the llvm-commits
mailing list