1 ; Test 64-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 i64 @f1(i64 %a, i64 *%dest) {
8 ; CHECK: sllg %r2, %r2, 1
14 ; Check multiplication by 3.
15 define i64 @f2(i64 %a, i64 *%dest) {
23 ; Check the high end of the MGHI range.
24 define i64 @f3(i64 %a, i64 *%dest) {
26 ; CHECK: mghi %r2, 32767
28 %mul = mul i64 %a, 32767
32 ; Check the next value up, which should use shifts.
33 define i64 @f4(i64 %a, i64 *%dest) {
35 ; CHECK: sllg %r2, %r2, 15
37 %mul = mul i64 %a, 32768
41 ; Check the next value up again, which can use MSGFI.
42 define i64 @f5(i64 %a, i64 *%dest) {
44 ; CHECK: msgfi %r2, 32769
46 %mul = mul i64 %a, 32769
50 ; Check the high end of the MSGFI range.
51 define i64 @f6(i64 %a, i64 *%dest) {
53 ; CHECK: msgfi %r2, 2147483647
55 %mul = mul i64 %a, 2147483647
59 ; Check the next value up, which should use shifts.
60 define i64 @f7(i64 %a, i64 *%dest) {
62 ; CHECK: sllg %r2, %r2, 31
64 %mul = mul i64 %a, 2147483648
68 ; Check the next value up again, which cannot use a constant multiplicatoin.
69 define i64 @f8(i64 %a, i64 *%dest) {
73 %mul = mul i64 %a, 2147483649
77 ; Check multiplication by -1, which is a negation.
78 define i64 @f9(i64 %a, i64 *%dest) {
80 ; CHECK: lcgr {{%r[0-5]}}, %r2
86 ; Check multiplication by -2, which should use shifts.
87 define i64 @f10(i64 %a, i64 *%dest) {
89 ; CHECK: sllg [[SHIFTED:%r[0-5]]], %r2, 1
90 ; CHECK: lcgr %r2, [[SHIFTED]]
96 ; Check multiplication by -3.
97 define i64 @f11(i64 %a, i64 *%dest) {
101 %mul = mul i64 %a, -3
105 ; Check the lowest useful MGHI value.
106 define i64 @f12(i64 %a, i64 *%dest) {
108 ; CHECK: mghi %r2, -32767
110 %mul = mul i64 %a, -32767
114 ; Check the next value down, which should use shifts.
115 define i64 @f13(i64 %a, i64 *%dest) {
117 ; CHECK: sllg [[SHIFTED:%r[0-5]]], %r2, 15
118 ; CHECK: lcgr %r2, [[SHIFTED]]
120 %mul = mul i64 %a, -32768
124 ; Check the next value down again, which can use MSGFI.
125 define i64 @f14(i64 %a, i64 *%dest) {
127 ; CHECK: msgfi %r2, -32769
129 %mul = mul i64 %a, -32769
133 ; Check the lowest useful MSGFI value.
134 define i64 @f15(i64 %a, i64 *%dest) {
136 ; CHECK: msgfi %r2, -2147483647
138 %mul = mul i64 %a, -2147483647
142 ; Check the next value down, which should use shifts.
143 define i64 @f16(i64 %a, i64 *%dest) {
145 ; CHECK: sllg [[SHIFTED:%r[0-5]]], %r2, 31
146 ; CHECK: lcgr %r2, [[SHIFTED]]
148 %mul = mul i64 %a, -2147483648
152 ; Check the next value down again, which cannot use constant multiplication
153 define i64 @f17(i64 %a, i64 *%dest) {
157 %mul = mul i64 %a, -2147483649