summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/guality/bswaptest.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/guality/bswaptest.c')
-rw-r--r--gcc/testsuite/gcc.dg/guality/bswaptest.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/guality/bswaptest.c b/gcc/testsuite/gcc.dg/guality/bswaptest.c
new file mode 100644
index 00000000000..38b9d981c87
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/bswaptest.c
@@ -0,0 +1,32 @@
+/* { dg-do run { target { x86_64-*-* && lp64 } } } */
+/* { dg-options "-g" } */
+
+volatile int vv;
+
+__attribute__((noclone, noinline)) long
+foo (long x)
+{
+ long f = __builtin_bswap64 (x);
+ long g = f;
+ asm volatile ("" : "+r" (f));
+ vv++; /* { dg-final { gdb-test 12 "g" "f" } } */
+ return f;
+}
+
+__attribute__((noclone, noinline)) int
+bar (int x)
+{
+ int f = __builtin_bswap32 (x);
+ int g = f;
+ asm volatile ("" : "+r" (f));
+ vv++; /* { dg-final { gdb-test 22 "g" "f" } } */
+ return f;
+}
+
+int
+main ()
+{
+ foo (0x123456789abcde0fUL);
+ bar (0x12345678);
+ return 0;
+}