160 lines · plain
1; Test 64-bit multiplication in which the second operand is constant.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s4 5; Check multiplication by 2, which should use shifts.6define i64 @f1(i64 %a, ptr %dest) {7; CHECK-LABEL: f1:8; CHECK: sllg %r2, %r2, 19; CHECK: br %r1410 %mul = mul i64 %a, 211 ret i64 %mul12}13 14; Check multiplication by 3.15define i64 @f2(i64 %a, ptr %dest) {16; CHECK-LABEL: f2:17; CHECK: mghi %r2, 318; CHECK: br %r1419 %mul = mul i64 %a, 320 ret i64 %mul21}22 23; Check the high end of the MGHI range.24define i64 @f3(i64 %a, ptr %dest) {25; CHECK-LABEL: f3:26; CHECK: mghi %r2, 3276727; CHECK: br %r1428 %mul = mul i64 %a, 3276729 ret i64 %mul30}31 32; Check the next value up, which should use shifts.33define i64 @f4(i64 %a, ptr %dest) {34; CHECK-LABEL: f4:35; CHECK: sllg %r2, %r2, 1536; CHECK: br %r1437 %mul = mul i64 %a, 3276838 ret i64 %mul39}40 41; Check the next value up again, which can use MSGFI.42define i64 @f5(i64 %a, ptr %dest) {43; CHECK-LABEL: f5:44; CHECK: msgfi %r2, 3276945; CHECK: br %r1446 %mul = mul i64 %a, 3276947 ret i64 %mul48}49 50; Check the high end of the MSGFI range.51define i64 @f6(i64 %a, ptr %dest) {52; CHECK-LABEL: f6:53; CHECK: msgfi %r2, 214748364754; CHECK: br %r1455 %mul = mul i64 %a, 214748364756 ret i64 %mul57}58 59; Check the next value up, which should use shifts.60define i64 @f7(i64 %a, ptr %dest) {61; CHECK-LABEL: f7:62; CHECK: sllg %r2, %r2, 3163; CHECK: br %r1464 %mul = mul i64 %a, 214748364865 ret i64 %mul66}67 68; Check the next value up again, which cannot use a constant multiplicatoin.69define i64 @f8(i64 %a, ptr %dest) {70; CHECK-LABEL: f8:71; CHECK-NOT: msgfi72; CHECK: br %r1473 %mul = mul i64 %a, 214748364974 ret i64 %mul75}76 77; Check multiplication by -1, which is a negation.78define i64 @f9(i64 %a, ptr %dest) {79; CHECK-LABEL: f9:80; CHECK: lcgr {{%r[0-5]}}, %r281; CHECK: br %r1482 %mul = mul i64 %a, -183 ret i64 %mul84}85 86; Check multiplication by -2, which should use shifts.87define i64 @f10(i64 %a, ptr %dest) {88; CHECK-LABEL: f10:89; CHECK: sllg [[SHIFTED:%r[0-5]]], %r2, 190; CHECK: lcgr %r2, [[SHIFTED]]91; CHECK: br %r1492 %mul = mul i64 %a, -293 ret i64 %mul94}95 96; Check multiplication by -3.97define i64 @f11(i64 %a, ptr %dest) {98; CHECK-LABEL: f11:99; CHECK: mghi %r2, -3100; CHECK: br %r14101 %mul = mul i64 %a, -3102 ret i64 %mul103}104 105; Check the lowest useful MGHI value.106define i64 @f12(i64 %a, ptr %dest) {107; CHECK-LABEL: f12:108; CHECK: mghi %r2, -32767109; CHECK: br %r14110 %mul = mul i64 %a, -32767111 ret i64 %mul112}113 114; Check the next value down, which should use shifts.115define i64 @f13(i64 %a, ptr %dest) {116; CHECK-LABEL: f13:117; CHECK: sllg [[SHIFTED:%r[0-5]]], %r2, 15118; CHECK: lcgr %r2, [[SHIFTED]]119; CHECK: br %r14120 %mul = mul i64 %a, -32768121 ret i64 %mul122}123 124; Check the next value down again, which can use MSGFI.125define i64 @f14(i64 %a, ptr %dest) {126; CHECK-LABEL: f14:127; CHECK: msgfi %r2, -32769128; CHECK: br %r14129 %mul = mul i64 %a, -32769130 ret i64 %mul131}132 133; Check the lowest useful MSGFI value.134define i64 @f15(i64 %a, ptr %dest) {135; CHECK-LABEL: f15:136; CHECK: msgfi %r2, -2147483647137; CHECK: br %r14138 %mul = mul i64 %a, -2147483647139 ret i64 %mul140}141 142; Check the next value down, which should use shifts.143define i64 @f16(i64 %a, ptr %dest) {144; CHECK-LABEL: f16:145; CHECK: sllg [[SHIFTED:%r[0-5]]], %r2, 31146; CHECK: lcgr %r2, [[SHIFTED]]147; CHECK: br %r14148 %mul = mul i64 %a, -2147483648149 ret i64 %mul150}151 152; Check the next value down again, which cannot use constant multiplication153define i64 @f17(i64 %a, ptr %dest) {154; CHECK-LABEL: f17:155; CHECK-NOT: msgfi156; CHECK: br %r14157 %mul = mul i64 %a, -2147483649158 ret i64 %mul159}160