[PATCH] D91059: [LoopVectorizer] NFCI: Calculate register usage based on TLI.getTypeLegalizationCost.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 01:08:14 PST 2020


sdesmalen added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5805
+  auto GetRegUsage = [&DL, &TTI=TTI](Type *Ty, ElementCount VF) {
     if (Ty->isTokenTy())
       return 0U;
----------------
The example provided by @uabelho fails for the load instruction (with a struct as result type) which is outside the loop body and isn't actually vectorized, so counting it as a vector register usage seems overly conservative. The `extractvalue` instruction in the body itself is vectorized, which is fine, since the extracted value  from the aggregate is a valid element type for a vector.

I suggest addressing the issue with:
```
-  if (Ty->isTokenTy())
+  if (Ty->isTokenTy() || !VectorType::isValidElementType(Ty))
      return 0U;
```

@uabelho @SjoerdMeijer are you happy with me re-landing the patch with the above change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91059



More information about the llvm-commits mailing list