PR 61713: ICE when expanding single-threaded version of atomic_test_and_set.
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Mon, 4 Aug 2014 10:03:32 +0000 (10:03 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Mon, 4 Aug 2014 10:03:32 +0000 (10:03 +0000)
PR target/61713
* gcc/optabs.c (expand_atomic_test_and_set): Do not try to emit
move to subtarget in serial version if result is ignored.

PR target/61713
* gcc.dg/pr61756.c: New test.

From-SVN: r213555

gcc/ChangeLog
gcc/optabs.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr61756.c [new file with mode: 0644]

index e2a17a6..f201518 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-04  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR target/61713
+       * gcc/optabs.c (expand_atomic_test_and_set): Do not try to emit
+       move to subtarget in serial version if result is ignored.
+
 2014-07-14  Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
             Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
index c7bd9d0..65328a6 100644 (file)
@@ -7356,7 +7356,10 @@ expand_atomic_test_and_set (rtx target, rtx mem, enum memmodel model)
      perform the operation.  */
   if (!ret)
     {
-      emit_move_insn (subtarget, mem);
+      /* If the result is ignored skip the move to target.  */
+      if (subtarget != const0_rtx)
+        emit_move_insn (subtarget, mem);
+
       emit_move_insn (mem, trueval);
       ret = subtarget;
     }
index b02eaf4..e149043 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-04  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR target/61713
+       * gcc.dg/pr61756.c: New test.
+
 2014-08-04  Tom de Vries  <tom@codesourcery.com>
 
        * gcc.dg/cproj-fails-with-broken-glibc.c: Use xfail for broken glibc
diff --git a/gcc/testsuite/gcc.dg/pr61756.c b/gcc/testsuite/gcc.dg/pr61756.c
new file mode 100644 (file)
index 0000000..c021290
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR target/61756  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -march=armv5" { target arm*-*-*  } } */
+
+#include <stdatomic.h>
+
+static volatile atomic_flag guard = ATOMIC_FLAG_INIT;
+
+void
+try_atomic_flag_test_and_set (void)
+{
+  atomic_flag_test_and_set (&guard);
+}