From 44f9bcdfef23552aaa2af8f5a5a0cd754fc61dd8 Mon Sep 17 00:00:00 2001 From: ibolton Date: Fri, 3 May 2013 18:30:00 +0000 Subject: [PATCH] AArch64 test cases for TST instruction git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198585 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 + gcc/testsuite/gcc.target/aarch64/tst_1.c | 150 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/aarch64/tst_2.c | 156 +++++++++++++++++++++++++++++++ 3 files changed, 311 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/tst_1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/tst_2.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d673f44..6e279dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-03 Ian Bolton + + * gcc.target/aarch64/tst_1.c: New test. + * gcc.target/aarch64/tst_2.c: Likewise + 2013-05-02 Jeff Law PR tree-optimization/57144 diff --git a/gcc/testsuite/gcc.target/aarch64/tst_1.c b/gcc/testsuite/gcc.target/aarch64/tst_1.c new file mode 100644 index 0000000..4838b1b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/tst_1.c @@ -0,0 +1,150 @@ +/* { dg-do run } */ +/* { dg-options "-O2 --save-temps -fno-inline" } */ + +extern void abort (void); + +int +tst_si_test1 (int a, int b, int c) +{ + int d = a & b; + + /* { dg-final { scan-assembler-times "tst\tw\[0-9\]+, w\[0-9\]+" 2 } } */ + if (d == 0) + return 12; + else + return 18; +} + +int +tst_si_test2 (int a, int b, int c) +{ + int d = a & 0x99999999; + + /* { dg-final { scan-assembler "tst\tw\[0-9\]+, -1717986919" } } */ + if (d == 0) + return 12; + else + return 18; +} + +int +tst_si_test3 (int a, int b, int c) +{ + int d = a & (b << 3); + + /* { dg-final { scan-assembler "tst\tw\[0-9\]+, w\[0-9\]+, lsl 3" } } */ + if (d == 0) + return 12; + else + return 18; +} + +typedef long long s64; + +s64 +tst_di_test1 (s64 a, s64 b, s64 c) +{ + s64 d = a & b; + + /* { dg-final { scan-assembler-times "tst\tx\[0-9\]+, x\[0-9\]+" 2 } } */ + if (d == 0) + return 12; + else + return 18; +} + +s64 +tst_di_test2 (s64 a, s64 b, s64 c) +{ + s64 d = a & 0xaaaaaaaaaaaaaaaall; + + /* { dg-final { scan-assembler "tst\tx\[0-9\]+, -6148914691236517206" } } */ + if (d == 0) + return 12; + else + return 18; +} + +s64 +tst_di_test3 (s64 a, s64 b, s64 c) +{ + s64 d = a & (b << 3); + + /* { dg-final { scan-assembler "tst\tx\[0-9\]+, x\[0-9\]+, lsl 3" } } */ + if (d == 0) + return 12; + else + return 18; +} + +int +main () +{ + int x; + s64 y; + + x = tst_si_test1 (29, 4, 5); + if (x != 18) + abort (); + + x = tst_si_test1 (5, 2, 20); + if (x != 12) + abort (); + + x = tst_si_test2 (29, 4, 5); + if (x != 18) + abort (); + + x = tst_si_test2 (1024, 2, 20); + if (x != 12) + abort (); + + x = tst_si_test3 (35, 4, 5); + if (x != 18) + abort (); + + x = tst_si_test3 (5, 2, 20); + if (x != 12) + abort (); + + y = tst_di_test1 (0x130000029ll, + 0x320000004ll, + 0x505050505ll); + + if (y != 18) + abort (); + + y = tst_di_test1 (0x5000500050005ll, + 0x2111211121112ll, + 0x0000000002020ll); + if (y != 12) + abort (); + + y = tst_di_test2 (0x130000029ll, + 0x320000004ll, + 0x505050505ll); + if (y != 18) + abort (); + + y = tst_di_test2 (0x540004100ll, + 0x320000004ll, + 0x805050205ll); + if (y != 12) + abort (); + + y = tst_di_test3 (0x130000029ll, + 0x064000008ll, + 0x505050505ll); + if (y != 18) + abort (); + + y = tst_di_test3 (0x130002900ll, + 0x088000008ll, + 0x505050505ll); + if (y != 12) + abort (); + + return 0; +} + +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/tst_2.c b/gcc/testsuite/gcc.target/aarch64/tst_2.c new file mode 100644 index 0000000..1e80904 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/tst_2.c @@ -0,0 +1,156 @@ +/* { dg-do run } */ +/* { dg-options "-O2 --save-temps -fno-inline" } */ + +extern void abort (void); + +int +tst_si_test1 (int a, int b, int c) +{ + int d = a & b; + + /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } } */ + /* { dg-final { scan-assembler-times "and\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" 2 } } */ + if (d <= 0) + return 12; + else + return 18; +} + +int +tst_si_test2 (int a, int b, int c) +{ + int d = a & 0x99999999; + + /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, -1717986919" } } */ + /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, -1717986919" } } */ + if (d <= 0) + return 12; + else + return 18; +} + +int +tst_si_test3 (int a, int b, int c) +{ + int d = a & (b << 3); + + /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */ + /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */ + if (d <= 0) + return 12; + else + return 18; +} + +typedef long long s64; + +s64 +tst_di_test1 (s64 a, s64 b, s64 c) +{ + s64 d = a & b; + + /* { dg-final { scan-assembler-not "tst\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } } */ + /* { dg-final { scan-assembler-times "and\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" 2 } } */ + if (d <= 0) + return 12; + else + return 18; +} + +s64 +tst_di_test2 (s64 a, s64 b, s64 c) +{ + s64 d = a & 0xaaaaaaaaaaaaaaaall; + + /* { dg-final { scan-assembler-not "tst\tx\[0-9\]+, x\[0-9\]+, -6148914691236517206" } } */ + /* { dg-final { scan-assembler "and\tx\[0-9\]+, x\[0-9\]+, -6148914691236517206" } } */ + if (d <= 0) + return 12; + else + return 18; +} + +s64 +tst_di_test3 (s64 a, s64 b, s64 c) +{ + s64 d = a & (b << 3); + + /* { dg-final { scan-assembler-not "tst\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */ + /* { dg-final { scan-assembler "and\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */ + if (d <= 0) + return 12; + else + return 18; +} + +int +main () +{ + int x; + s64 y; + + x = tst_si_test1 (29, 4, 5); + if (x != 18) + abort (); + + x = tst_si_test1 (5, 2, 20); + if (x != 12) + abort (); + + x = tst_si_test2 (29, 4, 5); + if (x != 18) + abort (); + + x = tst_si_test2 (1024, 2, 20); + if (x != 12) + abort (); + + x = tst_si_test3 (35, 4, 5); + if (x != 18) + abort (); + + x = tst_si_test3 (5, 2, 20); + if (x != 12) + abort (); + + y = tst_di_test1 (0x130000029ll, + 0x320000004ll, + 0x505050505ll); + + if (y != 18) + abort (); + + y = tst_di_test1 (0x5000500050005ll, + 0x2111211121112ll, + 0x0000000002020ll); + if (y != 12) + abort (); + + y = tst_di_test2 (0x130000029ll, + 0x320000004ll, + 0x505050505ll); + if (y != 18) + abort (); + + y = tst_di_test2 (0x540004100ll, + 0x320000004ll, + 0x805050205ll); + if (y != 12) + abort (); + + y = tst_di_test3 (0x130000029ll, + 0x064000008ll, + 0x505050505ll); + if (y != 18) + abort (); + + y = tst_di_test3 (0x130002900ll, + 0x088000008ll, + 0x505050505ll); + if (y != 12) + abort (); + + return 0; +} + +/* { dg-final { cleanup-saved-temps } } */ -- 2.7.4