mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-07 20:04:03 +00:00
Change isBuildVectorAllOnesInteger to isBuildVectorAllOnes. Also check for
floating point cases. llvm-svn: 27165
This commit is contained in:
parent
c508c91acb
commit
4667bd17cb
@ -455,9 +455,9 @@ namespace ISD {
|
|||||||
|
|
||||||
/// Node predicates
|
/// Node predicates
|
||||||
|
|
||||||
/// isBuildVectorAllOnesInteger - Return true if the specified node is a
|
/// isBuildVectorAllOnes - Return true if the specified node is a
|
||||||
/// BUILD_VECTOR where all of the elements are ~0 or undef.
|
/// BUILD_VECTOR where all of the elements are ~0 or undef.
|
||||||
bool isBuildVectorAllOnesInteger(const SDNode *N);
|
bool isBuildVectorAllOnes(const SDNode *N);
|
||||||
|
|
||||||
/// isBuildVectorAllZeros - Return true if the specified node is a
|
/// isBuildVectorAllZeros - Return true if the specified node is a
|
||||||
/// BUILD_VECTOR where all of the elements are 0 or undef.
|
/// BUILD_VECTOR where all of the elements are 0 or undef.
|
||||||
|
@ -70,11 +70,10 @@ bool ConstantFPSDNode::isExactlyValue(double V) const {
|
|||||||
// ISD Namespace
|
// ISD Namespace
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// isBuildVectorAllOnesInteger - Return true if the specified node is a
|
/// isBuildVectorAllOnes - Return true if the specified node is a
|
||||||
/// BUILD_VECTOR where all of the elements are ~0 or undef.
|
/// BUILD_VECTOR where all of the elements are ~0 or undef.
|
||||||
bool ISD::isBuildVectorAllOnesInteger(const SDNode *N) {
|
bool ISD::isBuildVectorAllOnes(const SDNode *N) {
|
||||||
if (N->getOpcode() != ISD::BUILD_VECTOR ||
|
if (N->getOpcode() != ISD::BUILD_VECTOR) return false;
|
||||||
!MVT::isInteger(N->getOperand(0).getValueType())) return false;
|
|
||||||
|
|
||||||
unsigned i = 0, e = N->getNumOperands();
|
unsigned i = 0, e = N->getNumOperands();
|
||||||
|
|
||||||
@ -88,8 +87,13 @@ bool ISD::isBuildVectorAllOnesInteger(const SDNode *N) {
|
|||||||
// Do not accept build_vectors that aren't all constants or which have non-~0
|
// Do not accept build_vectors that aren't all constants or which have non-~0
|
||||||
// elements.
|
// elements.
|
||||||
SDOperand NotZero = N->getOperand(i);
|
SDOperand NotZero = N->getOperand(i);
|
||||||
if (!isa<ConstantSDNode>(NotZero) ||
|
if (isa<ConstantSDNode>(NotZero)) {
|
||||||
!cast<ConstantSDNode>(NotZero)->isAllOnesValue())
|
if (!cast<ConstantSDNode>(NotZero)->isAllOnesValue())
|
||||||
|
return false;
|
||||||
|
} else if (isa<ConstantFPSDNode>(NotZero)) {
|
||||||
|
if (!cast<ConstantFPSDNode>(NotZero)->isExactlyValue(-1))
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Okay, we have at least one ~0 value, check to see if the rest match or are
|
// Okay, we have at least one ~0 value, check to see if the rest match or are
|
||||||
@ -106,24 +110,35 @@ bool ISD::isBuildVectorAllOnesInteger(const SDNode *N) {
|
|||||||
/// BUILD_VECTOR where all of the elements are 0 or undef.
|
/// BUILD_VECTOR where all of the elements are 0 or undef.
|
||||||
bool ISD::isBuildVectorAllZeros(const SDNode *N) {
|
bool ISD::isBuildVectorAllZeros(const SDNode *N) {
|
||||||
if (N->getOpcode() != ISD::BUILD_VECTOR) return false;
|
if (N->getOpcode() != ISD::BUILD_VECTOR) return false;
|
||||||
|
|
||||||
bool AllUndef = true;
|
unsigned i = 0, e = N->getNumOperands();
|
||||||
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
|
||||||
SDOperand Elt = N->getOperand(i);
|
// Skip over all of the undef values.
|
||||||
if (Elt.getOpcode() != ISD::UNDEF) {
|
while (i != e && N->getOperand(i).getOpcode() == ISD::UNDEF)
|
||||||
AllUndef = false;
|
++i;
|
||||||
if (isa<ConstantSDNode>(Elt)) {
|
|
||||||
if (!cast<ConstantSDNode>(Elt)->isNullValue())
|
// Do not accept an all-undef vector.
|
||||||
return false;
|
if (i == e) return false;
|
||||||
} else if (isa<ConstantFPSDNode>(Elt)) {
|
|
||||||
if (!cast<ConstantFPSDNode>(Elt)->isExactlyValue(0.0))
|
// Do not accept build_vectors that aren't all constants or which have non-~0
|
||||||
return false;
|
// elements.
|
||||||
} else
|
SDOperand Zero = N->getOperand(i);
|
||||||
return false;
|
if (isa<ConstantSDNode>(Zero)) {
|
||||||
}
|
if (!cast<ConstantSDNode>(Zero)->isNullValue())
|
||||||
}
|
return false;
|
||||||
|
} else if (isa<ConstantFPSDNode>(Zero)) {
|
||||||
return !AllUndef;
|
if (!cast<ConstantFPSDNode>(Zero)->isExactlyValue(0.0))
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Okay, we have at least one ~0 value, check to see if the rest match or are
|
||||||
|
// undefs.
|
||||||
|
for (++i; i != e; ++i)
|
||||||
|
if (N->getOperand(i) != Zero &&
|
||||||
|
N->getOperand(i).getOpcode() != ISD::UNDEF)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
|
/// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
|
||||||
|
Loading…
Reference in New Issue
Block a user