[PATCH] D72861: [InstCombine] Support disabling expensive combines in opt

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 12:08:56 PST 2020


nikic created this revision.
nikic added reviewers: spatel, lebedev.ri.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

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...

Noticed while looking into https://bugs.llvm.org/show_bug.cgi?id=44541. Another issue I noticed is that NewPM always enables expensive combines, whiles legacy PM on does so at `-O3`. Anyone know whether that was an intentional choice or an oversight?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72861

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/expensive-combines.ll


Index: llvm/test/Transforms/InstCombine/expensive-combines.ll
===================================================================
--- llvm/test/Transforms/InstCombine/expensive-combines.ll
+++ 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)
Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72861.238567.patch
Type: text/x-patch
Size: 1265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200116/75f4b465/attachment-0001.bin>


More information about the llvm-commits mailing list