diff options
author | Richard Biener <rguenther@suse.de> | 2017-03-28 10:10:01 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-03-28 10:10:01 +0000 |
commit | 737f500a0bb2cfdf1e28975a27403e555ede633e (patch) | |
tree | e79b9e94380748bba99a522e52b8dd348721a2c6 /gcc | |
parent | 62f96a79f10e0c6772e5302c076b8c062e42b0d9 (diff) | |
download | gcc-737f500a0bb2cfdf1e28975a27403e555ede633e.zip gcc-737f500a0bb2cfdf1e28975a27403e555ede633e.tar.gz gcc-737f500a0bb2cfdf1e28975a27403e555ede633e.tar.bz2 |
re PR middle-end/80222 (may_alias folded away)
2017-03-28 Richard Biener <rguenther@suse.de>
PR middle-end/80222
* gimple-fold.c (gimple_fold_indirect_ref): Do not touch
TYPE_REF_CAN_ALIAS_ALL references.
* fold-const.c (fold_indirect_ref_1): Likewise.
* g++.dg/pr80222.C: New testcase.
From-SVN: r246527
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fold-const.c | 3 | ||||
-rw-r--r-- | gcc/gimple-fold.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/pr80222.C | 13 |
5 files changed, 31 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 27e7b8f..7274aa4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-03-28 Richard Biener <rguenther@suse.de> + + PR middle-end/80222 + * gimple-fold.c (gimple_fold_indirect_ref): Do not touch + TYPE_REF_CAN_ALIAS_ALL references. + * fold-const.c (fold_indirect_ref_1): Likewise. + 2017-03-28 Martin Liska <mliska@suse.cz> PR ipa/80104 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 6db16b5..fb54ffa 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -14006,7 +14006,8 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0) STRIP_NOPS (sub); subtype = TREE_TYPE (sub); - if (!POINTER_TYPE_P (subtype)) + if (!POINTER_TYPE_P (subtype) + || TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (op0))) return NULL_TREE; if (TREE_CODE (sub) == ADDR_EXPR) diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 3094b54..a6a958c 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -6539,8 +6539,8 @@ gimple_get_virt_method_for_binfo (HOST_WIDE_INT token, tree known_binfo, return gimple_get_virt_method_for_vtable (token, v, offset, can_refer); } -/* Given a pointer value OP0, return a simplified version of an - indirection through OP0, or NULL_TREE if no simplification is +/* Given a pointer value T, return a simplified version of an + indirection through T, or NULL_TREE if no simplification is possible. Note that the resulting type may be different from the type pointed to in the sense that it is still compatible from the langhooks point of view. */ @@ -6554,7 +6554,8 @@ gimple_fold_indirect_ref (tree t) STRIP_NOPS (sub); subtype = TREE_TYPE (sub); - if (!POINTER_TYPE_P (subtype)) + if (!POINTER_TYPE_P (subtype) + || TYPE_REF_CAN_ALIAS_ALL (ptype)) return NULL_TREE; if (TREE_CODE (sub) == ADDR_EXPR) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a896f75..4abe1dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-28 Richard Biener <rguenther@suse.de> + + PR middle-end/80222 + * g++.dg/pr80222.C: New testcase. + 2017-03-28 Martin Liska <mliska@suse.cz> PR ipa/80104 diff --git a/gcc/testsuite/g++.dg/pr80222.C b/gcc/testsuite/g++.dg/pr80222.C new file mode 100644 index 0000000..ed1b37f --- /dev/null +++ b/gcc/testsuite/g++.dg/pr80222.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-optimized" } */ + +struct C { int i; }__attribute__((may_alias)) ; + +C a, b; + +int main() +{ + a = static_cast <C&> (b); +} + +// { dg-final { scan-tree-dump "{ref-all}\\\)&b\];" "optimized" } } */ |