[llvm] [LICM] Add option `-licm-allow-speculation` (PR #176648)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 18 05:47:45 PST 2026
https://github.com/dianqk created https://github.com/llvm/llvm-project/pull/176648
The option is used to check whether to register pressure from speculation instructions without modifying LLVM source code.
>From a607e5e9e24e1695483412212649938af9356487 Mon Sep 17 00:00:00 2001
From: dianqk <dianqk at dianqk.net>
Date: Sun, 18 Jan 2026 21:38:42 +0800
Subject: [PATCH] [LICM] Add option `-licm-allow-speculation`
---
llvm/lib/Transforms/Scalar/LICM.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 02ece8bdf31db..fa914caa5d038 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -146,6 +146,10 @@ static cl::opt<unsigned> IntAssociationUpperLimit(
"Set upper limit for the number of transformations performed "
"during a single round of hoisting the reassociated expressions."));
+static cl::opt<bool>
+ AllowSpeculationOpt("licm-allow-speculation", cl::Hidden, cl::init(true),
+ cl::desc("Allow speculation in LICM pass"));
+
// Experimental option to allow imprecision in LICM in pathological cases, in
// exchange for faster compile. This is to be removed if MemorySSA starts to
// address the same issue. LICM calls MemorySSAWalker's
@@ -1732,7 +1736,7 @@ static bool isSafeToExecuteUnconditionally(
const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo,
OptimizationRemarkEmitter *ORE, const Instruction *CtxI,
AssumptionCache *AC, bool AllowSpeculation) {
- if (AllowSpeculation &&
+ if (AllowSpeculationOpt && AllowSpeculation &&
isSafeToSpeculativelyExecute(&Inst, CtxI, AC, DT, TLI))
return true;
More information about the llvm-commits
mailing list