[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Optimisation bug in gcc 4 ?



Patrice Mandin wrote:
with gcc 4.4.2 (starting at -O1 level), it assumes the field has a
constant value, optimizes the test by removing it, and the code that
follows, thus also wiping out entirely the function myvidix_func from
the generated assembly code

Sorry, I can't reproduce your bug, either with gcc 4.4.2 or 4.5.0 (with my own patches).

Look at the definition of trap_14_wl() in /usr/.../include/mint/osbind.h:
#define trap_14_wllw(n, a, b, c)					\
__extension__								\
({									\
	register long retvalue __asm__("d0");				\
	long  _a = (long) (a);						\
	long  _b = (long) (b);						\
	short _c = (short)(c);						\
	    								\
	__asm__ volatile						\
	(								\
		"movw	%4,sp@-\n\t"					\
		"movl	%3,sp@-\n\t"					\
		"movl	%2,sp@-\n\t"					\
		"movw	%1,sp@-\n\t"					\
		"trap	#14\n\t"					\
		"lea	sp@(12),sp"					\
	: "=r"(retvalue)			/* outputs */		\
	: "g"(n), "r"(_a), "r"(_b), "r"(_c)       /* inputs  */		\
	: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */	\
	  AND_MEMORY							\
	);								\
	retvalue;							\
})

The important word is "volatile" after __asm__. It prevents the assembler code block to be dropped if the compiler thinks it is useless. If I remove the volatile keyword the code disappears with some tests. But when volatile is present, it always work.

There is something special on your system, I can't understand why it fails. Except if you have messed your osbind.h file, which is probably not the case. Someone else should try the testcase.

--
Vincent Rivière