combine.c (simplify_and_const_int): Don't trunc_int_for_mode "nonzero" as that might...
authorAlan Modra <amodra@bigpond.net.au>
Tue, 22 Jan 2002 23:42:07 +0000 (23:42 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Tue, 22 Jan 2002 23:42:07 +0000 (10:12 +1030)
* combine.c (simplify_and_const_int): Don't trunc_int_for_mode
"nonzero" as that might add "1" bits.  Ensure "constop" is
properly sign extened.
(force_to_mode): Tweak for sign extended constop.

From-SVN: r49112

gcc/ChangeLog
gcc/combine.c

index 724a8b90a2a2e4bc25270b2f94bbbffd070010ee..30d007887137b0100c17e1041b1618818121774b 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-23  Alan Modra  <amodra@bigpond.net.au>
+
+       * combine.c (simplify_and_const_int): Don't trunc_int_for_mode
+       "nonzero" as that might add "1" bits.  Ensure "constop" is
+       properly sign extened.
+       (force_to_mode): Tweak for sign extended constop.
+
 2002-01-22  Richard Henderson  <rth@redhat.com>
 
        * config/alpha/alpha.c (some_small_symbolic_mem_operand) Use
index 663fd1d61986578d057a7540d5b965fd0f1be2c8..47ac3a8aa623ac8ec49988d158eff4dcb8bed337 100644 (file)
@@ -6701,7 +6701,8 @@ force_to_mode (x, mode, mask, reg, just_select)
             need it.  */
 
          if (GET_CODE (x) == AND && GET_CODE (XEXP (x, 1)) == CONST_INT
-             && (unsigned HOST_WIDE_INT) INTVAL (XEXP (x, 1)) == mask)
+             && ((INTVAL (XEXP (x, 1)) & GET_MODE_MASK (GET_MODE (x)))
+                 == (HOST_WIDE_INT) mask))
            x = XEXP (x, 0);
 
          /* If it remains an AND, try making another AND with the bits
@@ -7755,7 +7756,6 @@ simplify_and_const_int (x, mode, varop, constop)
      MODE.  */
 
   nonzero = nonzero_bits (varop, mode) & GET_MODE_MASK (mode);
-  nonzero = trunc_int_for_mode (nonzero, mode);
 
   /* Turn off all bits in the constant that are known to already be zero.
      Thus, if the AND isn't needed at all, we will have CONSTOP == NONZERO_BITS
@@ -7823,19 +7823,22 @@ simplify_and_const_int (x, mode, varop, constop)
   /* If we are only masking insignificant bits, return VAROP.  */
   if (constop == nonzero)
     x = varop;
-
-  /* Otherwise, return an AND.  See how much, if any, of X we can use.  */
-  else if (x == 0 || GET_CODE (x) != AND || GET_MODE (x) != mode)
-    x = gen_binary (AND, mode, varop, GEN_INT (constop));
-
   else
     {
+      /* Otherwise, return an AND.  */
       constop = trunc_int_for_mode (constop, mode);
-      if (GET_CODE (XEXP (x, 1)) != CONST_INT
-         || (unsigned HOST_WIDE_INT) INTVAL (XEXP (x, 1)) != constop)
-       SUBST (XEXP (x, 1), GEN_INT (constop));
+      /* See how much, if any, of X we can use.  */
+      if (x == 0 || GET_CODE (x) != AND || GET_MODE (x) != mode)
+       x = gen_binary (AND, mode, varop, GEN_INT (constop));
 
-      SUBST (XEXP (x, 0), varop);
+      else
+       {
+         if (GET_CODE (XEXP (x, 1)) != CONST_INT
+             || (unsigned HOST_WIDE_INT) INTVAL (XEXP (x, 1)) != constop)
+           SUBST (XEXP (x, 1), GEN_INT (constop));
+
+         SUBST (XEXP (x, 0), varop);
+       }
     }
 
   return x;