This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/51867] GCC generates inconsistent code for same sources calling builtin calls, like sqrtf
- From: "amker.cheng at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 16 Jan 2012 10:15:59 +0000
- Subject: [Bug middle-end/51867] GCC generates inconsistent code for same sources calling builtin calls, like sqrtf
- Auto-submitted: auto-generated
- References: <bug-51867-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51867
--- Comment #1 from amker.cheng <amker.cheng at gmail dot com> 2012-01-16 10:15:59 UTC ---
The cause is in function expand_builtin, gcc checks following conditions:
----------------------------------------------
/* When not optimizing, generate calls to library functions for a certain
set of builtins. */
if (!optimize
&& !called_as_built_in (fndecl)
&& DECL_ASSEMBLER_NAME_SET_P (fndecl)
&& fcode != BUILT_IN_ALLOCA
&& fcode != BUILT_IN_ALLOCA_WITH_ALIGN
&& fcode != BUILT_IN_FREE)
return expand_call (exp, target, ignore);
The control flow is:
1, DECL_ASSEMBLER_NAME_SET_P (fndecl) is false at the first time when compiling
a;
2, It is then set in following codes when expanding sqrtf call in function a;
3, When compiling function b, gcc checks DECL_ASSEMBLER_NAME_SET_P (fndecl)
again and this time it's true;