summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Arceri <tarceri@itsqueeze.com>2018-04-03 11:38:13 +1000
committerJuan A. Suarez Romero <jasuarez@igalia.com>2018-04-12 21:49:31 +0200
commit1ec916659831ac1da1b31475bfe18422275ba76d (patch)
treee10a8a6c5f292c492490086d04cf4dae58757586
parentf1604f69c20d85d7e3e112ecf7a373d6143094aa (diff)
glsl: always call do_lower_jumps() after loop unrolling
This fixes a bug in radeonsi where LLVM cannot handle the case where a break exists but its not the last instruction in the block. LLVM would fail with: Terminator found in the middle of a basic block! LLVM ERROR: Broken function found, compilation aborted! Fixes: 96fe8834f539 "glsl_to_tgsi: do fewer optimizations with GLSLOptimizeConservatively" Reviewed-by: Matt Turner <mattst88@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105317 (cherry picked from commit b42633db8e3711e54a5bd10495b1436b8e362801)
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 59821732b98..98e4b64747b 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -2239,6 +2239,24 @@ do_common_optimization(exec_list *ir, bool linked,
loop_progress = false;
loop_progress |= do_constant_propagation(ir);
loop_progress |= do_if_simplification(ir);
+
+ /* Some drivers only call do_common_optimization() once rather
+ * than in a loop. So we must call do_lower_jumps() after
+ * unrolling a loop because for drivers that use LLVM validation
+ * will fail if a jump is not the last instruction in the block.
+ * For example the following will fail LLVM validation:
+ *
+ * (loop (
+ * ...
+ * break
+ * (assign (x) (var_ref v124) (expression int + (var_ref v124)
+ * (constant int (1)) ) )
+ * ))
+ */
+ loop_progress |= do_lower_jumps(ir, true, true,
+ options->EmitNoMainReturn,
+ options->EmitNoCont,
+ options->EmitNoLoops);
}
progress |= loop_progress;
}