This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] m68k: fix builtins/memset.c
- From: Roman Zippel <zippel at linux-m68k dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Jul 2004 19:55:56 +0200 (CEST)
- Subject: [PATCH] m68k: fix builtins/memset.c
Hi,
This patch fixes builtins/memset.c, which currently fails because
"memset(ptr, val, 1)" isn't optimized to a simple set operation. The
current definition of MOVE_BY_PIECES_P prevents byte moves, theoretically
it's possible to fix this also by defining a new STORE_BY_PIECES_P, but
the easier solution is to just remove MOVE_BY_PIECES_P. The reason it was
added is long gone, as bytes pushes on the stack are handled via the
pushqi1 pattern now. To make sure this stays this way I replaced the code
in output_move_qimode() which used to generate this code with an abort().
The patch is tested on linux-m68k.
bye, Roman
2004-07-13 Roman Zippel <zippel@linux-m68k.org>
* config/m68k/m68k.c (output_move_qimode): Abort on an attempt to
generate code which is generated by pushqi1 now
* config/m68k/m68k.h (MOVE_BY_PIECES_P): Remove.
Index: gcc/config/m68k/m68k.c
===================================================================
RCS file: /home/roman/src/gcc-cvs/gcc/gcc/config/m68k/m68k.c,v
retrieving revision 1.134
diff -u -r1.134 m68k.c
--- gcc/config/m68k/m68k.c 16 Jun 2004 21:53:46 -0000 1.134
+++ gcc/config/m68k/m68k.c 13 Jul 2004 09:29:21 -0000
@@ -1780,10 +1780,6 @@
const char *
output_move_qimode (rtx *operands)
{
- rtx xoperands[4];
-
- /* This is probably useless, since it loses for pushing a struct
- of several bytes a byte at a time. */
/* 68k family always modifies the stack pointer by at least 2, even for
byte pushes. The 5200 (ColdFire) does not do this. */
if (GET_CODE (operands[0]) == MEM
@@ -1791,22 +1787,8 @@
&& XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx
&& ! ADDRESS_REG_P (operands[1])
&& ! TARGET_COLDFIRE)
- {
- xoperands[1] = operands[1];
- xoperands[2]
- = gen_rtx_MEM (QImode,
- gen_rtx_PLUS (VOIDmode, stack_pointer_rtx, const1_rtx));
- /* Just pushing a byte puts it in the high byte of the halfword. */
- /* We must put it in the low-order, high-numbered byte. */
- if (!reg_mentioned_p (stack_pointer_rtx, operands[1]))
- {
- xoperands[3] = stack_pointer_rtx;
- output_asm_insn ("subq%.l #2,%3\n\tmove%.b %1,%2", xoperands);
- }
- else
- output_asm_insn ("move%.b %1,%-\n\tmove%.b %@,%2", xoperands);
- return "";
- }
+ /* generated by pushqi1 pattern now */
+ abort ();
/* clr and st insns on 68000 read before writing.
This isn't so on the 68010, but we have no TARGET_68010. */
Index: gcc/config/m68k/m68k.h
===================================================================
RCS file: /home/roman/src/gcc-cvs/gcc/gcc/config/m68k/m68k.h,v
retrieving revision 1.116
diff -u -r1.116 m68k.h
--- gcc/config/m68k/m68k.h 25 Jun 2004 05:05:16 -0000 1.116
+++ gcc/config/m68k/m68k.h 13 Jul 2004 09:29:22 -0000
@@ -675,11 +675,6 @@
On the ColdFire, sp@- in a byte insn pushes just a byte. */
#define PUSH_ROUNDING(BYTES) (TARGET_COLDFIRE ? BYTES : ((BYTES) + 1) & ~1)
-/* We want to avoid trying to push bytes. */
-#define MOVE_BY_PIECES_P(SIZE, ALIGN) \
- (move_by_pieces_ninsns (SIZE, ALIGN) < MOVE_RATIO \
- && (((SIZE) >=16 && (ALIGN) >= 16) || (TARGET_COLDFIRE)))
-
#define FIRST_PARM_OFFSET(FNDECL) 8
/* On the 68000, the RTS insn cannot pop anything.