Commit a60749f5 by Richard Kenner Committed by Richard Kenner

fold-const.c (operand_equal_p): Remove code to allow null ARG0/1.

	* fold-const.c (operand_equal_p): Remove code to allow null ARG0/1.
	Define locals macros OP_SAME and OP_SAME_WITH_NULL and use throughout.

From-SVN: r87082
parent 8d168c24
2004-09-04 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* fold-const.c (operand_equal_p): Remove code to allow null ARG0/1.
Define locals macros OP_SAME and OP_SAME_WITH_NULL and use throughout.
2004-09-04 Jan Hubicka <jh@suse.cz> 2004-09-04 Jan Hubicka <jh@suse.cz>
* passes.c (rest_of_clean_state): Fix merge conflict made during * passes.c (rest_of_clean_state): Fix merge conflict made during
......
...@@ -2285,17 +2285,8 @@ truth_value_p (enum tree_code code) ...@@ -2285,17 +2285,8 @@ truth_value_p (enum tree_code code)
int int
operand_equal_p (tree arg0, tree arg1, unsigned int flags) 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 either is ERROR_MARK, they aren't equal. */
else if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK) if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK)
return 0; return 0;
/* If both types don't have the same signedness, then we can't consider /* If both types don't have the same signedness, then we can't consider
...@@ -2387,6 +2378,17 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags) ...@@ -2387,6 +2378,17 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
if (flags & OEP_ONLY_CONST) if (flags & OEP_ONLY_CONST)
return 0; return 0;
/* Define macros to test an operan from arg0 and arg1 for equality and a
variant that allows null and views null as being different from any
non-null value. In the latter case, if either is null, the both
must be; otherwise, do the normal comparison. */
#define OP_SAME(N) operand_equal_p (TREE_OPERAND (arg0, N), \
TREE_OPERAND (arg1, N), flags)
#define OP_SAME_WITH_NULL(N) \
((!TREE_OPERAND (arg0, N) || !TREE_OPERAND (arg1, N)) \
? TREE_OPERAND (arg0, N) == TREE_OPERAND (arg1, N) : OP_SAME (N))
switch (TREE_CODE_CLASS (TREE_CODE (arg0))) switch (TREE_CODE_CLASS (TREE_CODE (arg0)))
{ {
case '1': case '1':
...@@ -2407,15 +2409,11 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags) ...@@ -2407,15 +2409,11 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
break; break;
} }
return operand_equal_p (TREE_OPERAND (arg0, 0), return OP_SAME (0);
TREE_OPERAND (arg1, 0), flags);
case '<': case '<':
case '2': case '2':
if (operand_equal_p (TREE_OPERAND (arg0, 0), if (OP_SAME (0) && OP_SAME (1))
TREE_OPERAND (arg1, 0), flags)
&& operand_equal_p (TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg1, 1), flags))
return 1; return 1;
/* For commutative ops, allow the other order. */ /* For commutative ops, allow the other order. */
...@@ -2437,37 +2435,23 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags) ...@@ -2437,37 +2435,23 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
case INDIRECT_REF: case INDIRECT_REF:
case REALPART_EXPR: case REALPART_EXPR:
case IMAGPART_EXPR: case IMAGPART_EXPR:
return operand_equal_p (TREE_OPERAND (arg0, 0), return OP_SAME (0);
TREE_OPERAND (arg1, 0), flags);
case ARRAY_REF: case ARRAY_REF:
case ARRAY_RANGE_REF: case ARRAY_RANGE_REF:
return (operand_equal_p (TREE_OPERAND (arg0, 0), /* Operands 2 and 3 may be null. */
TREE_OPERAND (arg1, 0), flags) return (OP_SAME (0)
&& operand_equal_p (TREE_OPERAND (arg0, 1), && OP_SAME (1)
TREE_OPERAND (arg1, 1), flags) && OP_SAME_WITH_NULL (2)
&& operand_equal_p (TREE_OPERAND (arg0, 2), && OP_SAME_WITH_NULL (3));
TREE_OPERAND (arg1, 2), flags)
&& operand_equal_p (TREE_OPERAND (arg0, 3),
TREE_OPERAND (arg1, 3), flags));
case COMPONENT_REF: case COMPONENT_REF:
return (operand_equal_p (TREE_OPERAND (arg0, 0), /* Handle operand 2 the same as for ARRAY_REF. */
TREE_OPERAND (arg1, 0), flags) return OP_SAME (0) && OP_SAME (1) && OP_SAME_WITH_NULL (2);
&& 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: case BIT_FIELD_REF:
return (operand_equal_p (TREE_OPERAND (arg0, 0), return OP_SAME (0) && OP_SAME (1) && OP_SAME (2);
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));
default: default:
return 0; return 0;
} }
...@@ -2477,33 +2461,28 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags) ...@@ -2477,33 +2461,28 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
{ {
case ADDR_EXPR: case ADDR_EXPR:
case TRUTH_NOT_EXPR: case TRUTH_NOT_EXPR:
return operand_equal_p (TREE_OPERAND (arg0, 0), return OP_SAME (0);
TREE_OPERAND (arg1, 0), flags);
case TRUTH_ANDIF_EXPR: case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR: case TRUTH_ORIF_EXPR:
return operand_equal_p (TREE_OPERAND (arg0, 0), return OP_SAME (0) && OP_SAME (1);
TREE_OPERAND (arg1, 0), flags)
&& operand_equal_p (TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg1, 1), flags);
case TRUTH_AND_EXPR: case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR: case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR: case TRUTH_XOR_EXPR:
if (OP_SAME (0) && OP_SAME (1))
return 1;
/* Otherwise take into account this is a commutative operation. */
return (operand_equal_p (TREE_OPERAND (arg0, 0), return (operand_equal_p (TREE_OPERAND (arg0, 0),
TREE_OPERAND (arg1, 0), flags) TREE_OPERAND (arg1, 1), flags)
&& operand_equal_p (TREE_OPERAND (arg0, 1), && operand_equal_p (TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg1, 1), flags)) TREE_OPERAND (arg1, 0), 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 CALL_EXPR: case CALL_EXPR:
/* If the CALL_EXPRs call different functions, then they /* If the CALL_EXPRs call different functions, then they
clearly can not be equal. */ clearly can not be equal. */
if (! operand_equal_p (TREE_OPERAND (arg0, 0), if (!OP_SAME (0))
TREE_OPERAND (arg1, 0), flags))
return 0; return 0;
{ {
...@@ -2549,6 +2528,9 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags) ...@@ -2549,6 +2528,9 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
default: default:
return 0; return 0;
} }
#undef OP_SAME
#undef OP_SAME_WITH_NULL
} }
/* Similar to operand_equal_p, but see if ARG0 might have been made by /* Similar to operand_equal_p, but see if ARG0 might have been made by
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment