diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e2a17a6db0a..f201518d3c1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-08-04 Kyrylo Tkachov + + 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 Kyrylo Tkachov diff --git a/gcc/optabs.c b/gcc/optabs.c index c7bd9d07485..65328a668ba 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b02eaf4b62d..e149043758a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-08-04 Kyrylo Tkachov + + PR target/61713 + * gcc.dg/pr61756.c: New test. + 2014-08-04 Tom de Vries * 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 index 00000000000..c0212907558 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61756.c @@ -0,0 +1,15 @@ +/* PR target/61756 */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -march=armv5" { target arm*-*-* } } */ + +#include + +static volatile atomic_flag guard = ATOMIC_FLAG_INIT; + +void +try_atomic_flag_test_and_set (void) +{ + atomic_flag_test_and_set (&guard); +}