[PATCH] D79421: [CodeGen] Fix FoldConstantVectorArithmetic for scalable vectors

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 08:03:35 PDT 2020


david-arm created this revision.
david-arm added reviewers: fpetrogalli, sdesmalen, ctetreau.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

For now I have changed FoldConstantVectorArithmetic to return early
if we encounter a scalable vector, since the subsequent code assumes
you can perform lane-wise constant folds. However, in future work we
should be able to extend this to look at splats of a constant value
and fold those if possible.

The code path I have changed is defended by this existing test:

  CodeGen/AArch64/sve-int-arith.ll


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79421

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5020,6 +5020,12 @@
   if (!VT.isVector())
     return SDValue();
 
+  // TODO: All the folds below are performed lane-by-lane and assume a fixed
+  // vector width, however we should be able to do constant folds involving
+  // splat vector nodes too.
+  if (VT.isScalableVector())
+    return SDValue();
+
   unsigned NumElts = VT.getVectorNumElements();
 
   auto IsScalarOrSameVectorSize = [&](const SDValue &Op) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79421.262112.patch
Type: text/x-patch
Size: 646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200505/87b9cec9/attachment-0001.bin>


More information about the llvm-commits mailing list