diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-16 21:03:09 +0100 |
---|---|---|
committer | Hans Wennborg <hans@chromium.org> | 2020-02-10 11:28:33 +0100 |
commit | d9b836dc6f78c5fb1f1b425943e1335b235b32d8 (patch) | |
tree | 8a12fd3f0b6c5db243f24dfc152ce4783b4088f2 | |
parent | d65ef4321e6f244e68b191c84b8c76fb06662573 (diff) | |
download | bcm5719-llvm-d9b836dc6f78c5fb1f1b425943e1335b235b32d8.tar.gz bcm5719-llvm-d9b836dc6f78c5fb1f1b425943e1335b235b32d8.zip |
[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)
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/expensive-combines.ll | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 801c09a317a..bf32996d96e 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 96a45b05cfb..28acb773bfd 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) |