1; Test that divisions by constants are implemented as multiplications. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu -asm-verbose=0 | FileCheck %s 4 5; Check signed 32-bit division. 6define i32 @f1(i32 %a) { 7; CHECK-LABEL: f1: 8; CHECK: lgfr [[REG:%r[0-5]]], %r2 9; CHECK: msgfi [[REG]], 502748801 10; CHECK-DAG: srlg [[RES1:%r[0-5]]], [[REG]], 63 11; CHECK-DAG: srag %r2, [[REG]], 46 12; CHECK: ar %r2, [[RES1]] 13; CHECK: br %r14 14 %b = sdiv i32 %a, 139968 15 ret i32 %b 16} 17 18; Check unsigned 32-bit division. 19define i32 @f2(i32 %a) { 20; CHECK-LABEL: f2: 21; CHECK: llgfr [[REG:%r[0-5]]], %r2 22; CHECK: msgfi [[REG]], 502748801 23; CHECK: srlg %r2, [[REG]], 46 24; CHECK: br %r14 25 %b = udiv i32 %a, 139968 26 ret i32 %b 27} 28 29; Check signed 64-bit division. 30define i64 @f3(i64 %dummy, i64 %a) { 31; CHECK-LABEL: f3: 32; CHECK-DAG: llihf [[CONST:%r[0-5]]], 1005497601 33; CHECK-DAG: oilf [[CONST]], 4251762321 34; CHECK-DAG: srag [[REG:%r[0-5]]], %r3, 63 35; CHECK-DAG: ngr [[REG]], [[CONST]] 36; CHECK-DAG: mlgr %r2, [[CONST]] 37; CHECK: sgr %r2, [[REG]] 38; CHECK: srlg [[RES1:%r[0-5]]], %r2, 63 39; CHECK: srag %r2, %r2, 15 40; CHECK: agr %r2, [[RES1]] 41; CHECK: br %r14 42 %b = sdiv i64 %a, 139968 43 ret i64 %b 44} 45 46; Check unsigned 64-bit division. 47define i64 @f4(i64 %dummy, i64 %a) { 48; CHECK-LABEL: f4: 49; CHECK: llihf [[CONST:%r[0-5]]], 1005497601 50; CHECK: oilf [[CONST]], 4251762321 51; CHECK: mlgr %r2, [[CONST]] 52; CHECK: srlg %r2, %r2, 15 53; CHECK: br %r14 54 %b = udiv i64 %a, 139968 55 ret i64 %b 56} 57