1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -simplifycfg -S < %s | FileCheck %s
4 %struct.Counters = type { i64, i64, i64, [8 x i8] }
6 @m = global i64 3, align 8
7 @counters = global %struct.Counters zeroinitializer, align 16
9 define i32 @align_both_equal() local_unnamed_addr {
10 ; CHECK-LABEL: @align_both_equal(
12 ; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
13 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1>
14 ; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
15 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8
16 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1
17 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0
18 ; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2>
19 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]]
20 ; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2
21 ; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0
22 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1>
23 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]]
24 ; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true
25 ; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true
26 ; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
27 ; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]]
28 ; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
29 ; CHECK-NEXT: br label [[TMP10]]
33 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
34 %1 = add nsw <2 x i64> %0, <i64 1, i64 1>
35 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
36 %2 = load i64, i64* @m, align 8
38 %tobool = icmp eq i64 %and, 0
39 br i1 %tobool, label %if.end, label %if.then
41 if.then: ; preds = %entry
42 %3 = add nsw <2 x i64> %0, <i64 2, i64 2>
43 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
46 if.end: ; preds = %entry, %if.then
47 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ]
49 %tobool5 = icmp eq i64 %and4, 0
50 br i1 %tobool5, label %if.end9, label %if.then6
52 if.then6: ; preds = %if.end
53 %5 = add nsw <2 x i64> %4, <i64 1, i64 1>
54 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
57 if.end9: ; preds = %if.end, %if.then6
61 define i32 @align_not_equal() local_unnamed_addr {
62 ; CHECK-LABEL: @align_not_equal(
64 ; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
65 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1>
66 ; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
67 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8
68 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1
69 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0
70 ; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2>
71 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]]
72 ; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2
73 ; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0
74 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1>
75 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]]
76 ; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true
77 ; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true
78 ; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
79 ; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]]
80 ; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
81 ; CHECK-NEXT: br label [[TMP10]]
85 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
86 %1 = add nsw <2 x i64> %0, <i64 1, i64 1>
87 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
88 %2 = load i64, i64* @m, align 8
90 %tobool = icmp eq i64 %and, 0
91 br i1 %tobool, label %if.end, label %if.then
93 if.then: ; preds = %entry
94 %3 = add nsw <2 x i64> %0, <i64 2, i64 2>
95 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 16
98 if.end: ; preds = %entry, %if.then
99 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ]
100 %and4 = and i64 %2, 2
101 %tobool5 = icmp eq i64 %and4, 0
102 br i1 %tobool5, label %if.end9, label %if.then6
104 if.then6: ; preds = %if.end
105 %5 = add nsw <2 x i64> %4, <i64 1, i64 1>
106 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
109 if.end9: ; preds = %if.end, %if.then6
113 define i32 @align_single_zero() local_unnamed_addr {
114 ; CHECK-LABEL: @align_single_zero(
116 ; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
117 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1>
118 ; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
119 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8
120 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1
121 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0
122 ; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2>
123 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]]
124 ; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2
125 ; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0
126 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1>
127 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]]
128 ; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true
129 ; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true
130 ; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
131 ; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]]
132 ; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
133 ; CHECK-NEXT: br label [[TMP10]]
137 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
138 %1 = add nsw <2 x i64> %0, <i64 1, i64 1>
139 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
140 %2 = load i64, i64* @m, align 8
142 %tobool = icmp eq i64 %and, 0
143 br i1 %tobool, label %if.end, label %if.then
145 if.then: ; preds = %entry
146 %3 = add nsw <2 x i64> %0, <i64 2, i64 2>
147 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*)
150 if.end: ; preds = %entry, %if.then
151 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ]
152 %and4 = and i64 %2, 2
153 %tobool5 = icmp eq i64 %and4, 0
154 br i1 %tobool5, label %if.end9, label %if.then6
156 if.then6: ; preds = %if.end
157 %5 = add nsw <2 x i64> %4, <i64 1, i64 1>
158 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
161 if.end9: ; preds = %if.end, %if.then6
165 define i32 @align_single_zero_second_greater_default() local_unnamed_addr {
166 ; CHECK-LABEL: @align_single_zero_second_greater_default(
168 ; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
169 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1>
170 ; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
171 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8
172 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1
173 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0
174 ; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2>
175 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]]
176 ; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2
177 ; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0
178 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1>
179 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]]
180 ; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true
181 ; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true
182 ; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
183 ; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]]
184 ; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 16
185 ; CHECK-NEXT: br label [[TMP10]]
189 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
190 %1 = add nsw <2 x i64> %0, <i64 1, i64 1>
191 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
192 %2 = load i64, i64* @m, align 8
194 %tobool = icmp eq i64 %and, 0
195 br i1 %tobool, label %if.end, label %if.then
197 if.then: ; preds = %entry
198 %3 = add nsw <2 x i64> %0, <i64 2, i64 2>
199 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 32
202 if.end: ; preds = %entry, %if.then
203 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ]
204 %and4 = and i64 %2, 2
205 %tobool5 = icmp eq i64 %and4, 0
206 br i1 %tobool5, label %if.end9, label %if.then6
208 if.then6: ; preds = %if.end
209 %5 = add nsw <2 x i64> %4, <i64 1, i64 1>
210 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*)
213 if.end9: ; preds = %if.end, %if.then6
217 define i32 @align_both_zero() local_unnamed_addr {
218 ; CHECK-LABEL: @align_both_zero(
220 ; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
221 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1>
222 ; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
223 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8
224 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1
225 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0
226 ; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2>
227 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]]
228 ; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2
229 ; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0
230 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1>
231 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]]
232 ; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true
233 ; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true
234 ; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
235 ; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]]
236 ; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 16
237 ; CHECK-NEXT: br label [[TMP10]]
241 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
242 %1 = add nsw <2 x i64> %0, <i64 1, i64 1>
243 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
244 %2 = load i64, i64* @m, align 8
246 %tobool = icmp eq i64 %and, 0
247 br i1 %tobool, label %if.end, label %if.then
249 if.then: ; preds = %entry
250 %3 = add nsw <2 x i64> %0, <i64 2, i64 2>
251 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*)
254 if.end: ; preds = %entry, %if.then
255 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ]
256 %and4 = and i64 %2, 2
257 %tobool5 = icmp eq i64 %and4, 0
258 br i1 %tobool5, label %if.end9, label %if.then6
260 if.then6: ; preds = %if.end
261 %5 = add nsw <2 x i64> %4, <i64 1, i64 1>
262 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*)
265 if.end9: ; preds = %if.end, %if.then6