Revision: 6174
Author: [email protected]
Date: Wed Jan  5 03:25:42 2011
Log: Do not transform a/b into a * (1/b) in the parser for integer constants.

Strength reduction should be performed at a later stage. This
change avoid going to a double representation the case of
integer division.


Review URL: http://codereview.chromium.org/6044010
http://code.google.com/p/v8/source/detail?r=6174

Modified:
 /branches/bleeding_edge/src/parser.cc

=======================================
--- /branches/bleeding_edge/src/parser.cc       Tue Jan  4 04:19:55 2011
+++ /branches/bleeding_edge/src/parser.cc       Wed Jan  5 03:25:42 2011
@@ -2322,26 +2322,6 @@
             break;
         }
       }
-
-      // Convert constant divisions to multiplications for speed.
-      if (op == Token::DIV &&
-          y && y->AsLiteral() && y->AsLiteral()->handle()->IsNumber()) {
-        double y_val = y->AsLiteral()->handle()->Number();
-        int64_t y_int = static_cast<int64_t>(y_val);
-        // There are rounding issues with this optimization, but they don't
- // apply if the number to be divided with has a reciprocal that can be - // precisely represented as a floating point number. This is the case - // if the number is an integer power of 2. Negative integer powers of
-        // 2 work too, but for -2, -1, 1 and 2 we don't do the strength
-        // reduction because the inlined optimistic idiv has a reasonable
- // chance of succeeding by producing a Smi answer with no remainder.
-        if (static_cast<double>(y_int) == y_val &&
-            (IsPowerOf2(y_int) || IsPowerOf2(-y_int)) &&
-            (y_int > 2 || y_int < -2)) {
-          y = NewNumberLiteral(1 / y_val);
-          op = Token::MUL;
-        }
-      }

       // For now we distinguish between comparisons and other binary
       // operations.  (We could combine the two and get rid of this

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to