summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/Chapter11Test.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-08-10 11:11:18 -0700
committerCliff Click <cliffc@acm.org>2026-10-08 16:52:27 -0700
commitd32f97238c903765dec4e9a9f3cbfa5fd12cded6 (patch)
treea5ac731801ef7066bab6359c4e85c2bdd20082a6 /src/test/java/com/seaofnodes/simple/Chapter11Test.java
parentb5ebb2032aa04cf4506d533127d373d4cf5a25c6 (diff)
downloadSimple-linear.tar.gz
Simple-linear.zip
Chapter 25: Modules, Separate Compilation, and SSA Constructionlinear
Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: Symious <14933944+symious@users.noreply.github.com> Co-authored-by: Jun Kawasaki <jun784@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter11Test.java')
-rw-r--r--src/test/java/com/seaofnodes/simple/Chapter11Test.java61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter11Test.java b/src/test/java/com/seaofnodes/simple/Chapter11Test.java
deleted file mode 100644
index 3d5d2686..00000000
--- a/src/test/java/com/seaofnodes/simple/Chapter11Test.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.seaofnodes.simple;
-
-import com.seaofnodes.simple.codegen.*;
-import com.seaofnodes.simple.node.*;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class Chapter11Test {
- @Test public void testIndependentField() {
- var code = new CodeGen("""
- struct S { int x; int y; };
- !S !s = new S;
- s.x = 42;
- while (arg > 0) { s.y = s.y + arg; arg = arg - 1; }
- return s.x;
- """).parse().opto();
- var stop = code._stop;
- assertEquals("return 42;",stop.toString());
- assertEquals("42",Eval2.eval(code,5));
- assertNull(stop.walk(n -> n instanceof LoadNode ? n : null));
- }
-
- @Test public void testParallelMemoryPhis() {
- var code = new CodeGen("""
- struct S { int x; int y; int z; };
- !S !a = new S; !S !b = new S;
- !S !p = a; if (arg) p = b;
- while (arg > 0) {
- a.x = p.x + arg;
- a.y = p.y + 2;
- a.z = p.z + 3;
- arg = arg - 1;
- }
- return a;
- """).parse().opto();
- var stop = code._stop;
- int[] phis = {0};
- stop.walk(n -> {
- // Store sinking can replace field memory Phis with value Phis.
- if (n instanceof PhiNode) phis[0]++;
- if (n instanceof MemMergeNode m && m.in(1) instanceof BulkMemPhiNode b)
- for(int a=b._aliases.nextSetBit(0); a>=0; a=b._aliases.nextSetBit(a+1))
- assertTrue(a<m.nIns() && m.in(a)!=null);
- assertFalse(n instanceof PhiNode && n.isMem() &&
- !(n instanceof MemPhiNode) && !(n instanceof BulkMemPhiNode) && !(n instanceof ParmNode));
- return null;
- });
- assertTrue(phis[0]>=4); // Three fields and the loop counter.
- assertEquals("S{x=1,y=2,z=3}",Eval2.eval(code,4));
- }
-
- @Test public void testLateSliceWorklist() {
- // Seed 97 exposed a store selecting a bulk predecessor without queuing
- // it. Keep both the worklist assertion and the final heap check.
- for (int seed : new int[]{0,97,123,456}) {
- var code = new CodeGen(Chapter10Test.NESTED_MEMORY,com.seaofnodes.simple.type.TypeInteger.BOT,seed,false).parse();
- code.opto();
- assertEquals("S{x=9,y=25,z=17}",Eval2.eval(code,4));
- }
- }
-}