Hi! On Tue, Sep 28, 2021 at 05:15:07PM -0400, Mathieu Desnoyers wrote: > C99 describes that accessing volatile objects are side-effects, and that > "at certain specified points in the execution sequence called sequence > points, all side effects of previous evaluations shall be complete > and no side effects of subsequent evaluations shall have taken > place". [2] But note that the kernel explicitly uses C89 (with GNU extensions). Side effects are largely equal there though. Also note that there may no place in the generated machine code that corresponds exactly to some sequence point. Sequence points are a concept that applies to the source program and how that executes on the abstract machine. > +Because ctrl_dep emits distinct asm volatile within each leg of the if > +statement, the compiler cannot transform the two writes to 'b' into a > +conditional-move (cmov) instruction, thus ensuring the presence of a > +conditional branch. Also because the ctrl_dep emits asm volatile within > +each leg of the if statement, the compiler cannot move the write to 'c' > +before the conditional branch. I think your reasoning here misses some things. So many that I don't know where to start to list them, every "because" and "thus" here does not follow, and even the statements of fact are not a given. Why do you want a conditional branch insn at all, anyway? You really want something else as far as I can see. It is essential here that there is a READ_ONCE and the WRITE_ONCE. Those things might make it work the way you want, but as Linus says this is all way too subtle. Can you include the *_ONCE into the primitive itself somehow? Segher