summaryrefslogtreecommitdiff
path: root/chapter21/src/test
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-04-12 11:41:58 -0700
committerCliff Click <cliffc@acm.org>2025-04-12 11:41:58 -0700
commitd08925c1ff212e2157356eacbd748e679b80954d (patch)
tree5761010cf6fba6101734a3bb6f806fdf3841210b /chapter21/src/test
parent798bd959410eb6c2e0b9f7ae1222181ac2b295d4 (diff)
downloadSimple-d08925c1ff212e2157356eacbd748e679b80954d.tar.gz
Simple-d08925c1ff212e2157356eacbd748e679b80954d.zip
2 more encoding bugs
Missing constant NIL, arm CAST
Diffstat (limited to 'chapter21/src/test')
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java8
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/progs/antiDep1.smp11
2 files changed, 19 insertions, 0 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
index 0610d294..e584f9bc 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
+++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
@@ -64,6 +64,14 @@ public class Chapter21Test {
testCPU(src,"arm" , "SystemV",19,null);
}
+ @Test
+ public void testAntiDeps1() throws IOException {
+ String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/antiDep1.smp"));
+ testCPU(src,"x86_64_v2", "SystemV", 3,"return mov(mov(S));");
+ testCPU(src,"riscv" , "SystemV",10,"return mov(mov(S));");
+ testCPU(src,"arm" , "SystemV",10,"return mov(mov(S));");
+ }
+
@Test public void testNewtonExport() throws IOException {
String result = """
0 0.000000
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/progs/antiDep1.smp b/chapter21/src/test/java/com/seaofnodes/simple/progs/antiDep1.smp
new file mode 100644
index 00000000..b18dfd16
--- /dev/null
+++ b/chapter21/src/test/java/com/seaofnodes/simple/progs/antiDep1.smp
@@ -0,0 +1,11 @@
+// -*- mode: java; -*-
+struct S { int f; };
+var v0 = new S;
+S? v1;
+if (arg) v1 = new S;
+if (v1) {
+ v0.f = v1.f;
+} else {
+ v0.f = 2;
+}
+return v0;