On Tue, Jun 08, 2021 at 01:22:58PM +0200, Peter Zijlstra wrote:
Works for me; and note how it mirrors how we implemented volatile_if()
in the first place, by doing an expression wrapper.
__builtin_ctrl_depends(expr) would have to:
- ensure !__builtin_const_p(expr) (A)
Why would it be an error if __builtin_constant_p(expr)? In many
programs the compiler can figure out some expression does never change.
Having a control dependency on sometthing like that is not erroneous.
- imply an acquire compiler fence (B)
- ensure cond-branch is emitted (C)
(C) is almost impossible to do. This should be reformulated to talk
about the effect of the generated code, instead.
*OR*
- ensure !__builtin_const_p(expr); (A)
- upgrade the load in @expr to load-acquire (D)
So that will only work if there is exactly one read from memory in expr?
That is problematic.
This needs some work.
Segher