This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] bswap testcase: Only compile on targets currently implementing the bswap patterns
- From: "Andreas Krebbel" <krebbel at linux dot vnet dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Jun 2009 12:34:09 +0200
- Subject: [Committed] bswap testcase: Only compile on targets currently implementing the bswap patterns
Hi,
the bswap pass only actually does something if the back end provides
an implementation of the bswap pattern therefore the testcase will
fail on the other targets. The attached patch enables the testcase
only on targets providing the respective bswap pattern.
Tested on s390x and applied to mainline.
Bye,
-Andreas-
2009-06-14 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* gcc.dg/optimize-bswap-1.c: Split into these two:
* gcc.dg/optimize-bswapsi-1.c: New testcase.
* gcc.dg/optimize-bswapdi-1.c: New testcase.
Index: gcc/testsuite/gcc.dg/optimize-bswap-1.c
===================================================================
--- gcc/testsuite/gcc.dg/optimize-bswap-1.c 2009-06-15 09:12:23.000000000 +0200
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,52 +0,0 @@
-/* { dg-do compile } */
-/* { dg-require-effective-target stdint_types } */
-/* { dg-options "-O2 -fdump-tree-bswap" } */
-
-#include <stdint.h>
-
-#define __const_swab32(x) ((uint32_t)( \
- (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
- (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
- (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
- (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
-
-#define __const_swab64(x) ((uint64_t)( \
- (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \
- (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
- (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
- (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
- (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
- (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
- (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
- (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56)))
-
-/* This byte swap implementation is used by the Linux kernel and the
- GNU C library. */
-
-uint32_t
-swap32_a (uint32_t in)
-{
- return __const_swab32 (in);
-}
-
-uint64_t
-swap64 (uint64_t in)
-{
- return __const_swab64 (in);
-}
-
-/* The OpenSSH byte swap implementation. */
-uint32_t
-swap32_b (uint32_t in)
-{
- uint32_t a;
-
- a = (in << 16) | (in >> 16);
- a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
-
- return a;
-}
-
-/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 2 "bswap" } } */
-/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 1 "bswap" } } */
-/* { dg-final { cleanup-tree-dump "bswap" } } */
Index: gcc/testsuite/gcc.dg/optimize-bswapdi-1.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/optimize-bswapdi-1.c 2009-06-15 09:31:35.000000000 +0200
@@ -0,0 +1,28 @@
+/* { dg-do compile { target alpha*-*-* ia64*-*-* x86_64-*-* s390x-*-* } } */
+/* { dg-require-effective-target stdint_types } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -fdump-tree-bswap" } */
+
+#include <stdint.h>
+#define __const_swab64(x) ((uint64_t)( \
+ (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+ (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+ (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+ (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
+ (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
+ (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+ (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+ (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56)))
+
+
+/* This byte swap implementation is used by the Linux kernel and the
+ GNU C library. */
+
+uint64_t
+swap64 (uint64_t in)
+{
+ return __const_swab64 (in);
+}
+
+/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 1 "bswap" } } */
+/* { dg-final { cleanup-tree-dump "bswap" } } */
Index: gcc/testsuite/gcc.dg/optimize-bswapsi-1.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/optimize-bswapsi-1.c 2009-06-15 09:25:10.000000000 +0200
@@ -0,0 +1,35 @@
+/* { dg-do compile { target alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */
+/* { dg-require-effective-target stdint_types } */
+/* { dg-options "-O2 -fdump-tree-bswap" } */
+
+#include <stdint.h>
+
+#define __const_swab32(x) ((uint32_t)( \
+ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
+ (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
+ (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
+
+/* This byte swap implementation is used by the Linux kernel and the
+ GNU C library. */
+
+uint32_t
+swap32_a (uint32_t in)
+{
+ return __const_swab32 (in);
+}
+
+/* The OpenSSH byte swap implementation. */
+uint32_t
+swap32_b (uint32_t in)
+{
+ uint32_t a;
+
+ a = (in << 16) | (in >> 16);
+ a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
+
+ return a;
+}
+
+/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 2 "bswap" } } */
+/* { dg-final { cleanup-tree-dump "bswap" } } */