diff options
| author | Cliff Click <cliffc@acm.org> | 2025-04-21 11:57:04 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-04-21 11:57:04 -0700 |
| commit | 5fb03752b195e99dd251c9d497cccc93335bffe2 (patch) | |
| tree | 3661556b0ea2276611c7524aa34865b9c4ff597b | |
| parent | 79d6d7b2a882046da6be199da0a0651c6c13bb2b (diff) | |
| download | Simple-5fb03752b195e99dd251c9d497cccc93335bffe2.tar.gz Simple-5fb03752b195e99dd251c9d497cccc93335bffe2.zip | |
Code quality on loop with many continues
3 files changed, 24 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 6a22498b..1857367b 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java @@ -73,6 +73,13 @@ public class Chapter21Test { TestC.run("stringHash", 9); } + @Test public void testLoop2() throws IOException { + String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/loop2.smp")); + testCPU(src,"x86_64_v2", "Win64" ,0,"return (inc,Phi(Loop,0,inc));"); + testCPU(src,"riscv" , "SystemV",0,"return ( Phi(Loop,0,addi) + #1 );"); + testCPU(src,"arm" , "SystemV",0,"return (inc,Phi(Loop,0,inc));"); + } + @Test public void testNewtonExport() throws IOException { String result = """ 0 0.000000 (0) diff --git a/chapter21/src/test/java/com/seaofnodes/simple/progs/loop2.c b/chapter21/src/test/java/com/seaofnodes/simple/progs/loop2.c new file mode 100644 index 00000000..934f2d89 --- /dev/null +++ b/chapter21/src/test/java/com/seaofnodes/simple/progs/loop2.c @@ -0,0 +1,7 @@ + +__attribute__ ((CALL_CONV)) +extern int loop2(); + +int main() { + return loop2(); +} diff --git a/chapter21/src/test/java/com/seaofnodes/simple/progs/loop2.smp b/chapter21/src/test/java/com/seaofnodes/simple/progs/loop2.smp new file mode 100644 index 00000000..01ec827e --- /dev/null +++ b/chapter21/src/test/java/com/seaofnodes/simple/progs/loop2.smp @@ -0,0 +1,10 @@ +// -*- mode: java; -*- +int i = 0; +while(true) { + i += 1; + if( i==0 ) continue; + if( i==1 ) continue; + if( i==2 ) break; + continue; +} +return i; |
