diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3568,7 +3568,8 @@ ProfileSummaryInfo *PSI, bool ExpensiveCombines, unsigned MaxIterations, LoopInfo *LI) { auto &DL = F.getParent()->getDataLayout(); - ExpensiveCombines |= EnableExpensiveCombines; + if (EnableExpensiveCombines.getNumOccurrences()) + ExpensiveCombines = EnableExpensiveCombines; MaxIterations = std::min(MaxIterations, LimitMaxIterations.getValue()); /// Builder - This is an IRBuilder that automatically inserts new diff --git a/llvm/test/Transforms/InstCombine/expensive-combines.ll b/llvm/test/Transforms/InstCombine/expensive-combines.ll --- a/llvm/test/Transforms/InstCombine/expensive-combines.ll +++ b/llvm/test/Transforms/InstCombine/expensive-combines.ll @@ -16,7 +16,7 @@ ; ; EXPENSIVE-OFF-LABEL: @test( ; EXPENSIVE-OFF-NEXT: [[CALL:%.*]] = call i32 @passthru(i32 0) -; EXPENSIVE-OFF-NEXT: call void @sink(i32 0) +; EXPENSIVE-OFF-NEXT: call void @sink(i32 [[CALL]]) ; EXPENSIVE-OFF-NEXT: ret void ; %call = call i32 @passthru(i32 0)