This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Over optimisation
- To: help-gcc at gnu dot org
- Subject: Re: Over optimisation
- From: Veksler Michael <mveksler at technion dot ac dot il>
- Date: 3 Oct 1999 16:40:36 GMT
- Newsgroups: gnu.gcc.help
- Organization: Technion, Israel Institute of Technology
- References: <01bf05ce$5ca544c0$4f7fa890@us1.lincoln.msl.mitel.com>
- Xref: wodc7nx0 gnu.gcc.help:1255
Andrew Davies <Andrew_Davies@Xmitel.com> wrote:
> Hi,
> I have a problem with the optimiser. When I compile the following test
> loop:
>
> do {
> test = regbase->utx & 0x8000;
> }while(test == 0x0000);
[snip]
> I think the optimiser is assuming the line inside the do while loop is
> static and therefore removes it from the loop. As a result it gets stuck.
> Anyone know how to solve this without turning the optimiser off?
The optimizer is right, unless you declare regbase volatile. Otherwise,
the compiler has a right to assume that no one is modifying 'regbase'.
Michael