PR c/56980
[official-gcc.git] / gcc / testsuite / gcc.dg / pr20126.c
blob257832ab18a5b2bca9d090b376b79617f6e6afb0
1 /* dg-do run */
2 /* dg-options "-O2" */
4 /* PR target/20126 was not really target-specific, but rather a loop's
5 failure to take into account the possibility that a DEST_ADDR giv
6 replacement might fail, such as when you attempt to replace a REG
7 with a PLUS in one of the register_operands of cmpstrqi_rex_1. */
9 extern void abort (void);
11 typedef struct { int a; char b[3]; } S;
12 S c = { 2, "aa" }, d = { 2, "aa" };
14 void *
15 bar (const void *x, int y, int z)
17 return (void *) 0;
20 int
21 foo (S *x, S *y)
23 const char *e, *f, *g;
24 int h;
26 h = y->a;
27 f = y->b;
28 e = x->b;
30 if (h == 1)
31 return bar (e, *f, x->a) != 0;
33 g = e + x->a - h;
34 while (e <= g)
36 const char *t = e + 1;
37 if (__builtin_memcmp (e, f, h) == 0)
38 return 1;
39 e = t;
41 return 0;
44 int
45 main (void)
47 if (foo (&c, &d) != 1)
48 abort ();
49 return 0;