X87: Fixed flooring division by a power of 2, once again...
authorweiliang.lin@intel.com <weiliang.lin@intel.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 13 Jun 2014 07:03:11 +0000 (07:03 +0000)
committerweiliang.lin@intel.com <weiliang.lin@intel.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 13 Jun 2014 07:03:11 +0000 (07:03 +0000)
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
R=weiliang.lin@intel.com

Review URL: https://codereview.chromium.org/330133004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21829 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/x87/lithium-codegen-x87.cc

index 1e9168d..dab8768 100644 (file)
@@ -1546,14 +1546,17 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) {
     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;
   }