In same manner as D82438, but in FoldTwoEntryPHINode, estimate the cost needed to insert the required selects and count this against the given budget. This will prevent some high cost conversions which IfConversion can later evaluate with better accuracy.
Details
Diff Detail
Event Timeline
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
98–102 | Looking at getCmpSelInstrCost(), right, only the select, so +1. |
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2018 | Well, the function takes BudgetRemaining by value, |
Rebased after moving the select cost and validation into a standalone function. I've kept the threshold at 4 as a default, because this causes far fewer codegen changes (X86, AArch64, Arm) than trying to adjust it to accommodate the select by bumping it up to 5.
You need to bump it by that new cmp+sel cost, so +2.