When InstCombine simplifies a load -> extract element to gep -> load, place

the new load by the old load instead of by the extract element because
a store could have occurred between the load and extract element.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mon P Wang
2009-08-13 05:12:13 +00:00
parent b808588a3a
commit 7c4efa6808
2 changed files with 28 additions and 3 deletions
@@ -12465,12 +12465,14 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
unsigned AS =
cast<PointerType>(I->getOperand(0)->getType())->getAddressSpace();
Value *Ptr = InsertBitCastBefore(I->getOperand(0),
PointerType::get(EI.getType(), AS),EI);
PointerType::get(EI.getType(), AS),*I);
GetElementPtrInst *GEP =
GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName()+".gep");
cast<GEPOperator>(GEP)->setIsInBounds(true);
InsertNewInstBefore(GEP, EI);
return new LoadInst(GEP);
InsertNewInstBefore(GEP, *I);
LoadInst* Load = new LoadInst(GEP, "tmp");
InsertNewInstBefore(Load, *I);
return ReplaceInstUsesWith(EI, Load);
}
}
if (InsertElementInst *IE = dyn_cast<InsertElementInst>(I)) {