mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-05 11:19:41 +00:00
isSplatMask() bug: first element can be an undef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
89a1b380a4
commit
94fe5eb14a
@ -1753,17 +1753,29 @@ static bool isSplatMask(SDNode *N) {
|
|||||||
|
|
||||||
// This is a splat operation if each element of the permute is the same, and
|
// This is a splat operation if each element of the permute is the same, and
|
||||||
// if the value doesn't reference the second vector.
|
// if the value doesn't reference the second vector.
|
||||||
SDOperand Elt = N->getOperand(0);
|
unsigned NumElems = N->getNumOperands();
|
||||||
assert(isa<ConstantSDNode>(Elt) && "Invalid VECTOR_SHUFFLE mask!");
|
SDOperand ElementBase;
|
||||||
for (unsigned i = 1, e = N->getNumOperands(); i != e; ++i) {
|
unsigned i = 0;
|
||||||
|
for (; i != NumElems; ++i) {
|
||||||
|
SDOperand Elt = N->getOperand(i);
|
||||||
|
if (ConstantSDNode *EltV = dyn_cast<ConstantSDNode>(Elt)) {
|
||||||
|
ElementBase = Elt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ElementBase.Val)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (; i != NumElems; ++i) {
|
||||||
SDOperand Arg = N->getOperand(i);
|
SDOperand Arg = N->getOperand(i);
|
||||||
if (Arg.getOpcode() == ISD::UNDEF) continue;
|
if (Arg.getOpcode() == ISD::UNDEF) continue;
|
||||||
assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
|
assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
|
||||||
if (Arg != Elt) return false;
|
if (Arg != ElementBase) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure it is a splat of the first vector operand.
|
// Make sure it is a splat of the first vector operand.
|
||||||
return cast<ConstantSDNode>(Elt)->getValue() < N->getNumOperands();
|
return cast<ConstantSDNode>(ElementBase)->getValue() < NumElems;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isSplatMask - Return true if the specified VECTOR_SHUFFLE operand specifies
|
/// isSplatMask - Return true if the specified VECTOR_SHUFFLE operand specifies
|
||||||
@ -1771,7 +1783,7 @@ static bool isSplatMask(SDNode *N) {
|
|||||||
bool X86::isSplatMask(SDNode *N) {
|
bool X86::isSplatMask(SDNode *N) {
|
||||||
assert(N->getOpcode() == ISD::BUILD_VECTOR);
|
assert(N->getOpcode() == ISD::BUILD_VECTOR);
|
||||||
|
|
||||||
// We can only splat 64-bit, and 32-bit quantities.
|
// We can only splat 64-bit, and 32-bit quantities with a single instruction.
|
||||||
if (N->getNumOperands() != 4 && N->getNumOperands() != 2)
|
if (N->getNumOperands() != 4 && N->getNumOperands() != 2)
|
||||||
return false;
|
return false;
|
||||||
return ::isSplatMask(N);
|
return ::isSplatMask(N);
|
||||||
|
Loading…
Reference in New Issue
Block a user