[llvm] 7739f9f - [NewPM][Unswitch] Add option to disable -O3 non-trivial unswitching

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 11:12:16 PST 2021


Author: Arthur Eubanks
Date: 2021-02-01T11:11:59-08:00
New Revision: 7739f9ff974a2b301f5b036de55820b19a0df19a

URL: https://github.com/llvm/llvm-project/commit/7739f9ff974a2b301f5b036de55820b19a0df19a
DIFF: https://github.com/llvm/llvm-project/commit/7739f9ff974a2b301f5b036de55820b19a0df19a.diff

LOG: [NewPM][Unswitch] Add option to disable -O3 non-trivial unswitching

Some benchmarks regress with non-trivial unswitching, so add an option
to opt-out of performing non-trivial unswitching while investigating.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D95796

Added: 
    

Modified: 
    llvm/lib/Passes/PassBuilder.cpp
    llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index d4c4c6e01ef5..3af3ddf8ad43 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -274,6 +274,10 @@ static cl::opt<bool> PerformMandatoryInliningsFirst(
     cl::desc("Perform mandatory inlinings module-wide, before performing "
              "inlining."));
 
+static cl::opt<bool> EnableO3NonTrivialUnswitching(
+    "enable-npm-O3-nontrivial-unswitch", cl::init(true), cl::Hidden,
+    cl::ZeroOrMore, cl::desc("Enable non-trivial loop unswitching for -O3"));
+
 PipelineTuningOptions::PipelineTuningOptions() {
   LoopInterleaving = true;
   LoopVectorization = true;
@@ -726,7 +730,8 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
   // TODO: Investigate promotion cap for O1.
   LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
   LPM1.addPass(
-      SimpleLoopUnswitchPass(/* NonTrivial */ Level == OptimizationLevel::O3));
+      SimpleLoopUnswitchPass(/* NonTrivial */ Level == OptimizationLevel::O3 &&
+                             EnableO3NonTrivialUnswitching));
   LPM2.addPass(LoopIdiomRecognizePass());
   LPM2.addPass(IndVarSimplifyPass());
 

diff  --git a/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll b/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
index 186a65876911..7fd3b1d28d6d 100644
--- a/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
@@ -1,6 +1,7 @@
 ; RUN: opt < %s -S -passes="default<O1>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
 ; RUN: opt < %s -S -passes="default<O2>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
 ; RUN: opt < %s -S -passes="default<O3>" | FileCheck %s -check-prefixes=NONTRIVIAL,CHECK
+; RUN: opt < %s -S -passes="default<O3>" -enable-npm-O3-nontrivial-unswitch=0 | FileCheck %s -check-prefixes=TRIVIAL,CHECK
 ; RUN: opt < %s -S -passes="default<Os>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
 ; RUN: opt < %s -S -passes="default<Oz>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
 


        


More information about the llvm-commits mailing list