aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-06-26 17:03:01 +0100
committerFlorian Hahn <flo@fhahn.com>2025-06-26 17:24:31 +0100
commit42359e5572bf52a3b797dbff05e496f9023aa4d7 (patch)
tree5ee76c56fd3389d770e76e42e8dfac679643091c
parent1bae34e0aad5b57cefb0ea5603d98729f2c47eb4 (diff)
downloadllvm-users/SamTebbs33/fhahn-vpbundle-recipe.zip
llvm-users/SamTebbs33/fhahn-vpbundle-recipe.tar.gz
llvm-users/SamTebbs33/fhahn-vpbundle-recipe.tar.bz2
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlan.h9
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp11
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp2
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanValue.h4
4 files changed, 12 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 6b8f03c..39e9c55 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2797,9 +2797,12 @@ public:
return new VPSingleDefBundleRecipe(BundleType, NewBundledRecipes);
}
- /// Return the VPSingleDefRecipe producing the final result of the bundled
- /// recipe.
- VPSingleDefRecipe *getResultRecipe() const { return BundledRecipes.back(); }
+ /// Return the VPValue to use to infer the result type of the recipe.
+ VPValue *getTypeVPValue() const {
+ unsigned OpIdx =
+ cast<VPReductionRecipe>(BundledRecipes.back())->isConditional() ? 2 : 1;
+ return getOperand(getNumOperands() - OpIdx);
+ }
/// Insert the bundled recipes back into the VPlan, directly before the
/// current recipe. Leaves the bundle recipe empty, which must be removed
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index 31ee4cf..effcb1e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -269,14 +269,6 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
Type *ResultTy =
TypeSwitch<const VPRecipeBase *, Type *>(V->getDefiningRecipe())
- .Case<VPBundleRecipe>([this](const auto *R) {
- unsigned RdxOpIdxOffset =
- cast<VPReductionRecipe>(R->getResultRecipe())->isConditional()
- ? 2
- : 1;
- return inferScalarType(
- R->getOperand(R->getNumOperands() - RdxOpIdxOffset));
- })
.Case<VPActiveLaneMaskPHIRecipe, VPCanonicalIVPHIRecipe,
VPFirstOrderRecurrencePHIRecipe, VPReductionPHIRecipe,
VPWidenPointerInductionRecipe, VPEVLBasedIVPHIRecipe>(
@@ -311,6 +303,9 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
})
.Case<VPReductionRecipe>([this](const auto *R) {
return inferScalarType(R->getChainOp());
+ })
+ .Case<VPSingleDefBundleRecipe>([this](const auto *R) {
+ return inferScalarType(R->getTypeVPValue());
});
assert(ResultTy && "could not infer type for the given VPValue");
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 6eee840..ad861df 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2608,7 +2608,7 @@ void VPSingleDefBundleRecipe::unbundle() {
for (const auto &[Idx, Op] : enumerate(operands()))
BundleLiveInPlaceholders[Idx]->replaceAllUsesWith(Op);
- replaceAllUsesWith(getResultRecipe());
+ replaceAllUsesWith(BundledRecipes.back());
BundledRecipes.clear();
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index 7246cb9..6770fa0 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -32,7 +32,7 @@ namespace llvm {
// Forward declarations.
class raw_ostream;
class Value;
-class VPBundleRecipe;
+class VPSinglDefBundleRecipe;
class VPDef;
struct VPDoubleValueDef;
class VPSlotTracker;
@@ -50,7 +50,7 @@ class VPValue {
friend struct VPDoubleValueDef;
friend class VPInterleaveRecipe;
friend class VPlan;
- friend class VPBundleRecipe;
+ friend class VPSingleDefBundleRecipe;
const unsigned char SubclassID; ///< Subclass identifier (for isa/dyn_cast).