On Tue, Apr 17, 2012 at 1:48 AM, Jan Hubicka <hubi...@ucw.cz> wrote:
>> > 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.
>
> TO a degree - switch expansion needs more info than it can obtain from edge
> profile.  Having
> switch
>  case 1,3,5,7,8,9: aaa
>  case 2,4,6,8,10,12: bbb
> to produce well ballanced decision tree, it is not enough to know how
> often the value is even and how often it is odd...

Why is that? In this case, the expanded switch case does not use BST,
but testing against bit patterns.

>
> Thus there is a need for value histograms.

None of the existing value profiler will be powerful enough for this
though: the one_value profiler only tracks one value. The interval
profiler can potentially be used if the switch case range is small --
otherwise the runtime memory overhead will be too large.

Thanks,

David

>>
>> > 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.
>
> Yep.
> Honza
>>
>> >>
>> >>
>> >> The attached patch removes the heuristic.
>> >>
>> >> Bootstrapped and tested on powerpc-unknown-linux-gnu. OK for trunk?
>>
>> Ok.
>>
>> Thanks,
>> Richard.
>>
>> >> Ciao!
>> >> Steven
>> >
>> >

Reply via email to