This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs-1.0.3: mc68k/mcf5200 codegen bug when optimizing


At 12:25 01.07.98 , Rune Skårsmoen wrote:
>
>target=m68k-coff, crosscompiling (from both sun/solaris2 and 
>{m68k|i586}-linux)
>
>egcs-1.0.2 and egcs-1.0.3(a)
>
>The following function generates illegal opcodes for ColdFire when 
>optimizing.  compiler call:  m68k-coff-gcc -O2 -m5200 -S func.c
>
>
>
>short
>func(void)
>{
>	unsigned char x, y;
>
>	return  y | x << 8;
>}
>
>
>This doesn't happen when func() returns an int instead of a short, or when
>x and y are signed.
>
>
>
>	.file	"func.c"
>gcc2_compiled.:
>__gnu_compiled_c:
>.text
>	.even
>.globl func
>func:
>	link.w %a6,#0
>	and.w #0xFF,%d0			| illegal for coldfire
>	and.w #0xFF,%d1			| ditto
>	lsl.l #8,%d1
>	or.l %d1,%d0
>	ext.l %d0
>	unlk %a6
>	rts
>
>
>
>Is this enough information for a fix?


This little patch helps for the snapshots, I think it should also apply to
1.0.3. Probably some of the other lines below should be modified too.

Index: m68k.md
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/m68k/m68k.md,v
retrieving revision 1.16
diff -u -r1.16 m68k.md
--- m68k.md     1998/05/23 23:14:57     1.16
+++ m68k.md     1998/07/01 14:03:17
@@ -1584,7 +1584,7 @@
     {
       if (GET_CODE (operands[1]) == REG
          && REGNO (operands[0]) == REGNO (operands[1]))
-       return \"and%.w %#0xFF,%0\";
+       return (!TARGET_5200 ? \"and%.w %#0xFF,%0\" : \"and%.l %#0xFF,%0\");
       if (reg_mentioned_p (operands[0], operands[1]))
         return \"move%.b %1,%0\;and%.w %#0xFF,%0\";
       return \"clr%.w %0\;move%.b %1,%0\";





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]