From 957622ea93878ccc2cc43f57b1ce1b45d052da3e Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Sun, 30 Aug 2015 13:48:02 +0000 Subject: [PATCH] NFC: Code style in VectorUtils.cpp Differential Revision: http://reviews.llvm.org/D12478 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246381 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/VectorUtils.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Analysis/VectorUtils.cpp b/lib/Analysis/VectorUtils.cpp index 92a880c3762..93720857662 100644 --- a/lib/Analysis/VectorUtils.cpp +++ b/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(V); - if (CV) + if (auto *CV = dyn_cast(V)) return CV->getSplatValue(); - llvm::ShuffleVectorInst *ShuffleInst = dyn_cast(V); + + auto *ShuffleInst = dyn_cast(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(ShuffleInst->getOperand(0)); + auto *InsertEltInst = + dyn_cast(ShuffleInst->getOperand(0)); if (!InsertEltInst || !isa(InsertEltInst->getOperand(2)) || !cast(InsertEltInst->getOperand(2))->isNullValue()) return nullptr; -- 2.34.1