aboutsummaryrefslogtreecommitdiff
path: root/gcc/cse.c
diff options
context:
space:
mode:
authorSteven Bosscher <stevenb.gcc@gmail.com>2006-01-03 06:20:21 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2006-01-03 06:20:21 +0000
commit78b76d0884d435c6e05d023db71a8b00c0f044b2 (patch)
tree0f27e072946d5679715a3b35a103656388cb972e /gcc/cse.c
parent0884546e1b92fe109e30cca3295e6212e4b24567 (diff)
downloadgcc-78b76d0884d435c6e05d023db71a8b00c0f044b2.zip
gcc-78b76d0884d435c6e05d023db71a8b00c0f044b2.tar.gz
gcc-78b76d0884d435c6e05d023db71a8b00c0f044b2.tar.bz2
re PR rtl-optimization/25130 (miscompilation in GCSE)
* fold-const.c (operand_equal_p): Accept a NULL operand 0 for COMPONENT_REFs. * emit-rtl.c (mem_attrs_htab_eq): Use iterative_hash_expr for hashing trees instead of a pointer hash. (mem_attrs_htab_eq): Do a deep compare instead of a pointer compare for MEM_EXPR. PR rtl-optimization/25130 * cse.c (exp_equiv_p): Compare MEM_ATTRS instead of MEM_ALIAS_SET when comparing MEMs for GCSE From-SVN: r109264
Diffstat (limited to 'gcc/cse.c')
-rw-r--r--gcc/cse.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/cse.c b/gcc/cse.c
index 284f3fd..a352c0e 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -2538,16 +2538,26 @@ exp_equiv_p (rtx x, rtx y, int validate, bool for_gcse)
case MEM:
if (for_gcse)
{
- /* Can't merge two expressions in different alias sets, since we
- can decide that the expression is transparent in a block when
- it isn't, due to it being set with the different alias set. */
- if (MEM_ALIAS_SET (x) != MEM_ALIAS_SET (y))
- return 0;
-
/* A volatile mem should not be considered equivalent to any
other. */
if (MEM_VOLATILE_P (x) || MEM_VOLATILE_P (y))
return 0;
+
+ /* Can't merge two expressions in different alias sets, since we
+ can decide that the expression is transparent in a block when
+ it isn't, due to it being set with the different alias set.
+
+ Also, can't merge two expressions with different MEM_ATTRS.
+ They could e.g. be two different entities allocated into the
+ same space on the stack (see e.g. PR25130). In that case, the
+ MEM addresses can be the same, even though the two MEMs are
+ absolutely not equivalent.
+
+ But because really all MEM attributes should be the same for
+ equivalent MEMs, we just use the invariant that MEMs that have
+ the same attributes share the same mem_attrs data structure. */
+ if (MEM_ATTRS (x) != MEM_ATTRS (y))
+ return 0;
}
break;