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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 02:05:17 PST 2025


================
@@ -2244,18 +2259,28 @@ InstructionCost VPWidenCastRecipe::computeCost(ElementCount VF,
   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) {
+    if (auto *Recipe = dyn_cast_or_null<VPRecipeBase>(getSingleUser())) {
+      if (match(Recipe, m_VPInstruction<VPInstruction::Reverse>(m_VPValue())))
----------------
fhahn wrote:

```suggestion
      if (match(Recipe, m_Reverse(m_VPValue())))
```

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


More information about the llvm-commits mailing list