[llvm] a808d89 - [PredicateInfo] Add test for one unknown condition in and/or (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 11 13:33:45 PST 2021
Author: Nikita Popov
Date: 2021-01-11T22:33:34+01:00
New Revision: a808d89d355c98d7475795e13271beb90e9436cb
URL: https://github.com/llvm/llvm-project/commit/a808d89d355c98d7475795e13271beb90e9436cb
DIFF: https://github.com/llvm/llvm-project/commit/a808d89d355c98d7475795e13271beb90e9436cb.diff
LOG: [PredicateInfo] Add test for one unknown condition in and/or (NFC)
Test the case where one part of and/or is an icmp, while the other
one is an arbitrary value.
Added:
Modified:
llvm/test/Transforms/Util/PredicateInfo/testandor.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/Util/PredicateInfo/testandor.ll b/llvm/test/Transforms/Util/PredicateInfo/testandor.ll
index cd1491e31a8d..4697c9d3e059 100644
--- a/llvm/test/Transforms/Util/PredicateInfo/testandor.ll
+++ b/llvm/test/Transforms/Util/PredicateInfo/testandor.ll
@@ -209,3 +209,77 @@ nope:
call void @foo(i1 %z)
ret void
}
+
+define void @test_and_one_unknown_cond(i32 %x, i1 %c1) {
+; CHECK-LABEL: @test_and_one_unknown_cond(
+; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[X:%.*]], 0
+; CHECK-NEXT: [[A:%.*]] = and i1 [[C1:%.*]], [[C2]]
+; CHECK-NEXT: br i1 [[A]], label [[BOTH:%.*]], label [[NOPE:%.*]]
+; CHECK: both:
+; CHECK-NEXT: call void @bar(i32 [[X]])
+; CHECK-NEXT: call void @foo(i1 [[C1]])
+; CHECK-NEXT: call void @foo(i1 [[C2]])
+; CHECK-NEXT: call void @foo(i1 [[A]])
+; CHECK-NEXT: ret void
+; CHECK: nope:
+; CHECK-NEXT: call void @bar(i32 [[X]])
+; CHECK-NEXT: call void @foo(i1 [[C1]])
+; CHECK-NEXT: call void @foo(i1 [[C2]])
+; CHECK-NEXT: call void @foo(i1 [[A]])
+; CHECK-NEXT: ret void
+;
+ %c2 = icmp eq i32 %x, 0
+ %a = and i1 %c1, %c2
+ br i1 %a, label %both, label %nope
+
+both:
+ call void @bar(i32 %x)
+ call void @foo(i1 %c1)
+ call void @foo(i1 %c2)
+ call void @foo(i1 %a)
+ ret void
+
+nope:
+ call void @bar(i32 %x)
+ call void @foo(i1 %c1)
+ call void @foo(i1 %c2)
+ call void @foo(i1 %a)
+ ret void
+}
+
+define void @test_or_one_unknown_cond(i32 %x, i1 %c1) {
+; CHECK-LABEL: @test_or_one_unknown_cond(
+; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[X:%.*]], 0
+; CHECK-NEXT: [[A:%.*]] = or i1 [[C1:%.*]], [[C2]]
+; CHECK-NEXT: br i1 [[A]], label [[NOPE:%.*]], label [[BOTH_INVERTED:%.*]]
+; CHECK: both_inverted:
+; CHECK-NEXT: call void @bar(i32 [[X]])
+; CHECK-NEXT: call void @foo(i1 [[C1]])
+; CHECK-NEXT: call void @foo(i1 [[C2]])
+; CHECK-NEXT: call void @foo(i1 [[A]])
+; CHECK-NEXT: ret void
+; CHECK: nope:
+; CHECK-NEXT: call void @bar(i32 [[X]])
+; CHECK-NEXT: call void @foo(i1 [[C1]])
+; CHECK-NEXT: call void @foo(i1 [[C2]])
+; CHECK-NEXT: call void @foo(i1 [[A]])
+; CHECK-NEXT: ret void
+;
+ %c2 = icmp eq i32 %x, 0
+ %a = or i1 %c1, %c2
+ br i1 %a, label %nope, label %both_inverted
+
+both_inverted:
+ call void @bar(i32 %x)
+ call void @foo(i1 %c1)
+ call void @foo(i1 %c2)
+ call void @foo(i1 %a)
+ ret void
+
+nope:
+ call void @bar(i32 %x)
+ call void @foo(i1 %c1)
+ call void @foo(i1 %c2)
+ call void @foo(i1 %a)
+ ret void
+}
More information about the llvm-commits
mailing list