[llvm] [SLP][REVEC] Make getAltInstrMask and getGatherCost vectorize vector instructions. (PR #99461)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 04:46:29 PDT 2024


================
@@ -1032,10 +1032,13 @@ static void fixupOrderingIndices(MutableArrayRef<unsigned> Order) {
 /// Opcode1.
 SmallBitVector getAltInstrMask(ArrayRef<Value *> VL, unsigned Opcode0,
                                unsigned Opcode1) {
-  SmallBitVector OpcodeMask(VL.size(), false);
+  Type *ScalarTy = VL[0]->getType();
+  unsigned ScalarTyNumElements = getNumElements(ScalarTy);
+  SmallBitVector OpcodeMask(VL.size() * ScalarTyNumElements, false);
   for (unsigned Lane : seq<unsigned>(VL.size()))
     if (cast<Instruction>(VL[Lane])->getOpcode() == Opcode1)
-      OpcodeMask.set(Lane);
+      for (unsigned I = 0; I != ScalarTyNumElements; ++I)
+        OpcodeMask.set(Lane * ScalarTyNumElements + I);
----------------
alexey-bataev wrote:

```suggestion
      OpcodeMask.set(Lane * ScalarTyNumElements,  Lane * ScalarTyNumElements + ScalarTyNumElements);
```


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


More information about the llvm-commits mailing list