OLD | NEW |
---|---|
(Empty) | |
1 ; Assembly test for simple arithmetic operations. | |
jvoung (off chromium)
2015/05/18 23:31:40
Almost a dupe of arith-opt.ll, but tests assembly
| |
2 | |
3 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 | FileCheck %s | |
4 | |
5 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) | |
6 ; once enough infrastructure is in. Also, switch to --filetype=obj | |
7 ; when possible. | |
8 ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \ | |
9 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ | |
10 ; RUN: | %if --need=target_ARM32 --command FileCheck --check-prefix ARM32 %s | |
11 | |
12 define i32 @Add(i32 %a, i32 %b) { | |
13 entry: | |
14 %add = add i32 %b, %a | |
15 ret i32 %add | |
16 } | |
17 ; CHECK-LABEL: Add | |
18 ; CHECK: add e | |
19 ; ARM32-LABEL: Add | |
20 ; ARM32: add r | |
21 | |
22 define i32 @And(i32 %a, i32 %b) { | |
23 entry: | |
24 %and = and i32 %b, %a | |
25 ret i32 %and | |
26 } | |
27 ; CHECK-LABEL: And | |
28 ; CHECK: and e | |
29 ; ARM32-LABEL: And | |
30 ; ARM32: and r | |
31 | |
32 define i32 @Or(i32 %a, i32 %b) { | |
33 entry: | |
34 %or = or i32 %b, %a | |
35 ret i32 %or | |
36 } | |
37 ; CHECK-LABEL: Or | |
38 ; CHECK: or e | |
39 ; ARM32-LABEL: Or | |
40 ; ARM32: orr r | |
41 | |
42 define i32 @Xor(i32 %a, i32 %b) { | |
43 entry: | |
44 %xor = xor i32 %b, %a | |
45 ret i32 %xor | |
46 } | |
47 ; CHECK-LABEL: Xor | |
48 ; CHECK: xor e | |
49 ; ARM32-LABEL: Xor | |
50 ; ARM32: eor r | |
51 | |
52 define i32 @Sub(i32 %a, i32 %b) { | |
53 entry: | |
54 %sub = sub i32 %a, %b | |
55 ret i32 %sub | |
56 } | |
57 ; CHECK-LABEL: Sub | |
58 ; CHECK: sub e | |
59 ; ARM32-LABEL: Sub | |
60 ; ARM32: sub r | |
61 | |
62 define i32 @Mul(i32 %a, i32 %b) { | |
63 entry: | |
64 %mul = mul i32 %b, %a | |
65 ret i32 %mul | |
66 } | |
67 ; CHECK-LABEL: Mul | |
68 ; CHECK: imul e | |
69 ; ARM32-LABEL: Mul | |
70 ; ARM32: mul r | |
71 | |
72 ; Check for a valid ARM mul instruction where operands have to be registers. | |
73 ; On the other hand x86-32 does allow an immediate. | |
74 define i32 @MulImm(i32 %a, i32 %b) { | |
75 entry: | |
76 %mul = mul i32 %a, 99 | |
77 ret i32 %mul | |
78 } | |
79 ; CHECK-LABEL: MulImm | |
80 ; CHECK: imul e{{.*}},e{{.*}},0x63 | |
81 ; ARM32-LABEL: MulImm | |
82 ; ARM32: mov {{.*}}, #99 | |
83 ; ARM32: mul r{{.*}}, r{{.*}}, r{{.*}} | |
84 | |
85 ; Check for a valid addressing mode in the x86-32 mul instruction when | |
86 ; the second source operand is an immediate. | |
87 define i64 @MulImm64(i64 %a) { | |
88 entry: | |
89 %mul = mul i64 %a, 99 | |
90 ret i64 %mul | |
91 } | |
92 ; CHECK-LABEL: MulImm64 | |
93 ; CHECK: mov {{.*}},0x63 | |
94 ; CHECK-NOT: mul {{[0-9]+}} | |
95 ; | |
96 ; The ARM lowering is currently a bit inefficient for small 64-bit constants. | |
97 ; The top bits will be 0 and the instructions modeling that multiply by 0 | |
98 ; are not eliminated. | |
99 ; ARM32-LABEL: MulImm64 | |
100 ; ARM32: mov {{.*}}, #99 | |
101 ; ARM32: mov {{.*}}, #0 | |
102 ; ARM32: mul r | |
103 ; ARM32: mla r | |
104 ; ARM32: umull r | |
105 ; ARM32: add r | |
106 | |
107 define i32 @Sdiv(i32 %a, i32 %b) { | |
108 entry: | |
109 %div = sdiv i32 %a, %b | |
110 ret i32 %div | |
111 } | |
112 ; CHECK-LABEL: Sdiv | |
113 ; CHECK: cdq | |
114 ; CHECK: idiv e | |
115 ; ARM32-LABEL: Sdiv | |
116 ; TODO(jvoung) -- implement divide and check here. | |
117 ; The lowering needs to check if the denominator is 0 and trap, since | |
118 ; ARM normally doesn't trap on divide by 0. | |
119 | |
120 define i32 @Srem(i32 %a, i32 %b) { | |
121 entry: | |
122 %rem = srem i32 %a, %b | |
123 ret i32 %rem | |
124 } | |
125 ; CHECK-LABEL: Srem | |
126 ; CHECK: cdq | |
127 ; CHECK: idiv e | |
128 ; ARM32-LABEL: Srem | |
129 | |
130 define i32 @Udiv(i32 %a, i32 %b) { | |
131 entry: | |
132 %div = udiv i32 %a, %b | |
133 ret i32 %div | |
134 } | |
135 ; CHECK-LABEL: Udiv | |
136 ; CHECK: div e | |
137 ; ARM32-LABEL: Udiv | |
138 | |
139 define i32 @Urem(i32 %a, i32 %b) { | |
140 entry: | |
141 %rem = urem i32 %a, %b | |
142 ret i32 %rem | |
143 } | |
144 ; CHECK-LABEL: Urem | |
145 ; CHECK: div e | |
146 ; ARM32-LABEL: Urem | |
OLD | NEW |