| OLD | NEW |
| 1 ; This tries to be a comprehensive test of i64 operations, in | 1 ; This tries to be a comprehensive test of i64 operations, in |
| 2 ; particular the patterns for lowering i64 operations into constituent | 2 ; particular the patterns for lowering i64 operations into constituent |
| 3 ; i32 operations on x86-32. | 3 ; i32 operations on x86-32. |
| 4 | 4 |
| 5 ; TODO(jvoung): fix extra "CALLTARGETS" run. The llvm-objdump symbolizer | |
| 6 ; doesn't know how to symbolize non-section-local functions. | |
| 7 ; The newer LLVM 3.6 one does work, but watch out for other bugs. | |
| 8 | |
| 9 ; RUN: %p2i -i %s --args -O2 --verbose none \ | |
| 10 ; RUN: | FileCheck --check-prefix=CALLTARGETS %s | |
| 11 ; RUN: %p2i -i %s --args -O2 --verbose none \ | 5 ; RUN: %p2i -i %s --args -O2 --verbose none \ |
| 12 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | 6 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
| 13 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s | 7 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 14 ; RUN: %p2i -i %s --args -Om1 --verbose none \ | 8 ; RUN: %p2i -i %s --args -Om1 --verbose none \ |
| 15 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | 9 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
| 16 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - \ | 10 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - \ |
| 17 ; RUN: | FileCheck --check-prefix=OPTM1 %s | 11 ; RUN: | FileCheck --check-prefix=OPTM1 %s |
| 18 | 12 |
| 19 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 13 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 20 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 14 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 21 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 | 15 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 |
| 22 @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 | 16 @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 |
| 23 | 17 |
| 24 define internal i32 @ignore64BitArg(i64 %a, i32 %b, i64 %c) { | 18 define internal i32 @ignore64BitArg(i64 %a, i32 %b, i64 %c) { |
| 25 entry: | 19 entry: |
| 26 ret i32 %b | 20 ret i32 %b |
| 27 } | 21 } |
| 28 | 22 |
| 29 define internal i32 @pass64BitArg(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e, i64 %f
) { | 23 define internal i32 @pass64BitArg(i64 %a, i64 %b, i64 %c, i64 %d, i64 %e, i64 %f
) { |
| 30 entry: | 24 entry: |
| 31 %call = call i32 @ignore64BitArgNoInline(i64 %a, i32 123, i64 %b) | 25 %call = call i32 @ignore64BitArgNoInline(i64 %a, i32 123, i64 %b) |
| 32 %call1 = call i32 @ignore64BitArgNoInline(i64 %c, i32 123, i64 %d) | 26 %call1 = call i32 @ignore64BitArgNoInline(i64 %c, i32 123, i64 %d) |
| 33 %call2 = call i32 @ignore64BitArgNoInline(i64 %e, i32 123, i64 %f) | 27 %call2 = call i32 @ignore64BitArgNoInline(i64 %e, i32 123, i64 %f) |
| 34 %add = add i32 %call1, %call | 28 %add = add i32 %call1, %call |
| 35 %add3 = add i32 %add, %call2 | 29 %add3 = add i32 %add, %call2 |
| 36 ret i32 %add3 | 30 ret i32 %add3 |
| 37 } | 31 } |
| 38 ; CHECK-LABEL: pass64BitArg | 32 ; CHECK-LABEL: pass64BitArg |
| 39 ; CALLTARGETS-LABEL: pass64BitArg | |
| 40 ; CHECK: sub esp | 33 ; CHECK: sub esp |
| 41 ; CHECK: mov dword ptr [esp + 4] | 34 ; CHECK: mov dword ptr [esp + 4] |
| 42 ; CHECK: mov dword ptr [esp] | 35 ; CHECK: mov dword ptr [esp] |
| 43 ; CHECK: mov dword ptr [esp + 8], 123 | 36 ; CHECK: mov dword ptr [esp + 8], 123 |
| 44 ; CHECK: mov dword ptr [esp + 16] | 37 ; CHECK: mov dword ptr [esp + 16] |
| 45 ; CHECK: mov dword ptr [esp + 12] | 38 ; CHECK: mov dword ptr [esp + 12] |
| 46 ; CHECK: call -4 | 39 ; CHECK: call ignore64BitArgNoInline |
| 47 ; CALLTARGETS: .long ignore64BitArgNoInline | |
| 48 ; CHECK: sub esp | 40 ; CHECK: sub esp |
| 49 ; CHECK: mov dword ptr [esp + 4] | 41 ; CHECK: mov dword ptr [esp + 4] |
| 50 ; CHECK: mov dword ptr [esp] | 42 ; CHECK: mov dword ptr [esp] |
| 51 ; CHECK: mov dword ptr [esp + 8], 123 | 43 ; CHECK: mov dword ptr [esp + 8], 123 |
| 52 ; CHECK: mov dword ptr [esp + 16] | 44 ; CHECK: mov dword ptr [esp + 16] |
| 53 ; CHECK: mov dword ptr [esp + 12] | 45 ; CHECK: mov dword ptr [esp + 12] |
| 54 ; CHECK: call -4 | 46 ; CHECK: call ignore64BitArgNoInline |
| 55 ; CALLTARGETS: .long ignore64BitArgNoInline | |
| 56 ; CHECK: sub esp | 47 ; CHECK: sub esp |
| 57 ; CHECK: mov dword ptr [esp + 4] | 48 ; CHECK: mov dword ptr [esp + 4] |
| 58 ; CHECK: mov dword ptr [esp] | 49 ; CHECK: mov dword ptr [esp] |
| 59 ; CHECK: mov dword ptr [esp + 8], 123 | 50 ; CHECK: mov dword ptr [esp + 8], 123 |
| 60 ; CHECK: mov dword ptr [esp + 16] | 51 ; CHECK: mov dword ptr [esp + 16] |
| 61 ; CHECK: mov dword ptr [esp + 12] | 52 ; CHECK: mov dword ptr [esp + 12] |
| 62 ; CHECK: call -4 | 53 ; CHECK: call ignore64BitArgNoInline |
| 63 ; CALLTARGETS: .long ignore64BitArgNoInline | |
| 64 ; | 54 ; |
| 65 ; OPTM1-LABEL: pass64BitArg | 55 ; OPTM1-LABEL: pass64BitArg |
| 66 ; OPTM1: sub esp | 56 ; OPTM1: sub esp |
| 67 ; OPTM1: mov dword ptr [esp + 4] | 57 ; OPTM1: mov dword ptr [esp + 4] |
| 68 ; OPTM1: mov dword ptr [esp] | 58 ; OPTM1: mov dword ptr [esp] |
| 69 ; OPTM1: mov dword ptr [esp + 8], 123 | 59 ; OPTM1: mov dword ptr [esp + 8], 123 |
| 70 ; OPTM1: mov dword ptr [esp + 16] | 60 ; OPTM1: mov dword ptr [esp + 16] |
| 71 ; OPTM1: mov dword ptr [esp + 12] | 61 ; OPTM1: mov dword ptr [esp + 12] |
| 72 ; OPTM1: call -4 | 62 ; OPTM1: call ignore64BitArgNoInline |
| 73 ; OPTM1: sub esp | 63 ; OPTM1: sub esp |
| 74 ; OPTM1: mov dword ptr [esp + 4] | 64 ; OPTM1: mov dword ptr [esp + 4] |
| 75 ; OPTM1: mov dword ptr [esp] | 65 ; OPTM1: mov dword ptr [esp] |
| 76 ; OPTM1: mov dword ptr [esp + 8], 123 | 66 ; OPTM1: mov dword ptr [esp + 8], 123 |
| 77 ; OPTM1: mov dword ptr [esp + 16] | 67 ; OPTM1: mov dword ptr [esp + 16] |
| 78 ; OPTM1: mov dword ptr [esp + 12] | 68 ; OPTM1: mov dword ptr [esp + 12] |
| 79 ; OPTM1: call -4 | 69 ; OPTM1: call ignore64BitArgNoInline |
| 80 ; OPTM1: sub esp | 70 ; OPTM1: sub esp |
| 81 ; OPTM1: mov dword ptr [esp + 4] | 71 ; OPTM1: mov dword ptr [esp + 4] |
| 82 ; OPTM1: mov dword ptr [esp] | 72 ; OPTM1: mov dword ptr [esp] |
| 83 ; OPTM1: mov dword ptr [esp + 8], 123 | 73 ; OPTM1: mov dword ptr [esp + 8], 123 |
| 84 ; OPTM1: mov dword ptr [esp + 16] | 74 ; OPTM1: mov dword ptr [esp + 16] |
| 85 ; OPTM1: mov dword ptr [esp + 12] | 75 ; OPTM1: mov dword ptr [esp + 12] |
| 86 ; OPTM1: call -4 | 76 ; OPTM1: call ignore64BitArgNoInline |
| 87 | 77 |
| 88 declare i32 @ignore64BitArgNoInline(i64, i32, i64) | 78 declare i32 @ignore64BitArgNoInline(i64, i32, i64) |
| 89 | 79 |
| 90 define internal i32 @pass64BitConstArg(i64 %a, i64 %b) { | 80 define internal i32 @pass64BitConstArg(i64 %a, i64 %b) { |
| 91 entry: | 81 entry: |
| 92 %call = call i32 @ignore64BitArgNoInline(i64 %a, i32 123, i64 -240105309230672
5256) | 82 %call = call i32 @ignore64BitArgNoInline(i64 %a, i32 123, i64 -240105309230672
5256) |
| 93 ret i32 %call | 83 ret i32 %call |
| 94 } | 84 } |
| 95 ; CHECK-LABEL: pass64BitConstArg | 85 ; CHECK-LABEL: pass64BitConstArg |
| 96 ; CALLTARGETS-LABEL: pass64BitConstArg | |
| 97 ; CHECK: sub esp | 86 ; CHECK: sub esp |
| 98 ; CHECK: mov dword ptr [esp + 4] | 87 ; CHECK: mov dword ptr [esp + 4] |
| 99 ; CHECK-NEXT: mov dword ptr [esp] | 88 ; CHECK-NEXT: mov dword ptr [esp] |
| 100 ; CHECK-NEXT: mov dword ptr [esp + 8], 123 | 89 ; CHECK-NEXT: mov dword ptr [esp + 8], 123 |
| 101 ; Bundle padding might be added (so not using -NEXT). | 90 ; Bundle padding might be added (so not using -NEXT). |
| 102 ; CHECK: mov dword ptr [esp + 16], 3735928559 | 91 ; CHECK: mov dword ptr [esp + 16], 3735928559 |
| 103 ; CHECK-NEXT: mov dword ptr [esp + 12], 305419896 | 92 ; CHECK-NEXT: mov dword ptr [esp + 12], 305419896 |
| 104 ; Bundle padding will push the call down. | 93 ; Bundle padding will push the call down. |
| 105 ; CHECK-NOT: mov | 94 ; CHECK-NOT: mov |
| 106 ; CHECK: call -4 | 95 ; CHECK: call ignore64BitArgNoInline |
| 107 ; CALLTARGETS: .long ignore64BitArgNoInline | |
| 108 ; | 96 ; |
| 109 ; OPTM1-LABEL: pass64BitConstArg | 97 ; OPTM1-LABEL: pass64BitConstArg |
| 110 ; OPTM1: sub esp | 98 ; OPTM1: sub esp |
| 111 ; OPTM1: mov dword ptr [esp + 4] | 99 ; OPTM1: mov dword ptr [esp + 4] |
| 112 ; OPTM1-NEXT: mov dword ptr [esp] | 100 ; OPTM1-NEXT: mov dword ptr [esp] |
| 113 ; OPTM1-NEXT: mov dword ptr [esp + 8], 123 | 101 ; OPTM1-NEXT: mov dword ptr [esp + 8], 123 |
| 114 ; Bundle padding might be added (so not using -NEXT). | 102 ; Bundle padding might be added (so not using -NEXT). |
| 115 ; OPTM1: mov dword ptr [esp + 16], 3735928559 | 103 ; OPTM1: mov dword ptr [esp + 16], 3735928559 |
| 116 ; OPTM1-NEXT: mov dword ptr [esp + 12], 305419896 | 104 ; OPTM1-NEXT: mov dword ptr [esp + 12], 305419896 |
| 117 ; OPTM1-NOT: mov | 105 ; OPTM1-NOT: mov |
| 118 ; OPTM1: call -4 | 106 ; OPTM1: call ignore64BitArgNoInline |
| 119 | 107 |
| 120 define internal i64 @return64BitArg(i64 %a) { | 108 define internal i64 @return64BitArg(i64 %a) { |
| 121 entry: | 109 entry: |
| 122 ret i64 %a | 110 ret i64 %a |
| 123 } | 111 } |
| 124 ; CHECK-LABEL: return64BitArg | 112 ; CHECK-LABEL: return64BitArg |
| 125 ; CHECK: mov {{.*}}, dword ptr [esp + 4] | 113 ; CHECK: mov {{.*}}, dword ptr [esp + 4] |
| 126 ; CHECK: mov {{.*}}, dword ptr [esp + 8] | 114 ; CHECK: mov {{.*}}, dword ptr [esp + 8] |
| 127 ; | 115 ; |
| 128 ; OPTM1-LABEL: return64BitArg | 116 ; OPTM1-LABEL: return64BitArg |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 ; OPTM1: mul | 218 ; OPTM1: mul |
| 231 ; OPTM1: add | 219 ; OPTM1: add |
| 232 ; OPTM1: add | 220 ; OPTM1: add |
| 233 | 221 |
| 234 define internal i64 @div64BitSigned(i64 %a, i64 %b) { | 222 define internal i64 @div64BitSigned(i64 %a, i64 %b) { |
| 235 entry: | 223 entry: |
| 236 %div = sdiv i64 %a, %b | 224 %div = sdiv i64 %a, %b |
| 237 ret i64 %div | 225 ret i64 %div |
| 238 } | 226 } |
| 239 ; CHECK-LABEL: div64BitSigned | 227 ; CHECK-LABEL: div64BitSigned |
| 240 ; CALLTARGETS-LABEL: div64BitSigned | 228 ; CHECK: call __divdi3 |
| 241 ; CHECK: call -4 | |
| 242 ; CALLTARGETS: .long __divdi3 | |
| 243 | 229 |
| 244 ; OPTM1-LABEL: div64BitSigned | 230 ; OPTM1-LABEL: div64BitSigned |
| 245 ; OPTM1: call -4 | 231 ; OPTM1: call __divdi3 |
| 246 | 232 |
| 247 define internal i64 @div64BitSignedConst(i64 %a) { | 233 define internal i64 @div64BitSignedConst(i64 %a) { |
| 248 entry: | 234 entry: |
| 249 %div = sdiv i64 %a, 12345678901234 | 235 %div = sdiv i64 %a, 12345678901234 |
| 250 ret i64 %div | 236 ret i64 %div |
| 251 } | 237 } |
| 252 ; CHECK-LABEL: div64BitSignedConst | 238 ; CHECK-LABEL: div64BitSignedConst |
| 253 ; CALLTARGETS-LABEL: div64BitSignedConst | |
| 254 ; CHECK: mov dword ptr [esp + 12], 2874 | 239 ; CHECK: mov dword ptr [esp + 12], 2874 |
| 255 ; CHECK: mov dword ptr [esp + 8], 1942892530 | 240 ; CHECK: mov dword ptr [esp + 8], 1942892530 |
| 256 ; CHECK: call -4 | 241 ; CHECK: call __divdi3 |
| 257 ; CALLTARGETS: .long __divdi3 | |
| 258 ; | 242 ; |
| 259 ; OPTM1-LABEL: div64BitSignedConst | 243 ; OPTM1-LABEL: div64BitSignedConst |
| 260 ; OPTM1: mov dword ptr [esp + 12], 2874 | 244 ; OPTM1: mov dword ptr [esp + 12], 2874 |
| 261 ; OPTM1: mov dword ptr [esp + 8], 1942892530 | 245 ; OPTM1: mov dword ptr [esp + 8], 1942892530 |
| 262 ; OPTM1: call -4 | 246 ; OPTM1: call __divdi3 |
| 263 | 247 |
| 264 define internal i64 @div64BitUnsigned(i64 %a, i64 %b) { | 248 define internal i64 @div64BitUnsigned(i64 %a, i64 %b) { |
| 265 entry: | 249 entry: |
| 266 %div = udiv i64 %a, %b | 250 %div = udiv i64 %a, %b |
| 267 ret i64 %div | 251 ret i64 %div |
| 268 } | 252 } |
| 269 ; CHECK-LABEL: div64BitUnsigned | 253 ; CHECK-LABEL: div64BitUnsigned |
| 270 ; CALLTARGETS-LABEL: div64BitUnsigned | 254 ; CHECK: call __udivdi3 |
| 271 ; CHECK: call -4 | |
| 272 ; CALLTARGETS: .long __udivdi3 | |
| 273 ; | 255 ; |
| 274 ; OPTM1-LABEL: div64BitUnsigned | 256 ; OPTM1-LABEL: div64BitUnsigned |
| 275 ; OPTM1: call -4 | 257 ; OPTM1: call __udivdi3 |
| 276 | 258 |
| 277 define internal i64 @rem64BitSigned(i64 %a, i64 %b) { | 259 define internal i64 @rem64BitSigned(i64 %a, i64 %b) { |
| 278 entry: | 260 entry: |
| 279 %rem = srem i64 %a, %b | 261 %rem = srem i64 %a, %b |
| 280 ret i64 %rem | 262 ret i64 %rem |
| 281 } | 263 } |
| 282 ; CHECK-LABEL: rem64BitSigned | 264 ; CHECK-LABEL: rem64BitSigned |
| 283 ; CALLTARGETS-LABEL: rem64BitSigned | 265 ; CHECK: call __moddi3 |
| 284 ; CHECK: call -4 | |
| 285 ; CALLTARGETS: .long __moddi3 | |
| 286 ; | 266 ; |
| 287 ; OPTM1-LABEL: rem64BitSigned | 267 ; OPTM1-LABEL: rem64BitSigned |
| 288 ; OPTM1: call -4 | 268 ; OPTM1: call __moddi3 |
| 289 | 269 |
| 290 define internal i64 @rem64BitUnsigned(i64 %a, i64 %b) { | 270 define internal i64 @rem64BitUnsigned(i64 %a, i64 %b) { |
| 291 entry: | 271 entry: |
| 292 %rem = urem i64 %a, %b | 272 %rem = urem i64 %a, %b |
| 293 ret i64 %rem | 273 ret i64 %rem |
| 294 } | 274 } |
| 295 ; CHECK-LABEL: rem64BitUnsigned | 275 ; CHECK-LABEL: rem64BitUnsigned |
| 296 ; CALLTARGETS-LABEL: rem64BitUnsigned | 276 ; CHECK: call __umoddi3 |
| 297 ; CHECK: call -4 | |
| 298 ; CALLTARGETS: .long __umoddi3 | |
| 299 ; | 277 ; |
| 300 ; OPTM1-LABEL: rem64BitUnsigned | 278 ; OPTM1-LABEL: rem64BitUnsigned |
| 301 ; OPTM1: call -4 | 279 ; OPTM1: call __umoddi3 |
| 302 | 280 |
| 303 define internal i64 @shl64BitSigned(i64 %a, i64 %b) { | 281 define internal i64 @shl64BitSigned(i64 %a, i64 %b) { |
| 304 entry: | 282 entry: |
| 305 %shl = shl i64 %a, %b | 283 %shl = shl i64 %a, %b |
| 306 ret i64 %shl | 284 ret i64 %shl |
| 307 } | 285 } |
| 308 ; CHECK-LABEL: shl64BitSigned | 286 ; CHECK-LABEL: shl64BitSigned |
| 309 ; CHECK: shld | 287 ; CHECK: shld |
| 310 ; CHECK: shl e | 288 ; CHECK: shl e |
| 311 ; CHECK: test {{.*}}, 32 | 289 ; CHECK: test {{.*}}, 32 |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 | 1298 |
| 1321 if.end3: ; preds = %if.then2, %if.end | 1299 if.end3: ; preds = %if.then2, %if.end |
| 1322 ret void | 1300 ret void |
| 1323 } | 1301 } |
| 1324 ; The following checks are not strictly necessary since one of the RUN | 1302 ; The following checks are not strictly necessary since one of the RUN |
| 1325 ; lines actually runs the output through the assembler. | 1303 ; lines actually runs the output through the assembler. |
| 1326 ; CHECK-LABEL: icmpLt64Imm | 1304 ; CHECK-LABEL: icmpLt64Imm |
| 1327 ; CHECK-NOT: cmp {{[0-9]+}}, | 1305 ; CHECK-NOT: cmp {{[0-9]+}}, |
| 1328 ; OPTM1-LABEL: icmpLt64Imm | 1306 ; OPTM1-LABEL: icmpLt64Imm |
| 1329 ; OPTM1-NOT: cmp {{[0-9]+}}, | 1307 ; OPTM1-NOT: cmp {{[0-9]+}}, |
| OLD | NEW |