From 23481970c0115bf86f08c89b3916285b78311b8d Mon Sep 17 00:00:00 2001 From: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Date: Tue, 29 Sep 2026 17:37:41 +0800 Subject: Add same constant phi merge test --- .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 +++++++++++++++ 21 files changed, 315 insertions(+) diff --git a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 31ca56a0..674e2ba9 100644 --- a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -131,6 +131,21 @@ return a;"""); assertEquals("return (arg==Phi(Region16,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 31ca56a0..674e2ba9 100644 --- a/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -131,6 +131,21 @@ return a;"""); assertEquals("return (arg==Phi(Region16,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 5bb67817..d6c91a4a 100644 --- a/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -131,6 +131,21 @@ return a;"""); assertEquals("return (arg==Phi(Region16,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 68d379a1..fa9a5e37 100644 --- a/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region16,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 6ad3af15..2c869033 100644 --- a/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region16,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter10/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter10/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 35e54fa9..3d75ed03 100644 --- a/chapter10/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter10/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region16,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 8d15493f..b01ffe0a 100644 --- a/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region18,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 8d15493f..b01ffe0a 100644 --- a/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region18,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 9d154413..70f4ccea 100644 --- a/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region19,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 9d154413..70f4ccea 100644 --- a/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region19,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 9d154413..70f4ccea 100644 --- a/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region19,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java index b5920125..81ff2244 100644 --- a/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); assertEquals("return (arg==Phi(Region22,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 9afb8f28..7ea75f49 100644 --- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -132,6 +132,21 @@ return a;"""); assertEquals("return (arg==Phi(Region,3,2));", ret.toString()); } + @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java index f4db5624..ff60c695 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); diff --git a/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 86ec4136..7a9414a2 100644 --- a/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); diff --git a/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java index a584ad5a..70cc6121 100644 --- a/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); diff --git a/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); diff --git a/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 6ac08fda..79af6ae7 100644 --- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -137,6 +137,21 @@ return a; assertEquals("return (arg==Phi(Region,3,2));", code.print()); } + @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); -- cgit v1.2.3