[PATCH] D113578: [SCEV] Apply loop guards when computing max BTC for arbitrary steps.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 04:29:59 PST 2021


fhahn marked 2 inline comments as done.
fhahn added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:9670
+    assert(MaxWithGuards.ule(getUnsignedRangeMax(E)) &&
+           "applying loop guards unexpectedly pessimized max count");
+    M = getConstant(MaxWithGuards);
----------------
mkazantsev wrote:
> nikic wrote:
> > Same as in other cases, this assertions likely doesn't always hold.
> Isn't breach of this is a bug we want to fix?
> Same as in other cases, this assertions likely doesn't always hold.

Yeah, turns out I was a bit too optimistic. I didn't hit the assertion when building a larger number of projects, but I managed to construct a crashing test from other existing problematic tests. I added the test in 69c1cbe20f5d and turned the  assertion into a select of the minimum. 

I am also looking into weeding out the cases where applying the guard info pessimizes results. Unfortunately there are some cases where it pessimizes the range even if we only allow compares with constants. I'm still digging into the details, but it might be a case where the original range is not correct. I'm planning on sharing more on that soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113578



More information about the llvm-commits mailing list