| OLD | NEW |
| 1 ; This tests each of the supported NaCl atomic instructions for every | 1 ; This tests each of the supported NaCl atomic instructions for every |
| 2 ; size allowed. | 2 ; size allowed. |
| 3 | 3 |
| 4 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s | 4 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s |
| 5 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s --check-prefix=CHECKO2REM | 5 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s --check-prefix=CHECKO2 |
| 6 ; RUN: %llvm2ice -Om1 --verbose none %s | FileCheck %s | 6 ; RUN: %llvm2ice -Om1 --verbose none %s | FileCheck %s |
| 7 ; RUN: %llvm2ice -O2 --verbose none %s \ | 7 ; RUN: %llvm2ice -O2 --verbose none %s \ |
| 8 ; RUN: | llvm-mc -arch=x86 -x86-asm-syntax=intel -filetype=obj | 8 ; RUN: | llvm-mc -arch=x86 -x86-asm-syntax=intel -filetype=obj |
| 9 ; RUN: %llvm2ice -Om1 --verbose none %s \ | 9 ; RUN: %llvm2ice -Om1 --verbose none %s \ |
| 10 ; RUN: | llvm-mc -arch=x86 -x86-asm-syntax=intel -filetype=obj | 10 ; RUN: | llvm-mc -arch=x86 -x86-asm-syntax=intel -filetype=obj |
| 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 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 %ptr = inttoptr i32 %iptr to i64* | 81 %ptr = inttoptr i32 %iptr to i64* |
| 82 %r = call i64 @llvm.nacl.atomic.load.i64(i64* %ptr, i32 6) | 82 %r = call i64 @llvm.nacl.atomic.load.i64(i64* %ptr, i32 6) |
| 83 ret i64 %r | 83 ret i64 %r |
| 84 } | 84 } |
| 85 ; CHECK-LABEL: test_atomic_load_64 | 85 ; CHECK-LABEL: test_atomic_load_64 |
| 86 ; CHECK: movq x{{.*}}, qword | 86 ; CHECK: movq x{{.*}}, qword |
| 87 ; CHECK: movq qword {{.*}}, x{{.*}} | 87 ; CHECK: movq qword {{.*}}, x{{.*}} |
| 88 | 88 |
| 89 define i32 @test_atomic_load_32_with_arith(i32 %iptr) { | 89 define i32 @test_atomic_load_32_with_arith(i32 %iptr) { |
| 90 entry: | 90 entry: |
| 91 br label %next |
| 92 |
| 93 next: |
| 91 %ptr = inttoptr i32 %iptr to i32* | 94 %ptr = inttoptr i32 %iptr to i32* |
| 92 %r = call i32 @llvm.nacl.atomic.load.i32(i32* %ptr, i32 6) | 95 %r = call i32 @llvm.nacl.atomic.load.i32(i32* %ptr, i32 6) |
| 93 %r2 = add i32 %r, 32 | 96 %r2 = add i32 %r, 32 |
| 94 ret i32 %r2 | 97 ret i32 %r2 |
| 95 } | 98 } |
| 96 ; CHECK-LABEL: test_atomic_load_32_with_arith | 99 ; CHECK-LABEL: test_atomic_load_32_with_arith |
| 97 ; CHECK: mov {{.*}}, dword | 100 ; CHECK: mov {{.*}}, dword |
| 98 ; The next instruction may be a separate load or folded into an add. | 101 ; The next instruction may be a separate load or folded into an add. |
| 102 ; |
| 103 ; In O2 mode, we know that the load and add are going to be fused. |
| 104 ; CHECKO2-LABEL: test_atomic_load_32_with_arith |
| 105 ; CHECKO2: mov {{.*}}, dword |
| 106 ; CHECKO2: add {{.*}}, dword |
| 99 | 107 |
| 100 define i32 @test_atomic_load_32_ignored(i32 %iptr) { | 108 define i32 @test_atomic_load_32_ignored(i32 %iptr) { |
| 101 entry: | 109 entry: |
| 102 %ptr = inttoptr i32 %iptr to i32* | 110 %ptr = inttoptr i32 %iptr to i32* |
| 103 %ignored = call i32 @llvm.nacl.atomic.load.i32(i32* %ptr, i32 6) | 111 %ignored = call i32 @llvm.nacl.atomic.load.i32(i32* %ptr, i32 6) |
| 104 ret i32 0 | 112 ret i32 0 |
| 105 } | 113 } |
| 106 ; CHECK-LABEL: test_atomic_load_32_ignored | 114 ; CHECK-LABEL: test_atomic_load_32_ignored |
| 107 ; CHECK: mov {{.*}}, dword | 115 ; CHECK: mov {{.*}}, dword |
| 108 ; CHECK: mov {{.*}}, dword | 116 ; CHECK: mov {{.*}}, dword |
| 117 ; CHECKO2-LABEL: test_atomic_load_32_ignored |
| 118 ; CHECKO2: mov {{.*}}, dword |
| 119 ; CHECKO2: mov {{.*}}, dword |
| 109 | 120 |
| 110 define i64 @test_atomic_load_64_ignored(i32 %iptr) { | 121 define i64 @test_atomic_load_64_ignored(i32 %iptr) { |
| 111 entry: | 122 entry: |
| 112 %ptr = inttoptr i32 %iptr to i64* | 123 %ptr = inttoptr i32 %iptr to i64* |
| 113 %ignored = call i64 @llvm.nacl.atomic.load.i64(i64* %ptr, i32 6) | 124 %ignored = call i64 @llvm.nacl.atomic.load.i64(i64* %ptr, i32 6) |
| 114 ret i64 0 | 125 ret i64 0 |
| 115 } | 126 } |
| 116 ; CHECK-LABEL: test_atomic_load_64_ignored | 127 ; CHECK-LABEL: test_atomic_load_64_ignored |
| 117 ; CHECK: movq x{{.*}}, qword | 128 ; CHECK: movq x{{.*}}, qword |
| 118 ; CHECK: movq qword {{.*}}, x{{.*}} | 129 ; CHECK: movq qword {{.*}}, x{{.*}} |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 | 883 |
| 873 define i32 @test_atomic_is_lock_free_ignored(i32 %iptr) { | 884 define i32 @test_atomic_is_lock_free_ignored(i32 %iptr) { |
| 874 entry: | 885 entry: |
| 875 %ptr = inttoptr i32 %iptr to i8* | 886 %ptr = inttoptr i32 %iptr to i8* |
| 876 %ignored = call i1 @llvm.nacl.atomic.is.lock.free(i32 4, i8* %ptr) | 887 %ignored = call i1 @llvm.nacl.atomic.is.lock.free(i32 4, i8* %ptr) |
| 877 ret i32 0 | 888 ret i32 0 |
| 878 } | 889 } |
| 879 ; CHECK-LABEL: test_atomic_is_lock_free_ignored | 890 ; CHECK-LABEL: test_atomic_is_lock_free_ignored |
| 880 ; CHECK: mov {{.*}}, 0 | 891 ; CHECK: mov {{.*}}, 0 |
| 881 ; This can get optimized out, because it's side-effect-free. | 892 ; This can get optimized out, because it's side-effect-free. |
| 882 ; CHECKO2REM-LABEL: test_atomic_is_lock_free_ignored | 893 ; CHECKO2-LABEL: test_atomic_is_lock_free_ignored |
| 883 ; CHECKO2REM-NOT: mov {{.*}}, 1 | 894 ; CHECKO2-NOT: mov {{.*}}, 1 |
| 884 ; CHECKO2REM: mov {{.*}}, 0 | 895 ; CHECKO2: mov {{.*}}, 0 |
| 885 | 896 |
| 886 ; TODO(jvoung): at some point we can take advantage of the | 897 ; TODO(jvoung): at some point we can take advantage of the |
| 887 ; fact that nacl.atomic.is.lock.free will resolve to a constant | 898 ; fact that nacl.atomic.is.lock.free will resolve to a constant |
| 888 ; (which adds DCE opportunities). Once we optimize, the test expectations | 899 ; (which adds DCE opportunities). Once we optimize, the test expectations |
| 889 ; for this case should change. | 900 ; for this case should change. |
| 890 define i32 @test_atomic_is_lock_free_can_dce(i32 %iptr, i32 %x, i32 %y) { | 901 define i32 @test_atomic_is_lock_free_can_dce(i32 %iptr, i32 %x, i32 %y) { |
| 891 entry: | 902 entry: |
| 892 %ptr = inttoptr i32 %iptr to i8* | 903 %ptr = inttoptr i32 %iptr to i8* |
| 893 %i = call i1 @llvm.nacl.atomic.is.lock.free(i32 4, i8* %ptr) | 904 %i = call i1 @llvm.nacl.atomic.is.lock.free(i32 4, i8* %ptr) |
| 894 %i_ext = zext i1 %i to i32 | 905 %i_ext = zext i1 %i to i32 |
| 895 %cmp = icmp eq i32 %i_ext, 1 | 906 %cmp = icmp eq i32 %i_ext, 1 |
| 896 br i1 %cmp, label %lock_free, label %not_lock_free | 907 br i1 %cmp, label %lock_free, label %not_lock_free |
| 897 lock_free: | 908 lock_free: |
| 898 ret i32 %i_ext | 909 ret i32 %i_ext |
| 899 | 910 |
| 900 not_lock_free: | 911 not_lock_free: |
| 901 %z = add i32 %x, %y | 912 %z = add i32 %x, %y |
| 902 ret i32 %z | 913 ret i32 %z |
| 903 } | 914 } |
| 904 ; CHECK-LABEL: test_atomic_is_lock_free_can_dce | 915 ; CHECK-LABEL: test_atomic_is_lock_free_can_dce |
| 905 ; CHECK: mov {{.*}}, 1 | 916 ; CHECK: mov {{.*}}, 1 |
| 906 ; CHECK: ret | 917 ; CHECK: ret |
| 907 ; CHECK: add | 918 ; CHECK: add |
| 908 ; CHECK: ret | 919 ; CHECK: ret |
| 909 | 920 |
| 910 ; ERRORS-NOT: ICE translation error | 921 ; ERRORS-NOT: ICE translation error |
| 911 ; DUMP-NOT: SZ | 922 ; DUMP-NOT: SZ |
| OLD | NEW |