Module: Mesa
Branch: master
Commit: 6e22ad6edc34dc07a08b41a781f1c37ff3c536e7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e22ad6edc34dc07a08b41a781f1c37ff3c536e7

Author: Timothy Arceri <tarc...@itsqueeze.com>
Date:   Sun Apr  8 21:47:32 2018 +1000

nir: return early when lowering a return at the end of a function

Otherwise we create unused conditional return flags and things
get unnecessarily ugly fast when lowering nested functions.

Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

---

 src/compiler/nir/nir_lower_returns.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/compiler/nir/nir_lower_returns.c 
b/src/compiler/nir/nir_lower_returns.c
index 423192adb8..3ea69e2520 100644
--- a/src/compiler/nir/nir_lower_returns.c
+++ b/src/compiler/nir/nir_lower_returns.c
@@ -180,6 +180,12 @@ lower_returns_in_block(nir_block *block, struct 
lower_returns_state *state)
 
    nir_instr_remove(&jump->instr);
 
+   /* If this is a return in the last block of the function there is nothing
+    * more to do once its removed.
+    */
+   if (block == nir_impl_last_block(state->builder.impl))
+      return true;
+
    nir_builder *b = &state->builder;
 
    /* Set the return flag */

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to