Ignore observed Double output in binary operations when all uses are truncating to Integer32

BUG=v8:2424

Review URL: https://codereview.chromium.org/14320021

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14381 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 54a11734
...@@ -2228,13 +2228,24 @@ void HBinaryOperation::InferRepresentation(HInferRepresentation* h_infer) { ...@@ -2228,13 +2228,24 @@ void HBinaryOperation::InferRepresentation(HInferRepresentation* h_infer) {
} }
bool HBinaryOperation::IgnoreObservedOutputRepresentation(
Representation current_rep) {
return observed_output_representation_.IsDouble() &&
current_rep.IsInteger32() &&
// Mul in Integer32 mode would be too precise.
!this->IsMul() &&
// TODO(jkummerow): Remove blacklisting of Div when the Div
// instruction has learned not to deopt when the remainder is
// non-zero but all uses are truncating.
!this->IsDiv() &&
CheckUsesForFlag(kTruncatingToInt32);
}
Representation HBinaryOperation::RepresentationFromInputs() { Representation HBinaryOperation::RepresentationFromInputs() {
// Determine the worst case of observed input representations and // Determine the worst case of observed input representations and
// the currently assumed output representation. // the currently assumed output representation.
Representation rep = representation(); Representation rep = representation();
if (observed_output_representation_.is_more_general_than(rep)) {
rep = observed_output_representation_;
}
for (int i = 1; i <= 2; ++i) { for (int i = 1; i <= 2; ++i) {
Representation input_rep = observed_input_representation(i); Representation input_rep = observed_input_representation(i);
if (input_rep.is_more_general_than(rep)) rep = input_rep; if (input_rep.is_more_general_than(rep)) rep = input_rep;
...@@ -2252,6 +2263,13 @@ Representation HBinaryOperation::RepresentationFromInputs() { ...@@ -2252,6 +2263,13 @@ Representation HBinaryOperation::RepresentationFromInputs() {
right()->CheckFlag(kFlexibleRepresentation)) { right()->CheckFlag(kFlexibleRepresentation)) {
rep = right_rep; rep = right_rep;
} }
// Consider observed output representation, but ignore it if it's Double,
// this instruction is not a division, and all its uses are truncating
// to Integer32.
if (observed_output_representation_.is_more_general_than(rep) &&
!IgnoreObservedOutputRepresentation(rep)) {
rep = observed_output_representation_;
}
return rep; return rep;
} }
......
...@@ -3455,6 +3455,8 @@ class HBinaryOperation: public HTemplateInstruction<3> { ...@@ -3455,6 +3455,8 @@ class HBinaryOperation: public HTemplateInstruction<3> {
DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation)
private: private:
bool IgnoreObservedOutputRepresentation(Representation current_rep);
Representation observed_input_representation_[2]; Representation observed_input_representation_[2];
Representation observed_output_representation_; Representation observed_output_representation_;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment