Skip to content

Commit d9b836d

Browse files
nikiczmodem
authored andcommitted
[InstCombine] Support disabling expensive combines in opt
Currently, there is no way to disable ExpensiveCombines when doing a standalone opt -instcombine run, as that's the default, and the opt option can currently only be used to force enable, not to force disable. The only way to disable expensive combines is via -O1 or -O2, but that of course also runs the rest of the kitchen sink... This patch allows using opt -instcombine -expensive-combines=0 to run InstCombine without ExpensiveCombines. Differential Revision: https://reviews.llvm.org/D72861 (cherry picked from commit 2ca092f)
1 parent d65ef43 commit d9b836d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3568,7 +3568,8 @@ static bool combineInstructionsOverFunction(
35683568
ProfileSummaryInfo *PSI, bool ExpensiveCombines, unsigned MaxIterations,
35693569
LoopInfo *LI) {
35703570
auto &DL = F.getParent()->getDataLayout();
3571-
ExpensiveCombines |= EnableExpensiveCombines;
3571+
if (EnableExpensiveCombines.getNumOccurrences())
3572+
ExpensiveCombines = EnableExpensiveCombines;
35723573
MaxIterations = std::min(MaxIterations, LimitMaxIterations.getValue());
35733574

35743575
/// Builder - This is an IRBuilder that automatically inserts new

llvm/test/Transforms/InstCombine/expensive-combines.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ define void @test() {
1616
;
1717
; EXPENSIVE-OFF-LABEL: @test(
1818
; EXPENSIVE-OFF-NEXT: [[CALL:%.*]] = call i32 @passthru(i32 0)
19-
; EXPENSIVE-OFF-NEXT: call void @sink(i32 0)
19+
; EXPENSIVE-OFF-NEXT: call void @sink(i32 [[CALL]])
2020
; EXPENSIVE-OFF-NEXT: ret void
2121
;
2222
%call = call i32 @passthru(i32 0)

0 commit comments

Comments
 (0)