[PATCH] D99719: [SLP] Better estimate cost of no-op extracts on target vectors.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 1 06:48:19 PDT 2021


ABataev added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3495-3498
+        unsigned MaxVecRegSize = getMaxVecRegSize();
+        unsigned EltSize = getVectorElementSize(VL[0]);
+        unsigned EltsPerVector = MaxVecRegSize / EltSize;
+        unsigned Idx = 0;
----------------
I think it is better to use `TLI->getTypeLegalizationCost(DL, cast<ExtractElementInst>(V)->getVectorOperandType());` to get the real machine vector type and the number of splits.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3515
+            AllConsecutive &=
+                PrevExtract->getOperand(0) == CurrentExtract->getOperand(0) &&
+                !AllUsersVectorized && PrevIdx + 1 == IO->getZExtValue() &&
----------------
`->getVectorOperand()` instead of `getOperand(0)`


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3535
+                Cost -= TTI->getVectorInstrCost(Instruction::ExtractElement,
+                                                VecTy, I);
+            }
----------------
I think you need to use the real extract indices here to be more correct, i.e.
```
for (unsigned I = Idx - EltsPerVector; I <= Idx; ++I)
Cost -= TTI->getVectorInstrCost(Instruction::ExtractElement,
                                                cast<ExtractElementInst>(VL[I])->getVectorOperandType(), *getExtractIndex(cast<Instruction>(VL[I])));
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99719/new/

https://reviews.llvm.org/D99719



More information about the llvm-commits mailing list