forked from OSchip/llvm-project
[VPlan] Support PHIs as LastInst when inserting scalars in ::get().
At the moment, we create insertelement instructions directly after LastInst when inserting scalar values in a vector in VPTransformState::get. This results in invalid IR when LastInst is a phi, followed by another phi. In that case, the new instructions should be inserted just after the last PHI node in the block. At the moment, I don't think the problematic case can be triggered, but it can happen once predicate regions are merged and multiple VPredInstPHI recipes are in the same block (D100260). Reviewed By: Ayal Differential Revision: https://reviews.llvm.org/D104188
This commit is contained in:
parent
873308fd8c
commit
80a403348b
|
@ -9730,12 +9730,14 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part) {
|
|||
}
|
||||
|
||||
auto *LastInst = cast<Instruction>(get(Def, {Part, LastLane}));
|
||||
|
||||
// Set the insert point after the last scalarized instruction. This
|
||||
// ensures the insertelement sequence will directly follow the scalar
|
||||
// definitions.
|
||||
// Set the insert point after the last scalarized instruction or after the
|
||||
// last PHI, if LastInst is a PHI. This ensures the insertelement sequence
|
||||
// will directly follow the scalar definitions.
|
||||
auto OldIP = Builder.saveIP();
|
||||
auto NewIP = std::next(BasicBlock::iterator(LastInst));
|
||||
auto NewIP =
|
||||
isa<PHINode>(LastInst)
|
||||
? BasicBlock::iterator(LastInst->getParent()->getFirstNonPHI())
|
||||
: std::next(BasicBlock::iterator(LastInst));
|
||||
Builder.SetInsertPoint(&*NewIP);
|
||||
|
||||
// However, if we are vectorizing, we need to construct the vector values.
|
||||
|
|
Loading…
Reference in New Issue