[PATCH] D50558: [MustExecute] Fix algorithmic bug in isGuaranteedToExecute. PR38514

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 16 01:00:10 PDT 2018


mkazantsev added inline comments.


================
Comment at: lib/Analysis/MustExecute.cpp:144
+        if (CurLoop->contains(Succ) ||
+            !CanProveNotTakenFirstIteration(Succ, DT, CurLoop))
+          return false;
----------------
reames wrote:
> There's a subtlety here that may justify a comment or code structure change.  Specifically, we don't know that this particular path (out of the possible paths we identified) is taken on the first iteration.  So why is discharging the condition on that particular path on the first iterations sufficient?  Answer: because it implies that either a) this path is taken on the first iteration (and thus the exit isn't) or be another path is taken by the first iteration and by the time we execute this path, the instruction of interest has already executed.
I tried to elaborate the comment, hope it expresses the same idea.


https://reviews.llvm.org/D50558





More information about the llvm-commits mailing list