[PATCH] D79893: [SCEV] Constant fold MultExpr before applying depth limit.

Denis Antrushin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 14 00:29:53 PDT 2020


dantrushin marked an inline comment as done.
dantrushin added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:3006
+  if (Depth > MaxArithDepth || hasHugeExpression(Ops))
+    return getOrCreateMulExpr(Ops, Flags);
+
----------------
efriedma wrote:
> I think you need to rearrange the code a bit more: with the current version of the patch, we increase the depth before checking the current depth.
> 
> The general idea makes sense: we should perform optimizations that aren't recursive before the depth check.
Eli, could you explain?
Do you mean `Depth + 1` used in calls above on constant folding path?
My reasoning was following:
If we're already at depth limit (`Depth == MaxArithDepth`) then we don't want to recurse into possible expensive folding.
On the other hand, constant folding will be attempted anyway, which is what we want here.

Does it makes sense?





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79893





More information about the llvm-commits mailing list