[mips][mips64r6] Improve tests affected by the changes to multiplies and divides
[oota-llvm.git] / test / CodeGen / Mips / mips64instrs.ll
1 ; RUN: llc -march=mips64el -mcpu=mips4 -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=MIPS4 %s
2 ; RUN: llc -march=mips64el -mcpu=mips64 -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=MIPS64 %s
3
4 @gll0 = common global i64 0, align 8
5 @gll1 = common global i64 0, align 8
6
7 define i64 @f0(i64 %a0, i64 %a1) nounwind readnone {
8 entry:
9 ; ALL-LABEL: f0:
10 ; ALL:           daddu $2, ${{[45]}}, ${{[45]}}
11   %add = add nsw i64 %a1, %a0
12   ret i64 %add
13 }
14
15 define i64 @f1(i64 %a0, i64 %a1) nounwind readnone {
16 entry:
17 ; ALL-LABEL: f1:
18 ; ALL:           dsubu $2, $4, $5
19   %sub = sub nsw i64 %a0, %a1
20   ret i64 %sub
21 }
22
23 define i64 @f4(i64 %a0, i64 %a1) nounwind readnone {
24 entry:
25 ; ALL-LABEL: f4:
26 ; ALL:           and $2, ${{[45]}}, ${{[45]}}
27   %and = and i64 %a1, %a0
28   ret i64 %and
29 }
30
31 define i64 @f5(i64 %a0, i64 %a1) nounwind readnone {
32 entry:
33 ; ALL-LABEL: f5:
34 ; ALL:           or $2, ${{[45]}}, ${{[45]}}
35   %or = or i64 %a1, %a0
36   ret i64 %or
37 }
38
39 define i64 @f6(i64 %a0, i64 %a1) nounwind readnone {
40 entry:
41 ; ALL-LABEL: f6:
42 ; ALL:           xor $2, ${{[45]}}, ${{[45]}}
43   %xor = xor i64 %a1, %a0
44   ret i64 %xor
45 }
46
47 define i64 @f7(i64 %a0) nounwind readnone {
48 entry:
49 ; ALL-LABEL: f7:
50 ; ALL:           daddiu $2, $4, 20
51   %add = add nsw i64 %a0, 20
52   ret i64 %add
53 }
54
55 define i64 @f8(i64 %a0) nounwind readnone {
56 entry:
57 ; ALL-LABEL: f8:
58 ; ALL:           daddiu $2, $4, -20
59   %sub = add nsw i64 %a0, -20
60   ret i64 %sub
61 }
62
63 define i64 @f9(i64 %a0) nounwind readnone {
64 entry:
65 ; ALL-LABEL: f9:
66 ; ALL:           andi $2, $4, 20
67   %and = and i64 %a0, 20
68   ret i64 %and
69 }
70
71 define i64 @f10(i64 %a0) nounwind readnone {
72 entry:
73 ; ALL-LABEL: f10:
74 ; ALL:           ori $2, $4, 20
75   %or = or i64 %a0, 20
76   ret i64 %or
77 }
78
79 define i64 @f11(i64 %a0) nounwind readnone {
80 entry:
81 ; ALL-LABEL: f11:
82 ; ALL:           xori $2, $4, 20
83   %xor = xor i64 %a0, 20
84   ret i64 %xor
85 }
86
87 define i64 @f12(i64 %a, i64 %b) nounwind readnone {
88 entry:
89 ; ALL-LABEL: f12:
90 ; ALL:           mult ${{[45]}}, ${{[45]}}
91   %mul = mul nsw i64 %b, %a
92   ret i64 %mul
93 }
94
95 define i64 @f13(i64 %a, i64 %b) nounwind readnone {
96 entry:
97 ; ALL-LABEL: f13:
98 ; ALL:           mult ${{[45]}}, ${{[45]}}
99   %mul = mul i64 %b, %a
100   ret i64 %mul
101 }
102
103 define i64 @f14(i64 %a, i64 %b) nounwind readnone {
104 entry:
105 ; ALL-LABEL: f14:
106 ; ALL-DAG:       ld $[[P0:[0-9]+]], %got_disp(gll0)(
107 ; ALL-DAG:       ld $[[P1:[0-9]+]], %got_disp(gll1)(
108 ; ALL-DAG:       ld $[[T0:[0-9]+]], 0($[[P0]])
109 ; ALL-DAG:       ld $[[T1:[0-9]+]], 0($[[P1]])
110 ; ALL:           ddiv $zero, $[[T0]], $[[T1]]
111 ; ALL:           teq $[[T1]], $zero, 7
112 ; ALL:           mflo $2
113   %0 = load i64* @gll0, align 8
114   %1 = load i64* @gll1, align 8
115   %div = sdiv i64 %0, %1
116   ret i64 %div
117 }
118
119 define i64 @f15() nounwind readnone {
120 entry:
121 ; ALL-LABEL: f15:
122 ; ALL-DAG:       ld $[[P0:[0-9]+]], %got_disp(gll0)(
123 ; ALL-DAG:       ld $[[P1:[0-9]+]], %got_disp(gll1)(
124 ; ALL-DAG:       ld $[[T0:[0-9]+]], 0($[[P0]])
125 ; ALL-DAG:       ld $[[T1:[0-9]+]], 0($[[P1]])
126 ; ALL:           ddivu $zero, $[[T0]], $[[T1]]
127 ; ALL:           teq $[[T1]], $zero, 7
128 ; ALL:           mflo $2
129   %0 = load i64* @gll0, align 8
130   %1 = load i64* @gll1, align 8
131   %div = udiv i64 %0, %1
132   ret i64 %div
133 }
134
135 define i64 @f16(i64 %a, i64 %b) nounwind readnone {
136 entry:
137 ; ALL-LABEL: f16:
138 ; ALL:           ddiv $zero, $4, $5
139 ; ALL:           teq $5, $zero, 7
140 ; ALL:           mfhi $2
141   %rem = srem i64 %a, %b
142   ret i64 %rem
143 }
144
145 define i64 @f17(i64 %a, i64 %b) nounwind readnone {
146 entry:
147 ; ALL-LABEL: f17:
148 ; ALL:           ddivu $zero, $4, $5
149 ; ALL:           teq $5, $zero, 7
150 ; ALL:           mfhi $2
151   %rem = urem i64 %a, %b
152   ret i64 %rem
153 }
154
155 declare i64 @llvm.ctlz.i64(i64, i1) nounwind readnone
156
157 define i64 @f18(i64 %X) nounwind readnone {
158 entry:
159 ; ALL-LABEL: f18:
160
161 ; The MIPS4 version is too long to reasonably test. At least check we don't get dclz
162 ; MIPS4-NOT:     dclz
163
164 ; MIPS64:        dclz $2, $4
165   %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %X, i1 true)
166   ret i64 %tmp1
167 }
168
169 define i64 @f19(i64 %X) nounwind readnone {
170 entry:
171 ; ALL-LABEL: f19:
172
173 ; The MIPS4 version is too long to reasonably test. At least check we don't get dclo
174 ; MIPS4-NOT:     dclo
175
176 ; MIPS64:        dclo $2, $4
177   %neg = xor i64 %X, -1
178   %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %neg, i1 true)
179   ret i64 %tmp1
180 }
181
182 define i64 @f20(i64 %a, i64 %b) nounwind readnone {
183 entry:
184 ; ALL-LABEL: f20:
185 ; ALL:           nor $2, ${{[45]}}, ${{[45]}}
186   %or = or i64 %b, %a
187   %neg = xor i64 %or, -1
188   ret i64 %neg
189 }