1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -constraint-elimination -S %s | FileCheck %s
4 define i1 @test_add_nuw(i8 %start, i8 %low, i8 %high) {
5 ; CHECK-LABEL: @test_add_nuw(
7 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = add nuw i8 [[START:%.*]], 3
8 ; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8 [[ADD_PTR_I]], [[HIGH:%.*]]
9 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
11 ; CHECK-NEXT: [[UC_3:%.*]] = icmp ugt i8 [[START]], [[HIGH]]
12 ; CHECK-NEXT: [[START_1_1:%.*]] = add nuw i8 [[START]], 1
13 ; CHECK-NEXT: [[UC_4:%.*]] = icmp uge i8 [[START_1_1]], [[HIGH]]
14 ; CHECK-NEXT: [[RES_11:%.*]] = xor i1 [[UC_3]], [[UC_4]]
15 ; CHECK-NEXT: [[START_3_1:%.*]] = add nuw i8 [[START]], 3
16 ; CHECK-NEXT: [[T_0:%.*]] = icmp uge i8 [[START_3_1]], [[HIGH]]
17 ; CHECK-NEXT: [[RES_12:%.*]] = xor i1 [[RES_11]], true
18 ; CHECK-NEXT: [[UC_5:%.*]] = icmp ugt i8 [[START_3_1]], [[HIGH]]
19 ; CHECK-NEXT: [[RES_13:%.*]] = xor i1 [[RES_12]], [[UC_5]]
20 ; CHECK-NEXT: [[SC_8:%.*]] = icmp sge i8 [[START_1_1]], [[HIGH]]
21 ; CHECK-NEXT: [[RES_14:%.*]] = xor i1 [[RES_13]], [[SC_8]]
22 ; CHECK-NEXT: [[SC_9:%.*]] = icmp sge i8 [[START_3_1]], [[HIGH]]
23 ; CHECK-NEXT: [[RES_15:%.*]] = xor i1 [[RES_14]], [[SC_9]]
24 ; CHECK-NEXT: ret i1 [[RES_15]]
26 ; CHECK-NEXT: [[F_0:%.*]] = icmp ugt i8 [[START]], [[HIGH]]
27 ; CHECK-NEXT: [[START_1:%.*]] = add nuw i8 [[START]], 1
28 ; CHECK-NEXT: [[F_1:%.*]] = icmp uge i8 [[START_1]], [[HIGH]]
29 ; CHECK-NEXT: [[RES_0:%.*]] = xor i1 false, false
30 ; CHECK-NEXT: [[SC_1:%.*]] = icmp sgt i8 [[START]], [[HIGH]]
31 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[RES_0]], [[SC_1]]
32 ; CHECK-NEXT: [[SC_2:%.*]] = icmp sge i8 [[START_1]], [[HIGH]]
33 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[SC_2]]
34 ; CHECK-NEXT: [[START_2:%.*]] = add nuw i8 [[START]], 2
35 ; CHECK-NEXT: [[F_2:%.*]] = icmp uge i8 [[START_2]], [[HIGH]]
36 ; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[RES_2]], false
37 ; CHECK-NEXT: [[SC_3:%.*]] = icmp sge i8 [[START_2]], [[HIGH]]
38 ; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[RES_3]], [[SC_3]]
39 ; CHECK-NEXT: [[SC_4:%.*]] = icmp sle i8 [[START_2]], [[START_1]]
40 ; CHECK-NEXT: [[RES_5:%.*]] = xor i1 [[RES_4]], [[SC_4]]
41 ; CHECK-NEXT: [[START_3:%.*]] = add nuw i8 [[START]], 3
42 ; CHECK-NEXT: [[F_3:%.*]] = icmp uge i8 [[START_3]], [[HIGH]]
43 ; CHECK-NEXT: [[RES_6:%.*]] = xor i1 [[RES_5]], false
44 ; CHECK-NEXT: [[SC_5:%.*]] = icmp sge i8 [[START_3]], [[START_1]]
45 ; CHECK-NEXT: [[RES_7:%.*]] = xor i1 [[RES_6]], [[SC_5]]
46 ; CHECK-NEXT: [[START_4:%.*]] = add nuw i8 [[START]], 4
47 ; CHECK-NEXT: [[UC_2:%.*]] = icmp uge i8 [[START_4]], [[HIGH]]
48 ; CHECK-NEXT: [[RES_8:%.*]] = xor i1 [[RES_7]], [[UC_2]]
49 ; CHECK-NEXT: [[SC_6:%.*]] = icmp sge i8 [[START_4]], [[START_1]]
50 ; CHECK-NEXT: [[RES_9:%.*]] = xor i1 [[RES_8]], [[SC_6]]
51 ; CHECK-NEXT: [[SC_7:%.*]] = icmp sge i8 [[START_4]], [[HIGH]]
52 ; CHECK-NEXT: [[RES_10:%.*]] = xor i1 [[RES_9]], [[SC_7]]
53 ; CHECK-NEXT: ret i1 [[RES_10]]
56 %add.ptr.i = add nuw i8 %start, 3
57 %c.1 = icmp uge i8 %add.ptr.i, %high
58 br i1 %c.1, label %if.then, label %if.else
62 %uc.3 = icmp ugt i8 %start, %high
63 %start.1.1 = add nuw i8 %start, 1
64 %uc.4 = icmp uge i8 %start.1.1, %high
65 %res.11 = xor i1 %uc.3, %uc.4
67 %start.3.1 = add nuw i8 %start, 3
68 %t.0 = icmp uge i8 %start.3.1, %high
69 %res.12 = xor i1 %res.11, %t.0
71 %uc.5 = icmp ugt i8 %start.3.1, %high
72 %res.13 = xor i1 %res.12, %uc.5
74 %sc.8 = icmp sge i8 %start.1.1, %high
75 %res.14 = xor i1 %res.13, %sc.8
77 %sc.9 = icmp sge i8 %start.3.1, %high
78 %res.15 = xor i1 %res.14, %sc.9
83 %f.0 = icmp ugt i8 %start, %high
84 %start.1 = add nuw i8 %start, 1
85 %f.1 = icmp uge i8 %start.1, %high
86 %res.0 = xor i1 %f.0, %f.1
88 %sc.1 = icmp sgt i8 %start, %high
89 %res.1 = xor i1 %res.0, %sc.1
91 %sc.2 = icmp sge i8 %start.1, %high
92 %res.2 = xor i1 %res.1, %sc.2
94 %start.2 = add nuw i8 %start, 2
95 %f.2 = icmp uge i8 %start.2, %high
96 %res.3 = xor i1 %res.2, %f.2
98 %sc.3 = icmp sge i8 %start.2, %high
99 %res.4 = xor i1 %res.3, %sc.3
101 %sc.4 = icmp sle i8 %start.2, %start.1
102 %res.5 = xor i1 %res.4, %sc.4
104 %start.3 = add nuw i8 %start, 3
105 %f.3 = icmp uge i8 %start.3, %high
106 %res.6 = xor i1 %res.5, %f.3
108 %sc.5 = icmp sge i8 %start.3, %start.1
109 %res.7 = xor i1 %res.6, %sc.5
111 %start.4 = add nuw i8 %start, 4
112 %uc.2 = icmp uge i8 %start.4, %high
113 %res.8 = xor i1 %res.7, %uc.2
115 %sc.6 = icmp sge i8 %start.4, %start.1
116 %res.9 = xor i1 %res.8, %sc.6
118 %sc.7 = icmp sge i8 %start.4, %high
119 %res.10 = xor i1 %res.9, %sc.7
124 define i1 @test_and_ule_sge(i32 %x, i32 %y, i32 %z, i32 %a) {
125 ; CHECK-LABEL: @test_and_ule_sge(
127 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
128 ; CHECK-NEXT: [[C_2:%.*]] = icmp sle i32 [[Y]], [[Z:%.*]]
129 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_2]]
130 ; CHECK-NEXT: br i1 [[AND]], label [[THEN:%.*]], label [[ELSE:%.*]]
132 ; CHECK-NEXT: [[UC_1:%.*]] = icmp ule i32 [[X]], [[Z]]
133 ; CHECK-NEXT: [[UC_2:%.*]] = icmp ule i32 [[X]], [[Y]]
134 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[UC_1]], true
135 ; CHECK-NEXT: [[UC_3:%.*]] = icmp ule i32 [[Y]], [[Z]]
136 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[UC_3]]
137 ; CHECK-NEXT: [[UC_4:%.*]] = icmp ule i32 [[X]], [[A:%.*]]
138 ; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[RES_2]], [[UC_4]]
139 ; CHECK-NEXT: [[SC_1:%.*]] = icmp sle i32 [[X]], [[Z]]
140 ; CHECK-NEXT: [[RES_5:%.*]] = xor i1 [[RES_4]], [[SC_1]]
141 ; CHECK-NEXT: [[SC_2:%.*]] = icmp sle i32 [[X]], [[Y]]
142 ; CHECK-NEXT: [[RES_6:%.*]] = xor i1 [[RES_5]], [[SC_2]]
143 ; CHECK-NEXT: [[SC_3:%.*]] = icmp sle i32 [[Y]], [[Z]]
144 ; CHECK-NEXT: [[RES_7:%.*]] = xor i1 [[RES_6]], [[SC_3]]
145 ; CHECK-NEXT: [[SC_4:%.*]] = icmp sle i32 [[X]], [[A]]
146 ; CHECK-NEXT: [[RES_8:%.*]] = xor i1 [[RES_7]], [[SC_4]]
147 ; CHECK-NEXT: ret i1 [[RES_8]]
149 ; CHECK-NEXT: [[UC_5:%.*]] = icmp ule i32 [[X]], [[Z]]
150 ; CHECK-NEXT: [[UC_6:%.*]] = icmp ule i32 [[X]], [[A]]
151 ; CHECK-NEXT: [[RES_9:%.*]] = xor i1 [[UC_5]], [[UC_6]]
152 ; CHECK-NEXT: [[UC_7:%.*]] = icmp ule i32 [[X]], [[Y]]
153 ; CHECK-NEXT: [[RES_10:%.*]] = xor i1 [[RES_9]], [[UC_7]]
154 ; CHECK-NEXT: [[UC_8:%.*]] = icmp ule i32 [[Y]], [[Z]]
155 ; CHECK-NEXT: [[RES_11:%.*]] = xor i1 [[RES_10]], [[UC_8]]
156 ; CHECK-NEXT: [[SC_5:%.*]] = icmp sle i32 [[X]], [[Z]]
157 ; CHECK-NEXT: [[RES_12:%.*]] = xor i1 [[RES_11]], [[SC_5]]
158 ; CHECK-NEXT: [[SC_6:%.*]] = icmp sle i32 [[X]], [[A]]
159 ; CHECK-NEXT: [[RES_13:%.*]] = xor i1 [[RES_12]], [[SC_6]]
160 ; CHECK-NEXT: [[SC_7:%.*]] = icmp sle i32 [[X]], [[Y]]
161 ; CHECK-NEXT: [[RES_14:%.*]] = xor i1 [[RES_13]], [[SC_7]]
162 ; CHECK-NEXT: [[SC_8:%.*]] = icmp sle i32 [[Y]], [[Z]]
163 ; CHECK-NEXT: [[RES_15:%.*]] = xor i1 [[RES_14]], [[SC_8]]
164 ; CHECK-NEXT: ret i1 [[RES_15]]
167 %c.1 = icmp ule i32 %x, %y
168 %c.2 = icmp sle i32 %y, %z
169 %and = and i1 %c.1, %c.2
170 br i1 %and, label %then, label %else
173 %uc.1 = icmp ule i32 %x, %z
174 %uc.2 = icmp ule i32 %x, %y
175 %res.1 = xor i1 %uc.1, %uc.2
177 %uc.3 = icmp ule i32 %y, %z
178 %res.2 = xor i1 %res.1, %uc.3
180 %uc.4 = icmp ule i32 %x, %a
181 %res.4 = xor i1 %res.2, %uc.4
183 %sc.1 = icmp sle i32 %x, %z
184 %res.5 = xor i1 %res.4, %sc.1
186 %sc.2 = icmp sle i32 %x, %y
187 %res.6 = xor i1 %res.5, %sc.2
189 %sc.3 = icmp sle i32 %y, %z
190 %res.7 = xor i1 %res.6, %sc.3
192 %sc.4 = icmp sle i32 %x, %a
193 %res.8 = xor i1 %res.7, %sc.4
198 %uc.5 = icmp ule i32 %x, %z
199 %uc.6 = icmp ule i32 %x, %a
200 %res.9 = xor i1 %uc.5, %uc.6
202 %uc.7 = icmp ule i32 %x, %y
203 %res.10 = xor i1 %res.9, %uc.7
205 %uc.8 = icmp ule i32 %y, %z
206 %res.11 = xor i1 %res.10, %uc.8
208 %sc.5 = icmp sle i32 %x, %z
209 %res.12 = xor i1 %res.11, %sc.5
211 %sc.6 = icmp sle i32 %x, %a
212 %res.13 = xor i1 %res.12, %sc.6
214 %sc.7 = icmp sle i32 %x, %y
215 %res.14 = xor i1 %res.13, %sc.7
217 %sc.8 = icmp sle i32 %y, %z
218 %res.15 = xor i1 %res.14, %sc.8