[PATCH] D105942: [SCEV] Fix unsound reasoning in howManyLessThans

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 13 14:56:25 PDT 2021


reames created this revision.
reames added reviewers: efriedma, fhahn, mkazantsev.
Herald added subscribers: bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

This is split from D105216 <https://reviews.llvm.org/D105216>, it handles only a subset of the cases in that patch.

Specifically, the issue being fixed is that the code incorrectly assumed that (Start-Stide) < End implied that the backedge was taken at least once.  This is not true when e.g. Start = 4, Stride = 2, and End = 3.  In this case, computing (3-4+2-1)/2 gives a horrendously wrong backedge taken count.  (The correct answer is that the backedge is never taken in this loop.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105942

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll
  llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
  llvm/test/Transforms/LoopReroll/nonconst_lb.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105942.358432.patch
Type: text/x-patch
Size: 6994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210713/050f6575/attachment.bin>


More information about the llvm-commits mailing list