[llvm] [LICM] Improve hoisting of calls marked with invariant_load metadata (PR #193678)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 04:01:02 PDT 2026


================
@@ -7305,6 +7305,9 @@ bool llvm::isSafeToSpeculativelyExecuteWithOpcode(
       return false;
     const Function *Callee = CI->getCalledFunction();
 
+    // Assume we can always speculate invariant loads.
----------------
nikic wrote:

>From a quick skim it sounds like the concern is about the fact that call-site speculatable effectively affects program semantics even in dead code? That's true ... but is equally true for `!invariant.load`, right? At least as currently defined, as it's not saying it's invariant "from this point onwards", but "anywhere it is dereferenceable". (Dunno to what degree we rely on that distinction.)

https://github.com/llvm/llvm-project/pull/193678


More information about the llvm-commits mailing list