blob: 93f140d84504ff1f564ee73facdf6fbe5bf20222 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00008; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000016; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000017; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000025; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000026; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000034; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000035; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000043; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000044; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000052; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000053; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000061; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000062; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000070; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000071; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000079; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000080; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000088; CHECK-LABEL: f10:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000089; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000098; CHECK-LABEL: f11:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000099; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +0000107; CHECK-LABEL: f12:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000108; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +0000116; CHECK-LABEL: f13:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000117; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +0000126; CHECK-LABEL: f14:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000127; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +0000135; CHECK-LABEL: f15:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000136; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +0000144; CHECK-LABEL: f16:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000145; 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) {
Stephen Lind24ab202013-07-14 06:24:09 +0000154; CHECK-LABEL: f17:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000155; CHECK: msfi %r2, 2147483647
156; CHECK: br %r14
157 %mul = mul i32 %a, -2147483649
158 ret i32 %mul
159}