[all-commits] [llvm/llvm-project] b8c81f: [LoopUnswitch] Add shortcut if unswitched path is ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Mon Feb 1 01:04:16 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b8c81fa5c7f77a7a1267e42ddbbc9bffb10b0817
      https://github.com/llvm/llvm-project/commit/b8c81fa5c7f77a7a1267e42ddbbc9bffb10b0817
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2021-02-01 (Mon, 01 Feb 2021)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
    M llvm/test/Transforms/LoopUnswitch/partial-unswitch-cost.ll

  Log Message:
  -----------
  [LoopUnswitch] Add shortcut if unswitched path is a no-op.

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, 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.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D95468




More information about the All-commits mailing list