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

Chris Lattner clattner at apple.com
Sat Feb 28 18:33:55 PST 2009


On Feb 28, 2009, at 5:13 PM, Bob Wilson wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=65747&view=rev
> Log:
> Combine PPC's GetConstantBuildVectorBits and isConstantSplat  
> functions to a new
> method in a BuildVectorSDNode "pseudo-class".

Very nice Bob!

> +/// BuildVectorSDNode - A "pseudo-class" with methods for operating  
> on
> +/// BUILD_VECTORs.
> +class BuildVectorSDNode : public SDNode {
> +public:
> +  /// isConstantSplat - check if this is a constant splat, and if  
> so, return
> +  /// the splat element value in SplatBits.  Any undefined bits in  
> that value
> +  /// are set to zero, and the corresponding bits in the SplatUndef  
> mask are
> +  /// set.  The SplatSize value is set to the splat element size in  
> bytes.
> +  /// HasAnyUndefs is set to true if any bits in the vector are  
> undefined.
> +  bool isConstantSplat(unsigned &SplatBits, unsigned &SplatUndef,
> +                       unsigned &SplatSize, bool &HasAnyUndefs);

This should indicate what happens with vectors that have more than 32  
elements (which is #bits in SplatUndef etc).  Should this always  
return false?  What happens when the element is greater than 32-bits,  
e.g. <2 x i64> ?

Perhaps it would be best to change the interface to take APInts by ref.

> +// 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.
> +bool BuildVectorSDNode::isConstantSplat(unsigned &SplatBits,
> +                                        unsigned &SplatUndef,
> +                                        unsigned &SplatSize,
> +                                        bool &HasAnyUndefs) {
> +  uint64_t Bits128[2];
> +  uint64_t Undef128[2];

Ok, this is really specific to 128-bit vectors.  Do you plan to  
generalize this?

-Chris



More information about the llvm-commits mailing list