[PATCH] D133666: pVplan] Add VPValue::isDefinedOutsideVectorRegions helper (NFC).
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 11 04:46:17 PDT 2022
fhahn created this revision.
fhahn added reviewers: Ayal, gilr, rengolin, reames.
Herald added subscribers: tschuett, psnobl, rogfer01, bollu, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added subscribers: pcwang-thead, vkmr.
Herald added a project: LLVM.
@Ayal suggested a better named helper than using `!getDef()` to check if
a value is invariant across all parts.
The property we are using here is that the VPValue is defined outside
any vector loop region. There's a TODO left to handle recipes defined in
pre-header blocks.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133666
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanValue.h
Index: llvm/lib/Transforms/Vectorize/VPlanValue.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -198,6 +198,11 @@
"VPValue is not a live-in; it is defined by a VPDef inside a VPlan");
return getUnderlyingValue();
}
+
+ /// Returns true if the VPValue is defined outside any vector regions, i.e. it
+ /// is a live-in value.
+ /// TODO: Also handle recipes defined in pre-header blocks.
+ bool isDefinedOutsideVectorRegions() const { return !getDef(); }
};
typedef DenseMap<Value *, VPValue *> Value2VPValueTy;
Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3055,7 +3055,7 @@
if (auto *Def = VPV->getDef()) {
if (auto Rep = dyn_cast<VPReplicateRecipe>(Def))
return Rep->isUniform();
- return false;
+ return VPV->isDefinedOutsideVectorRegions();
}
// A value without a def is external to vplan and thus uniform.
return true;
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9644,7 +9644,9 @@
// If the recipe is uniform across all parts (instead of just per VF), only
// generate a single instance.
if ((isa<LoadInst>(UI) || isa<StoreInst>(UI)) &&
- all_of(operands(), [](VPValue *Op) { return !Op->getDef(); })) {
+ all_of(operands(), [](VPValue *Op) {
+ return Op->isDefinedOutsideVectorRegions();
+ })) {
State.ILV->scalarizeInstruction(UI, this, VPIteration(0, 0), IsPredicated,
State);
if (user_begin() != user_end()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133666.459353.patch
Type: text/x-patch
Size: 1935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220911/addaf801/attachment.bin>
More information about the llvm-commits
mailing list