[llvm] r253275 - [PRE] Preserve !invariant.load metadata
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 16:15:10 PST 2015
Author: reames
Date: Mon Nov 16 18:15:09 2015
New Revision: 253275
URL: http://llvm.org/viewvc/llvm-project?rev=253275&view=rev
Log:
[PRE] Preserve !invariant.load metadata
Spoted via inspection. Test case included.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
llvm/trunk/test/Transforms/GVN/invariant-load.ll
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=253275&r1=253274&r2=253275&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Nov 16 18:15:09 2015
@@ -1669,6 +1669,8 @@ bool GVN::PerformLoadPRE(LoadInst *LI, A
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);
Modified: llvm/trunk/test/Transforms/GVN/invariant-load.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/invariant-load.ll?rev=253275&r1=253274&r2=253275&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/GVN/invariant-load.ll (original)
+++ llvm/trunk/test/Transforms/GVN/invariant-load.ll Mon Nov 16 18:15:09 2015
@@ -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 = !{ }
More information about the llvm-commits
mailing list