1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -verify-machineinstrs -stop-after=finalize-isel -mtriple=powerpc64-ibm-aix-xcoff \
3 ; RUN: -mcpu=pwr4 < %s | FileCheck -check-prefix=AIX64 %s
4 ; RUN: llc -verify-machineinstrs -stop-after=finalize-isel -mtriple=powerpc-ibm-aix-xcoff \
5 ; RUN: -mcpu=pwr4 < %s | FileCheck -check-prefix=AIX32 %s
6 ; RUN: llc -verify-machineinstrs -stop-after=finalize-isel -mtriple=powerpc64le-unknown-linux-gnu \
7 ; RUN: -mcpu=pwr8 < %s | FileCheck -check-prefix=LE64 %s
9 ;; This file is copied from test/CodeGen/PowerPC/ctrloops.ll.
10 ;; In this file, we are testing the CTR loops form after ISEL.
12 @a = common global i32 0, align 4
14 define void @test1(i32 %c) nounwind {
15 ; AIX64-LABEL: name: test1
17 ; AIX64-NEXT: successors: %bb.1(0x80000000)
18 ; AIX64-NEXT: liveins: $x3
20 ; AIX64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x3
21 ; AIX64-NEXT: [[COPY1:%[0-9]+]]:gprc = COPY [[COPY]].sub_32
22 ; AIX64-NEXT: [[LI8_:%[0-9]+]]:g8rc = LI8 2048
23 ; AIX64-NEXT: MTCTR8loop killed [[LI8_]], implicit-def dead $ctr8
25 ; AIX64-NEXT: bb.1.for.body:
26 ; AIX64-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
28 ; AIX64-NEXT: [[LDtoc:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtoc @a, $x2 :: (load (s64) from got)
29 ; AIX64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtoc]] :: (volatile dereferenceable load (s32) from @a)
30 ; AIX64-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY1]]
31 ; AIX64-NEXT: STW killed [[ADD4_]], 0, [[LDtoc]] :: (volatile store (s32) into @a)
32 ; AIX64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
33 ; AIX64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.1
36 ; AIX64-NEXT: bb.2.for.end:
37 ; AIX64-NEXT: BLR8 implicit $lr8, implicit $rm
38 ; AIX32-LABEL: name: test1
40 ; AIX32-NEXT: successors: %bb.1(0x80000000)
41 ; AIX32-NEXT: liveins: $r3
43 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc = COPY $r3
44 ; AIX32-NEXT: [[LI:%[0-9]+]]:gprc = LI 2048
45 ; AIX32-NEXT: MTCTRloop killed [[LI]], implicit-def dead $ctr
47 ; AIX32-NEXT: bb.1.for.body:
48 ; AIX32-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
50 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc_and_gprc_nor0 = LWZtoc @a, $r2 :: (load (s32) from got)
51 ; AIX32-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LWZtoc]] :: (volatile dereferenceable load (s32) from @a)
52 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY]]
53 ; AIX32-NEXT: STW killed [[ADD4_]], 0, [[LWZtoc]] :: (volatile store (s32) into @a)
54 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
55 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.1
58 ; AIX32-NEXT: bb.2.for.end:
59 ; AIX32-NEXT: BLR implicit $lr, implicit $rm
60 ; LE64-LABEL: name: test1
62 ; LE64-NEXT: successors: %bb.1(0x80000000)
63 ; LE64-NEXT: liveins: $x3
65 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x3
66 ; LE64-NEXT: [[COPY1:%[0-9]+]]:gprc = COPY [[COPY]].sub_32
67 ; LE64-NEXT: [[LI8_:%[0-9]+]]:g8rc = LI8 2048
68 ; LE64-NEXT: MTCTR8loop killed [[LI8_]], implicit-def dead $ctr8
70 ; LE64-NEXT: bb.1.for.body:
71 ; LE64-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
73 ; LE64-NEXT: [[ADDIStocHA8_:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
74 ; LE64-NEXT: [[LDtocL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtocL @a, killed [[ADDIStocHA8_]] :: (load (s64) from got)
75 ; LE64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtocL]] :: (volatile dereferenceable load (s32) from @a)
76 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY1]]
77 ; LE64-NEXT: STW killed [[ADD4_]], 0, [[LDtocL]] :: (volatile store (s32) into @a)
78 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
79 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.1
82 ; LE64-NEXT: bb.2.for.end:
83 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm
87 for.body: ; preds = %for.body, %entry
88 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
89 %0 = load volatile i32, ptr @a, align 4
90 %add = add nsw i32 %0, %c
91 store volatile i32 %add, ptr @a, align 4
92 %inc = add nsw i32 %i.01, 1
93 %exitcond = icmp eq i32 %inc, 2048
94 br i1 %exitcond, label %for.end, label %for.body
96 for.end: ; preds = %for.body
100 define void @test2(i32 %c, i32 %d) nounwind {
101 ; AIX64-LABEL: name: test2
103 ; AIX64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
104 ; AIX64-NEXT: liveins: $x3, $x4
106 ; AIX64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
107 ; AIX64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
108 ; AIX64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
109 ; AIX64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
110 ; AIX64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
111 ; AIX64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
112 ; AIX64-NEXT: B %bb.1
114 ; AIX64-NEXT: bb.1.for.body.preheader:
115 ; AIX64-NEXT: successors: %bb.2(0x80000000)
117 ; AIX64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
118 ; AIX64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
119 ; AIX64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
120 ; AIX64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
121 ; AIX64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
122 ; AIX64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
124 ; AIX64-NEXT: bb.2.for.body:
125 ; AIX64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
127 ; AIX64-NEXT: [[LDtoc:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtoc @a, $x2 :: (load (s64) from got)
128 ; AIX64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtoc]] :: (volatile dereferenceable load (s32) from @a)
129 ; AIX64-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY2]]
130 ; AIX64-NEXT: STW killed [[ADD4_]], 0, [[LDtoc]] :: (volatile store (s32) into @a)
131 ; AIX64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
132 ; AIX64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
133 ; AIX64-NEXT: B %bb.3
135 ; AIX64-NEXT: bb.3.for.end:
136 ; AIX64-NEXT: BLR8 implicit $lr8, implicit $rm
137 ; AIX32-LABEL: name: test2
139 ; AIX32-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
140 ; AIX32-NEXT: liveins: $r3, $r4
142 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc = COPY $r4
143 ; AIX32-NEXT: [[COPY1:%[0-9]+]]:gprc = COPY $r3
144 ; AIX32-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY]], 1
145 ; AIX32-NEXT: BCC 12, killed [[CMPWI]], %bb.3
146 ; AIX32-NEXT: B %bb.1
148 ; AIX32-NEXT: bb.1.for.body.preheader:
149 ; AIX32-NEXT: successors: %bb.2(0x80000000)
151 ; AIX32-NEXT: MTCTRloop [[COPY]], implicit-def dead $ctr
153 ; AIX32-NEXT: bb.2.for.body:
154 ; AIX32-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
156 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc_and_gprc_nor0 = LWZtoc @a, $r2 :: (load (s32) from got)
157 ; AIX32-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LWZtoc]] :: (volatile dereferenceable load (s32) from @a)
158 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY1]]
159 ; AIX32-NEXT: STW killed [[ADD4_]], 0, [[LWZtoc]] :: (volatile store (s32) into @a)
160 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
161 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.2
162 ; AIX32-NEXT: B %bb.3
164 ; AIX32-NEXT: bb.3.for.end:
165 ; AIX32-NEXT: BLR implicit $lr, implicit $rm
166 ; LE64-LABEL: name: test2
168 ; LE64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
169 ; LE64-NEXT: liveins: $x3, $x4
171 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
172 ; LE64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
173 ; LE64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
174 ; LE64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
175 ; LE64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
176 ; LE64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
179 ; LE64-NEXT: bb.1.for.body.preheader:
180 ; LE64-NEXT: successors: %bb.2(0x80000000)
182 ; LE64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
183 ; LE64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
184 ; LE64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
185 ; LE64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
186 ; LE64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
187 ; LE64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
189 ; LE64-NEXT: bb.2.for.body:
190 ; LE64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
192 ; LE64-NEXT: [[ADDIStocHA8_:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
193 ; LE64-NEXT: [[LDtocL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtocL @a, killed [[ADDIStocHA8_]] :: (load (s64) from got)
194 ; LE64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtocL]] :: (volatile dereferenceable load (s32) from @a)
195 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY2]]
196 ; LE64-NEXT: STW killed [[ADD4_]], 0, [[LDtocL]] :: (volatile store (s32) into @a)
197 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
198 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
201 ; LE64-NEXT: bb.3.for.end:
202 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm
204 %cmp1 = icmp sgt i32 %d, 0
205 br i1 %cmp1, label %for.body, label %for.end
207 for.body: ; preds = %entry, %for.body
208 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
209 %0 = load volatile i32, ptr @a, align 4
210 %add = add nsw i32 %0, %c
211 store volatile i32 %add, ptr @a, align 4
212 %inc = add nsw i32 %i.02, 1
213 %exitcond = icmp eq i32 %inc, %d
214 br i1 %exitcond, label %for.end, label %for.body
216 for.end: ; preds = %for.body, %entry
220 define void @test3(i32 %c, i32 %d) nounwind {
221 ; AIX64-LABEL: name: test3
223 ; AIX64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
224 ; AIX64-NEXT: liveins: $x3, $x4
226 ; AIX64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
227 ; AIX64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
228 ; AIX64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
229 ; AIX64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
230 ; AIX64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
231 ; AIX64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
232 ; AIX64-NEXT: B %bb.1
234 ; AIX64-NEXT: bb.1.for.body.preheader:
235 ; AIX64-NEXT: successors: %bb.2(0x80000000)
237 ; AIX64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
238 ; AIX64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
239 ; AIX64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
240 ; AIX64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
241 ; AIX64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
242 ; AIX64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
243 ; AIX64-NEXT: [[LI:%[0-9]+]]:gprc = LI 0
245 ; AIX64-NEXT: bb.2.for.body:
246 ; AIX64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
248 ; AIX64-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.1, %1, %bb.2
249 ; AIX64-NEXT: [[LDtoc:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtoc @a, $x2 :: (load (s64) from got)
250 ; AIX64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtoc]] :: (volatile dereferenceable load (s32) from @a)
251 ; AIX64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 [[PHI]], killed [[LWZ]]
252 ; AIX64-NEXT: STW killed [[ADD4_]], 0, [[LDtoc]] :: (volatile store (s32) into @a)
253 ; AIX64-NEXT: [[ADD4_1:%[0-9]+]]:gprc = ADD4 [[PHI]], [[COPY2]]
254 ; AIX64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
255 ; AIX64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
256 ; AIX64-NEXT: B %bb.3
258 ; AIX64-NEXT: bb.3.for.end:
259 ; AIX64-NEXT: BLR8 implicit $lr8, implicit $rm
260 ; AIX32-LABEL: name: test3
262 ; AIX32-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
263 ; AIX32-NEXT: liveins: $r3, $r4
265 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc = COPY $r4
266 ; AIX32-NEXT: [[COPY1:%[0-9]+]]:gprc = COPY $r3
267 ; AIX32-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY]], 1
268 ; AIX32-NEXT: BCC 12, killed [[CMPWI]], %bb.3
269 ; AIX32-NEXT: B %bb.1
271 ; AIX32-NEXT: bb.1.for.body.preheader:
272 ; AIX32-NEXT: successors: %bb.2(0x80000000)
274 ; AIX32-NEXT: MTCTRloop [[COPY]], implicit-def dead $ctr
275 ; AIX32-NEXT: [[LI:%[0-9]+]]:gprc = LI 0
277 ; AIX32-NEXT: bb.2.for.body:
278 ; AIX32-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
280 ; AIX32-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.1, %1, %bb.2
281 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc_and_gprc_nor0 = LWZtoc @a, $r2 :: (load (s32) from got)
282 ; AIX32-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LWZtoc]] :: (volatile dereferenceable load (s32) from @a)
283 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 [[PHI]], killed [[LWZ]]
284 ; AIX32-NEXT: STW killed [[ADD4_]], 0, [[LWZtoc]] :: (volatile store (s32) into @a)
285 ; AIX32-NEXT: [[ADD4_1:%[0-9]+]]:gprc = ADD4 [[PHI]], [[COPY1]]
286 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
287 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.2
288 ; AIX32-NEXT: B %bb.3
290 ; AIX32-NEXT: bb.3.for.end:
291 ; AIX32-NEXT: BLR implicit $lr, implicit $rm
292 ; LE64-LABEL: name: test3
294 ; LE64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
295 ; LE64-NEXT: liveins: $x3, $x4
297 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
298 ; LE64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
299 ; LE64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
300 ; LE64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
301 ; LE64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
302 ; LE64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
305 ; LE64-NEXT: bb.1.for.body.preheader:
306 ; LE64-NEXT: successors: %bb.2(0x80000000)
308 ; LE64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
309 ; LE64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
310 ; LE64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
311 ; LE64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
312 ; LE64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
313 ; LE64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
314 ; LE64-NEXT: [[LI:%[0-9]+]]:gprc = LI 0
316 ; LE64-NEXT: bb.2.for.body:
317 ; LE64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
319 ; LE64-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.1, %1, %bb.2
320 ; LE64-NEXT: [[ADDIStocHA8_:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
321 ; LE64-NEXT: [[LDtocL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtocL @a, killed [[ADDIStocHA8_]] :: (load (s64) from got)
322 ; LE64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtocL]] :: (volatile dereferenceable load (s32) from @a)
323 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 [[PHI]], killed [[LWZ]]
324 ; LE64-NEXT: STW killed [[ADD4_]], 0, [[LDtocL]] :: (volatile store (s32) into @a)
325 ; LE64-NEXT: [[ADD4_1:%[0-9]+]]:gprc = ADD4 [[PHI]], [[COPY2]]
326 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
327 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
330 ; LE64-NEXT: bb.3.for.end:
331 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm
333 %cmp1 = icmp sgt i32 %d, 0
334 br i1 %cmp1, label %for.body, label %for.end
336 for.body: ; preds = %entry, %for.body
337 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
338 %mul = mul nsw i32 %i.02, %c
339 %0 = load volatile i32, ptr @a, align 4
340 %add = add nsw i32 %0, %mul
341 store volatile i32 %add, ptr @a, align 4
342 %inc = add nsw i32 %i.02, 1
343 %exitcond = icmp eq i32 %inc, %d
344 br i1 %exitcond, label %for.end, label %for.body
346 for.end: ; preds = %for.body, %entry
350 @tls_var = external thread_local global i8
352 define i32 @test4(i32 %inp) {
353 ; AIX64-LABEL: name: test4
355 ; AIX64-NEXT: successors: %bb.1(0x80000000)
356 ; AIX64-NEXT: liveins: $x3
358 ; AIX64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x3
359 ; AIX64-NEXT: [[COPY1:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
360 ; AIX64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY1]], 1
361 ; AIX64-NEXT: [[LI:%[0-9]+]]:gprc_and_gprc_nor0 = LI 1
362 ; AIX64-NEXT: [[ISEL:%[0-9]+]]:gprc = ISEL [[COPY1]], [[LI]], [[CMPWI]].sub_lt
363 ; AIX64-NEXT: [[SUBF:%[0-9]+]]:gprc = SUBF [[ISEL]], [[COPY1]]
364 ; AIX64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
365 ; AIX64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[SUBF]], %subreg.sub_32
366 ; AIX64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
367 ; AIX64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
368 ; AIX64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
370 ; AIX64-NEXT: bb.1.for.body:
371 ; AIX64-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
373 ; AIX64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
374 ; AIX64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.1
375 ; AIX64-NEXT: B %bb.2
377 ; AIX64-NEXT: bb.2.return:
378 ; AIX64-NEXT: [[LDtoc:%[0-9]+]]:g8rc = LDtoc target-flags(ppc-lo) @tls_var, $x2 :: (load (s64) from got)
379 ; AIX64-NEXT: [[LDtoc1:%[0-9]+]]:g8rc = LDtoc target-flags(ppc-tlsgd) @tls_var, $x2 :: (load (s64) from got)
380 ; AIX64-NEXT: [[TLSGDAIX8_:%[0-9]+]]:g8rc = TLSGDAIX8 killed [[LDtoc1]], killed [[LDtoc]]
381 ; AIX64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[TLSGDAIX8_]].sub_32
382 ; AIX64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 killed [[COPY2]], [[ISEL]]
383 ; AIX64-NEXT: [[DEF1:%[0-9]+]]:g8rc = IMPLICIT_DEF
384 ; AIX64-NEXT: [[INSERT_SUBREG1:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF1]], killed [[ADD4_]], %subreg.sub_32
385 ; AIX64-NEXT: $x3 = COPY [[INSERT_SUBREG1]]
386 ; AIX64-NEXT: BLR8 implicit $lr8, implicit $rm, implicit $x3
387 ; AIX32-LABEL: name: test4
389 ; AIX32-NEXT: successors: %bb.1(0x80000000)
390 ; AIX32-NEXT: liveins: $r3
392 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc_and_gprc_nor0 = COPY $r3
393 ; AIX32-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY]], 1
394 ; AIX32-NEXT: [[LI:%[0-9]+]]:gprc_and_gprc_nor0 = LI 1
395 ; AIX32-NEXT: [[ISEL:%[0-9]+]]:gprc = ISEL [[COPY]], [[LI]], [[CMPWI]].sub_lt
396 ; AIX32-NEXT: [[SUBF:%[0-9]+]]:gprc_and_gprc_nor0 = SUBF [[ISEL]], [[COPY]]
397 ; AIX32-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI killed [[SUBF]], 1
398 ; AIX32-NEXT: MTCTRloop killed [[ADDI]], implicit-def dead $ctr
400 ; AIX32-NEXT: bb.1.for.body:
401 ; AIX32-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
403 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
404 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.1
405 ; AIX32-NEXT: B %bb.2
407 ; AIX32-NEXT: bb.2.return:
408 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc = LWZtoc target-flags(ppc-lo) @tls_var, $r2 :: (load (s32) from got)
409 ; AIX32-NEXT: [[LWZtoc1:%[0-9]+]]:gprc = LWZtoc target-flags(ppc-tlsgd) @tls_var, $r2 :: (load (s32) from got)
410 ; AIX32-NEXT: [[TLSGDAIX:%[0-9]+]]:gprc = TLSGDAIX killed [[LWZtoc1]], killed [[LWZtoc]]
411 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 killed [[TLSGDAIX]], [[ISEL]]
412 ; AIX32-NEXT: $r3 = COPY [[ADD4_]]
413 ; AIX32-NEXT: BLR implicit $lr, implicit $rm, implicit $r3
414 ; LE64-LABEL: name: test4
416 ; LE64-NEXT: successors: %bb.1(0x80000000)
417 ; LE64-NEXT: liveins: $x3
419 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x3
420 ; LE64-NEXT: [[COPY1:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
421 ; LE64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY1]], 1
422 ; LE64-NEXT: [[LI:%[0-9]+]]:gprc_and_gprc_nor0 = LI 1
423 ; LE64-NEXT: [[ISEL:%[0-9]+]]:gprc = ISEL [[COPY1]], [[LI]], [[CMPWI]].sub_lt
424 ; LE64-NEXT: [[SUBF:%[0-9]+]]:gprc = SUBF [[ISEL]], [[COPY1]]
425 ; LE64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
426 ; LE64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[SUBF]], %subreg.sub_32
427 ; LE64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
428 ; LE64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
429 ; LE64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
431 ; LE64-NEXT: bb.1.for.body:
432 ; LE64-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
434 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
435 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.1
438 ; LE64-NEXT: bb.2.return:
439 ; LE64-NEXT: [[ADDISgotTprelHA:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDISgotTprelHA $x2, @tls_var
440 ; LE64-NEXT: [[LDgotTprelL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDgotTprelL @tls_var, killed [[ADDISgotTprelHA]]
441 ; LE64-NEXT: [[ADD8TLS:%[0-9]+]]:g8rc = ADD8TLS killed [[LDgotTprelL]], target-flags(ppc-tls) @tls_var
442 ; LE64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[ADD8TLS]].sub_32
443 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 killed [[COPY2]], [[ISEL]]
444 ; LE64-NEXT: [[DEF1:%[0-9]+]]:g8rc = IMPLICIT_DEF
445 ; LE64-NEXT: [[INSERT_SUBREG1:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF1]], killed [[ADD4_]], %subreg.sub_32
446 ; LE64-NEXT: $x3 = COPY [[INSERT_SUBREG1]]
447 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm, implicit $x3
451 for.body: ; preds = %for.body, %entry
452 %phi = phi i32 [ %dec, %for.body ], [ %inp, %entry ]
453 %load = ptrtoint ptr @tls_var to i32
454 %val = add i32 %load, %phi
455 %dec = add i32 %phi, -1
456 %cmp = icmp sgt i32 %phi, 1
457 br i1 %cmp, label %for.body, label %return
459 return: ; preds = %for.body