[ConstraintElim] Move after first instcombine run.
authorFlorian Hahn <flo@fhahn.com>
Tue, 3 Jan 2023 13:25:00 +0000 (13:25 +0000)
committerFlorian Hahn <flo@fhahn.com>
Tue, 3 Jan 2023 13:25:00 +0000 (13:25 +0000)
Running ConstraintEliminiation after the first InstCombine run results
in slightly more simplifications on average.

There are is a tiny number of regressions, mostly due to CVP eliminating
a condition that ConstraintElimination would use, but in most cases
there's a slight improvement or no change.

Reviewed By: nikic

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

llvm/lib/Passes/PassBuilderPipelines.cpp

index 6aae404..d546ab0 100644 (file)
@@ -492,9 +492,6 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
         SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
   }
 
-  if (EnableConstraintElimination)
-    FPM.addPass(ConstraintEliminationPass());
-
   // Speculative execution if the target has divergent branches; otherwise nop.
   FPM.addPass(SpeculativeExecutionPass(/* OnlyIfDivergentTarget =*/true));
 
@@ -508,6 +505,9 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
   if (Level == OptimizationLevel::O3)
     FPM.addPass(AggressiveInstCombinePass());
 
+  if (EnableConstraintElimination)
+    FPM.addPass(ConstraintEliminationPass());
+
   if (!Level.isOptimizingForSize())
     FPM.addPass(LibCallsShrinkWrapPass());