[llvm] [RFC][LV] Add support for speculative loads in loops that may fault (PR #151300)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 21:50:14 PDT 2025


================
@@ -7749,6 +7758,12 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
     Builder.insert(VectorPtr);
     Ptr = VectorPtr;
   }
+  if (Legal->getSpeculativeLoads().contains(I)) {
+    auto *Load = dyn_cast<LoadInst>(I);
+    return new VPWidenFFLoadRecipe(*Load, Ptr, Mask, VPIRMetadata(*Load, LVer),
----------------
lukel97 wrote:

Just making a note for later. I think it would be good to avoid having a dead `VPWidenFFLoadRecipe` when there's no non-EVL version of vp.load.ff. 

Can we instead just have one `VPWidenFFLoadRecipe` and here pass VF as the EVL argument? optimizeMaskToEVL can then set the EVL from the header mask later.

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


More information about the llvm-commits mailing list