[PATCH] D112262: [indvars] Rotate zext though icmp to reduce loop varying computation

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 21 12:31:38 PDT 2021


reames created this revision.
reames added reviewers: nikic, Florian, mkazantsev, lebedev.ri.
Herald added subscribers: bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

This change looks for cases where we can prove that an exit test of a loop can be performed in a narrower bitwidth, and that by doing so we can replace a loop-varying extend with a loop-invariant truncate.

The motivation here is that doing this unblocks the trip count analysis for narrow IVs involved in extended compare exit tests.  It also has the nice side effect of simply making the code faster, even if we gain no other benefit from the improved analysis ability.

I've noted a few places this could be extended, but I think this stands reasonable on it's own as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112262

Files:
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
  llvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112262.381361.patch
Type: text/x-patch
Size: 19526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211021/99111708/attachment.bin>


More information about the llvm-commits mailing list