This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/72795] Missed optimization of external-linkage variables in presence of barriers
- From: "peter at cordes dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 03 Aug 2016 18:13:22 +0000
- Subject: [Bug middle-end/72795] Missed optimization of external-linkage variables in presence of barriers
- Auto-submitted: auto-generated
- References: <bug-72795-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72795
Peter Cordes <peter at cordes dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |peter at cordes dot ca
--- Comment #1 from Peter Cordes <peter at cordes dot ca> ---
This is not a bug. Adding int gety(){ return y; } to the compilation unit
leads to the same asm for f() and g(). (https://godbolt.org/g/4z94YZ). It can
only be optimized away when there are no observers.
f() and g() have side-effects on global / static variables which of course
can't be optimized away.
BTW, this came up based on http://stackoverflow.com/a/38741832/224132.