# HG changeset patch # User Gilles Duboscq # Date 1307793531 -7200 # Node ID 53a8754c8eef6cc32bf1c8b8969de5a9006c294e # Parent 2823897b2da23d1e4a0623ba065c2a10341b5d31 Canonicalize *Sub to *Add when possible diff -r 2823897b2da2 -r 53a8754c8eef graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerSub.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerSub.java Fri Jun 10 16:53:34 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerSub.java Sat Jun 11 13:58:51 2011 +0200 @@ -82,6 +82,12 @@ if (c == 0) { return x; } + if (kind == CiKind.Int) { + return new IntegerAdd(kind, x, Constant.forInt((int) -c, graph), graph); + } else { + assert kind == CiKind.Long; + return new IntegerAdd(kind, x, Constant.forLong(-c, graph), graph); + } } else if (x.isConstant()) { long c = x.asConstant().asLong(); if (c == 0) {