[PATCH] D112236: [RISCV] Expand scalable vector bswap. Fix crash for bitreverse.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 29 09:58:24 PDT 2021


craig.topper added a comment.

In D112236#3086805 <https://reviews.llvm.org/D112236#3086805>, @frasercrmck wrote:

> It's not very clear to me why we have different ways of expanding bswap. Why doesn't `VectorLegalizer::ExpandBSWAP` always call `TLI.expandBSWAP`, for instance?

ExpandBSWAP is using the shift+and+or expansion. VectorLegalizer::ExpandBSWAP tries to use a shuffle+bitcast which would only be legal for a vector. I suppose we could sink that into expandBSWAP with a .isFixedVector() check if that's what you're asking?



================
Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp:1099
+  // Scalable vectors can't use shuffle expansion.
+  if (VT.isScalableVector())
+    return TLI.expandBSWAP(Node, DAG);
----------------
I've made a bold assumption here that SHL/SRL/AND/OR are all LegalOrCustom for a scalable vector. Otherwise the unroll fallback would crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112236



More information about the llvm-commits mailing list