1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
6 define i1 @test_and_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
7 ; CHECK-LABEL: @test_and_ule(
9 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
10 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
11 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_2]]
12 ; CHECK-NEXT: br i1 [[AND]], label [[BB1:%.*]], label [[EXIT:%.*]]
14 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i4 [[X]], [[Z]]
15 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i4 [[X]], [[Y]]
16 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, true
17 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i4 [[Y]], [[Z]]
18 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], true
19 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 [[X]], [[A:%.*]]
20 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_3]]
21 ; CHECK-NEXT: ret i1 [[R_3]]
23 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 [[X]], [[Z]]
24 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
25 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[C_4]], [[C_5]]
26 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Y]]
27 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_6]]
28 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[Y]], [[Z]]
29 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_7]]
30 ; CHECK-NEXT: ret i1 [[R_6]]
33 %c.1 = icmp ule i4 %x, %y
34 %c.2 = icmp ule i4 %y, %z
35 %and = and i1 %c.1, %c.2
36 br i1 %and, label %bb1, label %exit
39 %t.1 = icmp ule i4 %x, %z
40 %t.2 = icmp ule i4 %x, %y
41 %r.1 = xor i1 %t.1, %t.2
43 %t.3 = icmp ule i4 %y, %z
44 %r.2 = xor i1 %r.1, %t.3
47 %c.3 = icmp ule i4 %x, %a
48 %r.3 = xor i1 %r.2, %c.3
53 %c.4 = icmp ule i4 %x, %z
54 %c.5 = icmp ule i4 %x, %a
55 %r.4 = xor i1 %c.4, %c.5
57 %c.6 = icmp ule i4 %x, %y
58 %r.5 = xor i1 %r.4, %c.6
60 %c.7 = icmp ule i4 %y, %z
61 %r.6 = xor i1 %r.5, %c.7
66 ; The result of test_and_ule and test_and_select_ule should be same
67 define i1 @test_and_select_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
68 ; CHECK-LABEL: @test_and_select_ule(
70 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
71 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
72 ; CHECK-NEXT: [[AND:%.*]] = select i1 [[C_1]], i1 [[C_2]], i1 false
73 ; CHECK-NEXT: br i1 [[AND]], label [[BB1:%.*]], label [[EXIT:%.*]]
75 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i4 [[X]], [[Z]]
76 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i4 [[X]], [[Y]]
77 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, true
78 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i4 [[Y]], [[Z]]
79 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], true
80 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 [[X]], [[A:%.*]]
81 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_3]]
82 ; CHECK-NEXT: ret i1 [[R_3]]
84 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 [[X]], [[Z]]
85 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
86 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[C_4]], [[C_5]]
87 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Y]]
88 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_6]]
89 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[Y]], [[Z]]
90 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_7]]
91 ; CHECK-NEXT: ret i1 [[R_6]]
94 %c.1 = icmp ule i4 %x, %y
95 %c.2 = icmp ule i4 %y, %z
96 %and = select i1 %c.1, i1 %c.2, i1 false
97 br i1 %and, label %bb1, label %exit
100 %t.1 = icmp ule i4 %x, %z
101 %t.2 = icmp ule i4 %x, %y
102 %r.1 = xor i1 %t.1, %t.2
104 %t.3 = icmp ule i4 %y, %z
105 %r.2 = xor i1 %r.1, %t.3
107 %c.3 = icmp ule i4 %x, %a
108 %r.3 = xor i1 %r.2, %c.3
112 %c.4 = icmp ule i4 %x, %z
113 %c.5 = icmp ule i4 %x, %a
114 %r.4 = xor i1 %c.4, %c.5
116 %c.6 = icmp ule i4 %x, %y
117 %r.5 = xor i1 %r.4, %c.6
119 %c.7 = icmp ule i4 %y, %z
120 %r.6 = xor i1 %r.5, %c.7
124 define i4 @and_compare_undef(i4 %N, i4 %step) {
125 ; CHECK-LABEL: @and_compare_undef(
126 ; CHECK-NEXT: step.check:
127 ; CHECK-NEXT: [[STEP_POS:%.*]] = icmp uge i4 [[STEP:%.*]], 0
128 ; CHECK-NEXT: [[B1:%.*]] = add i4 undef, -1
129 ; CHECK-NEXT: [[STEP_ULT_N:%.*]] = icmp ult i4 [[B1]], [[N:%.*]]
130 ; CHECK-NEXT: [[AND_STEP:%.*]] = and i1 [[STEP_POS]], [[STEP_ULT_N]]
131 ; CHECK-NEXT: br i1 [[AND_STEP]], label [[PTR_CHECK:%.*]], label [[EXIT:%.*]]
133 ; CHECK-NEXT: br label [[EXIT]]
135 ; CHECK-NEXT: ret i4 3
138 %step.pos = icmp uge i4 %step, 0
139 %B1 = add i4 undef, -1
140 %step.ult.N = icmp ult i4 %B1, %N
141 %and.step = and i1 %step.pos, %step.ult.N
142 br i1 %and.step, label %ptr.check, label %exit