changeset 2978:53a8754c8eef

Canonicalize *Sub to *Add when possible
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Sat, 11 Jun 2011 13:58:51 +0200
parents 2823897b2da2
children 9dfbd92bb4b8
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerSub.java
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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) {