summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2018-03-06 11:20:28 -0500
committerSteven Perron <stevenperron@google.com>2018-03-19 13:49:04 -0400
commitb3daa93b46625a8122585d508a953fce868b6ee3 (patch)
treea5f1c8d940cd6759c625eae56e04d366fa55e6a1 /include
parent1ef6b192602129d112112eb2e611a27e7b3cc6e7 (diff)
Change merge return pass to handle structured cfg.
We are seeing shaders that have multiple returns in a functions. These functions must get inlined for legalization purposes; however, the inliner does not know how to inline functions that have multiple returns. The solution we will go with it to improve the merge return pass to handle structured control flow. Note that the merge return pass will assume the cfg has been cleanedup by dead branch elimination. Fixes #857.
Diffstat (limited to 'include')
-rw-r--r--include/spirv-tools/optimizer.hpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/include/spirv-tools/optimizer.hpp b/include/spirv-tools/optimizer.hpp
index 03eb1c29..d0907ac2 100644
--- a/include/spirv-tools/optimizer.hpp
+++ b/include/spirv-tools/optimizer.hpp
@@ -453,16 +453,19 @@ Optimizer::PassToken CreateCFGCleanupPass();
// that are not referenced.
Optimizer::PassToken CreateDeadVariableEliminationPass();
-// Create merge return pass.
-// This pass replaces all returns with unconditional branches to a new block
-// containing a return. If necessary, this new block will contain a PHI node to
-// select the correct return value.
+// create merge return pass.
+// changes functions that have multiple return statements so they have a single
+// return statement.
//
-// This pass does not consider unreachable code, nor does it perform any other
-// optimizations.
+// for structured control flow it is assumed that the only unreachable blocks in
+// the function are trivial merge and continue blocks.
//
-// This pass does not currently support structured control flow. It bails out if
-// the shader capability is detected.
+// a trivial merge block contains the label and an opunreachable instructions,
+// nothing else. a trivial continue block contain a label and an opbranch to
+// the header, nothing else.
+//
+// these conditions are guaranteed to be met after running dead-branch
+// elimination.
Optimizer::PassToken CreateMergeReturnPass();
// Create value numbering pass.