From e31c37890a86aedfb209cf543baf05b1b60a27d2 Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Mon, 29 Apr 2024 00:11:36 +0100 Subject: Ch10update (#75) * Store-after-Store peep * Load-after-Store peephole * Fix graph viz mem edge color bug * Scalar replace loop carried dependence * #67 Dead Not node hanging around - if we add a Not in the upcast then add it to the IterPeeps worklist to ensure it gets cleaned up. We don't see the Not node in the parser hence we cannot do a peep on it there. * #67 Update visuals. Add description of Store-Store and Store-Load peeps. Add examples. * #67 Undo the change that wasn't supposed to be committed! * #67 Update description of the Store-Store and Store-Load peepholes --------- Co-authored-by: Cliff Click --- .../java/com/seaofnodes/simple/Chapter10Test.java | 33 +++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'chapter10/src/test/java/com') diff --git a/chapter10/src/test/java/com/seaofnodes/simple/Chapter10Test.java b/chapter10/src/test/java/com/seaofnodes/simple/Chapter10Test.java index 6bafe72a..36ad19ae 100644 --- a/chapter10/src/test/java/com/seaofnodes/simple/Chapter10Test.java +++ b/chapter10/src/test/java/com/seaofnodes/simple/Chapter10Test.java @@ -30,9 +30,9 @@ bar.a = 1; bar.a = 2; return bar.a; """); - StopNode stop = parser.parse(true).iterate(true); + StopNode stop = parser.parse(false).iterate(true); System.out.println(IRPrinter.prettyPrint(stop, 99, true)); - assertEquals("return .a;", stop.toString()); + assertEquals("return 2;", stop.toString()); } @Test @@ -86,8 +86,8 @@ while (arg) { } return bar.a; """); - StopNode stop = parser.parse(true).iterate(true); - assertEquals("return .a;", stop.toString()); + StopNode stop = parser.parse(false).iterate(true); + assertEquals("return Phi(Loop10,0,(Phi_a+2));", stop.toString()); } @Test @@ -189,6 +189,31 @@ v1=new s0; catch( Exception e ) { assertEquals("Redefining name 'v1'", e.getMessage()); } } + @Test + public void testIter() { + // Build and use an iterator + Parser parser = new Parser( +""" +struct Iter { + int x; + int len; +} +Iter i = new Iter; +i.len = arg; +int sum=0; +while( i.x < i.len ) { + sum = sum + i.x; + i.x = i.x + 1; +} +return sum; +"""); + StopNode stop = parser.parse().iterate(true); + assertEquals("return Phi(Loop14,0,(Phi(Loop,0,(Phi_x+1))+Phi_sum));", stop.toString()); + } + + + + @Test public void test1() { Parser parser = new Parser(""" -- cgit v1.2.3