From 330e765e13717fc4a294302419355a393f000428 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 27 Jul 2008 16:55:31 +0000 Subject: [PATCH] re PR tree-optimization/36830 (STORAGE_ERROR raised compiling s-os_lib.adb) PR tree-optimization/36830 * tree-ssa-sccvn.c (vn_reference_op_compute_hash): Hash operand #2. (expressions_equal_p): Return false if only one operand is null. From-SVN: r138191 --- gcc/ChangeLog | 6 ++++++ gcc/tree-ssa-sccvn.c | 26 +++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 116c3c1067b..c69e60ebd5e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-07-27 Eric Botcazou + + PR tree-optimization/36830 + * tree-ssa-sccvn.c (vn_reference_op_compute_hash): Hash operand #2. + (expressions_equal_p): Return false if only one operand is null. + 2008-07-26 Gerald Pfeifer * doc/install.texi (powerpc-*-netbsd*): Remove redundant texinfo diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 48b5297b4d8..85ceb7e935c 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -319,7 +319,8 @@ static hashval_t vn_reference_op_compute_hash (const vn_reference_op_t vro1) { return iterative_hash_expr (vro1->op0, vro1->opcode) - + iterative_hash_expr (vro1->op1, vro1->opcode); + + iterative_hash_expr (vro1->op1, vro1->opcode) + + iterative_hash_expr (vro1->op2, vro1->opcode); } /* Return the hashcode for a given reference operation P1. */ @@ -2587,22 +2588,24 @@ get_next_value_id (void) } -/* Compare two expressions E1 and E2 and return true if they are - equal. */ +/* Compare two expressions E1 and E2 and return true if they are equal. */ bool expressions_equal_p (tree e1, tree e2) { - tree te1, te2; - + /* The obvious case. */ if (e1 == e2) return true; - te1 = TREE_TYPE (e1); - te2 = TREE_TYPE (e2); - if (te1 != te2) + /* If only one of them is null, they cannot be equal. */ + if (!e1 || !e2) + return false; + + /* Likewise if they are not of the same type. */ + if (TREE_TYPE (e1) != TREE_TYPE (e2)) return false; + /* Recurse on elements of lists. */ if (TREE_CODE (e1) == TREE_LIST && TREE_CODE (e2) == TREE_LIST) { tree lop1 = e1; @@ -2617,10 +2620,11 @@ expressions_equal_p (tree e1, tree e2) return false; } return true; - } - else if (TREE_CODE (e1) == TREE_CODE (e2) - && operand_equal_p (e1, e2, OEP_PURE_SAME)) + + /* Now perform the actual comparison. */ + if (TREE_CODE (e1) == TREE_CODE (e2) + && operand_equal_p (e1, e2, OEP_PURE_SAME)) return true; return false; -- 2.30.2