[llvm] f3c417f - [Passes] Add option for LoopVersioningLICM pass. (#67107)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 27 05:38:42 PDT 2023
Author: lcvon007
Date: 2023-09-27T07:38:37-05:00
New Revision: f3c417f341135ff357f2d454866d7d05262ebfca
URL: https://github.com/llvm/llvm-project/commit/f3c417f341135ff357f2d454866d7d05262ebfca
DIFF: https://github.com/llvm/llvm-project/commit/f3c417f341135ff357f2d454866d7d05262ebfca.diff
LOG: [Passes] Add option for LoopVersioningLICM pass. (#67107)
User only can use opt to test LoopVersioningLICM pass, and this PR add
the option back(deleted in https://reviews.llvm.org/D137915) so that
it's easy for verifying if it is useful for some benchmarks.
Added:
Modified:
llvm/lib/Passes/PassBuilderPipelines.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 2cc7d43cfcc71fa..78e0e6353056343 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -105,6 +105,7 @@
#include "llvm/Transforms/Scalar/LoopSink.h"
#include "llvm/Transforms/Scalar/LoopUnrollAndJamPass.h"
#include "llvm/Transforms/Scalar/LoopUnrollPass.h"
+#include "llvm/Transforms/Scalar/LoopVersioningLICM.h"
#include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
#include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
@@ -271,6 +272,10 @@ static cl::opt<AttributorRunOption> AttributorRun(
clEnumValN(AttributorRunOption::NONE, "none",
"disable attributor runs")));
+static cl::opt<bool> UseLoopVersioningLICM(
+ "enable-loop-versioning-licm", cl::init(false), cl::Hidden,
+ cl::desc("Enable the experimental Loop Versioning LICM pass"));
+
cl::opt<bool> EnableMemProfContextDisambiguation(
"enable-memprof-context-disambiguation", cl::init(false), cl::Hidden,
cl::ZeroOrMore, cl::desc("Enable MemProf context disambiguation"));
@@ -1343,6 +1348,21 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
invokeOptimizerEarlyEPCallbacks(MPM, Level);
FunctionPassManager OptimizePM;
+ // Scheduling LoopVersioningLICM when inlining is over, because after that
+ // we may see more accurate aliasing. Reason to run this late is that too
+ // early versioning may prevent further inlining due to increase of code
+ // size. Other optimizations which runs later might get benefit of no-alias
+ // assumption in clone loop.
+ if (UseLoopVersioningLICM) {
+ OptimizePM.addPass(
+ createFunctionToLoopPassAdaptor(LoopVersioningLICMPass()));
+ // LoopVersioningLICM pass might increase new LICM opportunities.
+ OptimizePM.addPass(createFunctionToLoopPassAdaptor(
+ LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+ /*AllowSpeculation=*/true),
+ /*USeMemorySSA=*/true, /*UseBlockFrequencyInfo=*/false));
+ }
+
OptimizePM.addPass(Float2IntPass());
OptimizePM.addPass(LowerConstantIntrinsicsPass());
More information about the llvm-commits
mailing list