diff --git a/gcc/testsuite/gcc.target/arm/builtin-bswap-1.c b/gcc/testsuite/gcc.target/arm/builtin-bswap-1.c index 43195bd8235b492a3c4783d88bf744ac92ee9f68..c1e7740d14d3ca4e93a71e38b12f82c19791a204 100644 --- a/gcc/testsuite/gcc.target/arm/builtin-bswap-1.c +++ b/gcc/testsuite/gcc.target/arm/builtin-bswap-1.c @@ -1,7 +1,9 @@ /* { dg-do compile } */ -/* { dg-options "-O2" } */ -/* { dg-require-effective-target arm_arch_v6_ok } */ -/* { dg-add-options arm_arch_v6 } */ +/* { dg-require-effective-target arm_arch_v6t2_ok } */ +/* { dg-add-options arm_arch_v6t2 } */ +/* This test depends on if-conversion creating the conditional forms of + of the instructions. Add an -mtune option known to facilitate that. */ +/* { dg-additional-options "-O2 -mtune=cortex-a53" } */ /* { dg-final { scan-assembler-not "orr\[ \t\]" } } */ /* { dg-final { scan-assembler-times "revsh\\t" 1 { target { arm_nothumb } } } } */ /* { dg-final { scan-assembler-times "revshne\\t" 1 { target { arm_nothumb } } } } */ @@ -13,69 +15,4 @@ /* { dg-final { scan-assembler-times "revne\\t" 2 { target { arm_nothumb } } } } */ /* { dg-final { scan-assembler-times "rev\\t" 4 { target { ! arm_nothumb } } } } */ -/* revsh */ -short swaps16 (short x) -{ - return __builtin_bswap16 (x); -} - -extern short foos16 (short); - -/* revshne */ -short swaps16_cond (short x, int y) -{ - short z = x; - if (y) - z = __builtin_bswap16 (x); - return foos16 (z); -} - -/* rev16 */ -unsigned short swapu16 (unsigned short x) -{ - return __builtin_bswap16 (x); -} - -extern unsigned short foou16 (unsigned short); - -/* rev16ne */ -unsigned short swapu16_cond (unsigned short x, int y) -{ - unsigned short z = x; - if (y) - z = __builtin_bswap16 (x); - return foou16 (z); -} - -/* rev */ -int swaps32 (int x) { - return __builtin_bswap32 (x); -} - -extern int foos32 (int); - -/* revne */ -int swaps32_cond (int x, int y) -{ - int z = x; - if (y) - z = __builtin_bswap32 (x); - return foos32 (z); -} - -/* rev */ -unsigned int swapu32 (unsigned int x) -{ - return __builtin_bswap32 (x); -} - -extern unsigned int foou32 (unsigned int); - -/* revne */ -unsigned int swapsu2 (unsigned int x, int y) -{ - int z = x; - if (y) - z = __builtin_bswap32 (x); - return foou32 (z); -} +#include "builtin-bswap.x" diff --git a/gcc/testsuite/gcc.target/arm/builtin-bswap-2.c b/gcc/testsuite/gcc.target/arm/builtin-bswap-2.c new file mode 100644 index 0000000000000000000000000000000000000000..4ba79aa322dc72b521dbff7e5f5ac3f77767988c --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/builtin-bswap-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_arch_v6m_ok } */ +/* { dg-add-options arm_arch_v6m } */ +/* { dg-additional-options "-O2" } */ +/* { dg-final { scan-assembler-not "orr\[ \t\]" } } */ +/* { dg-final { scan-assembler-times "revsh\\t" 2 } } */ +/* { dg-final { scan-assembler-times "rev16\\t" 2 } } */ +/* { dg-final { scan-assembler-times "rev\\t" 4 } } */ + +#include "builtin-bswap.x" diff --git a/gcc/testsuite/gcc.target/arm/builtin-bswap.x b/gcc/testsuite/gcc.target/arm/builtin-bswap.x new file mode 100644 index 0000000000000000000000000000000000000000..c96dbe6329c4dc648fd0bcc972ad494c7d6dc6e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/builtin-bswap.x @@ -0,0 +1,66 @@ +/* revsh */ +short swaps16 (short x) +{ + return __builtin_bswap16 (x); +} + +extern short foos16 (short); + +/* revshne */ +short swaps16_cond (short x, int y) +{ + short z = x; + if (y) + z = __builtin_bswap16 (x); + return foos16 (z); +} + +/* rev16 */ +unsigned short swapu16 (unsigned short x) +{ + return __builtin_bswap16 (x); +} + +extern unsigned short foou16 (unsigned short); + +/* rev16ne */ +unsigned short swapu16_cond (unsigned short x, int y) +{ + unsigned short z = x; + if (y) + z = __builtin_bswap16 (x); + return foou16 (z); +} + +/* rev */ +int swaps32 (int x) { + return __builtin_bswap32 (x); +} + +extern int foos32 (int); + +/* revne */ +int swaps32_cond (int x, int y) +{ + int z = x; + if (y) + z = __builtin_bswap32 (x); + return foos32 (z); +} + +/* rev */ +unsigned int swapu32 (unsigned int x) +{ + return __builtin_bswap32 (x); +} + +extern unsigned int foou32 (unsigned int); + +/* revne */ +unsigned int swapsu2 (unsigned int x, int y) +{ + int z = x; + if (y) + z = __builtin_bswap32 (x); + return foou32 (z); +} diff --git a/gcc/testsuite/gcc.target/arm/builtin-bswap16-1.c b/gcc/testsuite/gcc.target/arm/builtin-bswap16-1.c index 6920f004eab42443441227029c579aeb2bb981ee..e08a38abcf27807a29bd1eca1844bb7e9a369dd7 100644 --- a/gcc/testsuite/gcc.target/arm/builtin-bswap16-1.c +++ b/gcc/testsuite/gcc.target/arm/builtin-bswap16-1.c @@ -1,15 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O2" } */ -/* { dg-require-effective-target arm_arch_v6_ok } */ -/* { dg-add-options arm_arch_v6 } */ +/* { dg-require-effective-target arm_arch_v6t2_ok } */ +/* { dg-add-options arm_arch_v6t2 } */ +/* { dg-additional-options "-O2" } */ /* { dg-final { scan-assembler-not "orr\[ \t\]" } } */ -unsigned short swapu16_1 (unsigned short x) -{ - return (x << 8) | (x >> 8); -} - -unsigned short swapu16_2 (unsigned short x) -{ - return (x >> 8) | (x << 8); -} +#include "builtin-bswap16.x" diff --git a/gcc/testsuite/gcc.target/arm/builtin-bswap16-2.c b/gcc/testsuite/gcc.target/arm/builtin-bswap16-2.c new file mode 100644 index 0000000000000000000000000000000000000000..6b709a2887de45ded607d8eb076465e0ef5958de --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/builtin-bswap16-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_arch_v6m_ok } */ +/* { dg-add-options arm_arch_v6m } */ +/* { dg-additional-options "-O2" } */ +/* { dg-final { scan-assembler-not "orr\[ \t\]" } } */ + +#include "builtin-bswap16.x" diff --git a/gcc/testsuite/gcc.target/arm/builtin-bswap16.x b/gcc/testsuite/gcc.target/arm/builtin-bswap16.x new file mode 100644 index 0000000000000000000000000000000000000000..1e7f41edf013e353944f0a4879a1248c8a8b2f11 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/builtin-bswap16.x @@ -0,0 +1,9 @@ +unsigned short swapu16_1 (unsigned short x) +{ + return (x << 8) | (x >> 8); +} + +unsigned short swapu16_2 (unsigned short x) +{ + return (x >> 8) | (x << 8); +}