Subject: Re: Recent serial port lossage
To: Charles Hannum <Charles-Hannum@deshaw.com>
From: Randy Terbush <randy@zyzzyva.com>
List: port-i386
Date: 01/08/1996 07:45:11
In case someone has missed the discussion on this:

gcc-2.7.2 has a demonstratable optimization bug triggered at levels
above -O that can be worked around by setting -fno-strength-reduce.
Previous versions of gcc did *no* additional optimization above level
-O2. 2.7.2 now does -finline-functions at -O3, which could also be
causing some strange behavior. It would be interesting to know if
people having this problem could work around it with
'-O2 -fno-strength-reduce'.


> I've tracked this down to what I believe to be a bug in GCC 2.7.2.
> Basically, if you have code of the form:
> 
> volatile int foo;
> 
> ...
> 
> 	foo |= 0x80000000;
> 
> ...
> 
> in many (all?) cases, `gcc -O3' now compiles it as:
> 
> 	movl _foo,%e??
> 	orl $0x80000000,%e??
> 	movl %e??,_foo
> 
> rather than the obvious:
> 
> 	orl $0x80000000,_foo
> 
> This probably has something to do with pipeline scheduling on the
> Pentium, but it's not clear to me that the new behaviour, regardless
> of its relative performance, is *correct* for a `volatile' variable.
> In particular, I don't see a way to make sig_atomic_t work correctly.
> In general, it makes `volatile' nearly useless.
> 
> At any rate, I've worked around the problem in this case, but I
> wouldn't be surprised if it causes other random bugs.
> 
> If you've been having problems, please update your kernel sources
> after tonight's update, and let me know if your problems persist.