1 ; Test that divisions by constants are implemented as multiplications.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -asm-verbose=0 | FileCheck %s
5 ; Check signed 32-bit division.
6 define i32 @f1(i32 %a) {
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]]
14 %b = sdiv i32 %a, 139968
18 ; Check unsigned 32-bit division.
19 define i32 @f2(i32 %a) {
21 ; CHECK: llgfr [[REG:%r[0-5]]], %r2
22 ; CHECK: msgfi [[REG]], 502748801
23 ; CHECK: srlg %r2, [[REG]], 46
25 %b = udiv i32 %a, 139968
29 ; Check signed 64-bit division.
30 define i64 @f3(i64 %dummy, i64 %a) {
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]]
42 %b = sdiv i64 %a, 139968
46 ; Check unsigned 64-bit division.
47 define i64 @f4(i64 %dummy, i64 %a) {
49 ; CHECK: llihf [[CONST:%r[0-5]]], 1005497601
50 ; CHECK: oilf [[CONST]], 4251762321
51 ; CHECK: mlgr %r2, [[CONST]]
52 ; CHECK: srlg %r2, %r2, 15
54 %b = udiv i64 %a, 139968