GCC Bugzilla – Bug 40992
[4.4 Regression] cunroll ignoring asm size
Last modified: 2011-11-29 23:06:02 UTC
The attached file is a loop over the same function implemented in C and inline asm. When compiled with: gcc -O3 -fno-pic -fomit-frame-pointer -fdump-tree-cunroll-details -S cabac_unroll.i cunroll thinks they're different sizes: size: 55-4, last_iteration: 55-4 Loop size: 55 Estimated size after unrolling: 442 size: 8-4, last_iteration: 8-4 Loop size: 8 Estimated size after unrolling: 34 and expands the asm loop all 13 times. This is reduced from ffmpeg decode_cabac_residual, where it apparently causes significant decoding slowdown. Besides that, cunroll seems to be hurting ffmpeg in general on x86-32 (http://multimedia.cx/eggs/last-performance-smackdown-for-awhile/), maybe we'll turn it down some.
Created attachment 18315 [details] the source
asms are predicted to have a small size/cost because they should be used to implement single instructions that cannot be mapped to C easily. No easy way out without pessimizing more legitimate uses of asms.
Maybe the C version will be usable after everyone is using 4.4+, earlier versions tend to make a mess. Anyway, counting newlines for size estimation wouldn't pessimize anything.
>No easy way out without pessimizing more legitimate uses of asms. Actually that is not true. asm_insn_count in final.c will be able to count the number of instructions that an inline-asm will be. This size count is documented too. I am going to fix this by making asm_insn_count public and use that in tree-inline.c.
size: 41 __asm__ __volatile__ Before: size: 1 __asm__ __volatile__
Created attachment 18705 [details] Patch which should fix this
Fixed on the trunk.
Subject: Bug 40992 Author: pinskia Date: Mon Oct 5 17:46:35 2009 New Revision: 152458 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152458 Log: 2009-10-05 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/40992 * final.c (asm_str_count): Split out from asm_insn_count. * rtl.h (asm_str_count): New prototype. * tree-inline (estimate_num_insns) <case GIMPLE_ASM>: Call asm_str_count. Modified: trunk/gcc/ChangeLog trunk/gcc/final.c trunk/gcc/rtl.h trunk/gcc/tree-inline.c
GCC 4.3.5 is being released, adjusting target milestone.
4.3 branch is being closed, moving to 4.4.7 target.
No longer working on this.