[llvm] [SLP] Initial vectorization of non-power-of-2 ops. (PR #77790)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 5 11:50:00 PDT 2024
================
@@ -14798,14 +14843,23 @@ bool SLPVectorizerPass::vectorizeStores(ArrayRef<StoreInst *> Stores,
continue;
}
+ std::optional<unsigned> NonPowerOf2VF;
+ if (VectorizeNonPowerOf2) {
+ // First try vectorizing with a non-power-of-2 VF. At the moment, only
+ // consider cases where VF + 1 is a power-of-2, i.e. almost all vector
+ // lanes are used.
+ unsigned CandVF = Operands.size();
+ if (isPowerOf2_32(CandVF + 1) && CandVF <= MaxVF) {
+ NonPowerOf2VF = CandVF;
+ }
+ }
+
unsigned Sz = 1 + Log2_32(MaxVF) - Log2_32(MinVF);
- SmallVector<unsigned> CandidateVFs(Sz);
- // FIXME: Is division-by-2 the correct step? Should we assert that the
- // register size is a power-of-2?
- unsigned Size = MaxVF;
- for_each(CandidateVFs, [&](unsigned &VF) {
- VF = Size;
- Size /= 2;
+ SmallVector<unsigned> CandidateVFs(Sz + bool(NonPowerOf2VF));
----------------
fhahn wrote:
Done, thanks!
https://github.com/llvm/llvm-project/pull/77790
More information about the llvm-commits
mailing list