aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/neg_1.c
blob: 04b0fdd2313f7d37e57fad6fc427512c41080d6d (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline --save-temps" } */

extern void abort (void);

long long
neg64 (long long a)
{
  /* { dg-final { scan-assembler "neg\tx\[0-9\]+" } } */
  return 0 - a;
}

long long
neg64_in_dreg (long long a)
{
  /* { dg-final { scan-assembler "neg\td\[0-9\]+, d\[0-9\]+" } } */
  register long long x asm ("d8") = a;
  register long long y asm ("d9");
  asm volatile ("" : : "w" (x));
  y = 0 - x;
  asm volatile ("" : : "w" (y));
  return y;
}

int
neg32 (int a)
{
  /* { dg-final { scan-assembler "neg\tw\[0-9\]+" } } */
  return 0 - a;
}

int
neg32_in_sreg (int a)
{
  /* { dg-final { scan-assembler "neg\tv\[0-9\]+\.2s, v\[0-9\]+\.2s" } } */
  register int x asm ("s8") = a;
  register int y asm ("s9");
  asm volatile ("" : : "w" (x));
  y = 0 - x;
  asm volatile ("" : : "w" (y));
  return y;
}

int
main (void)
{
  long long a;
  int b;
  a = 61;
  b = 313;

  if (neg64 (a) != -61)
    abort ();

  if (neg64_in_dreg (a) != -61)
    abort ();

  if (neg32 (b) != -313)
    abort ();

  if (neg32_in_sreg (b) != -313)
    abort ();

  return 0;
}

/* { dg-final { cleanup-saved-temps } } */