summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2023-11-11 23:17:22 +0000
committerCliff Click <cliffc@acm.org>2026-09-29 12:34:58 -0700
commit03acc04cb96c452fb681d640d9947ee177d3e463 (patch)
tree7fcb7b446286f90a738fdabd3fde1126b7eed044
parent10249be5b6b13adfeaea77418a4770f0c39485f5 (diff)
downloadSimple-03acc04cb96c452fb681d640d9947ee177d3e463.tar.gz
Simple-03acc04cb96c452fb681d640d9947ee177d3e463.zip
Chapter 6: Peepholes for If
Co-authored-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Co-authored-by: Thalia Archibald <thalia@archibald.dev> Co-authored-by: Yichen Yan <oraluben@outlook.com> Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: Symious <14933944+symious@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: tannal <tannal2409@gmail.com> Co-authored-by: hadha <helsgithub15@gmail.com> Co-authored-by: Tamás Hadházy <85063808+Hels15@users.noreply.github.com> Co-authored-by: Tamas Hadhazy <helsgithub15@gmail.com> Co-authored-by: RobertObkircher <robert.obkircher@gmail.com> Co-authored-by: Robert Obkircher <robert.obkircher@gmail.com>
-rw-r--r--Makefile100
-rw-r--r--README.md2
-rw-r--r--docs/chapter06/06-grammar.md79
-rw-r--r--docs/chapter06/06-graph1-post.gv29
-rw-r--r--docs/chapter06/06-graph1-post.svg67
-rw-r--r--docs/chapter06/06-graph1-pre.gv52
-rw-r--r--docs/chapter06/06-graph1-pre.svg160
-rw-r--r--docs/chapter06/06-graph2-post.gv33
-rw-r--r--docs/chapter06/06-graph2-post.svg67
-rw-r--r--docs/chapter06/06-graph2-pre.gv55
-rw-r--r--docs/chapter06/06-graph2-pre.svg154
-rw-r--r--docs/chapter06/06-graph3-false.gv35
-rw-r--r--docs/chapter06/06-graph3-false.svg67
-rw-r--r--docs/chapter06/06-graph3-nonconst-peephole.gv56
-rw-r--r--docs/chapter06/06-graph3-nonconst-peephole.svg150
-rw-r--r--docs/chapter06/06-graph3-nonconst.gv86
-rw-r--r--docs/chapter06/06-graph3-nonconst.svg290
-rw-r--r--docs/chapter06/06-graph3-true.gv35
-rw-r--r--docs/chapter06/06-graph3-true.svg67
-rw-r--r--docs/chapter06/06-graph4-arg2.gv37
-rw-r--r--docs/chapter06/06-graph4-arg2.svg67
-rw-r--r--docs/chapter06/06-graph4-nonconst.gv122
-rw-r--r--docs/chapter06/06-graph4-nonconst.svg456
-rw-r--r--docs/chapter06/06-graph4-true.gv37
-rw-r--r--docs/chapter06/06-graph4-true.svg67
-rw-r--r--docs/chapter06/Makefile12
-rw-r--r--docs/chapter06/README.md200
-rw-r--r--docs/chapter06/lattice.gv97
-rw-r--r--docs/chapter06/lattice.svg319
-rw-r--r--src/main/java/com/seaofnodes/simple/Parser.java3
-rw-r--r--src/main/java/com/seaofnodes/simple/node/AddNode.java67
-rw-r--r--src/main/java/com/seaofnodes/simple/node/BoolNode.java7
-rw-r--r--src/main/java/com/seaofnodes/simple/node/IfNode.java20
-rw-r--r--src/main/java/com/seaofnodes/simple/node/MulNode.java6
-rw-r--r--src/main/java/com/seaofnodes/simple/node/Node.java49
-rw-r--r--src/main/java/com/seaofnodes/simple/node/PhiNode.java27
-rw-r--r--src/main/java/com/seaofnodes/simple/node/ProjNode.java2
-rw-r--r--src/main/java/com/seaofnodes/simple/node/RegionNode.java49
-rw-r--r--src/main/java/com/seaofnodes/simple/node/ReturnNode.java6
-rw-r--r--src/main/java/com/seaofnodes/simple/node/ScopeNode.java4
-rw-r--r--src/main/java/com/seaofnodes/simple/node/StartNode.java6
-rw-r--r--src/main/java/com/seaofnodes/simple/node/StopNode.java5
-rw-r--r--src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java2
-rw-r--r--src/main/java/com/seaofnodes/simple/print/SimpleGraphObserver.java2
-rw-r--r--src/main/java/com/seaofnodes/simple/type/Type.java37
-rw-r--r--src/main/java/com/seaofnodes/simple/type/TypeInteger.java2
-rw-r--r--src/main/java/com/seaofnodes/simple/type/TypeTuple.java8
-rw-r--r--src/test/java/com/seaofnodes/simple/Chapter06Test.java294
48 files changed, 3546 insertions, 48 deletions
diff --git a/Makefile b/Makefile
index 67307a26..8c2d5797 100644
--- a/Makefile
+++ b/Makefile
@@ -1 +1,99 @@
-include $(firstword $(wildcard ../build-support/early-chapter.mk build-support/early-chapter.mk))
+SHELL := /bin/bash
+# Shared packaging target; included after chapter source variables below.
+.DELETE_ON_ERROR:
+
+# for printing variable values
+# usage: make print-VARIABLE
+# > VARIABLE = value_of_variable
+print-% : ; @echo $* = $($*)
+
+# literal space
+space := $() $()
+
+# Decide OS-specific questions
+# jar-file seperator
+ifeq ($(OS),Windows_NT)
+ SEP = ;
+else
+ SEP = :
+endif
+# Find a reasonable ctags.
+CTAGS = $(shell which ctags)
+# Hack for MacOS: /usr/bin/ctags is unfriendly, so look for ctags from brew
+ifeq ($(UNAME),Darwin)
+ CTAGS = $(shell brew list ctags 2> /dev/null | grep bin/ctags)
+endif
+
+# Fun Args to javac. Mostly limit to java8 source definitions, and fairly
+# aggressive lint warnings.
+JAVAC_ARGS = -g
+
+# Source code
+SIMPLE := com/seaofnodes/simple
+SRC := src/main/java
+TST := src/test/java
+CLZDIR:= build/classes
+main_javas := $(wildcard $(SRC)/$(SIMPLE)/*java $(SRC)/$(SIMPLE)/*/*java)
+test_javas := $(wildcard $(TST)/$(SIMPLE)/*java $(TST)/$(SIMPLE)/*/*java)
+main_classes := $(patsubst $(SRC)/%java,$(CLZDIR)/main/%class,$(main_javas))
+include $(firstword $(wildcard ../graph/graph.mk graph/graph.mk))
+test_classes := $(patsubst $(TST)/%java,$(CLZDIR)/test/%class,$(test_javas))
+test_cp := $(patsubst $(TST)/$(SIMPLE)/%.java,com.seaofnodes.simple.%,$(test_javas))
+classes = $(main_classes) $(test_classes)
+# All the libraries
+libs = $(wildcard lib/*jar)
+jars = $(subst $(space),$(SEP),$(libs))
+
+
+default_targets := $(main_classes) $(test_classes)
+# Optionally add ctags to the default target if a reasonable one was found.
+ifneq ($(CTAGS),)
+default_targets += tags
+endif
+
+default: $(default_targets)
+
+# Compile just the out-of-date files
+$(main_classes): build/classes/main/%class: $(SRC)/%java $(graph_javas)
+ @echo "compiling " $@ " because " $?
+ @[ -d $(CLZDIR)/main ] || mkdir -p $(CLZDIR)/main
+ @javac $(JAVAC_ARGS) -cp "$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(SRC) -d $(CLZDIR)/main $(main_javas)
+
+$(test_classes): $(CLZDIR)/test/%class: $(TST)/%java $(main_classes)
+ @echo "compiling " $@ " because " $?
+ @[ -d $(CLZDIR)/test ] || mkdir -p $(CLZDIR)/test
+ @javac $(JAVAC_ARGS) -cp "$(CLZDIR)/test$(SEP)$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(TST) -d $(CLZDIR)/test $(test_javas)
+
+# Base launch line for JVM tests
+JVM=nice java -ea -cp "build/classes/main${SEP}${jars}${SEP}$(CLZDIR)/test"
+
+tests: $(default_targets)
+ $(JVM) org.junit.runner.JUnitCore $(test_cp)
+
+.PHONY: clean
+clean:
+ rm -rf build
+ rm -f TAGS
+ (find . -name "*~" -exec rm {} \; 2>/dev/null; exit 0)
+
+# Download libs from maven
+lib: lib/junit-4.12.jar lib/hamcrest-core-1.3.jar
+
+# Jars
+lib/junit-4.12.jar:
+ @[ -d lib ] || mkdir -p lib
+ @(cd lib; wget https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar)
+
+lib/hamcrest-core-1.3.jar:
+ @[ -d lib ] || mkdir -p lib
+ @(cd lib; wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar)
+
+# Build emacs tags (part of a tasty emacs ide experience)
+tags: $(main_javas) $(test_javas)
+ @rm -f TAGS
+ @$(CTAGS) -e --recurse=yes --extra=+q --fields=+fksaiS $(SRC) $(TST)
+
+include $(firstword $(wildcard ../build-support/chapter-release.mk build-support/chapter-release.mk))
+
+.PHONY: build
+build: $(main_classes)
diff --git a/README.md b/README.md
index 962ece1f..f255bafe 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@ The Simple language is styled after a subset of C or Java.
Non-zero values will be truthy. Peephole optimizations involving algebraic
simplifications.
* [Chapter 5](docs/chapter05/README.md): `if` statement. CFG construction.
-* Chapter 6: Peephole optimization around dead control flow.
+* [Chapter 6](docs/chapter06/README.md): Peephole optimization around dead control flow.
* Chapter 7: `while` statement; looping constructs - eager phi approach.
* Chapter 8: Looping constructs continued, lazy phi creation, `break` and `continue` statements.
* Chapter 9: Global Value Numbering. Iterative peepholes to fixpoint. Worklists.
diff --git a/docs/chapter06/06-grammar.md b/docs/chapter06/06-grammar.md
new file mode 100644
index 00000000..9ed7b160
--- /dev/null
+++ b/docs/chapter06/06-grammar.md
@@ -0,0 +1,79 @@
+# Grammar for Chapter 6
+
+```antlrv4
+grammar SimpleLanguage;
+
+program
+ : statement+ EOF
+ ;
+
+statement
+ : returnStatement
+ | declStatement
+ | blockStatment
+ | expressionStatement
+ | ifStatement
+ ;
+
+ifStatement
+ : 'if' '(' expression ')' statement ('else' statement)?
+ ;
+
+
+expressionStatement
+ : IDENTIFIER '=' expression ';'
+ ;
+
+blockStatement
+ : '{' statement+ '}'
+ ;
+
+declStatement
+ : 'int' IDENTIFIER '=' expression ';'
+ ;
+
+returnStatement
+ : 'return' expression ';'
+ ;
+
+expression
+ : comparisonExpression
+ ;
+
+comparisonExpression
+ : additiveExpression (('==' | '!='| '>'| '<'| '>='| '<=') additiveExpression)*
+ ;
+
+additiveExpression
+ : multiplicativeExpression (('+' | '-') multiplicativeExpression)*
+ ;
+
+multiplicativeExpression
+ : unaryExpression (('*' | '/') unaryExpression)*
+ ;
+
+unaryExpression
+ : ('-') unaryExpression
+ | primaryExpression
+ ;
+
+primaryExpression
+ : IDENTIFIER
+ | INTEGER_LITERAL
+ | 'true'
+ | 'false'
+ | '(' expression ')'
+ ;
+
+INTEGER_LITERAL
+ : [1-9][0-9]*
+ | [0]
+ ;
+
+IDENTIFIER
+ : NON_DIGIT (NON_DIGIT | DIGIT)*
+ ;
+
+NON_DIGIT: [a-zA-Z_];
+DEC_DIGIT: [0-9];
+```
diff --git a/docs/chapter06/06-graph1-post.gv b/docs/chapter06/06-graph1-post.gv
new file mode 100644
index 00000000..31480991
--- /dev/null
+++ b/docs/chapter06/06-graph1-post.gv
@@ -0,0 +1,29 @@
+digraph chapter06 {
+/*
+if( true ) return 2;
+return 1;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_12 [ label="#2" ];
+ Return13 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return13[taillabel=0 color=red];
+ Return13 -> Start2:p0[taillabel=0 color=red];
+ Return13 -> Con_12[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph1-post.svg b/docs/chapter06/06-graph1-post.svg
new file mode 100644
index 00000000..faabcd8c
--- /dev/null
+++ b/docs/chapter06/06-graph1-post.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="178pt" height="248pt"
+ viewBox="0.00 0.00 178.00 248.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 244)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-244 174,-244 174,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-232 162,-232 162,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<polygon fill="none" stroke="black" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<text text-anchor="start" x="30.5" y="-203.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="24,-164 24,-195 74,-195 74,-164 24,-164"/>
+<polygon fill="yellow" stroke="transparent" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<polygon fill="none" stroke="black" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<text text-anchor="start" x="32" y="-175.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="112,-52 58,-52 58,-16 112,-16 112,-52"/>
+<text text-anchor="middle" x="85" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return13 -->
+<g id="node4" class="node">
+<title>Return13</title>
+<polygon fill="yellow" stroke="black" points="118,-124 52,-124 52,-88 118,-88 118,-124"/>
+<text text-anchor="middle" x="85" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return13 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return13</title>
+<path fill="none" stroke="red" d="M85,-52.3C85,-60.02 85,-69.29 85,-77.89"/>
+<polygon fill="red" stroke="red" points="81.5,-77.9 85,-87.9 88.5,-77.9 81.5,-77.9"/>
+<text text-anchor="middle" x="82" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_12 -->
+<g id="node3" class="node">
+<title>Con_12</title>
+<ellipse fill="none" stroke="black" cx="127" cy="-192" rx="27" ry="18"/>
+<text text-anchor="middle" x="127" y="-188.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Return13&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>Return13&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M68.26,-124.13C60.77,-133.26 52.99,-145.23 50.13,-158.06"/>
+<polygon fill="red" stroke="red" points="46.66,-157.67 49,-168 53.61,-158.46 46.66,-157.67"/>
+<text text-anchor="middle" x="65.26" y="-126.73" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return13&#45;&gt;Con_12 -->
+<g id="edge3" class="edge">
+<title>Return13&#45;&gt;Con_12</title>
+<path fill="none" stroke="black" d="M93.7,-124.4C99.66,-136.31 107.65,-152.3 114.31,-165.62"/>
+<polygon fill="black" stroke="black" points="111.28,-167.38 118.88,-174.76 117.54,-164.25 111.28,-167.38"/>
+<text text-anchor="middle" x="90.7" y="-127" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph1-pre.gv b/docs/chapter06/06-graph1-pre.gv
new file mode 100644
index 00000000..2bfdd23d
--- /dev/null
+++ b/docs/chapter06/06-graph1-pre.gv
@@ -0,0 +1,52 @@
+digraph chapter06 {
+/*
+if( true ) return 2;
+return 1;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_6 [ label="#1" ];
+ If7 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_11 [ label="#2" ];
+ Return12 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ Con_13 [ label="#~CONTROL" ];
+ Region14 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Con_15 [ label="#1" ];
+ Return16 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region14;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return12[taillabel=0 color=red];
+ Stop3 -> Return16[taillabel=1 color=red];
+ If7 -> Start2:p0[taillabel=0 color=red];
+ If7 -> Con_6[taillabel=1];
+ Return12 -> If7:p0[taillabel=0 color=red];
+ Return12 -> Con_11[taillabel=1];
+ Region14 -> Con_13[taillabel=1];
+ Region14 -> If7:p1[taillabel=2 color=red];
+ Return16 -> Region14[taillabel=0 color=red];
+ Return16 -> Con_15[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph1-pre.svg b/docs/chapter06/06-graph1-pre.svg
new file mode 100644
index 00000000..f80edcfc
--- /dev/null
+++ b/docs/chapter06/06-graph1-pre.svg
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="316pt" height="420pt"
+ viewBox="0.00 0.00 316.00 420.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 416)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-416 312,-416 312,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-404 300,-404 300,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="35,-367 35,-392 85,-392 85,-367 35,-367"/>
+<polygon fill="none" stroke="black" points="35,-367 35,-392 85,-392 85,-367 35,-367"/>
+<text text-anchor="start" x="41.5" y="-375.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="35,-336 35,-367 85,-367 85,-336 35,-336"/>
+<polygon fill="yellow" stroke="transparent" points="40,-341 40,-362 80,-362 80,-341 40,-341"/>
+<polygon fill="none" stroke="black" points="40,-341 40,-362 80,-362 80,-341 40,-341"/>
+<text text-anchor="start" x="43" y="-347.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="150,-52 96,-52 96,-16 150,-16 150,-52"/>
+<text text-anchor="middle" x="123" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return12 -->
+<g id="node6" class="node">
+<title>Return12</title>
+<polygon fill="yellow" stroke="black" points="114,-124 48,-124 48,-88 114,-88 114,-124"/>
+<text text-anchor="middle" x="81" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return12 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return12</title>
+<path fill="none" stroke="red" d="M112.62,-52.3C107.74,-60.44 101.81,-70.31 96.42,-79.3"/>
+<polygon fill="red" stroke="red" points="93.41,-77.52 91.26,-87.9 99.41,-81.12 93.41,-77.52"/>
+<text text-anchor="middle" x="109.62" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return16 -->
+<g id="node10" class="node">
+<title>Return16</title>
+<polygon fill="yellow" stroke="black" points="198,-124 132,-124 132,-88 198,-88 198,-124"/>
+<text text-anchor="middle" x="165" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return16 -->
+<g id="edge2" class="edge">
+<title>Stop3&#45;&gt;Return16</title>
+<path fill="none" stroke="red" d="M133.38,-52.3C138.26,-60.44 144.19,-70.31 149.58,-79.3"/>
+<polygon fill="red" stroke="red" points="146.59,-81.12 154.74,-87.9 152.59,-77.52 146.59,-81.12"/>
+<text text-anchor="middle" x="130.38" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_6 -->
+<g id="node3" class="node">
+<title>Con_6</title>
+<ellipse fill="none" stroke="black" cx="138" cy="-364" rx="27" ry="18"/>
+<text text-anchor="middle" x="138" y="-360.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- If7 -->
+<g id="node4" class="node">
+<title>If7</title>
+<polygon fill="yellow" stroke="transparent" points="24,-267 24,-292 118,-292 118,-267 24,-267"/>
+<polygon fill="none" stroke="black" points="24,-267 24,-292 118,-292 118,-267 24,-267"/>
+<text text-anchor="start" x="65.5" y="-275.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="24,-236 24,-267 118,-267 118,-236 24,-236"/>
+<polygon fill="yellow" stroke="transparent" points="29,-241 29,-262 69,-262 69,-241 29,-241"/>
+<polygon fill="none" stroke="black" points="29,-241 29,-262 69,-262 69,-241 29,-241"/>
+<text text-anchor="start" x="32" y="-247.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="69,-241 69,-262 113,-262 113,-241 69,-241"/>
+<polygon fill="none" stroke="black" points="69,-241 69,-262 113,-262 113,-241 69,-241"/>
+<text text-anchor="start" x="72" y="-247.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If7&#45;&gt;Start2 -->
+<g id="edge3" class="edge">
+<title>If7&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M64.35,-296.23C62.56,-306.6 60.93,-318.45 60.29,-329.99"/>
+<polygon fill="red" stroke="red" points="56.79,-329.9 60,-340 63.79,-330.11 56.79,-329.9"/>
+<text text-anchor="middle" x="61.35" y="-298.83" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If7&#45;&gt;Con_6 -->
+<g id="edge4" class="edge">
+<title>If7&#45;&gt;Con_6</title>
+<path fill="none" stroke="black" d="M92.2,-296.01C101.67,-309.86 112.66,-325.94 121.5,-338.87"/>
+<polygon fill="black" stroke="black" points="118.7,-340.97 127.24,-347.25 124.48,-337.02 118.7,-340.97"/>
+<text text-anchor="middle" x="89.2" y="-298.61" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_11 -->
+<g id="node5" class="node">
+<title>Con_11</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-174.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Return12&#45;&gt;If7 -->
+<g id="edge5" class="edge">
+<title>Return12&#45;&gt;If7:p0</title>
+<path fill="none" stroke="red" d="M83.45,-124.21C85.4,-142.49 86.7,-172.01 79,-196 73.01,-214.66 56.37,-216.36 50.82,-229.83"/>
+<polygon fill="red" stroke="red" points="47.32,-229.54 49,-240 54.21,-230.77 47.32,-229.54"/>
+<text text-anchor="middle" x="80.45" y="-126.81" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return12&#45;&gt;Con_11 -->
+<g id="edge6" class="edge">
+<title>Return12&#45;&gt;Con_11</title>
+<path fill="none" stroke="black" d="M71.61,-124.3C67.1,-132.6 61.63,-142.69 56.67,-151.81"/>
+<polygon fill="black" stroke="black" points="53.46,-150.4 51.76,-160.86 59.61,-153.74 53.46,-150.4"/>
+<text text-anchor="middle" x="68.61" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_13 -->
+<g id="node7" class="node">
+<title>Con_13</title>
+<ellipse fill="none" stroke="black" cx="218" cy="-264" rx="74.19" ry="18"/>
+<text text-anchor="middle" x="218" y="-260.3" font-family="Times,serif" font-size="14.00">#~CONTROL</text>
+</g>
+<!-- Region14 -->
+<g id="node8" class="node">
+<title>Region14</title>
+<polygon fill="yellow" stroke="black" points="190,-196 124,-196 124,-160 190,-160 190,-196"/>
+<text text-anchor="middle" x="157" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region14&#45;&gt;If7 -->
+<g id="edge8" class="edge">
+<title>Region14&#45;&gt;If7:p1</title>
+<path fill="none" stroke="red" d="M150.64,-196.06C144.08,-212.53 133.37,-236.39 122.96,-246.35"/>
+<polygon fill="red" stroke="red" points="121.27,-243.29 114,-251 124.49,-249.5 121.27,-243.29"/>
+<text text-anchor="middle" x="147.64" y="-198.66" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Region14&#45;&gt;Con_13 -->
+<g id="edge7" class="edge">
+<title>Region14&#45;&gt;Con_13</title>
+<path fill="none" stroke="black" d="M169.64,-196.4C178.34,-208.39 190.04,-224.5 199.75,-237.87"/>
+<polygon fill="black" stroke="black" points="197.09,-240.16 205.79,-246.19 202.75,-236.04 197.09,-240.16"/>
+<text text-anchor="middle" x="166.64" y="-199" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_15 -->
+<g id="node9" class="node">
+<title>Con_15</title>
+<ellipse fill="none" stroke="black" cx="235" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="235" y="-174.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- Return16&#45;&gt;Region14 -->
+<g id="edge9" class="edge">
+<title>Return16&#45;&gt;Region14</title>
+<path fill="none" stroke="red" d="M163.02,-124.3C162.14,-132.02 161.08,-141.29 160.1,-149.89"/>
+<polygon fill="red" stroke="red" points="156.61,-149.56 158.95,-159.9 163.57,-150.36 156.61,-149.56"/>
+<text text-anchor="middle" x="160.02" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return16&#45;&gt;Con_15 -->
+<g id="edge10" class="edge">
+<title>Return16&#45;&gt;Con_15</title>
+<path fill="none" stroke="black" d="M182.3,-124.3C191.72,-133.72 203.47,-145.47 213.47,-155.47"/>
+<polygon fill="black" stroke="black" points="211.18,-158.12 220.72,-162.72 216.12,-153.18 211.18,-158.12"/>
+<text text-anchor="middle" x="179.3" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph2-post.gv b/docs/chapter06/06-graph2-post.gv
new file mode 100644
index 00000000..61ae2ca1
--- /dev/null
+++ b/docs/chapter06/06-graph2-post.gv
@@ -0,0 +1,33 @@
+digraph chapter06 {
+/*
+int a=1;
+if( true )
+ a=2;
+else
+ a=3;
+return a;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Return17 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_13 [ label="#2" ];
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Return17 -> Start2:p0[taillabel=0 color=red];
+ Return17 -> Con_13[taillabel=1];
+ Stop3 -> Return17[taillabel=0 color=red];
+}
diff --git a/docs/chapter06/06-graph2-post.svg b/docs/chapter06/06-graph2-post.svg
new file mode 100644
index 00000000..269eb15c
--- /dev/null
+++ b/docs/chapter06/06-graph2-post.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="178pt" height="248pt"
+ viewBox="0.00 0.00 178.00 248.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 244)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-244 174,-244 174,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-232 162,-232 162,-8 8,-8"/>
+</g>
+<!-- Return17 -->
+<g id="node1" class="node">
+<title>Return17</title>
+<polygon fill="yellow" stroke="black" points="118,-124 52,-124 52,-88 118,-88 118,-124"/>
+<text text-anchor="middle" x="85" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Start2 -->
+<g id="node2" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<polygon fill="none" stroke="black" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<text text-anchor="start" x="30.5" y="-203.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="24,-164 24,-195 74,-195 74,-164 24,-164"/>
+<polygon fill="yellow" stroke="transparent" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<polygon fill="none" stroke="black" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<text text-anchor="start" x="32" y="-175.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Return17&#45;&gt;Start2 -->
+<g id="edge1" class="edge">
+<title>Return17&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M68.26,-124.13C60.77,-133.26 52.99,-145.23 50.13,-158.06"/>
+<polygon fill="red" stroke="red" points="46.66,-157.67 49,-168 53.61,-158.46 46.66,-157.67"/>
+<text text-anchor="middle" x="65.26" y="-126.73" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_13 -->
+<g id="node4" class="node">
+<title>Con_13</title>
+<ellipse fill="none" stroke="black" cx="127" cy="-192" rx="27" ry="18"/>
+<text text-anchor="middle" x="127" y="-188.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Return17&#45;&gt;Con_13 -->
+<g id="edge2" class="edge">
+<title>Return17&#45;&gt;Con_13</title>
+<path fill="none" stroke="black" d="M93.7,-124.4C99.66,-136.31 107.65,-152.3 114.31,-165.62"/>
+<polygon fill="black" stroke="black" points="111.28,-167.38 118.88,-174.76 117.54,-164.25 111.28,-167.38"/>
+<text text-anchor="middle" x="90.7" y="-127" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Stop3 -->
+<g id="node3" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="112,-52 58,-52 58,-16 112,-16 112,-52"/>
+<text text-anchor="middle" x="85" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Stop3&#45;&gt;Return17 -->
+<g id="edge3" class="edge">
+<title>Stop3&#45;&gt;Return17</title>
+<path fill="none" stroke="red" d="M85,-52.3C85,-60.02 85,-69.29 85,-77.89"/>
+<polygon fill="red" stroke="red" points="81.5,-77.9 85,-87.9 88.5,-77.9 81.5,-77.9"/>
+<text text-anchor="middle" x="82" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph2-pre.gv b/docs/chapter06/06-graph2-pre.gv
new file mode 100644
index 00000000..d183b4c4
--- /dev/null
+++ b/docs/chapter06/06-graph2-pre.gv
@@ -0,0 +1,55 @@
+digraph chapter06 {
+/*
+int a=1;
+if( true )
+ a=2;
+else
+ a=3;
+return a;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Return16 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_7 [ label="#1" ];
+ If8 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_12 [ label="#2" ];
+ Con_13 [ label="#3" ];
+ Region14 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a15 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ { rank=same; Region14;Phi_a15;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Return16 -> Region14[taillabel=0 color=red];
+ Return16 -> Phi_a15[taillabel=1];
+ Stop3 -> Return16[taillabel=0 color=red];
+ If8 -> Start2:p0[taillabel=0 color=red];
+ If8 -> Con_7[taillabel=1];
+ Region14 -> If8:p0[taillabel=1 color=red];
+ Region14 -> If8:p1[taillabel=2 color=red];
+ Phi_a15 -> Region14 [style=dotted taillabel=0];
+ Phi_a15 -> Con_12[taillabel=1];
+ Phi_a15 -> Con_13[taillabel=2];
+}
diff --git a/docs/chapter06/06-graph2-pre.svg b/docs/chapter06/06-graph2-pre.svg
new file mode 100644
index 00000000..e9a4dd55
--- /dev/null
+++ b/docs/chapter06/06-graph2-pre.svg
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="294pt" height="420pt"
+ viewBox="0.00 0.00 294.00 420.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 416)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-416 290,-416 290,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-404 278,-404 278,-8 8,-8"/>
+</g>
+<!-- Return16 -->
+<g id="node1" class="node">
+<title>Return16</title>
+<polygon fill="yellow" stroke="black" points="187,-124 121,-124 121,-88 187,-88 187,-124"/>
+<text text-anchor="middle" x="154" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Region14 -->
+<g id="node8" class="node">
+<title>Region14</title>
+<polygon fill="yellow" stroke="black" points="226,-196 160,-196 160,-160 226,-160 226,-196"/>
+<text text-anchor="middle" x="193" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Return16&#45;&gt;Region14 -->
+<g id="edge1" class="edge">
+<title>Return16&#45;&gt;Region14</title>
+<path fill="none" stroke="red" d="M163.64,-124.3C168.13,-132.36 173.56,-142.11 178.52,-151.02"/>
+<polygon fill="red" stroke="red" points="175.55,-152.86 183.47,-159.9 181.66,-149.46 175.55,-152.86"/>
+<text text-anchor="middle" x="160.64" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Phi_a15 -->
+<g id="node9" class="node">
+<title>Phi_a15</title>
+<ellipse fill="lightyellow" stroke="black" cx="115" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-174.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Return16&#45;&gt;Phi_a15 -->
+<g id="edge2" class="edge">
+<title>Return16&#45;&gt;Phi_a15</title>
+<path fill="none" stroke="black" d="M144.36,-124.3C139.69,-132.68 134,-142.9 128.87,-152.1"/>
+<polygon fill="black" stroke="black" points="125.8,-150.42 123.99,-160.86 131.92,-153.82 125.8,-150.42"/>
+<text text-anchor="middle" x="141.36" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Start2 -->
+<g id="node2" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="126,-367 126,-392 176,-392 176,-367 126,-367"/>
+<polygon fill="none" stroke="black" points="126,-367 126,-392 176,-392 176,-367 126,-367"/>
+<text text-anchor="start" x="132.5" y="-375.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="126,-336 126,-367 176,-367 176,-336 126,-336"/>
+<polygon fill="yellow" stroke="transparent" points="131,-341 131,-362 171,-362 171,-341 131,-341"/>
+<polygon fill="none" stroke="black" points="131,-341 131,-362 171,-362 171,-341 131,-341"/>
+<text text-anchor="start" x="134" y="-347.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Stop3 -->
+<g id="node3" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="181,-52 127,-52 127,-16 181,-16 181,-52"/>
+<text text-anchor="middle" x="154" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Stop3&#45;&gt;Return16 -->
+<g id="edge3" class="edge">
+<title>Stop3&#45;&gt;Return16</title>
+<path fill="none" stroke="red" d="M154,-52.3C154,-60.02 154,-69.29 154,-77.89"/>
+<polygon fill="red" stroke="red" points="150.5,-77.9 154,-87.9 157.5,-77.9 150.5,-77.9"/>
+<text text-anchor="middle" x="151" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_7 -->
+<g id="node4" class="node">
+<title>Con_7</title>
+<ellipse fill="none" stroke="black" cx="229" cy="-364" rx="27" ry="18"/>
+<text text-anchor="middle" x="229" y="-360.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- If8 -->
+<g id="node5" class="node">
+<title>If8</title>
+<polygon fill="yellow" stroke="transparent" points="168,-267 168,-292 262,-292 262,-267 168,-267"/>
+<polygon fill="none" stroke="black" points="168,-267 168,-292 262,-292 262,-267 168,-267"/>
+<text text-anchor="start" x="209.5" y="-275.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="168,-236 168,-267 262,-267 262,-236 168,-236"/>
+<polygon fill="yellow" stroke="transparent" points="173,-241 173,-262 213,-262 213,-241 173,-241"/>
+<polygon fill="none" stroke="black" points="173,-241 173,-262 213,-262 213,-241 173,-241"/>
+<text text-anchor="start" x="176" y="-247.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="213,-241 213,-262 257,-262 257,-241 213,-241"/>
+<polygon fill="none" stroke="black" points="213,-241 213,-262 257,-262 257,-241 213,-241"/>
+<text text-anchor="start" x="216" y="-247.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If8&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>If8&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M205.76,-296.05C199.47,-314.72 190.61,-336.65 181.17,-346.18"/>
+<polygon fill="red" stroke="red" points="179.22,-343.25 172,-351 182.48,-349.44 179.22,-343.25"/>
+<text text-anchor="middle" x="202.76" y="-298.65" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If8&#45;&gt;Con_7 -->
+<g id="edge5" class="edge">
+<title>If8&#45;&gt;Con_7</title>
+<path fill="none" stroke="black" d="M219.43,-296.01C221.25,-308.76 223.34,-323.4 225.1,-335.73"/>
+<polygon fill="black" stroke="black" points="221.67,-336.47 226.55,-345.87 228.6,-335.48 221.67,-336.47"/>
+<text text-anchor="middle" x="216.43" y="-298.61" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_12 -->
+<g id="node6" class="node">
+<title>Con_12</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-260.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Con_13 -->
+<g id="node7" class="node">
+<title>Con_13</title>
+<ellipse fill="none" stroke="black" cx="115" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-260.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Region14&#45;&gt;If8 -->
+<g id="edge6" class="edge">
+<title>Region14&#45;&gt;If8:p0</title>
+<path fill="none" stroke="red" d="M193,-196.09C193,-205.55 193,-217.77 193,-229.69"/>
+<polygon fill="red" stroke="red" points="189.5,-230 193,-240 196.5,-230 189.5,-230"/>
+<text text-anchor="middle" x="190" y="-198.69" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region14&#45;&gt;If8 -->
+<g id="edge7" class="edge">
+<title>Region14&#45;&gt;If8:p1</title>
+<path fill="none" stroke="red" d="M213.02,-196.12C221.64,-205.06 230.48,-216.84 233.71,-229.84"/>
+<polygon fill="red" stroke="red" points="230.27,-230.52 235,-240 237.22,-229.64 230.27,-230.52"/>
+<text text-anchor="middle" x="210.02" y="-198.72" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a15&#45;&gt;Con_12 -->
+<g id="edge9" class="edge">
+<title>Phi_a15&#45;&gt;Con_12</title>
+<path fill="none" stroke="black" d="M102.13,-194.02C91.07,-206.92 74.96,-225.71 62.35,-240.42"/>
+<polygon fill="black" stroke="black" points="59.61,-238.24 55.76,-248.11 64.93,-242.8 59.61,-238.24"/>
+<text text-anchor="middle" x="99.13" y="-196.62" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a15&#45;&gt;Con_13 -->
+<g id="edge10" class="edge">
+<title>Phi_a15&#45;&gt;Con_13</title>
+<path fill="none" stroke="black" d="M115,-196.4C115,-207.74 115,-222.77 115,-235.68"/>
+<polygon fill="black" stroke="black" points="111.5,-235.9 115,-245.9 118.5,-235.9 111.5,-235.9"/>
+<text text-anchor="middle" x="112" y="-199" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a15&#45;&gt;Region14 -->
+<g id="edge8" class="edge">
+<title>Phi_a15&#45;&gt;Region14</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M142.12,-178C144.58,-178 147.04,-178 149.5,-178"/>
+<polygon fill="black" stroke="black" points="149.61,-181.5 159.61,-178 149.61,-174.5 149.61,-181.5"/>
+<text text-anchor="middle" x="145.12" y="-171.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph3-false.gv b/docs/chapter06/06-graph3-false.gv
new file mode 100644
index 00000000..28f741fa
--- /dev/null
+++ b/docs/chapter06/06-graph3-false.gv
@@ -0,0 +1,35 @@
+digraph chapter06 {
+/*
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_30 [ label="#1" ];
+ Return31 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return31[taillabel=0 color=red];
+ Return31 -> Start2:p0[taillabel=0 color=red];
+ Return31 -> Con_30[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph3-false.svg b/docs/chapter06/06-graph3-false.svg
new file mode 100644
index 00000000..49b04f09
--- /dev/null
+++ b/docs/chapter06/06-graph3-false.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="178pt" height="248pt"
+ viewBox="0.00 0.00 178.00 248.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 244)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-244 174,-244 174,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-232 162,-232 162,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<polygon fill="none" stroke="black" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<text text-anchor="start" x="30.5" y="-203.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="24,-164 24,-195 74,-195 74,-164 24,-164"/>
+<polygon fill="yellow" stroke="transparent" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<polygon fill="none" stroke="black" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<text text-anchor="start" x="32" y="-175.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="112,-52 58,-52 58,-16 112,-16 112,-52"/>
+<text text-anchor="middle" x="85" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return31 -->
+<g id="node4" class="node">
+<title>Return31</title>
+<polygon fill="yellow" stroke="black" points="118,-124 52,-124 52,-88 118,-88 118,-124"/>
+<text text-anchor="middle" x="85" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return31 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return31</title>
+<path fill="none" stroke="red" d="M85,-52.3C85,-60.02 85,-69.29 85,-77.89"/>
+<polygon fill="red" stroke="red" points="81.5,-77.9 85,-87.9 88.5,-77.9 81.5,-77.9"/>
+<text text-anchor="middle" x="82" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_30 -->
+<g id="node3" class="node">
+<title>Con_30</title>
+<ellipse fill="none" stroke="black" cx="127" cy="-192" rx="27" ry="18"/>
+<text text-anchor="middle" x="127" y="-188.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- Return31&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>Return31&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M68.26,-124.13C60.77,-133.26 52.99,-145.23 50.13,-158.06"/>
+<polygon fill="red" stroke="red" points="46.66,-157.67 49,-168 53.61,-158.46 46.66,-157.67"/>
+<text text-anchor="middle" x="65.26" y="-126.73" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return31&#45;&gt;Con_30 -->
+<g id="edge3" class="edge">
+<title>Return31&#45;&gt;Con_30</title>
+<path fill="none" stroke="black" d="M93.7,-124.4C99.66,-136.31 107.65,-152.3 114.31,-165.62"/>
+<polygon fill="black" stroke="black" points="111.28,-167.38 118.88,-174.76 117.54,-164.25 111.28,-167.38"/>
+<text text-anchor="middle" x="90.7" y="-127" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph3-nonconst-peephole.gv b/docs/chapter06/06-graph3-nonconst-peephole.gv
new file mode 100644
index 00000000..f8e3e5fa
--- /dev/null
+++ b/docs/chapter06/06-graph3-nonconst-peephole.gv
@@ -0,0 +1,56 @@
+digraph chapter06 {
+/*
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Region22 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ If8 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_27 [ label="#4" ];
+ Con_29 [ label="#1" ];
+ Phi_ab30 [ style=filled fillcolor=lightyellow label="&phi;_ab" ];
+ Return31 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region22;Phi_ab30;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return31[taillabel=0 color=red];
+ Region22 -> If8:p0[taillabel=1 color=red];
+ Region22 -> If8:p1[taillabel=2 color=red];
+ If8 -> Start2:p0[taillabel=0 color=red];
+ If8 -> Start2:p1[taillabel=1];
+ Phi_ab30 -> Region22 [style=dotted taillabel=0];
+ Phi_ab30 -> Con_27[taillabel=1];
+ Phi_ab30 -> Con_29[taillabel=2];
+ Return31 -> Region22[taillabel=0 color=red];
+ Return31 -> Phi_ab30[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph3-nonconst-peephole.svg b/docs/chapter06/06-graph3-nonconst-peephole.svg
new file mode 100644
index 00000000..c312ffc5
--- /dev/null
+++ b/docs/chapter06/06-graph3-nonconst-peephole.svg
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="294pt" height="420pt"
+ viewBox="0.00 0.00 294.00 420.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 416)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-416 290,-416 290,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-404 278,-404 278,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="168,-367 168,-392 249,-392 249,-367 168,-367"/>
+<polygon fill="none" stroke="black" points="168,-367 168,-392 249,-392 249,-367 168,-367"/>
+<text text-anchor="start" x="190" y="-375.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="168,-336 168,-367 249,-367 249,-336 168,-336"/>
+<polygon fill="yellow" stroke="transparent" points="173,-341 173,-362 213,-362 213,-341 173,-341"/>
+<polygon fill="none" stroke="black" points="173,-341 173,-362 213,-362 213,-341 173,-341"/>
+<text text-anchor="start" x="176" y="-347.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="213,-341 213,-362 244,-362 244,-341 213,-341"/>
+<text text-anchor="start" x="216" y="-347.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="180,-52 126,-52 126,-16 180,-16 180,-52"/>
+<text text-anchor="middle" x="153" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return31 -->
+<g id="node8" class="node">
+<title>Return31</title>
+<polygon fill="yellow" stroke="black" points="186,-124 120,-124 120,-88 186,-88 186,-124"/>
+<text text-anchor="middle" x="153" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return31 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return31</title>
+<path fill="none" stroke="red" d="M153,-52.3C153,-60.02 153,-69.29 153,-77.89"/>
+<polygon fill="red" stroke="red" points="149.5,-77.9 153,-87.9 156.5,-77.9 149.5,-77.9"/>
+<text text-anchor="middle" x="150" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Region22 -->
+<g id="node3" class="node">
+<title>Region22</title>
+<polygon fill="yellow" stroke="black" points="228,-196 162,-196 162,-160 228,-160 228,-196"/>
+<text text-anchor="middle" x="195" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- If8 -->
+<g id="node4" class="node">
+<title>If8</title>
+<polygon fill="yellow" stroke="transparent" points="168,-267 168,-292 262,-292 262,-267 168,-267"/>
+<polygon fill="none" stroke="black" points="168,-267 168,-292 262,-292 262,-267 168,-267"/>
+<text text-anchor="start" x="209.5" y="-275.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="168,-236 168,-267 262,-267 262,-236 168,-236"/>
+<polygon fill="yellow" stroke="transparent" points="173,-241 173,-262 213,-262 213,-241 173,-241"/>
+<polygon fill="none" stroke="black" points="173,-241 173,-262 213,-262 213,-241 173,-241"/>
+<text text-anchor="start" x="176" y="-247.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="213,-241 213,-262 257,-262 257,-241 213,-241"/>
+<polygon fill="none" stroke="black" points="213,-241 213,-262 257,-262 257,-241 213,-241"/>
+<text text-anchor="start" x="216" y="-247.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- Region22&#45;&gt;If8 -->
+<g id="edge2" class="edge">
+<title>Region22&#45;&gt;If8:p0</title>
+<path fill="none" stroke="red" d="M194.14,-196.09C193.72,-205.54 193.27,-217.77 193.08,-229.68"/>
+<polygon fill="red" stroke="red" points="189.58,-229.97 193,-240 196.58,-230.03 189.58,-229.97"/>
+<text text-anchor="middle" x="191.14" y="-198.69" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region22&#45;&gt;If8 -->
+<g id="edge3" class="edge">
+<title>Region22&#45;&gt;If8:p1</title>
+<path fill="none" stroke="red" d="M213.83,-196.05C222.1,-205.05 230.63,-216.92 233.76,-229.89"/>
+<polygon fill="red" stroke="red" points="230.31,-230.5 235,-240 237.25,-229.65 230.31,-230.5"/>
+<text text-anchor="middle" x="210.83" y="-198.65" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If8&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>If8&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M201.57,-296.16C198.03,-306.41 194.84,-318.18 193.57,-329.83"/>
+<polygon fill="red" stroke="red" points="190.07,-329.82 193,-340 197.06,-330.21 190.07,-329.82"/>
+<text text-anchor="middle" x="198.57" y="-298.76" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If8&#45;&gt;Start2 -->
+<g id="edge5" class="edge">
+<title>If8&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M223.47,-296.14C225.75,-306.5 227.81,-318.36 228.63,-329.94"/>
+<polygon fill="black" stroke="black" points="225.13,-330.14 229,-340 232.13,-329.88 225.13,-330.14"/>
+<text text-anchor="middle" x="220.47" y="-298.74" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_27 -->
+<g id="node5" class="node">
+<title>Con_27</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-260.3" font-family="Times,serif" font-size="14.00">#4</text>
+</g>
+<!-- Con_29 -->
+<g id="node6" class="node">
+<title>Con_29</title>
+<ellipse fill="none" stroke="black" cx="115" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-260.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- Phi_ab30 -->
+<g id="node7" class="node">
+<title>Phi_ab30</title>
+<ellipse fill="lightyellow" stroke="black" cx="112" cy="-178" rx="32.49" ry="18"/>
+<text text-anchor="middle" x="112" y="-174.3" font-family="Times,serif" font-size="14.00">φ_ab</text>
+</g>
+<!-- Phi_ab30&#45;&gt;Region22 -->
+<g id="edge6" class="edge">
+<title>Phi_ab30&#45;&gt;Region22</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M144.75,-178C147.03,-178 149.32,-178 151.6,-178"/>
+<polygon fill="black" stroke="black" points="151.63,-181.5 161.63,-178 151.63,-174.5 151.63,-181.5"/>
+<text text-anchor="middle" x="147.75" y="-171.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Phi_ab30&#45;&gt;Con_27 -->
+<g id="edge7" class="edge">
+<title>Phi_ab30&#45;&gt;Con_27</title>
+<path fill="none" stroke="black" d="M99.02,-194.8C88.58,-207.51 73.76,-225.56 61.98,-239.89"/>
+<polygon fill="black" stroke="black" points="59.1,-237.89 55.46,-247.84 64.51,-242.33 59.1,-237.89"/>
+<text text-anchor="middle" x="96.02" y="-197.4" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_ab30&#45;&gt;Con_29 -->
+<g id="edge8" class="edge">
+<title>Phi_ab30&#45;&gt;Con_29</title>
+<path fill="none" stroke="black" d="M112.61,-196C113.01,-207.31 113.55,-222.42 114.02,-235.43"/>
+<polygon fill="black" stroke="black" points="110.53,-235.87 114.38,-245.74 117.52,-235.62 110.53,-235.87"/>
+<text text-anchor="middle" x="109.61" y="-198.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Return31&#45;&gt;Region22 -->
+<g id="edge9" class="edge">
+<title>Return31&#45;&gt;Region22</title>
+<path fill="none" stroke="red" d="M163.38,-124.3C168.26,-132.44 174.19,-142.31 179.58,-151.3"/>
+<polygon fill="red" stroke="red" points="176.59,-153.12 184.74,-159.9 182.59,-149.52 176.59,-153.12"/>
+<text text-anchor="middle" x="160.38" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return31&#45;&gt;Phi_ab30 -->
+<g id="edge10" class="edge">
+<title>Return31&#45;&gt;Phi_ab30</title>
+<path fill="none" stroke="black" d="M142.87,-124.3C138.03,-132.56 132.15,-142.61 126.82,-151.7"/>
+<polygon fill="black" stroke="black" points="123.77,-149.98 121.74,-160.38 129.81,-153.52 123.77,-149.98"/>
+<text text-anchor="middle" x="139.87" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph3-nonconst.gv b/docs/chapter06/06-graph3-nonconst.gv
new file mode 100644
index 00000000..7cd4e8e2
--- /dev/null
+++ b/docs/chapter06/06-graph3-nonconst.gv
@@ -0,0 +1,86 @@
+digraph chapter06 {
+/*
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_6 [ label="#0" ];
+ Con_7 [ label="#1" ];
+ If8 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_12 [ label="#2" ];
+ If13 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_17 [ label="#2" ];
+ Con_18 [ label="#3" ];
+ Region19 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_b20 [ style=filled fillcolor=lightyellow label="&phi;_b" ];
+ Region21 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a22 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ Phi_b23 [ style=filled fillcolor=lightyellow label="&phi;_b" ];
+ Add24 [ label="+" ];
+ Return25 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region19;Phi_b20;}
+ { rank=same; Region21;Phi_b23;Phi_a22;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return25[taillabel=0 color=red];
+ If8 -> Start2:p0[taillabel=0 color=red];
+ If8 -> Start2:p1[taillabel=1];
+ If13 -> If8:p0[taillabel=0 color=red];
+ If13 -> Start2:p1[taillabel=1];
+ Region19 -> If13:p0[taillabel=1 color=red];
+ Region19 -> If13:p1[taillabel=2 color=red];
+ Phi_b20 -> Region19 [style=dotted taillabel=0];
+ Phi_b20 -> Con_17[taillabel=1];
+ Phi_b20 -> Con_18[taillabel=2];
+ Region21 -> Region19[taillabel=1 color=red];
+ Region21 -> If8:p1[taillabel=2 color=red];
+ Phi_a22 -> Region21 [style=dotted taillabel=0];
+ Phi_a22 -> Con_12[taillabel=1];
+ Phi_a22 -> Con_6[taillabel=2];
+ Phi_b23 -> Region21 [style=dotted taillabel=0];
+ Phi_b23 -> Phi_b20[taillabel=1];
+ Phi_b23 -> Con_7[taillabel=2];
+ Add24 -> Phi_b23[taillabel=1];
+ Add24 -> Phi_a22[taillabel=2];
+ Return25 -> Region21[taillabel=0 color=red];
+ Return25 -> Add24[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph3-nonconst.svg b/docs/chapter06/06-graph3-nonconst.svg
new file mode 100644
index 00000000..dee852e4
--- /dev/null
+++ b/docs/chapter06/06-graph3-nonconst.svg
@@ -0,0 +1,290 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="414pt" height="664pt"
+ viewBox="0.00 0.00 414.00 664.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 660)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-660 410,-660 410,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-648 398,-648 398,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="274,-611 274,-636 355,-636 355,-611 274,-611"/>
+<polygon fill="none" stroke="black" points="274,-611 274,-636 355,-636 355,-611 274,-611"/>
+<text text-anchor="start" x="296" y="-619.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="274,-580 274,-611 355,-611 355,-580 274,-580"/>
+<polygon fill="yellow" stroke="transparent" points="279,-585 279,-606 319,-606 319,-585 279,-585"/>
+<polygon fill="none" stroke="black" points="279,-585 279,-606 319,-606 319,-585 279,-585"/>
+<text text-anchor="start" x="282" y="-591.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="319,-585 319,-606 350,-606 350,-585 319,-585"/>
+<text text-anchor="start" x="322" y="-591.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="299,-52 245,-52 245,-16 299,-16 299,-52"/>
+<text text-anchor="middle" x="272" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return25 -->
+<g id="node16" class="node">
+<title>Return25</title>
+<polygon fill="yellow" stroke="black" points="305,-124 239,-124 239,-88 305,-88 305,-124"/>
+<text text-anchor="middle" x="272" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return25 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return25</title>
+<path fill="none" stroke="red" d="M272,-52.3C272,-60.02 272,-69.29 272,-77.89"/>
+<polygon fill="red" stroke="red" points="268.5,-77.9 272,-87.9 275.5,-77.9 268.5,-77.9"/>
+<text text-anchor="middle" x="269" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_6 -->
+<g id="node3" class="node">
+<title>Con_6</title>
+<ellipse fill="none" stroke="black" cx="259" cy="-322" rx="27" ry="18"/>
+<text text-anchor="middle" x="259" y="-318.3" font-family="Times,serif" font-size="14.00">#0</text>
+</g>
+<!-- Con_7 -->
+<g id="node4" class="node">
+<title>Con_7</title>
+<ellipse fill="none" stroke="black" cx="115" cy="-322" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-318.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- If8 -->
+<g id="node5" class="node">
+<title>If8</title>
+<polygon fill="yellow" stroke="transparent" points="288,-511 288,-536 382,-536 382,-511 288,-511"/>
+<polygon fill="none" stroke="black" points="288,-511 288,-536 382,-536 382,-511 288,-511"/>
+<text text-anchor="start" x="329.5" y="-519.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="288,-480 288,-511 382,-511 382,-480 288,-480"/>
+<polygon fill="yellow" stroke="transparent" points="293,-485 293,-506 333,-506 333,-485 293,-485"/>
+<polygon fill="none" stroke="black" points="293,-485 293,-506 333,-506 333,-485 293,-485"/>
+<text text-anchor="start" x="296" y="-491.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="333,-485 333,-506 377,-506 377,-485 333,-485"/>
+<polygon fill="none" stroke="black" points="333,-485 333,-506 377,-506 377,-485 333,-485"/>
+<text text-anchor="start" x="336" y="-491.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If8&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>If8&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M312.41,-540.3C306.75,-550.38 301.75,-562.04 299.83,-573.96"/>
+<polygon fill="red" stroke="red" points="296.34,-573.75 299,-584 303.31,-574.32 296.34,-573.75"/>
+<text text-anchor="middle" x="309.41" y="-542.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If8&#45;&gt;Start2 -->
+<g id="edge3" class="edge">
+<title>If8&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M335,-540.02C335,-550.47 335,-562.42 335,-573.98"/>
+<polygon fill="black" stroke="black" points="331.5,-574 335,-584 338.5,-574 331.5,-574"/>
+<text text-anchor="middle" x="332" y="-542.62" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_12 -->
+<g id="node6" class="node">
+<title>Con_12</title>
+<ellipse fill="none" stroke="black" cx="187" cy="-322" rx="27" ry="18"/>
+<text text-anchor="middle" x="187" y="-318.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- If13 -->
+<g id="node7" class="node">
+<title>If13</title>
+<polygon fill="yellow" stroke="transparent" points="267,-411 267,-436 361,-436 361,-411 267,-411"/>
+<polygon fill="none" stroke="black" points="267,-411 267,-436 361,-436 361,-411 267,-411"/>
+<text text-anchor="start" x="308.5" y="-419.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="267,-380 267,-411 361,-411 361,-380 267,-380"/>
+<polygon fill="yellow" stroke="transparent" points="272,-385 272,-406 312,-406 312,-385 272,-385"/>
+<polygon fill="none" stroke="black" points="272,-385 272,-406 312,-406 312,-385 272,-385"/>
+<text text-anchor="start" x="275" y="-391.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="312,-385 312,-406 356,-406 356,-385 312,-385"/>
+<polygon fill="none" stroke="black" points="312,-385 312,-406 356,-406 356,-385 312,-385"/>
+<text text-anchor="start" x="315" y="-391.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If13&#45;&gt;Start2 -->
+<g id="edge5" class="edge">
+<title>If13&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M288.75,-440.22C281.57,-450.93 274.7,-463.4 271,-476 262.99,-503.29 257.76,-514.83 271,-540 285.19,-566.97 324.2,-553.71 333.15,-573.98"/>
+<polygon fill="black" stroke="black" points="329.75,-574.8 335,-584 336.63,-573.53 329.75,-574.8"/>
+<text text-anchor="middle" x="285.75" y="-442.82" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- If13&#45;&gt;If8 -->
+<g id="edge4" class="edge">
+<title>If13&#45;&gt;If8:p0</title>
+<path fill="none" stroke="red" d="M313.4,-440.02C313.24,-450.46 313.09,-462.42 313.03,-473.98"/>
+<polygon fill="red" stroke="red" points="309.53,-473.99 313,-484 316.53,-474.01 309.53,-473.99"/>
+<text text-anchor="middle" x="310.4" y="-442.62" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_17 -->
+<g id="node8" class="node">
+<title>Con_17</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-408" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-404.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Con_18 -->
+<g id="node9" class="node">
+<title>Con_18</title>
+<ellipse fill="none" stroke="black" cx="115" cy="-408" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-404.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Region19 -->
+<g id="node10" class="node">
+<title>Region19</title>
+<polygon fill="yellow" stroke="black" points="370,-340 304,-340 304,-304 370,-304 370,-340"/>
+<text text-anchor="middle" x="337" y="-318.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region19&#45;&gt;If13 -->
+<g id="edge6" class="edge">
+<title>Region19&#45;&gt;If13:p0</title>
+<path fill="none" stroke="red" d="M315.29,-340.1C306.12,-348.94 296.78,-360.62 293.36,-373.72"/>
+<polygon fill="red" stroke="red" points="289.84,-373.63 292,-384 296.78,-374.54 289.84,-373.63"/>
+<text text-anchor="middle" x="312.29" y="-342.7" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region19&#45;&gt;If13 -->
+<g id="edge7" class="edge">
+<title>Region19&#45;&gt;If13:p1</title>
+<path fill="none" stroke="red" d="M335.71,-340.08C335.08,-349.53 334.4,-361.76 334.13,-373.68"/>
+<polygon fill="red" stroke="red" points="330.62,-373.96 334,-384 337.62,-374.04 330.62,-373.96"/>
+<text text-anchor="middle" x="332.71" y="-342.68" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_b20 -->
+<g id="node11" class="node">
+<title>Phi_b20</title>
+<ellipse fill="lightyellow" stroke="black" cx="43" cy="-322" rx="27.1" ry="18"/>
+<text text-anchor="middle" x="43" y="-318.3" font-family="Times,serif" font-size="14.00">φ_b</text>
+</g>
+<!-- Phi_b20&#45;&gt;Con_17 -->
+<g id="edge9" class="edge">
+<title>Phi_b20&#45;&gt;Con_17</title>
+<path fill="none" stroke="black" d="M43,-340.4C43,-351.74 43,-366.77 43,-379.68"/>
+<polygon fill="black" stroke="black" points="39.5,-379.9 43,-389.9 46.5,-379.9 39.5,-379.9"/>
+<text text-anchor="middle" x="40" y="-343" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_b20&#45;&gt;Con_18 -->
+<g id="edge10" class="edge">
+<title>Phi_b20&#45;&gt;Con_18</title>
+<path fill="none" stroke="black" d="M55.87,-338.02C66.93,-350.92 83.04,-369.71 95.65,-384.42"/>
+<polygon fill="black" stroke="black" points="93.07,-386.8 102.24,-392.11 98.39,-382.24 93.07,-386.8"/>
+<text text-anchor="middle" x="52.87" y="-340.62" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_b20&#45;&gt;Region19 -->
+<g id="edge8" class="edge">
+<title>Phi_b20&#45;&gt;Region19</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M57.22,-306.43C65.37,-298.68 76.29,-290.11 88,-286 129.52,-271.44 244.06,-272.69 286,-286 293.99,-288.54 301.81,-292.83 308.83,-297.58"/>
+<polygon fill="black" stroke="black" points="307.11,-300.66 317.24,-303.75 311.25,-295.01 307.11,-300.66"/>
+<text text-anchor="middle" x="54.22" y="-300.03" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Region21 -->
+<g id="node12" class="node">
+<title>Region21</title>
+<polygon fill="yellow" stroke="black" points="352,-268 286,-268 286,-232 352,-232 352,-268"/>
+<text text-anchor="middle" x="319" y="-246.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region21&#45;&gt;If8 -->
+<g id="edge12" class="edge">
+<title>Region21&#45;&gt;If8:p1</title>
+<path fill="none" stroke="red" d="M347.26,-268.03C359.43,-277.04 372.37,-289.3 379,-304 385.58,-318.6 394.79,-373.07 378,-440 373.59,-457.56 360.94,-461.07 356.53,-473.94"/>
+<polygon fill="red" stroke="red" points="353.05,-473.59 355,-484 359.97,-474.64 353.05,-473.59"/>
+<text text-anchor="middle" x="344.26" y="-270.63" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Region21&#45;&gt;Region19 -->
+<g id="edge11" class="edge">
+<title>Region21&#45;&gt;Region19</title>
+<path fill="none" stroke="red" d="M323.45,-268.3C325.45,-276.1 327.87,-285.49 330.1,-294.17"/>
+<polygon fill="red" stroke="red" points="326.72,-295.08 332.6,-303.9 333.5,-293.34 326.72,-295.08"/>
+<text text-anchor="middle" x="320.45" y="-270.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a22 -->
+<g id="node13" class="node">
+<title>Phi_a22</title>
+<ellipse fill="lightyellow" stroke="black" cx="241" cy="-250" rx="27" ry="18"/>
+<text text-anchor="middle" x="241" y="-246.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Phi_a22&#45;&gt;Con_6 -->
+<g id="edge15" class="edge">
+<title>Phi_a22&#45;&gt;Con_6</title>
+<path fill="none" stroke="black" d="M245.36,-267.95C247.39,-275.86 249.86,-285.46 252.14,-294.31"/>
+<polygon fill="black" stroke="black" points="248.8,-295.4 254.68,-304.21 255.58,-293.65 248.8,-295.4"/>
+<text text-anchor="middle" x="242.36" y="-270.55" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a22&#45;&gt;Con_12 -->
+<g id="edge14" class="edge">
+<title>Phi_a22&#45;&gt;Con_12</title>
+<path fill="none" stroke="black" d="M229.02,-266.54C222.02,-275.6 213.06,-287.21 205.21,-297.39"/>
+<polygon fill="black" stroke="black" points="202.29,-295.45 198.95,-305.51 207.83,-299.73 202.29,-295.45"/>
+<text text-anchor="middle" x="226.02" y="-269.14" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a22&#45;&gt;Region21 -->
+<g id="edge13" class="edge">
+<title>Phi_a22&#45;&gt;Region21</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M268.12,-250C270.58,-250 273.04,-250 275.5,-250"/>
+<polygon fill="black" stroke="black" points="275.61,-253.5 285.61,-250 275.61,-246.5 275.61,-253.5"/>
+<text text-anchor="middle" x="271.12" y="-243.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Phi_b23 -->
+<g id="node14" class="node">
+<title>Phi_b23</title>
+<ellipse fill="lightyellow" stroke="black" cx="133" cy="-250" rx="27.1" ry="18"/>
+<text text-anchor="middle" x="133" y="-246.3" font-family="Times,serif" font-size="14.00">φ_b</text>
+</g>
+<!-- Phi_b23&#45;&gt;Con_7 -->
+<g id="edge18" class="edge">
+<title>Phi_b23&#45;&gt;Con_7</title>
+<path fill="none" stroke="black" d="M128.64,-267.95C126.61,-275.86 124.14,-285.46 121.86,-294.31"/>
+<polygon fill="black" stroke="black" points="118.42,-293.65 119.32,-304.21 125.2,-295.4 118.42,-293.65"/>
+<text text-anchor="middle" x="125.64" y="-270.55" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_b23&#45;&gt;Phi_b20 -->
+<g id="edge17" class="edge">
+<title>Phi_b23&#45;&gt;Phi_b20</title>
+<path fill="none" stroke="black" d="M116.07,-264.17C102.58,-274.66 83.49,-289.51 68.2,-301.4"/>
+<polygon fill="black" stroke="black" points="65.9,-298.75 60.16,-307.65 70.2,-304.28 65.9,-298.75"/>
+<text text-anchor="middle" x="113.07" y="-266.77" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_b23&#45;&gt;Region21 -->
+<g id="edge16" class="edge">
+<title>Phi_b23&#45;&gt;Region21</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M152.84,-237.61C179.31,-222.7 227.54,-201.16 268,-214 275.99,-216.54 283.81,-220.83 290.83,-225.58"/>
+<polygon fill="black" stroke="black" points="289.11,-228.66 299.24,-231.75 293.25,-223.01 289.11,-228.66"/>
+<text text-anchor="middle" x="149.84" y="-231.21" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Add24 -->
+<g id="node15" class="node">
+<title>Add24</title>
+<ellipse fill="none" stroke="black" cx="241" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="241" y="-174.3" font-family="Times,serif" font-size="14.00">+</text>
+</g>
+<!-- Add24&#45;&gt;Phi_a22 -->
+<g id="edge20" class="edge">
+<title>Add24&#45;&gt;Phi_a22</title>
+<path fill="none" stroke="black" d="M241,-196.3C241,-204.02 241,-213.29 241,-221.89"/>
+<polygon fill="black" stroke="black" points="237.5,-221.9 241,-231.9 244.5,-221.9 237.5,-221.9"/>
+<text text-anchor="middle" x="238" y="-198.9" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Add24&#45;&gt;Phi_b23 -->
+<g id="edge19" class="edge">
+<title>Add24&#45;&gt;Phi_b23</title>
+<path fill="none" stroke="black" d="M222.19,-191.19C205.1,-202.27 179.69,-218.74 160.36,-231.27"/>
+<polygon fill="black" stroke="black" points="158.45,-228.34 151.96,-236.71 162.25,-234.21 158.45,-228.34"/>
+<text text-anchor="middle" x="219.19" y="-193.79" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Return25&#45;&gt;Region21 -->
+<g id="edge21" class="edge">
+<title>Return25&#45;&gt;Region21</title>
+<path fill="none" stroke="red" d="M277.67,-124.13C285.71,-148.44 300.52,-193.18 310.06,-221.99"/>
+<polygon fill="red" stroke="red" points="306.85,-223.42 313.31,-231.81 313.49,-221.22 306.85,-223.42"/>
+<text text-anchor="middle" x="274.67" y="-126.73" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return25&#45;&gt;Add24 -->
+<g id="edge22" class="edge">
+<title>Return25&#45;&gt;Add24</title>
+<path fill="none" stroke="black" d="M264.34,-124.3C260.76,-132.39 256.42,-142.19 252.46,-151.13"/>
+<polygon fill="black" stroke="black" points="249.21,-149.82 248.36,-160.38 255.61,-152.65 249.21,-149.82"/>
+<text text-anchor="middle" x="261.34" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph3-true.gv b/docs/chapter06/06-graph3-true.gv
new file mode 100644
index 00000000..9739169c
--- /dev/null
+++ b/docs/chapter06/06-graph3-true.gv
@@ -0,0 +1,35 @@
+digraph chapter06 {
+/*
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_28 [ label="#4" ];
+ Return29 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return29[taillabel=0 color=red];
+ Return29 -> Start2:p0[taillabel=0 color=red];
+ Return29 -> Con_28[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph3-true.svg b/docs/chapter06/06-graph3-true.svg
new file mode 100644
index 00000000..7e573cc6
--- /dev/null
+++ b/docs/chapter06/06-graph3-true.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="178pt" height="248pt"
+ viewBox="0.00 0.00 178.00 248.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 244)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-244 174,-244 174,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-232 162,-232 162,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<polygon fill="none" stroke="black" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<text text-anchor="start" x="30.5" y="-203.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="24,-164 24,-195 74,-195 74,-164 24,-164"/>
+<polygon fill="yellow" stroke="transparent" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<polygon fill="none" stroke="black" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<text text-anchor="start" x="32" y="-175.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="112,-52 58,-52 58,-16 112,-16 112,-52"/>
+<text text-anchor="middle" x="85" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return29 -->
+<g id="node4" class="node">
+<title>Return29</title>
+<polygon fill="yellow" stroke="black" points="118,-124 52,-124 52,-88 118,-88 118,-124"/>
+<text text-anchor="middle" x="85" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return29 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return29</title>
+<path fill="none" stroke="red" d="M85,-52.3C85,-60.02 85,-69.29 85,-77.89"/>
+<polygon fill="red" stroke="red" points="81.5,-77.9 85,-87.9 88.5,-77.9 81.5,-77.9"/>
+<text text-anchor="middle" x="82" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_28 -->
+<g id="node3" class="node">
+<title>Con_28</title>
+<ellipse fill="none" stroke="black" cx="127" cy="-192" rx="27" ry="18"/>
+<text text-anchor="middle" x="127" y="-188.3" font-family="Times,serif" font-size="14.00">#4</text>
+</g>
+<!-- Return29&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>Return29&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M68.26,-124.13C60.77,-133.26 52.99,-145.23 50.13,-158.06"/>
+<polygon fill="red" stroke="red" points="46.66,-157.67 49,-168 53.61,-158.46 46.66,-157.67"/>
+<text text-anchor="middle" x="65.26" y="-126.73" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return29&#45;&gt;Con_28 -->
+<g id="edge3" class="edge">
+<title>Return29&#45;&gt;Con_28</title>
+<path fill="none" stroke="black" d="M93.7,-124.4C99.66,-136.31 107.65,-152.3 114.31,-165.62"/>
+<polygon fill="black" stroke="black" points="111.28,-167.38 118.88,-174.76 117.54,-164.25 111.28,-167.38"/>
+<text text-anchor="middle" x="90.7" y="-127" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph4-arg2.gv b/docs/chapter06/06-graph4-arg2.gv
new file mode 100644
index 00000000..7d6913e2
--- /dev/null
+++ b/docs/chapter06/06-graph4-arg2.gv
@@ -0,0 +1,37 @@
+digraph chapter06 {
+/*
+int a = 0;
+int b = 1;
+int c = 0;
+if( arg ) {
+ a = 1;
+ if( arg==2 ) { c=2; } else { c=3; }
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b+c;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_44 [ label="#5" ];
+ Return45 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return45[taillabel=0 color=red];
+ Return45 -> Start2:p0[taillabel=0 color=red];
+ Return45 -> Con_44[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph4-arg2.svg b/docs/chapter06/06-graph4-arg2.svg
new file mode 100644
index 00000000..8ec80be4
--- /dev/null
+++ b/docs/chapter06/06-graph4-arg2.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="178pt" height="248pt"
+ viewBox="0.00 0.00 178.00 248.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 244)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-244 174,-244 174,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-232 162,-232 162,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<polygon fill="none" stroke="black" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<text text-anchor="start" x="30.5" y="-203.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="24,-164 24,-195 74,-195 74,-164 24,-164"/>
+<polygon fill="yellow" stroke="transparent" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<polygon fill="none" stroke="black" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<text text-anchor="start" x="32" y="-175.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="112,-52 58,-52 58,-16 112,-16 112,-52"/>
+<text text-anchor="middle" x="85" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return45 -->
+<g id="node4" class="node">
+<title>Return45</title>
+<polygon fill="yellow" stroke="black" points="118,-124 52,-124 52,-88 118,-88 118,-124"/>
+<text text-anchor="middle" x="85" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return45 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return45</title>
+<path fill="none" stroke="red" d="M85,-52.3C85,-60.02 85,-69.29 85,-77.89"/>
+<polygon fill="red" stroke="red" points="81.5,-77.9 85,-87.9 88.5,-77.9 81.5,-77.9"/>
+<text text-anchor="middle" x="82" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_44 -->
+<g id="node3" class="node">
+<title>Con_44</title>
+<ellipse fill="none" stroke="black" cx="127" cy="-192" rx="27" ry="18"/>
+<text text-anchor="middle" x="127" y="-188.3" font-family="Times,serif" font-size="14.00">#5</text>
+</g>
+<!-- Return45&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>Return45&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M68.26,-124.13C60.77,-133.26 52.99,-145.23 50.13,-158.06"/>
+<polygon fill="red" stroke="red" points="46.66,-157.67 49,-168 53.61,-158.46 46.66,-157.67"/>
+<text text-anchor="middle" x="65.26" y="-126.73" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return45&#45;&gt;Con_44 -->
+<g id="edge3" class="edge">
+<title>Return45&#45;&gt;Con_44</title>
+<path fill="none" stroke="black" d="M93.7,-124.4C99.66,-136.31 107.65,-152.3 114.31,-165.62"/>
+<polygon fill="black" stroke="black" points="111.28,-167.38 118.88,-174.76 117.54,-164.25 111.28,-167.38"/>
+<text text-anchor="middle" x="90.7" y="-127" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph4-nonconst.gv b/docs/chapter06/06-graph4-nonconst.gv
new file mode 100644
index 00000000..b8899b48
--- /dev/null
+++ b/docs/chapter06/06-graph4-nonconst.gv
@@ -0,0 +1,122 @@
+digraph chapter06 {
+/*
+int a = 0;
+int b = 1;
+int c = 0;
+if( arg ) {
+ a = 1;
+ if( arg==2 ) { c=2; } else { c=3; }
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b+c;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_6 [ label="#0" ];
+ Con_7 [ label="#1" ];
+ Con_8 [ label="#0" ];
+ If9 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_13 [ label="#1" ];
+ Con_14 [ label="#2" ];
+ EQNode15 [ label="==" ];
+ If16 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_20 [ label="#2" ];
+ Con_21 [ label="#3" ];
+ Region22 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_c23 [ style=filled fillcolor=lightyellow label="&phi;_c" ];
+ If24 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_28 [ label="#2" ];
+ Con_29 [ label="#3" ];
+ Region30 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_b31 [ style=filled fillcolor=lightyellow label="&phi;_b" ];
+ Region32 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a33 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ Phi_b34 [ style=filled fillcolor=lightyellow label="&phi;_b" ];
+ Phi_c35 [ style=filled fillcolor=lightyellow label="&phi;_c" ];
+ Add36 [ label="+" ];
+ Add37 [ label="+" ];
+ Return38 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region22;Phi_c23;}
+ { rank=same; Region30;Phi_b31;}
+ { rank=same; Region32;Phi_c35;Phi_a33;Phi_b34;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return38[taillabel=0 color=red];
+ If9 -> Start2:p0[taillabel=0 color=red];
+ If9 -> Start2:p1[taillabel=1];
+ EQNode15 -> Start2:p1[taillabel=1];
+ EQNode15 -> Con_14[taillabel=2];
+ If16 -> If9:p0[taillabel=0 color=red];
+ If16 -> EQNode15[taillabel=1];
+ Region22 -> If16:p0[taillabel=1 color=red];
+ Region22 -> If16:p1[taillabel=2 color=red];
+ Phi_c23 -> Region22 [style=dotted taillabel=0];
+ Phi_c23 -> Con_20[taillabel=1];
+ Phi_c23 -> Con_21[taillabel=2];
+ If24 -> Region22[taillabel=0 color=red];
+ If24 -> Start2:p1[taillabel=1];
+ Region30 -> If24:p0[taillabel=1 color=red];
+ Region30 -> If24:p1[taillabel=2 color=red];
+ Phi_b31 -> Region30 [style=dotted taillabel=0];
+ Phi_b31 -> Con_28[taillabel=1];
+ Phi_b31 -> Con_29[taillabel=2];
+ Region32 -> Region30[taillabel=1 color=red];
+ Region32 -> If9:p1[taillabel=2 color=red];
+ Phi_a33 -> Region32 [style=dotted taillabel=0];
+ Phi_a33 -> Con_13[taillabel=1];
+ Phi_a33 -> Con_6[taillabel=2];
+ Phi_b34 -> Region32 [style=dotted taillabel=0];
+ Phi_b34 -> Phi_b31[taillabel=1];
+ Phi_b34 -> Con_7[taillabel=2];
+ Phi_c35 -> Region32 [style=dotted taillabel=0];
+ Phi_c35 -> Phi_c23[taillabel=1];
+ Phi_c35 -> Con_8[taillabel=2];
+ Add36 -> Phi_c35[taillabel=1];
+ Add36 -> Phi_b34[taillabel=2];
+ Add37 -> Add36[taillabel=1];
+ Add37 -> Phi_a33[taillabel=2];
+ Return38 -> Region32[taillabel=0 color=red];
+ Return38 -> Add37[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph4-nonconst.svg b/docs/chapter06/06-graph4-nonconst.svg
new file mode 100644
index 00000000..d38c3636
--- /dev/null
+++ b/docs/chapter06/06-graph4-nonconst.svg
@@ -0,0 +1,456 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="506pt" height="908pt"
+ viewBox="0.00 0.00 506.00 908.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 904)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-904 502,-904 502,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-892 490,-892 490,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="266,-855 266,-880 347,-880 347,-855 266,-855"/>
+<polygon fill="none" stroke="black" points="266,-855 266,-880 347,-880 347,-855 266,-855"/>
+<text text-anchor="start" x="288" y="-863.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="266,-824 266,-855 347,-855 347,-824 266,-824"/>
+<polygon fill="yellow" stroke="transparent" points="271,-829 271,-850 311,-850 311,-829 271,-829"/>
+<polygon fill="none" stroke="black" points="271,-829 271,-850 311,-850 311,-829 271,-829"/>
+<text text-anchor="start" x="274" y="-835.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="311,-829 311,-850 342,-850 342,-829 311,-829"/>
+<text text-anchor="start" x="314" y="-835.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="329,-52 275,-52 275,-16 329,-16 329,-52"/>
+<text text-anchor="middle" x="302" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return38 -->
+<g id="node26" class="node">
+<title>Return38</title>
+<polygon fill="yellow" stroke="black" points="335,-124 269,-124 269,-88 335,-88 335,-124"/>
+<text text-anchor="middle" x="302" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return38 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return38</title>
+<path fill="none" stroke="red" d="M302,-52.3C302,-60.02 302,-69.29 302,-77.89"/>
+<polygon fill="red" stroke="red" points="298.5,-77.9 302,-87.9 305.5,-77.9 298.5,-77.9"/>
+<text text-anchor="middle" x="299" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_6 -->
+<g id="node3" class="node">
+<title>Con_6</title>
+<ellipse fill="none" stroke="black" cx="351" cy="-394" rx="27" ry="18"/>
+<text text-anchor="middle" x="351" y="-390.3" font-family="Times,serif" font-size="14.00">#0</text>
+</g>
+<!-- Con_7 -->
+<g id="node4" class="node">
+<title>Con_7</title>
+<ellipse fill="none" stroke="black" cx="207" cy="-394" rx="27" ry="18"/>
+<text text-anchor="middle" x="207" y="-390.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- Con_8 -->
+<g id="node5" class="node">
+<title>Con_8</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-394" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-390.3" font-family="Times,serif" font-size="14.00">#0</text>
+</g>
+<!-- If9 -->
+<g id="node6" class="node">
+<title>If9</title>
+<polygon fill="yellow" stroke="transparent" points="232,-755 232,-780 326,-780 326,-755 232,-755"/>
+<polygon fill="none" stroke="black" points="232,-755 232,-780 326,-780 326,-755 232,-755"/>
+<text text-anchor="start" x="273.5" y="-763.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="232,-724 232,-755 326,-755 326,-724 232,-724"/>
+<polygon fill="yellow" stroke="transparent" points="237,-729 237,-750 277,-750 277,-729 237,-729"/>
+<polygon fill="none" stroke="black" points="237,-729 237,-750 277,-750 277,-729 237,-729"/>
+<text text-anchor="start" x="240" y="-735.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="277,-729 277,-750 321,-750 321,-729 277,-729"/>
+<polygon fill="none" stroke="black" points="277,-729 277,-750 321,-750 321,-729 277,-729"/>
+<text text-anchor="start" x="280" y="-735.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If9&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>If9&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M286.26,-784.2C288.21,-794.57 289.98,-806.42 290.68,-817.97"/>
+<polygon fill="red" stroke="red" points="287.18,-818.12 291,-828 294.18,-817.89 287.18,-818.12"/>
+<text text-anchor="middle" x="283.26" y="-786.8" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If9&#45;&gt;Start2 -->
+<g id="edge3" class="edge">
+<title>If9&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M309.94,-784.28C317.27,-794.18 323.65,-805.76 326.02,-818.03"/>
+<polygon fill="black" stroke="black" points="322.54,-818.39 327,-828 329.51,-817.71 322.54,-818.39"/>
+<text text-anchor="middle" x="306.94" y="-786.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_13 -->
+<g id="node7" class="node">
+<title>Con_13</title>
+<ellipse fill="none" stroke="black" cx="279" cy="-394" rx="27" ry="18"/>
+<text text-anchor="middle" x="279" y="-390.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- Con_14 -->
+<g id="node8" class="node">
+<title>Con_14</title>
+<ellipse fill="none" stroke="black" cx="413" cy="-852" rx="27" ry="18"/>
+<text text-anchor="middle" x="413" y="-848.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- EQNode15 -->
+<g id="node9" class="node">
+<title>EQNode15</title>
+<ellipse fill="none" stroke="black" cx="413" cy="-752" rx="27" ry="18"/>
+<text text-anchor="middle" x="413" y="-748.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode15&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>EQNode15&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M403.94,-769.18C391.81,-790 369.82,-824.8 352.53,-835.66"/>
+<polygon fill="black" stroke="black" points="351.28,-832.39 343,-839 353.59,-838.99 351.28,-832.39"/>
+<text text-anchor="middle" x="400.94" y="-771.78" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode15&#45;&gt;Con_14 -->
+<g id="edge5" class="edge">
+<title>EQNode15&#45;&gt;Con_14</title>
+<path fill="none" stroke="black" d="M413,-770.07C413,-784.88 413,-806.57 413,-823.77"/>
+<polygon fill="black" stroke="black" points="409.5,-823.8 413,-833.8 416.5,-823.8 409.5,-823.8"/>
+<text text-anchor="middle" x="410" y="-772.67" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If16 -->
+<g id="node10" class="node">
+<title>If16</title>
+<polygon fill="yellow" stroke="transparent" points="380,-655 380,-680 474,-680 474,-655 380,-655"/>
+<polygon fill="none" stroke="black" points="380,-655 380,-680 474,-680 474,-655 380,-655"/>
+<text text-anchor="start" x="421.5" y="-663.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="380,-624 380,-655 474,-655 474,-624 380,-624"/>
+<polygon fill="yellow" stroke="transparent" points="385,-629 385,-650 425,-650 425,-629 385,-629"/>
+<polygon fill="none" stroke="black" points="385,-629 385,-650 425,-650 425,-629 385,-629"/>
+<text text-anchor="start" x="388" y="-635.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="425,-629 425,-650 469,-650 469,-629 425,-629"/>
+<polygon fill="none" stroke="black" points="425,-629 425,-650 469,-650 469,-629 425,-629"/>
+<text text-anchor="start" x="428" y="-635.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If16&#45;&gt;If9 -->
+<g id="edge6" class="edge">
+<title>If16&#45;&gt;If9:p0</title>
+<path fill="none" stroke="red" d="M371.81,-671.79C331.47,-686.19 280.89,-705.86 263.34,-719.58"/>
+<polygon fill="red" stroke="red" points="260.22,-717.91 257,-728 265.81,-722.12 260.22,-717.91"/>
+<text text-anchor="middle" x="368.81" y="-665.39" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If16&#45;&gt;EQNode15 -->
+<g id="edge7" class="edge">
+<title>If16&#45;&gt;EQNode15</title>
+<path fill="none" stroke="black" d="M422.57,-684.01C420.75,-696.76 418.66,-711.4 416.9,-723.73"/>
+<polygon fill="black" stroke="black" points="413.4,-723.48 415.45,-733.87 420.33,-724.47 413.4,-723.48"/>
+<text text-anchor="middle" x="419.57" y="-686.61" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_20 -->
+<g id="node11" class="node">
+<title>Con_20</title>
+<ellipse fill="none" stroke="black" cx="134" cy="-652" rx="27" ry="18"/>
+<text text-anchor="middle" x="134" y="-648.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Con_21 -->
+<g id="node12" class="node">
+<title>Con_21</title>
+<ellipse fill="none" stroke="black" cx="206" cy="-652" rx="27" ry="18"/>
+<text text-anchor="middle" x="206" y="-648.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Region22 -->
+<g id="node13" class="node">
+<title>Region22</title>
+<polygon fill="yellow" stroke="black" points="446,-584 380,-584 380,-548 446,-548 446,-584"/>
+<text text-anchor="middle" x="413" y="-562.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region22&#45;&gt;If16 -->
+<g id="edge8" class="edge">
+<title>Region22&#45;&gt;If16:p0</title>
+<path fill="none" stroke="red" d="M409.56,-584.01C407.87,-593.54 406.04,-605.9 405.32,-617.98"/>
+<polygon fill="red" stroke="red" points="401.82,-617.89 405,-628 408.81,-618.12 401.82,-617.89"/>
+<text text-anchor="middle" x="406.56" y="-586.61" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region22&#45;&gt;If16 -->
+<g id="edge9" class="edge">
+<title>Region22&#45;&gt;If16:p1</title>
+<path fill="none" stroke="red" d="M428.61,-584.03C435.66,-593.13 443.03,-605.06 445.83,-617.72"/>
+<polygon fill="red" stroke="red" points="442.39,-618.46 447,-628 449.35,-617.67 442.39,-618.46"/>
+<text text-anchor="middle" x="425.61" y="-586.63" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_c23 -->
+<g id="node14" class="node">
+<title>Phi_c23</title>
+<ellipse fill="lightyellow" stroke="black" cx="170" cy="-566" rx="27" ry="18"/>
+<text text-anchor="middle" x="170" y="-562.3" font-family="Times,serif" font-size="14.00">φ_c</text>
+</g>
+<!-- Phi_c23&#45;&gt;Con_20 -->
+<g id="edge11" class="edge">
+<title>Phi_c23&#45;&gt;Con_20</title>
+<path fill="none" stroke="black" d="M162.89,-583.6C157.81,-595.45 150.88,-611.62 145.08,-625.15"/>
+<polygon fill="black" stroke="black" points="141.82,-623.87 141.1,-634.44 148.25,-626.63 141.82,-623.87"/>
+<text text-anchor="middle" x="159.89" y="-586.2" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_c23&#45;&gt;Con_21 -->
+<g id="edge12" class="edge">
+<title>Phi_c23&#45;&gt;Con_21</title>
+<path fill="none" stroke="black" d="M177.11,-583.6C182.19,-595.45 189.12,-611.62 194.92,-625.15"/>
+<polygon fill="black" stroke="black" points="191.75,-626.63 198.9,-634.44 198.18,-623.87 191.75,-626.63"/>
+<text text-anchor="middle" x="174.11" y="-586.2" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_c23&#45;&gt;Region22 -->
+<g id="edge10" class="edge">
+<title>Phi_c23&#45;&gt;Region22</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M197.05,-566C254.48,-566 311.91,-566 369.34,-566"/>
+<polygon fill="black" stroke="black" points="369.68,-569.5 379.68,-566 369.68,-562.5 369.68,-569.5"/>
+<text text-anchor="middle" x="200.05" y="-559.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If24 -->
+<g id="node15" class="node">
+<title>If24</title>
+<polygon fill="yellow" stroke="transparent" points="375,-483 375,-508 469,-508 469,-483 375,-483"/>
+<polygon fill="none" stroke="black" points="375,-483 375,-508 469,-508 469,-483 375,-483"/>
+<text text-anchor="start" x="416.5" y="-491.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="375,-452 375,-483 469,-483 469,-452 375,-452"/>
+<polygon fill="yellow" stroke="transparent" points="380,-457 380,-478 420,-478 420,-457 380,-457"/>
+<polygon fill="none" stroke="black" points="380,-457 380,-478 420,-478 420,-457 380,-457"/>
+<text text-anchor="start" x="383" y="-463.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="420,-457 420,-478 464,-478 464,-457 420,-457"/>
+<polygon fill="none" stroke="black" points="420,-457 420,-478 464,-478 464,-457 420,-457"/>
+<text text-anchor="start" x="423" y="-463.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If24&#45;&gt;Start2 -->
+<g id="edge14" class="edge">
+<title>If24&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M392.77,-512.23C384.4,-522.84 376.15,-535.26 371,-548 331.39,-645.92 367.43,-681.24 343,-784 339.09,-800.45 330.97,-805.48 328.06,-817.95"/>
+<polygon fill="black" stroke="black" points="324.57,-817.69 327,-828 331.53,-818.42 324.57,-817.69"/>
+<text text-anchor="middle" x="389.77" y="-514.83" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- If24&#45;&gt;Region22 -->
+<g id="edge13" class="edge">
+<title>If24&#45;&gt;Region22</title>
+<path fill="none" stroke="red" d="M418.65,-512.28C417.76,-520.58 416.81,-529.48 415.94,-537.56"/>
+<polygon fill="red" stroke="red" points="412.45,-537.28 414.86,-547.6 419.41,-538.02 412.45,-537.28"/>
+<text text-anchor="middle" x="415.65" y="-514.88" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_28 -->
+<g id="node16" class="node">
+<title>Con_28</title>
+<ellipse fill="none" stroke="black" cx="135" cy="-480" rx="27" ry="18"/>
+<text text-anchor="middle" x="135" y="-476.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Con_29 -->
+<g id="node17" class="node">
+<title>Con_29</title>
+<ellipse fill="none" stroke="black" cx="207" cy="-480" rx="27" ry="18"/>
+<text text-anchor="middle" x="207" y="-476.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Region30 -->
+<g id="node18" class="node">
+<title>Region30</title>
+<polygon fill="yellow" stroke="black" points="482,-412 416,-412 416,-376 482,-376 482,-412"/>
+<text text-anchor="middle" x="449" y="-390.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region30&#45;&gt;If24 -->
+<g id="edge15" class="edge">
+<title>Region30&#45;&gt;If24:p0</title>
+<path fill="none" stroke="red" d="M424.79,-412.2C414.85,-420.99 404.86,-432.65 401.33,-446"/>
+<polygon fill="red" stroke="red" points="397.85,-445.63 400,-456 404.79,-446.55 397.85,-445.63"/>
+<text text-anchor="middle" x="421.79" y="-414.8" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region30&#45;&gt;If24 -->
+<g id="edge16" class="edge">
+<title>Region30&#45;&gt;If24:p1</title>
+<path fill="none" stroke="red" d="M445.99,-412.03C444.51,-421.56 442.91,-433.93 442.28,-446"/>
+<polygon fill="red" stroke="red" points="438.78,-445.91 442,-456 445.78,-446.1 438.78,-445.91"/>
+<text text-anchor="middle" x="442.99" y="-414.63" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_b31 -->
+<g id="node19" class="node">
+<title>Phi_b31</title>
+<ellipse fill="lightyellow" stroke="black" cx="135" cy="-394" rx="27.1" ry="18"/>
+<text text-anchor="middle" x="135" y="-390.3" font-family="Times,serif" font-size="14.00">φ_b</text>
+</g>
+<!-- Phi_b31&#45;&gt;Con_28 -->
+<g id="edge18" class="edge">
+<title>Phi_b31&#45;&gt;Con_28</title>
+<path fill="none" stroke="black" d="M135,-412.4C135,-423.74 135,-438.77 135,-451.68"/>
+<polygon fill="black" stroke="black" points="131.5,-451.9 135,-461.9 138.5,-451.9 131.5,-451.9"/>
+<text text-anchor="middle" x="132" y="-415" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_b31&#45;&gt;Con_29 -->
+<g id="edge19" class="edge">
+<title>Phi_b31&#45;&gt;Con_29</title>
+<path fill="none" stroke="black" d="M147.87,-410.02C158.93,-422.92 175.04,-441.71 187.65,-456.42"/>
+<polygon fill="black" stroke="black" points="185.07,-458.8 194.24,-464.11 190.39,-454.24 185.07,-458.8"/>
+<text text-anchor="middle" x="144.87" y="-412.62" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_b31&#45;&gt;Region30 -->
+<g id="edge17" class="edge">
+<title>Phi_b31&#45;&gt;Region30</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M149.22,-378.43C157.37,-370.68 168.29,-362.11 180,-358 224.67,-342.33 347.58,-344.66 393,-358 401.94,-360.63 410.81,-365.17 418.76,-370.16"/>
+<polygon fill="black" stroke="black" points="417.05,-373.23 427.3,-375.91 420.96,-367.43 417.05,-373.23"/>
+<text text-anchor="middle" x="146.22" y="-372.03" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Region32 -->
+<g id="node20" class="node">
+<title>Region32</title>
+<polygon fill="yellow" stroke="black" points="390,-340 324,-340 324,-304 390,-304 390,-340"/>
+<text text-anchor="middle" x="357" y="-318.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region32&#45;&gt;If9 -->
+<g id="edge21" class="edge">
+<title>Region32&#45;&gt;If9:p1</title>
+<path fill="none" stroke="red" d="M369.73,-340.15C376.29,-350.08 383.61,-363.12 387,-376 391.08,-391.47 392.32,-396.91 387,-412 380.17,-431.38 366.81,-429.44 358,-448 304.99,-559.76 299.28,-598.69 299.01,-717.76"/>
+<polygon fill="red" stroke="red" points="295.51,-718 299,-728 302.51,-718 295.51,-718"/>
+<text text-anchor="middle" x="366.73" y="-342.75" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Region32&#45;&gt;Region30 -->
+<g id="edge20" class="edge">
+<title>Region32&#45;&gt;Region30</title>
+<path fill="none" stroke="red" d="M379.74,-340.3C391.44,-349.2 405.86,-360.18 418.51,-369.8"/>
+<polygon fill="red" stroke="red" points="416.44,-372.63 426.52,-375.9 420.68,-367.06 416.44,-372.63"/>
+<text text-anchor="middle" x="376.74" y="-342.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a33 -->
+<g id="node21" class="node">
+<title>Phi_a33</title>
+<ellipse fill="lightyellow" stroke="black" cx="279" cy="-322" rx="27" ry="18"/>
+<text text-anchor="middle" x="279" y="-318.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Phi_a33&#45;&gt;Con_6 -->
+<g id="edge24" class="edge">
+<title>Phi_a33&#45;&gt;Con_6</title>
+<path fill="none" stroke="black" d="M293.57,-337.17C303.75,-347.06 317.52,-360.45 329.03,-371.64"/>
+<polygon fill="black" stroke="black" points="326.59,-374.15 336.2,-378.62 331.47,-369.13 326.59,-374.15"/>
+<text text-anchor="middle" x="290.57" y="-339.77" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a33&#45;&gt;Con_13 -->
+<g id="edge23" class="edge">
+<title>Phi_a33&#45;&gt;Con_13</title>
+<path fill="none" stroke="black" d="M279,-340.3C279,-348.02 279,-357.29 279,-365.89"/>
+<polygon fill="black" stroke="black" points="275.5,-365.9 279,-375.9 282.5,-365.9 275.5,-365.9"/>
+<text text-anchor="middle" x="276" y="-342.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a33&#45;&gt;Region32 -->
+<g id="edge22" class="edge">
+<title>Phi_a33&#45;&gt;Region32</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M306.12,-322C308.58,-322 311.04,-322 313.5,-322"/>
+<polygon fill="black" stroke="black" points="313.61,-325.5 323.61,-322 313.61,-318.5 313.61,-325.5"/>
+<text text-anchor="middle" x="309.12" y="-315.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Phi_b34 -->
+<g id="node22" class="node">
+<title>Phi_b34</title>
+<ellipse fill="lightyellow" stroke="black" cx="207" cy="-322" rx="27.1" ry="18"/>
+<text text-anchor="middle" x="207" y="-318.3" font-family="Times,serif" font-size="14.00">φ_b</text>
+</g>
+<!-- Phi_b34&#45;&gt;Con_7 -->
+<g id="edge27" class="edge">
+<title>Phi_b34&#45;&gt;Con_7</title>
+<path fill="none" stroke="black" d="M207,-340.3C207,-348.02 207,-357.29 207,-365.89"/>
+<polygon fill="black" stroke="black" points="203.5,-365.9 207,-375.9 210.5,-365.9 203.5,-365.9"/>
+<text text-anchor="middle" x="204" y="-342.9" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_b34&#45;&gt;Phi_b31 -->
+<g id="edge26" class="edge">
+<title>Phi_b34&#45;&gt;Phi_b31</title>
+<path fill="none" stroke="black" d="M192.08,-337.5C182.04,-347.27 168.62,-360.31 157.32,-371.3"/>
+<polygon fill="black" stroke="black" points="154.63,-369.03 149.9,-378.51 159.51,-374.05 154.63,-369.03"/>
+<text text-anchor="middle" x="189.08" y="-340.1" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_b34&#45;&gt;Region32 -->
+<g id="edge25" class="edge">
+<title>Phi_b34&#45;&gt;Region32</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M221.22,-306.43C229.37,-298.68 240.29,-290.11 252,-286 274.65,-278.06 283.12,-278.74 306,-286 313.99,-288.54 321.81,-292.83 328.83,-297.58"/>
+<polygon fill="black" stroke="black" points="327.11,-300.66 337.24,-303.75 331.25,-295.01 327.11,-300.66"/>
+<text text-anchor="middle" x="218.22" y="-300.03" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Phi_c35 -->
+<g id="node23" class="node">
+<title>Phi_c35</title>
+<ellipse fill="lightyellow" stroke="black" cx="112" cy="-322" rx="27" ry="18"/>
+<text text-anchor="middle" x="112" y="-318.3" font-family="Times,serif" font-size="14.00">φ_c</text>
+</g>
+<!-- Phi_c35&#45;&gt;Con_8 -->
+<g id="edge30" class="edge">
+<title>Phi_c35&#45;&gt;Con_8</title>
+<path fill="none" stroke="black" d="M97.7,-337.5C88.08,-347.27 75.22,-360.31 64.39,-371.3"/>
+<polygon fill="black" stroke="black" points="61.81,-368.94 57.28,-378.51 66.79,-373.85 61.81,-368.94"/>
+<text text-anchor="middle" x="94.7" y="-340.1" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_c35&#45;&gt;Phi_c23 -->
+<g id="edge29" class="edge">
+<title>Phi_c35&#45;&gt;Phi_c23</title>
+<path fill="none" stroke="black" d="M105.53,-339.52C93.19,-373.79 70.03,-454.23 99,-512 107.39,-528.74 123.86,-541.54 138.82,-550.37"/>
+<polygon fill="black" stroke="black" points="137.41,-553.59 147.86,-555.35 140.79,-547.46 137.41,-553.59"/>
+<text text-anchor="middle" x="102.53" y="-342.12" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_c35&#45;&gt;Region32 -->
+<g id="edge28" class="edge">
+<title>Phi_c35&#45;&gt;Region32</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M130.62,-308.94C143.75,-300.56 162.11,-290.44 180,-286 234.35,-272.5 252.62,-269.06 306,-286 313.99,-288.54 321.81,-292.83 328.83,-297.58"/>
+<polygon fill="black" stroke="black" points="327.11,-300.66 337.24,-303.75 331.25,-295.01 327.11,-300.66"/>
+<text text-anchor="middle" x="127.62" y="-302.54" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Add36 -->
+<g id="node24" class="node">
+<title>Add36</title>
+<ellipse fill="none" stroke="black" cx="207" cy="-250" rx="27" ry="18"/>
+<text text-anchor="middle" x="207" y="-246.3" font-family="Times,serif" font-size="14.00">+</text>
+</g>
+<!-- Add36&#45;&gt;Phi_b34 -->
+<g id="edge32" class="edge">
+<title>Add36&#45;&gt;Phi_b34</title>
+<path fill="none" stroke="black" d="M207,-268.3C207,-276.02 207,-285.29 207,-293.89"/>
+<polygon fill="black" stroke="black" points="203.5,-293.9 207,-303.9 210.5,-293.9 203.5,-293.9"/>
+<text text-anchor="middle" x="204" y="-270.9" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Add36&#45;&gt;Phi_c35 -->
+<g id="edge31" class="edge">
+<title>Add36&#45;&gt;Phi_c35</title>
+<path fill="none" stroke="black" d="M189.58,-263.84C175.07,-274.53 154.21,-289.9 137.77,-302.01"/>
+<polygon fill="black" stroke="black" points="135.61,-299.26 129.64,-308.01 139.76,-304.89 135.61,-299.26"/>
+<text text-anchor="middle" x="186.58" y="-266.44" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Add37 -->
+<g id="node25" class="node">
+<title>Add37</title>
+<ellipse fill="none" stroke="black" cx="279" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="279" y="-174.3" font-family="Times,serif" font-size="14.00">+</text>
+</g>
+<!-- Add37&#45;&gt;Phi_a33 -->
+<g id="edge34" class="edge">
+<title>Add37&#45;&gt;Phi_a33</title>
+<path fill="none" stroke="black" d="M279,-196.13C279,-220.33 279,-264.79 279,-293.61"/>
+<polygon fill="black" stroke="black" points="275.5,-293.81 279,-303.81 282.5,-293.81 275.5,-293.81"/>
+<text text-anchor="middle" x="276" y="-198.73" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Add37&#45;&gt;Add36 -->
+<g id="edge33" class="edge">
+<title>Add37&#45;&gt;Add36</title>
+<path fill="none" stroke="black" d="M264.43,-193.17C254.25,-203.06 240.48,-216.45 228.97,-227.64"/>
+<polygon fill="black" stroke="black" points="226.53,-225.13 221.8,-234.62 231.41,-230.15 226.53,-225.13"/>
+<text text-anchor="middle" x="261.43" y="-195.77" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Return38&#45;&gt;Region32 -->
+<g id="edge35" class="edge">
+<title>Return38&#45;&gt;Region32</title>
+<path fill="none" stroke="red" d="M306.41,-124.15C315.94,-161.25 338.54,-249.19 350.03,-293.9"/>
+<polygon fill="red" stroke="red" points="346.69,-294.95 352.57,-303.77 353.47,-293.21 346.69,-294.95"/>
+<text text-anchor="middle" x="303.41" y="-126.75" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return38&#45;&gt;Add37 -->
+<g id="edge36" class="edge">
+<title>Return38&#45;&gt;Add37</title>
+<path fill="none" stroke="black" d="M296.31,-124.3C293.75,-132.1 290.67,-141.49 287.82,-150.17"/>
+<polygon fill="black" stroke="black" points="284.42,-149.3 284.62,-159.9 291.07,-151.49 284.42,-149.3"/>
+<text text-anchor="middle" x="293.31" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/06-graph4-true.gv b/docs/chapter06/06-graph4-true.gv
new file mode 100644
index 00000000..6e48ee7d
--- /dev/null
+++ b/docs/chapter06/06-graph4-true.gv
@@ -0,0 +1,37 @@
+digraph chapter06 {
+/*
+int a = 0;
+int b = 1;
+int c = 0;
+if( arg ) {
+ a = 1;
+ if( arg==2 ) { c=2; } else { c=3; }
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b+c;
+
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_44 [ label="#6" ];
+ Return45 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return45[taillabel=0 color=red];
+ Return45 -> Start2:p0[taillabel=0 color=red];
+ Return45 -> Con_44[taillabel=1];
+}
diff --git a/docs/chapter06/06-graph4-true.svg b/docs/chapter06/06-graph4-true.svg
new file mode 100644
index 00000000..a533ea21
--- /dev/null
+++ b/docs/chapter06/06-graph4-true.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter06 Pages: 1 -->
+<svg width="178pt" height="248pt"
+ viewBox="0.00 0.00 178.00 248.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 244)">
+<title>chapter06</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-244 174,-244 174,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-232 162,-232 162,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<polygon fill="none" stroke="black" points="24,-195 24,-220 74,-220 74,-195 24,-195"/>
+<text text-anchor="start" x="30.5" y="-203.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="24,-164 24,-195 74,-195 74,-164 24,-164"/>
+<polygon fill="yellow" stroke="transparent" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<polygon fill="none" stroke="black" points="29,-169 29,-190 69,-190 69,-169 29,-169"/>
+<text text-anchor="start" x="32" y="-175.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="112,-52 58,-52 58,-16 112,-16 112,-52"/>
+<text text-anchor="middle" x="85" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return45 -->
+<g id="node4" class="node">
+<title>Return45</title>
+<polygon fill="yellow" stroke="black" points="118,-124 52,-124 52,-88 118,-88 118,-124"/>
+<text text-anchor="middle" x="85" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return45 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return45</title>
+<path fill="none" stroke="red" d="M85,-52.3C85,-60.02 85,-69.29 85,-77.89"/>
+<polygon fill="red" stroke="red" points="81.5,-77.9 85,-87.9 88.5,-77.9 81.5,-77.9"/>
+<text text-anchor="middle" x="82" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_44 -->
+<g id="node3" class="node">
+<title>Con_44</title>
+<ellipse fill="none" stroke="black" cx="127" cy="-192" rx="27" ry="18"/>
+<text text-anchor="middle" x="127" y="-188.3" font-family="Times,serif" font-size="14.00">#6</text>
+</g>
+<!-- Return45&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>Return45&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M68.26,-124.13C60.77,-133.26 52.99,-145.23 50.13,-158.06"/>
+<polygon fill="red" stroke="red" points="46.66,-157.67 49,-168 53.61,-158.46 46.66,-157.67"/>
+<text text-anchor="middle" x="65.26" y="-126.73" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return45&#45;&gt;Con_44 -->
+<g id="edge3" class="edge">
+<title>Return45&#45;&gt;Con_44</title>
+<path fill="none" stroke="black" d="M93.7,-124.4C99.66,-136.31 107.65,-152.3 114.31,-165.62"/>
+<polygon fill="black" stroke="black" points="111.28,-167.38 118.88,-174.76 117.54,-164.25 111.28,-167.38"/>
+<text text-anchor="middle" x="90.7" y="-127" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/docs/chapter06/Makefile b/docs/chapter06/Makefile
new file mode 100644
index 00000000..12659b8f
--- /dev/null
+++ b/docs/chapter06/Makefile
@@ -0,0 +1,12 @@
+GV := $(wildcard *.gv)
+SVG := $(patsubst %.gv,%.svg,$(GV))
+
+.PHONY: all
+all: $(SVG)
+
+%.svg: %.gv
+ dot -Tsvg $< > $@
+
+.PHONY: clean
+clean:
+ @rm -f $(SVG)
diff --git a/docs/chapter06/README.md b/docs/chapter06/README.md
new file mode 100644
index 00000000..a5151586
--- /dev/null
+++ b/docs/chapter06/README.md
@@ -0,0 +1,200 @@
+# Chapter 6: Peepholes for If
+
+# Table of Contents
+
+1. [Type System Revision](#type-system-revision)
+2. [Peephole of `if`](#peephole-of-if)
+3. [`Region` and `Phi`](#Region-and-Phi)
+4. [Discussion](#discussion)
+5. [Expanding Peephole Beyond Constant Expressions](#expanding-peephole-beyond-constant-expressions)
+6. [Dominators](#dominators)
+
+You can also read [this chapter](https://github.com/SeaOfNodes/Simple/tree/linear-chapter06) in a linear Git revision history on the [linear](https://github.com/SeaOfNodes/Simple/tree/linear) branch and [compare](https://github.com/SeaOfNodes/Simple/compare/linear-chapter05...linear-chapter06) it to the previous chapter.
+
+In this chapter we do not add new language features. Our goal is to add peephole optimization to `if` statements.
+
+
+## Type System Revision
+
+We now need to extend the type system to introduce another lattice structure, in addition to the Integer sub-lattice.
+As before we denote "Top" by T and "Bottom" by ⊥.
+
+* "Ctrl" represents a live control, whereas "~Ctrl" represents a dead control.
+* "INT" refers to an integer value, note that integer values have their own sub-lattice.
+
+| | ⊥ | Ctrl | ~Ctrl | T | INT |
+|-------|---|------|-------|-------|-----|
+| T | ⊥ | Ctrl | ~Ctrl | T | INT |
+| Ctrl | ⊥ | Ctrl | Ctrl | Ctrl | ⊥ |
+| ~Ctrl | ⊥ | Ctrl | ~Ctrl | ~Ctrl | ⊥ |
+| ⊥ | ⊥ | ⊥ | ⊥ | ⊥ | ⊥ |
+
+* "Top" meets any type is that type,
+* "Bottom" meets any type is "Bottom",
+* "Top", "Bottom", "Ctrl", "~Ctrl" are classed as simple types,
+* "Ctrl" meets "~Ctrl" is "Ctrl"
+* Unless covered above, a simple type meets non-simple results in "Bottom"
+
+The entire revised Lattice is shown below:
+
+![Lattice](./lattice.svg)
+
+
+## Peephole of `if`
+
+* Our general strategy is to continue parsing the entire `if` statement even if we know that one branch is dead.
+* This approach creates dead nodes which get cleaned up by dead code
+ elimination. The benefits are that we do not introduce special logic during
+ parsing, the normal graph building machinery takes care of cleaning up dead
+ nodes.
+* When we peephole an `If` node we test if the predicate is a constant. If so,
+ then one branch or the other dead, depending on if the constant is `0` or not.
+* When we add the `Proj` nodes, in this scenario, we already know one of the projections is dead. The peephole of the
+ relevant `Proj` node replaces the `Proj` with a `Constant` of type "~Ctrl" indicating dead control.
+* At this point our dead code elimination would kill the `If` node since it has no uses
+ - but we cannot do that because we need to continue the parse. The
+ important observation is that *we __can__ kill the `If` node after __both__
+ the `Proj` nodes have been created*, because any subsequent control flow can
+ only see the `Proj` nodes.
+* To ensure this, we add a dummy user to `If` before creating the first `Proj` and remove it immediately after, allowing the
+ second `Proj` to trigger a dead code elimination of the `If`.
+* The live `Proj` gets replaced by the parent of `If`, whereas the dead `Proj` gets replaced by "~Ctrl".
+* The parsing then continues as normal.
+* The other changes are when we reach the merge point with a dead control.
+* Again keeping with our strategy we merge as normal, including creating `Phi` nodes.
+* The `Region` may have have one of its inputs as "~Ctrl". This will be seen
+ by the `Phi` which then optimizes itself. If the `Phi` has just one live
+ input, the `Phi` peephole replaces itself with the remaining input.
+* Finally, at the end, when the `Region` node is peepholed, we see that it has only one live input and no Phi uses
+ and can be replaced with its one live input.
+
+## `Region` and `Phi`
+
+One of the invariants we maintain is that the for each control input to a
+`Region` every `Phi` has a 1-to-1 relationship with a data input. Thus, if a
+`Region` loses a control input, every `Phi`'s corresponding data input must be
+deleted. Conversely, we cannot collapse a Region until it has no dependent
+`Phi`s.
+
+When processing `If` we do not remove control inputs to a `Region`, instead the
+dead control input is simply set to `Constant(~Ctrl)`. The peephole logic in
+a `Phi` notices this and replaces itself with the live input.
+
+## Discussion
+
+With the changes above, our peephole optimization is able to fold dead code when
+an `if` statement has a condition that evaluates to `true` or `false` at compile time.
+
+Let's look at a simple example below:
+
+```java
+if( true ) return 2;
+return 1;
+```
+
+Before peephole:
+
+![Graph1-Pre](./06-graph1-pre.svg)
+
+After peephole:
+
+![Graph1-Post](./06-graph1-post.svg)
+
+Another example:
+
+```java
+int a=1;
+if( true )
+ a=2;
+else
+ a=3;
+return a;
+```
+
+Before peephole:
+
+![Graph2-Pre](./06-graph2-pre.svg)
+
+After peephole:
+
+![Graph2-Post](./06-graph2-post.svg)
+
+## Expanding Peephole Beyond Constant Expressions
+
+While our peephole of the `CFG` collapses dead code when the expression is
+a compile time constant. it does not do as well as it could with following example:
+
+```java
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+```
+
+In this example, `arg` is defined externally, and we have to assume it is not a constant.
+However, the code repeats the `if( arg )` condition in the inner `if` statement.
+We know that if the outer `if( arg )` is true, then the *inner `if` must also evaluate to true*.
+
+Our peephole at present cannot see this:
+
+![Graph3-NonConst](./06-graph3-nonconst.svg)
+
+What we would like is for our peephole to see that the inner `if` is fully determined by the
+outer `if` and thus, the code can be simplified as follows:
+
+```java
+int a = 0;
+int b = 1;
+if ( arg ) {
+ a = 2;
+ b = 2;
+}
+return a+b;
+```
+
+That is, the final outcome is either `4` if `arg` happens to be true, or `1` if `arg` happens to be false.
+
+## Dominators
+
+The key to implementing this peephole is the observation that the inner `if` is completely determined by the
+outer `if`. In compiler parlance, we say that the outer `if` dominates the inner `if`.
+
+There is a generic way to determine this type of domination; it involves constructing a dominator
+tree. For details of how to do this, please refer to the paper `A Simple, Fast Dominance Algorithm`.[^1]
+
+However, constructing a dominator tree is an expensive operation; one that we would not like to
+do in the middle of parsing. Fortunately, since we do not have loops yet, we do not
+have back edges in our control flow graph. Our control flow graph is essentially hierarchical, tree like.
+Thus, a simple form of dominator identification is possible.
+
+The main idea is that we can assign a `depth` to each control node, this represents the node's depth
+in the hierarchy. We can compute this depth incrementally as we need to. The nodes that are deeper in the hierarchy
+have a greater depth than the ones above.
+
+Secondly we know that for our control nodes, except for `Region`s, there is only one incoming control edge,
+which means that most control nodes have a single immediate dominating control node. `Region` nodes are different
+as they can have one or more control edges; but, we know that for `if` statements, a `Region` node has exactly two
+control inputs, one from each branch of the `if`. To find the immediate dominator of a `Region` node in the
+limited scenario of an `if`, we can follow the immediate dominator of each branch until we find the common ancestor
+node that dominates both the branches.
+
+If this ancestor node is also an `if` and its predicate is the same as the current `if`, then we know that
+the outcome of the present `if` is fully determined.
+
+The code that does this check is in the [`compute` method of the `if`](https://github.com/SeaOfNodes/Simple/blob/main/chapter06/src/main/java/com/seaofnodes/simple/node/IfNode.java#L38-L45).
+
+The `idom` method in `Node` provides a default implementation of the depth based immediate dominator calculation.
+`Region`'s [override this](https://github.com/SeaOfNodes/Simple/blob/main/chapter06/src/main/java/com/seaofnodes/simple/node/RegionNode.java#L57-L74) to implement the more complex search described above.
+
+It turns out that to simplify the example above, we need a [further peephole in our `Add` node](https://github.com/SeaOfNodes/Simple/blob/main/chapter06/src/main/java/com/seaofnodes/simple/node/AddNode.java#L64-L67).
+
+With all these changes, the outcome of the peephole is just what we would like to see!
+
+![Graph3-NonConst-Peephole](./06-graph3-nonconst-peephole.svg)
+
+[^1]: Cooper, K. D. Cooper, Harvey, T. J., and Kennedy, K. (2001).
+ A Simple, Fast Dominance Algorithm.
diff --git a/docs/chapter06/lattice.gv b/docs/chapter06/lattice.gv
new file mode 100644
index 00000000..e5cc59be
--- /dev/null
+++ b/docs/chapter06/lattice.gv
@@ -0,0 +1,97 @@
+digraph Lattice {
+ // Define nodes
+ splines=false;
+ node [shape=circle, style=filled, fillcolor=lightblue];
+ nodesep=0.6;
+
+ TOP [label=<<B>⊤</B >>, fillcolor=black, fontcolor=white];
+ BOT [label=<<B>⊥</B>>, fillcolor=black, fontcolor=white];
+
+ // ----------------------
+ // Control
+ XCTRL [label=<<B>⊤</B >:ctrl>, fillcolor=yellow, shape=oval];
+ CTRL [label=<<B>⊥</B>:ctrl>, fillcolor=yellow, shape=oval];
+
+ TOP -> XCTRL;
+ XCTRL -> CTRL;
+ CTRL -> BOT;
+
+ // ----------------------
+ // Integers
+ INT_TOP [label=<<B>⊤</B >:int>, fillcolor=lightblue, shape=oval];
+ INT_BOT [label=<<B>⊥</B>:int>, fillcolor=lightblue, shape=oval];
+
+ INT_MIN [label="-n" , fillcolor=lightblue];
+ INT_MINDOTS [label="...", fillcolor=lightblue shape=oval];
+ INT_MINUS [label="-1" , fillcolor=lightblue];
+ INT_ZERO [label="0" , fillcolor=lightblue];
+ INT_PLUS [label="1" , fillcolor=lightblue];
+ INT_MAXDOTS [label="...", fillcolor=lightblue, shape=oval];
+ INT_MAX [label="+n" , fillcolor=lightblue];
+
+ TOP -> INT_TOP;
+ INT_TOP -> INT_MIN;
+ INT_TOP -> INT_MINDOTS;
+ INT_TOP -> INT_MINUS;
+ INT_TOP -> INT_ZERO;
+ INT_TOP -> INT_PLUS;
+ INT_TOP -> INT_MAXDOTS;
+ INT_TOP -> INT_MAX;
+ INT_MIN -> INT_BOT;
+ INT_MINDOTS -> INT_BOT;
+ INT_MINUS -> INT_BOT;
+ INT_ZERO -> INT_BOT;
+ INT_PLUS -> INT_BOT;
+ INT_MAXDOTS -> INT_BOT;
+ INT_MAX -> INT_BOT;
+ INT_BOT -> BOT;
+
+ INT_MIN -> INT_MINDOTS -> INT_MINUS -> INT_ZERO -> INT_PLUS -> INT_MAXDOTS -> INT_MAX [style=invis];
+
+ // ----------------------
+ // Tuples
+
+ TUPLE_TOP [label=<<B>⊤</B >:tuple>, fillcolor=pink, shape=oval];
+ TUPLE_BOT [label=<<B>⊥</B>:tuple>, fillcolor=pink, shape=oval];
+
+ TUPLE1 [shape=none, fillcolor=none, label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TH><TD BGCOLOR="pink">tuple</TD></TH>
+ <TR><TD BGCOLOR="black" ><FONT color="white">type</FONT></TD></TR>
+ </TABLE>
+ >];
+ TUPLE2 [shape=none, fillcolor=none, label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TH><TD BGCOLOR="pink">tuple</TD></TH>
+ <TR><TD BGCOLOR="black" ><FONT color="white">type</FONT></TD></TR>
+ <TR><TD BGCOLOR="black" ><FONT color="white">type</FONT></TD></TR>
+ </TABLE>
+ >];
+ TUPLEN [shape=none, fillcolor=none, label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TH><TD BGCOLOR="pink">tuple</TD></TH>
+ <TR><TD BGCOLOR="black" ><FONT color="white">type</FONT></TD></TR>
+ <TR><TD BGCOLOR="black" ><FONT color="white">...</FONT></TD></TR>
+ <TR><TD BGCOLOR="black" ><FONT color="white">type</FONT></TD></TR>
+ </TABLE>
+ >];
+
+
+ TOP -> TUPLE_TOP;
+ TUPLE_TOP -> TUPLE1;
+ TUPLE_TOP -> TUPLE2;
+ TUPLE_TOP -> TUPLEN;
+ TUPLE1 -> TUPLE_BOT;
+ TUPLE2 -> TUPLE_BOT;
+ TUPLEN -> TUPLE_BOT;
+ TUPLE_BOT -> BOT;
+
+ // Additional customization
+ {rank=same; TOP}
+ {rank=same; XCTRL; INT_TOP; TUPLE_TOP}
+ {rank=same;
+ INT_MIN; INT_MINDOTS; INT_MINUS; INT_ZERO; INT_PLUS; INT_MAXDOTS; INT_MAX;
+ }
+ {rank=same; CTRL; INT_BOT, TUPLE_BOT}
+ {rank=same; BOT;}
+}
diff --git a/docs/chapter06/lattice.svg b/docs/chapter06/lattice.svg
new file mode 100644
index 00000000..86371c93
--- /dev/null
+++ b/docs/chapter06/lattice.svg
@@ -0,0 +1,319 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 12.2.0 (20241103.1931)
+ -->
+<!-- Title: Lattice Pages: 1 -->
+<svg width="855pt" height="406pt"
+ viewBox="0.00 0.00 854.60 406.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 402.5)">
+<title>Lattice</title>
+<polygon fill="white" stroke="none" points="-4,4 -4,-402.5 850.6,-402.5 850.6,4 -4,4"/>
+<!-- TOP -->
+<g id="node1" class="node">
+<title>TOP</title>
+<ellipse fill="black" stroke="black" cx="276.6" cy="-377.37" rx="21.12" ry="21.12"/>
+<text text-anchor="start" x="268.72" y="-372.95" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00" fill="white">⊤</text>
+</g>
+<!-- XCTRL -->
+<g id="node3" class="node">
+<title>XCTRL</title>
+<ellipse fill="yellow" stroke="black" cx="49.6" cy="-302.25" rx="36.51" ry="18"/>
+<text text-anchor="start" x="30.85" y="-298.2" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00">⊤</text>
+<text text-anchor="start" x="46.6" y="-298.2" font-family="Times New Roman,serif" font-size="14.00">:ctrl</text>
+</g>
+<!-- TOP&#45;&gt;XCTRL -->
+<g id="edge1" class="edge">
+<title>TOP&#45;&gt;XCTRL</title>
+<path fill="none" stroke="black" d="M256.45,-369.88C219.31,-357.92 139.36,-332.16 90.45,-316.41"/>
+<polygon fill="black" stroke="black" points="91.65,-313.12 81.06,-313.38 89.51,-319.78 91.65,-313.12"/>
+</g>
+<!-- INT_TOP -->
+<g id="node5" class="node">
+<title>INT_TOP</title>
+<ellipse fill="lightblue" stroke="black" cx="276.6" cy="-302.25" rx="33.95" ry="18"/>
+<text text-anchor="start" x="259.72" y="-298.2" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00">⊤</text>
+<text text-anchor="start" x="275.47" y="-298.2" font-family="Times New Roman,serif" font-size="14.00">:int</text>
+</g>
+<!-- TOP&#45;&gt;INT_TOP -->
+<g id="edge4" class="edge">
+<title>TOP&#45;&gt;INT_TOP</title>
+<path fill="none" stroke="black" d="M276.6,-356C276.6,-348.51 276.6,-339.87 276.6,-331.79"/>
+<polygon fill="black" stroke="black" points="280.1,-332.05 276.6,-322.05 273.1,-332.05 280.1,-332.05"/>
+</g>
+<!-- TUPLE_TOP -->
+<g id="node14" class="node">
+<title>TUPLE_TOP</title>
+<ellipse fill="pink" stroke="black" cx="673.6" cy="-302.25" rx="42.65" ry="18"/>
+<text text-anchor="start" x="650.35" y="-298.2" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00">⊤</text>
+<text text-anchor="start" x="666.1" y="-298.2" font-family="Times New Roman,serif" font-size="14.00">:tuple</text>
+</g>
+<!-- TOP&#45;&gt;TUPLE_TOP -->
+<g id="edge26" class="edge">
+<title>TOP&#45;&gt;TUPLE_TOP</title>
+<path fill="none" stroke="black" d="M297.66,-372.49C358.57,-361.27 536.1,-328.57 623.62,-312.45"/>
+<polygon fill="black" stroke="black" points="624.16,-315.91 633.36,-310.66 622.89,-309.03 624.16,-315.91"/>
+</g>
+<!-- BOT -->
+<g id="node2" class="node">
+<title>BOT</title>
+<ellipse fill="black" stroke="black" cx="276.6" cy="-21.12" rx="21.12" ry="21.12"/>
+<text text-anchor="start" x="268.72" y="-16.7" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00" fill="white">⊥</text>
+</g>
+<!-- CTRL -->
+<g id="node4" class="node">
+<title>CTRL</title>
+<ellipse fill="yellow" stroke="black" cx="49.6" cy="-96.25" rx="36.51" ry="18"/>
+<text text-anchor="start" x="30.85" y="-92.2" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00">⊥</text>
+<text text-anchor="start" x="46.6" y="-92.2" font-family="Times New Roman,serif" font-size="14.00">:ctrl</text>
+</g>
+<!-- XCTRL&#45;&gt;CTRL -->
+<g id="edge2" class="edge">
+<title>XCTRL&#45;&gt;CTRL</title>
+<path fill="none" stroke="black" d="M49.6,-283.97C49.6,-248.31 49.6,-169.19 49.6,-125.93"/>
+<polygon fill="black" stroke="black" points="53.1,-126 49.6,-116 46.1,-126 53.1,-126"/>
+</g>
+<!-- CTRL&#45;&gt;BOT -->
+<g id="edge3" class="edge">
+<title>CTRL&#45;&gt;BOT</title>
+<path fill="none" stroke="black" d="M79.74,-85.54C122.92,-71.63 201.96,-46.17 245.6,-32.11"/>
+<polygon fill="black" stroke="black" points="246.52,-35.49 254.96,-29.09 244.37,-28.83 246.52,-35.49"/>
+</g>
+<!-- INT_MIN -->
+<g id="node7" class="node">
+<title>INT_MIN</title>
+<ellipse fill="lightblue" stroke="black" cx="18.6" cy="-199.25" rx="18.6" ry="18.6"/>
+<text text-anchor="middle" x="18.6" y="-194.2" font-family="Times New Roman,serif" font-size="14.00">&#45;n</text>
+</g>
+<!-- INT_TOP&#45;&gt;INT_MIN -->
+<g id="edge5" class="edge">
+<title>INT_TOP&#45;&gt;INT_MIN</title>
+<path fill="none" stroke="black" d="M249.96,-290.82C200.87,-271.6 96.58,-230.78 46.53,-211.18"/>
+<polygon fill="black" stroke="black" points="47.87,-207.95 37.29,-207.56 45.32,-214.47 47.87,-207.95"/>
+</g>
+<!-- INT_MINDOTS -->
+<g id="node8" class="node">
+<title>INT_MINDOTS</title>
+<ellipse fill="lightblue" stroke="black" cx="107.6" cy="-199.25" rx="27" ry="18"/>
+<text text-anchor="middle" x="107.6" y="-194.2" font-family="Times New Roman,serif" font-size="14.00">...</text>
+</g>
+<!-- INT_TOP&#45;&gt;INT_MINDOTS -->
+<g id="edge6" class="edge">
+<title>INT_TOP&#45;&gt;INT_MINDOTS</title>
+<path fill="none" stroke="black" d="M254.85,-288.25C224.79,-270.29 170.48,-237.83 136.88,-217.75"/>
+<polygon fill="black" stroke="black" points="138.84,-214.85 128.46,-212.72 135.25,-220.85 138.84,-214.85"/>
+</g>
+<!-- INT_MINUS -->
+<g id="node9" class="node">
+<title>INT_MINUS</title>
+<ellipse fill="lightblue" stroke="black" cx="196.6" cy="-199.25" rx="18.6" ry="18.6"/>
+<text text-anchor="middle" x="196.6" y="-194.2" font-family="Times New Roman,serif" font-size="14.00">&#45;1</text>
+</g>
+<!-- INT_TOP&#45;&gt;INT_MINUS -->
+<g id="edge7" class="edge">
+<title>INT_TOP&#45;&gt;INT_MINUS</title>
+<path fill="none" stroke="black" d="M264.1,-285.47C250.86,-268.76 229.85,-242.23 214.78,-223.21"/>
+<polygon fill="black" stroke="black" points="217.61,-221.14 208.66,-215.48 212.12,-225.49 217.61,-221.14"/>
+</g>
+<!-- INT_ZERO -->
+<g id="node10" class="node">
+<title>INT_ZERO</title>
+<ellipse fill="lightblue" stroke="black" cx="276.6" cy="-199.25" rx="18" ry="18"/>
+<text text-anchor="middle" x="276.6" y="-194.2" font-family="Times New Roman,serif" font-size="14.00">0</text>
+</g>
+<!-- INT_TOP&#45;&gt;INT_ZERO -->
+<g id="edge8" class="edge">
+<title>INT_TOP&#45;&gt;INT_ZERO</title>
+<path fill="none" stroke="black" d="M276.6,-284.12C276.6,-269.02 276.6,-246.74 276.6,-228.93"/>
+<polygon fill="black" stroke="black" points="280.1,-228.98 276.6,-218.98 273.1,-228.98 280.1,-228.98"/>
+</g>
+<!-- INT_PLUS -->
+<g id="node11" class="node">
+<title>INT_PLUS</title>
+<ellipse fill="lightblue" stroke="black" cx="355.6" cy="-199.25" rx="18" ry="18"/>
+<text text-anchor="middle" x="355.6" y="-194.2" font-family="Times New Roman,serif" font-size="14.00">1</text>
+</g>
+<!-- INT_TOP&#45;&gt;INT_PLUS -->
+<g id="edge9" class="edge">
+<title>INT_TOP&#45;&gt;INT_PLUS</title>
+<path fill="none" stroke="black" d="M288.94,-285.47C302.08,-268.67 323,-241.93 337.89,-222.88"/>
+<polygon fill="black" stroke="black" points="340.52,-225.2 343.93,-215.17 335.01,-220.89 340.52,-225.2"/>
+</g>
+<!-- INT_MAXDOTS -->
+<g id="node12" class="node">
+<title>INT_MAXDOTS</title>
+<ellipse fill="lightblue" stroke="black" cx="443.6" cy="-199.25" rx="27" ry="18"/>
+<text text-anchor="middle" x="443.6" y="-194.2" font-family="Times New Roman,serif" font-size="14.00">...</text>
+</g>
+<!-- INT_TOP&#45;&gt;INT_MAXDOTS -->
+<g id="edge10" class="edge">
+<title>INT_TOP&#45;&gt;INT_MAXDOTS</title>
+<path fill="none" stroke="black" d="M298.43,-288.04C328.15,-270.07 381.44,-237.84 414.52,-217.83"/>
+<polygon fill="black" stroke="black" points="416.05,-221 422.8,-212.83 412.43,-215.01 416.05,-221"/>
+</g>
+<!-- INT_MAX -->
+<g id="node13" class="node">
+<title>INT_MAX</title>
+<ellipse fill="lightblue" stroke="black" cx="534.6" cy="-199.25" rx="21.15" ry="21.15"/>
+<text text-anchor="middle" x="534.6" y="-194.2" font-family="Times New Roman,serif" font-size="14.00">+n</text>
+</g>
+<!-- INT_TOP&#45;&gt;INT_MAX -->
+<g id="edge11" class="edge">
+<title>INT_TOP&#45;&gt;INT_MAX</title>
+<path fill="none" stroke="black" d="M303.23,-290.82C351.59,-271.89 453.51,-231.99 504.38,-212.08"/>
+<polygon fill="black" stroke="black" points="505.55,-215.38 513.59,-208.47 503,-208.86 505.55,-215.38"/>
+</g>
+<!-- INT_BOT -->
+<g id="node6" class="node">
+<title>INT_BOT</title>
+<ellipse fill="lightblue" stroke="black" cx="276.6" cy="-96.25" rx="33.95" ry="18"/>
+<text text-anchor="start" x="259.72" y="-92.2" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00">⊥</text>
+<text text-anchor="start" x="275.47" y="-92.2" font-family="Times New Roman,serif" font-size="14.00">:int</text>
+</g>
+<!-- INT_BOT&#45;&gt;BOT -->
+<g id="edge19" class="edge">
+<title>INT_BOT&#45;&gt;BOT</title>
+<path fill="none" stroke="black" d="M276.6,-77.92C276.6,-70.74 276.6,-62.18 276.6,-53.95"/>
+<polygon fill="black" stroke="black" points="280.1,-54.22 276.6,-44.22 273.1,-54.22 280.1,-54.22"/>
+</g>
+<!-- INT_MIN&#45;&gt;INT_BOT -->
+<g id="edge12" class="edge">
+<title>INT_MIN&#45;&gt;INT_BOT</title>
+<path fill="none" stroke="black" d="M35.92,-191.46C77.34,-175.25 182.81,-133.96 239.39,-111.81"/>
+<polygon fill="black" stroke="black" points="240.58,-115.11 248.62,-108.2 238.03,-108.59 240.58,-115.11"/>
+</g>
+<!-- INT_MIN&#45;&gt;INT_MINDOTS -->
+<!-- INT_MINDOTS&#45;&gt;INT_BOT -->
+<g id="edge13" class="edge">
+<title>INT_MINDOTS&#45;&gt;INT_BOT</title>
+<path fill="none" stroke="black" d="M127.31,-186.46C156.24,-169.18 210.48,-136.76 245,-116.13"/>
+<polygon fill="black" stroke="black" points="246.52,-119.3 253.3,-111.17 242.93,-113.29 246.52,-119.3"/>
+</g>
+<!-- INT_MINDOTS&#45;&gt;INT_MINUS -->
+<!-- INT_MINUS&#45;&gt;INT_BOT -->
+<g id="edge14" class="edge">
+<title>INT_MINUS&#45;&gt;INT_BOT</title>
+<path fill="none" stroke="black" d="M207.72,-184.2C220.41,-168.18 241.41,-141.67 256.89,-122.13"/>
+<polygon fill="black" stroke="black" points="259.58,-124.37 263.05,-114.35 254.09,-120.02 259.58,-124.37"/>
+</g>
+<!-- INT_MINUS&#45;&gt;INT_ZERO -->
+<!-- INT_ZERO&#45;&gt;INT_BOT -->
+<g id="edge15" class="edge">
+<title>INT_ZERO&#45;&gt;INT_BOT</title>
+<path fill="none" stroke="black" d="M276.6,-181.12C276.6,-166.02 276.6,-143.74 276.6,-125.93"/>
+<polygon fill="black" stroke="black" points="280.1,-125.98 276.6,-115.98 273.1,-125.98 280.1,-125.98"/>
+</g>
+<!-- INT_ZERO&#45;&gt;INT_PLUS -->
+<!-- INT_PLUS&#45;&gt;INT_BOT -->
+<g id="edge16" class="edge">
+<title>INT_PLUS&#45;&gt;INT_BOT</title>
+<path fill="none" stroke="black" d="M344.94,-184.63C332.49,-168.71 311.63,-142.04 296.23,-122.35"/>
+<polygon fill="black" stroke="black" points="299.01,-120.23 290.1,-114.51 293.5,-124.54 299.01,-120.23"/>
+</g>
+<!-- INT_PLUS&#45;&gt;INT_MAXDOTS -->
+<!-- INT_MAXDOTS&#45;&gt;INT_BOT -->
+<g id="edge17" class="edge">
+<title>INT_MAXDOTS&#45;&gt;INT_BOT</title>
+<path fill="none" stroke="black" d="M424.11,-186.46C395.53,-169.18 341.93,-136.76 307.82,-116.13"/>
+<polygon fill="black" stroke="black" points="309.99,-113.35 299.62,-111.17 306.37,-119.34 309.99,-113.35"/>
+</g>
+<!-- INT_MAXDOTS&#45;&gt;INT_MAX -->
+<!-- INT_MAX&#45;&gt;INT_BOT -->
+<g id="edge18" class="edge">
+<title>INT_MAX&#45;&gt;INT_BOT</title>
+<path fill="none" stroke="black" d="M515.2,-190.66C472.47,-173.93 369.55,-133.64 313.87,-111.84"/>
+<polygon fill="black" stroke="black" points="315.4,-108.68 304.81,-108.29 312.84,-115.2 315.4,-108.68"/>
+</g>
+<!-- TUPLE1 -->
+<g id="node16" class="node">
+<title>TUPLE1</title>
+<polygon fill="none" stroke="none" points="652.6,-225.75 598.6,-225.75 598.6,-172.75 652.6,-172.75 652.6,-225.75"/>
+<polygon fill="pink" stroke="none" points="609.1,-199.25 609.1,-221.75 642.1,-221.75 642.1,-199.25 609.1,-199.25"/>
+<polygon fill="none" stroke="black" points="609.1,-199.25 609.1,-221.75 642.1,-221.75 642.1,-199.25 609.1,-199.25"/>
+<text text-anchor="start" x="612.1" y="-205.45" font-family="Times New Roman,serif" font-size="14.00">tuple</text>
+<polygon fill="black" stroke="none" points="609.1,-176.75 609.1,-199.25 642.1,-199.25 642.1,-176.75 609.1,-176.75"/>
+<polygon fill="none" stroke="black" points="609.1,-176.75 609.1,-199.25 642.1,-199.25 642.1,-176.75 609.1,-176.75"/>
+<text text-anchor="start" x="613.97" y="-182.95" font-family="Times New Roman,serif" font-size="14.00" fill="white">type</text>
+</g>
+<!-- TUPLE_TOP&#45;&gt;TUPLE1 -->
+<g id="edge27" class="edge">
+<title>TUPLE_TOP&#45;&gt;TUPLE1</title>
+<path fill="none" stroke="black" d="M665.45,-284.12C659.18,-270.91 650.28,-252.2 642.49,-235.8"/>
+<polygon fill="black" stroke="black" points="645.67,-234.33 638.22,-226.8 639.35,-237.34 645.67,-234.33"/>
+</g>
+<!-- TUPLE2 -->
+<g id="node17" class="node">
+<title>TUPLE2</title>
+<polygon fill="none" stroke="none" points="749.6,-237 695.6,-237 695.6,-161.5 749.6,-161.5 749.6,-237"/>
+<polygon fill="pink" stroke="none" points="706.1,-210.5 706.1,-233 739.1,-233 739.1,-210.5 706.1,-210.5"/>
+<polygon fill="none" stroke="black" points="706.1,-210.5 706.1,-233 739.1,-233 739.1,-210.5 706.1,-210.5"/>
+<text text-anchor="start" x="709.1" y="-216.7" font-family="Times New Roman,serif" font-size="14.00">tuple</text>
+<polygon fill="black" stroke="none" points="706.1,-188 706.1,-210.5 739.1,-210.5 739.1,-188 706.1,-188"/>
+<polygon fill="none" stroke="black" points="706.1,-188 706.1,-210.5 739.1,-210.5 739.1,-188 706.1,-188"/>
+<text text-anchor="start" x="710.97" y="-194.2" font-family="Times New Roman,serif" font-size="14.00" fill="white">type</text>
+<polygon fill="black" stroke="none" points="706.1,-165.5 706.1,-188 739.1,-188 739.1,-165.5 706.1,-165.5"/>
+<polygon fill="none" stroke="black" points="706.1,-165.5 706.1,-188 739.1,-188 739.1,-165.5 706.1,-165.5"/>
+<text text-anchor="start" x="710.97" y="-171.7" font-family="Times New Roman,serif" font-size="14.00" fill="white">type</text>
+</g>
+<!-- TUPLE_TOP&#45;&gt;TUPLE2 -->
+<g id="edge28" class="edge">
+<title>TUPLE_TOP&#45;&gt;TUPLE2</title>
+<path fill="none" stroke="black" d="M681.91,-284.12C686.91,-273.8 693.55,-260.12 700.01,-246.81"/>
+<polygon fill="black" stroke="black" points="703,-248.65 704.22,-238.13 696.7,-245.6 703,-248.65"/>
+</g>
+<!-- TUPLEN -->
+<g id="node18" class="node">
+<title>TUPLEN</title>
+<polygon fill="none" stroke="none" points="846.6,-248.25 792.6,-248.25 792.6,-150.25 846.6,-150.25 846.6,-248.25"/>
+<polygon fill="pink" stroke="none" points="803.1,-221.75 803.1,-244.25 836.1,-244.25 836.1,-221.75 803.1,-221.75"/>
+<polygon fill="none" stroke="black" points="803.1,-221.75 803.1,-244.25 836.1,-244.25 836.1,-221.75 803.1,-221.75"/>
+<text text-anchor="start" x="806.1" y="-227.95" font-family="Times New Roman,serif" font-size="14.00">tuple</text>
+<polygon fill="black" stroke="none" points="803.1,-199.25 803.1,-221.75 836.1,-221.75 836.1,-199.25 803.1,-199.25"/>
+<polygon fill="none" stroke="black" points="803.1,-199.25 803.1,-221.75 836.1,-221.75 836.1,-199.25 803.1,-199.25"/>
+<text text-anchor="start" x="807.97" y="-205.45" font-family="Times New Roman,serif" font-size="14.00" fill="white">type</text>
+<polygon fill="black" stroke="none" points="803.1,-176.75 803.1,-199.25 836.1,-199.25 836.1,-176.75 803.1,-176.75"/>
+<polygon fill="none" stroke="black" points="803.1,-176.75 803.1,-199.25 836.1,-199.25 836.1,-176.75 803.1,-176.75"/>
+<text text-anchor="start" x="813.97" y="-182.95" font-family="Times New Roman,serif" font-size="14.00" fill="white">...</text>
+<polygon fill="black" stroke="none" points="803.1,-154.25 803.1,-176.75 836.1,-176.75 836.1,-154.25 803.1,-154.25"/>
+<polygon fill="none" stroke="black" points="803.1,-154.25 803.1,-176.75 836.1,-176.75 836.1,-154.25 803.1,-154.25"/>
+<text text-anchor="start" x="807.97" y="-160.45" font-family="Times New Roman,serif" font-size="14.00" fill="white">type</text>
+</g>
+<!-- TUPLE_TOP&#45;&gt;TUPLEN -->
+<g id="edge29" class="edge">
+<title>TUPLE_TOP&#45;&gt;TUPLEN</title>
+<path fill="none" stroke="black" d="M695.14,-286.35C718.34,-270.29 755.65,-244.48 783.38,-225.3"/>
+<polygon fill="black" stroke="black" points="785.27,-228.25 791.51,-219.68 781.29,-222.49 785.27,-228.25"/>
+</g>
+<!-- TUPLE_BOT -->
+<g id="node15" class="node">
+<title>TUPLE_BOT</title>
+<ellipse fill="pink" stroke="black" cx="673.6" cy="-96.25" rx="42.65" ry="18"/>
+<text text-anchor="start" x="650.35" y="-92.2" font-family="Times New Roman,serif" font-weight="bold" font-size="14.00">⊥</text>
+<text text-anchor="start" x="666.1" y="-92.2" font-family="Times New Roman,serif" font-size="14.00">:tuple</text>
+</g>
+<!-- TUPLE_BOT&#45;&gt;BOT -->
+<g id="edge33" class="edge">
+<title>TUPLE_BOT&#45;&gt;BOT</title>
+<path fill="none" stroke="black" d="M635.17,-88.17C557.01,-73.77 380.82,-41.32 308.5,-28"/>
+<polygon fill="black" stroke="black" points="309.38,-24.6 298.91,-26.23 308.11,-31.49 309.38,-24.6"/>
+</g>
+<!-- TUPLE1&#45;&gt;TUPLE_BOT -->
+<g id="edge30" class="edge">
+<title>TUPLE1&#45;&gt;TUPLE_BOT</title>
+<path fill="none" stroke="black" d="M637.71,-172.76C644.73,-158 653.56,-139.41 660.7,-124.38"/>
+<polygon fill="black" stroke="black" points="663.78,-126.06 664.91,-115.53 657.45,-123.06 663.78,-126.06"/>
+</g>
+<!-- TUPLE2&#45;&gt;TUPLE_BOT -->
+<g id="edge31" class="edge">
+<title>TUPLE2&#45;&gt;TUPLE_BOT</title>
+<path fill="none" stroke="black" d="M704.77,-161.5C698.84,-149.27 692.34,-135.89 686.82,-124.51"/>
+<polygon fill="black" stroke="black" points="690.05,-123.15 682.54,-115.69 683.76,-126.21 690.05,-123.15"/>
+</g>
+<!-- TUPLEN&#45;&gt;TUPLE_BOT -->
+<g id="edge32" class="edge">
+<title>TUPLEN&#45;&gt;TUPLE_BOT</title>
+<path fill="none" stroke="black" d="M792.82,-179.72C767.85,-162.45 730.64,-136.71 704.44,-118.58"/>
+<polygon fill="black" stroke="black" points="706.45,-115.72 696.23,-112.91 702.46,-121.47 706.45,-115.72"/>
+</g>
+</g>
+</svg>
diff --git a/src/main/java/com/seaofnodes/simple/Parser.java b/src/main/java/com/seaofnodes/simple/Parser.java
index 359d0175..b9fbf26f 100644
--- a/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/src/main/java/com/seaofnodes/simple/Parser.java
@@ -161,6 +161,7 @@ public class Parser {
IfNode ifNode = (IfNode)new IfNode(ctrl(), pred).<IfNode>keep().peephole();
// Setup projection nodes
Node ifT = new ProjNode(ifNode, 0, "True" ).peephole();
+ ifNode.unkeep();
Node ifF = new ProjNode(ifNode, 1, "False").peephole();
// In if true branch, the ifT proj node becomes the ctrl
// But first clone the scope and set it as current
@@ -204,7 +205,7 @@ public class Parser {
private Node parseReturn() {
var expr = require(parseExpression(), ";");
Node ret = STOP.addReturn(new ReturnNode(ctrl(), expr).peephole());
- ctrl(null); // Kill control
+ ctrl(new ConstantNode(Type.XCONTROL).peephole()); // Kill control
return ret;
}
diff --git a/src/main/java/com/seaofnodes/simple/node/AddNode.java b/src/main/java/com/seaofnodes/simple/node/AddNode.java
index 2772c4c5..72dc0ffd 100644
--- a/src/main/java/com/seaofnodes/simple/node/AddNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/AddNode.java
@@ -61,7 +61,8 @@ public class AddNode extends Node {
// Now we might see (add add non) or (add non non) but never (add non add) nor (add add add)
if( !(lhs instanceof AddNode) )
- return spine_cmp(lhs,rhs) ? swap12() : null;
+ // Rotate; look for (add (phi cons) con/(phi cons))
+ return spine_cmp(lhs,rhs) ? swap12() : phiCon(this,true);
// Now we only see (add add non)
@@ -70,23 +71,12 @@ public class AddNode extends Node {
if( lhs.in(2)._type.isConstant() && t2.isConstant() )
return new AddNode(lhs.in(1),new AddNode(lhs.in(2),rhs).peephole());
- if( lhs.in(2) instanceof PhiNode phi && phi.allCons() &&
- // Do we have ((x + (phi cons)) + con) ?
- // Do we have ((x + (phi cons)) + (phi cons)) ?
- // Push constant up through the phi: x + (phi con0+con0 con1+con1...)
-
- // Note that this is the exact reverse of Phi pulling a common op
- // down to reduce total op-count. We don't get in an endless push-
- // up push-down peephole cycle because the constants all fold first.
- (t2.isConstant() || (rhs instanceof PhiNode && phi.in(0) == rhs.in(0) && rhs.allCons()) ) ) {
- Node[] ns = new Node[phi.nIns()];
- ns[0] = phi.in(0);
- // Push constant up through the phi: x + (phi con0+con0 con1+con1...)
- for( int i=1; i<ns.length; i++ )
- ns[i] = new AddNode(phi.in(i),t2.isConstant() ? rhs : rhs.in(i)).peephole();
- String label = phi._label + (rhs instanceof PhiNode rphi ? rphi._label : "");
- return new AddNode(lhs.in(1),new PhiNode(label,ns).peephole());
- }
+
+ // Do we have ((x + (phi cons)) + con) ?
+ // Do we have ((x + (phi cons)) + (phi cons)) ?
+ // Push constant up through the phi: x + (phi con0+con0 con1+con1...)
+ Node phicon = phiCon(this,true);
+ if( phicon!=null ) return phicon;
// Now we sort along the spine via rotates, to gather similar things together.
@@ -98,6 +88,47 @@ public class AddNode extends Node {
return null;
}
+ // Rotation is only valid for associative ops, e.g. Add, Mul, And, Or.
+ // Do we have ((phi cons)|(x + (phi cons)) + con|(phi cons)) ?
+ // Push constant up through the phi: x + (phi con0+con0 con1+con1...)
+ static Node phiCon(Node op, boolean rotate) {
+ Node lhs = op.in(1);
+ Node rhs = op.in(2);
+ // LHS is either a Phi of constants, or another op with Phi of constants
+ PhiNode lphi = pcon(lhs);
+ if( rotate && lphi==null && lhs.nIns() > 2 ) {
+ // Only valid to rotate constants if both are same associative ops
+ if( lhs.getClass() != op.getClass() ) return null;
+ lphi = pcon(lhs.in(2)); // Will rotate with the Phi push
+ }
+ if( lphi==null ) return null;
+
+ // RHS is a constant or a Phi of constants
+ if( !(rhs instanceof ConstantNode con) && pcon(rhs)==null )
+ return null;
+
+ // If both are Phis, must be same Region
+ if( rhs instanceof PhiNode && lphi.in(0) != rhs.in(0) )
+ return null;
+
+ // Note that this is the exact reverse of Phi pulling a common op down
+ // to reduce total op-count. We don't get in an endless push-up
+ // push-down peephole cycle because the constants all fold first.
+ Node[] ns = new Node[lphi.nIns()];
+ ns[0] = lphi.in(0);
+ // Push constant up through the phi: x + (phi con0+con0 con1+con1...)
+ for( int i=1; i<ns.length; i++ )
+ ns[i] = op.copy(lphi.in(i), rhs instanceof PhiNode ? rhs.in(i) : rhs).peephole();
+ String label = lphi._label + (rhs instanceof PhiNode rphi ? rphi._label : "");
+ Node phi = new PhiNode(label,ns).peephole();
+ // Rotate needs another op, otherwise just the phi
+ return lhs==lphi ? phi : op.copy(lhs.in(1),phi);
+ }
+
+ static PhiNode pcon(Node op) {
+ return op instanceof PhiNode phi && phi.allCons() ? phi : null;
+ }
+
// Compare two off-spine nodes and decide what order they should be in.
// Do we rotate ((x + hi) + lo) into ((x + lo) + hi) ?
// Generally constants always go right, then Phi-of-constants, then muls, then others.
diff --git a/src/main/java/com/seaofnodes/simple/node/BoolNode.java b/src/main/java/com/seaofnodes/simple/node/BoolNode.java
index 87acc6cc..ab1b474c 100644
--- a/src/main/java/com/seaofnodes/simple/node/BoolNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/BoolNode.java
@@ -40,6 +40,13 @@ abstract public class BoolNode extends Node {
if( in(1)==in(2) )
return new ConstantNode(TypeInteger.constant(doOp(3,3)?1:0));
+ // Do we have ((phi cons) cmp con) ?
+ // Do we have ((phi cons) cmp (phi cons)) ?
+ // Push the compare up through the phi: (phi con0 cmp con, con1 cmp con...)
+ // No rotate: compares are not associative.
+ Node phicon = AddNode.phiCon(this,false);
+ if( phicon!=null ) return phicon;
+
return null;
}
diff --git a/src/main/java/com/seaofnodes/simple/node/IfNode.java b/src/main/java/com/seaofnodes/simple/node/IfNode.java
index 6124b893..34846e99 100644
--- a/src/main/java/com/seaofnodes/simple/node/IfNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/IfNode.java
@@ -26,7 +26,25 @@ public class IfNode extends MultiNode {
@Override
public Type compute() {
- return TypeTuple.IF;
+ // If the If node is not reachable then neither is any following Proj
+ if (ctrl()._type != Type.CONTROL) return TypeTuple.IF_NEITHER;
+ // If constant is 0 then false branch is reachable
+ // Else true branch is reachable
+ if (pred()._type instanceof TypeInteger ti && ti.isConstant()) {
+ if (ti.value() == 0) return TypeTuple.IF_FALSE;
+ else return TypeTuple.IF_TRUE;
+ }
+
+ // Hunt up the immediate dominator tree. If we find an identical if
+ // test on either the true or false branch, then this test matches.
+ for( Node dom = idom(), prior=this; dom!=null; prior=dom, dom = dom.idom() )
+ if( dom instanceof IfNode iff && iff.pred()==pred() )
+ return prior instanceof ProjNode proj
+ // Repeated test, dominated on one side. Test result is the same.
+ ? (proj._idx==0 ? TypeTuple.IF_TRUE : TypeTuple.IF_FALSE)
+ : null; // Repeated test not dominated on one side
+
+ return TypeTuple.IF_BOTH;
}
@Override
diff --git a/src/main/java/com/seaofnodes/simple/node/MulNode.java b/src/main/java/com/seaofnodes/simple/node/MulNode.java
index b1d9e44a..380cb042 100644
--- a/src/main/java/com/seaofnodes/simple/node/MulNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/MulNode.java
@@ -42,6 +42,12 @@ public class MulNode extends Node {
if ( t1.isConstant() && !t2.isConstant() )
return swap12();
+ // Do we have ((x * (phi cons)) * con) ?
+ // Do we have ((x * (phi cons)) * (phi cons)) ?
+ // Push constant up through the phi: x * (phi con0*con0 con1*con1...)
+ Node phicon = AddNode.phiCon(this,true);
+ if( phicon!=null ) return phicon;
+
return null;
}
@Override Node copy(Node lhs, Node rhs) { return new MulNode(lhs,rhs); }
diff --git a/src/main/java/com/seaofnodes/simple/node/Node.java b/src/main/java/com/seaofnodes/simple/node/Node.java
index e17d7b9a..6f9ee258 100644
--- a/src/main/java/com/seaofnodes/simple/node/Node.java
+++ b/src/main/java/com/seaofnodes/simple/node/Node.java
@@ -1,8 +1,10 @@
package com.seaofnodes.simple.node;
import com.seaofnodes.simple.Parser;
+
import com.seaofnodes.simple.Utils;
import com.seaofnodes.simple.type.Type;
+
import java.util.*;
/**
@@ -46,9 +48,19 @@ public abstract class Node {
*/
public Type _type;
+
+ /**
+ * Immediate dominator tree depth, used to approximate a real IDOM during
+ * parsing where we do not have the whole program, and also peepholes
+ * change the CFG incrementally.
+ * <p>
+ * See {@link <a href="https://en.wikipedia.org/wiki/Dominator_(graph_theory)">...</a>}
+ */
+ char _idepth;
+
/**
* A private Global Static mutable counter, for unique node id generation.
- * To make the compiler multi-threaded, this field will have to move into a TLS.
+ * To make the compiler multithreaded, this field will have to move into a TLS.
* Starting with value 1, to avoid bugs confusing node ID 0 with uninitialized values.
* */
private static int UNIQUE_ID = 1;
@@ -147,6 +159,17 @@ public abstract class Node {
return new_def;
}
+ // Remove the numbered input, compressing the inputs in-place. This
+ // shuffles the order deterministically - which is suitable for Region and
+ // Phi, but not for every Node.
+ void delDef(int idx) {
+ Node old_def = in(idx);
+ if( old_def != null && // If the old def exists, remove a def->use edge
+ old_def.delUse(this) ) // If we removed the last use, the old def is now dead
+ old_def.kill(); // Kill old def
+ Utils.del(_inputs, idx);
+ }
+
/**
* Add a new def to an existing Node. Keep the edges correct by
* adding the corresponding <em>def->use</em> edge.
@@ -355,6 +378,30 @@ public abstract class Node {
return true;
}
+ // Return the immediate dominator of this Node and compute dom tree depth.
+ Node idom() { return in(0); }
+
+ // Find the lowest common ancestor in the current dominator tree.
+ Node domLCA(Node rhs) {
+ if( rhs==null ) return this;
+ Node lhs = this;
+ while( lhs != rhs ) {
+ if( lhs==null || rhs==null ) return null;
+ int comp = lhs.idepth() - rhs.idepth();
+ if( comp >= 0 ) lhs = lhs.idom();
+ if( comp <= 0 ) rhs = rhs.idom();
+ }
+ return lhs;
+ }
+
+ int idepth() { return _idepth!=0 ? _idepth : cacheIDepth(idom().idepth()+1); }
+ // Zero depth means uncached. Check before narrowing so overflow cannot wrap.
+ final int cacheIDepth(int depth) {
+ assert 0 <= depth && depth <= Character.MAX_VALUE : "Dominator depth exceeds 65535";
+ return _idepth = (char)depth;
+ }
+
+
// Make a shallow copy (same class) of this Node, with given inputs and
// empty outputs and a new Node ID. The original inputs are ignored.
// Does not need to be implemented in isCFG() nodes.
diff --git a/src/main/java/com/seaofnodes/simple/node/PhiNode.java b/src/main/java/com/seaofnodes/simple/node/PhiNode.java
index b3b5462d..f7cf917e 100644
--- a/src/main/java/com/seaofnodes/simple/node/PhiNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/PhiNode.java
@@ -24,17 +24,18 @@ public class PhiNode extends Node {
@Override
public Type compute() {
- Type t = in(1)._type;
- for( int i=2; i<nIns(); i++ )
+ Type t = Type.TOP;
+ for (int i = 1; i < nIns(); i++)
t = t.meet(in(i)._type);
return t;
}
@Override
public Node idealize() {
- // Remove a "junk" Phi: Phi(x,x) is just x
- if( same_inputs() )
- return in(1);
+ // If we have only a single unique input, become it.
+ Node live = singleUniqueInput();
+ if (live != null)
+ return live;
// Pull "down" a common data op. One less op in the world. One more
// Phi, but Phis do not make code.
@@ -64,11 +65,17 @@ public class PhiNode extends Node {
return true;
}
- private boolean same_inputs() {
- for( int i=2; i<nIns(); i++ )
- if( in(1) != in(i) )
- return false;
- return true;
+ /**
+ * If only single unique input, return it
+ */
+ private Node singleUniqueInput() {
+ Node live = null;
+ for( int i=1; i<nIns(); i++ )
+ if( region().in(i)._type != Type.XCONTROL && in(i) != this )
+ if( live == null || live == in(i) ) live = in(i);
+ else return null;
+ return live;
}
+
}
diff --git a/src/main/java/com/seaofnodes/simple/node/ProjNode.java b/src/main/java/com/seaofnodes/simple/node/ProjNode.java
index 2826d192..85f28037 100644
--- a/src/main/java/com/seaofnodes/simple/node/ProjNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/ProjNode.java
@@ -35,6 +35,8 @@ public class ProjNode extends Node {
@Override
public Node idealize() {
+ if( ctrl()._type instanceof TypeTuple tt && tt._types[1-_idx]==Type.XCONTROL ) // Only true for IfNodes
+ return ctrl().in(0); // We become our input control
return null;
}
}
diff --git a/src/main/java/com/seaofnodes/simple/node/RegionNode.java b/src/main/java/com/seaofnodes/simple/node/RegionNode.java
index 5d520d65..9b51a277 100644
--- a/src/main/java/com/seaofnodes/simple/node/RegionNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/RegionNode.java
@@ -1,5 +1,6 @@
package com.seaofnodes.simple.node;
+import com.seaofnodes.simple.Utils;
import com.seaofnodes.simple.type.Type;
public class RegionNode extends Node {
@@ -17,11 +18,57 @@ public class RegionNode extends Node {
@Override
public Type compute() {
- return Type.CONTROL;
+ Type t = Type.XCONTROL;
+ for (int i = 1; i < nIns(); i++)
+ t = t.meet(in(i)._type);
+ return t;
}
@Override
public Node idealize() {
+ int path = findDeadInput();
+ if( path != 0 ) {
+ for( Node phi : _outputs )
+ if( phi instanceof PhiNode )
+ phi.delDef(path);
+ delDef(path);
+
+ // If down to a single input, become that input - but also make all
+ // Phis an identity on *their* single input.
+ if( nIns()==2 ) {
+ for( Node phi : _outputs )
+ if( phi instanceof PhiNode )
+ // Currently does not happen, because no loops
+ throw Utils.TODO();
+ return in(1);
+ }
+ return this;
+ }
return null;
}
+
+ private int findDeadInput() {
+ for( int i=1; i<nIns(); i++ )
+ if( in(i)._type==Type.XCONTROL )
+ return i;
+ return 0; // All inputs alive
+ }
+
+ // Immediate dominator of Region is a little more complicated.
+ @Override int idepth() {
+ if( _idepth!=0 ) return _idepth;
+ int depth=0;
+ for( Node n : _inputs )
+ if( n!=null )
+ depth = Math.max(depth,n.idepth()+1);
+ return cacheIDepth(depth);
+ }
+
+ @Override Node idom() {
+ Node lca = null;
+ // Recompute from predecessors: CFG edits can change the dominator.
+ for( int i=1; i<nIns(); i++ )
+ lca = in(i).domLCA(lca);
+ return lca;
+ }
}
diff --git a/src/main/java/com/seaofnodes/simple/node/ReturnNode.java b/src/main/java/com/seaofnodes/simple/node/ReturnNode.java
index c9d6c9c8..6130d050 100644
--- a/src/main/java/com/seaofnodes/simple/node/ReturnNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/ReturnNode.java
@@ -36,5 +36,9 @@ public class ReturnNode extends Node {
}
@Override
- public Node idealize() { return null; }
+ public Node idealize() {
+ if( ctrl()._type==Type.XCONTROL )
+ return ctrl();
+ return null;
+ }
}
diff --git a/src/main/java/com/seaofnodes/simple/node/ScopeNode.java b/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
index 32045fbc..a7a04a42 100644
--- a/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
@@ -162,14 +162,14 @@ public class ScopeNode extends Node {
* @return A new node representing the merge point
*/
public Node mergeScopes(ScopeNode that) {
- RegionNode r = (RegionNode) ctrl(new RegionNode(null,ctrl(), that.ctrl()).peephole());
+ RegionNode r = (RegionNode) ctrl(new RegionNode(null,ctrl(), that.ctrl()).keep());
String[] ns = reverseNames();
// Note that we skip i==0, which is bound to '$ctrl'
for (int i = 1; i < nIns(); i++)
if( in(i) != that.in(i) ) // No need for redundant Phis
setDef(i, new PhiNode(ns[i], r, in(i), that.in(i)).peephole());
that.kill(); // Kill merged scope
- return r;
+ return r.unkeep().peephole();
}
}
diff --git a/src/main/java/com/seaofnodes/simple/node/StartNode.java b/src/main/java/com/seaofnodes/simple/node/StartNode.java
index 022e276d..6b98aed7 100644
--- a/src/main/java/com/seaofnodes/simple/node/StartNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/StartNode.java
@@ -35,4 +35,10 @@ public class StartNode extends MultiNode {
@Override
public Node idealize() { return null; }
+
+ // No immediate dominator, and idepth==0
+ @Override
+ Node idom() { return null; }
+ @Override int idepth() { return 0; }
+
}
diff --git a/src/main/java/com/seaofnodes/simple/node/StopNode.java b/src/main/java/com/seaofnodes/simple/node/StopNode.java
index a30256f9..01574dc7 100644
--- a/src/main/java/com/seaofnodes/simple/node/StopNode.java
+++ b/src/main/java/com/seaofnodes/simple/node/StopNode.java
@@ -36,6 +36,11 @@ public class StopNode extends Node {
@Override
public Node idealize() {
+ int len = nIns();
+ for( int i=0; i<nIns(); i++ )
+ if( in(i)._type==Type.XCONTROL )
+ delDef(i--);
+ if( len != nIns() ) return this;
return null;
}
diff --git a/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java b/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
index 0c2ac4b0..84ef99f2 100644
--- a/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
+++ b/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
@@ -7,7 +7,7 @@ import com.seaofnodes.simple.node.*;
import com.seaofnodes.simple.node.Node;
import java.util.ArrayList;
-/** Chapter 5's view of the IR; browser, transport and layout are shared. */
+/** Chapter 6's view of the IR; browser, transport and layout are shared. */
public class SimpleGraphAdapter extends GraphAdapter<Node> {
@Override protected boolean dead(Node n) { return n.isDead(); }
@Override protected int id(Node n) { return n._nid; }
diff --git a/src/main/java/com/seaofnodes/simple/print/SimpleGraphObserver.java b/src/main/java/com/seaofnodes/simple/print/SimpleGraphObserver.java
index a7604165..ea9a705e 100644
--- a/src/main/java/com/seaofnodes/simple/print/SimpleGraphObserver.java
+++ b/src/main/java/com/seaofnodes/simple/print/SimpleGraphObserver.java
@@ -7,7 +7,7 @@ import com.seaofnodes.simple.node.Node;
import java.util.ArrayList;
import java.io.IOException;
-/** Chapter 5's compilation context; capture and event bookkeeping are shared. */
+/** Chapter 6's compilation context; capture and event bookkeeping are shared. */
public class SimpleGraphObserver extends GraphCapture<Node> {
private Parser _parser;
private Node _ret;
diff --git a/src/main/java/com/seaofnodes/simple/type/Type.java b/src/main/java/com/seaofnodes/simple/type/Type.java
index 6b9130ba..d66fb3e7 100644
--- a/src/main/java/com/seaofnodes/simple/type/Type.java
+++ b/src/main/java/com/seaofnodes/simple/type/Type.java
@@ -25,25 +25,50 @@ public class Type {
static final byte TBOT = 0; // Bottom (ALL)
static final byte TTOP = 1; // Top (ANY)
static final byte TCTRL = 2; // Ctrl flow bottom
- static final byte TSIMPLE = 3; // End of the Simple Types
- static final byte TINT = 4; // All Integers; see TypeInteger
- static final byte TTUPLE = 5; // Tuples; finite collections of unrelated Types, kept in parallel
+ static final byte TXCTRL = 3; // Ctrl flow top (mini-lattice: any-xctrl-ctrl-all)
+ static final byte TSIMPLE = 4; // End of the Simple Types
+ static final byte TINT = 5; // All Integers; see TypeInteger
+ static final byte TTUPLE = 6; // Tuples; finite collections of unrelated Types, kept in parallel
public final byte _type;
public boolean is_simple() { return _type < TSIMPLE; }
- private static final String[] STRS = new String[]{"Bot","Top","Ctrl"};
+ private static final String[] STRS = new String[]{"Bot","Top","Ctrl","~Ctrl"};
protected Type(byte type) { _type = type; }
public static final Type BOTTOM = new Type( TBOT ); // ALL
public static final Type TOP = new Type( TTOP ); // ANY
public static final Type CONTROL = new Type( TCTRL ); // Ctrl
+ public static final Type XCONTROL = new Type( TXCTRL ); // ~Ctrl
- public boolean isConstant() { return _type == TTOP; }
+ public boolean isConstant() { return _type == TTOP || _type == TXCTRL; }
public StringBuilder print(StringBuilder sb) {return is_simple() ? sb.append(STRS[_type]) : sb;}
- public Type meet(Type other) { return BOTTOM; }
+ public final Type meet(Type t) {
+ // Shortcut for the self case
+ if( t == this ) return this;
+ // Same-type is always safe in the subclasses
+ if( _type==t._type ) return xmeet(t);
+ // Reverse; xmeet 2nd arg is never "is_simple" and never equal to "this".
+ if( is_simple() ) return this.xmeet(t );
+ if( t.is_simple() ) return t .xmeet(this);
+ return BOTTOM; // Mixing 2 unrelated types
+ }
+
+ // Compute meet right now. Overridden in subclasses.
+ // Handle cases where 'this.is_simple()' and unequal to 't'.
+ // Subclassed xmeet calls can assert that '!t.is_simple()'.
+ protected Type xmeet(Type t) {
+ assert is_simple(); // Should be overridden in subclass
+ // ANY meet anything is thing; thing meet ALL is ALL
+ if( _type==TBOT || t._type==TTOP ) return this;
+ if( _type==TTOP || t._type==TBOT ) return t;
+ // 'this' is {TCTRL,TXCTRL}
+ if( !t.is_simple() ) return BOTTOM;
+ // 't' is {TCTRL,TXCTRL}
+ return _type==TCTRL || t._type==TCTRL ? CONTROL : XCONTROL;
+ }
@Override
public final String toString() {
diff --git a/src/main/java/com/seaofnodes/simple/type/TypeInteger.java b/src/main/java/com/seaofnodes/simple/type/TypeInteger.java
index cbaff45f..a9f6ee1c 100644
--- a/src/main/java/com/seaofnodes/simple/type/TypeInteger.java
+++ b/src/main/java/com/seaofnodes/simple/type/TypeInteger.java
@@ -41,7 +41,7 @@ public class TypeInteger extends Type {
public long value() { return _con; }
@Override
- public Type meet(Type other) {
+ public Type xmeet(Type other) {
if( this==other ) return this;
if (!(other instanceof TypeInteger i)) return super.meet(other);
// BOT wins
diff --git a/src/main/java/com/seaofnodes/simple/type/TypeTuple.java b/src/main/java/com/seaofnodes/simple/type/TypeTuple.java
index da701865..39d8f72b 100644
--- a/src/main/java/com/seaofnodes/simple/type/TypeTuple.java
+++ b/src/main/java/com/seaofnodes/simple/type/TypeTuple.java
@@ -10,7 +10,7 @@ public class TypeTuple extends Type {
}
@Override
- public Type meet(Type other) {
+ public Type xmeet(Type other) {
throw new UnsupportedOperationException("Meet on Tuple Type not yet implemented");
}
@@ -24,5 +24,9 @@ public class TypeTuple extends Type {
return sb;
}
- public static final TypeTuple IF = new TypeTuple(new Type[]{Type.CONTROL,Type.CONTROL});
+ public static final TypeTuple IF_BOTH = new TypeTuple(new Type[]{Type.CONTROL, Type.CONTROL});
+ public static final TypeTuple IF_NEITHER = new TypeTuple(new Type[]{Type.XCONTROL,Type.XCONTROL});
+ public static final TypeTuple IF_TRUE = new TypeTuple(new Type[]{Type.CONTROL, Type.XCONTROL});
+ public static final TypeTuple IF_FALSE = new TypeTuple(new Type[]{Type.XCONTROL,Type.CONTROL});
+
}
diff --git a/src/test/java/com/seaofnodes/simple/Chapter06Test.java b/src/test/java/com/seaofnodes/simple/Chapter06Test.java
new file mode 100644
index 00000000..cb58f2bb
--- /dev/null
+++ b/src/test/java/com/seaofnodes/simple/Chapter06Test.java
@@ -0,0 +1,294 @@
+package com.seaofnodes.simple;
+
+import com.seaofnodes.simple.node.*;
+import com.seaofnodes.simple.type.TypeInteger;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class Chapter06Test {
+
+ @Test
+ public void testPeepholeReturn() {
+ Parser parser = new Parser(
+"""
+if( true ) return 2;
+return 1;
+""");
+ StopNode stop = parser.parse();
+ assertEquals("return 2;", stop.toString());
+ assertTrue(stop.ret().ctrl() instanceof ProjNode);
+ }
+
+ @Test
+ public void testPeepholeRotate() {
+ Parser parser = new Parser(
+"""
+int a = 1;
+if (arg)
+ a = 2;
+return (arg < a) < 3;
+""");
+ StopNode stop = parser.parse();
+ assertEquals("return ((arg<Phi(Region12,2,1))<3);", stop.toString());
+ }
+
+ @Test
+ public void testPeepholeCFG() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( true )
+ a=2;
+else
+ a=3;
+return a;
+""");
+ StopNode stop = parser.parse();
+ assertEquals("return 2;", stop.toString());
+ assertTrue(stop.ret().ctrl() instanceof ProjNode);
+ }
+
+ @Test
+ public void testIfIf() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( arg!=1 )
+ a=2;
+else
+ a=3;
+int b=4;
+if( a==2 )
+ b=42;
+else
+ b=5;
+return b;""", TypeInteger.BOT);
+ StopNode stop = parser.parse();
+ assertEquals("return Phi(Region32,42,5);", stop.toString());
+ }
+
+ @Test
+ public void testIfArgIf() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( 1==1 )
+ a=2;
+else
+ a=3;
+int b=4;
+if( arg==2 )
+ b=a;
+else
+ b=5;
+return b;""", TypeInteger.BOT);
+ StopNode stop = parser.parse();
+ assertEquals("return Phi(Region28,2,5);", stop.toString());
+ }
+
+ @Test
+ public void testMerge3With2() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( arg==1 )
+ if( arg==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+""", TypeInteger.constant(2));
+ StopNode stop = parser.parse();
+ assertEquals("return 5;", stop.toString());
+ }
+
+ @Test
+ public void testMerge3With1() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( arg==1 )
+ if( arg==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+""", TypeInteger.constant(1));
+ StopNode stop = parser.parse();
+ assertEquals("return 3;", stop.toString());
+ }
+
+ @Test
+ public void testMerge3Peephole() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( arg==1 )
+ if( 1==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+""", TypeInteger.BOT);
+ StopNode stop = parser.parse();
+ assertEquals("return Phi(Region36,3,Phi(Region34,4,5));", stop.toString());
+ }
+
+ @Test
+ public void testMerge3Peephole1() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( arg==1 )
+ if( 1==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+""", TypeInteger.constant(1));
+ StopNode stop = parser.parse();
+ assertEquals("return 3;", stop.toString());
+ }
+
+ @Test
+ public void testMerge3Peephole3() {
+ Parser parser = new Parser(
+"""
+int a=1;
+if( arg==1 )
+ if( 1==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+""", TypeInteger.constant(3));
+ StopNode stop = parser.parse();
+ assertEquals("return 4;", stop.toString());
+ }
+
+ @Test
+ public void testDemo1NonConst() {
+ Parser parser = new Parser("""
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+""");
+ StopNode ret = parser.parse();
+ assertEquals("return Phi(Region22,4,1);", ret.toString());
+ }
+
+
+ @Test
+ public void testDemo1True() {
+ Parser parser = new Parser("""
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+""", TypeInteger.constant(1));
+ StopNode ret = parser.parse();
+ assertEquals("return 4;", ret.toString());
+ }
+
+ @Test
+ public void testDemo1False() {
+ Parser parser = new Parser("""
+int a = 0;
+int b = 1;
+if( arg ) {
+ a = 2;
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b;
+""", TypeInteger.constant(0));
+ StopNode ret = parser.parse();
+ assertEquals("return 1;", ret.toString());
+ }
+
+ @Test
+ public void testDemo2NonConst() {
+ Parser parser = new Parser("""
+int a = 0;
+int b = 1;
+int c = 0;
+if( arg ) {
+ a = 1;
+ if( arg==2 ) { c=2; } else { c=3; }
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b+c;
+""");
+ StopNode ret = parser.parse();
+ assertEquals("return (Phi(Region33,Phi(Region22,2,3),0)+Phi(Region33,3,1));", ret.toString());
+ }
+
+
+ @Test
+ public void testDemo2True() {
+ Parser parser = new Parser("""
+int a = 0;
+int b = 1;
+int c = 0;
+if( arg ) {
+ a = 1;
+ if( arg==2 ) { c=2; } else { c=3; }
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b+c;
+""", TypeInteger.constant(1));
+ StopNode ret = parser.parse();
+ assertEquals("return 6;", ret.toString());
+ }
+
+ @Test
+ public void testDemo2arg2() {
+ Parser parser = new Parser("""
+int a = 0;
+int b = 1;
+int c = 0;
+if( arg ) {
+ a = 1;
+ if( arg==2 ) { c=2; } else { c=3; }
+ if( arg ) { b = 2; }
+ else b = 3;
+}
+return a+b+c;
+""", TypeInteger.constant(2));
+ StopNode ret = parser.parse();
+ assertEquals("return 5;", ret.toString());
+ }
+
+}