From: Richard Guenther Date: Wed, 5 Jul 2006 10:54:17 +0000 (+0000) Subject: re PR middle-end/27084 (Does not propagate memory load base through useless type... X-Git-Tag: releases/gcc-4.2.0~2188 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09b868558b4beffb64f04223ffb981d92052b53e;p=thirdparty%2Fgcc.git re PR middle-end/27084 (Does not propagate memory load base through useless type conversion) 2006-07-05 Richard Guenther Andrew Pinski PR c++/27084 * cp-objcp-common.c (cxx_types_compatible_p): Ignore top level qualifiers for pointer type comparisons. * g++.dg/tree-ssa/copyprop-1.C: New testcase. Co-Authored-By: Andrew Pinski From-SVN: r115200 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 896749ede5d3..d2c0562851b4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2006-07-05 Richard Guenther + Andrew Pinski + + PR c++/27084 + * cp-objcp-common.c (cxx_types_compatible_p): Ignore + top level qualifiers for pointer type comparisons. + 2006-07-01 Jason Merrill PR c++/28215 diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index cb8369cb53b2..0b27abf101ec 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -179,7 +179,8 @@ cxx_types_compatible_p (tree x, tree y) if (POINTER_TYPE_P (x) && POINTER_TYPE_P (y) && TYPE_MODE (x) == TYPE_MODE (y) && TYPE_REF_CAN_ALIAS_ALL (x) == TYPE_REF_CAN_ALIAS_ALL (y) - && same_type_p (TREE_TYPE (x), TREE_TYPE (y))) + && same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (x), + TREE_TYPE (y))) return 1; return 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a0ef64223dad..02e6dd1f7080 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-07-05 Richard Guenther + Andrew Pinski + + PR c++/27084 + * g++.dg/tree-ssa/copyprop-1.C: New testcase. + 2006-07-04 Paul Thomas PR fortran/28174 diff --git a/gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C b/gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C new file mode 100644 index 000000000000..2be046915378 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-dce2" } */ + +/* Verify that we can eliminate the useless conversions to/from + const qualified pointer types + this_2 = o_1; + D.20003_4 = this_2->data_m; + this_5 = D.20003_4; + D.20005_6 = this_5->value; + copyprop should propagate o_1 and D.20003_4 to the loads of data_m + and value. dce removes all traces of this. */ + +struct Data { + int get() const { return value; } + int value; +}; + +struct Object { + int operator[](int i) const { return data_m->get(); } + Data *data_m; +}; + +int foo(Object&o) +{ + return o[0]; +} + +/* { dg-final { scan-tree-dump-not ".* = \[^>;\]*;" "dce2" } } */ +/* { dg-final { cleanup-tree-dump "dce2" } } */