Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
| index d3f1a9e09024c8f1643eb53bddc3b595b3953d3e..5cea51c2d27aec7c446e5ca2847c9194a12e8643 100644 |
| --- a/src/hydrogen-instructions.cc |
| +++ b/src/hydrogen-instructions.cc |
| @@ -1308,6 +1308,31 @@ const char* HUnaryMathOperation::OpName() const { |
| } |
| +Range* HUnaryMathOperation::InferRange(Zone* zone) { |
| + Representation r = representation(); |
| + if (r.IsSmiOrInteger32() && value()->HasRange()) { |
| + if (op() == kMathAbs) { |
| + int upper = value()->range()->upper(); |
| + int lower = value()->range()->lower(); |
| + bool spans_zero = lower < 0 && 0 < upper; |
|
Jakob Kummerow
2013/06/07 08:21:05
There's Range::CanBeZero(). It checks for '<=' ins
Toon Verwaest
2013/06/07 09:00:48
Done.
|
| + upper = abs(upper); |
| + lower = abs(lower); |
| + if (upper < lower) { |
| + int temp = upper; |
| + upper = lower; |
| + lower = temp; |
| + } |
| + if (spans_zero) lower = 0; |
| + Range* result = new(zone) Range(lower, upper); |
| + if (r.IsSmi()) result->TruncateToSmi(); |
|
Jakob Kummerow
2013/06/07 08:21:05
Is this needed? Doesn't r.IsSmi() imply value()->r
Toon Verwaest
2013/06/07 09:00:48
Added a comment to explain it.
On 2013/06/07 08:2
|
| + if (r.IsInteger32()) result->TruncateToInt32(); |
| + return result; |
| + } |
| + } |
| + return HValue::InferRange(zone); |
| +} |
| + |
| + |
| void HUnaryMathOperation::PrintDataTo(StringStream* stream) { |
| const char* name = OpName(); |
| stream->Add("%s ", name); |