fold-const.c (fold_single_bit_test): Fix overflow test.
authorRichard Biener <rguenther@suse.de>
Fri, 30 Aug 2013 11:52:15 +0000 (11:52 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 30 Aug 2013 11:52:15 +0000 (11:52 +0000)
2013-08-30  Richard Biener  <rguenther@suse.de>

* fold-const.c (fold_single_bit_test): Fix overflow test.

From-SVN: r202103

gcc/ChangeLog
gcc/fold-const.c

index 9321385270661e8264bed12c0c1c97ae6bc24aab..c3d91d3ee4f3d2d1ee74af98851cddfbab7b4e22 100644 (file)
@@ -1,3 +1,7 @@
+2013-08-30  Richard Biener  <rguenther@suse.de>
+
+       * fold-const.c (fold_single_bit_test): Fix overflow test.
+
 2013-08-30  Eric Botcazou  <ebotcazou@adacore.com>
 
        * function.c (assign_parm_setup_reg): For a parameter passed by pointer
index 1e0e7e5f98578ba1e4f878d1ab1c2af023224a74..f959f0a14a0d27889f438e73b0c94c1a0f6629e6 100644 (file)
@@ -6634,10 +6634,10 @@ fold_single_bit_test (location_t loc, enum tree_code code,
         not overflow, adjust BITNUM and INNER.  */
       if (TREE_CODE (inner) == RSHIFT_EXPR
          && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST
-         && TREE_INT_CST_HIGH (TREE_OPERAND (inner, 1)) == 0
+         && host_integerp (TREE_OPERAND (inner, 1), 1)
          && bitnum < TYPE_PRECISION (type)
-         && 0 > compare_tree_int (TREE_OPERAND (inner, 1),
-                                  bitnum - TYPE_PRECISION (type)))
+         && (TREE_INT_CST_LOW (TREE_OPERAND (inner, 1))
+             < (unsigned) (TYPE_PRECISION (type) - bitnum)))
        {
          bitnum += TREE_INT_CST_LOW (TREE_OPERAND (inner, 1));
          inner = TREE_OPERAND (inner, 0);