[PATCH] D80537: [CodeGen] Fix SimplifyDemandedBits for scalable vectors

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 00:30:55 PDT 2020


david-arm updated this revision to Diff 268071.

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

https://reviews.llvm.org/D80537

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


Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -590,9 +590,12 @@
                                           unsigned Depth,
                                           bool AssumeSingleUse) const {
   EVT VT = Op.getValueType();
-  APInt DemandedElts = VT.isVector()
-                           ? APInt::getAllOnesValue(VT.getVectorNumElements())
-                           : APInt(1, 1);
+  APInt DemandedElts;
+  if (!VT.isScalableVector()) {
+    DemandedElts = VT.isVector()
+                       ? APInt::getAllOnesValue(VT.getVectorNumElements())
+                       : APInt(1, 1);
+  }
   return SimplifyDemandedBits(Op, DemandedBits, DemandedElts, Known, TLO, Depth,
                               AssumeSingleUse);
 }
@@ -820,6 +823,15 @@
   assert(Op.getScalarValueSizeInBits() == BitWidth &&
          "Mask size mismatches value type size!");
 
+  // Don't know anything.
+  Known = KnownBits(BitWidth);
+
+  // TODO: We can probably do more work on calculating the known bits and
+  // simplifying the operations for scalable vectors, but for now we just
+  // bail out.
+  if (Op.getValueType().isScalableVector())
+    return false;
+
   unsigned NumElts = OriginalDemandedElts.getBitWidth();
   assert((!Op.getValueType().isVector() ||
           NumElts == Op.getValueType().getVectorNumElements()) &&
@@ -830,9 +842,6 @@
   SDLoc dl(Op);
   auto &DL = TLO.DAG.getDataLayout();
 
-  // Don't know anything.
-  Known = KnownBits(BitWidth);
-
   // Undef operand.
   if (Op.isUndef())
     return false;
@@ -2222,11 +2231,16 @@
   APInt DemandedElts = OriginalDemandedElts;
   unsigned NumElts = DemandedElts.getBitWidth();
   assert(VT.isVector() && "Expected vector op");
-  assert(VT.getVectorNumElements() == NumElts &&
-         "Mask size mismatches value type element count!");
 
   KnownUndef = KnownZero = APInt::getNullValue(NumElts);
 
+  // TODO: For now we assume we know nothing about scalable vectors.
+  if (VT.isScalableVector())
+    return false;
+
+  assert(VT.getVectorNumElements() == NumElts &&
+         "Mask size mismatches value type element count!");
+
   // Undef operand.
   if (Op.isUndef()) {
     KnownUndef.setAllBits();
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -323,8 +323,11 @@
 
     bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits) {
       EVT VT = Op.getValueType();
-      unsigned NumElts = VT.isVector() ? VT.getVectorNumElements() : 1;
-      APInt DemandedElts = APInt::getAllOnesValue(NumElts);
+      APInt DemandedElts;
+      if (!VT.isScalableVector()) {
+        unsigned NumElts = VT.isVector() ? VT.getVectorNumElements() : 1;
+        DemandedElts = APInt::getAllOnesValue(NumElts);
+      }
       return SimplifyDemandedBits(Op, DemandedBits, DemandedElts);
     }
 
@@ -332,8 +335,10 @@
     /// if things it uses can be simplified as it only uses some of the
     /// elements. If so, return true.
     bool SimplifyDemandedVectorElts(SDValue Op) {
-      unsigned NumElts = Op.getValueType().getVectorNumElements();
-      APInt DemandedElts = APInt::getAllOnesValue(NumElts);
+      EVT VT = Op.getValueType();
+      APInt DemandedElts;
+      if (!VT.isScalableVector())
+        DemandedElts = APInt::getAllOnesValue(VT.getVectorNumElements());
       return SimplifyDemandedVectorElts(Op, DemandedElts);
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80537.268071.patch
Type: text/x-patch
Size: 3683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200603/60db5a25/attachment.bin>


More information about the llvm-commits mailing list