https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66867
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 38740 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38740&action=edit gcc7-pr66867-wip.patch WIP untested patch using the same technique as we use for __builtin_*_overflow* builtins. I'll need to still finish writing the expansion for the case when we should expand it to external calls, once that is tested disable the ifn folding for !flag_inline_atomics, fix up -fsanitize=threads, use for other spots that look at atomic builtins. And, we need some optimization that would optimize the case where REALPART_EXPR is conditionally stored into a non-addressable var - we can store the oldval there unconditionally then, because it can't create a race.