[llvm-commits] [llvm] r65426 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp

Scott Michel scottm at aero.org
Tue Feb 24 19:12:50 PST 2009


Author: pingbak
Date: Tue Feb 24 21:12:50 2009
New Revision: 65426

URL: http://llvm.org/viewvc/llvm-project?rev=65426&view=rev
Log:
Remove all "cached" data from BuildVectorSDNode, preferring to retrieve
results via reference parameters.

This patch also appears to fix Evan's reported problem supplied as a
reduced bugpoint test case.

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=65426&r1=65425&r2=65426&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Tue Feb 24 21:12:50 2009
@@ -1933,13 +1933,6 @@
 /// encapsulate common BUILD_VECTOR code and operations such as constant splat
 /// testing.
 class BuildVectorSDNode : public SDNode {
-  //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
-  // Constant splat state:
-  //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
-  //! We've computed the splat already?
-  bool computedSplat;
-  //! It is a splat?
-  bool isSplatVector;
   //! Splat has undefined bits in it
   bool hasUndefSplatBitsFlag;
   //! The splat value
@@ -1959,36 +1952,25 @@
 public:
   //! Constant splat predicate.
   /*!
-   Determine if this ISD::BUILD_VECTOR is a constant splat. The results are
-   cached to prevent recomputation.
-
-   @param MinSplatBits: minimum number of bits in the constant splat, defaults
+   Determine if this ISD::BUILD_VECTOR is a constant splat. This method
+   returns information about the splat in \a hasUndefSplatBitsFlag,
+   \a SplatBits, \a SplatUndef and \a SplatSize if the return value is
+   true.
+
+   \param[out] hasUndefSplatBitsFlag: true if the constant splat contains
+          any undefined bits in the splat.
+   \param[out] SplatBits: The constant splat value
+   \param[out] SplatUndef: The undefined bits in the splat value
+   \param[out] SplatSize: The size of the constant splat in bytes
+   \param MinSplatBits: minimum number of bits in the constant splat, defaults
           to 0 for 'don't care', but normally one of [8, 16, 32, 64].
-   @return true if the splat has the required minimum number of bits and the
+
+   \return true if the splat has the required minimum number of bits and the
            splat really is a constant splat (accounting for undef bits).
    */
-  bool isConstantSplat(int MinSplatBits = 0);
-
-  //! Get the splatbits
-  uint64_t getSplatBits() const {
-    assert(computedSplat && "BuildVectorSDNode: compute splat bits first!");
-    return SplatBits;
-  }
-
-  uint64_t getSplatUndef() const {
-    assert(computedSplat && "BuildVectorSDNode: compute splat bits first!");
-    return SplatUndef;
-  }
-
-  unsigned getSplatSize() const {
-    assert(computedSplat && "BuildVectorSDNode: compute splat bits first!");
-    return SplatSize;
-  }
-
-  bool hasAnyUndefBits() const {
-    assert(computedSplat && "BuildVectorSDNode: compute splat bits first!");
-    return hasUndefSplatBitsFlag;
-  }
+  bool isConstantSplat(bool &hasUndefSplatBitsFlag, uint64_t &SplatBits,
+                       uint64_t &SplatUndef, unsigned &SplatSize,
+		       int MinSplatBits = 0);
 
   static bool classof(const BuildVectorSDNode *) { return true; }
   static bool classof(const SDNode *N) {

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=65426&r1=65425&r2=65426&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Feb 24 21:12:50 2009
@@ -4856,27 +4856,25 @@
 
 BuildVectorSDNode::BuildVectorSDNode(MVT vecVT, DebugLoc dl,
 				     const SDValue *Elts, unsigned NumElts)
-  : SDNode(ISD::BUILD_VECTOR, dl, getSDVTList(vecVT), Elts, NumElts),
-    computedSplat(false), isSplatVector(false), hasUndefSplatBitsFlag(false),
-    SplatBits(0LL), SplatUndef(0LL), SplatSize(0)
+  : SDNode(ISD::BUILD_VECTOR, dl, getSDVTList(vecVT), Elts, NumElts)
 { }
 
-bool BuildVectorSDNode::isConstantSplat(int MinSplatBits)  {
+bool BuildVectorSDNode::isConstantSplat(bool &hasUndefSplatBitsFlag,
+                                        uint64_t &SplatBits,
+                                        uint64_t &SplatUndef,
+					unsigned &SplatSize,
+		                        int MinSplatBits) {
   unsigned int nOps = getNumOperands();
   assert(nOps > 0 && "isConstantSplat has 0-size build vector");
 
-  // Return early if we already know the answer:
-  if (computedSplat)
-    return isSplatVector;
+  // Assume that this isn't a constant splat.
+  bool isSplatVector = false;
 
   // The vector's used (non-undef) bits
   uint64_t VectorBits[2] = { 0, 0 };
   // The vector's undefined bits
   uint64_t UndefBits[2] = { 0, 0 };
 
-  // Assume that this isn't a constant splat.
-  isSplatVector = false;
-
   // Gather the constant and undefined bits
   unsigned EltBitSize = getOperand(0).getValueType().getSizeInBits();
   for (unsigned i = 0; i < nOps; ++i) {
@@ -4901,7 +4899,6 @@
 	EltBits = DoubleToBits(apf.convertToDouble());
     } else {
       // Nonconstant element -> not a splat.
-      computedSplat = true;
       return isSplatVector;
     }
 
@@ -4910,7 +4907,6 @@
 
   if ((VectorBits[0] & ~UndefBits[1]) != (VectorBits[1] & ~UndefBits[0])) {
     // Can't be a splat if two pieces don't match.
-    computedSplat = true;
     return isSplatVector;
   }
 
@@ -4954,7 +4950,6 @@
     isSplatVector = true;
   }
 
-  computedSplat = true;
   return isSplatVector;
 }
 

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=65426&r1=65425&r2=65426&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Tue Feb 24 21:12:50 2009
@@ -3171,16 +3171,16 @@
   BuildVectorSDNode *BVN = dyn_cast<BuildVectorSDNode>(Op.getNode());
   assert(BVN != 0 && "Expected a BuildVectorSDNode in LowerBUILD_VECTOR");
 
+  uint64_t SplatBits;
+  uint64_t SplatUndef;
+  unsigned SplatSize;
+  bool HasAnyUndefs;
+
   // If this is a splat (repetition) of a value across the whole vector, return
   // the smallest size that splats it.  For example, "0x01010101010101..." is a
   // splat of 0x01, 0x0101, and 0x01010101.  We return SplatBits = 0x01 and
   // SplatSize = 1 byte.
-  if (BVN->isConstantSplat()) {
-    uint64_t SplatBits = BVN->getSplatBits();
-    uint64_t SplatUndef = BVN->getSplatUndef();
-    unsigned SplatSize = BVN->getSplatSize();
-    bool HasAnyUndefs = BVN->hasAnyUndefBits();
-
+  if (BVN->isConstantSplat(HasAnyUndefs, SplatBits, SplatUndef, SplatSize)) {
     // First, handle single instruction cases.
 
     // All zeros?





More information about the llvm-commits mailing list