t2-teq-reduce.mir
12.1 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
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -run-pass=thumb2-reduce-size %s -o - | FileCheck %s
--- |
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv8m.main"
%list_head = type { %list_head*, %list_data* }
%list_data = type { i16, i16 }
define %list_head* @reg_reg_it_block(%list_head* %a, i16 zeroext %b) {
entry:
br label %while.begin
while.begin: ; preds = %while.body.end, %entry
%list.addr.i = phi %list_head* [ %ld.5, %while.body.end ], [ %a, %entry ]
%info.i = getelementptr inbounds %list_head, %list_head* %list.addr.i, i32 0, i32 1
%ld.0 = load %list_data*, %list_data** %info.i, align 4
%data16.i1 = bitcast %list_data* %ld.0 to i16*
%ld.1 = load i16, i16* %data16.i1, align 2
%xor.1 = xor i16 %ld.1, %b
%cmp.i = icmp eq i16 %xor.1, 0
br i1 %cmp.i, label %exit, label %while.body.a
while.body.a: ; preds = %while.begin
%next.i2 = bitcast %list_head* %list.addr.i to %list_head**
%ld.2 = load %list_head*, %list_head** %next.i2, align 4
%cmp.i.1 = icmp eq %list_head* %ld.2, null
br i1 %cmp.i.1, label %exit, label %it.block
it.block: ; preds = %while.body.a
%info.i.1 = getelementptr inbounds %list_head, %list_head* %ld.2, i32 0, i32 1
%ld.3 = load %list_data*, %list_data** %info.i.1, align 4
%data16.i.13 = bitcast %list_data* %ld.3 to i16*
%ld.4 = load i16, i16* %data16.i.13, align 2
%xor.2 = xor i16 %ld.4, %b
%cmp.i.2 = icmp eq i16 %xor.2, 0
br i1 %cmp.i.2, label %exit, label %while.body.end
while.body.end: ; preds = %it.block
%next.i.14 = bitcast %list_head* %ld.2 to %list_head**
%ld.5 = load %list_head*, %list_head** %next.i.14, align 4
%cmp.i.3 = icmp eq %list_head* %ld.5, null
br i1 %cmp.i.3, label %exit, label %while.begin
exit: ; preds = %while.body.end, %it.block, %while.body.a, %while.begin
%res = phi %list_head* [ %list.addr.i, %while.begin ], [ %ld.2, %while.body.a ], [ %ld.2, %it.block ], [ %ld.5, %while.body.end ]
ret %list_head* %res
}
define i16 @op_not_killed(%list_head* %a, i16 zeroext %b) {
entry:
br label %while.begin
while.begin: ; preds = %while.body.end, %entry
%list.addr.i = phi %list_head* [ %ld.5, %while.body.end ], [ %a, %entry ]
%info.i = getelementptr inbounds %list_head, %list_head* %list.addr.i, i32 0, i32 1
%ld.0 = load %list_data*, %list_data** %info.i, align 4
%data16.i1 = bitcast %list_data* %ld.0 to i16*
%ld.1 = load i16, i16* %data16.i1, align 2
%xor.1 = xor i16 %ld.1, %b
%cmp.i = icmp eq i16 %xor.1, 0
br i1 %cmp.i, label %exit, label %while.body.a
while.body.a: ; preds = %while.begin
%next.i2 = bitcast %list_head* %list.addr.i to %list_head**
%ld.2 = load %list_head*, %list_head** %next.i2, align 4
%cmp.i.1 = icmp eq %list_head* %ld.2, null
br i1 %cmp.i.1, label %exit, label %it.block
it.block: ; preds = %while.body.a
%info.i.1 = getelementptr inbounds %list_head, %list_head* %ld.2, i32 0, i32 1
%ld.3 = load %list_data*, %list_data** %info.i.1, align 4
%data16.i.13 = bitcast %list_data* %ld.3 to i16*
%ld.4 = load i16, i16* %data16.i.13, align 2
%xor.2 = xor i16 %ld.4, %b
%cmp.i.2 = icmp eq i16 %xor.2, 0
br i1 %cmp.i.2, label %exit, label %while.body.end
while.body.end: ; preds = %it.block
%next.i.14 = bitcast %list_head* %ld.2 to %list_head**
%ld.5 = load %list_head*, %list_head** %next.i.14, align 4
%cmp.i.3 = icmp eq %list_head* %ld.5, null
br i1 %cmp.i.3, label %exit, label %while.begin
exit: ; preds = %while.body.end, %it.block, %while.body.a, %while.begin
%res = phi i16 [ %ld.1, %while.begin ], [ %ld.1, %while.body.a ], [ %ld.4, %it.block ], [ %ld.4, %while.body.end ]
ret i16 %res
}
...
---
name: reg_reg_it_block
tracksRegLiveness: true
liveins:
- { reg: '$r0', virtual-reg: '' }
- { reg: '$r1', virtual-reg: '' }
body: |
; CHECK-LABEL: name: reg_reg_it_block
; CHECK: bb.0.entry:
; CHECK: successors: %bb.2(0x80000000)
; CHECK: liveins: $r0, $r1
; CHECK: t2B %bb.2, 14 /* CC::al */, $noreg
; CHECK: bb.1.while.body.end:
; CHECK: successors: %bb.2(0x80000000)
; CHECK: liveins: $r0, $r1
; CHECK: renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load 4 from %ir.next.i.14)
; CHECK: tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
; CHECK: BUNDLE implicit-def dead $itstate, implicit killed $cpsr, implicit $r0 {
; CHECK: t2IT 0, 8, implicit-def $itstate
; CHECK: tBX_RET 0 /* CC::eq */, killed $cpsr, implicit $r0, implicit internal killed $itstate
; CHECK: }
; CHECK: bb.2.while.begin:
; CHECK: successors: %bb.4(0x04000000), %bb.3(0x7c000000)
; CHECK: liveins: $r0, $r1
; CHECK: renamable $r2 = tLDRi renamable $r0, 1, 14 /* CC::al */, $noreg :: (load 4 from %ir.info.i)
; CHECK: renamable $r2 = tLDRHi killed renamable $r2, 0, 14 /* CC::al */, $noreg :: (load 2 from %ir.data16.i1)
; CHECK: dead renamable $r2, $cpsr = tEOR killed renamable $r2, renamable $r1, 14 /* CC::al */, $noreg
; CHECK: t2Bcc %bb.4, 0 /* CC::eq */, killed $cpsr
; CHECK: bb.3.while.body.a:
; CHECK: successors: %bb.4(0x4207fef8), %bb.1(0x3df80108)
; CHECK: liveins: $r0, $r1
; CHECK: renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load 4 from %ir.next.i2)
; CHECK: tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
; CHECK: BUNDLE implicit-def dead $itstate, implicit-def dead $r2, implicit-def $cpsr, implicit $r0, implicit killed $cpsr, implicit $r1 {
; CHECK: t2IT 1, 30, implicit-def $itstate
; CHECK: renamable $r2 = tLDRi renamable $r0, 1, 1 /* CC::ne */, $cpsr, implicit internal $itstate :: (load 4 from %ir.info.i.1)
; CHECK: renamable $r2 = tLDRHi internal killed renamable $r2, 0, 1 /* CC::ne */, $cpsr, implicit internal killed $r2, implicit internal $itstate :: (load 2 from %ir.data16.i.13)
; CHECK: t2TEQrr internal killed renamable $r2, renamable $r1, 1 /* CC::ne */, killed $cpsr, implicit-def $cpsr, implicit internal killed $itstate
; CHECK: }
; CHECK: t2Bcc %bb.1, 1 /* CC::ne */, killed $cpsr
; CHECK: bb.4.exit:
; CHECK: liveins: $r0
; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
bb.0.entry:
successors: %bb.1(0x80000000)
liveins: $r0, $r1
t2B %bb.1, 14, $noreg
bb.3.while.body.end:
successors: %bb.1(0x80000000)
liveins: $r0, $r1
renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load 4 from %ir.next.i.14)
tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
BUNDLE implicit-def dead $itstate, implicit killed $cpsr, implicit $r0 {
t2IT 0, 8, implicit-def $itstate
tBX_RET 0, killed $cpsr, implicit $r0, implicit internal killed $itstate
}
bb.1.while.begin:
successors: %bb.4(0x04000000), %bb.2(0x7c000000)
liveins: $r0, $r1
renamable $r2 = tLDRi renamable $r0, 1, 14, $noreg :: (load 4 from %ir.info.i)
renamable $r2 = tLDRHi killed renamable $r2, 0, 14, $noreg :: (load 2 from %ir.data16.i1)
dead renamable $r2, $cpsr = tEOR killed renamable $r2, renamable $r1, 14, $noreg
t2Bcc %bb.4, 0, killed $cpsr
bb.2.while.body.a:
successors: %bb.4(0x80000000), %bb.3(0x78200000)
liveins: $r0, $r1
renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load 4 from %ir.next.i2)
tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
BUNDLE implicit-def dead $itstate, implicit-def dead $r2, implicit-def $cpsr, implicit $r0, implicit killed $cpsr, implicit $r1 {
t2IT 1, 30, implicit-def $itstate
renamable $r2 = tLDRi renamable $r0, 1, 1, $cpsr, implicit internal $itstate :: (load 4 from %ir.info.i.1)
renamable $r2 = tLDRHi internal killed renamable $r2, 0, 1, $cpsr, implicit internal killed $r2, implicit internal $itstate :: (load 2 from %ir.data16.i.13)
t2TEQrr internal killed renamable $r2, renamable $r1, 1, killed $cpsr, implicit-def $cpsr, implicit internal killed $itstate
}
t2Bcc %bb.3, 1, killed $cpsr
bb.4.exit:
liveins: $r0
tBX_RET 14, $noreg, implicit killed $r0
...
---
name: op_not_killed
tracksRegLiveness: true
liveins:
- { reg: '$r0', virtual-reg: '' }
- { reg: '$r1', virtual-reg: '' }
body: |
; CHECK-LABEL: name: op_not_killed
; CHECK: bb.0.entry:
; CHECK: successors: %bb.1(0x80000000)
; CHECK: liveins: $r0, $r1
; CHECK: $r2 = tMOVr $r0, 14 /* CC::al */, $noreg
; CHECK: bb.1.while.begin:
; CHECK: successors: %bb.5(0x04000000), %bb.2(0x7c000000)
; CHECK: liveins: $r1, $r2
; CHECK: renamable $r0 = tLDRi renamable $r2, 1, 14 /* CC::al */, $noreg :: (load 4 from %ir.info.i)
; CHECK: renamable $r0 = tLDRHi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load 2 from %ir.data16.i1)
; CHECK: t2TEQrr renamable $r0, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
; CHECK: t2Bcc %bb.5, 0 /* CC::eq */, killed $cpsr
; CHECK: bb.2.while.body.a:
; CHECK: successors: %bb.5(0x04000000), %bb.3(0x7c000000)
; CHECK: liveins: $r0, $r1, $r2
; CHECK: renamable $r2 = tLDRi killed renamable $r2, 0, 14 /* CC::al */, $noreg :: (load 4 from %ir.next.i2)
; CHECK: tCMPi8 renamable $r2, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
; CHECK: t2Bcc %bb.5, 0 /* CC::eq */, killed $cpsr
; CHECK: bb.3.it.block:
; CHECK: successors: %bb.5(0x04000000), %bb.4(0x7c000000)
; CHECK: liveins: $r1, $r2
; CHECK: renamable $r0 = tLDRi renamable $r2, 1, 14 /* CC::al */, $noreg :: (load 4 from %ir.info.i.1)
; CHECK: renamable $r0 = tLDRHi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load 2 from %ir.data16.i.13)
; CHECK: t2TEQrr renamable $r0, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
; CHECK: t2Bcc %bb.5, 0 /* CC::eq */, killed $cpsr
; CHECK: bb.4.while.body.end:
; CHECK: successors: %bb.5(0x04000000), %bb.1(0x7c000000)
; CHECK: liveins: $r0, $r1, $r2
; CHECK: renamable $r2 = tLDRi killed renamable $r2, 0, 14 /* CC::al */, $noreg :: (load 4 from %ir.next.i.14)
; CHECK: tCMPi8 renamable $r2, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
; CHECK: t2Bcc %bb.1, 1 /* CC::ne */, killed $cpsr
; CHECK: bb.5.exit:
; CHECK: liveins: $r0
; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $r0
bb.0.entry:
successors: %bb.1(0x80000000)
liveins: $r0, $r1
$r2 = tMOVr $r0, 14, $noreg
bb.1.while.begin:
successors: %bb.5(0x04000000), %bb.2(0x7c000000)
liveins: $r1, $r2
renamable $r0 = t2LDRi12 renamable $r2, 4, 14, $noreg :: (load 4 from %ir.info.i)
renamable $r0 = t2LDRHi12 killed renamable $r0, 0, 14, $noreg :: (load 2 from %ir.data16.i1)
t2TEQrr renamable $r0, renamable $r1, 14, $noreg, implicit-def $cpsr
t2Bcc %bb.5, 0, killed $cpsr
bb.2.while.body.a:
successors: %bb.5(0x04000000), %bb.3(0x7c000000)
liveins: $r0, $r1, $r2
renamable $r2 = t2LDRi12 killed renamable $r2, 0, 14, $noreg :: (load 4 from %ir.next.i2)
t2CMPri renamable $r2, 0, 14, $noreg, implicit-def $cpsr
t2Bcc %bb.5, 0, killed $cpsr
bb.3.it.block:
successors: %bb.5(0x04000000), %bb.4(0x7c000000)
liveins: $r1, $r2
renamable $r0 = t2LDRi12 renamable $r2, 4, 14, $noreg :: (load 4 from %ir.info.i.1)
renamable $r0 = t2LDRHi12 killed renamable $r0, 0, 14, $noreg :: (load 2 from %ir.data16.i.13)
t2TEQrr renamable $r0, renamable $r1, 14, $noreg, implicit-def $cpsr
t2Bcc %bb.5, 0, killed $cpsr
bb.4.while.body.end:
successors: %bb.5(0x04000000), %bb.1(0x7c000000)
liveins: $r0, $r1, $r2
renamable $r2 = t2LDRi12 killed renamable $r2, 0, 14, $noreg :: (load 4 from %ir.next.i.14)
t2CMPri renamable $r2, 0, 14, $noreg, implicit-def $cpsr
t2Bcc %bb.1, 1, killed $cpsr
bb.5.exit:
liveins: $r0
tBX_RET 14, $noreg, implicit $r0
...