This is the mail archive of the 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: [patch] Remove strange case cost code

On Tue, Apr 17, 2012 at 8:49 AM, Jan Hubicka <> wrote:
>> Hello,
>> There is code in stmt.c since the initial checkin, that tries to
>> balance a switch tree according to some ascii heuristics. I see a
>> couple of problems with this code:
>> 1. It doesn't seem to help much. With the attached patch to remove the
>> code, I see no compile time changes to e.g. compile GCC itself.
>> 2. It isn't clear what the heuristic is based on (no reference to any
>> testing done, or a reference to a book or paper).
>> 3. The heuristic is applied for case values in the range <-1,127>
>> (inclusive) even if the type of the switch expression isn't char or
>> int but e.g. an enum. This results in funny application of this
>> heuristic in GCC itself to e.g. some cases of enum rtx_code and enum
>> tree_code.
> Note that it would make a lot of sense to teach this heuristics predict.c
> and properly identify chars.

Indeed this would be the proper place to implement this logic.

> Also it is possble to get an historgrams from profile feedback into
> switch expansion. I always wanted to do that once switch expansion code
> is cleaned up and moved to gimple level...

Indeed.  At least the parts that expand switch stmts to (balanced) trees
should be moved to the GIMPLE level, retaining only the table-jump-like
expansions as switch stmts.

>> The attached patch removes the heuristic.
>> Bootstrapped and tested on powerpc-unknown-linux-gnu. OK for trunk?



>> Ciao!
>> Steven

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