I think JMM-05 (https://github.com/jeehoonkang/memory-model-explorer/blob/master/test/jmm-05.test) should be allowed, as contrary to the decision JMM people (and we) made. Here is a series of "standard" optimizations that lead JMM-05 into a program that can clearly output the designated outcome.
-
By some global analysis, deduce that
r2
should be 0 or 1. Thus transform thread 2 into:r2 = y; if (r2) { x = 1 } else {