Commit b8aa7986 by Richard Kenner

(add[hs]i3): Only use two addq.w or subq.w instructions when...

(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
parent b686ee30
...@@ -789,7 +789,24 @@ ...@@ -789,7 +789,24 @@
"* "*
{ {
if (ADDRESS_REG_P (operands[0])) 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. */ /* moveq is faster on the 68000. */
if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_5200)) if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_5200))
#if defined(MOTOROLA) && !defined(CRDS) #if defined(MOTOROLA) && !defined(CRDS)
...@@ -2149,11 +2166,10 @@ ...@@ -2149,11 +2166,10 @@
? \"subq%.w %2,%0\" ? \"subq%.w %2,%0\"
: \"subq%.l %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. add a small integer (8 < N <= 16) to an address register.
Likewise for subqw. */ Likewise for subqw. */
if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 if (TARGET_CPU32 && ADDRESS_REG_P (operands[0]))
&& ADDRESS_REG_P (operands[0]))
{ {
if (INTVAL (operands[2]) > 8 if (INTVAL (operands[2]) > 8
&& INTVAL (operands[2]) <= 16) && INTVAL (operands[2]) <= 16)
...@@ -2175,7 +2191,7 @@ ...@@ -2175,7 +2191,7 @@
&& INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) >= -0x8000
&& INTVAL (operands[2]) < 0x8000) && INTVAL (operands[2]) < 0x8000)
{ {
if (!TARGET_5200) if (TARGET_68040)
return \"add%.w %2,%0\"; return \"add%.w %2,%0\";
else else
#ifdef MOTOROLA #ifdef MOTOROLA
...@@ -2203,9 +2219,9 @@ ...@@ -2203,9 +2219,9 @@
"!TARGET_5200" "!TARGET_5200"
"* "*
{ {
#ifndef NO_ADDSUB_Q
if (GET_CODE (operands[2]) == CONST_INT) if (GET_CODE (operands[2]) == CONST_INT)
{ {
#ifndef NO_ADDSUB_Q
/* If the constant would be a negative number when interpreted as /* If the constant would be a negative number when interpreted as
HImode, make it negative. This is usually, but not always, done HImode, make it negative. This is usually, but not always, done
elsewhere in the compiler. First check for constants out of range, elsewhere in the compiler. First check for constants out of range,
...@@ -2225,11 +2241,10 @@ ...@@ -2225,11 +2241,10 @@
- INTVAL (operands[2])); - INTVAL (operands[2]));
return \"subq%.w %2,%0\"; 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. add a small integer (8 < N <= 16) to an address register.
Likewise for subqw. */ Likewise for subqw. */
if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 if (TARGET_CPU32 && ADDRESS_REG_P (operands[0]))
&& ADDRESS_REG_P (operands[0]))
{ {
if (INTVAL (operands[2]) > 8 if (INTVAL (operands[2]) > 8
&& INTVAL (operands[2]) <= 16) && INTVAL (operands[2]) <= 16)
...@@ -2246,8 +2261,14 @@ ...@@ -2246,8 +2261,14 @@
return \"subq%.w %#8,%0\;subq%.w %2,%0\"; return \"subq%.w %#8,%0\;subq%.w %2,%0\";
} }
} }
}
#endif #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\"; return \"add%.w %2,%0\";
}") }")
...@@ -2264,9 +2285,9 @@ ...@@ -2264,9 +2285,9 @@
"!TARGET_5200" "!TARGET_5200"
"* "*
{ {
#ifndef NO_ADDSUB_Q
if (GET_CODE (operands[1]) == CONST_INT) if (GET_CODE (operands[1]) == CONST_INT)
{ {
#ifndef NO_ADDSUB_Q
/* If the constant would be a negative number when interpreted as /* If the constant would be a negative number when interpreted as
HImode, make it negative. This is usually, but not always, done HImode, make it negative. This is usually, but not always, done
elsewhere in the compiler. First check for constants out of range, elsewhere in the compiler. First check for constants out of range,
...@@ -2286,11 +2307,10 @@ ...@@ -2286,11 +2307,10 @@
- INTVAL (operands[1])); - INTVAL (operands[1]));
return \"subq%.w %1,%0\"; 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. add a small integer (8 < N <= 16) to an address register.
Likewise for subqw. */ Likewise for subqw. */
if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 if (TARGET_CPU32 && ADDRESS_REG_P (operands[0]))
&& ADDRESS_REG_P (operands[0]))
{ {
if (INTVAL (operands[1]) > 8 if (INTVAL (operands[1]) > 8
&& INTVAL (operands[1]) <= 16) && INTVAL (operands[1]) <= 16)
...@@ -2307,8 +2327,14 @@ ...@@ -2307,8 +2327,14 @@
return \"subq%.w %#8,%0\;subq%.w %1,%0\"; return \"subq%.w %#8,%0\;subq%.w %1,%0\";
} }
} }
}
#endif #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\"; return \"add%.w %1,%0\";
}") }")
...@@ -2319,9 +2345,9 @@ ...@@ -2319,9 +2345,9 @@
"!TARGET_5200" "!TARGET_5200"
"* "*
{ {
#ifndef NO_ADDSUB_Q
if (GET_CODE (operands[1]) == CONST_INT) if (GET_CODE (operands[1]) == CONST_INT)
{ {
#ifndef NO_ADDSUB_Q
/* If the constant would be a negative number when interpreted as /* If the constant would be a negative number when interpreted as
HImode, make it negative. This is usually, but not always, done HImode, make it negative. This is usually, but not always, done
elsewhere in the compiler. First check for constants out of range, elsewhere in the compiler. First check for constants out of range,
...@@ -2341,11 +2367,10 @@ ...@@ -2341,11 +2367,10 @@
- INTVAL (operands[1])); - INTVAL (operands[1]));
return \"subq%.w %1,%0\"; 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. add a small integer (8 < N <= 16) to an address register.
Likewise for subqw. */ Likewise for subqw. */
if (TARGET_68020 && !TARGET_68040 && !TARGET_68060 if (TARGET_CPU32 && ADDRESS_REG_P (operands[0]))
&& ADDRESS_REG_P (operands[0]))
{ {
if (INTVAL (operands[1]) > 8 if (INTVAL (operands[1]) > 8
&& INTVAL (operands[1]) <= 16) && INTVAL (operands[1]) <= 16)
...@@ -2362,8 +2387,14 @@ ...@@ -2362,8 +2387,14 @@
return \"subq%.w %#8,%0\;subq%.w %1,%0\"; return \"subq%.w %#8,%0\;subq%.w %1,%0\";
} }
} }
}
#endif #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\"; return \"add%.w %1,%0\";
}") }")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment