- // or at the start of the basic block, so any subsequent extracts can use it.
- bool ReplaceAllExtUsers;
- if (auto *ExtVecOpInst = dyn_cast<Instruction>(ExtVecOp)) {
+ // (as long as it's not a PHI) or at the start of the basic block of the
+ // extract, so any subsequent extracts in the same basic block can use it.
+ // TODO: Insert before the earliest ExtractElementInst that is replaced.
+ auto *ExtVecOpInst = dyn_cast<Instruction>(ExtVecOp);
+ if (ExtVecOpInst && !isa<PHINode>(ExtVecOpInst))