This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/47255] Missed CSE optimization with inline functions, and __attribute__((const))
- From: "bonzini at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 7 Feb 2011 10:58:01 +0000
- Subject: [Bug tree-optimization/47255] Missed CSE optimization with inline functions, and __attribute__((const))
- Auto-submitted: auto-generated
- References: <bug-47255-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47255
Paolo Bonzini <bonzini at gnu dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bonzini at gnu dot org
--- Comment #4 from Paolo Bonzini <bonzini at gnu dot org> 2011-02-07 10:57:54 UTC ---
I think this is invalid. const attributes are a hint to GCC regarding parts of
the program that it cannot see, but IMHO the const/pure/nothrow on a function
that is static and a leaf should have no effect on code generation (since GCC
can infer just as much).
So, in the first example GCC is "fixing" a wrong usage of const on part of the
program.
In the second example attached, there is no use of syscalls and GCC properly
optimizes out square2 and square3. If syscalls were added, the bug would be
about missed attributes on the syscalls. BTW, getgid, getuid etc. are pure but
not const.