summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/pr20204.c
blob: ca97a3ae9c725cb8b4a5c45f94f9bc0e5a60055a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* { dg-do run } */
/* { dg-options "-O2" } */

void *x (void *pdst, const void *psrc, unsigned int pn)
{
  register void *return_dst = pdst;
  register unsigned char *dst = pdst;
  register unsigned const char *src = psrc;
  register int n __asm__ ("ebx") = pn;

  if (src < dst && dst < src + n)
    {
      src += n;
      dst += n;
      while (n--)
        *--dst = *--src;
      return return_dst;
    }

  while (n >= 16) n--;

  return return_dst;
}
extern void abort ();
extern void exit (int);
char xx[30] = "abc";
int main (void)
{
  char yy[30] = "aab";

  if (x (xx + 1, xx, 2) != xx + 1 || memcmp (xx, yy, sizeof (yy)) != 0)
    abort ();
  exit (0);
}