Skip to content

Commit a275559

Browse files
committed
[VPlan] Improve narrowToSingleScalarRecipes (NFC)
1 parent 9e1d656 commit a275559

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,13 +1307,13 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
13071307
if (RepR && (RepR->isSingleScalar() || RepR->isPredicated()))
13081308
continue;
13091309

1310-
auto *RepOrWidenR = cast<VPSingleDefRecipe>(&R);
1311-
if (RepR && isa<StoreInst>(RepR->getUnderlyingInstr()) &&
1310+
// Handle replicate-stores to single-scalar address.
1311+
if (RepR && RepR->getOpcode() == Instruction::Store &&
13121312
vputils::isSingleScalar(RepR->getOperand(1))) {
13131313
auto *Clone = new VPReplicateRecipe(
1314-
RepOrWidenR->getUnderlyingInstr(), RepOrWidenR->operands(),
1314+
RepR->getUnderlyingInstr(), RepR->operands(),
13151315
true /*IsSingleScalar*/, nullptr /*Mask*/, *RepR /*Metadata*/);
1316-
Clone->insertBefore(RepOrWidenR);
1316+
Clone->insertBefore(RepR);
13171317
auto *Ext = new VPInstruction(VPInstruction::ExtractLastElement,
13181318
{Clone->getOperand(0)});
13191319
Ext->insertBefore(Clone);
@@ -1325,6 +1325,7 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
13251325
// Skip recipes that aren't single scalars or don't have only their
13261326
// scalar results used. In the latter case, we would introduce extra
13271327
// broadcasts.
1328+
auto *RepOrWidenR = cast<VPSingleDefRecipe>(&R);
13281329
if (!vputils::isSingleScalar(RepOrWidenR) ||
13291330
!all_of(RepOrWidenR->users(), [RepOrWidenR](const VPUser *U) {
13301331
return U->usesScalars(RepOrWidenR) ||

0 commit comments

Comments
 (0)