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

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 8 18:29:21 PDT 2023


caojoshua created this revision.
Herald added subscribers: javed.absar, zzheng, hiraditya.
Herald added a project: All.
caojoshua added reviewers: nikic, mkazantsev, reames.
Herald added a subscriber: StephenFan.
caojoshua updated this revision to Diff 511942.
caojoshua added a comment.
caojoshua published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

code cleanup


caojoshua added a comment.

We could technically find the largest multiple under the threshold that is not limited to powers of 2, but that is much more computation heavy and the benefits are questionable.

An interesting case where this is beneficial is in the LoopUnroll test. Before, we returned a trip multiple of 1, but this change returns a trip multiple of 2^32. Since its trying to unroll by a factor of 8, and 2^32 is divisible by eight, LoopUnroll knows that the loop epilogue is not required anymore.


SCEV determines that loops with trip count >=2^32 have a trip multiple
of 1 to guard against huge multiples. This patch stregthens this to
instead find the greatest power of 2 divisor that is less than the
threshold.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147868

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/huge-trip-multiple.ll
  llvm/test/Transforms/LoopUnroll/X86/mmx.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147868.511942.patch
Type: text/x-patch
Size: 7511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230409/dd65b3e6/attachment.bin>


More information about the llvm-commits mailing list