adx-commute.mir
8.65 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
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -o - -mtriple=x86_64-- -run-pass=twoaddressinstruction,simple-register-coalescing %s | FileCheck %s
# Tests for commuting ADCX and ADOX to avoid copies. The ADOX tests were manually constructed by modifying ADCX tests to use OF instead of CF.
--- |
; ModuleID = 'test.ll'
source_filename = "test.ll"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
define void @adcx32_commute(i8 %cf, i32 %a, i32 %b, i32* %res) #0 {
%ret = call { i8, i32 } @llvm.x86.addcarry.32(i8 %cf, i32 %a, i32 %b)
%1 = extractvalue { i8, i32 } %ret, 1
%2 = mul i32 %a, %1
store i32 %2, i32* %res
ret void
}
define void @adcx64_commute(i8 %cf, i64 %a, i64 %b, i64* %res) #0 {
%ret = call { i8, i64 } @llvm.x86.addcarry.64(i8 %cf, i64 %a, i64 %b)
%1 = extractvalue { i8, i64 } %ret, 1
%2 = mul i64 %a, %1
store i64 %2, i64* %res
ret void
}
define void @adox32_commute(i8 %cf, i32 %a, i32 %b, i32* %res) #0 {
%ret = call { i8, i32 } @llvm.x86.addcarry.32(i8 %cf, i32 %a, i32 %b)
%1 = extractvalue { i8, i32 } %ret, 1
%2 = mul i32 %a, %1
store i32 %2, i32* %res
ret void
}
define void @adox64_commute(i8 %cf, i64 %a, i64 %b, i64* %res) #0 {
%ret = call { i8, i64 } @llvm.x86.addcarry.64(i8 %cf, i64 %a, i64 %b)
%1 = extractvalue { i8, i64 } %ret, 1
%2 = mul i64 %a, %1
store i64 %2, i64* %res
ret void
}
; Function Attrs: nounwind readnone
declare { i8, i32 } @llvm.x86.addcarry.32(i8, i32, i32) #1
; Function Attrs: nounwind readnone
declare { i8, i64 } @llvm.x86.addcarry.64(i8, i64, i64) #1
; Function Attrs: nounwind
declare void @llvm.stackprotector(i8*, i8**) #2
attributes #0 = { "target-features"="+adx" }
attributes #1 = { nounwind readnone "target-features"="+adx" }
attributes #2 = { nounwind }
...
---
name: adcx32_commute
alignment: 16
tracksRegLiveness: true
registers:
- { id: 0, class: gr32 }
- { id: 1, class: gr32 }
- { id: 2, class: gr32 }
- { id: 3, class: gr64 }
- { id: 4, class: gr8 }
- { id: 5, class: gr8 }
- { id: 6, class: gr32 }
- { id: 7, class: gr32 }
liveins:
- { reg: '$edi', virtual-reg: '%0' }
- { reg: '$esi', virtual-reg: '%1' }
- { reg: '$edx', virtual-reg: '%2' }
- { reg: '$rcx', virtual-reg: '%3' }
body: |
bb.0 (%ir-block.0):
liveins: $edi, $esi, $edx, $rcx
; CHECK-LABEL: name: adcx32_commute
; CHECK: liveins: $edi, $esi, $edx, $rcx
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rcx
; CHECK: [[COPY1:%[0-9]+]]:gr32 = COPY $edx
; CHECK: [[COPY2:%[0-9]+]]:gr32 = COPY $esi
; CHECK: [[COPY3:%[0-9]+]]:gr32 = COPY $edi
; CHECK: dead [[COPY3]].sub_8bit:gr32 = ADD8ri [[COPY3]].sub_8bit, -1, implicit-def $eflags
; CHECK: [[ADCX32rr:%[0-9]+]]:gr32 = ADCX32rr [[ADCX32rr]], [[COPY2]], implicit-def dead $eflags, implicit killed $eflags
; CHECK: [[IMUL32rr:%[0-9]+]]:gr32 = IMUL32rr [[IMUL32rr]], [[COPY2]], implicit-def dead $eflags
; CHECK: MOV32mr [[COPY]], 1, $noreg, 0, $noreg, [[IMUL32rr]] :: (store 4 into %ir.res)
; CHECK: RET 0
%3:gr64 = COPY killed $rcx
%2:gr32 = COPY killed $edx
%1:gr32 = COPY killed $esi
%0:gr32 = COPY killed $edi
%4:gr8 = COPY killed %0.sub_8bit
dead %5:gr8 = ADD8ri killed %4, -1, implicit-def $eflags
%6:gr32 = ADCX32rr %1, killed %2, implicit-def dead $eflags, implicit killed $eflags
%7:gr32 = IMUL32rr killed %1, killed %6, implicit-def dead $eflags
MOV32mr killed %3, 1, $noreg, 0, $noreg, killed %7 :: (store 4 into %ir.res)
RET 0
...
---
name: adcx64_commute
alignment: 16
tracksRegLiveness: true
registers:
- { id: 0, class: gr32 }
- { id: 1, class: gr64 }
- { id: 2, class: gr64 }
- { id: 3, class: gr64 }
- { id: 4, class: gr8 }
- { id: 5, class: gr8 }
- { id: 6, class: gr64 }
- { id: 7, class: gr64 }
liveins:
- { reg: '$edi', virtual-reg: '%0' }
- { reg: '$rsi', virtual-reg: '%1' }
- { reg: '$rdx', virtual-reg: '%2' }
- { reg: '$rcx', virtual-reg: '%3' }
body: |
bb.0 (%ir-block.0):
liveins: $edi, $rsi, $rdx, $rcx
; CHECK-LABEL: name: adcx64_commute
; CHECK: liveins: $edi, $rsi, $rdx, $rcx
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rcx
; CHECK: [[COPY1:%[0-9]+]]:gr64 = COPY $rdx
; CHECK: [[COPY2:%[0-9]+]]:gr64 = COPY $rsi
; CHECK: [[COPY3:%[0-9]+]]:gr32 = COPY $edi
; CHECK: dead [[COPY3]].sub_8bit:gr32 = ADD8ri [[COPY3]].sub_8bit, -1, implicit-def $eflags
; CHECK: [[ADCX64rr:%[0-9]+]]:gr64 = ADCX64rr [[ADCX64rr]], [[COPY2]], implicit-def dead $eflags, implicit killed $eflags
; CHECK: [[IMUL64rr:%[0-9]+]]:gr64 = IMUL64rr [[IMUL64rr]], [[COPY2]], implicit-def dead $eflags
; CHECK: MOV64mr [[COPY]], 1, $noreg, 0, $noreg, [[IMUL64rr]] :: (store 8 into %ir.res)
; CHECK: RET 0
%3:gr64 = COPY killed $rcx
%2:gr64 = COPY killed $rdx
%1:gr64 = COPY killed $rsi
%0:gr32 = COPY killed $edi
%4:gr8 = COPY killed %0.sub_8bit
dead %5:gr8 = ADD8ri killed %4, -1, implicit-def $eflags
%6:gr64 = ADCX64rr %1, killed %2, implicit-def dead $eflags, implicit killed $eflags
%7:gr64 = IMUL64rr killed %1, killed %6, implicit-def dead $eflags
MOV64mr killed %3, 1, $noreg, 0, $noreg, killed %7 :: (store 8 into %ir.res)
RET 0
...
---
name: adox32_commute
alignment: 16
tracksRegLiveness: true
registers:
- { id: 0, class: gr32 }
- { id: 1, class: gr32 }
- { id: 2, class: gr32 }
- { id: 3, class: gr64 }
- { id: 4, class: gr8 }
- { id: 5, class: gr8 }
- { id: 6, class: gr32 }
- { id: 7, class: gr32 }
liveins:
- { reg: '$edi', virtual-reg: '%0' }
- { reg: '$esi', virtual-reg: '%1' }
- { reg: '$edx', virtual-reg: '%2' }
- { reg: '$rcx', virtual-reg: '%3' }
body: |
bb.0 (%ir-block.0):
liveins: $edi, $esi, $edx, $rcx
; CHECK-LABEL: name: adox32_commute
; CHECK: liveins: $edi, $esi, $edx, $rcx
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rcx
; CHECK: [[COPY1:%[0-9]+]]:gr32 = COPY $edx
; CHECK: [[COPY2:%[0-9]+]]:gr32 = COPY $esi
; CHECK: [[COPY3:%[0-9]+]]:gr32 = COPY $edi
; CHECK: dead [[COPY3]].sub_8bit:gr32 = ADD8ri [[COPY3]].sub_8bit, 127, implicit-def $eflags
; CHECK: [[ADOX32rr:%[0-9]+]]:gr32 = ADOX32rr [[ADOX32rr]], [[COPY2]], implicit-def dead $eflags, implicit killed $eflags
; CHECK: [[IMUL32rr:%[0-9]+]]:gr32 = IMUL32rr [[IMUL32rr]], [[COPY2]], implicit-def dead $eflags
; CHECK: MOV32mr [[COPY]], 1, $noreg, 0, $noreg, [[IMUL32rr]] :: (store 4 into %ir.res)
; CHECK: RET 0
%3:gr64 = COPY killed $rcx
%2:gr32 = COPY killed $edx
%1:gr32 = COPY killed $esi
%0:gr32 = COPY killed $edi
%4:gr8 = COPY killed %0.sub_8bit
dead %5:gr8 = ADD8ri killed %4, 127, implicit-def $eflags
%6:gr32 = ADOX32rr %1, killed %2, implicit-def dead $eflags, implicit killed $eflags
%7:gr32 = IMUL32rr killed %1, killed %6, implicit-def dead $eflags
MOV32mr killed %3, 1, $noreg, 0, $noreg, killed %7 :: (store 4 into %ir.res)
RET 0
...
---
name: adox64_commute
alignment: 16
tracksRegLiveness: true
registers:
- { id: 0, class: gr32 }
- { id: 1, class: gr64 }
- { id: 2, class: gr64 }
- { id: 3, class: gr64 }
- { id: 4, class: gr8 }
- { id: 5, class: gr8 }
- { id: 6, class: gr64 }
- { id: 7, class: gr64 }
liveins:
- { reg: '$edi', virtual-reg: '%0' }
- { reg: '$rsi', virtual-reg: '%1' }
- { reg: '$rdx', virtual-reg: '%2' }
- { reg: '$rcx', virtual-reg: '%3' }
body: |
bb.0 (%ir-block.0):
liveins: $edi, $rsi, $rdx, $rcx
; CHECK-LABEL: name: adox64_commute
; CHECK: liveins: $edi, $rsi, $rdx, $rcx
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rcx
; CHECK: [[COPY1:%[0-9]+]]:gr64 = COPY $rdx
; CHECK: [[COPY2:%[0-9]+]]:gr64 = COPY $rsi
; CHECK: [[COPY3:%[0-9]+]]:gr32 = COPY $edi
; CHECK: dead [[COPY3]].sub_8bit:gr32 = ADD8ri [[COPY3]].sub_8bit, 127, implicit-def $eflags
; CHECK: [[ADOX64rr:%[0-9]+]]:gr64 = ADOX64rr [[ADOX64rr]], [[COPY2]], implicit-def dead $eflags, implicit killed $eflags
; CHECK: [[IMUL64rr:%[0-9]+]]:gr64 = IMUL64rr [[IMUL64rr]], [[COPY2]], implicit-def dead $eflags
; CHECK: MOV64mr [[COPY]], 1, $noreg, 0, $noreg, [[IMUL64rr]] :: (store 8 into %ir.res)
; CHECK: RET 0
%3:gr64 = COPY killed $rcx
%2:gr64 = COPY killed $rdx
%1:gr64 = COPY killed $rsi
%0:gr32 = COPY killed $edi
%4:gr8 = COPY killed %0.sub_8bit
dead %5:gr8 = ADD8ri killed %4, 127, implicit-def $eflags
%6:gr64 = ADOX64rr %1, killed %2, implicit-def dead $eflags, implicit killed $eflags
%7:gr64 = IMUL64rr killed %1, killed %6, implicit-def dead $eflags
MOV64mr killed %3, 1, $noreg, 0, $noreg, killed %7 :: (store 8 into %ir.res)
RET 0
...