diff options
author | Richard Guenther <rguenther@suse.de> | 2007-09-07 11:57:57 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2007-09-07 11:57:57 +0000 |
commit | ccf64c833ffaa36f74940afcdaef57a688bb4dcf (patch) | |
tree | 0514e97c90603913cf1160e3082b070b0b763294 | |
parent | 201b2eadc44a3217be14bed57b979dc4b01a5990 (diff) | |
download | gcc-ccf64c833ffaa36f74940afcdaef57a688bb4dcf.tar.gz |
re PR middle-end/33330 (Wrong alias for accessing scalar through array)
2007-09-07 Richard Guenther <rguenther@suse.de>
PR middle-end/33330
* tree-ssa-operands.c (access_can_touch_variable): An access
of the form (*p)[0] can touch a variable of same size.
From-SVN: r128240
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/tree-ssa-operands.c | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be49cf50e60..a63a9e9748d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-09-07 Richard Guenther <rguenther@suse.de> + + PR middle-end/33330 + * tree-ssa-operands.c (access_can_touch_variable): An access + of the form (*p)[0] can touch a variable of same size. + 2007-09-07 Jan Hubicka <jh@suse.cz> * passes.c (init_optimization_passes): Add simple dce and addressable diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index c18f97d4960..a3e34ecc766 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -1292,6 +1292,15 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset, } To implement this, we just punt on accesses through union pointers entirely. + + Another case we have to allow is accessing a variable + through an array access at offset zero. This happens from + code generated by the fortran frontend like + + char[1:1] & my_char_ref; + char my_char; + my_char_ref_1 = (char[1:1] &) &my_char; + D.874_2 = (*my_char_ref_1)[1]{lb: 1 sz: 1}; */ else if (ref && flag_strict_aliasing @@ -1300,6 +1309,14 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset, && base && (TREE_CODE (base) != INDIRECT_REF || TREE_CODE (TREE_TYPE (base)) != UNION_TYPE) + && (TREE_CODE (base) != INDIRECT_REF + || TREE_CODE (ref) != ARRAY_REF + || offset != 0 + || (DECL_SIZE (alias) + && TREE_CODE (DECL_SIZE (alias)) == INTEGER_CST + && size != -1 + && (unsigned HOST_WIDE_INT)size + != TREE_INT_CST_LOW (DECL_SIZE (alias)))) && !AGGREGATE_TYPE_P (TREE_TYPE (alias)) && TREE_CODE (TREE_TYPE (alias)) != COMPLEX_TYPE && !var_ann (alias)->is_heapvar |