aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-04-26 09:21:44 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-04-26 09:21:44 +0000
commitad0e2567d69760fa7156ef24418b4d10f99def6a (patch)
tree8ff4c2719e2c23a082193dd49ef8d3a607ac33e4 /gcc/fold-const.c
parent0d467c0bf219265a40b0cfe284092ec5382d4b1a (diff)
downloadgcc-ad0e2567d69760fa7156ef24418b4d10f99def6a.zip
gcc-ad0e2567d69760fa7156ef24418b4d10f99def6a.tar.gz
gcc-ad0e2567d69760fa7156ef24418b4d10f99def6a.tar.bz2
re PR tree-optimization/48694 (possible memory hog bug)
2011-04-26 Richard Guenther <rguenther@suse.de> PR middle-end/48694 * tree.h (OEP_CONSTANT_ADDRESS_OF): New operand_equal_flag. * fold-const.c (operand_equal_p): For TREE_CONSTANT ADDR_EXPRs compare the operands with OEP_CONSTANT_ADDRESS_OF. Treat trees with TREE_SIDE_EFFECTS equal when OEP_CONSTANT_ADDRESS_OF is set. * gcc.dg/torture/pr48694-1.c: New testcase. * gcc.dg/torture/pr48694-2.c: Likewise. From-SVN: r172954
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 8f90f6f..1aa0dec 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2473,9 +2473,12 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
equal if they have no side effects. If we have two identical
expressions with side effects that should be treated the same due
to the only side effects being identical SAVE_EXPR's, that will
- be detected in the recursive calls below. */
+ be detected in the recursive calls below.
+ If we are taking an invariant address of two identical objects
+ they are necessarily equal as well. */
if (arg0 == arg1 && ! (flags & OEP_ONLY_CONST)
&& (TREE_CODE (arg0) == SAVE_EXPR
+ || (flags & OEP_CONSTANT_ADDRESS_OF)
|| (! TREE_SIDE_EFFECTS (arg0) && ! TREE_SIDE_EFFECTS (arg1))))
return 1;
@@ -2538,7 +2541,8 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
case ADDR_EXPR:
return operand_equal_p (TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 0),
- 0);
+ TREE_CONSTANT (arg0) && TREE_CONSTANT (arg1)
+ ? OEP_CONSTANT_ADDRESS_OF : 0);
default:
break;
}