https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113106

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Perhaps related,

--cut here--
int a;

int foo(void)
{
  return *(volatile int *) &a + *(volatile int *) &a;
}
--cut here--

compiles with -O2 to:

        movl    a(%rip), %eax
        movl    a(%rip), %edx
        addl    %edx, %eax
        ret

but may be compiled to:

        movl    a(%rip), %eax
        addl    a(%rip), %eax
        ret

(the memory read may propagate to the insn)

Reply via email to