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

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
For reference, the same optimization should be applied with address spaces:

--cut here--
int __seg_gs b;

int bar(void)
{
  return *(volatile __seg_gs int *) &b + b;
}
--cut here--

the above testcase currently compiles to:

        movl    %gs:b(%rip), %eax
        addl    %gs:b(%rip), %eax
        ret

but can be compiled to:

        movl    %gs:b(%rip), %eax
        addl    %eax, %eax
        ret

Reply via email to