[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 27 01:55:29 PDT 2025


================
@@ -2143,29 +2157,50 @@ InstructionCost VPWidenCastRecipe::computeCost(ElementCount VF,
       return TTI::CastContextHint::None;
     if (!WidenMemoryRecipe->isConsecutive())
       return TTI::CastContextHint::GatherScatter;
-    if (WidenMemoryRecipe->isReverse())
-      return TTI::CastContextHint::Reversed;
     if (WidenMemoryRecipe->isMasked())
       return TTI::CastContextHint::Masked;
     return TTI::CastContextHint::Normal;
   };
 
+  using namespace llvm::VPlanPatternMatch;
   VPValue *Operand = getOperand(0);
   TTI::CastContextHint CCH = TTI::CastContextHint::None;
+  bool IsReverse = false;
   // 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) {
+    static auto GetOnlyUser = [](const VPSingleDefRecipe *R) -> VPRecipeBase * {
----------------
Mel-Chen wrote:

715a55ff55c3625ed1b3dcad5d37a36f6b75138c
My bad, dropped it, may be an error that occurred when changing from static function to lambda. :(

https://github.com/llvm/llvm-project/pull/146525


More information about the llvm-commits mailing list