[llvm] a2f96a1 - [ConstraintElimination] Add tests with logical ANDs.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 06:50:39 PDT 2022
Author: Florian Hahn
Date: 2022-10-06T14:50:13+01:00
New Revision: a2f96a10cfa12e6f6b3d1d5138be207ab96ff68e
URL: https://github.com/llvm/llvm-project/commit/a2f96a10cfa12e6f6b3d1d5138be207ab96ff68e
DIFF: https://github.com/llvm/llvm-project/commit/a2f96a10cfa12e6f6b3d1d5138be207ab96ff68e.diff
LOG: [ConstraintElimination] Add tests with logical ANDs.
Added:
Modified:
llvm/test/Transforms/ConstraintElimination/and.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/ConstraintElimination/and.ll b/llvm/test/Transforms/ConstraintElimination/and.ll
index 19cbf6c2d445..284f98c6a45e 100644
--- a/llvm/test/Transforms/ConstraintElimination/and.ll
+++ b/llvm/test/Transforms/ConstraintElimination/and.ll
@@ -452,3 +452,178 @@ exit:
ret i1 %r.10
}
+define i1 @test_and_chain_select_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
+; CHECK-LABEL: @test_and_chain_select_ule(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 3, [[X]]
+; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 3, [[A:%.*]]
+; CHECK-NEXT: [[AND_1:%.*]] = select i1 [[C_1]], i1 [[C_1]], i1 false
+; CHECK-NEXT: [[AND_2:%.*]] = select i1 [[AND_1]], i1 [[C_3]], i1 false
+; CHECK-NEXT: [[AND_3:%.*]] = select i1 [[C_4]], i1 [[AND_2]], i1 false
+; CHECK-NEXT: br i1 [[AND_3]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[T_1:%.*]] = icmp ule i4 [[X]], [[Z]]
+; CHECK-NEXT: [[T_2:%.*]] = icmp ule i4 [[X]], [[Y]]
+; CHECK-NEXT: [[R_1:%.*]] = xor i1 [[T_1]], [[T_2]]
+; CHECK-NEXT: [[T_3:%.*]] = icmp ule i4 [[Y]], [[Z]]
+; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[T_3]]
+; CHECK-NEXT: [[T_4:%.*]] = icmp ule i4 3, [[X]]
+; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[T_4]]
+; CHECK-NEXT: [[T_5:%.*]] = icmp ule i4 3, [[A]]
+; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[R_3]], [[T_5]]
+; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
+; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
+; CHECK-NEXT: ret i1 [[R_5]]
+; CHECK: exit:
+; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Z]]
+; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[X]], [[A]]
+; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[C_6]], [[C_7]]
+; CHECK-NEXT: [[C_8:%.*]] = icmp ule i4 [[X]], [[Y]]
+; CHECK-NEXT: [[R_7:%.*]] = xor i1 [[R_6]], [[C_8]]
+; CHECK-NEXT: [[C_9:%.*]] = icmp ule i4 [[Y]], [[Z]]
+; CHECK-NEXT: [[R_8:%.*]] = xor i1 [[R_7]], [[C_9]]
+; CHECK-NEXT: [[C_10:%.*]] = icmp ule i4 3, [[X]]
+; CHECK-NEXT: [[R_9:%.*]] = xor i1 [[R_8]], [[C_10]]
+; CHECK-NEXT: [[C_11:%.*]] = icmp ule i4 3, [[A]]
+; CHECK-NEXT: [[R_10:%.*]] = xor i1 [[R_9]], [[C_11]]
+; CHECK-NEXT: ret i1 [[R_10]]
+;
+entry:
+ %c.1 = icmp ule i4 %x, %y
+ %c.2 = icmp ule i4 %y, %z
+ %c.3 = icmp ule i4 3, %x
+ %c.4 = icmp ule i4 3, %a
+ %and.1 = select i1 %c.1, i1 %c.1, i1 false
+ %and.2 = select i1 %and.1, i1 %c.3, i1 false
+ %and.3 = select i1 %c.4, i1 %and.2, i1 false
+ br i1 %and.3, label %bb1, label %exit
+
+bb1:
+ %t.1 = icmp ule i4 %x, %z
+ %t.2 = icmp ule i4 %x, %y
+ %r.1 = xor i1 %t.1, %t.2
+
+ %t.3 = icmp ule i4 %y, %z
+ %r.2 = xor i1 %r.1, %t.3
+
+ %t.4 = icmp ule i4 3, %x
+ %r.3 = xor i1 %r.2, %t.4
+
+ %t.5 = icmp ule i4 3, %a
+ %r.4 = xor i1 %r.3, %t.5
+
+ %c.5 = icmp ule i4 %x, %a
+ %r.5 = xor i1 %r.4, %c.5
+
+ ret i1 %r.5
+
+exit:
+ %c.6 = icmp ule i4 %x, %z
+ %c.7 = icmp ule i4 %x, %a
+ %r.6 = xor i1 %c.6, %c.7
+
+ %c.8 = icmp ule i4 %x, %y
+ %r.7 = xor i1 %r.6, %c.8
+
+ %c.9 = icmp ule i4 %y, %z
+ %r.8 = xor i1 %r.7, %c.9
+
+ %c.10 = icmp ule i4 3, %x
+ %r.9 = xor i1 %r.8, %c.10
+
+ %c.11 = icmp ule i4 3, %a
+ %r.10 = xor i1 %r.9, %c.11
+
+ ret i1 %r.10
+}
+
+define i1 @test_and_chain_select_ule_logical_or(i4 %x, i4 %y, i4 %z, i4 %a) {
+; CHECK-LABEL: @test_and_chain_select_ule_logical_or(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 3, [[X]]
+; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 3, [[A:%.*]]
+; CHECK-NEXT: [[AND_1:%.*]] = select i1 [[C_1]], i1 [[C_1]], i1 false
+; CHECK-NEXT: [[AND_2:%.*]] = select i1 [[AND_1]], i1 [[C_3]], i1 false
+; CHECK-NEXT: [[AND_3:%.*]] = select i1 [[C_4]], i1 [[AND_2]], i1 false
+; CHECK-NEXT: [[AND_4:%.*]] = select i1 [[AND_3]], i1 true, i1 false
+; CHECK-NEXT: br i1 [[AND_4]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[T_1:%.*]] = icmp ule i4 [[X]], [[Z]]
+; CHECK-NEXT: [[T_2:%.*]] = icmp ule i4 [[X]], [[Y]]
+; CHECK-NEXT: [[R_1:%.*]] = xor i1 [[T_1]], [[T_2]]
+; CHECK-NEXT: [[T_3:%.*]] = icmp ule i4 [[Y]], [[Z]]
+; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[T_3]]
+; CHECK-NEXT: [[T_4:%.*]] = icmp ule i4 3, [[X]]
+; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[T_4]]
+; CHECK-NEXT: [[T_5:%.*]] = icmp ule i4 3, [[A]]
+; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[R_3]], [[T_5]]
+; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
+; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
+; CHECK-NEXT: ret i1 [[R_5]]
+; CHECK: exit:
+; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Z]]
+; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[X]], [[A]]
+; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[C_6]], [[C_7]]
+; CHECK-NEXT: [[C_8:%.*]] = icmp ule i4 [[X]], [[Y]]
+; CHECK-NEXT: [[R_7:%.*]] = xor i1 [[R_6]], [[C_8]]
+; CHECK-NEXT: [[C_9:%.*]] = icmp ule i4 [[Y]], [[Z]]
+; CHECK-NEXT: [[R_8:%.*]] = xor i1 [[R_7]], [[C_9]]
+; CHECK-NEXT: [[C_10:%.*]] = icmp ule i4 3, [[X]]
+; CHECK-NEXT: [[R_9:%.*]] = xor i1 [[R_8]], [[C_10]]
+; CHECK-NEXT: [[C_11:%.*]] = icmp ule i4 3, [[A]]
+; CHECK-NEXT: [[R_10:%.*]] = xor i1 [[R_9]], [[C_11]]
+; CHECK-NEXT: ret i1 [[R_10]]
+;
+entry:
+ %c.1 = icmp ule i4 %x, %y
+ %c.2 = icmp ule i4 %y, %z
+ %c.3 = icmp ule i4 3, %x
+ %c.4 = icmp ule i4 3, %a
+ %and.1 = select i1 %c.1, i1 %c.1, i1 false
+ %and.2 = select i1 %and.1, i1 %c.3, i1 false
+ %and.3 = select i1 %c.4, i1 %and.2, i1 false
+ %and.4 = select i1 %and.3, i1 true, i1 false
+ br i1 %and.4, label %bb1, label %exit
+
+bb1:
+ %t.1 = icmp ule i4 %x, %z
+ %t.2 = icmp ule i4 %x, %y
+ %r.1 = xor i1 %t.1, %t.2
+
+ %t.3 = icmp ule i4 %y, %z
+ %r.2 = xor i1 %r.1, %t.3
+
+ %t.4 = icmp ule i4 3, %x
+ %r.3 = xor i1 %r.2, %t.4
+
+ %t.5 = icmp ule i4 3, %a
+ %r.4 = xor i1 %r.3, %t.5
+
+ %c.5 = icmp ule i4 %x, %a
+ %r.5 = xor i1 %r.4, %c.5
+
+ ret i1 %r.5
+
+exit:
+ %c.6 = icmp ule i4 %x, %z
+ %c.7 = icmp ule i4 %x, %a
+ %r.6 = xor i1 %c.6, %c.7
+
+ %c.8 = icmp ule i4 %x, %y
+ %r.7 = xor i1 %r.6, %c.8
+
+ %c.9 = icmp ule i4 %y, %z
+ %r.8 = xor i1 %r.7, %c.9
+
+ %c.10 = icmp ule i4 3, %x
+ %r.9 = xor i1 %r.8, %c.10
+
+ %c.11 = icmp ule i4 3, %a
+ %r.10 = xor i1 %r.9, %c.11
+
+ ret i1 %r.10
+}
More information about the llvm-commits
mailing list