| OLD | NEW |
| 1 ; This tests the NaCl intrinsics not related to atomic operations. | 1 ; This tests the NaCl intrinsics not related to atomic operations. |
| 2 | 2 |
| 3 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s | 3 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s |
| 4 ; RUN: %llvm2ice -Om1 --verbose none %s | FileCheck %s | 4 ; RUN: %llvm2ice -Om1 --verbose none %s | FileCheck %s |
| 5 | 5 |
| 6 ; Do another run w/ O2 and a different check-prefix (otherwise O2 and Om1 | 6 ; Do another run w/ O2 and a different check-prefix (otherwise O2 and Om1 |
| 7 ; share the same "CHECK" prefix). This separate run helps check that | 7 ; share the same "CHECK" prefix). This separate run helps check that |
| 8 ; some code is optimized out. | 8 ; some code is optimized out. |
| 9 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s --check-prefix=CHECKO2REM | 9 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s --check-prefix=CHECKO2REM |
| 10 | 10 |
| 11 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s | 11 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
| 12 ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s | 12 ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| 13 ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ | 13 ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ |
| 14 ; RUN: | FileCheck --check-prefix=DUMP %s | 14 ; RUN: | FileCheck --check-prefix=DUMP %s |
| 15 | 15 |
| 16 declare i8* @llvm.nacl.read.tp() | 16 declare i8* @llvm.nacl.read.tp() |
| 17 declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) | 17 declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) |
| 18 declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) | 18 declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) |
| 19 declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) | 19 declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) |
| 20 declare void @llvm.nacl.longjmp(i8*, i32) | 20 declare void @llvm.nacl.longjmp(i8*, i32) |
| 21 declare i32 @llvm.nacl.setjmp(i8*) | 21 declare i32 @llvm.nacl.setjmp(i8*) |
| 22 declare float @llvm.sqrt.f32(float) | 22 declare float @llvm.sqrt.f32(float) |
| 23 declare double @llvm.sqrt.f64(double) | 23 declare double @llvm.sqrt.f64(double) |
| 24 declare void @llvm.trap() | 24 declare void @llvm.trap() |
| 25 declare i16 @llvm.bswap.i16(i16) |
| 26 declare i32 @llvm.bswap.i32(i32) |
| 27 declare i64 @llvm.bswap.i64(i64) |
| 25 declare i32 @llvm.ctlz.i32(i32, i1) | 28 declare i32 @llvm.ctlz.i32(i32, i1) |
| 26 declare i64 @llvm.ctlz.i64(i64, i1) | 29 declare i64 @llvm.ctlz.i64(i64, i1) |
| 27 declare i32 @llvm.cttz.i32(i32, i1) | 30 declare i32 @llvm.cttz.i32(i32, i1) |
| 28 declare i64 @llvm.cttz.i64(i64, i1) | 31 declare i64 @llvm.cttz.i64(i64, i1) |
| 29 declare i32 @llvm.ctpop.i32(i32) | 32 declare i32 @llvm.ctpop.i32(i32) |
| 30 declare i64 @llvm.ctpop.i64(i64) | 33 declare i64 @llvm.ctpop.i64(i64) |
| 31 | 34 |
| 32 define i32 @test_nacl_read_tp() { | 35 define i32 @test_nacl_read_tp() { |
| 33 entry: | 36 entry: |
| 34 %ptr = call i8* @llvm.nacl.read.tp() | 37 %ptr = call i8* @llvm.nacl.read.tp() |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 br i1 %r1, label %Zero, label %NonZero | 238 br i1 %r1, label %Zero, label %NonZero |
| 236 Zero: | 239 Zero: |
| 237 call void @llvm.trap() | 240 call void @llvm.trap() |
| 238 unreachable | 241 unreachable |
| 239 NonZero: | 242 NonZero: |
| 240 ret i32 1 | 243 ret i32 1 |
| 241 } | 244 } |
| 242 ; CHECK-LABEL: test_trap | 245 ; CHECK-LABEL: test_trap |
| 243 ; CHECK: ud2 | 246 ; CHECK: ud2 |
| 244 | 247 |
| 248 define i32 @test_bswap_16(i32 %x) { |
| 249 entry: |
| 250 %x_trunc = trunc i32 %x to i16 |
| 251 %r = call i16 @llvm.bswap.i16(i16 %x_trunc) |
| 252 %r_zext = zext i16 %r to i32 |
| 253 ret i32 %r_zext |
| 254 } |
| 255 ; CHECK-LABEL: test_bswap_16 |
| 256 ; CHECK: rol {{.*}}, 8 |
| 257 |
| 258 define i32 @test_bswap_32(i32 %x) { |
| 259 entry: |
| 260 %r = call i32 @llvm.bswap.i32(i32 %x) |
| 261 ret i32 %r |
| 262 } |
| 263 ; CHECK-LABEL: test_bswap_32 |
| 264 ; CHECK: bswap e{{.*}} |
| 265 |
| 266 define i64 @test_bswap_64(i64 %x) { |
| 267 entry: |
| 268 %r = call i64 @llvm.bswap.i64(i64 %x) |
| 269 ret i64 %r |
| 270 } |
| 271 ; CHECK-LABEL: test_bswap_64 |
| 272 ; CHECK: bswap e{{.*}} |
| 273 ; CHECK: bswap e{{.*}} |
| 274 |
| 245 define i32 @test_ctlz_32(i32 %x) { | 275 define i32 @test_ctlz_32(i32 %x) { |
| 246 entry: | 276 entry: |
| 247 %r = call i32 @llvm.ctlz.i32(i32 %x, i1 0) | 277 %r = call i32 @llvm.ctlz.i32(i32 %x, i1 0) |
| 248 ret i32 %r | 278 ret i32 %r |
| 249 } | 279 } |
| 250 ; CHECK-LABEL: test_ctlz_32 | 280 ; CHECK-LABEL: test_ctlz_32 |
| 251 ; TODO(jvoung): If we detect that LZCNT is supported, then use that | 281 ; TODO(jvoung): If we detect that LZCNT is supported, then use that |
| 252 ; and avoid the need to do the cmovne and xor stuff to guarantee that | 282 ; and avoid the need to do the cmovne and xor stuff to guarantee that |
| 253 ; the result is well-defined w/ input == 0. | 283 ; the result is well-defined w/ input == 0. |
| 254 ; CHECK: bsr [[REG_TMP:e.*]], {{.*}} | 284 ; CHECK: bsr [[REG_TMP:e.*]], {{.*}} |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 ret i32 %r | 390 ret i32 %r |
| 361 } | 391 } |
| 362 ; If there is a trunc, then the mov {{.*}}, 0 is dead and gets optimized out. | 392 ; If there is a trunc, then the mov {{.*}}, 0 is dead and gets optimized out. |
| 363 ; CHECKO2REM-LABEL: test_popcount_64_ret_i32 | 393 ; CHECKO2REM-LABEL: test_popcount_64_ret_i32 |
| 364 ; CHECKO2REM: call __popcountdi2 | 394 ; CHECKO2REM: call __popcountdi2 |
| 365 ; CHECKO2REM-NOT: mov {{.*}}, 0 | 395 ; CHECKO2REM-NOT: mov {{.*}}, 0 |
| 366 | 396 |
| 367 | 397 |
| 368 ; ERRORS-NOT: ICE translation error | 398 ; ERRORS-NOT: ICE translation error |
| 369 ; DUMP-NOT: SZ | 399 ; DUMP-NOT: SZ |
| OLD | NEW |