ppc64-P9-mod.ll
6.74 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
; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 -verify-machineinstrs | FileCheck %s
; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr9 -verify-machineinstrs | FileCheck %s
; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 | FileCheck %s -check-prefix=CHECK-PWR8 -implicit-check-not mod[us][wd]
@mod_resultsw = local_unnamed_addr global i32 0, align 4
@mod_resultud = local_unnamed_addr global i64 0, align 8
@div_resultsw = local_unnamed_addr global i32 0, align 4
@mod_resultuw = local_unnamed_addr global i32 0, align 4
@div_resultuw = local_unnamed_addr global i32 0, align 4
@div_resultsd = local_unnamed_addr global i64 0, align 8
@mod_resultsd = local_unnamed_addr global i64 0, align 8
@div_resultud = local_unnamed_addr global i64 0, align 8
; Function Attrs: norecurse nounwind
define void @modulo_sw(i32 signext %a, i32 signext %b) local_unnamed_addr {
entry:
%rem = srem i32 %a, %b
store i32 %rem, i32* @mod_resultsw, align 4
ret void
; CHECK-LABEL: modulo_sw
; CHECK: modsw {{[0-9]+}}, 3, 4
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_sw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind readnone
define zeroext i32 @modulo_uw(i32 zeroext %a, i32 zeroext %b) local_unnamed_addr {
entry:
%rem = urem i32 %a, %b
ret i32 %rem
; CHECK-LABEL: modulo_uw
; CHECK: moduw {{[0-9]+}}, 3, 4
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_uw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind readnone
define i64 @modulo_sd(i64 %a, i64 %b) local_unnamed_addr {
entry:
%rem = srem i64 %a, %b
ret i64 %rem
; CHECK-LABEL: modulo_sd
; CHECK: modsd {{[0-9]+}}, 3, 4
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_sd
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
define void @modulo_ud(i64 %a, i64 %b) local_unnamed_addr {
entry:
%rem = urem i64 %a, %b
store i64 %rem, i64* @mod_resultud, align 8
ret void
; CHECK-LABEL: modulo_ud
; CHECK: modud {{[0-9]+}}, 3, 4
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_ud
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
define void @modulo_div_sw(i32 signext %a, i32 signext %b) local_unnamed_addr {
entry:
%rem = srem i32 %a, %b
store i32 %rem, i32* @mod_resultsw, align 4
%div = sdiv i32 %a, %b
store i32 %div, i32* @div_resultsw, align 4
ret void
; CHECK-LABEL: modulo_div_sw
; CHECK-NOT: modsw
; CHECK: div
; CHECK-NOT: modsw
; CHECK: mull
; CHECK-NOT: modsw
; CHECK: sub
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_div_sw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
define void @modulo_div_abc_sw(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr {
entry:
%rem = srem i32 %a, %c
store i32 %rem, i32* @mod_resultsw, align 4
%div = sdiv i32 %b, %c
store i32 %div, i32* @div_resultsw, align 4
ret void
; CHECK-LABEL: modulo_div_abc_sw
; CHECK: modsw {{[0-9]+}}, 3, 5
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_div_abc_sw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
define void @modulo_div_uw(i32 zeroext %a, i32 zeroext %b) local_unnamed_addr {
entry:
%rem = urem i32 %a, %b
store i32 %rem, i32* @mod_resultuw, align 4
%div = udiv i32 %a, %b
store i32 %div, i32* @div_resultuw, align 4
ret void
; CHECK-LABEL: modulo_div_uw
; CHECK-NOT: modsw
; CHECK: div
; CHECK-NOT: modsw
; CHECK: mull
; CHECK-NOT: modsw
; CHECK: sub
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_div_uw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
define void @modulo_div_swuw(i32 signext %a, i32 signext %b) local_unnamed_addr {
entry:
%rem = srem i32 %a, %b
store i32 %rem, i32* @mod_resultsw, align 4
%div = udiv i32 %a, %b
store i32 %div, i32* @div_resultsw, align 4
ret void
; CHECK-LABEL: modulo_div_swuw
; CHECK: modsw {{[0-9]+}}, 3, 4
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_div_swuw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
define void @modulo_div_udsd(i64 %a, i64 %b) local_unnamed_addr {
entry:
%rem = urem i64 %a, %b
store i64 %rem, i64* @mod_resultud, align 8
%div = sdiv i64 %a, %b
store i64 %div, i64* @div_resultsd, align 8
ret void
; CHECK-LABEL: modulo_div_udsd
; CHECK: modud {{[0-9]+}}, 3, 4
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_div_udsd
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
define void @modulo_const32_sw(i32 signext %a) local_unnamed_addr {
entry:
%rem = srem i32 %a, 32
store i32 %rem, i32* @mod_resultsw, align 4
ret void
; CHECK-LABEL: modulo_const32_sw
; CHECK-NOT: modsw
; CHECK: srawi
; CHECK-NOT: modsw
; CHECK: addze
; CHECK-NOT: modsw
; CHECK: slwi
; CHECK-NOT: modsw
; CHECK: subf
; CHECK-NOT: modsw
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_const32_sw
; CHECK-PWR8: srawi
; CHECK-PWR8: addze
; CHECK-PWR8: slwi
; CHECK-PWR8: subf
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind readnone
define signext i32 @modulo_const3_sw(i32 signext %a) local_unnamed_addr {
entry:
%rem = srem i32 %a, 3
ret i32 %rem
; CHECK-LABEL: modulo_const3_sw
; CHECK-NOT: modsw
; CHECK: mull
; CHECK-NOT: modsw
; CHECK: sub
; CHECK-NOT: modsw
; CHECK: blr
; CHECK-PWR8-LABEL: modulo_const3_sw
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind readnone
define signext i32 @const2_modulo_sw(i32 signext %a) local_unnamed_addr {
entry:
%rem = srem i32 2, %a
ret i32 %rem
; CHECK-LABEL: const2_modulo_sw
; CHECK: modsw {{[0-9]+}}, {{[0-9]+}}, 3
; CHECK: blr
; CHECK-PWR8-LABEL: const2_modulo_sw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}
; Function Attrs: norecurse nounwind
; FIXME On power 9 this test will still produce modsw because the divide is in
; a different block than the remainder. Due to the nature of the SDAG we cannot
; see the div in the other block.
define void @blocks_modulo_div_sw(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr {
entry:
%div = sdiv i32 %a, %b
store i32 %div, i32* @div_resultsw, align 4
%cmp = icmp sgt i32 %c, 0
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
%rem = srem i32 %a, %b
store i32 %rem, i32* @mod_resultsw, align 4
br label %if.end
if.end: ; preds = %if.then, %entry
ret void
; CHECK-LABEL: blocks_modulo_div_sw
; CHECK: div
; CHECK: modsw {{[0-9]+}}, 3, 4
; CHECK: blr
; CHECK-PWR8-LABEL: blocks_modulo_div_sw
; CHECK-PWR8: div
; CHECK-PWR8: mull
; CHECK-PWR8: sub
; CHECK-PWR8: blr
}