1 ; RUN: llc -march=mips64el -mcpu=mips4 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,MIPS4,ACCMULDIV %s
2 ; RUN: llc -march=mips64el -mcpu=mips64 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,HAS-DCLO,ACCMULDIV %s
3 ; RUN: llc -march=mips64el -mcpu=mips64r2 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,HAS-DCLO,ACCMULDIV %s
4 ; RUN: llc -march=mips64el -mcpu=mips64r6 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,HAS-DCLO,GPRMULDIV %s
6 @gll0 = common global i64 0, align 8
7 @gll1 = common global i64 0, align 8
9 define i64 @f0(i64 %a0, i64 %a1) nounwind readnone {
12 ; ALL: daddu $2, ${{[45]}}, ${{[45]}}
13 %add = add nsw i64 %a1, %a0
17 define i64 @f1(i64 %a0, i64 %a1) nounwind readnone {
20 ; ALL: dsubu $2, $4, $5
21 %sub = sub nsw i64 %a0, %a1
25 define i64 @f4(i64 %a0, i64 %a1) nounwind readnone {
28 ; ALL: and $2, ${{[45]}}, ${{[45]}}
29 %and = and i64 %a1, %a0
33 define i64 @f5(i64 %a0, i64 %a1) nounwind readnone {
36 ; ALL: or $2, ${{[45]}}, ${{[45]}}
41 define i64 @f6(i64 %a0, i64 %a1) nounwind readnone {
44 ; ALL: xor $2, ${{[45]}}, ${{[45]}}
45 %xor = xor i64 %a1, %a0
49 define i64 @f7(i64 %a0) nounwind readnone {
52 ; ALL: daddiu $2, $4, 20
53 %add = add nsw i64 %a0, 20
57 define i64 @f8(i64 %a0) nounwind readnone {
60 ; ALL: daddiu $2, $4, -20
61 %sub = add nsw i64 %a0, -20
65 define i64 @f9(i64 %a0) nounwind readnone {
68 ; ALL: andi $2, $4, 20
69 %and = and i64 %a0, 20
73 define i64 @f10(i64 %a0) nounwind readnone {
81 define i64 @f11(i64 %a0) nounwind readnone {
84 ; ALL: xori $2, $4, 20
85 %xor = xor i64 %a0, 20
89 define i64 @f12(i64 %a, i64 %b) nounwind readnone {
93 ; ACCMULDIV: mult ${{[45]}}, ${{[45]}}
94 ; GPRMULDIV: dmul $2, ${{[45]}}, ${{[45]}}
96 %mul = mul nsw i64 %b, %a
100 define i64 @f13(i64 %a, i64 %b) nounwind readnone {
104 ; ACCMULDIV: mult ${{[45]}}, ${{[45]}}
105 ; GPRMULDIV: dmul $2, ${{[45]}}, ${{[45]}}
107 %mul = mul i64 %b, %a
111 define i64 @f14(i64 %a, i64 %b) nounwind readnone {
114 ; ALL-DAG: ld $[[T0:[0-9]+]], %lo(gll0)(${{[0-9]+}})
115 ; ALL-DAG: ld $[[T1:[0-9]+]], %lo(gll1)(${{[0-9]+}})
117 ; ACCMULDIV: ddiv $zero, $[[T0]], $[[T1]]
118 ; ACCMULDIV: teq $[[T1]], $zero, 7
121 ; GPRMULDIV: ddiv $2, $[[T0]], $[[T1]]
122 ; GPRMULDIV: teq $[[T1]], $zero, 7
124 %0 = load i64, ptr @gll0, align 8
125 %1 = load i64, ptr @gll1, align 8
126 %div = sdiv i64 %0, %1
130 define i64 @f15() nounwind readnone {
133 ; ALL-DAG: ld $[[T0:[0-9]+]], %lo(gll0)(${{[0-9]+}})
134 ; ALL-DAG: ld $[[T1:[0-9]+]], %lo(gll1)(${{[0-9]+}})
136 ; ACCMULDIV: ddivu $zero, $[[T0]], $[[T1]]
137 ; ACCMULDIV: teq $[[T1]], $zero, 7
140 ; GPRMULDIV: ddivu $2, $[[T0]], $[[T1]]
141 ; GPRMULDIV: teq $[[T1]], $zero, 7
143 %0 = load i64, ptr @gll0, align 8
144 %1 = load i64, ptr @gll1, align 8
145 %div = udiv i64 %0, %1
149 define i64 @f16(i64 %a, i64 %b) nounwind readnone {
153 ; ACCMULDIV: ddiv $zero, $4, $5
154 ; ACCMULDIV: teq $5, $zero, 7
157 ; GPRMULDIV: dmod $2, $4, $5
158 ; GPRMULDIV: teq $5, $zero, 7
160 %rem = srem i64 %a, %b
164 define i64 @f17(i64 %a, i64 %b) nounwind readnone {
168 ; ACCMULDIV: ddivu $zero, $4, $5
169 ; ACCMULDIV: teq $5, $zero, 7
172 ; GPRMULDIV: dmodu $2, $4, $5
173 ; GPRMULDIV: teq $5, $zero, 7
175 %rem = urem i64 %a, %b
179 declare i64 @llvm.ctlz.i64(i64, i1) nounwind readnone
181 define i64 @f18(i64 %X) nounwind readnone {
185 ; The MIPS4 version is too long to reasonably test. At least check we don't get dclz
188 ; HAS-DCLO: dclz $2, $4
190 %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %X, i1 true)
194 define i64 @f19(i64 %X) nounwind readnone {
198 ; The MIPS4 version is too long to reasonably test. At least check we don't get dclo
201 ; HAS-DCLO: dclo $2, $4
203 %neg = xor i64 %X, -1
204 %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %neg, i1 true)
208 define i64 @f20(i64 %a, i64 %b) nounwind readnone {
211 ; ALL: nor $2, ${{[45]}}, ${{[45]}}
213 %neg = xor i64 %or, -1