• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test 32-bit multiplication in which the second operand is constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check multiplication by 2, which should use shifts.
6define i32 @f1(i32 %a, i32 *%dest) {
7; CHECK-LABEL: f1:
8; CHECK: sll %r2, 1
9; CHECK: br %r14
10  %mul = mul i32 %a, 2
11  ret i32 %mul
12}
13
14; Check multiplication by 3.
15define i32 @f2(i32 %a, i32 *%dest) {
16; CHECK-LABEL: f2:
17; CHECK: mhi %r2, 3
18; CHECK: br %r14
19  %mul = mul i32 %a, 3
20  ret i32 %mul
21}
22
23; Check the high end of the MHI range.
24define i32 @f3(i32 %a, i32 *%dest) {
25; CHECK-LABEL: f3:
26; CHECK: mhi %r2, 32767
27; CHECK: br %r14
28  %mul = mul i32 %a, 32767
29  ret i32 %mul
30}
31
32; Check the next value up, which should use shifts.
33define i32 @f4(i32 %a, i32 *%dest) {
34; CHECK-LABEL: f4:
35; CHECK: sll %r2, 15
36; CHECK: br %r14
37  %mul = mul i32 %a, 32768
38  ret i32 %mul
39}
40
41; Check the next value up again, which can use MSFI.
42define i32 @f5(i32 %a, i32 *%dest) {
43; CHECK-LABEL: f5:
44; CHECK: msfi %r2, 32769
45; CHECK: br %r14
46  %mul = mul i32 %a, 32769
47  ret i32 %mul
48}
49
50; Check the high end of the MSFI range.
51define i32 @f6(i32 %a, i32 *%dest) {
52; CHECK-LABEL: f6:
53; CHECK: msfi %r2, 2147483647
54; CHECK: br %r14
55  %mul = mul i32 %a, 2147483647
56  ret i32 %mul
57}
58
59; Check the next value up, which should use shifts.
60define i32 @f7(i32 %a, i32 *%dest) {
61; CHECK-LABEL: f7:
62; CHECK: sll %r2, 31
63; CHECK: br %r14
64  %mul = mul i32 %a, 2147483648
65  ret i32 %mul
66}
67
68; Check the next value up again, which is treated as a negative value.
69define i32 @f8(i32 %a, i32 *%dest) {
70; CHECK-LABEL: f8:
71; CHECK: msfi %r2, -2147483647
72; CHECK: br %r14
73  %mul = mul i32 %a, 2147483649
74  ret i32 %mul
75}
76
77; Check multiplication by -1, which is a negation.
78define i32 @f9(i32 %a, i32 *%dest) {
79; CHECK-LABEL: f9:
80; CHECK: lcr %r2, %r2
81; CHECK: br %r14
82  %mul = mul i32 %a, -1
83  ret i32 %mul
84}
85
86; Check multiplication by -2, which should use shifts.
87define i32 @f10(i32 %a, i32 *%dest) {
88; CHECK-LABEL: f10:
89; CHECK: sll %r2, 1
90; CHECK: lcr %r2, %r2
91; CHECK: br %r14
92  %mul = mul i32 %a, -2
93  ret i32 %mul
94}
95
96; Check multiplication by -3.
97define i32 @f11(i32 %a, i32 *%dest) {
98; CHECK-LABEL: f11:
99; CHECK: mhi %r2, -3
100; CHECK: br %r14
101  %mul = mul i32 %a, -3
102  ret i32 %mul
103}
104
105; Check the lowest useful MHI value.
106define i32 @f12(i32 %a, i32 *%dest) {
107; CHECK-LABEL: f12:
108; CHECK: mhi %r2, -32767
109; CHECK: br %r14
110  %mul = mul i32 %a, -32767
111  ret i32 %mul
112}
113
114; Check the next value down, which should use shifts.
115define i32 @f13(i32 %a, i32 *%dest) {
116; CHECK-LABEL: f13:
117; CHECK: sll %r2, 15
118; CHECK: lcr %r2, %r2
119; CHECK: br %r14
120  %mul = mul i32 %a, -32768
121  ret i32 %mul
122}
123
124; Check the next value down again, which can use MSFI.
125define i32 @f14(i32 %a, i32 *%dest) {
126; CHECK-LABEL: f14:
127; CHECK: msfi %r2, -32769
128; CHECK: br %r14
129  %mul = mul i32 %a, -32769
130  ret i32 %mul
131}
132
133; Check the lowest useful MSFI value.
134define i32 @f15(i32 %a, i32 *%dest) {
135; CHECK-LABEL: f15:
136; CHECK: msfi %r2, -2147483647
137; CHECK: br %r14
138  %mul = mul i32 %a, -2147483647
139  ret i32 %mul
140}
141
142; Check the next value down, which should use shifts.
143define i32 @f16(i32 %a, i32 *%dest) {
144; CHECK-LABEL: f16:
145; CHECK: sll %r2, 31
146; CHECK-NOT: lcr
147; CHECK: br %r14
148  %mul = mul i32 %a, -2147483648
149  ret i32 %mul
150}
151
152; Check the next value down again, which is treated as a positive value.
153define i32 @f17(i32 %a, i32 *%dest) {
154; CHECK-LABEL: f17:
155; CHECK: msfi %r2, 2147483647
156; CHECK: br %r14
157  %mul = mul i32 %a, -2147483649
158  ret i32 %mul
159}
160