160 lines · plain
1; Test 32-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 i32 @f1(i32 %a, ptr %dest) {7; CHECK-LABEL: f1:8; CHECK: sll %r2, 19; CHECK: br %r1410 %mul = mul i32 %a, 211 ret i32 %mul12}13 14; Check multiplication by 3.15define i32 @f2(i32 %a, ptr %dest) {16; CHECK-LABEL: f2:17; CHECK: mhi %r2, 318; CHECK: br %r1419 %mul = mul i32 %a, 320 ret i32 %mul21}22 23; Check the high end of the MHI range.24define i32 @f3(i32 %a, ptr %dest) {25; CHECK-LABEL: f3:26; CHECK: mhi %r2, 3276727; CHECK: br %r1428 %mul = mul i32 %a, 3276729 ret i32 %mul30}31 32; Check the next value up, which should use shifts.33define i32 @f4(i32 %a, ptr %dest) {34; CHECK-LABEL: f4:35; CHECK: sll %r2, 1536; CHECK: br %r1437 %mul = mul i32 %a, 3276838 ret i32 %mul39}40 41; Check the next value up again, which can use MSFI.42define i32 @f5(i32 %a, ptr %dest) {43; CHECK-LABEL: f5:44; CHECK: msfi %r2, 3276945; CHECK: br %r1446 %mul = mul i32 %a, 3276947 ret i32 %mul48}49 50; Check the high end of the MSFI range.51define i32 @f6(i32 %a, ptr %dest) {52; CHECK-LABEL: f6:53; CHECK: msfi %r2, 214748364754; CHECK: br %r1455 %mul = mul i32 %a, 214748364756 ret i32 %mul57}58 59; Check the next value up, which should use shifts.60define i32 @f7(i32 %a, ptr %dest) {61; CHECK-LABEL: f7:62; CHECK: sll %r2, 3163; CHECK: br %r1464 %mul = mul i32 %a, 214748364865 ret i32 %mul66}67 68; Check the next value up again, which is treated as a negative value.69define i32 @f8(i32 %a, ptr %dest) {70; CHECK-LABEL: f8:71; CHECK: msfi %r2, -214748364772; CHECK: br %r1473 %mul = mul i32 %a, 214748364974 ret i32 %mul75}76 77; Check multiplication by -1, which is a negation.78define i32 @f9(i32 %a, ptr %dest) {79; CHECK-LABEL: f9:80; CHECK: lcr %r2, %r281; CHECK: br %r1482 %mul = mul i32 %a, -183 ret i32 %mul84}85 86; Check multiplication by -2, which should use shifts.87define i32 @f10(i32 %a, ptr %dest) {88; CHECK-LABEL: f10:89; CHECK: sll %r2, 190; CHECK: lcr %r2, %r291; CHECK: br %r1492 %mul = mul i32 %a, -293 ret i32 %mul94}95 96; Check multiplication by -3.97define i32 @f11(i32 %a, ptr %dest) {98; CHECK-LABEL: f11:99; CHECK: mhi %r2, -3100; CHECK: br %r14101 %mul = mul i32 %a, -3102 ret i32 %mul103}104 105; Check the lowest useful MHI value.106define i32 @f12(i32 %a, ptr %dest) {107; CHECK-LABEL: f12:108; CHECK: mhi %r2, -32767109; CHECK: br %r14110 %mul = mul i32 %a, -32767111 ret i32 %mul112}113 114; Check the next value down, which should use shifts.115define i32 @f13(i32 %a, ptr %dest) {116; CHECK-LABEL: f13:117; CHECK: sll %r2, 15118; CHECK: lcr %r2, %r2119; CHECK: br %r14120 %mul = mul i32 %a, -32768121 ret i32 %mul122}123 124; Check the next value down again, which can use MSFI.125define i32 @f14(i32 %a, ptr %dest) {126; CHECK-LABEL: f14:127; CHECK: msfi %r2, -32769128; CHECK: br %r14129 %mul = mul i32 %a, -32769130 ret i32 %mul131}132 133; Check the lowest useful MSFI value.134define i32 @f15(i32 %a, ptr %dest) {135; CHECK-LABEL: f15:136; CHECK: msfi %r2, -2147483647137; CHECK: br %r14138 %mul = mul i32 %a, -2147483647139 ret i32 %mul140}141 142; Check the next value down, which should use shifts.143define i32 @f16(i32 %a, ptr %dest) {144; CHECK-LABEL: f16:145; CHECK: sll %r2, 31146; CHECK-NOT: lcr147; CHECK: br %r14148 %mul = mul i32 %a, -2147483648149 ret i32 %mul150}151 152; Check the next value down again, which is treated as a positive value.153define i32 @f17(i32 %a, ptr %dest) {154; CHECK-LABEL: f17:155; CHECK: msfi %r2, 2147483647156; CHECK: br %r14157 %mul = mul i32 %a, -2147483649158 ret i32 %mul159}160