1/* This failed on s390x due to bug in loop.c.
2   loop.c failed to remove a REG_EQUAL note when
3   hoisting an insn from a loop body.  */
4
5/* { dg-options "-O3 -fPIC" } */
6/* { dg-do run { target fpic } } */
7
8typedef __SIZE_TYPE__ size_t;
9int memcmp(const void *s1, const void *s2, size_t n);
10
11typedef struct
12{
13  char name[30];
14  int a;
15} LOCAL;
16
17int global = 0;
18int sy = 1;
19int subroutine_offset;
20
21LOCAL local = { "local", 0 };
22LOCAL keywords = { "keywords", 1 };
23int local_table = 0;
24int keywords_table = 0;
25
26void __attribute__((noinline)) bar (char *p_buffer)
27{
28  p_buffer[255] = 1;
29}
30
31int __attribute__((noinline)) foo (char *p_str1)
32{
33  global = 1;
34  return 1;
35}
36
37int __attribute__((noinline)) loop_next (int *p_table, char *p_table_head)
38{
39  static int loop_next = 0;
40
41  if (loop_next == 1)
42    return 1;
43
44  loop_next = 1;
45  return 0;
46}
47
48int
49main ()
50{
51  char buffer[256];
52  int ende = 0;
53  int index;
54  int local_base = 2;
55
56  keywords.a = 1;
57  for (sy = 0;; sy++)
58    {
59      for (index = 1;;)
60	{
61	  bar (buffer);
62	  if (buffer[sy] != 0)
63	    {
64	      ende = 1;
65	      break;
66	    };
67	  if (foo (buffer))
68	    {
69	      keywords.a += index - 1;
70	      break;
71	    }
72	  index++;
73	}
74      if (ende)
75	break;
76    }
77
78  subroutine_offset = 0;
79
80  for (;;)
81    {
82      if (loop_next (&keywords_table, (char*)&keywords))
83	break;
84
85      if ((!memcmp (keywords.name, "+++", 3)))
86	local_base = 100;
87      else
88	local_base = 0;
89
90      if ((!memcmp (keywords.name, "+++", 3)))
91	subroutine_offset += local_table;
92
93      for (;;)
94	{
95	  if (loop_next (&local_table, (char*)&local))
96	    break;;
97	  if ((local.a == 0))
98	    continue;;
99	  foo (local.name);
100	}
101    }
102  return 0;
103}
104