# HG changeset patch # User Stefan Anzinger # Date 1424544502 -3600 # Node ID 34c0014aaf5bc73c2eb2c4e3610d6d7f34d78148 # Parent 8fc336a04d7752d78d4b01073defea69bb1cf95a Merge diff -r 8fc336a04d77 -r 34c0014aaf5b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/MulNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/MulNode.java Fri Feb 20 22:22:55 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/MulNode.java Sat Feb 21 19:48:22 2015 +0100 @@ -77,33 +77,8 @@ if (c instanceof PrimitiveConstant && ((PrimitiveConstant) c).getKind().isNumericInteger()) { long i = ((PrimitiveConstant) c).asLong(); - boolean signFlip = false; - if (i < 0) { - i = -i; - signFlip = true; - } - if (i > 0) { - ValueNode mulResult = null; - long bit1 = i & -i; - long bit2 = i - bit1; - bit2 = bit2 & -bit2; // Extract 2nd bit - if (CodeUtil.isPowerOf2(i)) { // - mulResult = new LeftShiftNode(forX, ConstantNode.forInt(CodeUtil.log2(i))); - } else if (bit2 + bit1 == i) { // We can work with two shifts and add - ValueNode shift1 = new LeftShiftNode(forX, ConstantNode.forInt(CodeUtil.log2(bit1))); - ValueNode shift2 = new LeftShiftNode(forX, ConstantNode.forInt(CodeUtil.log2(bit2))); - mulResult = new AddNode(shift1, shift2); - } else if (CodeUtil.isPowerOf2(i + 1)) { // shift and subtract - ValueNode shift1 = new LeftShiftNode(forX, ConstantNode.forInt(CodeUtil.log2(i + 1))); - mulResult = new SubNode(shift1, forX); - } - if (mulResult != null) { - if (signFlip) { - return new NegateNode(mulResult); - } else { - return mulResult; - } - } + if (i > 0 && CodeUtil.isPowerOf2(i)) { + return new LeftShiftNode(forX, ConstantNode.forInt(CodeUtil.log2(i))); } }