(add[hs]i3): Only use two addq.w or subq.w instructions when...
authorRichard Kenner <kenner@gcc.gnu.org>
Tue, 10 Dec 1996 22:13:04 +0000 (17:13 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Tue, 10 Dec 1996 22:13:04 +0000 (17:13 -0500)
(add[hs]i3): Only use two addq.w or subq.w instructions
when adding or subtracting constants 8 < N < 16 on TARGET_CPU32.
Use lea instead of add.w when adding 16 bit constants to address
registers on all but TARGET_68040.

From-SVN: r13265

gcc/config/m68k/m68k.md

index 01dde67ec4743837da11a15a61ee347452e6c205..61e4a663e9c763130b0ea620e745d3203f6bd312 100644 (file)
   "*
 {
   if (ADDRESS_REG_P (operands[0]))
-    return \"sub%.l %0,%0\";
+    {
+      /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
+      if (!TARGET_68040 && !TARGET_68060)
+       return \"sub%.l %0,%0\";
+      else
+       {
+#ifdef MOTOROLA
+#ifdef SGS
+         /* Many SGS assemblers croak on size specifiers for constants. */
+         return \"lea 0,%0\";
+#else
+         return \"lea 0.w,%0\";
+#endif
+#else
+         return \"lea 0:w,%0\";
+#endif
+       }
+    }
   /* moveq is faster on the 68000.  */
   if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_5200))
 #if defined(MOTOROLA) && !defined(CRDS)
                  ? \"subq%.w %2,%0\"
                  : \"subq%.l %2,%0\");
        }
-      /* On the 68020 it is faster to use two addqw instructions to
+      /* On the CPU32 it is faster to use two addqw instructions to
         add a small integer (8 < N <= 16) to an address register.
         Likewise for subqw. */
-      if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 
-          && ADDRESS_REG_P (operands[0]))
+      if (TARGET_CPU32 && ADDRESS_REG_P (operands[0]))
        {
          if (INTVAL (operands[2]) > 8
              && INTVAL (operands[2]) <= 16)
          && INTVAL (operands[2]) >= -0x8000
          && INTVAL (operands[2]) < 0x8000)
        {
-         if (!TARGET_5200)
+         if (TARGET_68040)
            return \"add%.w %2,%0\";
          else
 #ifdef MOTOROLA  
   "!TARGET_5200"
   "*
 {
-#ifndef NO_ADDSUB_Q
   if (GET_CODE (operands[2]) == CONST_INT)
     {
+#ifndef NO_ADDSUB_Q
       /* If the constant would be a negative number when interpreted as
         HImode, make it negative.  This is usually, but not always, done
         elsewhere in the compiler.  First check for constants out of range,
                                 - INTVAL (operands[2]));
          return \"subq%.w %2,%0\";
        }
-      /* On the 68020 it is faster to use two addqw instructions to
+      /* On the CPU32 it is faster to use two addqw instructions to
         add a small integer (8 < N <= 16) to an address register.  
         Likewise for subqw. */
-      if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 
-          && ADDRESS_REG_P (operands[0]))
+      if (TARGET_CPU32 && ADDRESS_REG_P (operands[0]))
        {
          if (INTVAL (operands[2]) > 8
              && INTVAL (operands[2]) <= 16)
              return \"subq%.w %#8,%0\;subq%.w %2,%0\";
            }
        }
-    }
 #endif
+      if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
+#ifdef MOTOROLA  
+           return \"lea (%c2,%0),%0\";
+#else
+           return \"lea %0@(%c2),%0\";
+#endif
+    }
   return \"add%.w %2,%0\";
 }")
 
   "!TARGET_5200"
   "*
 {
-#ifndef NO_ADDSUB_Q
   if (GET_CODE (operands[1]) == CONST_INT)
     {
+#ifndef NO_ADDSUB_Q
       /* If the constant would be a negative number when interpreted as
         HImode, make it negative.  This is usually, but not always, done
         elsewhere in the compiler.  First check for constants out of range,
                                 - INTVAL (operands[1]));
          return \"subq%.w %1,%0\";
        }
-      /* On the 68020 it is faster to use two addqw instructions to
+      /* On the CPU32 it is faster to use two addqw instructions to
         add a small integer (8 < N <= 16) to an address register. 
         Likewise for subqw. */
-      if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 
-          && ADDRESS_REG_P (operands[0]))
+      if (TARGET_CPU32 && ADDRESS_REG_P (operands[0]))
        {
          if (INTVAL (operands[1]) > 8
              && INTVAL (operands[1]) <= 16)
              return \"subq%.w %#8,%0\;subq%.w %1,%0\";
            }
        }
-    }
 #endif
+      if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
+#ifdef MOTOROLA  
+           return \"lea (%c1,%0),%0\";
+#else
+           return \"lea %0@(%c1),%0\";
+#endif
+    }
   return \"add%.w %1,%0\";
 }")
 
   "!TARGET_5200"
   "*
 {
-#ifndef NO_ADDSUB_Q
   if (GET_CODE (operands[1]) == CONST_INT)
     {
+#ifndef NO_ADDSUB_Q
       /* If the constant would be a negative number when interpreted as
         HImode, make it negative.  This is usually, but not always, done
         elsewhere in the compiler.  First check for constants out of range,
                                 - INTVAL (operands[1]));
          return \"subq%.w %1,%0\";
        }
-      /* On the 68020 it is faster to use two addqw instructions to
+      /* On the CPU32 it is faster to use two addqw instructions to
         add a small integer (8 < N <= 16) to an address register.
         Likewise for subqw. */
-      if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 
-          && ADDRESS_REG_P (operands[0])) 
+      if (TARGET_CPU32 && ADDRESS_REG_P (operands[0])) 
        {
          if (INTVAL (operands[1]) > 8
              && INTVAL (operands[1]) <= 16)
              return \"subq%.w %#8,%0\;subq%.w %1,%0\";
            }
        }
-    }
 #endif
+      if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
+#ifdef MOTOROLA  
+           return \"lea (%c1,%0),%0\";
+#else
+           return \"lea %0@(%c1),%0\";
+#endif
+    }
   return \"add%.w %1,%0\";
 }")