Dave Korn wrote:
> Andrew Haley wrote:
>> eCos@ wrote:
> 
>>> ===============================================
>>> int *p;
>>>
>>> int main(void)
>>> {
>>>         p++;
>>>         __asm__ __volatile__ (""::);
>>>         p++;
>>> }
>>> ===============================================
> 
>>> assembly code is like: 
>>> 'addl $4, %eax'
>>> 'addl $4, %eax'
> 
>>> ===============================================
>>> int *p;
>>>
>>> int main(void)
>>> {
>>>         p++;
>>>         __asm__ __volatile__ (""::);
>>>         p+=8;
>>> }
>>> ===============================================
> 
>>> According to the assembly code, we found that gcc merge the 'p++' & 'p+=8' 
>>> and generate 'addl $36, p'
> 
>> If you really need a memory barrier, you have to use one:
> 
>   So, this is a real bug then - but it's a missed optimisation in the first
> case, not a bogus one in the second case?

Probably, but it's not a very interesting one.  For what it's worth, the
tree dumps are identical right up to the very last tree optimization pass.

Andrew.

Reply via email to