https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98737

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #2)
> This can be optimized with peephole2, we already have similar case in
> sync.md:
> 
> ;; This peephole2 and following insn optimize
> ;; __sync_fetch_and_add (x, -N) == N into just lock {add,sub,inc,dec}
> ;; followed by testing of flags instead of lock xadd and comparisons.

That doesn't seem to do anything though, I see the same bad code for 

_Bool h(long b)
{
  return __sync_fetch_and_add(&a, -b) == b;
}

Reply via email to