This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]