[PATCH] D25682: [LoopUnroll] Keep the loop test only on the first iteration of max-or-zero loops

silviu.baranga@arm.com via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 11:35:43 PDT 2016

sbaranga added inline comments.

Comment at: include/llvm/Analysis/ScalarEvolution.h:1394
+  /// returned value or zero.
+  const SCEV *getMaxBackedgeTakenCount(const Loop *L,
+                                       bool *MaxOrZero = nullptr);
I've only taken a brief look at this, but it might be a nicer interface to add a getMaxOrZeroBackedgeTakenCount. That way we don't have to add the MaxOrZero everywhere (same in other places) and would look more like the existing code.

Comment at: lib/Analysis/ScalarEvolution.cpp:5741
         MustExitMaxBECount = EL.MaxNotTaken;
-      else {
+        MustExitMaxOrZero = EL.MaxOrZero;
+      } else {
Does this work with more than one loop exit and with predicated loop exits?

I'm not certain this would hold if we have at least one loop exit that doesn't dominate the latch, given the very strict definition (the backedge gets taken exactly 0 or MaxNotTaken times).



More information about the llvm-commits mailing list