aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKwok Cheung Yeung <kcy@codesourcery.com>2020-08-06 13:52:52 +0200
committerTom de Vries <tdevries@suse.de>2020-08-07 07:59:28 +0200
commit6339f93279b24b5a61eeed2a5040b8b2a0d3ab42 (patch)
tree19944d872e48f40c5b214e75188b5bd0415c222d /gcc
parenteb5f081c16bde273f0b3c24b5929c822ae502a4f (diff)
downloadgcc-6339f93279b24b5a61eeed2a5040b8b2a0d3ab42.zip
gcc-6339f93279b24b5a61eeed2a5040b8b2a0d3ab42.tar.gz
gcc-6339f93279b24b5a61eeed2a5040b8b2a0d3ab42.tar.bz2
[testsuite] Add gcc.dg/ia64-sync-5.c
There currently is no sync_char_short-enabled run test that tests __sync_val_compare_and_swap. Fix this by copying ia64-sync-3.c and modifying it for char/short. Tested on x86_64. 2020-08-06 Kwok Cheung Yeung <kcy@codesourcery.com> Tom de Vries <tdevries@suse.de> gcc/testsuite/ChangeLog: * gcc.dg/ia64-sync-5.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/ia64-sync-5.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ia64-sync-5.c b/gcc/testsuite/gcc.dg/ia64-sync-5.c
new file mode 100644
index 0000000..8b16b29b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ia64-sync-5.c
@@ -0,0 +1,83 @@
+/* { dg-do run } */
+/* { dg-require-effective-target sync_char_short } */
+/* { dg-options } */
+/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
+/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */
+
+/* Test basic functionality of the intrinsics. */
+
+/* This is a copy of gcc.dg/ia64-sync-3.c, for 8-bit and 16-bit. */
+
+__extension__ typedef __SIZE_TYPE__ size_t;
+
+extern void abort (void);
+extern void *memcpy (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+static char AC[4];
+static char init_qi[4] = { -30,-30,-50,-50 };
+static char test_qi[4] = { -115,-115,25,25 };
+
+static void
+do_qi (void)
+{
+ if (__sync_val_compare_and_swap(AC+0, -30, -115) != -30)
+ abort ();
+ if (__sync_val_compare_and_swap(AC+0, -30, -115) != -115)
+ abort ();
+ if (__sync_bool_compare_and_swap(AC+1, -30, -115) != 1)
+ abort ();
+ if (__sync_bool_compare_and_swap(AC+1, -30, -115) != 0)
+ abort ();
+
+ if (__sync_val_compare_and_swap(AC+2, AC[2], 25) != -50)
+ abort ();
+ if (__sync_val_compare_and_swap(AC+2, AC[2], 25) != 25)
+ abort ();
+ if (__sync_bool_compare_and_swap(AC+3, AC[3], 25) != 1)
+ abort ();
+ if (__sync_bool_compare_and_swap(AC+3, AC[3], 25) != 1)
+ abort ();
+}
+
+static short AS[4];
+static short init_hi[4] = { -30,-30,-50,-50 };
+static short test_hi[4] = { -115,-115,25,25 };
+
+static void
+do_hi (void)
+{
+ if (__sync_val_compare_and_swap(AS+0, -30, -115) != -30)
+ abort ();
+ if (__sync_val_compare_and_swap(AS+0, -30, -115) != -115)
+ abort ();
+ if (__sync_bool_compare_and_swap(AS+1, -30, -115) != 1)
+ abort ();
+ if (__sync_bool_compare_and_swap(AS+1, -30, -115) != 0)
+ abort ();
+
+ if (__sync_val_compare_and_swap(AS+2, AS[2], 25) != -50)
+ abort ();
+ if (__sync_val_compare_and_swap(AS+2, AS[2], 25) != 25)
+ abort ();
+ if (__sync_bool_compare_and_swap(AS+3, AS[3], 25) != 1)
+ abort ();
+ if (__sync_bool_compare_and_swap(AS+3, AS[3], 25) != 1)
+ abort ();
+}
+
+int main()
+{
+ memcpy(AC, init_qi, sizeof(init_qi));
+ memcpy(AS, init_hi, sizeof(init_hi));
+
+ do_qi ();
+ do_hi ();
+
+ if (memcmp (AC, test_qi, sizeof(test_qi)))
+ abort ();
+ if (memcmp (AS, test_hi, sizeof(test_hi)))
+ abort ();
+
+ return 0;
+}