summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/ChangeLog25
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-1-v10.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-1-v32.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-1.c35
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-2c.c8
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-2i.c9
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-2s.c9
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-3i.c11
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-3s.c11
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-4c.c8
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-4i.c8
-rw-r--r--gcc/testsuite/gcc.target/cris/sync-4s.c8
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1a.c5
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2a.c5
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3a.c5
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1.c111
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1a.c5
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1a.c5
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2a.c5
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3a.c5
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1.c4
-rw-r--r--gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1a.c5
28 files changed, 319 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 29ed833df4c..c06dfd1670b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,28 @@
+2012-06-01 Hans-Peter Nilsson <hp@axis.com>
+
+ * gcc.target/cris/sync-1-v10.c,
+ gcc.target/cris/sync-1-v32.c, gcc.target/cris/sync-1.c,
+ gcc.target/cris/sync-2c.c, gcc.target/cris/sync-2i.c,
+ gcc.target/cris/sync-2s.c, gcc.target/cris/sync-3i.c,
+ gcc.target/cris/sync-3s.c, gcc.target/cris/sync-4c.c,
+ gcc.target/cris/sync-4i.c, gcc.target/cris/sync-4s.c,
+ gcc.target/cris/torture/sync-mis-op-i-1.c,
+ gcc.target/cris/torture/sync-mis-op-i-1a.c,
+ gcc.target/cris/torture/sync-mis-op-i-2.c,
+ gcc.target/cris/torture/sync-mis-op-i-2a.c,
+ gcc.target/cris/torture/sync-mis-op-i-3.c,
+ gcc.target/cris/torture/sync-mis-op-i-3a.c,
+ gcc.target/cris/torture/sync-mis-op-s-1.c,
+ gcc.target/cris/torture/sync-mis-op-s-1a.c,
+ gcc.target/cris/torture/sync-mis-xchg-i-1.c,
+ gcc.target/cris/torture/sync-mis-xchg-i-1a.c,
+ gcc.target/cris/torture/sync-mis-xchg-i-2.c,
+ gcc.target/cris/torture/sync-mis-xchg-i-2a.c,
+ gcc.target/cris/torture/sync-mis-xchg-i-3.c,
+ gcc.target/cris/torture/sync-mis-xchg-i-3a.c,
+ gcc.target/cris/torture/sync-mis-xchg-s-1.c,
+ gcc.target/cris/torture/sync-mis-xchg-s-1a.c: New tests.
+
2012-05-31 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/ldist-pr45948-2.c: New testcase copy of
diff --git a/gcc/testsuite/gcc.target/cris/sync-1-v10.c b/gcc/testsuite/gcc.target/cris/sync-1-v10.c
new file mode 100644
index 00000000000..640098a96db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-1-v10.c
@@ -0,0 +1,4 @@
+/* Check that we can assemble both base atomic variants. */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -march=v10" } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-1-v32.c b/gcc/testsuite/gcc.target/cris/sync-1-v32.c
new file mode 100644
index 00000000000..644d922a3db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-1-v32.c
@@ -0,0 +1,4 @@
+/* Check that we can assemble both base atomic variants. */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -march=v32" } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-1.c b/gcc/testsuite/gcc.target/cris/sync-1.c
new file mode 100644
index 00000000000..1bc9a674c3b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-1.c
@@ -0,0 +1,35 @@
+/* Check that we can assemble both base atomic variants, for v0. */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -march=v0" } */
+
+#ifndef type
+#define type char
+#endif
+
+#if !defined(op) && !defined(xchg)
+#define op 1
+#define xchg 1
+#endif
+
+#ifndef op
+#define op 0
+#endif
+
+#ifndef xchg
+#define xchg 0
+#endif
+
+#if op
+int sfa (type *p, type *q, int a)
+{
+ return __atomic_fetch_nand (p, a, __ATOMIC_ACQ_REL)
+ + __atomic_fetch_add (q, a, __ATOMIC_SEQ_CST);
+}
+#endif
+
+#if xchg
+void acen (type *ptr, type *val, type *ret)
+{
+ __atomic_exchange (ptr, val, ret, __ATOMIC_SEQ_CST);
+}
+#endif
diff --git a/gcc/testsuite/gcc.target/cris/sync-2c.c b/gcc/testsuite/gcc.target/cris/sync-2c.c
new file mode 100644
index 00000000000..80e646c20db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-2c.c
@@ -0,0 +1,8 @@
+/* Check that we don't get alignment-checking code, char. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */
+/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */
+/* { dg-final { scan-assembler-not "\tand" } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-2i.c b/gcc/testsuite/gcc.target/cris/sync-2i.c
new file mode 100644
index 00000000000..e43aa5356f5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-2i.c
@@ -0,0 +1,9 @@
+/* Check that we get the expected alignment-checking code, op variant, int. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Dop -Dtype=int" } */
+/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */
+/* { dg-final { scan-assembler "\tbreak 8" } } */
+/* { dg-final { scan-assembler "\tbtstq \\(2-1\\)," } } */
+/* { dg-final { scan-assembler-not "\tand" } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-2s.c b/gcc/testsuite/gcc.target/cris/sync-2s.c
new file mode 100644
index 00000000000..9be7dc6bcb5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-2s.c
@@ -0,0 +1,9 @@
+/* Check that we get the expected alignment-checking code, op variant, short. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Dop -Dtype=short" } */
+/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */
+/* { dg-final { scan-assembler "\tbreak 8" } } */
+/* { dg-final { scan-assembler "\tbtstq \\(1-1\\)," } } */
+/* { dg-final { scan-assembler-not "\tand" } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-3i.c b/gcc/testsuite/gcc.target/cris/sync-3i.c
new file mode 100644
index 00000000000..114e0a846e8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-3i.c
@@ -0,0 +1,11 @@
+/* Check that we get the expected alignment-checking code, xchg variant, int.
+ Unfortunately, PRE moves the "and" to a different BB, so combine doesn't
+ see it with the compare to make it a btstq. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Dxchg -Dtype=int" } */
+/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */
+/* { dg-final { scan-assembler "\tbreak 8" } } */
+/* { dg-final { scan-assembler "\tbtstq \\(2-1\\)," { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "\tand" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-3s.c b/gcc/testsuite/gcc.target/cris/sync-3s.c
new file mode 100644
index 00000000000..facbb39ed94
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-3s.c
@@ -0,0 +1,11 @@
+/* Check that we get the expected alignment-checking code, xchg variant, short.
+ Unfortunately, PRE moves the "and" to a different BB, so combine doesn't
+ see it with the compare to make it a btstq. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Dxchg -Dtype=short" } */
+/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */
+/* { dg-final { scan-assembler "\tbreak 8" } } */
+/* { dg-final { scan-assembler "\tbtstq \\(1-1\\)," { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "\tand" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-4c.c b/gcc/testsuite/gcc.target/cris/sync-4c.c
new file mode 100644
index 00000000000..e8cb69267b8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-4c.c
@@ -0,0 +1,8 @@
+/* Check that we get don't alignment-checking code, xchg variant, char. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mno-trap-unaligned-atomic" } */
+/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */
+/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */
+/* { dg-final { scan-assembler-not "\tand" } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-4i.c b/gcc/testsuite/gcc.target/cris/sync-4i.c
new file mode 100644
index 00000000000..9756c696386
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-4i.c
@@ -0,0 +1,8 @@
+/* Check that we don't get alignment-checking code, int. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Dtype=int -mno-trap-unaligned-atomic" } */
+/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */
+/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */
+/* { dg-final { scan-assembler-not "\tand" } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/sync-4s.c b/gcc/testsuite/gcc.target/cris/sync-4s.c
new file mode 100644
index 00000000000..2d644303a79
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/sync-4s.c
@@ -0,0 +1,8 @@
+/* Check that we don't get alignment-checking code, short. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Dtype=short -mno-trap-unaligned-atomic" } */
+/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */
+/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */
+/* { dg-final { scan-assembler-not "\tand" } } */
+/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */
+#include "sync-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1.c
new file mode 100644
index 00000000000..733ec4bac57
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=int" } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1a.c
new file mode 100644
index 00000000000..4cd233316e2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=int -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2.c
new file mode 100644
index 00000000000..97d0bf067b0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=int -Dmisalignment=2" } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2a.c
new file mode 100644
index 00000000000..3596e9ea5b1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=int -Dmisalignment=2 -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3.c
new file mode 100644
index 00000000000..07479469f49
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=int -Dmisalignment=3" } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3a.c
new file mode 100644
index 00000000000..46a04f42c0e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=int -Dmisalignment=3 -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1.c
new file mode 100644
index 00000000000..21b5269eced
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1.c
@@ -0,0 +1,111 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=short" } */
+
+/* Make sure we get a SIGTRAP or equivalent when passing unaligned
+ but otherwise valid pointers to the atomic builtins. */
+
+#include <signal.h>
+#include <stdlib.h>
+
+#ifndef type
+#error type not defined
+#endif
+
+#ifndef op
+#define op 0
+#endif
+
+#ifndef xchg
+#define xchg 0
+#endif
+
+#if op
+int sfa (type *p, type *q, int a);
+#endif
+
+#if xchg
+void acen (type *ptr, type *val, type *ret);
+#endif
+
+#ifndef misalignment
+#define misalignment 1
+#endif
+
+volatile int trap_expected = 0;
+
+struct { char x[misalignment]; type i; } s __attribute__ ((__aligned__ (4)))
+ = { {0}, (type) 0xdeadbeef };
+type x = 2;
+type ret = 42;
+
+#ifdef TRAP_USING_ABORT
+#define SYMSTR(x) STR1(__USER_LABEL_PREFIX__, x)
+#define STR1(x,y) STR2(x, y)
+#define STR2(x,y) #x #y
+/* LTO requires marking seemingly-unused-but-used global functions. */
+void my_abort (void) __asm__ (SYMSTR (abort)) __attribute__ ((__used__));
+void my_abort (void)
+#else
+#ifdef __gnu_linux__
+void trap_handler(int signum)
+#else
+#error "can't catch break 8"
+#endif
+#endif
+{
+ if (1
+#ifndef TRAP_USING_ABORT
+ && signum == SIGTRAP
+#endif
+ && trap_expected
+ && s.i == (type) 0xdeadbeef
+ && x == 2 && ret == 42)
+ exit (0);
+
+#ifdef TRAP_USING_ABORT
+ /* We might be able to trust the exit-value getting through, but add
+ a NULL-dereference SEGV just in case. Make sure gcc doesn't
+ understand the NULL. */
+ *({ int *p; asm ("" : "=rm" (p) : "0" (0)); p; }) = 0xdead;
+ exit (2);
+#else
+ abort ();
+#endif
+}
+
+int main(void)
+{
+ type x = 0;
+ type ret;
+
+#ifndef TRAP_USING_ABORT
+#ifdef __gnu_linux__
+ if (signal (SIGTRAP, trap_handler) == SIG_ERR)
+ abort ();
+#endif
+#endif
+
+ trap_expected = 1;
+
+#if op
+ sfa (&s.i, &s.i, 42);
+
+ /* We should have fallen into the trap now. But don't call abort
+ yet: if the trap is implemented as a call to abort, we have to
+ tell the difference. Set a global variable *and* make sure the
+ setting isn't eliminated by optimizers: another call to sfa
+ should do it. */
+ trap_expected = 0;
+
+ sfa (&x, &x, 1);
+#else
+ acen (&s.i, &x, &ret);
+
+ trap_expected = 0;
+
+ acen (&x, &x, &ret);
+#endif
+
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1a.c
new file mode 100644
index 00000000000..fc91e7c9a8a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dop -Dtype=short -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1.c
new file mode 100644
index 00000000000..1072caca9ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=int" } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1a.c
new file mode 100644
index 00000000000..af6ef8ac748
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=int -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2.c
new file mode 100644
index 00000000000..b02f4875b02
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=2" } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2a.c
new file mode 100644
index 00000000000..8c7918470c6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=2 -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3.c
new file mode 100644
index 00000000000..637aecfd288
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=3" } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3a.c
new file mode 100644
index 00000000000..e7c90a360d3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=3 -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1.c
new file mode 100644
index 00000000000..73742854ed5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target *-*-linux* } } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=short" } */
+#include "sync-mis-op-s-1.c"
diff --git a/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1a.c b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1a.c
new file mode 100644
index 00000000000..5dcef52207d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1a.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-additional-sources "../sync-1.c" } */
+/* { dg-options "-Dxchg -Dtype=short -DTRAP_USING_ABORT -mno-trap-using-break8" } */
+/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */
+#include "sync-mis-op-s-1.c"