[Bug middle-end/70861] Improve code generation of switch tables

2016-04-28 Thread wdijkstr at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70861

--- Comment #3 from Wilco  ---
(In reply to Andrew Pinski from comment #2)
> Note I think if we had gotos instead of assignment here we should do the
> similar thing for the switch table itself.

Absolutely, that was my point.

> Note also the assignment to i is getting in the way for the switch to
> constant table form.

In SSA form you can sink the assignments into a shared block, so it should be
able deal with an identical assignment to a global, pointer, array or even
returning directly. Also it's common that the default or a few other cases are
doing something different, so those need to be pulled out separately.

However that's icing on the cake - the key issue is that GCC doesn't even do
the basic stuff yet. Most compilers are able to split off cases with high
profile counts, dense switch tables, ranges that all go to the same block etc.

[Bug middle-end/70861] Improve code generation of switch tables

2016-04-28 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70861

--- Comment #2 from Andrew Pinski  ---
Note I think if we had gotos instead of assignment here we should do the
similar thing for the switch table itself.

Note also the assignment to i is getting in the way for the switch to constant
table form.

[Bug middle-end/70861] Improve code generation of switch tables

2016-04-28 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70861

--- Comment #1 from Andrew Pinski  ---
I think we should turn this into the following:

((unsigned)a) <= 9 ? table[a] : (a == 110 ? 27 : 77);

That is pull out the 110/default case so table would be small.