Mercurial > hg > graal-compiler
changeset 12751:d61e3ca7c89b
Canonicalize coversions that don't change the type.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 11 Nov 2013 17:56:52 +0100 |
parents | c61d1f1bbee0 |
children | 53f8adcbc474 |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Mon Nov 11 17:54:16 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Mon Nov 11 17:56:52 2013 +0100 @@ -233,12 +233,18 @@ @Override public Node canonical(CanonicalizerTool tool) { - if (value.isConstant()) { + if (from == to) { + return value; + } else if (value.isConstant()) { return ConstantNode.forPrimitive(evalConst(value.asConstant()), graph()); } else if (value instanceof ConvertNode) { ConvertNode other = (ConvertNode) value; if (other.isLossless() && other.to != Kind.Char) { - return graph().unique(new ConvertNode(other.from, this.to, other.value())); + if (other.from == this.to) { + return other.value(); + } else { + return graph().unique(new ConvertNode(other.from, this.to, other.value())); + } } } return this;