[PATCH] D95468: [LoopUnswitch] Add shortcut if unswitched path is a no-op.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 26 12:12:01 PST 2021


fhahn created this revision.
fhahn added reviewers: jonpa, jdoerfert, reames, efriedma.
Herald added a subscriber: hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

If we determine that the invariant path through the loop has no effects,
we can directly branch to the exit block, instead to unswitching first.

Besides avoiding some extra work (unswitching first, then deleting the
loop again) this allows to be more aggressive than regular unswitching
with respect to cost-modeling. This approach should always be be
desirable.

This is similar in spirit to D93734 <https://reviews.llvm.org/D93734>, just that it uses the previously
added checks for loop-unswitching.

I tried to add the required no-op checks from scratch, as we only check
a subset of the loop. There is potential to unify the checks with
LoopDeletion, at the cost of adding a predicate whether a block should
be considered.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95468

Files:
  llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
  llvm/test/Transforms/LoopUnswitch/partial-unswitch-cost.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95468.319376.patch
Type: text/x-patch
Size: 16101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210126/006e0e79/attachment.bin>


More information about the llvm-commits mailing list