From bd0ef17d0f9563ed9579fe060b785211e8378006 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Thu, 1 Oct 2026 15:47:15 -0700 Subject: Restore missing anti-dependence walk --- .../test/java/com/seaofnodes/simple/Chapter21Test.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'chapter23/src/test') diff --git a/chapter23/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter23/src/test/java/com/seaofnodes/simple/Chapter21Test.java index 9aa18821..7e82e37c 100644 --- a/chapter23/src/test/java/com/seaofnodes/simple/Chapter21Test.java +++ b/chapter23/src/test/java/com/seaofnodes/simple/Chapter21Test.java @@ -18,6 +18,24 @@ import static org.junit.Assert.*; public class Chapter21Test { + @Test public void testReadBeforeConditionalStore() { + var code = new CodeGen(""" + struct S { int x; }; S !a=new S; S !b=new S; + a.x=10; b.x=20; S !p=a; if(arg&1) p=b; + int sum=0; + for(int i=0; i<6; i++) { + sum+=a.x; + if(i==2) p.x=30; + else if(i==4) b.x=40; + } + return sum; + """).parse().opto(); + // The i==2 read still sees 10: three reads of 10, then three of 30. + assertEquals("120",Eval2.eval(code,0)); + assertEquals("60",Eval2.eval(code,1)); + } + + @Test public void testArmBitfieldExtracts() { // Independent SXT/UXT instruction words, plus ASR, LSR and LSL aliases. int[] ops = {0x93401c20,0xd3401c20,0x93403c20,0xd3403c20, -- cgit v1.2.3