On Mon, Jan 06, 2025 at 10:40:03PM +0100, Jonas Oberhauser wrote:
We first discuss why the more standard definition does not work well for
language models like LKMM. For example, consider
r1 = *a;
*b = 1;
if (*a == 1)
if (r1 == 1)
?
*b = 1;
*c = *b;
In the execution where r1 == 1, there is a control dependency from
the load of *a to the second store to *b, from which the load to *b reads,
and the store to *c has a data dependency on this load from *b. Nevertheless
there is no semantic dependency from the load of *a to the store to *c; the
compiler could easily replace the last line with *c = 1 and move this line to
the top as follows:
*c = 1;
r1 = *a;
*b = 1;
Since there is no order imposed by this sequence of syntactic dependencies
and reads, syntactic dependencies can not by themselves form an acyclic
relation.
In turn, there are some sequences of syntactic dependencies and reads that do
form semantic dependencies, such as
r1 = *a;
*b = 2;
if (*a == 1)
r1 again?
*b = 1;
*c = *b;
Here we would consider that the store to *c has a semantic data dependency on
the read from *a, given that depending on the result of that read, we store
either the value 1 or 2 to *c.