Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: src/hydrogen-instructions.cc

Issue 17094005: Fix MathFloorOfDiv canonicalization ASSERT failures (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 5ec663c47b29460c823cf8579471fab7e8e37f21..f69fbc9b938cc5466d859771eb707ee1b1762c54 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698