Hi!

When working on PR57130, I've wondered why we don't simplify it much earlier
and end up with creating such weirdness.

The following patch fixes that, by using nonzero_bits to see if all the low
bits must be zero and in that case just return zero.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2013-05-02  Jakub Jelinek  <ja...@redhat.com>

        * simplify-rtx.c (simplify_truncation): If nonzero_bits
        on op shows all bits zero in mode, return zero.

--- gcc/simplify-rtx.c.jj       2013-04-03 15:46:45.000000000 +0200
+++ gcc/simplify-rtx.c  2013-05-02 11:16:18.202043607 +0200
@@ -774,6 +774,11 @@ simplify_truncation (enum machine_mode m
     return simplify_gen_unary (TRUNCATE, mode, XEXP (op, 0),
                               GET_MODE (XEXP (op, 0)));
 
+  /* If op is known to have all lower bits zero, the result is zero.  */
+  if (HWI_COMPUTABLE_MODE_P (op_mode)
+      && (nonzero_bits (op, op_mode) & GET_MODE_MASK (mode)) == 0)
+    return CONST0_RTX (mode);
+
   return NULL_RTX;
 }
 

        Jakub

Reply via email to