From 462fdcce48d055b51f7ca5835c4dd43a94ecf767 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 21 Jul 2004 01:21:11 +0000 Subject: [PATCH] fold-const.c (operand_equal_p): Temporarily support NULL args. * fold-const.c (operand_equal_p): Temporarily support NULL args. (operand_equal_p, case ARRAY_REF): Compare args 2 and 3. (operand_equal_p, case COMPONENT_REF): Likewise, for arg 2. From-SVN: r84990 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 28 +++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index babc4700a48..f581fcd9ca4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,12 @@ * config/arm/arm.c (thumb_expand_prologue): Remove bogus GEN_INT. +2004-07-20 Richard Kenner + + * fold-const.c (operand_equal_p): Temporarily support NULL args. + (operand_equal_p, case ARRAY_REF): Compare args 2 and 3. + (operand_equal_p, case COMPONENT_REF): Likewise, for arg 2. + 2004-07-20 Zack Weinberg * rtl.h (plus_constant): Delete. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index df397f79b4e..946a2fb1cc4 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2348,8 +2348,17 @@ truth_value_p (enum tree_code code) int operand_equal_p (tree arg0, tree arg1, unsigned int flags) { + /* If one is specified and the other isn't, they aren't equal and if + neither is specified, they are. + + ??? This is temporary and is meant only to handle the cases of the + optional operands for COMPONENT_REF and ARRAY_REF. */ + if ((arg0 && !arg1) || (!arg0 && arg1)) + return 0; + else if (!arg0 && !arg1) + return 1; /* If either is ERROR_MARK, they aren't equal. */ - if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK) + else if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK) return 0; /* If both types don't have the same signedness, then we can't consider @@ -2483,13 +2492,26 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags) return operand_equal_p (TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 0), flags); - case COMPONENT_REF: case ARRAY_REF: case ARRAY_RANGE_REF: 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)); + TREE_OPERAND (arg1, 1), flags) + && operand_equal_p (TREE_OPERAND (arg0, 2), + TREE_OPERAND (arg1, 2), flags) + && operand_equal_p (TREE_OPERAND (arg0, 3), + TREE_OPERAND (arg1, 3), flags)); + + + case COMPONENT_REF: + 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, 2), + TREE_OPERAND (arg1, 2), flags)); + case BIT_FIELD_REF: return (operand_equal_p (TREE_OPERAND (arg0, 0), -- 2.30.2