1 ; Test 32-bit multiplication in which the second operand is constant.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check multiplication by 2, which should use shifts.
6 define i32 @f1(i32 %a, i32 *%dest) {
14 ; Check multiplication by 3.
15 define i32 @f2(i32 %a, i32 *%dest) {
23 ; Check the high end of the MHI range.
24 define i32 @f3(i32 %a, i32 *%dest) {
26 ; CHECK: mhi %r2, 32767
28 %mul = mul i32 %a, 32767
32 ; Check the next value up, which should use shifts.
33 define i32 @f4(i32 %a, i32 *%dest) {
37 %mul = mul i32 %a, 32768
41 ; Check the next value up again, which can use MSFI.
42 define i32 @f5(i32 %a, i32 *%dest) {
44 ; CHECK: msfi %r2, 32769
46 %mul = mul i32 %a, 32769
50 ; Check the high end of the MSFI range.
51 define i32 @f6(i32 %a, i32 *%dest) {
53 ; CHECK: msfi %r2, 2147483647
55 %mul = mul i32 %a, 2147483647
59 ; Check the next value up, which should use shifts.
60 define i32 @f7(i32 %a, i32 *%dest) {
64 %mul = mul i32 %a, 2147483648
68 ; Check the next value up again, which is treated as a negative value.
69 define i32 @f8(i32 %a, i32 *%dest) {
71 ; CHECK: msfi %r2, -2147483647
73 %mul = mul i32 %a, 2147483649
77 ; Check multiplication by -1, which is a negation.
78 define i32 @f9(i32 %a, i32 *%dest) {
86 ; Check multiplication by -2, which should use shifts.
87 define i32 @f10(i32 %a, i32 *%dest) {
96 ; Check multiplication by -3.
97 define i32 @f11(i32 %a, i32 *%dest) {
101 %mul = mul i32 %a, -3
105 ; Check the lowest useful MHI value.
106 define i32 @f12(i32 %a, i32 *%dest) {
108 ; CHECK: mhi %r2, -32767
110 %mul = mul i32 %a, -32767
114 ; Check the next value down, which should use shifts.
115 define i32 @f13(i32 %a, i32 *%dest) {
118 ; CHECK: lcr %r2, %r2
120 %mul = mul i32 %a, -32768
124 ; Check the next value down again, which can use MSFI.
125 define i32 @f14(i32 %a, i32 *%dest) {
127 ; CHECK: msfi %r2, -32769
129 %mul = mul i32 %a, -32769
133 ; Check the lowest useful MSFI value.
134 define i32 @f15(i32 %a, i32 *%dest) {
136 ; CHECK: msfi %r2, -2147483647
138 %mul = mul i32 %a, -2147483647
142 ; Check the next value down, which should use shifts.
143 define i32 @f16(i32 %a, i32 *%dest) {
148 %mul = mul i32 %a, -2147483648
152 ; Check the next value down again, which is treated as a positive value.
153 define i32 @f17(i32 %a, i32 *%dest) {
155 ; CHECK: msfi %r2, 2147483647
157 %mul = mul i32 %a, -2147483649