[Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Apr 9 11:39:21 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Zhendong Su from comment #1)
> [578] % gcctk -O1 -S -o O1.s small.c
> [579] % gcctk -O3 -S -o O3.s small.c
> [580] % 
> [580] % wc O1.s O3.s
>   22   43  410 O1.s
>   37   77  682 O3.s
>   59  120 1092 total
> [581] % 
> [581] % grep foo O1.s
> [582] % grep foo O3.s
>         call    foo
> [583] % 
> [583] % cat small.c
> extern void foo(void);
> static int a, b;
> static void c() {
>   if (a) {
>     foo();
>     for (; b < 1; b++)
>       ;
>   }
> }
> int main() {
>   c();
>   c();
>   return 0;
> }

This is another case of failing to elide a no longer called function.  We
end up partially inlining c() at -O3, inlining the if (a) head and thus
we eliminate the calls to c() in main rather than the call to foo in c().

I'd say the -O3 result is superior but still we fail to remove the
c.part() function definition from the assembly.  We have duplicates for this
case.


More information about the Gcc-bugs mailing list