Mercurial > hg > truffle
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerMulNode.java @ 11883:673f93db4adc
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 02 Oct 2013 21:40:29 +0200 |
parents | da9db8331658 04b039d82e86 |
children | 34c07ef28bc9 |
comparison
equal
deleted
inserted
replaced
11882:51059863da73 | 11883:673f93db4adc |
---|---|
35 public IntegerMulNode(Kind kind, ValueNode x, ValueNode y) { | 35 public IntegerMulNode(Kind kind, ValueNode x, ValueNode y) { |
36 super(kind, x, y); | 36 super(kind, x, y); |
37 } | 37 } |
38 | 38 |
39 @Override | 39 @Override |
40 public Constant evalConst(Constant... inputs) { | |
41 assert inputs.length == 2; | |
42 return Constant.forIntegerKind(kind(), inputs[0].asLong() * inputs[1].asLong(), null); | |
43 } | |
44 | |
45 @Override | |
40 public Node canonical(CanonicalizerTool tool) { | 46 public Node canonical(CanonicalizerTool tool) { |
41 if (x().isConstant() && !y().isConstant()) { | 47 if (x().isConstant() && !y().isConstant()) { |
42 return graph().unique(new IntegerMulNode(kind(), y(), x())); | 48 return graph().unique(new IntegerMulNode(kind(), y(), x())); |
43 } | 49 } |
44 if (x().isConstant()) { | 50 if (x().isConstant()) { |
45 if (kind() == Kind.Int) { | 51 return ConstantNode.forPrimitive(evalConst(x().asConstant(), y().asConstant()), graph()); |
46 return ConstantNode.forInt(x().asConstant().asInt() * y().asConstant().asInt(), graph()); | |
47 } else { | |
48 assert kind() == Kind.Long; | |
49 return ConstantNode.forLong(x().asConstant().asLong() * y().asConstant().asLong(), graph()); | |
50 } | |
51 } else if (y().isConstant()) { | 52 } else if (y().isConstant()) { |
52 long c = y().asConstant().asLong(); | 53 long c = y().asConstant().asLong(); |
53 if (c == 1) { | 54 if (c == 1) { |
54 return x(); | 55 return x(); |
55 } | 56 } |