[llvm] Provide intrinsics for speculative loads (PR #179642)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 13 03:29:45 PDT 2026
================
@@ -6854,6 +6854,70 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
&Call);
break;
}
+ case Intrinsic::speculative_load: {
+ Type *LoadTy = Call.getType();
+ TypeSize Size = DL.getTypeStoreSize(LoadTy);
+ // For scalable vectors, check the known minimum size is a power of 2.
+ Check(Size.getKnownMinValue() > 0 && isPowerOf2_64(Size.getKnownMinValue()),
+ "llvm.speculative.load type must have a power-of-2 size", &Call);
+
+ unsigned NumArgs = Call.arg_size();
+ Check(NumArgs >= 3, "llvm.speculative.load requires at least 3 arguments",
+ &Call);
+
+ Value *PayloadArg = Call.getArgOperand(2);
+ if (PayloadArg->getType()->isIntegerTy(64)) {
+ // Direct form: (ptr, i1 from_end, i64 num_accessible_bytes)
+ Check(NumArgs == 3,
+ "llvm.speculative.load direct form has too many arguments", &Call);
+ if (auto *CI = dyn_cast<ConstantInt>(PayloadArg)) {
----------------
nikic wrote:
Can't verify non-immarg constants, it will introduce errors due to constant propagation.
https://github.com/llvm/llvm-project/pull/179642
More information about the llvm-commits
mailing list