summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.h
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r--compiler/optimizing/nodes.h43
1 files changed, 38 insertions, 5 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 3733850745..88d39d16e5 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -2427,8 +2427,13 @@ class HConstant : public HExpression<0> {
bool CanBeMoved() const OVERRIDE { return true; }
+ // Is this constant -1 in the arithmetic sense?
virtual bool IsMinusOne() const { return false; }
- virtual bool IsZero() const { return false; }
+ // Is this constant 0 in the arithmetic sense?
+ virtual bool IsArithmeticZero() const { return false; }
+ // Is this constant a 0-bit pattern?
+ virtual bool IsZeroBitPattern() const { return false; }
+ // Is this constant 1 in the arithmetic sense?
virtual bool IsOne() const { return false; }
virtual uint64_t GetValueAsUint64() const = 0;
@@ -2449,6 +2454,9 @@ class HNullConstant : public HConstant {
size_t ComputeHashCode() const OVERRIDE { return 0; }
+ // The null constant representation is a 0-bit pattern.
+ virtual bool IsZeroBitPattern() const { return true; }
+
DECLARE_INSTRUCTION(NullConstant);
private:
@@ -2476,9 +2484,15 @@ class HIntConstant : public HConstant {
size_t ComputeHashCode() const OVERRIDE { return GetValue(); }
bool IsMinusOne() const OVERRIDE { return GetValue() == -1; }
- bool IsZero() const OVERRIDE { return GetValue() == 0; }
+ bool IsArithmeticZero() const OVERRIDE { return GetValue() == 0; }
+ bool IsZeroBitPattern() const OVERRIDE { return GetValue() == 0; }
bool IsOne() const OVERRIDE { return GetValue() == 1; }
+ // Integer constants are used to encode Boolean values as well,
+ // where 1 means true and 0 means false.
+ bool IsTrue() const { return GetValue() == 1; }
+ bool IsFalse() const { return GetValue() == 0; }
+
DECLARE_INSTRUCTION(IntConstant);
private:
@@ -2509,7 +2523,8 @@ class HLongConstant : public HConstant {
size_t ComputeHashCode() const OVERRIDE { return static_cast<size_t>(GetValue()); }
bool IsMinusOne() const OVERRIDE { return GetValue() == -1; }
- bool IsZero() const OVERRIDE { return GetValue() == 0; }
+ bool IsArithmeticZero() const OVERRIDE { return GetValue() == 0; }
+ bool IsZeroBitPattern() const OVERRIDE { return GetValue() == 0; }
bool IsOne() const OVERRIDE { return GetValue() == 1; }
DECLARE_INSTRUCTION(LongConstant);
@@ -2542,7 +2557,16 @@ class HFloatConstant : public HConstant {
bool IsMinusOne() const OVERRIDE {
return bit_cast<uint32_t, float>(value_) == bit_cast<uint32_t, float>((-1.0f));
}
- bool IsZero() const OVERRIDE {
+ bool IsArithmeticZero() const OVERRIDE {
+ return std::fpclassify(value_) == FP_ZERO;
+ }
+ bool IsArithmeticPositiveZero() const {
+ return IsArithmeticZero() && !std::signbit(value_);
+ }
+ bool IsArithmeticNegativeZero() const {
+ return IsArithmeticZero() && std::signbit(value_);
+ }
+ bool IsZeroBitPattern() const OVERRIDE {
return bit_cast<uint32_t, float>(value_) == bit_cast<uint32_t, float>(0.0f);
}
bool IsOne() const OVERRIDE {
@@ -2584,7 +2608,16 @@ class HDoubleConstant : public HConstant {
bool IsMinusOne() const OVERRIDE {
return bit_cast<uint64_t, double>(value_) == bit_cast<uint64_t, double>((-1.0));
}
- bool IsZero() const OVERRIDE {
+ bool IsArithmeticZero() const OVERRIDE {
+ return std::fpclassify(value_) == FP_ZERO;
+ }
+ bool IsArithmeticPositiveZero() const {
+ return IsArithmeticZero() && !std::signbit(value_);
+ }
+ bool IsArithmeticNegativeZero() const {
+ return IsArithmeticZero() && std::signbit(value_);
+ }
+ bool IsZeroBitPattern() const OVERRIDE {
return bit_cast<uint64_t, double>(value_) == bit_cast<uint64_t, double>((0.0));
}
bool IsOne() const OVERRIDE {