Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests_lit/llvm2ice_tests/arith.ll

Issue 1414383004: Lower a few basic MIPS binops for i{8,16,32,64}. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: patch 2 per change requests from stichnot Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 ; Assembly test for simple arithmetic operations. 1 ; Assembly test for simple arithmetic operations.
2 2
3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ 3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
4 ; RUN: --target x8632 -i %s --args -O2 \ 4 ; RUN: --target x8632 -i %s --args -O2 \
5 ; RUN: | %if --need=target_X8632 --command FileCheck %s 5 ; RUN: | %if --need=target_X8632 --command FileCheck %s
6 6
7 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) 7 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented)
8 ; once enough infrastructure is in. Also, switch to --filetype=obj 8 ; once enough infrastructure is in. Also, switch to --filetype=obj
9 ; when possible. 9 ; when possible.
10 ; RUN: %if --need=target_ARM32 --need=allow_dump \ 10 ; RUN: %if --need=target_ARM32 --need=allow_dump \
11 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \ 11 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \
12 ; RUN: -i %s --args -O2 --skip-unimplemented \ 12 ; RUN: -i %s --args -O2 --skip-unimplemented \
13 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ 13 ; RUN: | %if --need=target_ARM32 --need=allow_dump \
14 ; RUN: --command FileCheck --check-prefix ARM32 %s 14 ; RUN: --command FileCheck --check-prefix ARM32 %s
15 ; RUN: %if --need=target_ARM32 --need=allow_dump \ 15 ; RUN: %if --need=target_ARM32 --need=allow_dump \
16 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \ 16 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \
17 ; RUN: -i %s --args -O2 --mattr=hwdiv-arm --skip-unimplemented \ 17 ; RUN: -i %s --args -O2 --mattr=hwdiv-arm --skip-unimplemented \
18 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ 18 ; RUN: | %if --need=target_ARM32 --need=allow_dump \
19 ; RUN: --command FileCheck --check-prefix ARM32HWDIV %s 19 ; RUN: --command FileCheck --check-prefix ARM32HWDIV %s
20 ; RUN: %if --need=target_ARM32 --need=allow_dump \ 20 ; RUN: %if --need=target_ARM32 --need=allow_dump \
21 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \ 21 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target arm32 \
22 ; RUN: -i %s --args -Om1 --skip-unimplemented \ 22 ; RUN: -i %s --args -Om1 --skip-unimplemented \
23 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ 23 ; RUN: | %if --need=target_ARM32 --need=allow_dump \
24 ; RUN: --command FileCheck --check-prefix ARM32 %s 24 ; RUN: --command FileCheck --check-prefix ARM32 %s
25 ;
26 ; RUN: %if --need=target_MIPS32 --need=allow_dump \
27 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target mips32\
28 ; RUN: -i %s --args -O2 --skip-unimplemented \
29 ; RUN: | %if --need=target_MIPS32 --need=allow_dump \
30 ; RUN: --command FileCheck --check-prefix MIPS32 %s
31
32 ; RUN: %if --need=target_MIPS32 --need=allow_dump \
33 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target mips32\
34 ; RUN: -i %s --args -Om1 --skip-unimplemented \
35 ; RUN: | %if --need=target_MIPS32 --need=allow_dump \
36 ; RUN: --command FileCheck --check-prefix MIPS32 %s
25 37
26 define internal i32 @Add(i32 %a, i32 %b) { 38 define internal i32 @Add(i32 %a, i32 %b) {
27 entry: 39 entry:
28 %add = add i32 %b, %a 40 %add = add i32 %b, %a
29 ret i32 %add 41 ret i32 %add
30 } 42 }
31 ; CHECK-LABEL: Add 43 ; CHECK-LABEL: Add
32 ; CHECK: add e 44 ; CHECK: add e
33 ; ARM32-LABEL: Add 45 ; ARM32-LABEL: Add
34 ; ARM32: add r 46 ; ARM32: add r
47 ; MIPS32-LABEL: Add
48 ; MIPS32: add
35 49
36 define internal i32 @And(i32 %a, i32 %b) { 50 define internal i32 @And(i32 %a, i32 %b) {
37 entry: 51 entry:
38 %and = and i32 %b, %a 52 %and = and i32 %b, %a
39 ret i32 %and 53 ret i32 %and
40 } 54 }
41 ; CHECK-LABEL: And 55 ; CHECK-LABEL: And
42 ; CHECK: and e 56 ; CHECK: and e
43 ; ARM32-LABEL: And 57 ; ARM32-LABEL: And
44 ; ARM32: and r 58 ; ARM32: and r
59 ; MIPS32-LABEL: And
60 ; MIPS32: and
45 61
46 define internal i32 @Or(i32 %a, i32 %b) { 62 define internal i32 @Or(i32 %a, i32 %b) {
47 entry: 63 entry:
48 %or = or i32 %b, %a 64 %or = or i32 %b, %a
49 ret i32 %or 65 ret i32 %or
50 } 66 }
51 ; CHECK-LABEL: Or 67 ; CHECK-LABEL: Or
52 ; CHECK: or e 68 ; CHECK: or e
53 ; ARM32-LABEL: Or 69 ; ARM32-LABEL: Or
54 ; ARM32: orr r 70 ; ARM32: orr r
71 ; MIPS32-LABEL: Or
72 ; MIPS32: or
55 73
56 define internal i32 @Xor(i32 %a, i32 %b) { 74 define internal i32 @Xor(i32 %a, i32 %b) {
57 entry: 75 entry:
58 %xor = xor i32 %b, %a 76 %xor = xor i32 %b, %a
59 ret i32 %xor 77 ret i32 %xor
60 } 78 }
61 ; CHECK-LABEL: Xor 79 ; CHECK-LABEL: Xor
62 ; CHECK: xor e 80 ; CHECK: xor e
63 ; ARM32-LABEL: Xor 81 ; ARM32-LABEL: Xor
64 ; ARM32: eor r 82 ; ARM32: eor r
83 ; MIPS32-LABEL: Xor
84 ; MIPS32: xor
65 85
66 define internal i32 @Sub(i32 %a, i32 %b) { 86 define internal i32 @Sub(i32 %a, i32 %b) {
67 entry: 87 entry:
68 %sub = sub i32 %a, %b 88 %sub = sub i32 %a, %b
69 ret i32 %sub 89 ret i32 %sub
70 } 90 }
71 ; CHECK-LABEL: Sub 91 ; CHECK-LABEL: Sub
72 ; CHECK: sub e 92 ; CHECK: sub e
73 ; ARM32-LABEL: Sub 93 ; ARM32-LABEL: Sub
74 ; ARM32: sub r 94 ; ARM32: sub r
95 ; MIPS32-LABEL: Sub
96 ; MIPS32: sub
75 97
76 define internal i32 @Mul(i32 %a, i32 %b) { 98 define internal i32 @Mul(i32 %a, i32 %b) {
77 entry: 99 entry:
78 %mul = mul i32 %b, %a 100 %mul = mul i32 %b, %a
79 ret i32 %mul 101 ret i32 %mul
80 } 102 }
81 ; CHECK-LABEL: Mul 103 ; CHECK-LABEL: Mul
82 ; CHECK: imul e 104 ; CHECK: imul e
83 ; ARM32-LABEL: Mul 105 ; ARM32-LABEL: Mul
84 ; ARM32: mul r 106 ; ARM32: mul r
107 ; MIPS32-LABEL: Mul
108 ; MIPS32: mul
85 109
86 ; Check for a valid ARM mul instruction where operands have to be registers. 110 ; Check for a valid ARM mul instruction where operands have to be registers.
87 ; On the other hand x86-32 does allow an immediate. 111 ; On the other hand x86-32 does allow an immediate.
88 define internal i32 @MulImm(i32 %a, i32 %b) { 112 define internal i32 @MulImm(i32 %a, i32 %b) {
89 entry: 113 entry:
90 %mul = mul i32 %a, 99 114 %mul = mul i32 %a, 99
91 ret i32 %mul 115 ret i32 %mul
92 } 116 }
93 ; CHECK-LABEL: MulImm 117 ; CHECK-LABEL: MulImm
94 ; CHECK: imul e{{.*}},e{{.*}},0x63 118 ; CHECK: imul e{{.*}},e{{.*}},0x63
95 ; ARM32-LABEL: MulImm 119 ; ARM32-LABEL: MulImm
96 ; ARM32: mov {{.*}}, #99 120 ; ARM32: mov {{.*}}, #99
97 ; ARM32: mul r{{.*}}, r{{.*}}, r{{.*}} 121 ; ARM32: mul r{{.*}}, r{{.*}}, r{{.*}}
122 ; MIPS32-LABEL: MulImm
123 ; MIPS32: mul
98 124
99 ; Check for a valid addressing mode in the x86-32 mul instruction when 125 ; Check for a valid addressing mode in the x86-32 mul instruction when
100 ; the second source operand is an immediate. 126 ; the second source operand is an immediate.
101 define internal i64 @MulImm64(i64 %a) { 127 define internal i64 @MulImm64(i64 %a) {
102 entry: 128 entry:
103 %mul = mul i64 %a, 99 129 %mul = mul i64 %a, 99
104 ret i64 %mul 130 ret i64 %mul
105 } 131 }
106 ; NOTE: the lowering is currently a bit inefficient for small 64-bit constants. 132 ; NOTE: the lowering is currently a bit inefficient for small 64-bit constants.
107 ; The top bits of the immediate are 0, but the instructions modeling that 133 ; The top bits of the immediate are 0, but the instructions modeling that
108 ; multiply by 0 are not eliminated (see expanded 64-bit ARM lowering). 134 ; multiply by 0 are not eliminated (see expanded 64-bit ARM lowering).
109 ; CHECK-LABEL: MulImm64 135 ; CHECK-LABEL: MulImm64
110 ; CHECK: mov {{.*}},0x63 136 ; CHECK: mov {{.*}},0x63
111 ; CHECK: mov {{.*}},0x0 137 ; CHECK: mov {{.*}},0x0
112 ; CHECK-NOT: mul {{[0-9]+}} 138 ; CHECK-NOT: mul {{[0-9]+}}
113 ; 139 ;
114 ; ARM32-LABEL: MulImm64 140 ; ARM32-LABEL: MulImm64
115 ; ARM32: movw {{.*}}, #99 141 ; ARM32: movw {{.*}}, #99
116 ; ARM32: movw {{.*}}, #0 142 ; ARM32: movw {{.*}}, #0
117 ; ARM32: mul r 143 ; ARM32: mul r
118 ; ARM32: mla r 144 ; ARM32: mla r
119 ; ARM32: umull r 145 ; ARM32: umull r
120 ; ARM32: add r 146 ; ARM32: add r
121 147
148 ; MIPS32-LABEL: MulImm64
149
122 define internal i32 @Sdiv(i32 %a, i32 %b) { 150 define internal i32 @Sdiv(i32 %a, i32 %b) {
123 entry: 151 entry:
124 %div = sdiv i32 %a, %b 152 %div = sdiv i32 %a, %b
125 ret i32 %div 153 ret i32 %div
126 } 154 }
127 ; CHECK-LABEL: Sdiv 155 ; CHECK-LABEL: Sdiv
128 ; CHECK: cdq 156 ; CHECK: cdq
129 ; CHECK: idiv e 157 ; CHECK: idiv e
130 ; 158 ;
131 ; ARM32-LABEL: Sdiv 159 ; ARM32-LABEL: Sdiv
132 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] 160 ; ARM32: tst [[DENOM:r.*]], [[DENOM]]
133 ; ARM32: bne 161 ; ARM32: bne
134 ; ARM32: .word 0xe7fedef0 162 ; ARM32: .word 0xe7fedef0
135 ; ARM32: {{.*}} bl {{.*}} __divsi3 163 ; ARM32: {{.*}} bl {{.*}} __divsi3
136 ; ARM32HWDIV-LABEL: Sdiv 164 ; ARM32HWDIV-LABEL: Sdiv
137 ; ARM32HWDIV: tst 165 ; ARM32HWDIV: tst
138 ; ARM32HWDIV: bne 166 ; ARM32HWDIV: bne
139 ; ARM32HWDIV: sdiv 167 ; ARM32HWDIV: sdiv
140 168
169 ; MIPS32-LABEL: Sdiv
170
141 define internal i32 @SdivConst(i32 %a) { 171 define internal i32 @SdivConst(i32 %a) {
142 entry: 172 entry:
143 %div = sdiv i32 %a, 219 173 %div = sdiv i32 %a, 219
144 ret i32 %div 174 ret i32 %div
145 } 175 }
146 ; CHECK-LABEL: SdivConst 176 ; CHECK-LABEL: SdivConst
147 ; CHECK: cdq 177 ; CHECK: cdq
148 ; CHECK: idiv e 178 ; CHECK: idiv e
149 ; 179 ;
150 ; ARM32-LABEL: SdivConst 180 ; ARM32-LABEL: SdivConst
151 ; ARM32-NOT: tst 181 ; ARM32-NOT: tst
152 ; ARM32: bl {{.*}} __divsi3 182 ; ARM32: bl {{.*}} __divsi3
153 ; ARM32HWDIV-LABEL: SdivConst 183 ; ARM32HWDIV-LABEL: SdivConst
154 ; ARM32HWDIV-NOT: tst 184 ; ARM32HWDIV-NOT: tst
155 ; ARM32HWDIV: sdiv 185 ; ARM32HWDIV: sdiv
156 186
187 ; MIPS32-LABEL: SdivConst
188
157 define internal i32 @Srem(i32 %a, i32 %b) { 189 define internal i32 @Srem(i32 %a, i32 %b) {
158 entry: 190 entry:
159 %rem = srem i32 %a, %b 191 %rem = srem i32 %a, %b
160 ret i32 %rem 192 ret i32 %rem
161 } 193 }
162 ; CHECK-LABEL: Srem 194 ; CHECK-LABEL: Srem
163 ; CHECK: cdq 195 ; CHECK: cdq
164 ; CHECK: idiv e 196 ; CHECK: idiv e
165 ; 197 ;
166 ; ARM32-LABEL: Srem 198 ; ARM32-LABEL: Srem
167 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] 199 ; ARM32: tst [[DENOM:r.*]], [[DENOM]]
168 ; ARM32: bne 200 ; ARM32: bne
169 ; ARM32: bl {{.*}} __modsi3 201 ; ARM32: bl {{.*}} __modsi3
170 ; ARM32HWDIV-LABEL: Srem 202 ; ARM32HWDIV-LABEL: Srem
171 ; ARM32HWDIV: tst 203 ; ARM32HWDIV: tst
172 ; ARM32HWDIV: bne 204 ; ARM32HWDIV: bne
173 ; ARM32HWDIV: sdiv 205 ; ARM32HWDIV: sdiv
174 ; ARM32HWDIV: mls 206 ; ARM32HWDIV: mls
175 207
208 ; MIPS32-LABEL: Srem
209
176 define internal i32 @Udiv(i32 %a, i32 %b) { 210 define internal i32 @Udiv(i32 %a, i32 %b) {
177 entry: 211 entry:
178 %div = udiv i32 %a, %b 212 %div = udiv i32 %a, %b
179 ret i32 %div 213 ret i32 %div
180 } 214 }
181 ; CHECK-LABEL: Udiv 215 ; CHECK-LABEL: Udiv
182 ; CHECK: div e 216 ; CHECK: div e
183 ; 217 ;
184 ; ARM32-LABEL: Udiv 218 ; ARM32-LABEL: Udiv
185 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] 219 ; ARM32: tst [[DENOM:r.*]], [[DENOM]]
186 ; ARM32: bne 220 ; ARM32: bne
187 ; ARM32: bl {{.*}} __udivsi3 221 ; ARM32: bl {{.*}} __udivsi3
188 ; ARM32HWDIV-LABEL: Udiv 222 ; ARM32HWDIV-LABEL: Udiv
189 ; ARM32HWDIV: tst 223 ; ARM32HWDIV: tst
190 ; ARM32HWDIV: bne 224 ; ARM32HWDIV: bne
191 ; ARM32HWDIV: udiv 225 ; ARM32HWDIV: udiv
192 226
227 ; MIPS32-LABEL: Udiv
228
193 define internal i32 @Urem(i32 %a, i32 %b) { 229 define internal i32 @Urem(i32 %a, i32 %b) {
194 entry: 230 entry:
195 %rem = urem i32 %a, %b 231 %rem = urem i32 %a, %b
196 ret i32 %rem 232 ret i32 %rem
197 } 233 }
198 ; CHECK-LABEL: Urem 234 ; CHECK-LABEL: Urem
199 ; CHECK: div e 235 ; CHECK: div e
200 ; 236 ;
201 ; ARM32-LABEL: Urem 237 ; ARM32-LABEL: Urem
202 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] 238 ; ARM32: tst [[DENOM:r.*]], [[DENOM]]
203 ; ARM32: bne 239 ; ARM32: bne
204 ; ARM32: bl {{.*}} __umodsi3 240 ; ARM32: bl {{.*}} __umodsi3
205 ; ARM32HWDIV-LABEL: Urem 241 ; ARM32HWDIV-LABEL: Urem
206 ; ARM32HWDIV: tst 242 ; ARM32HWDIV: tst
207 ; ARM32HWDIV: bne 243 ; ARM32HWDIV: bne
208 ; ARM32HWDIV: udiv 244 ; ARM32HWDIV: udiv
209 ; ARM32HWDIV: mls 245 ; ARM32HWDIV: mls
210 246
247 ; MIPS32-LABEL: Urem
248
211 ; The following tests check that shift instructions don't try to use a 249 ; The following tests check that shift instructions don't try to use a
212 ; ConstantRelocatable as an immediate operand. 250 ; ConstantRelocatable as an immediate operand.
213 251
214 @G = internal global [4 x i8] zeroinitializer, align 4 252 @G = internal global [4 x i8] zeroinitializer, align 4
215 253
216 define internal i32 @ShlReloc(i32 %a) { 254 define internal i32 @ShlReloc(i32 %a) {
217 entry: 255 entry:
218 %opnd = ptrtoint [4 x i8]* @G to i32 256 %opnd = ptrtoint [4 x i8]* @G to i32
219 %result = shl i32 %a, %opnd 257 %result = shl i32 %a, %opnd
220 ret i32 %result 258 ret i32 %result
(...skipping 11 matching lines...) Expand all
232 ; CHECK: shr {{.*}},cl 270 ; CHECK: shr {{.*}},cl
233 271
234 define internal i32 @AshrReloc(i32 %a) { 272 define internal i32 @AshrReloc(i32 %a) {
235 entry: 273 entry:
236 %opnd = ptrtoint [4 x i8]* @G to i32 274 %opnd = ptrtoint [4 x i8]* @G to i32
237 %result = ashr i32 %a, %opnd 275 %result = ashr i32 %a, %opnd
238 ret i32 %result 276 ret i32 %result
239 } 277 }
240 ; CHECK-LABEL: AshrReloc 278 ; CHECK-LABEL: AshrReloc
241 ; CHECK: sar {{.*}},cl 279 ; CHECK: sar {{.*}},cl
OLDNEW
« src/IceTargetLoweringMIPS32.cpp ('K') | « src/IceTargetLoweringMIPS32.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698