[PATCH, i386]: Optimization of the i386 and x86_64 compilers

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Sat Mar 3 00:46:00 GMT 2007


On Fri, 2 Mar 2007, Meissner, Michael wrote:

> One win I've thought about is to optimize multiple comparisons against
> small constants, ie:
>
> 	If (a == 5 || a == 7 || a == 11) { ... }
>
> Into:
>
> 	if (((unsigned)a) < 32 && (1 << a) & ((1 << 5) | (1 << 7) | (1
> << 11))
>
> Then you would also want to handle switch statements where you have a
> few cases that are small constants to using this also.

Switch statements were already done by Roger (four years ago):
http://gcc.gnu.org/ml/gcc-patches/2003-01/msg01950.html

But AFAICT, if statements are not yet so optimized.  I think that would be
a welcome addition.

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu



More information about the Gcc-patches mailing list