Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 \ | |
|
Jim Stichnoth
2015/11/04 14:47:24
80-col
rkotlerimgtec
2015/11/05 01:28:44
Done.
| |
| 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 | |
| 25 | 32 |
| 26 define internal i32 @Add(i32 %a, i32 %b) { | 33 define internal i32 @Add(i32 %a, i32 %b) { |
| 27 entry: | 34 entry: |
| 28 %add = add i32 %b, %a | 35 %add = add i32 %b, %a |
| 29 ret i32 %add | 36 ret i32 %add |
| 30 } | 37 } |
| 31 ; CHECK-LABEL: Add | 38 ; CHECK-LABEL: Add |
| 32 ; CHECK: add e | 39 ; CHECK: add e |
| 33 ; ARM32-LABEL: Add | 40 ; ARM32-LABEL: Add |
| 34 ; ARM32: add r | 41 ; ARM32: add r |
| 42 ; MIPS32-LABEL: Add | |
| 43 ; MIPS32: add | |
| 35 | 44 |
| 36 define internal i32 @And(i32 %a, i32 %b) { | 45 define internal i32 @And(i32 %a, i32 %b) { |
| 37 entry: | 46 entry: |
| 38 %and = and i32 %b, %a | 47 %and = and i32 %b, %a |
| 39 ret i32 %and | 48 ret i32 %and |
| 40 } | 49 } |
| 41 ; CHECK-LABEL: And | 50 ; CHECK-LABEL: And |
| 42 ; CHECK: and e | 51 ; CHECK: and e |
| 43 ; ARM32-LABEL: And | 52 ; ARM32-LABEL: And |
| 44 ; ARM32: and r | 53 ; ARM32: and r |
| 54 ; MIPS32-LABEL: And | |
| 55 ; MIPS32: and | |
| 45 | 56 |
| 46 define internal i32 @Or(i32 %a, i32 %b) { | 57 define internal i32 @Or(i32 %a, i32 %b) { |
| 47 entry: | 58 entry: |
| 48 %or = or i32 %b, %a | 59 %or = or i32 %b, %a |
| 49 ret i32 %or | 60 ret i32 %or |
| 50 } | 61 } |
| 51 ; CHECK-LABEL: Or | 62 ; CHECK-LABEL: Or |
| 52 ; CHECK: or e | 63 ; CHECK: or e |
| 53 ; ARM32-LABEL: Or | 64 ; ARM32-LABEL: Or |
| 54 ; ARM32: orr r | 65 ; ARM32: orr r |
| 66 ; MIPS32-LABEL: Or | |
| 67 ; MIPS32: or | |
| 55 | 68 |
| 56 define internal i32 @Xor(i32 %a, i32 %b) { | 69 define internal i32 @Xor(i32 %a, i32 %b) { |
| 57 entry: | 70 entry: |
| 58 %xor = xor i32 %b, %a | 71 %xor = xor i32 %b, %a |
| 59 ret i32 %xor | 72 ret i32 %xor |
| 60 } | 73 } |
| 61 ; CHECK-LABEL: Xor | 74 ; CHECK-LABEL: Xor |
| 62 ; CHECK: xor e | 75 ; CHECK: xor e |
| 63 ; ARM32-LABEL: Xor | 76 ; ARM32-LABEL: Xor |
| 64 ; ARM32: eor r | 77 ; ARM32: eor r |
| 78 ; MIPS32-LABEL: Xor | |
| 79 ; MIPS32: xor | |
| 65 | 80 |
| 66 define internal i32 @Sub(i32 %a, i32 %b) { | 81 define internal i32 @Sub(i32 %a, i32 %b) { |
| 67 entry: | 82 entry: |
| 68 %sub = sub i32 %a, %b | 83 %sub = sub i32 %a, %b |
| 69 ret i32 %sub | 84 ret i32 %sub |
| 70 } | 85 } |
| 71 ; CHECK-LABEL: Sub | 86 ; CHECK-LABEL: Sub |
| 72 ; CHECK: sub e | 87 ; CHECK: sub e |
| 73 ; ARM32-LABEL: Sub | 88 ; ARM32-LABEL: Sub |
| 74 ; ARM32: sub r | 89 ; ARM32: sub r |
| 90 ; MIPS32-LABEL: Sub | |
| 91 ; MIPS32: sub | |
| 75 | 92 |
| 76 define internal i32 @Mul(i32 %a, i32 %b) { | 93 define internal i32 @Mul(i32 %a, i32 %b) { |
| 77 entry: | 94 entry: |
| 78 %mul = mul i32 %b, %a | 95 %mul = mul i32 %b, %a |
| 79 ret i32 %mul | 96 ret i32 %mul |
| 80 } | 97 } |
| 81 ; CHECK-LABEL: Mul | 98 ; CHECK-LABEL: Mul |
| 82 ; CHECK: imul e | 99 ; CHECK: imul e |
| 83 ; ARM32-LABEL: Mul | 100 ; ARM32-LABEL: Mul |
| 84 ; ARM32: mul r | 101 ; ARM32: mul r |
| 102 ; MIPS32-LABEL: Mul | |
| 103 ; MIPS32: mul | |
| 85 | 104 |
| 86 ; Check for a valid ARM mul instruction where operands have to be registers. | 105 ; Check for a valid ARM mul instruction where operands have to be registers. |
| 87 ; On the other hand x86-32 does allow an immediate. | 106 ; On the other hand x86-32 does allow an immediate. |
| 88 define internal i32 @MulImm(i32 %a, i32 %b) { | 107 define internal i32 @MulImm(i32 %a, i32 %b) { |
| 89 entry: | 108 entry: |
| 90 %mul = mul i32 %a, 99 | 109 %mul = mul i32 %a, 99 |
| 91 ret i32 %mul | 110 ret i32 %mul |
| 92 } | 111 } |
| 93 ; CHECK-LABEL: MulImm | 112 ; CHECK-LABEL: MulImm |
| 94 ; CHECK: imul e{{.*}},e{{.*}},0x63 | 113 ; CHECK: imul e{{.*}},e{{.*}},0x63 |
| 95 ; ARM32-LABEL: MulImm | 114 ; ARM32-LABEL: MulImm |
| 96 ; ARM32: mov {{.*}}, #99 | 115 ; ARM32: mov {{.*}}, #99 |
| 97 ; ARM32: mul r{{.*}}, r{{.*}}, r{{.*}} | 116 ; ARM32: mul r{{.*}}, r{{.*}}, r{{.*}} |
| 117 ; MIPS32-LABEL: MulImm | |
| 118 ; MIPS32: mul | |
| 98 | 119 |
| 99 ; Check for a valid addressing mode in the x86-32 mul instruction when | 120 ; Check for a valid addressing mode in the x86-32 mul instruction when |
| 100 ; the second source operand is an immediate. | 121 ; the second source operand is an immediate. |
| 101 define internal i64 @MulImm64(i64 %a) { | 122 define internal i64 @MulImm64(i64 %a) { |
| 102 entry: | 123 entry: |
| 103 %mul = mul i64 %a, 99 | 124 %mul = mul i64 %a, 99 |
| 104 ret i64 %mul | 125 ret i64 %mul |
| 105 } | 126 } |
| 106 ; NOTE: the lowering is currently a bit inefficient for small 64-bit constants. | 127 ; 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 | 128 ; 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). | 129 ; multiply by 0 are not eliminated (see expanded 64-bit ARM lowering). |
| 109 ; CHECK-LABEL: MulImm64 | 130 ; CHECK-LABEL: MulImm64 |
| 110 ; CHECK: mov {{.*}},0x63 | 131 ; CHECK: mov {{.*}},0x63 |
| 111 ; CHECK: mov {{.*}},0x0 | 132 ; CHECK: mov {{.*}},0x0 |
| 112 ; CHECK-NOT: mul {{[0-9]+}} | 133 ; CHECK-NOT: mul {{[0-9]+}} |
| 113 ; | 134 ; |
| 114 ; ARM32-LABEL: MulImm64 | 135 ; ARM32-LABEL: MulImm64 |
| 115 ; ARM32: movw {{.*}}, #99 | 136 ; ARM32: movw {{.*}}, #99 |
| 116 ; ARM32: movw {{.*}}, #0 | 137 ; ARM32: movw {{.*}}, #0 |
| 117 ; ARM32: mul r | 138 ; ARM32: mul r |
| 118 ; ARM32: mla r | 139 ; ARM32: mla r |
| 119 ; ARM32: umull r | 140 ; ARM32: umull r |
| 120 ; ARM32: add r | 141 ; ARM32: add r |
| 121 | 142 |
| 143 ; MIPS32-LABEL: MulImm64 | |
| 144 | |
| 122 define internal i32 @Sdiv(i32 %a, i32 %b) { | 145 define internal i32 @Sdiv(i32 %a, i32 %b) { |
| 123 entry: | 146 entry: |
| 124 %div = sdiv i32 %a, %b | 147 %div = sdiv i32 %a, %b |
| 125 ret i32 %div | 148 ret i32 %div |
| 126 } | 149 } |
| 127 ; CHECK-LABEL: Sdiv | 150 ; CHECK-LABEL: Sdiv |
| 128 ; CHECK: cdq | 151 ; CHECK: cdq |
| 129 ; CHECK: idiv e | 152 ; CHECK: idiv e |
| 130 ; | 153 ; |
| 131 ; ARM32-LABEL: Sdiv | 154 ; ARM32-LABEL: Sdiv |
| 132 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] | 155 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 133 ; ARM32: bne | 156 ; ARM32: bne |
| 134 ; ARM32: .word 0xe7fedef0 | 157 ; ARM32: .word 0xe7fedef0 |
| 135 ; ARM32: {{.*}} bl {{.*}} __divsi3 | 158 ; ARM32: {{.*}} bl {{.*}} __divsi3 |
| 136 ; ARM32HWDIV-LABEL: Sdiv | 159 ; ARM32HWDIV-LABEL: Sdiv |
| 137 ; ARM32HWDIV: tst | 160 ; ARM32HWDIV: tst |
| 138 ; ARM32HWDIV: bne | 161 ; ARM32HWDIV: bne |
| 139 ; ARM32HWDIV: sdiv | 162 ; ARM32HWDIV: sdiv |
| 140 | 163 |
| 164 ; MIPS32-LABEL: Sdiv | |
| 165 | |
| 141 define internal i32 @SdivConst(i32 %a) { | 166 define internal i32 @SdivConst(i32 %a) { |
| 142 entry: | 167 entry: |
| 143 %div = sdiv i32 %a, 219 | 168 %div = sdiv i32 %a, 219 |
| 144 ret i32 %div | 169 ret i32 %div |
| 145 } | 170 } |
| 146 ; CHECK-LABEL: SdivConst | 171 ; CHECK-LABEL: SdivConst |
| 147 ; CHECK: cdq | 172 ; CHECK: cdq |
| 148 ; CHECK: idiv e | 173 ; CHECK: idiv e |
| 149 ; | 174 ; |
| 150 ; ARM32-LABEL: SdivConst | 175 ; ARM32-LABEL: SdivConst |
| 151 ; ARM32-NOT: tst | 176 ; ARM32-NOT: tst |
| 152 ; ARM32: bl {{.*}} __divsi3 | 177 ; ARM32: bl {{.*}} __divsi3 |
| 153 ; ARM32HWDIV-LABEL: SdivConst | 178 ; ARM32HWDIV-LABEL: SdivConst |
| 154 ; ARM32HWDIV-NOT: tst | 179 ; ARM32HWDIV-NOT: tst |
| 155 ; ARM32HWDIV: sdiv | 180 ; ARM32HWDIV: sdiv |
| 156 | 181 |
| 182 ; MIPS32-LABEL: SdivConst | |
| 183 | |
| 157 define internal i32 @Srem(i32 %a, i32 %b) { | 184 define internal i32 @Srem(i32 %a, i32 %b) { |
| 158 entry: | 185 entry: |
| 159 %rem = srem i32 %a, %b | 186 %rem = srem i32 %a, %b |
| 160 ret i32 %rem | 187 ret i32 %rem |
| 161 } | 188 } |
| 162 ; CHECK-LABEL: Srem | 189 ; CHECK-LABEL: Srem |
| 163 ; CHECK: cdq | 190 ; CHECK: cdq |
| 164 ; CHECK: idiv e | 191 ; CHECK: idiv e |
| 165 ; | 192 ; |
| 166 ; ARM32-LABEL: Srem | 193 ; ARM32-LABEL: Srem |
| 167 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] | 194 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 168 ; ARM32: bne | 195 ; ARM32: bne |
| 169 ; ARM32: bl {{.*}} __modsi3 | 196 ; ARM32: bl {{.*}} __modsi3 |
| 170 ; ARM32HWDIV-LABEL: Srem | 197 ; ARM32HWDIV-LABEL: Srem |
| 171 ; ARM32HWDIV: tst | 198 ; ARM32HWDIV: tst |
| 172 ; ARM32HWDIV: bne | 199 ; ARM32HWDIV: bne |
| 173 ; ARM32HWDIV: sdiv | 200 ; ARM32HWDIV: sdiv |
| 174 ; ARM32HWDIV: mls | 201 ; ARM32HWDIV: mls |
| 175 | 202 |
| 203 ; MIPS32-LABEL: Srem | |
| 204 | |
| 176 define internal i32 @Udiv(i32 %a, i32 %b) { | 205 define internal i32 @Udiv(i32 %a, i32 %b) { |
| 177 entry: | 206 entry: |
| 178 %div = udiv i32 %a, %b | 207 %div = udiv i32 %a, %b |
| 179 ret i32 %div | 208 ret i32 %div |
| 180 } | 209 } |
| 181 ; CHECK-LABEL: Udiv | 210 ; CHECK-LABEL: Udiv |
| 182 ; CHECK: div e | 211 ; CHECK: div e |
| 183 ; | 212 ; |
| 184 ; ARM32-LABEL: Udiv | 213 ; ARM32-LABEL: Udiv |
| 185 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] | 214 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 186 ; ARM32: bne | 215 ; ARM32: bne |
| 187 ; ARM32: bl {{.*}} __udivsi3 | 216 ; ARM32: bl {{.*}} __udivsi3 |
| 188 ; ARM32HWDIV-LABEL: Udiv | 217 ; ARM32HWDIV-LABEL: Udiv |
| 189 ; ARM32HWDIV: tst | 218 ; ARM32HWDIV: tst |
| 190 ; ARM32HWDIV: bne | 219 ; ARM32HWDIV: bne |
| 191 ; ARM32HWDIV: udiv | 220 ; ARM32HWDIV: udiv |
| 192 | 221 |
| 222 ; MIPS32-LABEL: Udiv | |
| 223 | |
| 193 define internal i32 @Urem(i32 %a, i32 %b) { | 224 define internal i32 @Urem(i32 %a, i32 %b) { |
| 194 entry: | 225 entry: |
| 195 %rem = urem i32 %a, %b | 226 %rem = urem i32 %a, %b |
| 196 ret i32 %rem | 227 ret i32 %rem |
| 197 } | 228 } |
| 198 ; CHECK-LABEL: Urem | 229 ; CHECK-LABEL: Urem |
| 199 ; CHECK: div e | 230 ; CHECK: div e |
| 200 ; | 231 ; |
| 201 ; ARM32-LABEL: Urem | 232 ; ARM32-LABEL: Urem |
| 202 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] | 233 ; ARM32: tst [[DENOM:r.*]], [[DENOM]] |
| 203 ; ARM32: bne | 234 ; ARM32: bne |
| 204 ; ARM32: bl {{.*}} __umodsi3 | 235 ; ARM32: bl {{.*}} __umodsi3 |
| 205 ; ARM32HWDIV-LABEL: Urem | 236 ; ARM32HWDIV-LABEL: Urem |
| 206 ; ARM32HWDIV: tst | 237 ; ARM32HWDIV: tst |
| 207 ; ARM32HWDIV: bne | 238 ; ARM32HWDIV: bne |
| 208 ; ARM32HWDIV: udiv | 239 ; ARM32HWDIV: udiv |
| 209 ; ARM32HWDIV: mls | 240 ; ARM32HWDIV: mls |
| 210 | 241 |
| 242 ; MIPS32-LABEL: Urem | |
| 243 | |
| 211 ; The following tests check that shift instructions don't try to use a | 244 ; The following tests check that shift instructions don't try to use a |
| 212 ; ConstantRelocatable as an immediate operand. | 245 ; ConstantRelocatable as an immediate operand. |
| 213 | 246 |
| 214 @G = internal global [4 x i8] zeroinitializer, align 4 | 247 @G = internal global [4 x i8] zeroinitializer, align 4 |
| 215 | 248 |
| 216 define internal i32 @ShlReloc(i32 %a) { | 249 define internal i32 @ShlReloc(i32 %a) { |
| 217 entry: | 250 entry: |
| 218 %opnd = ptrtoint [4 x i8]* @G to i32 | 251 %opnd = ptrtoint [4 x i8]* @G to i32 |
| 219 %result = shl i32 %a, %opnd | 252 %result = shl i32 %a, %opnd |
| 220 ret i32 %result | 253 ret i32 %result |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 232 ; CHECK: shr {{.*}},cl | 265 ; CHECK: shr {{.*}},cl |
| 233 | 266 |
| 234 define internal i32 @AshrReloc(i32 %a) { | 267 define internal i32 @AshrReloc(i32 %a) { |
| 235 entry: | 268 entry: |
| 236 %opnd = ptrtoint [4 x i8]* @G to i32 | 269 %opnd = ptrtoint [4 x i8]* @G to i32 |
| 237 %result = ashr i32 %a, %opnd | 270 %result = ashr i32 %a, %opnd |
| 238 ret i32 %result | 271 ret i32 %result |
| 239 } | 272 } |
| 240 ; CHECK-LABEL: AshrReloc | 273 ; CHECK-LABEL: AshrReloc |
| 241 ; CHECK: sar {{.*}},cl | 274 ; CHECK: sar {{.*}},cl |
| OLD | NEW |