summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2007-10-17 17:51:30 +0000
committerDan Gohman <gohman@apple.com>2007-10-17 17:51:30 +0000
commit07159205dd114db9c94a54e27b67fed298aec4d3 (patch)
tree85b6296ecca2ce79087e7bfa602542b360180fe2 /llvm/lib
parenta32aaefadcf84f20861332961a5d2c68b19e3abb (diff)
downloadbcm5719-llvm-07159205dd114db9c94a54e27b67fed298aec4d3.tar.gz
bcm5719-llvm-07159205dd114db9c94a54e27b67fed298aec4d3.zip
Define a helper function ConstantVector::getSplatValue for testing for
and working with broadcasted constants. llvm-svn: 43076
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Constants.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 350a306d797..9c1377dbd7b 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -1286,6 +1286,17 @@ bool ConstantVector::isAllOnesValue() const {
return true;
}
+/// getSplatValue - If this is a splat constant, where all of the
+/// elements have the same value, return that value. Otherwise return null.
+Constant *ConstantVector::getSplatValue() {
+ // Check out first element.
+ Constant *Elt = getOperand(0);
+ // Then make sure all remaining elements point to the same value.
+ for (unsigned I = 1, E = getNumOperands(); I < E; ++I)
+ if (getOperand(I) != Elt) return 0;
+ return Elt;
+}
+
//---- ConstantPointerNull::get() implementation...
//
OpenPOWER on IntegriCloud