# HG changeset patch # User Gilles Duboscq # Date 1376226670 -7200 # Node ID fc86bdb42a5262d8b434e5c53e0bbc17b3e6c9f6 # Parent d876002b98e677ff9761f4f1655e151d28ed8885 Avoid repeated lowering of convert nodes on AMD64 diff -r d876002b98e6 -r fc86bdb42a52 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Sat Aug 10 22:57:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Sun Aug 11 15:11:10 2013 +0200 @@ -34,7 +34,7 @@ /** * The {@code ConvertNode} class represents a conversion between primitive types. */ -public final class ConvertNode extends FloatingNode implements Canonicalizable, LIRLowerable, Lowerable, ArithmeticOperation { +public class ConvertNode extends FloatingNode implements Canonicalizable, LIRLowerable, Lowerable, ArithmeticOperation { public static enum Op { I2L(Int, Long, true), diff -r d876002b98e6 -r fc86bdb42a52 graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertNode.java Sun Aug 11 15:11:10 2013 +0200 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.replacements.amd64; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.calc.ConvertNode.Op; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +/** + * This node has the semantics of the AMD64 conversions. It is used in the lowering of the + * ConvertNode which, on AMD64 needs a AMD64ConvertNode plus some fixup code that handles the corner + * cases that differ between AMD64 and Java. + * + */ +public class AMD64ConvertNode extends FloatingNode implements LIRLowerable, ArithmeticOperation { + + @Input private ValueNode value; + public final Op opcode; + + public AMD64ConvertNode(Op opcode, ValueNode value) { + super(StampFactory.forKind(opcode.to.getStackKind())); + this.opcode = opcode; + this.value = value; + } + + public void generate(LIRGeneratorTool gen) { + gen.setResult(this, gen.emitConvert(opcode, gen.operand(value))); + } +} diff -r d876002b98e6 -r fc86bdb42a52 graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java --- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java Sat Aug 10 22:57:50 2013 +0200 +++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java Sun Aug 11 15:11:10 2013 +0200 @@ -176,7 +176,7 @@ convert.replaceAtUsages(replacee); Arguments args = new Arguments(key); args.add("input", convert.value()); - args.add("result", convert); + args.add("result", convert.graph().unique(new AMD64ConvertNode(convert.opcode, convert.value()))); SnippetTemplate template = template(args); Debug.log("Lowering %s in %s: node=%s, template=%s, arguments=%s", convert.opcode, graph, convert, template, args);