[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 30 23:28:33 PST 2025
================
@@ -2341,21 +2356,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->getNumUsers() == 0 || R->hasMoreThanOneUniqueUser())
+ return nullptr;
+ return dyn_cast<VPRecipeBase>(*R->user_begin());
----------------
Mel-Chen wrote:
f61eaad36156c5eb1851647c72b79c26fe2d6f7d
I'm not sure whether SmallVector Users can contain duplicate users. If we want to preserve the original semantics of this code, we should guard it with hasOneUser() before calling getSingleUser().
https://github.com/llvm/llvm-project/pull/146525
More information about the llvm-commits
mailing list