[PATCH] Prefer reg as first operand in commutative operator

Paulo J. Matos paulo@matos-sorge.com
Tue Feb 14 07:40:00 GMT 2012


Hi,

This patch was submitted as part of PR 52235.
It increases the preference of a register for first operand of a 
commutative operator.

2012-02-13 Paulo Matos <paulo.matos@csr.com>
	* gcc/rtlanal.c: Increase preference of a register for the
	first operand in a commutative operator.

--- gcc46/gcc/rtlanal.c	(gcc 4.6.2)
+++ gcc46/gcc/rtlanal.c	(working copy)
@@ -3047,11 +3047,11 @@

    /* Constants always come the second operand.  Prefer "nice" 
constants.  */
    if (code == CONST_INT)
+    return -9;
+  if (code == CONST_DOUBLE)
      return -8;
-  if (code == CONST_DOUBLE)
-    return -7;
    if (code == CONST_FIXED)
-    return -7;
+    return -8;
    op = avoid_constant_pool_reference (op);
    code = GET_CODE (op);

@@ -3059,26 +3059,28 @@
      {
      case RTX_CONST_OBJ:
        if (code == CONST_INT)
+        return -7;
+      if (code == CONST_DOUBLE)
          return -6;
-      if (code == CONST_DOUBLE)
-        return -5;
        if (code == CONST_FIXED)
-        return -5;
-      return -4;
+        return -6;
+      return -5;

      case RTX_EXTRA:
        /* SUBREGs of objects should come second.  */
        if (code == SUBREG && OBJECT_P (SUBREG_REG (op)))
-        return -3;
+        return -4;
        return 0;

      case RTX_OBJ:
        /* Complex expressions should be the first, so decrease priority
           of objects.  Prefer pointer objects over non pointer objects.  */
-      if ((REG_P (op) && REG_POINTER (op))
-	  || (MEM_P (op) && MEM_POINTER (op)))
-	return -1;
-      return -2;
+      if(REG_P(op))
+          return -1;
+      else if ((REG_P (op) && REG_POINTER (op))
+               || (MEM_P (op) && MEM_POINTER (op)))
+          return -2;
+      return -3;

      case RTX_COMM_ARITH:
        /* Prefer operands that are themselves commutative to be first.

-- 
PMatos



More information about the Gcc-patches mailing list