aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/sisd-shft-neg_1.c
blob: c091657cb5751af2d87ae22e67f80fa3f6a1b049 (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
35
36
37
38
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline" } */

extern void abort (void);

#define force_simd_si(v) asm volatile ("mov %s0, %1.s[0]" :"=w" (v) :"w" (v) :)

unsigned int
shft_add (unsigned int a, unsigned int b)
{
  unsigned int c;

  force_simd_si (a);
  force_simd_si (b);
  c = a >> b;
  force_simd_si (c);

  return c + b;
}

int
main (void)
{
  unsigned int i = 0;
  unsigned int a = 0xdeadbeef;

  for (i = 0; i < 32; i++)
  {
    unsigned int exp = (a / (1 << i) + i);
    unsigned int got = shft_add (a, i);

    if (exp != got)
      abort ();
  }

  return 0;
}