aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/abs_1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/aarch64/abs_1.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/aarch64/abs_1.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/aarch64/abs_1.c b/gcc-4.9/gcc/testsuite/gcc.target/aarch64/abs_1.c
new file mode 100644
index 000000000..938bc84ed
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/aarch64/abs_1.c
@@ -0,0 +1,53 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline --save-temps" } */
+
+extern long long llabs (long long);
+extern void abort (void);
+
+long long
+abs64 (long long a)
+{
+ /* { dg-final { scan-assembler "eor\t" } } */
+ /* { dg-final { scan-assembler "sub\t" } } */
+ return llabs (a);
+}
+
+long long
+abs64_in_dreg (long long a)
+{
+ /* { dg-final { scan-assembler "abs\td\[0-9\]+, d\[0-9\]+" } } */
+ register long long x asm ("d8") = a;
+ register long long y asm ("d9");
+ asm volatile ("" : : "w" (x));
+ y = llabs (x);
+ asm volatile ("" : : "w" (y));
+ return y;
+}
+
+int
+main (void)
+{
+ volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL;
+
+ if (abs64 (ll0) != 0LL)
+ abort ();
+
+ if (abs64 (ll1) != 1LL)
+ abort ();
+
+ if (abs64 (llm1) != 1LL)
+ abort ();
+
+ if (abs64_in_dreg (ll0) != 0LL)
+ abort ();
+
+ if (abs64_in_dreg (ll1) != 1LL)
+ abort ();
+
+ if (abs64_in_dreg (llm1) != 1LL)
+ abort ();
+
+ return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */