summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-03-26 09:50:58 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-03-26 09:50:58 +0000
commita67899195f74afe6b2350328cb73a6772bf40b48 (patch)
tree225a1b33f5674cced36b21b7f445fb78021ced38 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent30ee72586d611a8723b3d37c9ca01367b695ef7f (diff)
downloadbcm5719-llvm-a67899195f74afe6b2350328cb73a6772bf40b48.tar.gz
bcm5719-llvm-a67899195f74afe6b2350328cb73a6772bf40b48.zip
Add ISD::isBuildVectorAllZeros predicate
llvm-svn: 27147
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 18e2ebcb45e..c0cd6467011 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -101,6 +101,30 @@ bool ISD::isBuildVectorAllOnesInteger(const SDNode *N) {
}
+/// isBuildVectorAllZeros - Return true if the specified node is a
+/// BUILD_VECTOR where all of the elements are 0 or undef.
+bool ISD::isBuildVectorAllZeros(const SDNode *N) {
+ if (N->getOpcode() != ISD::BUILD_VECTOR) return false;
+
+ bool AllUndef = true;
+ for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
+ SDOperand Elt = N->getOperand(i);
+ if (Elt.getOpcode() != ISD::UNDEF) {
+ AllUndef = false;
+ if (isa<ConstantSDNode>(Elt)) {
+ if (!cast<ConstantSDNode>(Elt)->isNullValue())
+ return false;
+ } else if (isa<ConstantFPSDNode>(Elt)) {
+ if (!cast<ConstantFPSDNode>(Elt)->isExactlyValue(0.0))
+ return false;
+ } else
+ return false;
+ }
+ }
+
+ return !AllUndef;
+}
+
/// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
/// when given the operation for (X op Y).
ISD::CondCode ISD::getSetCCSwappedOperands(ISD::CondCode Operation) {
OpenPOWER on IntegriCloud