From: jkummerow@chromium.org Date: Fri, 14 Jun 2013 16:27:52 +0000 (+0000) Subject: Fix MathFloorOfDiv canonicalization ASSERT failures X-Git-Tag: upstream/4.7.83~13818 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb1057ad5d13260c1a92df82a138551bd77b0b7a;p=platform%2Fupstream%2Fv8.git Fix MathFloorOfDiv canonicalization ASSERT failures - remove outdated ASSERT about instruction type - add inserted HChanges to the graph R=danno@chromium.org Review URL: https://codereview.chromium.org/17094005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15166 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 5ec663c..f69fbc9 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -1510,9 +1510,7 @@ void HChange::PrintDataTo(StringStream* stream) { } -static HValue* SimplifiedDividendForMathFloorOfDiv( - HValue* dividend, - Representation observed_representation) { +static HValue* SimplifiedDividendForMathFloorOfDiv(HValue* dividend) { // A value with an integer representation does not need to be transformed. if (dividend->representation().IsInteger32()) { return dividend; @@ -1522,11 +1520,6 @@ static HValue* SimplifiedDividendForMathFloorOfDiv( HChange::cast(dividend)->from().IsInteger32()) { return HChange::cast(dividend)->value(); } - // If we've only seen integers so far, insert an appropriate change. - if (observed_representation.IsSmiOrInteger32()) { - return new(dividend->block()->zone()) - HChange(dividend, Representation::Integer32(), false, false); - } return NULL; } @@ -1547,14 +1540,20 @@ HValue* HUnaryMathOperation::Canonicalize() { HValue* left = hdiv->left(); HValue* right = hdiv->right(); // Try to simplify left and right values of the division. - HValue* new_left = SimplifiedDividendForMathFloorOfDiv( - left, hdiv->observed_input_representation(1)); + HValue* new_left = SimplifiedDividendForMathFloorOfDiv(left); + if (new_left == NULL && + hdiv->observed_input_representation(1).IsSmiOrInteger32()) { + new_left = new(block()->zone()) + HChange(left, Representation::Integer32(), false, false); + HChange::cast(new_left)->InsertBefore(this); + } HValue* new_right = LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(right); if (new_right == NULL && hdiv->observed_input_representation(2).IsSmiOrInteger32()) { new_right = new(block()->zone()) HChange(right, Representation::Integer32(), false, false); + HChange::cast(new_right)->InsertBefore(this); } // Return if left or right are not optimizable. @@ -1576,13 +1575,9 @@ HValue* HUnaryMathOperation::Canonicalize() { ReplaceAllUsesWith(instr); Kill(); // We know the division had no other uses than this HMathFloor. Delete it. - // Also delete the arguments of the division if they are not used any - // more. + // Dead code elimination will deal with |left| and |right| if + // appropriate. hdiv->DeleteAndReplaceWith(NULL); - ASSERT(left->IsChange() || left->IsConstant()); - ASSERT(right->IsChange() || right->IsConstant()); - if (left->HasNoUses()) left->DeleteAndReplaceWith(NULL); - if (right->HasNoUses()) right->DeleteAndReplaceWith(NULL); // Return NULL to remove this instruction from the graph. return NULL;