2013/3/5 Eric Botcazou <ebotca...@adacore.com>:
>> In other words, any 32-bit target with 'need_64bit_hwint=yes' in config.gcc
>> is not able to have benefit from this optimization because it never
>> passes the condition test.
>>
>>
>> My solution is to use GET_MODE_MASK(mode) to filter out all bits not
>> in target mode. The following is my patch:
>
> The patch is OK for 4.9 once stage #1 is open if it passes bootstrap/regtest.

Thanks for the approval. I will wait for 4.9 stage1 opening.
The following is the new patch according to your suggestions:


gcc/ChangeLog:

        * combine.c (simplify_compare_const): Use GET_MODE_MASK to filter out
        unnecessary bits in the constant power of two case.


diff --git a/gcc/combine.c b/gcc/combine.c
index 67bd776..ce2b583 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -10917,8 +10917,9 @@ simplify_compare_const (enum rtx_code code,
rtx op0, rtx *pop1)
       && (code == EQ || code == NE || code == GE || code == GEU
           || code == LT || code == LTU)
       && mode_width <= HOST_BITS_PER_WIDE_INT
-      && exact_log2 (const_op) >= 0
-      && nonzero_bits (op0, mode) == (unsigned HOST_WIDE_INT) const_op)
+      && exact_log2 (const_op & GET_MODE_MASK (mode)) >= 0
+      && (nonzero_bits (op0, mode)
+          == (unsigned HOST_WIDE_INT) (const_op & GET_MODE_MASK (mode))))
     {
       code = (code == EQ || code == GE || code == GEU ? NE : EQ);
       const_op = 0;



Best regards,
jasonwucj

Reply via email to