summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/VectorUtils.cpp
diff options
context:
space:
mode:
authorElena Demikhovsky <elena.demikhovsky@intel.com>2015-08-30 13:48:02 +0000
committerElena Demikhovsky <elena.demikhovsky@intel.com>2015-08-30 13:48:02 +0000
commit63a7ca9948a2623efaf4aad2bbaf9cc80ca50731 (patch)
tree989c037a46db00ab0fe5a9cc3822b26c926c080c /llvm/lib/Analysis/VectorUtils.cpp
parent3b1d3b0d84af2bf5a50dd31f20fb81ca74c41880 (diff)
downloadbcm5719-llvm-63a7ca9948a2623efaf4aad2bbaf9cc80ca50731.tar.gz
bcm5719-llvm-63a7ca9948a2623efaf4aad2bbaf9cc80ca50731.zip
NFC: Code style in VectorUtils.cpp
Differential Revision: http://reviews.llvm.org/D12478 llvm-svn: 246381
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r--llvm/lib/Analysis/VectorUtils.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 92a880c3762..93720857662 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -410,22 +410,24 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) {
}
/// \brief Get splat value if the input is a splat vector or return nullptr.
-/// The value may be extracted from a splat constants vector or from
-/// a sequence of instructions that broadcast a single value into a vector.
+/// This function is not fully general. It checks only 2 cases:
+/// the input value is (1) a splat constants vector or (2) a sequence
+/// of instructions that broadcast a single value into a vector.
+///
llvm::Value *llvm::getSplatValue(Value *V) {
- llvm::ConstantDataVector *CV = dyn_cast<llvm::ConstantDataVector>(V);
- if (CV)
+ if (auto *CV = dyn_cast<ConstantDataVector>(V))
return CV->getSplatValue();
- llvm::ShuffleVectorInst *ShuffleInst = dyn_cast<llvm::ShuffleVectorInst>(V);
+
+ auto *ShuffleInst = dyn_cast<ShuffleVectorInst>(V);
if (!ShuffleInst)
return nullptr;
- // All-zero (our undef) shuffle mask elements.
- for (int i : ShuffleInst->getShuffleMask())
- if (i != 0 && i != -1)
+ // All-zero (or undef) shuffle mask elements.
+ for (int MaskElt : ShuffleInst->getShuffleMask())
+ if (MaskElt != 0 && MaskElt != -1)
return nullptr;
// The first shuffle source is 'insertelement' with index 0.
- llvm::InsertElementInst *InsertEltInst =
- dyn_cast<llvm::InsertElementInst>(ShuffleInst->getOperand(0));
+ auto *InsertEltInst =
+ dyn_cast<InsertElementInst>(ShuffleInst->getOperand(0));
if (!InsertEltInst || !isa<ConstantInt>(InsertEltInst->getOperand(2)) ||
!cast<ConstantInt>(InsertEltInst->getOperand(2))->isNullValue())
return nullptr;
OpenPOWER on IntegriCloud