[all-commits] [llvm/llvm-project] 65db7d: [NFC][SimplifyCFG] Add statistic to `FoldBranchToC...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Thu Nov 26 11:52:17 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 65db7d38e0502db7b5753e974e630fd1663cb65b
      https://github.com/llvm/llvm-project/commit/65db7d38e0502db7b5753e974e630fd1663cb65b
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-11-26 (Thu, 26 Nov 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp

  Log Message:
  -----------
  [NFC][SimplifyCFG] Add statistic to `FoldBranchToCommonDest()` fold


  Commit: 394b4fdb41542f695ed478c33275c54afb081efe
      https://github.com/llvm/llvm-project/commit/394b4fdb41542f695ed478c33275c54afb081efe
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-11-26 (Thu, 26 Nov 2020)

  Changed paths:
    A llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

  Log Message:
  -----------
  [NFC][SimplifyCFG] Add test coverage for FoldBranchToCommonDest xform with live-out bonus instuctions

The uses of the bonus instructions should not be preventing the transformation.


  Commit: 2245fb8aaa1c1f85f53f7b19a1ee3ac69b1a1dfe
      https://github.com/llvm/llvm-project/commit/2245fb8aaa1c1f85f53f7b19a1ee3ac69b1a1dfe
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-11-26 (Thu, 26 Nov 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/LoopUnroll/peel-loop-inner.ll
    M llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

  Log Message:
  -----------
  [SimplifyCFG] FoldBranchToCommonDest: lift use-restriction on bonus instructions

1. It doesn't make sense to enforce that the bonus instruction
   is only used once in it's basic block. What matters is
   whether those user instructions fit within our budget, sure,
   but that is another question.
2. It doesn't make sense to enforce that said bonus instructions
   are only used within their basic block. Perhaps the branch
   condition isn't using the value computed by said bonus instruction,
   and said bonus instruction is simply being calculated
   to be used in successors?

So iff we can clone bonus instructions, to lift these restrictions,
we just need to carefully update their external uses
to use the new cloned instructions.

Notably, this transform (even without this change) appears to be
poison-unsafe as per alive2, but is otherwise (including the patch) legal.

We don't introduce any new PHI nodes, but only "move" the instructions
around, i'm not really seeing much potential for extra cost modelling
for the transform, especially since now we allow at most one such
bonus instruction by default.

This causes the fold to fire +11.4% more (13216 -> 14725)
as of vanilla llvm test-suite + RawSpeed.

The motivational pattern is IEEE-754-2008 Binary16->Binary32
extension code:
https://github.com/darktable-org/rawspeed/blob/ca57d77fb2ba81f21fc712cfac26e54f46406473/src/librawspeed/common/FloatingPoint.h#L115-L120
^ that should be a switch, but it is not now: https://godbolt.org/z/bvja5v
That being said, even thought this seemed like this would fix it: https://godbolt.org/z/xGq3TM
apparently that fold is happening somewhere else afterall,
so something else also has a similar 'artificial' restriction.


Compare: https://github.com/llvm/llvm-project/compare/433d0a30c6e6...2245fb8aaa1c


More information about the All-commits mailing list