[all-commits] [llvm/llvm-project] a866f7: [NFC][SimplifyCFG] 'Fold branch to common dest': a...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Tue Mar 23 08:31:11 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a866f72eb2b52b46799e5c64b1b25df4f6fa91e7
      https://github.com/llvm/llvm-project/commit/a866f72eb2b52b46799e5c64b1b25df4f6fa91e7
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-03-23 (Tue, 23 Mar 2021)

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

  Log Message:
  -----------
  [NFC][SimplifyCFG] 'Fold branch to common dest': add test for cost overestimation

We should not count the cost of duplication into predecessors into which
we won't ultimately duplicate.


  Commit: b5822026dd727e23a6ed6270f9844e0021141607
      https://github.com/llvm/llvm-project/commit/b5822026dd727e23a6ed6270f9844e0021141607
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-03-23 (Tue, 23 Mar 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest-two-preds-cost.ll

  Log Message:
  -----------
  [SimplifyCFG] 'Fold branch to common dest': don't overestimate the cost

`FoldBranchToCommonDest()` has a certain budget (`-bonus-inst-threshold=`)
for bonus instruction duplication. And currently it calculates the cost
as-if it will actually duplicate into each predecessor.

But ignoring the budget, it won't always duplicate into each predecessor,
there are some correctness and profitability checks.
So when calculating the cost, we should first check into which blocks
will we *actually* duplicate, and only then use that block count
to do budgeting.


Compare: https://github.com/llvm/llvm-project/compare/af8056889ac9...b5822026dd72


More information about the All-commits mailing list