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
39 ; AIX32-LABEL: name: test1
41 ; AIX32-NEXT: successors: %bb.1(0x80000000)
42 ; AIX32-NEXT: liveins: $r3
44 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc = COPY $r3
45 ; AIX32-NEXT: [[LI:%[0-9]+]]:gprc = LI 2048
46 ; AIX32-NEXT: MTCTRloop killed [[LI]], implicit-def dead $ctr
48 ; AIX32-NEXT: bb.1.for.body:
49 ; AIX32-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
51 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc_and_gprc_nor0 = LWZtoc @a, $r2 :: (load (s32) from got)
52 ; AIX32-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LWZtoc]] :: (volatile dereferenceable load (s32) from @a)
53 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY]]
54 ; AIX32-NEXT: STW killed [[ADD4_]], 0, [[LWZtoc]] :: (volatile store (s32) into @a)
55 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
56 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.1
59 ; AIX32-NEXT: bb.2.for.end:
60 ; AIX32-NEXT: BLR implicit $lr, implicit $rm
62 ; LE64-LABEL: name: test1
64 ; LE64-NEXT: successors: %bb.1(0x80000000)
65 ; LE64-NEXT: liveins: $x3
67 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x3
68 ; LE64-NEXT: [[COPY1:%[0-9]+]]:gprc = COPY [[COPY]].sub_32
69 ; LE64-NEXT: [[LI8_:%[0-9]+]]:g8rc = LI8 2048
70 ; LE64-NEXT: MTCTR8loop killed [[LI8_]], implicit-def dead $ctr8
72 ; LE64-NEXT: bb.1.for.body:
73 ; LE64-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
75 ; LE64-NEXT: [[ADDIStocHA8_:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
76 ; LE64-NEXT: [[LDtocL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtocL @a, killed [[ADDIStocHA8_]] :: (load (s64) from got)
77 ; LE64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtocL]] :: (volatile dereferenceable load (s32) from @a)
78 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY1]]
79 ; LE64-NEXT: STW killed [[ADD4_]], 0, [[LDtocL]] :: (volatile store (s32) into @a)
80 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
81 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.1
84 ; LE64-NEXT: bb.2.for.end:
85 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm
89 for.body: ; preds = %for.body, %entry
90 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
91 %0 = load volatile i32, ptr @a, align 4
92 %add = add nsw i32 %0, %c
93 store volatile i32 %add, ptr @a, align 4
94 %inc = add nsw i32 %i.01, 1
95 %exitcond = icmp eq i32 %inc, 2048
96 br i1 %exitcond, label %for.end, label %for.body
98 for.end: ; preds = %for.body
102 define void @test2(i32 %c, i32 %d) nounwind {
103 ; AIX64-LABEL: name: test2
105 ; AIX64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
106 ; AIX64-NEXT: liveins: $x3, $x4
108 ; AIX64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
109 ; AIX64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
110 ; AIX64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
111 ; AIX64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
112 ; AIX64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
113 ; AIX64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
114 ; AIX64-NEXT: B %bb.1
116 ; AIX64-NEXT: bb.1.for.body.preheader:
117 ; AIX64-NEXT: successors: %bb.2(0x80000000)
119 ; AIX64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
120 ; AIX64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
121 ; AIX64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
122 ; AIX64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
123 ; AIX64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
124 ; AIX64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
126 ; AIX64-NEXT: bb.2.for.body:
127 ; AIX64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
129 ; AIX64-NEXT: [[LDtoc:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtoc @a, $x2 :: (load (s64) from got)
130 ; AIX64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtoc]] :: (volatile dereferenceable load (s32) from @a)
131 ; AIX64-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY2]]
132 ; AIX64-NEXT: STW killed [[ADD4_]], 0, [[LDtoc]] :: (volatile store (s32) into @a)
133 ; AIX64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
134 ; AIX64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
135 ; AIX64-NEXT: B %bb.3
137 ; AIX64-NEXT: bb.3.for.end:
138 ; AIX64-NEXT: BLR8 implicit $lr8, implicit $rm
140 ; AIX32-LABEL: name: test2
142 ; AIX32-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
143 ; AIX32-NEXT: liveins: $r3, $r4
145 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc = COPY $r4
146 ; AIX32-NEXT: [[COPY1:%[0-9]+]]:gprc = COPY $r3
147 ; AIX32-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY]], 1
148 ; AIX32-NEXT: BCC 12, killed [[CMPWI]], %bb.3
149 ; AIX32-NEXT: B %bb.1
151 ; AIX32-NEXT: bb.1.for.body.preheader:
152 ; AIX32-NEXT: successors: %bb.2(0x80000000)
154 ; AIX32-NEXT: MTCTRloop [[COPY]], implicit-def dead $ctr
156 ; AIX32-NEXT: bb.2.for.body:
157 ; AIX32-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
159 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc_and_gprc_nor0 = LWZtoc @a, $r2 :: (load (s32) from got)
160 ; AIX32-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LWZtoc]] :: (volatile dereferenceable load (s32) from @a)
161 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY1]]
162 ; AIX32-NEXT: STW killed [[ADD4_]], 0, [[LWZtoc]] :: (volatile store (s32) into @a)
163 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
164 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.2
165 ; AIX32-NEXT: B %bb.3
167 ; AIX32-NEXT: bb.3.for.end:
168 ; AIX32-NEXT: BLR implicit $lr, implicit $rm
170 ; LE64-LABEL: name: test2
172 ; LE64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
173 ; LE64-NEXT: liveins: $x3, $x4
175 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
176 ; LE64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
177 ; LE64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
178 ; LE64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
179 ; LE64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
180 ; LE64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
183 ; LE64-NEXT: bb.1.for.body.preheader:
184 ; LE64-NEXT: successors: %bb.2(0x80000000)
186 ; LE64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
187 ; LE64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
188 ; LE64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
189 ; LE64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
190 ; LE64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
191 ; LE64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
193 ; LE64-NEXT: bb.2.for.body:
194 ; LE64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
196 ; LE64-NEXT: [[ADDIStocHA8_:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
197 ; LE64-NEXT: [[LDtocL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtocL @a, killed [[ADDIStocHA8_]] :: (load (s64) from got)
198 ; LE64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtocL]] :: (volatile dereferenceable load (s32) from @a)
199 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = nsw ADD4 killed [[LWZ]], [[COPY2]]
200 ; LE64-NEXT: STW killed [[ADD4_]], 0, [[LDtocL]] :: (volatile store (s32) into @a)
201 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
202 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
205 ; LE64-NEXT: bb.3.for.end:
206 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm
208 %cmp1 = icmp sgt i32 %d, 0
209 br i1 %cmp1, label %for.body, label %for.end
211 for.body: ; preds = %entry, %for.body
212 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
213 %0 = load volatile i32, ptr @a, align 4
214 %add = add nsw i32 %0, %c
215 store volatile i32 %add, ptr @a, align 4
216 %inc = add nsw i32 %i.02, 1
217 %exitcond = icmp eq i32 %inc, %d
218 br i1 %exitcond, label %for.end, label %for.body
220 for.end: ; preds = %for.body, %entry
224 define void @test3(i32 %c, i32 %d) nounwind {
225 ; AIX64-LABEL: name: test3
227 ; AIX64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
228 ; AIX64-NEXT: liveins: $x3, $x4
230 ; AIX64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
231 ; AIX64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
232 ; AIX64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
233 ; AIX64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
234 ; AIX64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
235 ; AIX64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
236 ; AIX64-NEXT: B %bb.1
238 ; AIX64-NEXT: bb.1.for.body.preheader:
239 ; AIX64-NEXT: successors: %bb.2(0x80000000)
241 ; AIX64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
242 ; AIX64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
243 ; AIX64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
244 ; AIX64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
245 ; AIX64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
246 ; AIX64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
247 ; AIX64-NEXT: [[LI:%[0-9]+]]:gprc = LI 0
249 ; AIX64-NEXT: bb.2.for.body:
250 ; AIX64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
252 ; AIX64-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.1, %1, %bb.2
253 ; AIX64-NEXT: [[LDtoc:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtoc @a, $x2 :: (load (s64) from got)
254 ; AIX64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtoc]] :: (volatile dereferenceable load (s32) from @a)
255 ; AIX64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 [[PHI]], killed [[LWZ]]
256 ; AIX64-NEXT: STW killed [[ADD4_]], 0, [[LDtoc]] :: (volatile store (s32) into @a)
257 ; AIX64-NEXT: [[ADD4_1:%[0-9]+]]:gprc = ADD4 [[PHI]], [[COPY2]]
258 ; AIX64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
259 ; AIX64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
260 ; AIX64-NEXT: B %bb.3
262 ; AIX64-NEXT: bb.3.for.end:
263 ; AIX64-NEXT: BLR8 implicit $lr8, implicit $rm
265 ; AIX32-LABEL: name: test3
267 ; AIX32-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
268 ; AIX32-NEXT: liveins: $r3, $r4
270 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc = COPY $r4
271 ; AIX32-NEXT: [[COPY1:%[0-9]+]]:gprc = COPY $r3
272 ; AIX32-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY]], 1
273 ; AIX32-NEXT: BCC 12, killed [[CMPWI]], %bb.3
274 ; AIX32-NEXT: B %bb.1
276 ; AIX32-NEXT: bb.1.for.body.preheader:
277 ; AIX32-NEXT: successors: %bb.2(0x80000000)
279 ; AIX32-NEXT: MTCTRloop [[COPY]], implicit-def dead $ctr
280 ; AIX32-NEXT: [[LI:%[0-9]+]]:gprc = LI 0
282 ; AIX32-NEXT: bb.2.for.body:
283 ; AIX32-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
285 ; AIX32-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.1, %1, %bb.2
286 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc_and_gprc_nor0 = LWZtoc @a, $r2 :: (load (s32) from got)
287 ; AIX32-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LWZtoc]] :: (volatile dereferenceable load (s32) from @a)
288 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 [[PHI]], killed [[LWZ]]
289 ; AIX32-NEXT: STW killed [[ADD4_]], 0, [[LWZtoc]] :: (volatile store (s32) into @a)
290 ; AIX32-NEXT: [[ADD4_1:%[0-9]+]]:gprc = ADD4 [[PHI]], [[COPY1]]
291 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
292 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.2
293 ; AIX32-NEXT: B %bb.3
295 ; AIX32-NEXT: bb.3.for.end:
296 ; AIX32-NEXT: BLR implicit $lr, implicit $rm
298 ; LE64-LABEL: name: test3
300 ; LE64-NEXT: successors: %bb.1(0x50000000), %bb.3(0x30000000)
301 ; LE64-NEXT: liveins: $x3, $x4
303 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x4
304 ; LE64-NEXT: [[COPY1:%[0-9]+]]:g8rc = COPY $x3
305 ; LE64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[COPY1]].sub_32
306 ; LE64-NEXT: [[COPY3:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
307 ; LE64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY3]], 1
308 ; LE64-NEXT: BCC 12, killed [[CMPWI]], %bb.3
311 ; LE64-NEXT: bb.1.for.body.preheader:
312 ; LE64-NEXT: successors: %bb.2(0x80000000)
314 ; LE64-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI [[COPY3]], -1
315 ; LE64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
316 ; LE64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[ADDI]], %subreg.sub_32
317 ; LE64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
318 ; LE64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
319 ; LE64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
320 ; LE64-NEXT: [[LI:%[0-9]+]]:gprc = LI 0
322 ; LE64-NEXT: bb.2.for.body:
323 ; LE64-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
325 ; LE64-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.1, %1, %bb.2
326 ; LE64-NEXT: [[ADDIStocHA8_:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
327 ; LE64-NEXT: [[LDtocL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDtocL @a, killed [[ADDIStocHA8_]] :: (load (s64) from got)
328 ; LE64-NEXT: [[LWZ:%[0-9]+]]:gprc = LWZ 0, [[LDtocL]] :: (volatile dereferenceable load (s32) from @a)
329 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 [[PHI]], killed [[LWZ]]
330 ; LE64-NEXT: STW killed [[ADD4_]], 0, [[LDtocL]] :: (volatile store (s32) into @a)
331 ; LE64-NEXT: [[ADD4_1:%[0-9]+]]:gprc = ADD4 [[PHI]], [[COPY2]]
332 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
333 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.2
336 ; LE64-NEXT: bb.3.for.end:
337 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm
339 %cmp1 = icmp sgt i32 %d, 0
340 br i1 %cmp1, label %for.body, label %for.end
342 for.body: ; preds = %entry, %for.body
343 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
344 %mul = mul nsw i32 %i.02, %c
345 %0 = load volatile i32, ptr @a, align 4
346 %add = add nsw i32 %0, %mul
347 store volatile i32 %add, ptr @a, align 4
348 %inc = add nsw i32 %i.02, 1
349 %exitcond = icmp eq i32 %inc, %d
350 br i1 %exitcond, label %for.end, label %for.body
352 for.end: ; preds = %for.body, %entry
356 @tls_var = external thread_local global i8
358 define i32 @test4(i32 %inp) {
359 ; AIX64-LABEL: name: test4
361 ; AIX64-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
362 ; AIX64-NEXT: liveins: $x3
364 ; AIX64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x3
365 ; AIX64-NEXT: [[COPY1:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
366 ; AIX64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY1]], 1
367 ; AIX64-NEXT: [[LI:%[0-9]+]]:gprc_and_gprc_nor0 = LI 1
368 ; AIX64-NEXT: BCC 12, [[CMPWI]], %bb.4
370 ; AIX64-NEXT: bb.3.entry:
371 ; AIX64-NEXT: successors: %bb.4(0x80000000)
373 ; AIX64-NEXT: bb.4.entry:
374 ; AIX64-NEXT: successors: %bb.1(0x80000000)
376 ; AIX64-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.3, [[COPY1]], %bb.0
377 ; AIX64-NEXT: [[SUBF:%[0-9]+]]:gprc = SUBF [[PHI]], [[COPY1]]
378 ; AIX64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
379 ; AIX64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[SUBF]], %subreg.sub_32
380 ; AIX64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
381 ; AIX64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
382 ; AIX64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
384 ; AIX64-NEXT: bb.1.for.body:
385 ; AIX64-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
387 ; AIX64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
388 ; AIX64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.1
389 ; AIX64-NEXT: B %bb.2
391 ; AIX64-NEXT: bb.2.return:
392 ; AIX64-NEXT: [[LDtoc:%[0-9]+]]:g8rc = LDtoc target-flags(ppc-tlsgdm) @tls_var, $x2 :: (load (s64) from got)
393 ; AIX64-NEXT: [[LDtoc1:%[0-9]+]]:g8rc = LDtoc target-flags(ppc-tlsgd) @tls_var, $x2 :: (load (s64) from got)
394 ; AIX64-NEXT: [[TLSGDAIX8_:%[0-9]+]]:g8rc = TLSGDAIX8 killed [[LDtoc1]], killed [[LDtoc]]
395 ; AIX64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[TLSGDAIX8_]].sub_32
396 ; AIX64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 killed [[COPY2]], [[PHI]]
397 ; AIX64-NEXT: [[DEF1:%[0-9]+]]:g8rc = IMPLICIT_DEF
398 ; AIX64-NEXT: [[INSERT_SUBREG1:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF1]], killed [[ADD4_]], %subreg.sub_32
399 ; AIX64-NEXT: $x3 = COPY [[INSERT_SUBREG1]]
400 ; AIX64-NEXT: BLR8 implicit $lr8, implicit $rm, implicit $x3
402 ; AIX32-LABEL: name: test4
404 ; AIX32-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
405 ; AIX32-NEXT: liveins: $r3
407 ; AIX32-NEXT: [[COPY:%[0-9]+]]:gprc_and_gprc_nor0 = COPY $r3
408 ; AIX32-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY]], 1
409 ; AIX32-NEXT: [[LI:%[0-9]+]]:gprc_and_gprc_nor0 = LI 1
410 ; AIX32-NEXT: BCC 12, [[CMPWI]], %bb.4
412 ; AIX32-NEXT: bb.3.entry:
413 ; AIX32-NEXT: successors: %bb.4(0x80000000)
415 ; AIX32-NEXT: bb.4.entry:
416 ; AIX32-NEXT: successors: %bb.1(0x80000000)
418 ; AIX32-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.3, [[COPY]], %bb.0
419 ; AIX32-NEXT: [[SUBF:%[0-9]+]]:gprc_and_gprc_nor0 = SUBF [[PHI]], [[COPY]]
420 ; AIX32-NEXT: [[ADDI:%[0-9]+]]:gprc = ADDI killed [[SUBF]], 1
421 ; AIX32-NEXT: MTCTRloop killed [[ADDI]], implicit-def dead $ctr
423 ; AIX32-NEXT: bb.1.for.body:
424 ; AIX32-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
426 ; AIX32-NEXT: [[DecreaseCTRloop:%[0-9]+]]:crbitrc = DecreaseCTRloop 1, implicit-def dead $ctr, implicit $ctr
427 ; AIX32-NEXT: BC killed [[DecreaseCTRloop]], %bb.1
428 ; AIX32-NEXT: B %bb.2
430 ; AIX32-NEXT: bb.2.return:
431 ; AIX32-NEXT: [[LWZtoc:%[0-9]+]]:gprc = LWZtoc target-flags(ppc-tlsgdm) @tls_var, $r2 :: (load (s32) from got)
432 ; AIX32-NEXT: [[LWZtoc1:%[0-9]+]]:gprc = LWZtoc target-flags(ppc-tlsgd) @tls_var, $r2 :: (load (s32) from got)
433 ; AIX32-NEXT: [[TLSGDAIX:%[0-9]+]]:gprc = TLSGDAIX killed [[LWZtoc1]], killed [[LWZtoc]]
434 ; AIX32-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 killed [[TLSGDAIX]], [[PHI]]
435 ; AIX32-NEXT: $r3 = COPY [[ADD4_]]
436 ; AIX32-NEXT: BLR implicit $lr, implicit $rm, implicit $r3
438 ; LE64-LABEL: name: test4
440 ; LE64-NEXT: successors: %bb.1(0x80000000)
441 ; LE64-NEXT: liveins: $x3
443 ; LE64-NEXT: [[COPY:%[0-9]+]]:g8rc = COPY $x3
444 ; LE64-NEXT: [[COPY1:%[0-9]+]]:gprc_and_gprc_nor0 = COPY [[COPY]].sub_32
445 ; LE64-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[COPY1]], 1
446 ; LE64-NEXT: [[LI:%[0-9]+]]:gprc_and_gprc_nor0 = LI 1
447 ; LE64-NEXT: [[ISEL:%[0-9]+]]:gprc = ISEL [[COPY1]], [[LI]], [[CMPWI]].sub_lt
448 ; LE64-NEXT: [[SUBF:%[0-9]+]]:gprc = SUBF [[ISEL]], [[COPY1]]
449 ; LE64-NEXT: [[DEF:%[0-9]+]]:g8rc = IMPLICIT_DEF
450 ; LE64-NEXT: [[INSERT_SUBREG:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF]], killed [[SUBF]], %subreg.sub_32
451 ; LE64-NEXT: [[RLDICL:%[0-9]+]]:g8rc_and_g8rc_nox0 = RLDICL killed [[INSERT_SUBREG]], 0, 32
452 ; LE64-NEXT: [[ADDI8_:%[0-9]+]]:g8rc = nuw nsw ADDI8 killed [[RLDICL]], 1
453 ; LE64-NEXT: MTCTR8loop killed [[ADDI8_]], implicit-def dead $ctr8
455 ; LE64-NEXT: bb.1.for.body:
456 ; LE64-NEXT: successors: %bb.1(0x7c000000), %bb.2(0x04000000)
458 ; LE64-NEXT: [[DecreaseCTR8loop:%[0-9]+]]:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
459 ; LE64-NEXT: BC killed [[DecreaseCTR8loop]], %bb.1
462 ; LE64-NEXT: bb.2.return:
463 ; LE64-NEXT: [[ADDISgotTprelHA:%[0-9]+]]:g8rc_and_g8rc_nox0 = ADDISgotTprelHA $x2, @tls_var
464 ; LE64-NEXT: [[LDgotTprelL:%[0-9]+]]:g8rc_and_g8rc_nox0 = LDgotTprelL @tls_var, killed [[ADDISgotTprelHA]]
465 ; LE64-NEXT: [[ADD8TLS:%[0-9]+]]:g8rc = ADD8TLS killed [[LDgotTprelL]], target-flags(ppc-tls) @tls_var
466 ; LE64-NEXT: [[COPY2:%[0-9]+]]:gprc = COPY [[ADD8TLS]].sub_32
467 ; LE64-NEXT: [[ADD4_:%[0-9]+]]:gprc = ADD4 killed [[COPY2]], [[ISEL]]
468 ; LE64-NEXT: [[DEF1:%[0-9]+]]:g8rc = IMPLICIT_DEF
469 ; LE64-NEXT: [[INSERT_SUBREG1:%[0-9]+]]:g8rc = INSERT_SUBREG [[DEF1]], killed [[ADD4_]], %subreg.sub_32
470 ; LE64-NEXT: $x3 = COPY [[INSERT_SUBREG1]]
471 ; LE64-NEXT: BLR8 implicit $lr8, implicit $rm, implicit $x3
475 for.body: ; preds = %for.body, %entry
476 %phi = phi i32 [ %dec, %for.body ], [ %inp, %entry ]
477 %load = ptrtoint ptr @tls_var to i32
478 %val = add i32 %load, %phi
479 %dec = add i32 %phi, -1
480 %cmp = icmp sgt i32 %phi, 1
481 br i1 %cmp, label %for.body, label %return
483 return: ; preds = %for.body