[PATCH] D79036: [SCCP] Switch to widen at PHIs, stores and call edges.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 18:34:43 PDT 2020


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

I guess I'll start by stepping back to state the fundamental issue here: constant ranges introduce way to many intermediate states, so the algorithm doesn't converge in a reasonable amount of time.  To deal with this, you have to skip some steps: force values to overdefined, or maybe a substantially wider constantrange.  There are a few different ways you could do this:

1. Some sort of global counter: after N steps, anything still in the worklist goes straight to overdefined.
2. Detect specific cycles: for example, if you have a loop induction variable, compute the range based on the trip count of the loop.
3. What you're doing here: add a counter to each join point.  It's impossible to loop without a join point, so you'll catch any arithmetic loops.
4. Add a counter to arithmetic operations.
5. Probably some other approaches I haven't thought of.

All of these can potentially work together: you can take the intersection of multiple approaches.

My intuition is that detecting specific cycles is going to be a lot more effective than iteratively widening, in terms of finding optimization opportunities.  But detecting cycles is hard to do reliably, so we probably want some iterative limit anyway.

------

I think the approach here does a good job of avoiding potential pathological cases, some of which might not really involve arithmetic.  And I don't see any issues with the implementation.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79036





More information about the llvm-commits mailing list