aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr98190.c
blob: bfdd17d927080c381ace87c595606cb4dce4e43f (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
/* PR middle-end/98190 */
/* { dg-do run } */
/* { dg-options "-O2" } */

static int __attribute__((noipa))
foo (const char *p, const char *q, const int len)
{
  for (int i = 0; i < len; p++, q++, i++)
    {
      int equal;
      _Bool x, y;
      __builtin_memcpy ((char *) &x, p, sizeof x);
      __builtin_memcpy ((char *) &y, q, sizeof y);
      equal = (x == y);
      if (equal <= 0)
	return equal;
    }
  return 1;
}

int
main ()
{
  const _Bool buf[4] = { 1, 0, 0, 0 };
#ifdef __aarch64__
  register long x4 asm ("x4") = 0xdeadbeefULL;
  register long x5 asm ("x5") = 0xcafebabeULL;
  asm volatile (""::"r" (x4), "r" (x5));
#endif
  if (foo ((char *) &buf[0], (char *) &buf[0], 1) != 1)
    __builtin_abort ();
  return 0;
}