From 3b55ebb22156e1f3496cd1ee4a05e03b4780e579 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Fri, 8 May 2015 13:13:19 +0100 Subject: Simplify floating-point comparisons with NaN in Optimizing. This change was suggested by Ian. Also, simplify some art::HFloatConstant and art::HDoubleConstant methods. Change-Id: I7908df23581a7f61c8ec79c290fe5f70798ac3be --- compiler/optimizing/nodes.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'compiler/optimizing/nodes.h') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 5fc0470310..53bff91a47 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2094,15 +2094,16 @@ class HFloatConstant : public HConstant { size_t ComputeHashCode() const OVERRIDE { return static_cast(GetValue()); } bool IsMinusOne() const OVERRIDE { - return bit_cast(AsFloatConstant()->GetValue()) == - bit_cast((-1.0f)); + return bit_cast(value_) == bit_cast((-1.0f)); } bool IsZero() const OVERRIDE { - return AsFloatConstant()->GetValue() == 0.0f; + return value_ == 0.0f; } bool IsOne() const OVERRIDE { - return bit_cast(AsFloatConstant()->GetValue()) == - bit_cast(1.0f); + return bit_cast(value_) == bit_cast(1.0f); + } + bool IsNaN() const { + return std::isnan(value_); } DECLARE_INSTRUCTION(FloatConstant); @@ -2132,15 +2133,16 @@ class HDoubleConstant : public HConstant { size_t ComputeHashCode() const OVERRIDE { return static_cast(GetValue()); } bool IsMinusOne() const OVERRIDE { - return bit_cast(AsDoubleConstant()->GetValue()) == - bit_cast((-1.0)); + return bit_cast(value_) == bit_cast((-1.0)); } bool IsZero() const OVERRIDE { - return AsDoubleConstant()->GetValue() == 0.0; + return value_ == 0.0; } bool IsOne() const OVERRIDE { - return bit_cast(AsDoubleConstant()->GetValue()) == - bit_cast(1.0); + return bit_cast(value_) == bit_cast(1.0); + } + bool IsNaN() const { + return std::isnan(value_); } DECLARE_INSTRUCTION(DoubleConstant); -- cgit v1.2.3-59-g8ed1b