diff options
| author | Philip Reames <listmail@philipreames.com> | 2016-04-21 17:03:33 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2016-04-21 17:03:33 +0000 |
| commit | ac55090e96787a31bfdb9ffa1fb8d0760f666db7 (patch) | |
| tree | 1a92985aba069433d5ae36a2fa73e33cb057a043 /llvm/test/Transforms/InstCombine/atomic.ll | |
| parent | 34b335bdf7bdcd4e7dec8d3915a704fed6adcd62 (diff) | |
| download | bcm5719-llvm-ac55090e96787a31bfdb9ffa1fb8d0760f666db7.tar.gz bcm5719-llvm-ac55090e96787a31bfdb9ffa1fb8d0760f666db7.zip | |
[instcombine][unordered] Implement *-load forwarding for unordered atomics
This builds on 266999 which made FindAvailableValue do the right thing. Tests included show the newly enabled transforms and those which disabled either due to conservatism or correctness requirements.
llvm-svn: 267006
Diffstat (limited to 'llvm/test/Transforms/InstCombine/atomic.ll')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/atomic.ll | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/llvm/test/Transforms/InstCombine/atomic.ll b/llvm/test/Transforms/InstCombine/atomic.ll index bf576ba4b3a..75b63ff36ab 100644 --- a/llvm/test/Transforms/InstCombine/atomic.ll +++ b/llvm/test/Transforms/InstCombine/atomic.ll @@ -37,11 +37,11 @@ define i32 @test3(i32* %p) { ret i32 %z } -; FIXME: Forwarding from a stronger atomic is fine +; Forwarding from a stronger ordered atomic is fine define i32 @test4(i32* %p) { ; CHECK-LABEL: define i32 @test4( ; CHECK: %x = load atomic i32, i32* %p seq_cst, align 4 -; CHECK: %y = load atomic i32, i32* %p unordered, align 4 +; CHECK: shl i32 %x, 1 %x = load atomic i32, i32* %p seq_cst, align 4 %y = load atomic i32, i32* %p unordered, align 4 %z = add i32 %x, %y @@ -60,3 +60,36 @@ define i32 @test5(i32* %p) { ret i32 %z } +; Forwarding atomic to atomic is fine +define i32 @test6(i32* %p) { +; CHECK-LABEL: define i32 @test6( +; CHECK: %x = load atomic i32, i32* %p unordered, align 4 +; CHECK: shl i32 %x, 1 + %x = load atomic i32, i32* %p unordered, align 4 + %y = load atomic i32, i32* %p unordered, align 4 + %z = add i32 %x, %y + ret i32 %z +} + +; FIXME: we currently don't do anything for monotonic +define i32 @test7(i32* %p) { +; CHECK-LABEL: define i32 @test7( +; CHECK: %x = load atomic i32, i32* %p seq_cst, align 4 +; CHECK: %y = load atomic i32, i32* %p monotonic, align 4 + %x = load atomic i32, i32* %p seq_cst, align 4 + %y = load atomic i32, i32* %p monotonic, align 4 + %z = add i32 %x, %y + ret i32 %z +} + +; FIXME: We could forward in racy code +define i32 @test8(i32* %p) { +; CHECK-LABEL: define i32 @test8( +; CHECK: %x = load atomic i32, i32* %p seq_cst, align 4 +; CHECK: %y = load atomic i32, i32* %p acquire, align 4 + %x = load atomic i32, i32* %p seq_cst, align 4 + %y = load atomic i32, i32* %p acquire, align 4 + %z = add i32 %x, %y + ret i32 %z +} + |

