[PATCH] D147868: [SCEV] Strengthen huge constant trip multiples.

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 10 00:12:28 PDT 2023


caojoshua marked an inline comment as done.
caojoshua added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8248
+  // Guard against huge trip multiples (this requires checking for zero to
+  // handle the case where the trip count == -1 and the addition wraps).
   assert(Result && "SCEVConstant expected to have non-null ConstantInt");
----------------
efriedma wrote:
> If the Result is zero, countTrailingZeros() will return the bitwidth of the integer, I think, which doesn't match the comment.
> 
> I don't think the wrapping thing can actually happen since D110587 was merged, though, so we shouldn't see a trip count of zero.  So maybe update the comment while you're here.
> 
> (Maybe it's theoretically possible that some combination of folding could end up folding a poison trip count to zero.  In that case, though, it wouldn't really matter what multiple we return.)
You're right, TripCount should never be zero. I added an assertion for this and removed that section of the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147868



More information about the llvm-commits mailing list