diff options
author | Philip Reames <listmail@philipreames.com> | 2015-11-17 00:15:09 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2015-11-17 00:15:09 +0000 |
commit | b6e8fe3dacb49dfe4c67dbc3cc40d59cd902f519 (patch) | |
tree | 41f5a4c88e7fb2f0ce74b8a7989ec21657233cf4 | |
parent | dbd2d32892e83d270b6fedc54ea301f75e8ae0ac (diff) | |
download | bcm5719-llvm-b6e8fe3dacb49dfe4c67dbc3cc40d59cd902f519.tar.gz bcm5719-llvm-b6e8fe3dacb49dfe4c67dbc3cc40d59cd902f519.zip |
[PRE] Preserve !invariant.load metadata
Spoted via inspection. Test case included.
llvm-svn: 253275
-rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 2 | ||||
-rw-r--r-- | llvm/test/Transforms/GVN/invariant-load.ll | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index e2822e320a8..06faa2d76b6 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1669,6 +1669,8 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock, if (Tags) NewLoad->setAAMetadata(Tags); + if (auto *MD = LI->getMetadata(LLVMContext::MD_invariant_load)) + NewLoad->setMetadata(LLVMContext::MD_invariant_load, MD); if (auto *InvGroupMD = LI->getMetadata(LLVMContext::MD_invariant_group)) NewLoad->setMetadata(LLVMContext::MD_invariant_group, InvGroupMD); diff --git a/llvm/test/Transforms/GVN/invariant-load.ll b/llvm/test/Transforms/GVN/invariant-load.ll index 982da8cfe48..f74fd3392c1 100644 --- a/llvm/test/Transforms/GVN/invariant-load.ll +++ b/llvm/test/Transforms/GVN/invariant-load.ll @@ -114,6 +114,23 @@ entry: ret i32 %res } +define i32 @test8(i1 %cnd, i32* %p) { +; CHECK-LABEL: test8 +; CHECK: @bar +; CHECK: load i32, i32* %p2, !invariant.load +; CHECK: br label %merge +entry: + %v1 = load i32, i32* %p, !invariant.load !0 + br i1 %cnd, label %taken, label %merge +taken: + %p2 = call i32* (...) @bar(i32* %p) + br label %merge +merge: + %p3 = phi i32* [%p, %entry], [%p2, %taken] + %v2 = load i32, i32* %p3, !invariant.load !0 + %res = sub i32 %v1, %v2 + ret i32 %res +} !0 = !{ } |