[llvm-branch-commits] [llvm] d9b836d - [InstCombine] Support disabling expensive combines in opt
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 10 02:32:42 PST 2020
Author: Nikita Popov
Date: 2020-02-10T11:28:33+01:00
New Revision: d9b836dc6f78c5fb1f1b425943e1335b235b32d8
URL: https://github.com/llvm/llvm-project/commit/d9b836dc6f78c5fb1f1b425943e1335b235b32d8
DIFF: https://github.com/llvm/llvm-project/commit/d9b836dc6f78c5fb1f1b425943e1335b235b32d8.diff
LOG: [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 2ca092f3209579fde7a38ade511c1bbcef213c36)
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/expensive-combines.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 801c09a317a7..bf32996d96e2 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3568,7 +3568,8 @@ static bool combineInstructionsOverFunction(
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
index 96a45b05cfb5..28acb773bfd5 100644
--- a/llvm/test/Transforms/InstCombine/expensive-combines.ll
+++ b/llvm/test/Transforms/InstCombine/expensive-combines.ll
@@ -16,7 +16,7 @@ define void @test() {
;
; 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)
More information about the llvm-branch-commits
mailing list