Reviewers: Weiliang,

Message:
wl.
please review and commit this patch.
thanks.

Description:
X87: Fixed flooring division by a power of 2, once again...

port r21769

original message:
    Avoid right shifts by zero bits: On ARM it actually means shifting by
    32 bits (correctness issue) and on other platforms they are useless
    (performance issue). This is fix for the fix in r20544.

    BUG=v8:3259
    LOG=y

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

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

Affected files (+8, -5 lines):
  M     src/x87/lithium-codegen-x87.cc


Index: src/x87/lithium-codegen-x87.cc
===================================================================
--- src/x87/lithium-codegen-x87.cc      (revision 21827)
+++ src/x87/lithium-codegen-x87.cc      (working copy)
@@ -1546,14 +1546,17 @@
     DeoptimizeIf(zero, instr->environment());
   }

-  if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
-    __ sar(dividend, shift);
+  // Dividing by -1 is basically negation, unless we overflow.
+  if (divisor == -1) {
+    if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
+      DeoptimizeIf(overflow, instr->environment());
+    }
     return;
   }

-  // Dividing by -1 is basically negation, unless we overflow.
-  if (divisor == -1) {
-    DeoptimizeIf(overflow, instr->environment());
+  // If the negation could not overflow, simply shifting is OK.
+  if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
+    __ sar(dividend, shift);
     return;
   }



--
--
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