summaryrefslogtreecommitdiff
path: root/chapter21/src/test
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-04-05 15:53:10 -0700
committerCliff Click <cliffc@acm.org>2025-04-05 15:53:10 -0700
commit532b34d34fde93b2841f4c9544c673a0d89434ea (patch)
tree8fad454941c428d9b2ebb435470b09c35923979a /chapter21/src/test
parent7277ab049ab9cae5fa64cd5ea958f69278f773a4 (diff)
downloadSimple-532b34d34fde93b2841f4c9544c673a0d89434ea.tar.gz
Simple-532b34d34fde93b2841f4c9544c673a0d89434ea.zip
Fix vs0 bugs
Use a BoolNode.NE instead of inverting outputs; the outputs are already matched and cannot be inverted. Use a `swap` not an `invert` when switching sides in a compare.
Diffstat (limited to 'chapter21/src/test')
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java2
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java2
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp6
3 files changed, 5 insertions, 5 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java
index da58b76e..69179043 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java
+++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java
@@ -74,7 +74,7 @@ return sqrt(arg) + sqrt(arg+2);
public void testNewtonFloat() throws IOException {
String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp"))
+ "flt farg = arg; return test_sqrt(farg) + test_sqrt(farg+2.0);";
- testCPU(src,"x86_64_v2", "SystemV",23,null);
+ testCPU(src,"x86_64_v2", "SystemV",39,null);
testCPU(src,"riscv" , "SystemV",17,null);
testCPU(src,"arm" , "SystemV",18,null);
}
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
index c3f9193e..5f68d0e3 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
+++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
@@ -47,7 +47,7 @@ public class Chapter21Test {
public void testNewtonFloat() throws IOException {
String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp"))
+ "flt farg = arg; return test_sqrt(farg) + test_sqrt(farg+2.0);";
- testCPU(src,"x86_64_v2", "SystemV",23,null);
+ testCPU(src,"x86_64_v2", "SystemV",39,null);
testCPU(src,"riscv" , "SystemV",18,null);
testCPU(src,"arm" , "SystemV",19,null);
}
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp b/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp
index 1389e12d..c76e942f 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp
+++ b/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp
@@ -1,12 +1,12 @@
// -*- mode: java; -*-
// Newtons approximation to the square root
val test_sqrt = { flt x ->
- //flt epsilon = 1e-57;
+ flt epsilon = 1e-57;
flt guess = x;
while( 1 ) {
flt next = (x/guess + guess)/2;
- //if( guess-epsilon <= next & next <= guess+epsilon ) return guess;
- if( guess==next ) return guess;
+ if( guess-epsilon <= next & next <= guess+epsilon ) return guess;
+ //if( guess==next ) return guess;
guess = next;
}
};