]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c4x.c (legitimize_operands): Use rtx_cost to determine if it is worthwhile forcing...
authorMichael Hayes <m.hayes@elec.canterbury.ac.nz>
Sat, 17 Apr 1999 22:27:41 +0000 (22:27 +0000)
committerMichael Hayes <m.hayes@gcc.gnu.org>
Sat, 17 Apr 1999 22:27:41 +0000 (22:27 +0000)
* config/c4x/c4x.c (legitimize_operands): Use rtx_cost
to determine if it is worthwhile forcing a constant into a register.
* config/c4x/c4x.h (CONST_COSTS): An integer value of 255 or 65535
used with a logical and or an integer value of 16 or 24 used with
a right shift has zero cost on the C40.

From-SVN: r26529

gcc/ChangeLog
gcc/config/c4x/c4x.c
gcc/config/c4x/c4x.h

index 0ae98a6110f2e53e3bef6eb791a33b7e6fc8ca66..9411c209b2f124b740c0462129c5dd00f867ec5a 100644 (file)
@@ -1,3 +1,11 @@
+Sun Apr 18 17:24:10 1999  Michael Hayes  <m.hayes@elec.canterbury.ac.nz>
+
+       * config/c4x/c4x.c (legitimize_operands): Use rtx_cost
+       to determine if it is worthwhile forcing a constant into a register.
+       * config/c4x/c4x.h (CONST_COSTS): An integer value of 255 or 65535
+       used with a logical and or an integer value of 16 or 24 used with
+       a right shift has zero cost on the C40.
+
 Sat Apr 17 21:30:11 1999  Bernd Schmidt <crux@pool.informatik.rwth-aachen.de>
 
        * gcse.c (compute_local_properties): If setp is nonzero, clear
index 0b84e02826e6f0f10d1db62b09fe02372cfd389a..5c5690a4eaf9cfea230f7ee1245aed1a6f5ab7ce 100644 (file)
@@ -3582,6 +3582,11 @@ c4x_valid_operands (code, operands, mode, force)
 
       /* Any valid memory operand screened by src_operand is OK.  */      
     case MEM:
+#if 0
+      if (code2 != REG)
+       return 0;
+#endif
+      break;
 
       /* After CSE, any remaining (ADDRESSOF:P reg) gets converted
         into a stack slot memory address comprising a PLUS and a
@@ -3644,10 +3649,9 @@ legitimize_operands (code, operands, mode)
       if (! reload_in_progress
          && TARGET_HOIST
          && optimize > 0
-         && ((GET_CODE (operands[1]) == CONST_INT 
-              && ! c4x_J_constant (operands[1])
-              && INTVAL (operands[1]) != 0)
-             || GET_CODE (operands[1]) == CONST_DOUBLE))
+         && GET_CODE (operands[1]) == CONST_INT 
+         && preserve_subexpressions_p ()
+         && rtx_cost (operands[1], code) > 1)
        operands[1] = force_reg (mode, operands[1]);
       
       if (! reload_in_progress
@@ -3661,11 +3665,11 @@ legitimize_operands (code, operands, mode)
      opportunities.  */
   if (! reload_in_progress
       && ! ((code == PLUS || code == MINUS) && mode == Pmode)
-      && (TARGET_HOIST && optimize > 1
-       && ((GET_CODE (operands[2]) == CONST_INT 
-           && ! c4x_J_constant (operands[2])
-           && INTVAL (operands[2]) != 0)
-          || GET_CODE (operands[2]) == CONST_DOUBLE)))
+      && TARGET_HOIST
+      && optimize > 1
+      && GET_CODE (operands[2]) == CONST_INT
+      && preserve_subexpressions_p ()
+      && rtx_cost (operands[2], code) > 1)
     operands[2] = force_reg (mode, operands[2]);
 
   /* We can get better code on a C30 if we force constant shift counts
index 67ac4a0cd873f34e7afc1f1955694245cc11d113..1dc8d5c63ed70491965b4e20f62b58eaa3952f77 100644 (file)
@@ -1763,7 +1763,13 @@ extern void c4x_encode_section_info ();
    Some small integers are effectively free for the C40.  We should
    also consider if we are using the small memory model.  With
    the big memory model we require an extra insn for a constant
-   loaded from memory.  */
+   loaded from memory.  
+
+   This is used by expand_binop to decide whether to force a constant
+   into a register.  If the cost is greater than 2 and the constant
+   is used within a short loop, it gets forced into a register.  
+   Ideally, there should be some weighting as to how mnay times it is used
+   within the loop.  */
 
 #define SHIFT_CODE_P(C) ((C) == ASHIFT || (C) == ASHIFTRT || (C) == LSHIFTRT)
 
@@ -1776,6 +1782,16 @@ extern void c4x_encode_section_info ();
        case CONST_INT:                                         \
            if (c4x_J_constant (RTX))                           \
             return 0;                                          \
+          if (! TARGET_C3X                                     \
+              && OUTER_CODE == AND                             \
+               && GET_CODE (RTX) == CONST_INT                  \
+              && (INTVAL (RTX) == 255 || INTVAL (RTX) == 65535))       \
+            return 0;                                          \
+          if (! TARGET_C3X                                     \
+              && (OUTER_CODE == ASHIFTRT || OUTER_CODE == LSHIFTRT)    \
+               && GET_CODE (RTX) == CONST_INT                  \
+              && (INTVAL (RTX) == 16 || INTVAL (RTX) == 24))   \
+            return 0;                                          \
            if (TARGET_C3X && SHIFT_CODE_P (OUTER_CODE))                \
             return 3;                                          \
            if (LOGICAL_CODE_P (OUTER_CODE)                     \