[llvm] [ScalarizeMaskedMemIntr] Optimize splat non-constant masks (PR #104537)

Giuseppe Rossini via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 16 03:59:10 PDT 2024


================
@@ -188,8 +191,39 @@ static void scalarizeMaskedLoad(const DataLayout &DL, CallInst *CI,
     return;
   }
 
+  // Optimize the case where the "masked load" is a predicated load - that is,
+  // where the mask is the splat of a non-constant scalar boolean. In that case,
+  // use that splated value as the guard on a conditional vector load.
+  if (isSplatValue(Mask, /*Index=*/0)) {
+    Value *Predicate = Builder.CreateExtractElement(Mask, uint64_t(0ull),
----------------
giuseros wrote:

Could you add a debug assert so that I can verify that this behavior worked without inspecting asm/ir ?

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


More information about the llvm-commits mailing list