Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index c56f5dc36f8cce87074c070cf4486746d1ad6272..5da613f591e1956bf1167a4a7add99a3d59a0fe4 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -3721,6 +3721,12 @@ HType HChange::CalculateInferredType() { |
Representation HUnaryMathOperation::RepresentationFromInputs() { |
+ if (SupportsFlexibleFloorAndRound() && |
+ (op_ == kMathFloor || op_ == kMathRound)) { |
+ // Floor and Round always take a double input. The integral result can be |
+ // used as an integer or a double. Infer the representation from the uses. |
+ return Representation::None(); |
+ } |
Representation rep = representation(); |
// If any of the actual input representation is more general than what we |
// have so far but not Tagged, use that representation instead. |
@@ -4189,6 +4195,41 @@ HInstruction* HUnaryMathOperation::New( |
} |
+Representation HUnaryMathOperation::RepresentationFromUses() { |
+ if (op_ != kMathFloor && op_ != kMathRound) { |
+ return HValue::RepresentationFromUses(); |
+ } |
+ |
+ // The instruction can have an int32 or double output. Prefer a double |
+ // representation if there are double uses. |
+ bool has_double_use = false; |
+ |
+ for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
+ HValue* use = it.value(); |
+ Representation rep = use->RequiredInputRepresentation(it.index()); |
+ bool rep_required = !rep.IsNone(); |
+ if (!rep_required) { |
Jakob Kummerow
2014/04/25 14:12:03
I'm not sure I like the way you're prioritizing re
Alexandre Rames
2014/04/25 16:05:26
Removed consideration of the required representati
Jakob Kummerow
2014/04/28 13:53:32
Any reason you're not looking at both required and
|
+ rep = use->observed_input_representation(it.index()); |
+ } |
+ if (FLAG_trace_representation && !rep.IsNone()) { |
+ PrintF("#%d %s is %s by #%d %s as %s%s\n", |
+ id(), Mnemonic(), |
+ rep_required ? "required" : "used", |
+ use->id(), use->Mnemonic(), rep.Mnemonic(), |
+ (use->CheckFlag(kTruncatingToInt32) ? "-trunc" : "")); |
+ } |
+ if (rep.IsDouble()) { |
+ has_double_use = true; |
+ if (!FLAG_trace_representation) { |
+ break; |
Jakob Kummerow
2014/04/25 14:12:03
nit: indentation. Also, a comment would be nice (e
Alexandre Rames
2014/04/25 16:05:26
Done.
|
+ } |
+ } |
+ } |
+ return has_double_use ? Representation::Double() |
+ : Representation::Integer32(); |
+} |
+ |
+ |
HInstruction* HPower::New(Zone* zone, |
HValue* context, |
HValue* left, |