[PATCH] D118090: [ScalarEvolution] Handle <= and >= in non infinite loops

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 11:39:32 PST 2022


nikic added a comment.

Looks fine to me as well.



================
Comment at: llvm/include/llvm/Analysis/ScalarEvolution.h:1118
+                            const SCEV *&RHS, unsigned Depth = 0,
+                            bool ControlingFiniteLoop = false);
 
----------------
controlling


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8473
+                                 loopHasNoAbnormalExits(L) &&
+                                 loopIsFiniteByAssumption(L));
 
----------------
As the same check is repeated below, extract it into a variable?


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:10079
+  // 1) The range of the RHS does not include the (signed/unsigned) boundaries
+  // 2) The loop is finite, with this comparison controling the exit. Since the
+  // loop is finite, the bound cannot include the corresponding boundary
----------------
controlling 


================
Comment at: llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll:9
+
+define void @SLE(i32 %len) #1 {
+; CHECK-LABEL: 'SLE'
----------------
Please avoid attribute groups for test input, just put the `willreturn` directly here.

It would also be good to have a negative test that shows that the BECount is not inferred without willreturn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118090



More information about the llvm-commits mailing list