FAILURE MAP
← Case archive

FA-11486 / Compiler transformation correctness / Open access

Instruction swapping ignores a write after an earlier read · case 01

Instruction swapping ignores a write after an earlier read.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Scheduling checks only read-after-write dependencies.

VERIFIED REPAIR

Reject swaps on RAW, WAR and WAW register intersections.

Unsuccessful approach: Adding WAR checks still allows two writes to exchange final register contents.

Case contract

Return whether two adjacent pure register instructions can swap; each read/write collection is a set of register names, and any RAW, WAR or WAW conflict forbids swapping. Memory and control effects are excluded.

Why this case matters

A deterministic miniature compiler-pass model; inputs are explicit IR facts, not a production compiler.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(r1, w1, r2, w2):
    return not (set(w1) & set(r2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
x = 'r'+str(N)
y = 'r'+str(N+1)
check('empty', solve([],[],[],[]), True)
check('RAW', solve([],[x],[x],[]), False)
check('WAR', solve([x],[],[],[x]), False)
check('WAW', solve([],[x],[],[x]), False)
check('read sharing', solve([x],[],[x],[]), True)
check('disjoint writes', solve([],[x],[],[y]), True)
check('mixed dependence', solve([y],[x],[x],[y]), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
emptyTrueTruePassed
RAWFalseFalsePassed
WARTrueFalseFailed
WAWTrueFalseFailed
read sharingTrueTruePassed
disjoint writesTrueTruePassed
mixed dependenceFalseFalsePassed

SHA-256 / bb9d8f3f23b3d6ea6add58e8369114a853426354a27bb25ccc35450ce711e41c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(r1, w1, r2, w2):
    return not ((set(w1) & set(r2)) or (set(r1) & set(w2)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
x = 'r'+str(N)
y = 'r'+str(N+1)
check('empty', solve([],[],[],[]), True)
check('RAW', solve([],[x],[x],[]), False)
check('WAR', solve([x],[],[],[x]), False)
check('WAW', solve([],[x],[],[x]), False)
check('read sharing', solve([x],[],[x],[]), True)
check('disjoint writes', solve([],[x],[],[y]), True)
check('mixed dependence', solve([y],[x],[x],[y]), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
emptyTrueTruePassed
RAWFalseFalsePassed
WARFalseFalsePassed
WAWTrueFalseFailed
read sharingTrueTruePassed
disjoint writesTrueTruePassed
mixed dependenceFalseFalsePassed

SHA-256 / 770c77a193e858d398010cc5e48a16132c73fd03041433054c0a9c820ca45aa2

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(r1, w1, r2, w2):
    return not ((set(w1) & set(r2)) or (set(r1) & set(w2)) or (set(w1) & set(w2)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
x = 'r'+str(N)
y = 'r'+str(N+1)
check('empty', solve([],[],[],[]), True)
check('RAW', solve([],[x],[x],[]), False)
check('WAR', solve([x],[],[],[x]), False)
check('WAW', solve([],[x],[],[x]), False)
check('read sharing', solve([x],[],[x],[]), True)
check('disjoint writes', solve([],[x],[],[y]), True)
check('mixed dependence', solve([y],[x],[x],[y]), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
emptyTrueTruePassed
RAWFalseFalsePassed
WARFalseFalsePassed
WAWFalseFalsePassed
read sharingTrueTruePassed
disjoint writesTrueTruePassed
mixed dependenceFalseFalsePassed

SHA-256 / 3f8d74a72cb00c4cf5248a9fc4ebb44fd75272830f3e11bf1a7b973a6299eee3

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:38:48.404385+00:00.

Case digest / 824061979d06ef7fc31a47b3a6d38cd4a3584e03f193e86f2b1334f8e38c9979