[PATCH] D101722: [SCEV] Don't require ControlsExit for gt/lt NoWrap

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 5 12:54:01 PDT 2021


reames added a comment.

I think this code may simply be too strict in general.  Let me explain my reasoning.

For each exit, we are only computing the exit count for the loop *if and only if* that exit is taken.  The fact that the loop might exit through another exit previously is handled by the fact we take the min of all exit counts.  We have an invariant in this code that all cached exit counts are for exits which dominate the backedge (and thus are guaranteed not to be bypassed).

If we have an exit which depends on UB which dominates the backedge, we know that said loop either a) returns through another exit before that one on the final iteration, b) returns through another exit on a previous iteration, or b) is undefined.

I think the single exit check can be replaced with a check for whether the current exit dominates the backedge.  One point of remaining confusion is why the check for abnormal exits at all, SCEVs exit counts only describe exits through explicit exits.  This seems to have been added in c7f69b92, which I think may simply be wrong?

I mention this mostly because I didn't follow your reasoning about equality vs inequalities.  :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101722



More information about the llvm-commits mailing list