phi-eliminate.mir
11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 %s -o - \
# RUN: -run-pass=livevars,phi-node-elimination | FileCheck %s
--- |
define void @phi_eliminate(i32 %0, i32 %1, i8* %2) {
%scevgep3 = getelementptr i8, i8* %2, i64 undef
call void @llvm.set.loop.iterations.i64(i64 undef)
br label %4
4: ; preds = %4, %3
%5 = phi i32 [ %8, %4 ], [ %0, %3 ]
%6 = phi i8* [ %scevgep3, %3 ], [ %7, %4 ]
%7 = getelementptr i8, i8* %6, i64 -1
%8 = sdiv i32 %5, %1
%9 = mul nsw i32 %8, %1
%10 = sub nsw i32 %5, %9
%11 = icmp ult i32 %10, 10
%12 = trunc i32 %10 to i8
%13 = select i1 %11, i8 48, i8 55
%14 = add i8 %13, %12
store i8 %14, i8* %7, align 1
%15 = call i1 @llvm.loop.decrement.i64(i64 1)
br i1 %15, label %4, label %16
16: ; preds = %4
ret void
}
declare void @llvm.set.loop.iterations.i64(i64)
declare i1 @llvm.loop.decrement.i64(i64)
declare void @llvm.stackprotector(i8*, i8**)
...
---
name: phi_eliminate
alignment: 16
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
failedISel: false
tracksRegLiveness: true
hasWinCFI: false
registers:
- { id: 0, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 1, class: gprc, preferred-register: '' }
- { id: 2, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 3, class: g8rc, preferred-register: '' }
- { id: 4, class: gprc, preferred-register: '' }
- { id: 5, class: g8rc, preferred-register: '' }
- { id: 6, class: g8rc, preferred-register: '' }
- { id: 7, class: g8rc, preferred-register: '' }
- { id: 8, class: gprc, preferred-register: '' }
- { id: 9, class: gprc, preferred-register: '' }
- { id: 10, class: g8rc, preferred-register: '' }
- { id: 11, class: gprc, preferred-register: '' }
- { id: 12, class: gprc, preferred-register: '' }
- { id: 13, class: crrc, preferred-register: '' }
- { id: 14, class: gprc_and_gprc_nor0, preferred-register: '' }
- { id: 15, class: gprc_and_gprc_nor0, preferred-register: '' }
- { id: 16, class: gprc, preferred-register: '' }
- { id: 17, class: gprc, preferred-register: '' }
- { id: 18, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 19, class: gprc, preferred-register: '' }
- { id: 20, class: gprc, preferred-register: '' }
- { id: 21, class: gprc, preferred-register: '' }
- { id: 22, class: crrc, preferred-register: '' }
- { id: 23, class: gprc, preferred-register: '' }
- { id: 24, class: gprc, preferred-register: '' }
- { id: 25, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 26, class: gprc, preferred-register: '' }
- { id: 27, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 28, class: gprc, preferred-register: '' }
- { id: 29, class: gprc, preferred-register: '' }
- { id: 30, class: gprc, preferred-register: '' }
- { id: 31, class: crrc, preferred-register: '' }
- { id: 32, class: gprc, preferred-register: '' }
- { id: 33, class: gprc, preferred-register: '' }
- { id: 34, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 35, class: gprc, preferred-register: '' }
- { id: 36, class: gprc, preferred-register: '' }
- { id: 37, class: gprc, preferred-register: '' }
- { id: 38, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 39, class: g8rc, preferred-register: '' }
- { id: 40, class: gprc, preferred-register: '' }
- { id: 41, class: gprc, preferred-register: '' }
- { id: 42, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 43, class: gprc, preferred-register: '' }
- { id: 44, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 45, class: gprc, preferred-register: '' }
- { id: 46, class: gprc, preferred-register: '' }
- { id: 47, class: crrc, preferred-register: '' }
- { id: 48, class: gprc, preferred-register: '' }
- { id: 49, class: gprc, preferred-register: '' }
- { id: 50, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 51, class: g8rc, preferred-register: '' }
- { id: 52, class: gprc, preferred-register: '' }
- { id: 53, class: gprc, preferred-register: '' }
- { id: 54, class: g8rc_and_g8rc_nox0, preferred-register: '' }
- { id: 55, class: gprc, preferred-register: '' }
- { id: 56, class: gprc, preferred-register: '' }
liveins:
- { reg: '$x3', virtual-reg: '%5' }
- { reg: '$x4', virtual-reg: '%6' }
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 0
offsetAdjustment: 0
maxAlignment: 1
adjustsStack: false
hasCalls: false
stackProtector: ''
maxCallFrameSize: 4294967295
cvBytesOfCalleeSavedRegisters: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
savePoint: ''
restorePoint: ''
fixedStack: []
stack: []
callSites: []
constants: []
machineFunctionInfo: {}
body: |
; CHECK-LABEL: name: phi_eliminate
; CHECK: bb.0 (%ir-block.3):
; CHECK: successors: %bb.1(0x80000000)
; CHECK: liveins: $x3, $x4
; CHECK: %6:g8rc = COPY killed $x4
; CHECK: %5:g8rc = COPY killed $x3
; CHECK: %9:gprc = COPY killed %6.sub_32
; CHECK: %8:gprc = COPY killed %5.sub_32
; CHECK: MTCTR8loop undef %10:g8rc, implicit-def dead $ctr8
; CHECK: %14:gprc_and_gprc_nor0 = LI 55
; CHECK: %15:gprc_and_gprc_nor0 = LI 48
; CHECK: bb.1 (%ir-block.4):
; CHECK: successors: %bb.2(0x40000000), %bb.7(0x40000000)
; CHECK: %19:gprc = DIVW %8, %9
; CHECK: BDNZ8 %bb.2, implicit-def $ctr8, implicit $ctr8
; CHECK: bb.7:
; CHECK: successors: %bb.5(0x80000000)
; CHECK: %61:gprc = COPY killed %8
; CHECK: %62:g8rc_and_g8rc_nox0 = IMPLICIT_DEF
; CHECK: %63:gprc = COPY killed %19
; CHECK: B %bb.5
; CHECK: bb.2 (%ir-block.4):
; CHECK: successors: %bb.3(0x40000000), %bb.4(0x40000000)
; CHECK: %20:gprc = nsw MULLW %19, %9
; CHECK: %21:gprc = SUBF killed %20, killed %8
; CHECK: %22:crrc = CMPLWI %21, 10
; CHECK: %23:gprc = ISEL %15, %14, killed %22.sub_lt
; CEHCK: %24:gprc = ADD4 killed %23, killed %21
; CHECK: %25:g8rc_and_g8rc_nox0 = STBU killed %24, -1, undef %0:g8rc_and_g8rc_nox0 :: (store 1 into %ir.7)
; CHECK: %26:gprc = DIVW %19, %9
; CHECK: %57:gprc = COPY killed %26
; CHECK: %58:gprc = COPY %19
; CHECK: %59:g8rc_and_g8rc_nox0 = COPY killed %25
; CHECK: %60:gprc = COPY killed %19
; CHECK: BDZ8 %bb.4, implicit-def $ctr8, implicit $ctr8
; CHECK: B %bb.3
; CHECK: bb.3 (%ir-block.4):
; CHECK: successors: %bb.3(0x7c000000), %bb.4(0x04000000)
; CHECK: %38:g8rc_and_g8rc_nox0 = COPY killed %59
; CHECK: %37:gprc = COPY %57
; CHECK: %36:gprc = COPY killed %58
; CHECK: %35:gprc = COPY killed %57
; CHECK: %27:g8rc_and_g8rc_nox0 = COPY killed %38
; CHECK: %56:gprc = COPY %35
; CHECK: %28:gprc = DIVW %56, %9
; CHECK: %29:gprc = nsw MULLW killed %37, %9
; CHECK: %30:gprc = SUBF killed %29, killed %36
; CHECK: %31:crrc = CMPLWI %30, 10
; CHECK: %32:gprc = ISEL %15, %14, killed %31.sub_lt
; CHECK: %33:gprc = ADD4 killed %32, killed %30
; CHECK: %34:g8rc_and_g8rc_nox0 = STBU killed %33, -1, killed %27 :: (store unknown-size into %ir.7, align 1)
; CHECK: %57:gprc = COPY killed %28
; CHECK: %58:gprc = COPY killed %35
; CHECK: %59:g8rc_and_g8rc_nox0 = COPY killed %34
; CHECK: %60:gprc = COPY killed %56
; CHECK: BDNZ8 %bb.3, implicit-def $ctr8, implicit $ctr8
; CHECK: B %bb.4
; CHECK: bb.4:
; CHECK: successors: %bb.5(0x80000000)
; CHECK: %44:g8rc_and_g8rc_nox0 = COPY killed %59
; CHECK: %43:gprc = COPY killed %57
; CHECK: %41:gprc = COPY killed %60
; CHECK: %39:g8rc = COPY killed %44
; CHECK: %61:gprc = COPY killed %41
; CHECK: %62:g8rc_and_g8rc_nox0 = COPY killed %39
; CHECK: %63:gprc = COPY killed %43
; CHECK: bb.5:
; CHECK: successors: %bb.6(0x80000000)
; CHECK: %55:gprc = COPY killed %63
; CHECK: %54:g8rc_and_g8rc_nox0 = COPY killed %62
; CHECK: %53:gprc = COPY killed %61
; CHECK: %45:gprc = nsw MULLW killed %55, killed %9
; CHECK: %46:gprc = SUBF killed %45, killed %53
; CHECK: %47:crrc = CMPLWI %46, 10
; CHECK: %48:gprc = ISEL killed %15, killed %14, killed %47.sub_lt
; CHECK: %49:gprc = ADD4 killed %48, killed %46
; CHECK: dead %50:g8rc_and_g8rc_nox0 = STBU killed %49, -1, killed %54 :: (store unknown-size into %ir.7, align 1)
; CHECK: B %bb.6
; CHECK: bb.6 (%ir-block.16):
; CHECK: BLR8 implicit $lr8, implicit $rm
bb.0 (%ir-block.3):
successors: %bb.1(0x80000000)
liveins: $x3, $x4
%6:g8rc = COPY killed $x4
%5:g8rc = COPY killed $x3
%9:gprc = COPY killed %6.sub_32
%8:gprc = COPY killed %5.sub_32
MTCTR8loop undef %10:g8rc, implicit-def dead $ctr8
%14:gprc_and_gprc_nor0 = LI 55
%15:gprc_and_gprc_nor0 = LI 48
bb.1 (%ir-block.4):
successors: %bb.2(0x40000000), %bb.5(0x40000000)
%19:gprc = DIVW %8, %9
BDZ8 %bb.5, implicit-def $ctr8, implicit $ctr8
B %bb.2
bb.2 (%ir-block.4):
successors: %bb.3(0x40000000), %bb.4(0x40000000)
%20:gprc = nsw MULLW %19, %9
%21:gprc = SUBF killed %20, killed %8
%22:crrc = CMPLWI %21, 10
%23:gprc = ISEL %15, %14, killed %22.sub_lt
%24:gprc = ADD4 killed %23, killed %21
%25:g8rc_and_g8rc_nox0 = STBU killed %24, -1, undef %0:g8rc_and_g8rc_nox0 :: (store 1 into %ir.7)
%26:gprc = DIVW %19, %9
BDZ8 %bb.4, implicit-def $ctr8, implicit $ctr8
B %bb.3
bb.3 (%ir-block.4):
successors: %bb.3(0x7c000000), %bb.4(0x04000000)
%35:gprc = PHI %26, %bb.2, %28, %bb.3
%36:gprc = PHI %19, %bb.2, %35, %bb.3
%37:gprc = PHI %26, %bb.2, %28, %bb.3
%38:g8rc_and_g8rc_nox0 = PHI %25, %bb.2, %34, %bb.3
%27:g8rc_and_g8rc_nox0 = COPY killed %38
%56:gprc = COPY %35
%28:gprc = DIVW %56, %9
%29:gprc = nsw MULLW killed %37, %9
%30:gprc = SUBF killed %29, killed %36
%31:crrc = CMPLWI %30, 10
%32:gprc = ISEL %15, %14, killed %31.sub_lt
%33:gprc = ADD4 killed %32, killed %30
%34:g8rc_and_g8rc_nox0 = STBU killed %33, -1, killed %27 :: (store unknown-size into %ir.7, align 1)
BDNZ8 %bb.3, implicit-def $ctr8, implicit $ctr8
B %bb.4
bb.4:
successors: %bb.5(0x80000000)
%41:gprc = PHI %19, %bb.2, %56, %bb.3
%43:gprc = PHI %26, %bb.2, %28, %bb.3
%44:g8rc_and_g8rc_nox0 = PHI %25, %bb.2, %34, %bb.3
%39:g8rc = COPY killed %44
bb.5:
successors: %bb.6(0x80000000)
%53:gprc = PHI %8, %bb.1, %41, %bb.4
%54:g8rc_and_g8rc_nox0 = PHI undef %0:g8rc_and_g8rc_nox0, %bb.1, %39, %bb.4
%55:gprc = PHI %19, %bb.1, %43, %bb.4
%45:gprc = nsw MULLW killed %55, killed %9
%46:gprc = SUBF killed %45, killed %53
%47:crrc = CMPLWI %46, 10
%48:gprc = ISEL killed %15, killed %14, killed %47.sub_lt
%49:gprc = ADD4 killed %48, killed %46
dead %50:g8rc_and_g8rc_nox0 = STBU killed %49, -1, killed %54 :: (store unknown-size into %ir.7, align 1)
B %bb.6
bb.6 (%ir-block.16):
BLR8 implicit $lr8, implicit $rm
...