PR18060 - When we RAUW values with ExtractElement instructions in some cases

we generate PHI nodes with multiple entries from the same basic block but
with different values. Enabling CSE on ExtractElement instructions make sure
that all of the RAUWed instructions are the same.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195773 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nadav Rotem
2013-11-26 17:29:19 +00:00
parent 15f7d261b5
commit bba8da2ba0
2 changed files with 55 additions and 0 deletions

View File

@@ -1591,6 +1591,8 @@ Value *BoUpSLP::vectorizeTree() {
if (PHINode *PN = dyn_cast<PHINode>(Vec)) {
Builder.SetInsertPoint(PN->getParent()->getFirstInsertionPt());
Value *Ex = Builder.CreateExtractElement(Vec, Lane);
if (Instruction *Ins = dyn_cast<Instruction>(Ex))
GatherSeq.insert(Ins);
User->replaceUsesOfWith(Scalar, Ex);
} else if (isa<Instruction>(Vec)){
if (PHINode *PH = dyn_cast<PHINode>(User)) {
@@ -1598,17 +1600,23 @@ Value *BoUpSLP::vectorizeTree() {
if (PH->getIncomingValue(i) == Scalar) {
Builder.SetInsertPoint(PH->getIncomingBlock(i)->getTerminator());
Value *Ex = Builder.CreateExtractElement(Vec, Lane);
if (Instruction *Ins = dyn_cast<Instruction>(Ex))
GatherSeq.insert(Ins);
PH->setOperand(i, Ex);
}
}
} else {
Builder.SetInsertPoint(cast<Instruction>(User));
Value *Ex = Builder.CreateExtractElement(Vec, Lane);
if (Instruction *Ins = dyn_cast<Instruction>(Ex))
GatherSeq.insert(Ins);
User->replaceUsesOfWith(Scalar, Ex);
}
} else {
Builder.SetInsertPoint(F->getEntryBlock().begin());
Value *Ex = Builder.CreateExtractElement(Vec, Lane);
if (Instruction *Ins = dyn_cast<Instruction>(Ex))
GatherSeq.insert(Ins);
User->replaceUsesOfWith(Scalar, Ex);
}