This is the mail archive of the gcc@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]
Other format: [Raw text]

[m68k] asm regression with 3.3/3.4/3.5


Hello!

The following testcase case fails with GCC 3.3 and later when compiled with
-O. GCC 2.95.2 generates working code. I think its a GCC3 bug. Initially the
bug was noticed with m68k-amigaos. However, a 3.3 m68k-linux cross-compiler
shows the same bug (there A6 has to be replaced with eg. A5 in the testcase;
with m68k-amigaos A6 is a free register and A5 is the framepointer)
For me this is a serious bug which could be triggered at random places.
I would appriciate any help finding this bug.

-- cut --
#define osfunc(v1,v2)					\
({							\
 int _v1 = (v1);					\
 int _v2 = (v2);					\
 {							\
   register int _d0 __asm("d0") = 0xDEADBEAF;		\
   register int _d1 __asm("d1") = 0xDEADBEAF;		\
   register int _a0 __asm("a0") = 0xDEADBEAF;		\
   register int _a1 __asm("a1") = 0xDEADBEAF;		\
   register void *const _bn __asm("a6") = (base);	\
   register int __v1 __asm("d0") = (_v1);		\
   register int __v2 __asm("a0") = (_v2);		\
   __asm volatile ("jsr a6@(-0x84:W)"			\
   : "=r" (_d0), "=r" (_d1), "=r" (_a0), "=r" (_a1)	\
   : "r" (_bn), "rf" (__v1), "rf" (__v2)		\
   : "fp0", "fp1", "cc", "memory");			\
  }							\
})

void bar(void);

void foo(void *base) {
  for (;;) {
    osfunc(1,2);
    bar();
  }
}
-- cut --

GCC 2.95.2 generates:

_foo:	movel a6,sp@-
	movel d2,sp@-
	movel sp@(12),d2
L3:	movel d2,a6
	moveq #1,d0
	movew #2,a0
#APP
	jsr a6@(-0x84:W)
#NO_APP
	jbsr _bar
	jra L3

but GCC 3.3 and all later versions generate:

_foo:	movel d2,sp@-
	movel sp@(8),d2
L2:	moveq #1,d0
	movew #2,a0
#APP
	jsr a6@(-0x84:W)
#NO_APP
	jbsr _bar
	jra L2

GCC3 "forgets" to load A6 and it doesn't save the register at all. It seems
that GCC3 thinks A6 isn't used at all. If the call to bar() is removed, the
generated code is correct and A6 is used as expected:

_foo:	movel a6,sp@-
	movel sp@(8),a6
L2:	moveq #1,d0
	movew #2,a0
#APP
	jsr a6@(-0x84:W)
#NO_APP
	jra L2

The testcase was additionally compiled with -fomit-frame-pointer to have
less instructions to post.

Gunther


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