https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127626
--- Comment #2 from Taylor R Campbell <campbell+gcc-bugzilla at mumble dot net> --- (In reply to Drea Pinski from comment #1) > Note the ABI for some targets, the upper bits of the register might be > undefined. So the assembly versions might need to mask off the upper bits > in some cases. > > It might be a misunderstand there too. Yes, it may be that the implicit prototype of the C function __sync_val_compare_and_swap_1 is not directly related to the ABI contract of the ELF symbol __sync_val_compare_and_swap_1. But I don't have an explanation for why the code is generated the way it is on armv5t and not on sh3 or sparc, other than that on armv5t, gcc is treating the ELF symbol _as if_ it were a C function with an implicit prototype that is signed, in disagreement with the implicit prototype of the builtin C function __sync_val_compare_and_swap_1. And it would be nice if this ABI contract were written down!
