Mercurial > hg > truffle
diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerSubNode.java @ 14707:6ce6c4ccba8f
initial support for memory arithmetic on x86
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 20 Mar 2014 15:57:03 -0700 |
parents | 9738280055ce |
children | fbae9be45c95 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerSubNode.java Thu Mar 20 13:41:32 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerSubNode.java Thu Mar 20 15:57:03 2014 -0700 @@ -26,6 +26,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -97,7 +98,9 @@ if (reassociated != this) { return reassociated; } - if (c < 0) { + if (c < 0 || ((IntegerStamp) StampFactory.forKind(y().getKind())).contains(-c)) { + // Adding a negative is more friendly to the backend since adds are + // commutative, so prefer add when it fits. return IntegerArithmeticNode.add(graph(), x(), ConstantNode.forIntegerStamp(stamp(), -c, graph())); } } else if (x().isConstant()) { @@ -117,4 +120,13 @@ public void generate(ArithmeticLIRGenerator gen) { gen.setResult(this, gen.emitSub(gen.operand(x()), gen.operand(y()))); } + + @Override + public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) { + Value result = gen.emitSubMemory(x(), y(), access); + if (result != null) { + gen.setResult(this, result); + } + return result != null; + } }