From 6e22ad6edc34dc07a08b41a781f1c37ff3c536e7 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Sun, 8 Apr 2018 21:47:32 +1000 Subject: [PATCH] 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 --- 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 423192adb8a..3ea69e25204 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 */ -- 2.30.2