aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Endo <olegendo@gcc.gnu.org>2012-07-02 22:59:59 +0000
committerOleg Endo <olegendo@gcc.gnu.org>2012-07-02 22:59:59 +0000
commit0f676cfe574afcce819bc95889b1fe094e467715 (patch)
treed899b1ff41a891f0d864b615743db645236823b3
parentf031c3441f38fb0c27bb11eae460191e7a2e9e28 (diff)
downloadgcc-0f676cfe574afcce819bc95889b1fe094e467715.zip
gcc-0f676cfe574afcce819bc95889b1fe094e467715.tar.gz
gcc-0f676cfe574afcce819bc95889b1fe094e467715.tar.bz2
re PR target/53568 (SH Target: Add support for bswap built-ins)
PR target/53568 * gcc.target/sh/pr53568-1.c: New. From-SVN: r189181
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/sh/pr53568-1.c82
2 files changed, 87 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 916fcfb..dead281 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-07-03 Oleg Endo <olegendo@gcc.gnu.org>
+
+ PR target/53568
+ * gcc.target/sh/pr53568-1.c: New.
+
2012-07-02 Oleg Endo <olegendo@gcc.gnu.org>
PR target/51244
diff --git a/gcc/testsuite/gcc.target/sh/pr53568-1.c b/gcc/testsuite/gcc.target/sh/pr53568-1.c
new file mode 100644
index 0000000..22f836e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/sh/pr53568-1.c
@@ -0,0 +1,82 @@
+/* Check that the bswap32 pattern is generated as swap.b and swap.w
+ instructions. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O2" } */
+/* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } } */
+/* { dg-final { scan-assembler-times "swap.w" 7 } } */
+/* { dg-final { scan-assembler-times "swap.b" 16 } } */
+/* { dg-final { scan-assembler-times "extu.w" 2 } } */
+/* { dg-final { scan-assembler-times "mov" 1 } } */
+/* { dg-final { scan-assembler-not "{shll8|shlr8|shld|shad}" } } */
+
+int
+test_func_00 (int a)
+{
+ /* 1x swap.w
+ 2x swap.b */
+ return __builtin_bswap32 (a);
+}
+
+unsigned int
+test_func_01 (unsigned int a)
+{
+ /* 1x swap.w
+ 2x swap.b */
+ return __builtin_bswap32 (a);
+}
+
+int
+test_func_02 (int a)
+{
+ /* 1x swap.w
+ 2x swap.b */
+ return (((a >> 0) & 0xFF) << 24)
+ | (((a >> 8) & 0xFF) << 16)
+ | (((a >> 16) & 0xFF) << 8)
+ | (((a >> 24) & 0xFF) << 0);
+}
+
+unsigned int
+test_func_03 (unsigned int a)
+{
+ /* 1x swap.w
+ 2x swap.b */
+ return (((a >> 0) & 0xFF) << 24)
+ | (((a >> 8) & 0xFF) << 16)
+ | (((a >> 16) & 0xFF) << 8)
+ | (((a >> 24) & 0xFF) << 0);
+}
+
+int
+test_func_04 (int a)
+{
+ /* 1x swap.b
+ 1x extu.w */
+ return __builtin_bswap32 (a) >> 16;
+}
+
+unsigned short
+test_func_05 (unsigned short a)
+{
+ /* 1x swap.b
+ 1x extu.w */
+ return __builtin_bswap32 (a) >> 16;
+}
+
+long long
+test_func_06 (long long a)
+{
+ /* 2x swap.w
+ 4x swap.b */
+ return __builtin_bswap64 (a);
+}
+
+long long
+test_func_07 (long long a)
+{
+ /* 1x swap.w
+ 2x swap.b
+ 1x mov #0,Rn */
+ return __builtin_bswap64 (a) >> 32;
+}
+