[PATCH] D79083: [CodeGen] Fix warnings due to SelectionDAG::getSplatSourceVector

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 06:24:07 PDT 2020


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

I have fixed several places in getSplatSourceVector and isSplatValue
to work correctly with scalable vectors. I added new support for
the ISD::SPLAT_VECTOR DAG node as one of the obvious cases we can
support with scalable vectors. In other places I have tried to do
the sensible thing, such as bail out for vector types we don't yet
support.

It's not possible to add test cases to cover these changes, since
they are currently only ever exercised on certain targets, e.g.
only X86 targets use the result of getSplatSourceVector. I've
assumed that X86 tests already exist to test these code paths for
fixed vectors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79083

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
@@ -2279,12 +2279,15 @@
 /// across all DemandedElts.
 bool SelectionDAG::isSplatValue(SDValue V, const APInt &DemandedElts,
                                 APInt &UndefElts) {
-  if (!DemandedElts)
-    return false; // No demanded elts, better to assume we don't know anything.
-
   EVT VT = V.getValueType();
   assert(VT.isVector() && "Vector type expected");
 
+  if (V.getOpcode() == ISD::SPLAT_VECTOR)
+    return true;
+
+  if (!DemandedElts || VT.isScalableVector())
+    return false; // No demanded elts, better to assume we don't know anything.
+
   unsigned NumElts = VT.getVectorNumElements();
   assert(NumElts == DemandedElts.getBitWidth() && "Vector size mismatch");
   UndefElts = APInt::getNullValue(NumElts);
@@ -2363,7 +2366,8 @@
 bool SelectionDAG::isSplatValue(SDValue V, bool AllowUndefs) {
   EVT VT = V.getValueType();
   assert(VT.isVector() && "Vector type expected");
-  unsigned NumElts = VT.getVectorNumElements();
+  // For now we don't support this with scalable vectors.
+  unsigned NumElts = VT.isScalableVector() ? 0 : VT.getVectorNumElements();
 
   APInt UndefElts;
   APInt DemandedElts = APInt::getAllOnesValue(NumElts);
@@ -2378,6 +2382,9 @@
   unsigned Opcode = V.getOpcode();
   switch (Opcode) {
   default: {
+    if (VT.isScalableVector())
+      return SDValue();
+
     APInt UndefElts;
     APInt DemandedElts = APInt::getAllOnesValue(VT.getVectorNumElements());
     if (isSplatValue(V, DemandedElts, UndefElts)) {
@@ -2391,6 +2398,8 @@
     }
     break;
   }
+  case ISD::SPLAT_VECTOR:
+    return V;
   case ISD::VECTOR_SHUFFLE: {
     // Check if this is a shuffle node doing a splat.
     // TODO - remove this and rely purely on SelectionDAG::isSplatValue,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79083.260895.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/d317d323/attachment.bin>


More information about the llvm-commits mailing list