]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
combine.c (num_sign_bit_copies): In NEG...
authorBernd Schmidt <crux@ohara.Informatik.RWTH-Aachen.DE>
Wed, 6 Jan 1999 23:43:14 +0000 (16:43 -0700)
committerJeff Law <law@gcc.gnu.org>
Wed, 6 Jan 1999 23:43:14 +0000 (16:43 -0700)
        * combine.c (num_sign_bit_copies): In NEG, MULT, DIV and MOD cases,
        when a test can't be performed due to limited width of
        HOST_BITS_PER_WIDE_INT, use the more conservative approximation.
        Fix UDIV case for cases where the first operand has the highest bit
        set.
And fix a couple copyrights.

From-SVN: r24549

gcc/combine.c
gcc/config/h8300/h8300.h
gcc/expr.c

index 374cd3da6f4aa694bb71ac79dc63a77888dc09f9..db9bb381d85237267a36baee725709a5a3c4c6cc 100644 (file)
@@ -1,5 +1,5 @@
 /* Optimize by combining instructions for GNU compiler.
-   Copyright (C) 1987, 88, 92-97, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1987, 88, 92-98, 1999 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -7994,13 +7994,15 @@ num_sign_bit_copies (x, mode)
         is known to be positive, the number of sign bit copies is the
         same as that of the input.  Finally, if the input has just one bit
         that might be nonzero, all the bits are copies of the sign bit.  */
+      num0 = num_sign_bit_copies (XEXP (x, 0), mode);
+      if (bitwidth > HOST_BITS_PER_WIDE_INT)
+       return num0 > 1 ? num0 - 1 : 1;
+
       nonzero = nonzero_bits (XEXP (x, 0), mode);
       if (nonzero == 1)
        return bitwidth;
 
-      num0 = num_sign_bit_copies (XEXP (x, 0), mode);
       if (num0 > 1
-         && bitwidth <= HOST_BITS_PER_WIDE_INT
          && (((HOST_WIDE_INT) 1 << (bitwidth - 1)) & nonzero))
        num0--;
 
@@ -8044,19 +8046,27 @@ num_sign_bit_copies (x, mode)
 
       result = bitwidth - (bitwidth - num0) - (bitwidth - num1);
       if (result > 0
-         && bitwidth <= HOST_BITS_PER_WIDE_INT
-         && ((nonzero_bits (XEXP (x, 0), mode)
-              & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
-         && ((nonzero_bits (XEXP (x, 1), mode)
-             & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0))
+         && (bitwidth > HOST_BITS_PER_WIDE_INT
+             || (((nonzero_bits (XEXP (x, 0), mode)
+                   & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
+                 && ((nonzero_bits (XEXP (x, 1), mode)
+                      & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0))))
        result--;
 
       return MAX (1, result);
 
     case UDIV:
-      /* The result must be <= the first operand.  */
-      return num_sign_bit_copies (XEXP (x, 0), mode);
-
+      /* The result must be <= the first operand.  If the first operand
+         has the high bit set, we know nothing about the number of sign
+         bit copies.  */
+      if (bitwidth > HOST_BITS_PER_WIDE_INT)
+       return 1;
+      else if ((nonzero_bits (XEXP (x, 0), mode)
+               & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
+       return 1;
+      else
+       return num_sign_bit_copies (XEXP (x, 0), mode);
+                                   
     case UMOD:
       /* The result must be <= the scond operand.  */
       return num_sign_bit_copies (XEXP (x, 1), mode);
@@ -8067,20 +8077,20 @@ num_sign_bit_copies (x, mode)
         to add 1.  */
       result = num_sign_bit_copies (XEXP (x, 0), mode);
       if (result > 1
-         && bitwidth <= HOST_BITS_PER_WIDE_INT
-         && (nonzero_bits (XEXP (x, 1), mode)
-             & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
-       result --;
+         && (bitwidth > HOST_BITS_PER_WIDE_INT
+             || (nonzero_bits (XEXP (x, 1), mode)
+                 & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0))
+       result--;
 
       return result;
 
     case MOD:
       result = num_sign_bit_copies (XEXP (x, 1), mode);
       if (result > 1
-         && bitwidth <= HOST_BITS_PER_WIDE_INT
-         && (nonzero_bits (XEXP (x, 1), mode)
-             & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
-       result --;
+         && (bitwidth > HOST_BITS_PER_WIDE_INT
+             || (nonzero_bits (XEXP (x, 1), mode)
+                 & ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0))
+       result--;
 
       return result;
 
index d160f64ecf227cbd32f75a9a25b1b02b74c4558c..25c95f3f3f295e90f1a1b7a57250e63c4cf4f1af 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler. 
    Hitachi H8/300 version generating coff 
-   Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
    Contributed by Steve Chamberlain (sac@cygnus.com),
    Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
 
index 18abfc6d05c4bc412e89ce87a6f1a69c59eb5787..7f364adb3288048f24e61265e1b7e192ff220cf5 100644 (file)
@@ -1,5 +1,5 @@
 /* Convert tree expression to rtl instructions, for GNU compiler.
-   Copyright (C) 1988, 92-97, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1988, 92-98, 1999 Free Software Foundation, Inc.
 
 This file is part of GNU CC.