OLD | NEW |
1 ; This tests the optimization of atomic cmpxchg w/ following cmp + branches. | 1 ; This tests the optimization of atomic cmpxchg w/ following cmp + branches. |
2 | 2 |
3 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 \ | 3 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 \ |
4 ; RUN: | FileCheck --check-prefix=O2 %s | 4 ; RUN: | FileCheck --check-prefix=O2 %s |
5 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 \ | 5 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 \ |
6 ; RUN: | FileCheck --check-prefix=OM1 %s | 6 ; RUN: | FileCheck --check-prefix=OM1 %s |
7 | 7 |
8 declare i32 @llvm.nacl.atomic.cmpxchg.i32(i32*, i32, i32, i32, i32) | 8 declare i32 @llvm.nacl.atomic.cmpxchg.i32(i32*, i32, i32, i32, i32) |
9 | 9 |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 ; O2-LABEL: test_atomic_cmpxchg_loop | 34 ; O2-LABEL: test_atomic_cmpxchg_loop |
35 ; O2: lock cmpxchg DWORD PTR [e{{[^a].}}],e{{[^a]}} | 35 ; O2: lock cmpxchg DWORD PTR [e{{[^a].}}],e{{[^a]}} |
36 ; O2-NEXT: j{{e|ne}} | 36 ; O2-NEXT: j{{e|ne}} |
37 ; Make sure the call isn't accidentally deleted. | 37 ; Make sure the call isn't accidentally deleted. |
38 ; O2: call | 38 ; O2: call |
39 ; | 39 ; |
40 ; Check that the unopt version does have a cmp | 40 ; Check that the unopt version does have a cmp |
41 ; OM1-LABEL: test_atomic_cmpxchg_loop | 41 ; OM1-LABEL: test_atomic_cmpxchg_loop |
42 ; OM1: lock cmpxchg DWORD PTR [e{{[^a].}}],e{{[^a]}} | 42 ; OM1: lock cmpxchg DWORD PTR [e{{[^a].}}],e{{[^a]}} |
43 ; OM1: cmp | 43 ; OM1: cmp |
44 ; OM1: je | 44 ; OM1: sete |
45 ; OM1: call | 45 ; OM1: call |
46 | 46 |
47 ; Still works if the compare operands are flipped. | 47 ; Still works if the compare operands are flipped. |
48 define i32 @test_atomic_cmpxchg_loop2(i32 %iptr, i32 %expected, i32 %desired) { | 48 define i32 @test_atomic_cmpxchg_loop2(i32 %iptr, i32 %expected, i32 %desired) { |
49 entry: | 49 entry: |
50 br label %loop | 50 br label %loop |
51 | 51 |
52 loop: | 52 loop: |
53 %expected_loop = phi i32 [ %expected, %entry ], [ %old, %loop ] | 53 %expected_loop = phi i32 [ %expected, %entry ], [ %old, %loop ] |
54 %ptr = inttoptr i32 %iptr to i32* | 54 %ptr = inttoptr i32 %iptr to i32* |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 br i1 %success, label %done, label %loop | 123 br i1 %success, label %done, label %loop |
124 | 124 |
125 done: | 125 done: |
126 %r = zext i1 %success to i32 | 126 %r = zext i1 %success to i32 |
127 ret i32 %r | 127 ret i32 %r |
128 } | 128 } |
129 ; O2-LABEL: test_atomic_cmpxchg_no_opt2 | 129 ; O2-LABEL: test_atomic_cmpxchg_no_opt2 |
130 ; O2: lock cmpxchg DWORD PTR [e{{[^a].}}],e{{[^a]}} | 130 ; O2: lock cmpxchg DWORD PTR [e{{[^a].}}],e{{[^a]}} |
131 ; O2: mov {{.*}} | 131 ; O2: mov {{.*}} |
132 ; O2: cmp | 132 ; O2: cmp |
133 ; O2: je | 133 ; O2: sete |
OLD | NEW |