[llvm] 15bf707 - [VPlan] Support truncated IVs in getSCEVExprForVPValue. (NFCI)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 25 14:09:59 PST 2025
Author: Florian Hahn
Date: 2025-12-25T22:03:29Z
New Revision: 15bf7079b0a99cb6cb77e7600fae0aa4cddb0a57
URL: https://github.com/llvm/llvm-project/commit/15bf7079b0a99cb6cb77e7600fae0aa4cddb0a57
DIFF: https://github.com/llvm/llvm-project/commit/15bf7079b0a99cb6cb77e7600fae0aa4cddb0a57.diff
LOG: [VPlan] Support truncated IVs in getSCEVExprForVPValue. (NFCI)
Handle truncated inductions in getSCEVExprForVPValue. This means we are
able to compute SCEV expressions for more inductions used in the
VPlan-based cost model, which should produce costs matching the legacy
cost model.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index dac5ba1b990b8..165eac7d19a56 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -137,7 +137,11 @@ const SCEV *vputils::getSCEVExprForVPValue(const VPValue *V,
return SE.getCouldNotCompute();
const SCEV *Start =
getSCEVExprForVPValue(R->getStartValue(), PSE, L);
- return SE.getAddRecExpr(Start, Step, L, SCEV::FlagAnyWrap);
+ const SCEV *AddRec =
+ SE.getAddRecExpr(Start, Step, L, SCEV::FlagAnyWrap);
+ if (R->getTruncInst())
+ return SE.getTruncateExpr(AddRec, R->getScalarType());
+ return AddRec;
})
.Case<VPDerivedIVRecipe>([&SE, &PSE, L](const VPDerivedIVRecipe *R) {
const SCEV *Start = getSCEVExprForVPValue(R->getOperand(0), PSE, L);
More information about the llvm-commits
mailing list