[llvm] [VPlan] Introduce recipes for VP loads and stores. (PR #87816)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 06:38:03 PDT 2024


================
@@ -9383,24 +9337,7 @@ void VPWidenLoadRecipe::execute(VPTransformState &State) {
         Mask = Builder.CreateVectorReverse(Mask, "reverse");
     }
 
-    // TODO: split this into several classes for better design.
-    if (State.EVL) {
-      assert(State.UF == 1 && "Expected only UF == 1 when vectorizing with "
-                              "explicit vector length.");
-      assert(cast<VPInstruction>(State.EVL)->getOpcode() ==
-                 VPInstruction::ExplicitVectorLength &&
-             "EVL must be VPInstruction::ExplicitVectorLength.");
-      Value *EVL = State.get(State.EVL, VPIteration(0, 0));
-      // If EVL is not nullptr, then EVL must be a valid value set during plan
-      // creation, possibly default value = whole vector register length. EVL
-      // is created only if TTI prefers predicated vectorization, thus if EVL
-      // is not nullptr it also implies preference for predicated
-      // vectorization.
-      // FIXME: Support reverse loading after vp_reverse is added.
-      NewLI = lowerLoadUsingVectorIntrinsics(
-          Builder, DataTy, State.get(getAddr(), Part, !CreateGather),
-          CreateGather, Mask, EVL, Alignment);
-    } else if (CreateGather) {
+    if (CreateGather) {
----------------
ayalz wrote:

```suggestion
    Value *Addr = State.get(getAddr(), Part, !CreateGather);
    if (CreateGather)
      NewLI = Builder.CreateMaskedGather(DataTy, Addr, Alignment, Mask,
                                       nullptr, "wide.masked.gather");
    else if (Mask)
      NewLI = Builder.CreateMaskedLoad(DataTy, Addr, Alignment, Mask,
                                       PoisonValue::get(DataTy),
                                       "wide.masked.load");
    else
      NewLI =
          Builder.CreateAlignedLoad(DataTy, Addr, Alignment, "wide.load");
    // Add metadata to the load, but setVectorValue to possibly reversed shuffle.
    State.addMetadata(NewLI, LI);
    if (Reverse)
      NewLI = Builder.CreateVectorReverse(NewLI, "reverse");
    State.set(this, NewLI, Part);
```
nit: could be simplified a bit, consistent with VPWidenVPLoadRecipe::execute()?

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


More information about the llvm-commits mailing list