Index: src/crankshaft/hydrogen-instructions.cc |
diff --git a/src/crankshaft/hydrogen-instructions.cc b/src/crankshaft/hydrogen-instructions.cc |
index 17d268cfe16d2e17a0dd59b9d1908a31a6ccc7e8..85222f63a376884d7bda88db0427f00645309ebc 100644 |
--- a/src/crankshaft/hydrogen-instructions.cc |
+++ b/src/crankshaft/hydrogen-instructions.cc |
@@ -259,7 +259,11 @@ bool Range::AddAndCheckOverflow(const Representation& r, Range* other) { |
bool may_overflow = false; |
lower_ = AddWithoutOverflow(r, lower_, other->lower(), &may_overflow); |
upper_ = AddWithoutOverflow(r, upper_, other->upper(), &may_overflow); |
- KeepOrder(); |
+ if (may_overflow) { |
+ Clear(); |
+ } else { |
+ KeepOrder(); |
+ } |
#ifdef DEBUG |
Verify(); |
#endif |
@@ -271,13 +275,21 @@ bool Range::SubAndCheckOverflow(const Representation& r, Range* other) { |
bool may_overflow = false; |
lower_ = SubWithoutOverflow(r, lower_, other->upper(), &may_overflow); |
upper_ = SubWithoutOverflow(r, upper_, other->lower(), &may_overflow); |
- KeepOrder(); |
+ if (may_overflow) { |
+ Clear(); |
+ } else { |
+ KeepOrder(); |
+ } |
#ifdef DEBUG |
Verify(); |
#endif |
return may_overflow; |
} |
+void Range::Clear() { |
+ lower_ = kMinInt; |
+ upper_ = kMaxInt; |
+} |
void Range::KeepOrder() { |
if (lower_ > upper_) { |
@@ -301,8 +313,12 @@ bool Range::MulAndCheckOverflow(const Representation& r, Range* other) { |
int v2 = MulWithoutOverflow(r, lower_, other->upper(), &may_overflow); |
int v3 = MulWithoutOverflow(r, upper_, other->lower(), &may_overflow); |
int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow); |
- lower_ = Min(Min(v1, v2), Min(v3, v4)); |
- upper_ = Max(Max(v1, v2), Max(v3, v4)); |
+ if (may_overflow) { |
+ Clear(); |
+ } else { |
+ lower_ = Min(Min(v1, v2), Min(v3, v4)); |
+ upper_ = Max(Max(v1, v2), Max(v3, v4)); |
+ } |
#ifdef DEBUG |
Verify(); |
#endif |