From e6dda2fee7eb38ee035d4bcc32496bab89bd5967 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 6 Jul 2018 14:52:36 +0000 Subject: [Constant] add undef element query for vector constants; NFC This is likely to be used in D48987 and similar patches, so adding it as an NFC preliminary step. llvm-svn: 336442 --- llvm/lib/IR/Constants.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'llvm/lib/IR') diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 3ea7598c11e..032793effed 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -254,6 +254,16 @@ bool Constant::isNaN() const { return true; } +bool Constant::containsUndefElement() const { + if (!getType()->isVectorTy()) + return false; + for (unsigned i = 0, e = getType()->getVectorNumElements(); i != e; ++i) + if (isa(getAggregateElement(i))) + return true; + + return false; +} + /// Constructor to create a '0' constant of arbitrary type. Constant *Constant::getNullValue(Type *Ty) { switch (Ty->getTypeID()) { -- cgit v1.2.3