aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/pr63843.c
blob: 9f6c7b06c391fd70ca2ce76ecccf110a537b77b8 (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
/* PR rtl-optimization/63843 */

static inline __attribute__ ((always_inline))
unsigned short foo (unsigned short v)
{
  return (v << 8) | (v >> 8);
}

unsigned short __attribute__ ((noinline, noclone, hot))
bar (unsigned char *x)
{
  unsigned int a;
  unsigned short b;
  __builtin_memcpy (&a, &x[0], sizeof (a));
  a ^= 0x80808080U;
  __builtin_memcpy (&x[0], &a, sizeof (a));
  __builtin_memcpy (&b, &x[2], sizeof (b));
  return foo (b);
}

int
main ()
{
  unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 };
  if (__CHAR_BIT__ == 8
      && sizeof (short) == 2
      && sizeof (int) == 4
      && bar (x) != 0x8181U)
    __builtin_abort ();
  return 0;
}