[PATCH] D87344: [IndVars] Remove exiting conditions that are trivially true/false

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 10:15:09 PDT 2020


reames added a comment.

In D87344#2298471 <https://reviews.llvm.org/D87344#2298471>, @nikic wrote:

> What is the relationship between this code and `SimplifyIndvar::eliminateIVComparison()`? Is this basically the same thing, just for icmps against something other than the IV itself?
>
> If I'm understanding this correctly, this optimization doesn't really seem to be related to loop exits and could apply to any icmp in the loop. Looking at it in terms of a loop exit seems to make the logic more complicated (e.g. the double inversion of the predicate).

If we want to generally handle icmps involving SCEVs which were not either uses of IVs (directly) or loop exits, I agree this code would be good to pull out and use.

The catch is the the IV logic only visits a small subset of icmps.  If you have any form of complicated expression feeding the icmp, it gives up without every reaching it.

I'll note that I think it's seriously worth considering whether we want a transform which just visits all icmps in a loop and tries to eliminate them, but that's a broader task than this patch.  :)


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

https://reviews.llvm.org/D87344



More information about the llvm-commits mailing list