[llvm] [VPlan] Update final IV exit value via VPlan. (PR #112147)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 13:26:25 PST 2025


================
@@ -666,6 +666,134 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
   }
 }
 
+/// Return a wide IV, if \p VPV is an optimizable wide IV or wide IV use. That
+/// is, if \p VPV is either an untruncated wide induction, or if it increments a
+/// wide induction by its step.
+static VPWidenInductionRecipe *isOptimizableIVOrUse(VPValue *VPV) {
+  auto *WideIV = dyn_cast<VPWidenInductionRecipe>(VPV);
+  if (WideIV) {
+    // VPV itself is a wide induction, separately compute the end value for exit
+    // users if it is not a truncated IV.
+    if (isa<VPWidenPointerInductionRecipe>(WideIV) ||
+        !cast<VPWidenIntOrFpInductionRecipe>(WideIV)->getTruncInst())
+      return WideIV;
+    return nullptr;
+  }
+
+  // Check if VPV is an optimizable induction increment.
----------------
fhahn wrote:

I am not sure, generally I think there are more benefits from not having explicitly increments if not needed, especially early on

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


More information about the llvm-commits mailing list