This is the mail archive of the gcc-help@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]

Re: Over optimisation


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


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