[PATCH] D135667: [SCEV] Replace assert with returning CouldNotComp in computeMaxBECountForLT.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 06:55:03 PDT 2022


fhahn created this revision.
fhahn added reviewers: reames, mkazantsev, nikic, efriedma.
Herald added subscribers: javed.absar, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: LLVM.

This patch removes the bail out for signed predicates and non-positive
strides in howManyLessThans and updates computeMaxBECountForLT to return
SCEVCouldNotCompute for signed predicates with negative strides.

AFAICT bail-out was only added because computeMaxBECountForLT may not
handle negative signed strides correctly. Instead of not calling
computeMaxBECountForLT at all because we bail out earlier, we can
instead return SCEVCouldNotCompute in computeMaxBECountForLT.

The max backedge taken count will be computed as the max value of the
symbolic backedge taken count.

This improves precision in cases where we can compute symbolic backedge
taken counts and also fixes a crash.

Fixes #57818.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135667

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
  llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135667.466798.patch
Type: text/x-patch
Size: 9285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221011/4d0334f2/attachment.bin>


More information about the llvm-commits mailing list