[llvm] 8a56179 - [VPlan] Store induction kind & binop directly in VPDerviedIVRecipe(NFC)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 10 02:58:12 PDT 2023
Author: Florian Hahn
Date: 2023-08-10T10:57:32+01:00
New Revision: 8a56179bcd8cfad152d4589c78b6b775324457b2
URL: https://github.com/llvm/llvm-project/commit/8a56179bcd8cfad152d4589c78b6b775324457b2
DIFF: https://github.com/llvm/llvm-project/commit/8a56179bcd8cfad152d4589c78b6b775324457b2.diff
LOG: [VPlan] Store induction kind & binop directly in VPDerviedIVRecipe(NFC)
Limit the information stored in VPDerivedIVRecipe to the ingredients
really needed.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9bd86afb75187f..ef4b540cbfc95b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2386,7 +2386,7 @@ static Value *
emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
Value *Step,
InductionDescriptor::InductionKind InductionKind,
- BinaryOperator *InductionBinOp) {
+ const BinaryOperator *InductionBinOp) {
Type *StepTy = Step->getType();
Value *CastedIndex = StepTy->isIntegerTy()
? B.CreateSExtOrTrunc(Index, StepTy)
@@ -9479,19 +9479,17 @@ void VPDerivedIVRecipe::execute(VPTransformState &State) {
// Fast-math-flags propagate from the original induction instruction.
IRBuilder<>::FastMathFlagGuard FMFG(State.Builder);
- if (IndDesc.getInductionBinOp() &&
- isa<FPMathOperator>(IndDesc.getInductionBinOp()))
- State.Builder.setFastMathFlags(
- IndDesc.getInductionBinOp()->getFastMathFlags());
+ if (BinOp && isa<FPMathOperator>(BinOp))
+ State.Builder.setFastMathFlags(BinOp->getFastMathFlags());
Value *Step = State.get(getStepValue(), VPIteration(0, 0));
Value *CanonicalIV = State.get(getCanonicalIV(), VPIteration(0, 0));
- Value *DerivedIV = emitTransformedIndex(
- State.Builder, CanonicalIV, getStartValue()->getLiveInIRValue(), Step,
- IndDesc.getKind(), IndDesc.getInductionBinOp());
+ Value *DerivedIV = emitTransformedIndex(State.Builder, CanonicalIV,
+ getStartValue()->getLiveInIRValue(),
+ Step, Kind, BinOp);
DerivedIV->setName("offset.idx");
if (ResultTy != DerivedIV->getType()) {
- assert(Step->getType()->isIntegerTy() &&
+ assert(IsTruncated && Step->getType()->isIntegerTy() &&
"Truncation requires an integer step");
DerivedIV = State.Builder.CreateTrunc(DerivedIV, ResultTy);
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index c9da695fee8006..b6d8a55d0b8119 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2143,15 +2143,20 @@ class VPDerivedIVRecipe : public VPRecipeBase, public VPValue {
/// induction and in this case it will get truncated to ResultTy.
Type *ResultTy;
+ bool IsTruncated;
+
/// Induction descriptor for the induction the canonical IV is transformed to.
- const InductionDescriptor &IndDesc;
+ const InductionDescriptor::InductionKind Kind;
+ const BinaryOperator *BinOp;
public:
VPDerivedIVRecipe(const InductionDescriptor &IndDesc, VPValue *Start,
VPCanonicalIVPHIRecipe *CanonicalIV, VPValue *Step,
Type *ResultTy)
: VPRecipeBase(VPDef::VPDerivedIVSC, {Start, CanonicalIV, Step}),
- VPValue(this), ResultTy(ResultTy), IndDesc(IndDesc) {}
+ VPValue(this), ResultTy(ResultTy),
+ IsTruncated(IndDesc.getStep()->getType() != ResultTy),
+ Kind(IndDesc.getKind()), BinOp(IndDesc.getInductionBinOp()) {}
~VPDerivedIVRecipe() override = default;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index dec7f73b013768..e70dcec6b8e009 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -797,7 +797,7 @@ void VPDerivedIVRecipe::print(raw_ostream &O, const Twine &Indent,
O << " * ";
getStepValue()->printAsOperand(O, SlotTracker);
- if (IndDesc.getStep()->getType() != ResultTy)
+ if (IsTruncated)
O << " (truncated to " << *ResultTy << ")";
}
#endif
More information about the llvm-commits
mailing list