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]
5 @mod_resultsw = common local_unnamed_addr global i32 0, align 4
6 @mod_resultud = common local_unnamed_addr global i64 0, align 8
7 @div_resultsw = common local_unnamed_addr global i32 0, align 4
8 @mod_resultuw = common local_unnamed_addr global i32 0, align 4
9 @div_resultuw = common local_unnamed_addr global i32 0, align 4
10 @div_resultsd = common local_unnamed_addr global i64 0, align 8
11 @mod_resultsd = common local_unnamed_addr global i64 0, align 8
12 @div_resultud = common local_unnamed_addr global i64 0, align 8
14 ; Function Attrs: norecurse nounwind
15 define void @modulo_sw(i32 signext %a, i32 signext %b) local_unnamed_addr {
17 %rem = srem i32 %a, %b
18 store i32 %rem, i32* @mod_resultsw, align 4
20 ; CHECK-LABEL: modulo_sw
21 ; CHECK: modsw {{[0-9]+}}, 3, 4
23 ; CHECK-PWR8-LABEL: modulo_sw
30 ; Function Attrs: norecurse nounwind readnone
31 define zeroext i32 @modulo_uw(i32 zeroext %a, i32 zeroext %b) local_unnamed_addr {
33 %rem = urem i32 %a, %b
35 ; CHECK-LABEL: modulo_uw
36 ; CHECK: moduw {{[0-9]+}}, 3, 4
38 ; CHECK-PWR8-LABEL: modulo_uw
45 ; Function Attrs: norecurse nounwind readnone
46 define i64 @modulo_sd(i64 %a, i64 %b) local_unnamed_addr {
48 %rem = srem i64 %a, %b
50 ; CHECK-LABEL: modulo_sd
51 ; CHECK: modsd {{[0-9]+}}, 3, 4
53 ; CHECK-PWR8-LABEL: modulo_sd
60 ; Function Attrs: norecurse nounwind
61 define void @modulo_ud(i64 %a, i64 %b) local_unnamed_addr {
63 %rem = urem i64 %a, %b
64 store i64 %rem, i64* @mod_resultud, align 8
66 ; CHECK-LABEL: modulo_ud
67 ; CHECK: modud {{[0-9]+}}, 3, 4
69 ; CHECK-PWR8-LABEL: modulo_ud
76 ; Function Attrs: norecurse nounwind
77 define void @modulo_div_sw(i32 signext %a, i32 signext %b) local_unnamed_addr {
79 %rem = srem i32 %a, %b
80 store i32 %rem, i32* @mod_resultsw, align 4
81 %div = sdiv i32 %a, %b
82 store i32 %div, i32* @div_resultsw, align 4
84 ; CHECK-LABEL: modulo_div_sw
92 ; CHECK-PWR8-LABEL: modulo_div_sw
99 ; Function Attrs: norecurse nounwind
100 define void @modulo_div_abc_sw(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr {
102 %rem = srem i32 %a, %c
103 store i32 %rem, i32* @mod_resultsw, align 4
104 %div = sdiv i32 %b, %c
105 store i32 %div, i32* @div_resultsw, align 4
107 ; CHECK-LABEL: modulo_div_abc_sw
108 ; CHECK: modsw {{[0-9]+}}, 3, 5
110 ; CHECK-PWR8-LABEL: modulo_div_abc_sw
117 ; Function Attrs: norecurse nounwind
118 define void @modulo_div_uw(i32 zeroext %a, i32 zeroext %b) local_unnamed_addr {
120 %rem = urem i32 %a, %b
121 store i32 %rem, i32* @mod_resultuw, align 4
122 %div = udiv i32 %a, %b
123 store i32 %div, i32* @div_resultuw, align 4
125 ; CHECK-LABEL: modulo_div_uw
133 ; CHECK-PWR8-LABEL: modulo_div_uw
140 ; Function Attrs: norecurse nounwind
141 define void @modulo_div_swuw(i32 signext %a, i32 signext %b) local_unnamed_addr {
143 %rem = srem i32 %a, %b
144 store i32 %rem, i32* @mod_resultsw, align 4
145 %div = udiv i32 %a, %b
146 store i32 %div, i32* @div_resultsw, align 4
148 ; CHECK-LABEL: modulo_div_swuw
149 ; CHECK: modsw {{[0-9]+}}, 3, 4
151 ; CHECK-PWR8-LABEL: modulo_div_swuw
158 ; Function Attrs: norecurse nounwind
159 define void @modulo_div_udsd(i64 %a, i64 %b) local_unnamed_addr {
161 %rem = urem i64 %a, %b
162 store i64 %rem, i64* @mod_resultud, align 8
163 %div = sdiv i64 %a, %b
164 store i64 %div, i64* @div_resultsd, align 8
166 ; CHECK-LABEL: modulo_div_udsd
167 ; CHECK: modud {{[0-9]+}}, 3, 4
169 ; CHECK-PWR8-LABEL: modulo_div_udsd
176 ; Function Attrs: norecurse nounwind
177 define void @modulo_const32_sw(i32 signext %a) local_unnamed_addr {
179 %rem = srem i32 %a, 32
180 store i32 %rem, i32* @mod_resultsw, align 4
182 ; CHECK-LABEL: modulo_const32_sw
193 ; CHECK-PWR8-LABEL: modulo_const32_sw
201 ; Function Attrs: norecurse nounwind readnone
202 define signext i32 @modulo_const3_sw(i32 signext %a) local_unnamed_addr {
204 %rem = srem i32 %a, 3
206 ; CHECK-LABEL: modulo_const3_sw
213 ; CHECK-PWR8-LABEL: modulo_const3_sw
219 ; Function Attrs: norecurse nounwind readnone
220 define signext i32 @const2_modulo_sw(i32 signext %a) local_unnamed_addr {
222 %rem = srem i32 2, %a
224 ; CHECK-LABEL: const2_modulo_sw
225 ; CHECK: modsw {{[0-9]+}}, {{[0-9]+}}, 3
227 ; CHECK-PWR8-LABEL: const2_modulo_sw
234 ; Function Attrs: norecurse nounwind
235 ; FIXME On power 9 this test will still produce modsw because the divide is in
236 ; a different block than the remainder. Due to the nature of the SDAG we cannot
237 ; see the div in the other block.
238 define void @blocks_modulo_div_sw(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr {
240 %div = sdiv i32 %a, %b
241 store i32 %div, i32* @div_resultsw, align 4
242 %cmp = icmp sgt i32 %c, 0
243 br i1 %cmp, label %if.then, label %if.end
245 if.then: ; preds = %entry
246 %rem = srem i32 %a, %b
247 store i32 %rem, i32* @mod_resultsw, align 4
250 if.end: ; preds = %if.then, %entry
252 ; CHECK-LABEL: blocks_modulo_div_sw
254 ; CHECK: modsw {{[0-9]+}}, 3, 4
256 ; CHECK-PWR8-LABEL: blocks_modulo_div_sw