[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 01:57:23 PDT 2025
================
@@ -2224,21 +2238,37 @@ InstructionCost VPWidenCastRecipe::computeCost(ElementCount VF,
return TTI::CastContextHint::Normal;
};
+ using namespace llvm::VPlanPatternMatch;
VPValue *Operand = getOperand(0);
TTI::CastContextHint CCH = TTI::CastContextHint::None;
// For Trunc/FPTrunc, get the context from the only user.
- if ((Opcode == Instruction::Trunc || Opcode == Instruction::FPTrunc) &&
- !hasMoreThanOneUniqueUser() && getNumUsers() > 0) {
- if (auto *StoreRecipe = dyn_cast<VPRecipeBase>(*user_begin()))
- CCH = ComputeCCH(StoreRecipe);
+ if (Opcode == Instruction::Trunc || Opcode == Instruction::FPTrunc) {
+ auto GetOnlyUser = [](const VPSingleDefRecipe *R) -> VPRecipeBase * {
+ if (R->hasMoreThanOneUniqueUser() || R->getNumUsers() == 0)
+ return nullptr;
+ return dyn_cast<VPRecipeBase>(*R->user_begin());
+ };
----------------
Mel-Chen wrote:
Although it might not be related, this comment made me find that maybe swapping the two conditions could be better.
9546b23d9758a8fc49d6431e69f22421d1a0cc69
https://github.com/llvm/llvm-project/pull/146525
More information about the llvm-commits
mailing list