[Bug tree-optimization/84562] -faggressive-loop-optimizations makes decisions based on weak data structures
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 28 11:39:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84562
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #3)
> It's not just -faggressive-loop-optimizations, it seems that constructors of
> weak globals are available for folding, and I really doubt that's actually
> intended; after all, GCC does always consider weak function interposable, so
> why not objects? Compare:
>
> __attribute__((weak)) const int x=0; int f(){return x==0;}
>
> f:
> movl $1, %eax
> ret
>
> vs.
>
> __attribute__((weak)) int x(void){return 0;} int f(){return x()==0;}
>
> f:
> subq $8, %rsp
> call x
> testl %eax, %eax
> sete %al
> movzbl %al, %eax
> popq %rdx
> ret
I agree this inconsistency is odd (verified other compilers behave the same).
More information about the Gcc-bugs
mailing list