This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/34708] Inlining heuristics issue
- From: "hubicka at ucw dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Jan 2008 23:46:31 -0000
- Subject: [Bug tree-optimization/34708] Inlining heuristics issue
- References: <bug-34708-87@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from hubicka at ucw dot cz 2008-01-07 23:46 -------
Subject: Re: New: Inlining heuristics issue
Hi,
I am testing the attached patch. It simply accounts two instructions
for each case label, I guess it does not make much sense to try to do
something smarter until we move lowering of swithc constructs to tree
level.
Interestingly enough the function manages to be small when just one
switch is accounted. I wonder if removing "* 2" still fixes the real
testcase (ie the extreme growth is caused by too much of cascaded
inlining).
The inlining costs are quite biassed not taking into account the cost of
address operations assuming that real work dominates the CPU time, that
is probably still the case but we get to extreme side cases like this in
other metricts..
Honza
Index: tree-inline.c
===================================================================
*** tree-inline.c (revision 131386)
--- tree-inline.c (working copy)
*************** estimate_num_insns_1 (tree *tp, int *wal
*** 2387,2395 ****
break;
case SWITCH_EXPR:
! /* TODO: Cost of a switch should be derived from the number of
! branches. */
! d->count += d->weights->switch_cost;
break;
/* Few special cases of expensive operations. This is useful
--- 2387,2400 ----
break;
case SWITCH_EXPR:
! /* Take into account cost of the switch + guess 2 conditional jumps for
! each case label.
!
! TODO: once switch expansion algorithm is sufficiently separated
! from RTL expansion, we might ask it for real cost of the switch
! construct. */
! d->count += (d->weights->switch_cost
! + TREE_VEC_LENGTH (SWITCH_LABELS (x)) * 2);
break;
/* Few special cases of expensive operations. This is useful
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34708