This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
store motion breaks asm outputs to memory
- To: gcc-patches at gcc dot gnu dot org, amacleod at redhat dot com
- Subject: store motion breaks asm outputs to memory
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 14 Apr 2001 12:29:30 -0300
- Organization: GCC Team, Red Hat
The following program:
int *p;
int f () {
int ret;
asm volatile ("%0" : "=m" (ret));
if (ret != 0)
*p = ret;
return ret;
}
fails to compile with -mam33 -O2 on mn10300-elf. The problem is that
the careful addressof expansion of the asm output operand, that would
have allowed it to compile, is annihilated by store motion: it
replaces with a pseudo the dest stack slot ``copied from'' the
ASM_OPERANDS. The pseudo ends up being assigned to d0 by global
alloc, and reload barfs, complaining of inconsistent operand
constraints in the asm.
Here's a fix. The first hunk is enough to fix the problem, but I
couldn't convince myself the second shouldn't remain. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* gcse.c (compute_ld_motion_mems): ASM outputs aren't moveable.
(find_moveable_store): Likewise.
Index: gcc/gcse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcse.c,v
retrieving revision 1.125
diff -u -p -r1.125 gcse.c
--- gcc/gcse.c 2001/04/11 18:22:46 1.125
+++ gcc/gcse.c 2001/04/14 15:21:19
@@ -6264,7 +6264,8 @@ compute_ld_motion_mems ()
{
ptr = ldst_entry (dest);
- if (GET_CODE (src) != MEM)
+ if (GET_CODE (src) != MEM
+ && GET_CODE (src) != ASM_OPERANDS)
ptr->stores = alloc_INSN_LIST (insn, ptr->stores);
else
ptr->invalid = 1;
@@ -6521,7 +6522,8 @@ find_moveable_store (insn)
struct ls_expr * ptr;
rtx dest = PATTERN (insn);
- if (GET_CODE (dest) != SET)
+ if (GET_CODE (dest) != SET
+ || GET_CODE (SET_SRC (dest)) == ASM_OPERANDS)
return;
dest = SET_DEST (dest);
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me