[PATCH] D138412: [IndVarSimplify] Lift limitations on IV being a Phi for turn-to-invariant

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 07:36:07 PST 2022


lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

The test changes seem like improvements to me.
Since we expand into preheader (which might be some other's loop body),
i guess size growth shouldn't be too much of an issue.
LG, but maybe wait for another opinion for a few days.



================
Comment at: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp:224-229
+  if (Rewriter.isHighCostExpansion(InvariantLHS, L, SCEVCheapExpansionBudget,
+                                   TTI, PHTerm))
     return false;
-
+  if (Rewriter.isHighCostExpansion(InvariantRHS, L, SCEVCheapExpansionBudget,
+                                   TTI, PHTerm))
+    return false;
----------------
I guess this is slightly broken, if rhs is constant but lhs needs 2x the `SCEVCheapExpansionBudget`,
we'd still want to expand. (Well, or they both in total should fit into `SCEVCheapExpansionBudget`).
But that is a separate issue.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138412/new/

https://reviews.llvm.org/D138412



More information about the llvm-commits mailing list