This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR tree-optimization/34708 (too much inlining)


On Jan 8, 2008 1:24 PM, Jan Hubicka <jh@suse.cz> wrote:
>
> Hi,
> the testcase involves a lot of inlining because quite large SWITCH statement
> cost is underestimated.  This patch fixes it by assuming two conditionals for
> each SWITCH label.
>
> Bootstrapped/regtested i686-linux, OK?

Hmm, this makes estimates consistent comparing

const char *getit(int i)
{
  if (i == 0)
    return "foo";
  else if (i == 1)
    return "bar";
  else
    return "foobar";
}

and

const char *getit(int i)
{
  switch (i)
    {
    case 0: return "foo";
    case 1: return "bar";
    default: return "foobar";
    }
}

apart from adding d->weights->switch_cost, right?  So I'd rather remove
the addition of d->weights->switch_cost.  Does this make the testcase
still fixed?

Richard.

> Honza
>
>         PR tree-optimization/34708
>         * tree-inline.c (estimate_num_insns_1): Compute SWITCH cost based on
>         number of case labels.
> 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
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]