14.2.10.5 Control Dependencies
Keywords: perfbook_html

###
14.2.10.5 Control Dependencies

A control dependency requires a full read memory barrier, not simply a data dependency barrier to make it work correctly. Consider the following bit of code:

      1 q = &a;
      2 if (p)
      3   q = &b;
      4 <data dependency barrier>
      5 x = *q;

This will not have the desired effect because there is no actual data dependency, but rather a control dependency that the CPU may short-circuit by attempting to predict the outcome in advance. In such a case what's actually required is:

      1 q = &a;
      2 if (p)
      3   q = &b;
      4 <read barrier>
      5 x = *q;