diff options
author | Chris Lattner <sabre@nondot.org> | 2006-03-25 22:57:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-03-25 22:57:01 +0000 |
commit | 61d4399dfc7046595e30ad34a28c72a885cb8100 (patch) | |
tree | d4bfe0524ff7ec0cc67c4110cc9f4ed1a5fb749e | |
parent | 322dcd379eb19ea8d01478a661920ea1ce62fa0d (diff) | |
download | external_llvm-61d4399dfc7046595e30ad34a28c72a885cb8100.zip external_llvm-61d4399dfc7046595e30ad34a28c72a885cb8100.tar.gz external_llvm-61d4399dfc7046595e30ad34a28c72a885cb8100.tar.bz2 |
Implement the ISD::isBuildVectorAllOnesInteger predicate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27130 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 97b4095..9fcfc61 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -66,9 +66,40 @@ bool ConstantFPSDNode::isExactlyValue(double V) const { } //===----------------------------------------------------------------------===// -// ISD Class +// ISD Namespace //===----------------------------------------------------------------------===// +/// isBuildVectorAllOnesInteger - Return true if the specified node is a +/// BUILD_VECTOR where all of the elements are ~0 or undef. +bool ISD::isBuildVectorAllOnesInteger(const SDNode *N) { + if (N->getOpcode() != ISD::BUILD_VECTOR || + !MVT::isInteger(N->getOperand(0).getValueType())) return false; + + unsigned i = 0, e = N->getNumOperands(); + + // Skip over all of the undef values. + while (i != e && N->getOperand(i).getOpcode() == ISD::UNDEF) + ++i; + + // Do not accept an all-undef vector. + if (i == e) return false; + + // Do not accept build_vectors that aren't all constants or which have non-~0 + // elements. + if (!isa<ConstantSDNode>(N) || !cast<ConstantSDNode>(N)->isAllOnesValue()) + return false; + + // Okay, we have at least one ~0 value, check to see if the rest match or are + // undefs. + SDOperand NotZero = N->getOperand(i); + for (++i; i != e; ++i) + if (N->getOperand(i) != NotZero && + N->getOperand(i).getOpcode() != ISD::UNDEF) + return false; + return true; +} + + /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) /// when given the operation for (X op Y). ISD::CondCode ISD::getSetCCSwappedOperands(ISD::CondCode Operation) { |