re PR rtl-optimization/57381 (array of volatile pointers hangs gcc)
authorRichard Biener <rguenther@suse.de>
Thu, 23 May 2013 10:08:33 +0000 (10:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 23 May 2013 10:08:33 +0000 (10:08 +0000)
2013-05-23  Richard Biener  <rguenther@suse.de>

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.

From-SVN: r199240

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr57381.c [new file with mode: 0644]

index a4bf07a1f92aac1ac1f01d713df4b291626eae20..b9c78a81c86991ebf945ef3a571da721bc326ba7 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-23  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/57381
+       * fold-const.c (operand_equal_p): Compare FIELD_DECLs with
+       OEP_CONSTANT_ADDRESS_OF retained.
+
 2013-05-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/57344
index a2b7ac183126ec6d28afcef4ecea6ca5068809a0..38db3f1d83231fc73f583f6dbd30a568139ddc38 100644 (file)
@@ -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))
index 6485a5cfbe01e34665125b26bad04c58d8630af4..db6e9fa4fdaf3c7c80427e0da8c5128d6a447018 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-23  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/57381
+       * gcc.dg/torture/pr57381.c: New testcase.
+
 2013-05-23  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..c0172b3
--- /dev/null
@@ -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;
+}