[PATCH] D105216: [ScalarEvolution] Fix overflow in computeBECount.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 13 11:23:04 PDT 2021


reames added a comment.

In D105216#2874703 <https://reviews.llvm.org/D105216#2874703>, @efriedma wrote:

> So we never want to use getUDivCeilSCEV if we're optimizing an expression by proving `RHS > Start - Stride`.  As I outline in the proof in this patch, in this case, we can show that the backedge-taken count is actually `((RHS - 1) - (Start - Stride)) /u Stride`, which is equivalent to the expression we would produce without this patch.

It's this last bit which is non-obvious from the patch.  You're using an entirely different formula for the BTC in this case, you should say so in the comments!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105216



More information about the llvm-commits mailing list