This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize (X >> N) {>,>=,<,<=} C in the combiner (PR tree-optimization/20517)
> Like this? The reason I haven't done this initially was that
> a) I was afraid of LTGT and UN* codes, but those shouldn't be present for
> MODE_INT op0 which is checked earlier
I thought of this...
> b) I want to prefer C << N over ((C + 1) << N) - 1 when possible (when low
> bits are known to be zero), because the former might be a cheaper
> constant and I didn't want to call nonzero_bits twice. In the patch
> below that is handled by adding the low_bits temporary.
but not of that. :-)
> 2010-09-10 Jakub Jelinek <jakub@redhat.com>
>
> PR rtl-optimization/45617
> * combine.c (simplify_comparison): Optimize (X >> N) {>,>=,<,<=} C
> even if low N bits of X aren't known to be zero.
>
> * gcc.target/i386/pr45617.c: New test.
OK, modulo:
+ HOST_WIDE_INT low_bits
+ = (nonzero_bits (XEXP (op0, 0), mode)
+ & (((HOST_WIDE_INT) 1 << INTVAL (XEXP (op0, 1))) - 1));
unsigned HOST_WIDE_INT
+ if (low_bits != 0
+ && (code == GT || code == GTU || code == LE || code == LEU))
long line
Thanks.
--
Eric Botcazou