Incorrect code produced with inline functions & assembler

Alan Modra alan@linuxcare.com.au
Fri Feb 9 18:03:00 GMT 2001


On Fri, 9 Feb 2001, Brian Hurt wrote:

> When compiled with -O2 -finline-functions the following code incorrectly
> removes the or-with-constant code.

Your code is incorrect.

>     __asm__ __volatile__ ("outl %0, %w1" : "=a" (val) : "Nd" (portno));
                                             ^^^^^^^^^^
This says %eax is an output of the asm, rather than an input.  Since %eax
is not mentioned as an input, it's quite reasonable for gcc to optimise
away code that seems to be only changing unused registers.

Alan Modra
-- 
Linuxcare.  Support for the Revolution.




More information about the Gcc-bugs mailing list