summaryrefslogtreecommitdiff
path: root/chapter32/src/test/java/com/seaofnodes/simple/SchedulingTest.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-11-15 16:11:39 -0800
committerCliff Click <cliffc@acm.org>2026-11-15 16:11:39 -0800
commit9fe7c6f9697b5bbf3041261fdc60040e75cc674f (patch)
treed92a8ff20ed984938d90ad8917b4d67fba9fb745 /chapter32/src/test/java/com/seaofnodes/simple/SchedulingTest.java
parentf0a6c6757a795b8e186de0076836a87acef59fa7 (diff)
downloadSimple-ch32.tar.gz
Simple-ch32.zip
Split off chapter 31ch32
Ch 32 will be focused on compiler performance issues.
Diffstat (limited to 'chapter32/src/test/java/com/seaofnodes/simple/SchedulingTest.java')
-rw-r--r--chapter32/src/test/java/com/seaofnodes/simple/SchedulingTest.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/chapter32/src/test/java/com/seaofnodes/simple/SchedulingTest.java b/chapter32/src/test/java/com/seaofnodes/simple/SchedulingTest.java
new file mode 100644
index 00000000..16e12b0f
--- /dev/null
+++ b/chapter32/src/test/java/com/seaofnodes/simple/SchedulingTest.java
@@ -0,0 +1,47 @@
+package com.seaofnodes.simple;
+
+import org.junit.Test;
+
+public class SchedulingTest {
+ @Test public void nativeFoldedLoadsWithLaterOperands() throws Exception {
+ TestC.runSYS("""
+ val compare_noInline={ i64[] a, int flag ->
+ i64 x=a[0];
+ i64 y=flag ? a[1] : a[2];
+ return x==y;
+ };
+ val add_noInline={ i64[] a, int flag ->
+ i64 x=a[0];
+ i64 y=flag ? a[1] : a[2];
+ return x+y;
+ };
+ val main={ ->
+ val a=new i64[3]; a[0]=17; a[1]=17; a[2]=23;
+ if(!compare_noInline(a,1) || compare_noInline(a,0)) return 1;
+ if(add_noInline(a,1)!=34 || add_noInline(a,0)!=40) return 2;
+ return 0;
+ };
+ ""","scheduleLaterOperands","",-1);
+ }
+
+ @Test public void nativeLoadsAcrossWrites() throws Exception {
+ TestC.runSYS("""
+ val change_noInline={ i64[] a -> a[0]=a[1]; return a[0]; };
+ val compare_noInline={ i64[] a ->
+ i64 x=a[0];
+ return x==change_noInline(a);
+ };
+ val add_noInline={ i64[] a ->
+ i64 x=a[0];
+ return x+change_noInline(a);
+ };
+ val main={ ->
+ val a=new i64[2]; a[0]=17; a[1]=23;
+ if(compare_noInline(a)) return 1;
+ a[0]=17; a[1]=29;
+ if(add_noInline(a)!=46) return 2;
+ return 0;
+ };
+ ""","scheduleAcrossWrites","",-1);
+ }
+}