1 ; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 -verify-machineinstrs | FileCheck %s
2 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr9 -verify-machineinstrs | FileCheck %s
3 ; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 | FileCheck %s -check-prefix=CHECK-PWR8 -implicit-check-not mod[us][wd]
4 ; RUN: opt < %s -passes=div-rem-pairs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 | \
5 ; RUN: llc -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-DRP
6 ; RUN: opt < %s -passes=div-rem-pairs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr9 | \
7 ; RUN: llc -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-DRP
8 ; RUN: opt < %s -passes=div-rem-pairs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 | \
9 ; RUN: llc -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-PWR8 -implicit-check-not mod[us][wd]
11 @mod_resultsw = local_unnamed_addr global i32 0, align 4
12 @mod_resultud = local_unnamed_addr global i64 0, align 8
13 @div_resultsw = local_unnamed_addr global i32 0, align 4
14 @mod_resultuw = local_unnamed_addr global i32 0, align 4
15 @div_resultuw = local_unnamed_addr global i32 0, align 4
16 @div_resultsd = local_unnamed_addr global i64 0, align 8
17 @mod_resultsd = local_unnamed_addr global i64 0, align 8
18 @div_resultud = local_unnamed_addr global i64 0, align 8
20 ; Function Attrs: norecurse nounwind
21 define void @modulo_sw(i32 signext %a, i32 signext %b) local_unnamed_addr {
23 %rem = srem i32 %a, %b
24 store i32 %rem, ptr @mod_resultsw, align 4
26 ; CHECK-LABEL: modulo_sw
27 ; CHECK: modsw {{[0-9]+}}, 3, 4
29 ; CHECK-PWR8-LABEL: modulo_sw
36 ; Function Attrs: norecurse nounwind readnone
37 define zeroext i32 @modulo_uw(i32 zeroext %a, i32 zeroext %b) local_unnamed_addr {
39 %rem = urem i32 %a, %b
41 ; CHECK-LABEL: modulo_uw
42 ; CHECK: moduw {{[0-9]+}}, 3, 4
44 ; CHECK-PWR8-LABEL: modulo_uw
51 ; Function Attrs: norecurse nounwind readnone
52 define i64 @modulo_sd(i64 %a, i64 %b) local_unnamed_addr {
54 %rem = srem i64 %a, %b
56 ; CHECK-LABEL: modulo_sd
57 ; CHECK: modsd {{[0-9]+}}, 3, 4
59 ; CHECK-PWR8-LABEL: modulo_sd
66 ; Function Attrs: norecurse nounwind
67 define void @modulo_ud(i64 %a, i64 %b) local_unnamed_addr {
69 %rem = urem i64 %a, %b
70 store i64 %rem, ptr @mod_resultud, align 8
72 ; CHECK-LABEL: modulo_ud
73 ; CHECK: modud {{[0-9]+}}, 3, 4
75 ; CHECK-PWR8-LABEL: modulo_ud
82 ; Function Attrs: norecurse nounwind
83 define void @modulo_div_sw(i32 signext %a, i32 signext %b) local_unnamed_addr {
85 %rem = srem i32 %a, %b
86 store i32 %rem, ptr @mod_resultsw, align 4
87 %div = sdiv i32 %a, %b
88 store i32 %div, ptr @div_resultsw, align 4
90 ; CHECK-LABEL: modulo_div_sw
91 ; CHECK: modsw {{[0-9]+}}, 3, 4
93 ; CHECK-DRP-LABEL: modulo_div_sw
94 ; CHECK-DRP-NOT: modsw
96 ; CHECK-DRP-NOT: modsw
98 ; CHECK-DRP-NOT: modsw
101 ; CHECK-PWR8-LABEL: modulo_div_sw
108 ; Function Attrs: norecurse nounwind
109 define void @modulo_div_abc_sw(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr {
111 %rem = srem i32 %a, %c
112 store i32 %rem, ptr @mod_resultsw, align 4
113 %div = sdiv i32 %b, %c
114 store i32 %div, ptr @div_resultsw, align 4
116 ; CHECK-LABEL: modulo_div_abc_sw
117 ; CHECK: modsw {{[0-9]+}}, 3, 5
119 ; CHECK-PWR8-LABEL: modulo_div_abc_sw
126 ; Function Attrs: norecurse nounwind
127 define void @modulo_div_uw(i32 zeroext %a, i32 zeroext %b) local_unnamed_addr {
129 %rem = urem i32 %a, %b
130 store i32 %rem, ptr @mod_resultuw, align 4
131 %div = udiv i32 %a, %b
132 store i32 %div, ptr @div_resultuw, align 4
134 ; CHECK-LABEL: modulo_div_uw
135 ; CHECK: moduw {{[0-9]+}}, 3, 4
137 ; CHECK-DRP-LABEL: modulo_div_uw
138 ; CHECK-DRP-NOT: moduw
140 ; CHECK-DRP-NOT: moduw
142 ; CHECK-DRP-NOT: moduw
145 ; CHECK-PWR8-LABEL: modulo_div_uw
152 ; Function Attrs: norecurse nounwind
153 define void @modulo_div_swuw(i32 signext %a, i32 signext %b) local_unnamed_addr {
155 %rem = srem i32 %a, %b
156 store i32 %rem, ptr @mod_resultsw, align 4
157 %div = udiv i32 %a, %b
158 store i32 %div, ptr @div_resultsw, align 4
160 ; CHECK-LABEL: modulo_div_swuw
161 ; CHECK: modsw {{[0-9]+}}, 3, 4
163 ; CHECK-PWR8-LABEL: modulo_div_swuw
170 ; Function Attrs: norecurse nounwind
171 define void @modulo_div_udsd(i64 %a, i64 %b) local_unnamed_addr {
173 %rem = urem i64 %a, %b
174 store i64 %rem, ptr @mod_resultud, align 8
175 %div = sdiv i64 %a, %b
176 store i64 %div, ptr @div_resultsd, align 8
178 ; CHECK-LABEL: modulo_div_udsd
179 ; CHECK: modud {{[0-9]+}}, 3, 4
181 ; CHECK-PWR8-LABEL: modulo_div_udsd
188 ; Function Attrs: norecurse nounwind
189 define void @modulo_const32_sw(i32 signext %a) local_unnamed_addr {
191 %rem = srem i32 %a, 32
192 store i32 %rem, ptr @mod_resultsw, align 4
194 ; CHECK-LABEL: modulo_const32_sw
205 ; CHECK-PWR8-LABEL: modulo_const32_sw
213 ; Function Attrs: norecurse nounwind readnone
214 define signext i32 @modulo_const3_sw(i32 signext %a) local_unnamed_addr {
216 %rem = srem i32 %a, 3
218 ; CHECK-LABEL: modulo_const3_sw
225 ; CHECK-PWR8-LABEL: modulo_const3_sw
231 ; Function Attrs: norecurse nounwind readnone
232 define signext i32 @const2_modulo_sw(i32 signext %a) local_unnamed_addr {
234 %rem = srem i32 2, %a
236 ; CHECK-LABEL: const2_modulo_sw
237 ; CHECK: modsw {{[0-9]+}}, {{[0-9]+}}, 3
239 ; CHECK-PWR8-LABEL: const2_modulo_sw
246 ; Function Attrs: norecurse nounwind
247 define void @blocks_modulo_div_sw(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr {
249 %div = sdiv i32 %a, %b
250 store i32 %div, ptr @div_resultsw, align 4
251 %cmp = icmp sgt i32 %c, 0
252 br i1 %cmp, label %if.then, label %if.end
254 if.then: ; preds = %entry
255 %rem = srem i32 %a, %b
256 store i32 %rem, ptr @mod_resultsw, align 4
259 if.end: ; preds = %if.then, %entry
261 ; CHECK-LABEL: blocks_modulo_div_sw
263 ; CHECK: modsw {{[0-9]+}}, 3, 4
265 ; CHECK-DRP-LABEL: blocks_modulo_div_sw
266 ; CHECK-DRP-NOT: modsw
268 ; CHECK-DRP-NOT: modsw
270 ; CHECK-DRP-NOT: modsw
273 ; CHECK-PWR8-LABEL: blocks_modulo_div_sw