Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
| index b36706b49b48119b6332a54e6782a9904e929ee5..b307a4c289586d526a7e73ca3ae80bb22f0d5d6d 100644 |
| --- a/src/hydrogen-instructions.cc |
| +++ b/src/hydrogen-instructions.cc |
| @@ -84,6 +84,10 @@ void HValue::InferRepresentation(HInferRepresentation* h_infer) { |
| UpdateRepresentation(new_rep, h_infer, "inputs"); |
| new_rep = RepresentationFromUses(); |
| UpdateRepresentation(new_rep, h_infer, "uses"); |
| + new_rep = RepresentationFromUseRequirements(); |
| + if (new_rep.fits_into(Representation::Integer32())) { |
| + UpdateRepresentation(new_rep, h_infer, "use requirements"); |
| + } |
| } |
| @@ -2304,6 +2308,10 @@ void HBinaryOperation::InferRepresentation(HInferRepresentation* h_infer) { |
| if (!observed_output_representation_.IsNone()) return; |
| new_rep = RepresentationFromUses(); |
| UpdateRepresentation(new_rep, h_infer, "uses"); |
| + new_rep = RepresentationFromUseRequirements(); |
| + if (new_rep.fits_into(Representation::Integer32())) { |
| + UpdateRepresentation(new_rep, h_infer, "use requirements"); |
| + } |
| } |
| @@ -3660,34 +3668,24 @@ Representation HPhi::RepresentationFromInputs() { |
| } |
| -Representation HPhi::RepresentationFromUseRequirements() { |
| - Representation all_uses_require = Representation::None(); |
| - bool all_uses_require_the_same = true; |
| +Representation HValue::RepresentationFromUseRequirements() { |
| + Representation rep = Representation::None(); |
| for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
|
Jakob Kummerow
2013/06/14 13:36:43
Please add a high-level comment outlining the algo
Toon Verwaest
2013/06/14 13:58:12
Done.
|
| // We check for observed_input_representation elsewhere. |
| Representation use_rep = |
| it.value()->RequiredInputRepresentation(it.index()); |
| - // No useful info from this use -> look at the next one. |
| - if (use_rep.IsNone()) { |
| + if (rep.IsNone()) { |
| + rep = use_rep; |
| continue; |
| } |
| - if (use_rep.Equals(all_uses_require)) { |
| + if (use_rep.IsNone() || rep.Equals(use_rep)) continue; |
| + if (rep.generalize(use_rep).IsInteger32()) { |
| + rep = Representation::Integer32(); |
| continue; |
| } |
| - // This use's representation contradicts what we've seen so far. |
| - if (!all_uses_require.IsNone()) { |
| - ASSERT(!use_rep.Equals(all_uses_require)); |
| - all_uses_require_the_same = false; |
| - break; |
| - } |
| - // Otherwise, initialize observed representation. |
| - all_uses_require = use_rep; |
| - } |
| - if (all_uses_require_the_same) { |
| - return all_uses_require; |
| + return Representation::None(); |
| } |
| - |
| - return Representation::None(); |
| + return rep; |
| } |