This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PATCH, i386]: Optimization of the i386 and x86_64 compilers
- From: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>
- To: "Meissner, Michael" <michael dot meissner at amd dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Uros Bizjak <ubizjak at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Mar 2007 19:46:36 -0500 (EST)
- Subject: RE: [PATCH, i386]: Optimization of the i386 and x86_64 compilers
- References: <6096959DEF5C9447A6BF80BDC7EB9EDC06155C5D@SBOSEXMB1.amd.com>
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