diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-15 06:14:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-15 06:14:08 +0000 |
commit | be6610caba8076c864f0e6584442472115d72b2b (patch) | |
tree | 8abf870b09adfd148b4f70374aac3e626e92e465 /llvm/lib | |
parent | b1a151211919a00d73c441e944271dd820884152 (diff) | |
download | bcm5719-llvm-be6610caba8076c864f0e6584442472115d72b2b.tar.gz bcm5719-llvm-be6610caba8076c864f0e6584442472115d72b2b.zip |
devirtualize Constant::isNullValue:
4 files changed, 15 insertions(+), 60 deletions(-)
llvm-svn: 135252
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 019a590f412..681e7269c9b 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -49,6 +49,19 @@ bool Constant::isNegativeZeroValue() const { return isNullValue(); } +bool Constant::isNullValue() const { + // 0 is null. + if (const ConstantInt *CI = dyn_cast<ConstantInt>(this)) + return CI->isZero(); + + // +0.0 is null. + if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this)) + return CFP->isZero() && !CFP->isNegative(); + + // constant zero is zero for aggregates and cpnull is null for pointers. + return isa<ConstantAggregateZero>(this) || isa<ConstantPointerNull>(this); +} + // Constructor to create a '0' constant of arbitrary type... Constant *Constant::getNullValue(const Type *Ty) { switch (Ty->getTypeID()) { @@ -551,11 +564,7 @@ ConstantFP::ConstantFP(const Type *Ty, const APFloat& V) "FP type Mismatch"); } -bool ConstantFP::isNullValue() const { - return Val.isZero() && !Val.isNegative(); -} - -bool ConstantFP::isExactlyValue(const APFloat& V) const { +bool ConstantFP::isExactlyValue(const APFloat &V) const { return Val.bitwiseIsEqual(V); } |