* fold-const.c (tree_expr_nonnegative_p): A&B is nonnegative when
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Mar 2004 19:11:35 +0000 (19:11 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Mar 2004 19:11:35 +0000 (19:11 +0000)
A is nonnegative or B is nonnegative.  Similarly A|B is nonnegative
when both A and B are nonnegative.
(tree_expr_nonzero_p): A|B is nonzero when A is nonzero or B is
nonzero.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79870 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c

index af4fae5..603f6a4 100644 (file)
@@ -1,3 +1,11 @@
+2004-03-23  Roger Sayle  <roger@eyesopen.com>
+
+       * fold-const.c (tree_expr_nonnegative_p): A&B is nonnegative when
+       A is nonnegative or B is nonnegative.  Similarly A|B is nonnegative
+       when both A and B are nonnegative.
+       (tree_expr_nonzero_p): A|B is nonzero when A is nonzero or B is
+       nonzero.
+
 2004-03-23  Kazu Hirata  <kazu@cs.umass.edu>
 
        * fold-const.c (fold): Remove cases for INTEGER_CST, REAL_CST,
index 948a46c..417d1a4 100644 (file)
@@ -8717,6 +8717,13 @@ tree_expr_nonnegative_p (tree t)
       return tree_expr_nonnegative_p (TREE_OPERAND (t, 0))
             && tree_expr_nonnegative_p (TREE_OPERAND (t, 1));
 
+    case BIT_AND_EXPR:
+      return tree_expr_nonnegative_p (TREE_OPERAND (t, 1))
+            || tree_expr_nonnegative_p (TREE_OPERAND (t, 0));
+    case BIT_IOR_EXPR:
+      return tree_expr_nonnegative_p (TREE_OPERAND (t, 0))
+            && tree_expr_nonnegative_p (TREE_OPERAND (t, 1));
+
     case NOP_EXPR:
       {
        tree inner_type = TREE_TYPE (TREE_OPERAND (t, 0));
@@ -8955,6 +8962,10 @@ tree_expr_nonzero_p (tree t)
     case NON_LVALUE_EXPR:
       return tree_expr_nonzero_p (TREE_OPERAND (t, 0));
 
+    case BIT_IOR_EXPR:
+      return tree_expr_nonzero_p (TREE_OPERAND (t, 1))
+            || tree_expr_nonzero_p (TREE_OPERAND (t, 0));
+
     default:
       break;
     }