diff options
author | Dan Gohman <gohman@apple.com> | 2007-10-17 17:51:30 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2007-10-17 17:51:30 +0000 |
commit | 3b7cf0aabafc1c7a89a5a978d4a4307c891027ce (patch) | |
tree | 80af5492ed455036a92b53f6dcc3683572c81b4b /lib/VMCore | |
parent | efd4a5144b03f61ebfd53d0245176f95e1170fb8 (diff) | |
download | external_llvm-3b7cf0aabafc1c7a89a5a978d4a4307c891027ce.zip external_llvm-3b7cf0aabafc1c7a89a5a978d4a4307c891027ce.tar.gz external_llvm-3b7cf0aabafc1c7a89a5a978d4a4307c891027ce.tar.bz2 |
Define a helper function ConstantVector::getSplatValue for testing for
and working with broadcasted constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43076 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Constants.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 350a306..9c1377d 100644 --- a/lib/VMCore/Constants.cpp +++ b/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... // |