[PRE] Preserve !invariant.load metadata

Spoted via inspection.  Test case included.

llvm-svn: 253275
This commit is contained in:
Philip Reames 2015-11-17 00:15:09 +00:00
parent ee15a8e627
commit 577e9b1072
2 changed files with 19 additions and 0 deletions

View File

@ -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);

View File

@ -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 = !{ }