Reviewers: Sven Panne,

Message:
Easy one... PTAL

Description:
Reduce number of conditional jumps generated for standard integer division.

Please review this at https://codereview.chromium.org/239433011/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+18, -12 lines):
  M src/ia32/lithium-codegen-ia32.cc
  M src/x64/lithium-codegen-x64.cc


Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index fad23ade32c6e6c22ff6bd70461a9921756be0da..0ea02803a420dcde6b8986fc6520944279a3b3ef 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -1570,20 +1570,23 @@ void LCodeGen::DoDivI(LDivI* instr) {
   ASSERT(!divisor.is(edx));

   // Check for x / 0.
+  Label dividend_not_zero;
   if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
+    // Check for (0 / -x) that will produce negative zero.
+    if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
+      __ test(dividend, dividend);
+      __ j(not_zero, &dividend_not_zero, Label::kNear);
+    }
     __ test(divisor, divisor);
-    DeoptimizeIf(zero, instr->environment());
-  }
-
+    DeoptimizeIf(less_equal, instr->environment());
+  } else if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
   // Check for (0 / -x) that will produce negative zero.
-  if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
-    Label dividend_not_zero;
     __ test(dividend, dividend);
     __ j(not_zero, &dividend_not_zero, Label::kNear);
     __ test(divisor, divisor);
     DeoptimizeIf(sign, instr->environment());
-    __ bind(&dividend_not_zero);
   }
+  __ bind(&dividend_not_zero);

   // Check for (kMinInt / -1).
   if (hdiv->CheckFlag(HValue::kCanOverflow)) {
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index 44651cb942b7ac3063d018f04d71cf2cfe7f6806..c3e76f5abe8f3ddbc863cb31f4bbd7bb4730d534 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -1351,20 +1351,23 @@ void LCodeGen::DoDivI(LDivI* instr) {
   ASSERT(!divisor.is(rdx));

   // Check for x / 0.
+  Label dividend_not_zero;
   if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
+    // Check for (0 / -x) that will produce negative zero.
+    if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
+      __ testl(dividend, dividend);
+      __ j(not_zero, &dividend_not_zero, Label::kNear);
+    }
     __ testl(divisor, divisor);
-    DeoptimizeIf(zero, instr->environment());
-  }
-
+    DeoptimizeIf(less_equal, instr->environment());
+  } else if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
   // Check for (0 / -x) that will produce negative zero.
-  if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
-    Label dividend_not_zero;
     __ testl(dividend, dividend);
     __ j(not_zero, &dividend_not_zero, Label::kNear);
     __ testl(divisor, divisor);
     DeoptimizeIf(sign, instr->environment());
-    __ bind(&dividend_not_zero);
   }
+  __ bind(&dividend_not_zero);

   // Check for (kMinInt / -1).
   if (hdiv->CheckFlag(HValue::kCanOverflow)) {


--
--
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/d/optout.

Reply via email to