[llvm] a6b06b7 - [VPlan] Print VPValue operands for VPWidenPHI if possible.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 6 04:11:36 PDT 2021
Author: Florian Hahn
Date: 2021-04-06T12:11:21+01:00
New Revision: a6b06b785cda1bb94dd05f29d66892ccb44cf0cd
URL: https://github.com/llvm/llvm-project/commit/a6b06b785cda1bb94dd05f29d66892ccb44cf0cd
DIFF: https://github.com/llvm/llvm-project/commit/a6b06b785cda1bb94dd05f29d66892ccb44cf0cd.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index ab793e95d2414..421ecb28029a7 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1008,7 +1008,21 @@ void VPWidenGEPRecipe::print(raw_ostream &O, const Twine &Indent,
void VPWidenPHIRecipe::print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const {
- O << Indent << "WIDEN-PHI " << VPlanIngredient(getUnderlyingValue());
+ O << Indent << "WIDEN-PHI ";
+
+ auto *OriginalPhi = cast<PHINode>(getUnderlyingValue());
+ // Unless all incoming values are modeled in VPlan print the original PHI
+ // directly.
+ // TODO: Remove once all VPWidenPHIRecipe instances keep all relevant incoming
+ // values as VPValues.
+ if (getNumOperands() != OriginalPhi->getNumOperands()) {
+ O << VPlanIngredient(OriginalPhi);
+ return;
+ }
+
+ printAsOperand(O, SlotTracker);
+ O << " = phi ";
+ printOperands(O, SlotTracker);
}
void VPBlendRecipe::print(raw_ostream &O, const Twine &Indent,
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp
index 853be5757731c..ea84034354a91 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp
@@ -111,7 +111,7 @@ compound=true
N1 -> N2 [ label=""]
N2 [label =
"for.body:\l" +
- " WIDEN-PHI %indvars.iv = phi 0, %indvars.iv.next\l" +
+ " WIDEN-PHI ir\<%indvars.iv\> = phi ir\<0\>, ir\<%indvars.iv.next\>\l" +
" EMIT ir\<%arr.idx\> = getelementptr ir\<%A\> ir\<%indvars.iv\>\l" +
" EMIT ir\<%l1\> = load ir\<%arr.idx\>\l" +
" EMIT ir\<%res\> = add ir\<%l1\> ir\<10\>\l" +
More information about the llvm-commits
mailing list