Skip to content

Commit a6b06b7

Browse files
committed
[VPlan] Print VPValue operands for VPWidenPHI if possible.
For VPWidenPHIRecipes that model all incoming values as VPValue operands, print those operands instead of printing the original PHI. D99294 updates recipes of reduction PHIs to use the VPValue for the incoming value from the loop backedge, making use of this new printing.
1 parent 3eadcb8 commit a6b06b7

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,21 @@ void VPWidenGEPRecipe::print(raw_ostream &O, const Twine &Indent,
10081008

10091009
void VPWidenPHIRecipe::print(raw_ostream &O, const Twine &Indent,
10101010
VPSlotTracker &SlotTracker) const {
1011-
O << Indent << "WIDEN-PHI " << VPlanIngredient(getUnderlyingValue());
1011+
O << Indent << "WIDEN-PHI ";
1012+
1013+
auto *OriginalPhi = cast<PHINode>(getUnderlyingValue());
1014+
// Unless all incoming values are modeled in VPlan print the original PHI
1015+
// directly.
1016+
// TODO: Remove once all VPWidenPHIRecipe instances keep all relevant incoming
1017+
// values as VPValues.
1018+
if (getNumOperands() != OriginalPhi->getNumOperands()) {
1019+
O << VPlanIngredient(OriginalPhi);
1020+
return;
1021+
}
1022+
1023+
printAsOperand(O, SlotTracker);
1024+
O << " = phi ";
1025+
printOperands(O, SlotTracker);
10121026
}
10131027

10141028
void VPBlendRecipe::print(raw_ostream &O, const Twine &Indent,

llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ compound=true
111111
N1 -> N2 [ label=""]
112112
N2 [label =
113113
"for.body:\l" +
114-
" WIDEN-PHI %indvars.iv = phi 0, %indvars.iv.next\l" +
114+
" WIDEN-PHI ir\<%indvars.iv\> = phi ir\<0\>, ir\<%indvars.iv.next\>\l" +
115115
" EMIT ir\<%arr.idx\> = getelementptr ir\<%A\> ir\<%indvars.iv\>\l" +
116116
" EMIT ir\<%l1\> = load ir\<%arr.idx\>\l" +
117117
" EMIT ir\<%res\> = add ir\<%l1\> ir\<10\>\l" +

0 commit comments

Comments
 (0)