Implement PPC::isSplatShuffleMask and PPC::getVSPLTImmediate.
authorChris Lattner <sabre@nondot.org>
Mon, 20 Mar 2006 06:37:44 +0000 (06:37 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 20 Mar 2006 06:37:44 +0000 (06:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26897 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCISelLowering.cpp

index 3eb5e2dacead83b76b2484673a86d6056752c800..eeed0dfe742ae017c50183f826fe91f7448098f4 100644 (file)
@@ -245,14 +245,25 @@ static bool isFloatingPointZero(SDOperand Op) {
 /// VSPLTB/VSPLTH/VSPLTW.
 bool PPC::isSplatShuffleMask(SDNode *N) {
   assert(N->getOpcode() == ISD::BUILD_VECTOR);
-  return false;
+  // This is a splat operation if each element of the permute is the same, and
+  // if the value doesn't reference the second vector.
+  SDOperand Elt = N->getOperand(0);
+  assert(isa<ConstantSDNode>(Elt) && "Invalid VECTOR_SHUFFLE mask!");
+  for (unsigned i = 1, e = N->getNumOperands(); i != e; ++i) {
+    assert(isa<ConstantSDNode>(N->getOperand(i)) &&
+           "Invalid VECTOR_SHUFFLE mask!");
+    if (N->getOperand(i) != Elt) return false;
+  }
+
+  // Make sure it is a splat of the first vector operand.
+  return cast<ConstantSDNode>(Elt)->getValue() < N->getNumOperands();
 }
 
 /// getVSPLTImmediate - Return the appropriate VSPLT* immediate to splat the
 /// specified isSplatShuffleMask VECTOR_SHUFFLE mask.
 unsigned PPC::getVSPLTImmediate(SDNode *N) {
   assert(isSplatShuffleMask(N));
-  return 0;
+  return cast<ConstantSDNode>(N)->getValue();
 }