HomePhabricator

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

Authored by lebedev.ri on Mar 23 2021, 8:22 AM.

Description

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

Details

Committed
lebedev.riMar 23 2021, 8:30 AM
Parents
rGa866f72eb2b5: [NFC][SimplifyCFG] 'Fold branch to common dest': add test for cost…
Branches
Unknown
Tags
Unknown