https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105011
--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> --- Even better: ... diff --git a/libatomic/tas_n.c b/libatomic/tas_n.c index d0d8c283b495..65eaa7753a51 100644 --- a/libatomic/tas_n.c +++ b/libatomic/tas_n.c @@ -73,7 +73,7 @@ SIZE(libat_test_and_set) (UTYPE *mptr, int smodel) __ATOMIC_RELAXED, __ATOMIC_RELAXED)); post_barrier (smodel); - return woldval != 0; + return (woldval & wval) == wval; } #define DONE 1 ... That also gives back accurate results in case TARGET_ATOMIC_TEST_AND_SET_TRUEVAL has more than one bit set.