[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)
    Luke Lau via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Sep  1 04:45:26 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());
+    };
----------------
lukel97 wrote:
I don't think we need to check for zero users in my linked PR, since we're checking the uses of an operand. So it will always have at least one use
https://github.com/llvm/llvm-project/pull/146525
    
    
More information about the llvm-commits
mailing list