Revision: 15161
Author: [email protected]
Date: Fri Jun 14 07:33:15 2013
Log: Make MathFloorOfDiv optimization trigger more often
BUG=v8:2205
[email protected]
Review URL: https://codereview.chromium.org/16973002
http://code.google.com/p/v8/source/detail?r=15161
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-arm.h
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.h
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.h
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Fri Jun 14 02:02:11 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Fri Jun 14 07:33:15 2013
@@ -1401,19 +1401,6 @@
return false;
}
-
-
-HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue*
dividend) {
- // A value with an integer representation does not need to be
transformed.
- if (dividend->representation().IsInteger32()) {
- return dividend;
- // A change from an integer32 can be replaced by the integer32 value.
- } else if (dividend->IsChange() &&
- HChange::cast(dividend)->from().IsInteger32()) {
- return HChange::cast(dividend)->value();
- }
- return NULL;
-}
HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor)
{
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Tue Jun 11 03:47:44 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Fri Jun 14 07:33:15 2013
@@ -2692,7 +2692,6 @@
LInstruction* DoRSub(HSub* instr);
static bool HasMagicNumberForDivisor(int32_t divisor);
- static HValue* SimplifiedDividendForMathFloorOfDiv(HValue* val);
static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
LInstruction* DoMathFloor(HUnaryMathOperation* instr);
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Fri Jun 14
07:23:05 2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Fri Jun 14
07:33:15 2013
@@ -1508,32 +1508,54 @@
if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?");
if (CheckFlag(kAllowUndefinedAsNaN)) stream->Add("
allow-undefined-as-nan");
}
+
+
+static HValue* SimplifiedDividendForMathFloorOfDiv(
+ HValue* dividend,
+ Representation observed_representation) {
+ // A value with an integer representation does not need to be
transformed.
+ if (dividend->representation().IsInteger32()) {
+ return dividend;
+ }
+ // A change from an integer32 can be replaced by the integer32 value.
+ if (dividend->IsChange() &&
+ 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;
+}
HValue* HUnaryMathOperation::Canonicalize() {
if (op() == kMathFloor) {
+ HValue* val = value();
+ if (val->IsChange()) val = HChange::cast(val)->value();
+
// If the input is integer32 then we replace the floor instruction
- // with its input. This happens before the representation changes are
- // introduced.
-
- // TODO(2205): The above comment is lying. All of this happens
- // *after* representation changes are introduced. We should check
- // for value->IsChange() and react accordingly if yes.
-
- if (value()->representation().IsInteger32()) return value();
+ // with its input.
+ if (val->representation().IsInteger32()) return val;
#if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_IA32) || \
defined(V8_TARGET_ARCH_X64)
- if (value()->IsDiv() && (value()->UseCount() == 1)) {
- // TODO(2038): Implement this optimization for non ARM architectures.
- HDiv* hdiv = HDiv::cast(value());
+ if (val->IsDiv() && (val->UseCount() == 1)) {
+ HDiv* hdiv = HDiv::cast(val);
HValue* left = hdiv->left();
HValue* right = hdiv->right();
// Try to simplify left and right values of the division.
- HValue* new_left =
- LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(left);
+ HValue* new_left = SimplifiedDividendForMathFloorOfDiv(
+ left, hdiv->observed_input_representation(1));
HValue* new_right =
- LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(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);
+ }
// Return if left or right are not optimizable.
if ((new_left == NULL) || (new_right == NULL)) return this;
@@ -1547,9 +1569,8 @@
!HInstruction::cast(new_right)->IsLinked()) {
HInstruction::cast(new_right)->InsertBefore(this);
}
- HMathFloorOfDiv* instr = new(block()->zone())
HMathFloorOfDiv(context(),
- new_left,
- new_right);
+ HMathFloorOfDiv* instr = new(block()->zone())
+ HMathFloorOfDiv(context(), new_left, new_right);
// Replace this HMathFloor instruction by the new HMathFloorOfDiv.
instr->InsertBefore(this);
ReplaceAllUsesWith(instr);
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Jun 14 07:16:03 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Fri Jun 14 07:33:15 2013
@@ -2985,6 +2985,15 @@
}
continue;
}
+ if (current->IsReturn()) {
+ // Drop mergeable simulates in the list. This is safe because
+ // simulates after instructions with side effects are never added
+ // to the merge list.
+ while (!mergelist.is_empty()) {
+ mergelist.RemoveLast()->DeleteAndReplaceWith(NULL);
+ }
+ continue;
+ }
// Skip the non-simulates and the first simulate.
if (!current->IsSimulate()) continue;
if (first) {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Fri Jun 14 02:02:11
2013
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Fri Jun 14 07:33:15
2013
@@ -1468,19 +1468,6 @@
return DoArithmeticT(Token::DIV, instr);
}
}
-
-
-HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue*
dividend) {
- // A value with an integer representation does not need to be
transformed.
- if (dividend->representation().IsInteger32()) {
- return dividend;
- // A change from an integer32 can be replaced by the integer32 value.
- } else if (dividend->IsChange() &&
- HChange::cast(dividend)->from().IsInteger32()) {
- return HChange::cast(dividend)->value();
- }
- return NULL;
-}
HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor)
{
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Tue Jun 4 01:28:33 2013
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Fri Jun 14 07:33:15 2013
@@ -2813,7 +2813,6 @@
HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO
- static HValue* SimplifiedDividendForMathFloorOfDiv(HValue* val);
static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
LInstruction* DoMathFloor(HUnaryMathOperation* instr);
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Fri Jun 14 02:02:11 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Fri Jun 14 07:33:15 2013
@@ -1383,19 +1383,6 @@
return DoArithmeticT(Token::DIV, instr);
}
}
-
-
-HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue*
dividend) {
- // A value with an integer representation does not need to be
transformed.
- if (dividend->representation().IsInteger32()) {
- return dividend;
- // A change from an integer32 can be replaced by the integer32 value.
- } else if (dividend->IsChange() &&
- HChange::cast(dividend)->from().IsInteger32()) {
- return HChange::cast(dividend)->value();
- }
- return NULL;
-}
HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor)
{
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h Tue Jun 4 01:28:33 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.h Fri Jun 14 07:33:15 2013
@@ -2590,7 +2590,6 @@
HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO
- static HValue* SimplifiedDividendForMathFloorOfDiv(HValue* val);
static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
LInstruction* DoMathFloor(HUnaryMathOperation* instr);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.