From 54d581a26ea5cc6ec540be1f108d18db0bbd365a Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Mon, 21 Jun 2004 12:59:58 +0000 Subject: [PATCH] fold-const.c (operand_equal_p): Pass flags in recursive calls for binary and relational operations. * 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 | 9 +++++++++ gcc/fold-const.c | 26 +++++++++++++++++++++++--- gcc/tree.c | 7 +++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87ddfc76dd4..6fb2d9e450c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2004-06-21 Roger Sayle + + * 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 * rtlanal.c (may_trap_p): Mark LTGT as trapping. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 517d5508b95..68c9722ea18 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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)); diff --git a/gcc/tree.c b/gcc/tree.c index bb7ed19272c..fb1f4d77b69 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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: -- 2.30.2