diff options
| author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-06-26 19:51:19 +0000 | 
|---|---|---|
| committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-06-26 19:51:19 +0000 | 
| commit | ed988fb97d8cbede0880c1f254ff8788803dccb3 (patch) | |
| tree | cdbff21ad156f20bdc92b69a037e1b5cba5a63b2 /llvm/test/Transforms | |
| parent | 83e0723457a039381e0347730cb6448826c9eca9 (diff) | |
| download | bcm5719-llvm-ed988fb97d8cbede0880c1f254ff8788803dccb3.tar.gz bcm5719-llvm-ed988fb97d8cbede0880c1f254ff8788803dccb3.zip | |
GVN: Preserve invariant.load metadata
If both instructions to be replaced are marked invariant the resulting
instruction is invariant.
rdar://13358910
Fix by Erik Eckstein!
llvm-svn: 211801
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/GVN/invariant-load.ll | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/llvm/test/Transforms/GVN/invariant-load.ll b/llvm/test/Transforms/GVN/invariant-load.ll new file mode 100644 index 00000000000..73a12787fbd --- /dev/null +++ b/llvm/test/Transforms/GVN/invariant-load.ll @@ -0,0 +1,30 @@ +; RUN: opt -basicaa -gvn -S < %s | FileCheck %s + +define i32 @test1(i32* nocapture %p, i8* nocapture %q) { +; CHECK-LABEL: test1 +; CHECK: %x = load i32* %p, align 4, !invariant.load !0 +; CHECK-NOT: %y = load +entry: +  %x = load i32* %p, align 4, !invariant.load !0 +  %conv = trunc i32 %x to i8 +  store i8 %conv, i8* %q, align 1 +  %y = load i32* %p, align 4, !invariant.load !0 +  %add = add i32 %y, 1 +  ret i32 %add +} + +define i32 @test2(i32* nocapture %p, i8* nocapture %q) { +; CHECK-LABEL: test2 +; CHECK-NOT: !invariant.load +; CHECK-NOT: %y = load +entry: +  %x = load i32* %p, align 4 +  %conv = trunc i32 %x to i8 +  store i8 %conv, i8* %q, align 1 +  %y = load i32* %p, align 4, !invariant.load !0 +  %add = add i32 %y, 1 +  ret i32 %add +} + +!0 = metadata !{ } + | 

