On Mon, Nov 18, 2019 at 03:34:35PM +0100, Martin Liška wrote:
> > Now, I believe with the if to gswitch optimization these will only rarely
> > kick in, because the IL will have switches that reassoc doesn't handle,
> > instead of series of ifs.
> 
> Yes, so my question is whether reassoc can handle gswitch statements similar
> to series of if statements? Note that use can write explicitly something like:

I don't see how.  Either the cswitch pass runs early, and then you need to
take it into account when deciding whether to expand it as series of ifs or
table lookup or bittest (say, realize you'd need just a single condition to
cover everything and go with if series), or it runs late and then on the
other side if reassoc turned gswitch into if series without taking into
account other possibilities like table lookup, it could pessimize stuff.
So, IMHO cswitch should he able to do this too.

> 
> switch (a)
>    case 0...30:
>       return 1;
>    case 32:
>       return 1;
>    case 34:
>       return 1;
> 
> which won't be optimized by reassoc. While it can handle something 
> 0<=A<=30|A==32|A==34.

        Jakub

Reply via email to