[Bug middle-end/100323] New: #pragma and attribute optimize don't enable inlining
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 28 17:54:17 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100323
Bug ID: 100323
Summary: #pragma and attribute optimize don't enable inlining
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
I expected the effect of the attribute and the #pragma on the calls to f() in
both g() and h() to be to inline them. They aren't. With #pragma clang
optimize on, Clang inlines the call in h().
If this should be the expected behavior in GCC it should be documented.
$ cat a.c && gcc -O0 -S -Wall -fdump-tree-optimized=/dev/stdout a.c
static int f (void) { return 0; }
__attribute__ ((optimize (2)))
int g (void) { return f (); }
#pragma GCC optimize ("2")
int h (void) { return f (); }
;; Function f (f, funcdef_no=0, decl_uid=1943, cgraph_uid=1, symbol_order=0)
int f ()
{
int D.1952;
int _1;
<bb 2> :
_1 = 0;
<bb 3> :
<L0>:
return _1;
}
;; Function g (g, funcdef_no=1, decl_uid=1946, cgraph_uid=2, symbol_order=1)
__attribute__((optimize (2)))
int g ()
{
int _3;
<bb 2> [local count: 1073741824]:
_3 = f (); [tail call]
return _3;
}
;; Function h (h, funcdef_no=2, decl_uid=1949, cgraph_uid=3, symbol_order=2)
__attribute__((optimize ("2")))
int h ()
{
int _3;
<bb 2> [local count: 1073741824]:
_3 = f (); [tail call]
return _3;
}
More information about the Gcc-bugs
mailing list