https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117091

--- Comment #12 from Filip Kastl <pheeck at gcc dot gnu.org> ---
(In reply to Andi Kleen from comment #9)
> Yes I guess we should keep better switches at -O1 because machine generated
> code may have lot of switches.
> 
> I don't think we need perfect clustering? Perhaps there is some heuristic
> that is good enough. Maybe just kmeans or something like that.
> 
> The deep recursion I saw was for balance_case_nodes

Yeah, maybe there exists some heuristic that we could use.  I believe that
kmeans solves a different problem that just happens to also be called
clustering.

So I think we should do this
1) Turn off the current bit test and jump table clustering algorithms on -O0
(Andi already submitted this patch)
2) Turn off the current algorithms for switches bigger than some constant (not
sure how big it should be)
3) Try to come up with a clustering algorithm which doesn't guarantee optimal
results but runs fast. Use it when the current algorithms are switched off

BTW For (2) maybe this limit could be dynamic and proportionate to the square
root of the size of the whole program? That way O(n^2) algs would still be
linear in the size of the whole compiler input.

Reply via email to