From 324d4d99f52dd36164839ec8133d37147b4d4a7b Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 23 May 2013 10:08:33 +0000 Subject: [PATCH] 2013-05-23 Richard Biener PR middle-end/57381 * fold-const.c (operand_equal_p): Compare FIELD_DECLs with OEP_CONSTANT_ADDRESS_OF retained. * gcc.dg/torture/pr57381.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199240 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr57381.c | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr57381.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a4bf07a..b9c78a8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-05-23 Richard Biener + + PR middle-end/57381 + * fold-const.c (operand_equal_p): Compare FIELD_DECLs with + OEP_CONSTANT_ADDRESS_OF retained. + 2013-05-23 Jakub Jelinek PR middle-end/57344 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a2b7ac1..38db3f1 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2664,10 +2664,10 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) case COMPONENT_REF: /* Handle operand 2 the same as for ARRAY_REF. Operand 0 may be NULL when we're called to compare MEM_EXPRs. */ - if (!OP_SAME_WITH_NULL (0)) + if (!OP_SAME_WITH_NULL (0) || !OP_SAME (1)) return 0; flags &= ~OEP_CONSTANT_ADDRESS_OF; - return OP_SAME (1) && OP_SAME_WITH_NULL (2); + return OP_SAME_WITH_NULL (2); case BIT_FIELD_REF: if (!OP_SAME (0)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6485a5c..db6e9fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-23 Richard Biener + + PR middle-end/57381 + * gcc.dg/torture/pr57381.c: New testcase. + 2013-05-23 Jakub Jelinek PR middle-end/57344 diff --git a/gcc/testsuite/gcc.dg/torture/pr57381.c b/gcc/testsuite/gcc.dg/torture/pr57381.c new file mode 100644 index 0000000..c0172b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57381.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +struct S0 { int f0, f1, f2; }; + +struct S1 { + int f0; + volatile struct S0 f2; +}; + +static struct S1 s = {0x47BED265,{0x06D4EB3E,5,0U}}; + +int foo(struct S0 p) +{ + for (s.f2.f2 = 0; (s.f2.f2 <= 12); s.f2.f2++) + { + volatile int *l_61[5][2][2] = {{{&s.f2.f0,&s.f2.f0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,&s.f2.f0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,(void*)0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,&s.f2.f0},{&s.f2.f0,&s.f2.f0}},{{&s.f2.f0,&s.f2.f0},{(void*)0,&s.f2.f0}}}; + + volatile int **l_68 = &l_61[0][0][1]; + volatile int *l_76 = &s.f2.f0; + (*l_68) = l_61[0][0][0]; + if ((*l_76 = (p.f2 % 5))) ; + } + return p.f0; +} -- 2.7.4