aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c')
-rw-r--r--gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c
new file mode 100644
index 000000000..ceec45e69
--- /dev/null
+++ b/gcc-4.8/gcc/testsuite/gcc.c-torture/execute/pr60454.c
@@ -0,0 +1,31 @@
+#ifdef __UINT32_TYPE__
+typedef __UINT32_TYPE__ uint32_t;
+#else
+typedef unsigned uint32_t;
+#endif
+
+#define __fake_const_swab32(x) ((uint32_t)( \
+ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
+ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 8) | \
+ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) ) | \
+ (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
+
+/* Previous version of bswap optimization would detect byte swap when none
+ happen. This test aims at catching such wrong detection to avoid
+ regressions. */
+
+__attribute__ ((noinline, noclone)) uint32_t
+fake_swap32 (uint32_t in)
+{
+ return __fake_const_swab32 (in);
+}
+
+int main(void)
+{
+ if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
+ return 0;
+ if (fake_swap32 (0x12345678UL) != 0x78567E12UL)
+ __builtin_abort ();
+ return 0;
+}