Partial roll-back of r2210; converting a div to a shift breaks for negative numerators. That's what I get for not writing a unit test.
Found by: jeffreyconroy@yahoo.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2295 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
index 2d24c1f..7eedecc 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
@@ -140,13 +140,6 @@
evalConcat(lhs, rhs, ctx);
}
break;
- case DIV:
- case ASG_DIV:
- if (x.getType() != program.getTypePrimitiveFloat()
- && x.getType() != program.getTypePrimitiveDouble()) {
- divToShift(x, lhs, rhs, ctx);
- }
- break;
default:
if (op.isAssignment()) {
lvalues.remove(lhs);
@@ -700,40 +693,6 @@
return true;
}
- private void divToShift(JBinaryOperation x, JExpression lhs,
- JExpression rhs, Context ctx) {
- long divisor;
- if (rhs instanceof JIntLiteral) {
- divisor = ((JIntLiteral) rhs).getValue();
- } else if (rhs instanceof JLongLiteral) {
- divisor = ((JLongLiteral) rhs).getValue();
- } else {
- return;
- }
-
- if (divisor == 1) {
- ctx.replaceMe(lhs);
- return;
- } else if (divisor == -1 && !x.getOp().isAssignment()) {
- JPrefixOperation negOp = new JPrefixOperation(program,
- x.getSourceInfo(), JUnaryOperator.NEG, lhs);
- ctx.replaceMe(negOp);
- return;
- }
-
- if (divisor > 1 && divisor == Long.highestOneBit(divisor)) {
- // It's a power of two, convert to a shift operation.
- int shift = Long.numberOfTrailingZeros(divisor);
- JBinaryOperator op = x.getOp().isAssignment() ? JBinaryOperator.ASG_SHR
- : JBinaryOperator.SHR;
- JBinaryOperation binOp = new JBinaryOperation(program,
- x.getSourceInfo(), lhs.getType(), op, lhs,
- program.getLiteralInt(shift));
- ctx.replaceMe(binOp);
- return;
- }
- }
-
private void evalConcat(JExpression lhs, JExpression rhs, Context ctx) {
if (lhs instanceof JValueLiteral && rhs instanceof JValueLiteral) {
Object lhsObj = ((JValueLiteral) lhs).getValueObj();