fold-const.c (operand_equal_p): Pass flags in recursive calls for binary and relation...
authorRoger Sayle <roger@eyesopen.com>
Mon, 21 Jun 2004 12:59:58 +0000 (12:59 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Mon, 21 Jun 2004 12:59:58 +0000 (12:59 +0000)
* fold-const.c (operand_equal_p): Pass flags in recursive calls for
binary and relational operations.  Add support for TRUTH_ANDIF_EXPR,
TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR and TRUTH_XOR_EXPR.
* tree.c (commutative_tree_code): Also list UNORDERED_EXPR,
ORDERED_EXPR, UNEQ_EXPR, LTGT_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR
and TRUTH_XOR_EXPR.

From-SVN: r83433

gcc/ChangeLog
gcc/fold-const.c
gcc/tree.c

index 87ddfc76dd4d7337100daa045feea47769538b66..6fb2d9e450caa125ffe9102da880f48000f02237 100644 (file)
@@ -1,3 +1,12 @@
+2004-06-21  Roger Sayle  <roger@eyesopen.com>
+
+       * fold-const.c (operand_equal_p): Pass flags in recursive calls for
+       binary and relational operations.  Add support for TRUTH_ANDIF_EXPR,
+       TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR and TRUTH_XOR_EXPR.
+       * tree.c (commutative_tree_code): Also list UNORDERED_EXPR,
+       ORDERED_EXPR, UNEQ_EXPR, LTGT_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR
+       and TRUTH_XOR_EXPR.
+
 2004-06-21  Paolo Bonzini  <bonzini@gnu.org>
 
        * rtlanal.c (may_trap_p): Mark LTGT as trapping.
index 517d5508b954007b0624786bf88a65ba2a4d2805..68c9722ea183640f3fa5e4e9d496e9cc15088a28 100644 (file)
@@ -2454,9 +2454,10 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
 
     case '<':
     case '2':
-      if (operand_equal_p (TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 0), 0)
-         && operand_equal_p (TREE_OPERAND (arg0, 1), TREE_OPERAND (arg1, 1),
-                             0))
+      if (operand_equal_p (TREE_OPERAND (arg0, 0),
+                          TREE_OPERAND (arg1, 0), flags)
+         && operand_equal_p (TREE_OPERAND (arg0, 1),
+                             TREE_OPERAND (arg1, 1), flags))
        return 1;
 
       /* For commutative ops, allow the other order.  */
@@ -2506,6 +2507,25 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
          return operand_equal_p (TREE_OPERAND (arg0, 0),
                                  TREE_OPERAND (arg1, 0), flags);
 
+       case TRUTH_ANDIF_EXPR:
+       case TRUTH_ORIF_EXPR:
+         return operand_equal_p (TREE_OPERAND (arg0, 0),
+                                 TREE_OPERAND (arg1, 0), flags)
+                && operand_equal_p (TREE_OPERAND (arg0, 1),
+                                    TREE_OPERAND (arg1, 1), flags);
+
+       case TRUTH_AND_EXPR:
+       case TRUTH_OR_EXPR:
+       case TRUTH_XOR_EXPR:
+         return (operand_equal_p (TREE_OPERAND (arg0, 0),
+                                  TREE_OPERAND (arg1, 0), flags)
+                 && operand_equal_p (TREE_OPERAND (arg0, 1),
+                                     TREE_OPERAND (arg1, 1), flags))
+                || (operand_equal_p (TREE_OPERAND (arg0, 0),
+                                     TREE_OPERAND (arg1, 1), flags)
+                    && operand_equal_p (TREE_OPERAND (arg0, 1),
+                                        TREE_OPERAND (arg1, 0), flags));
+
        case RTL_EXPR:
          return rtx_equal_p (RTL_EXPR_RTL (arg0), RTL_EXPR_RTL (arg1));
 
index bb7ed19272cc3e241e6e8066f49a99c75c097682..fb1f4d77b6955520e5c8b6e1cf01994fc7f76bca 100644 (file)
@@ -3792,6 +3792,13 @@ commutative_tree_code (enum tree_code code)
     case BIT_AND_EXPR:
     case NE_EXPR:
     case EQ_EXPR:
+    case UNORDERED_EXPR:
+    case ORDERED_EXPR:
+    case UNEQ_EXPR:
+    case LTGT_EXPR:
+    case TRUTH_AND_EXPR:
+    case TRUTH_XOR_EXPR:
+    case TRUTH_OR_EXPR:
       return true;
 
     default: