[PATCH] D44676: [SCEV] Make exact taken count calculation more optimistic

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 3 01:59:41 PDT 2018


mkazantsev added inline comments.


================
Comment at: llvm/trunk/lib/Analysis/ScalarEvolution.cpp:6675
     assert(ENT.ExactNotTaken != SE->getCouldNotCompute() && "bad exit SCEV");
+    assert(SE->DT.dominates(ENT.ExitingBlock, Latch) &&
+           "We should only have known counts for exits that dominate latch!");
----------------
Actually I start thinking that this may be an over-conservative assert. Imagine the situation:
  do { // Loop 1
    do { // Loop 2
       if (invariant_cond) exit
     } while (...)
  } while(...)

If we unswitch Loop 2 by invariant condition, we end up with something like
  do { // Loop 1
    if (invariant_cond) {
      do { // Loop 2
       } while (...)
     } else {
      do { // Loop 2 copy
       } while (...)
     }
  } while(...)
Exits in copies of loop2 no longer dominate the latch of loop1. I didn't comprehend it from the very beginning, but this may be an issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D44676





More information about the llvm-commits mailing list