2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / abs_1.c
blob938bc84ed9599e550e3e8207f371dbb57e7efca3
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-inline --save-temps" } */
4 extern long long llabs (long long);
5 extern void abort (void);
7 long long
8 abs64 (long long a)
10 /* { dg-final { scan-assembler "eor\t" } } */
11 /* { dg-final { scan-assembler "sub\t" } } */
12 return llabs (a);
15 long long
16 abs64_in_dreg (long long a)
18 /* { dg-final { scan-assembler "abs\td\[0-9\]+, d\[0-9\]+" } } */
19 register long long x asm ("d8") = a;
20 register long long y asm ("d9");
21 asm volatile ("" : : "w" (x));
22 y = llabs (x);
23 asm volatile ("" : : "w" (y));
24 return y;
27 int
28 main (void)
30 volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL;
32 if (abs64 (ll0) != 0LL)
33 abort ();
35 if (abs64 (ll1) != 1LL)
36 abort ();
38 if (abs64 (llm1) != 1LL)
39 abort ();
41 if (abs64_in_dreg (ll0) != 0LL)
42 abort ();
44 if (abs64_in_dreg (ll1) != 1LL)
45 abort ();
47 if (abs64_in_dreg (llm1) != 1LL)
48 abort ();
50 return 0;
53 /* { dg-final { cleanup-saved-temps } } */