[PATCH] D152730: [ConstraintElim] Add A < B if A is an increasing phi for A != B.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 05:32:35 PDT 2023


nikic added a comment.

The last time I looked at this, I think the logic was correct, but I was having some serious doubts that doing this in ConstraintElim is really a good idea. A big red flag here is that this will only work if the "primary" loop condition comes first, while in canonical (rotated) form, it would be last, on the loop latch. It happens to work out for the motivating example because ConstraintElim runs fairly early, but that also means we are locked into that pipeline position, and that this may not generalize to other frontends. There are other weaknesses (e.g. the fact that this only works on pre-inc IV, even though post-inc is canonical), but support for those can be added. The dependence on the order of exits seems like a fundamental limitation that is hard to avoid.

optimizeLoopExits() in IndVarSimplify is normally the transform for eliminating such exits. That one can handle exits in any order, and I does eliminate such checks in many other cases. What prevents it from optimizing this particular case? Is that a fundamental limitation of optimizeLoopExits(), or something that can be fixed? Is there some other reason we should be doing this in ConstraintElim rather than IndVars (or other SCEV-based transform)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152730



More information about the llvm-commits mailing list