Subject: Re: [boost] [atomic] (op)_and_test naming
From: Peter Dimov (lists_at_[hidden])
Date: 2018-01-26 17:27:09
Andrey Semashev wrote:
> Clang doesn't seem to support __builtin_constant_p, which makes it fail to
> convert "add" to "inc" in add_and_test and opaque_add. Maybe I should
> switch clang to the generic emulation backend.
This would make it use `xadd` instead of `add`, see
https://godbolt.org/g/V1iTbj. Adding `inc_and_test` seems more
straightforward and consistent with the spirit of the current interface that
lets the user express the exact operation instead of relying on the compiler
to figure it out.
> OTOH, Intel compiler does support it and generates better code for
> add_and_test and opaque_add than for fetch_add.
Indeed it does, https://godbolt.org/g/QAbTZo.
I checked the g++ and clang++ versions and was going to say that nowhere
does opaque_add generate better code than the dumb fetch_add, but it does on
> `fetch_add` is implemented in terms of instrinsics (I assume, clang
> supports __atomic* intrinsics, so those should be used).
To get back on topic, I'm fine with making op_and_test return true on
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk