[Mesa-dev] [PATCH 07/10] nir: return early when lowering a return at the end of a function
Jason Ekstrand
jason at jlekstrand.net
Tue Apr 17 02:32:27 UTC 2018
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
On Mon, Apr 9, 2018 at 9:34 PM, Timothy Arceri <tarceri at itsqueeze.com>
wrote:
> Otherwise we create unused conditional return flags and things
> get unnecessarily ugly fast when lowering nested functions.
> ---
> src/compiler/nir/nir_lower_returns.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/src/compiler/nir/nir_lower_returns.c
> b/src/compiler/nir/nir_lower_returns.c
> index 423192adb8a..e1ba5f2ad64 100644
> --- a/src/compiler/nir/nir_lower_returns.c
> +++ b/src/compiler/nir/nir_lower_returns.c
> @@ -27,6 +27,7 @@
>
> struct lower_returns_state {
> nir_builder builder;
> + nir_function_impl *impl;
>
I think we could avoid this by looking at block->node.parent. Meh.
> struct exec_list *cf_list;
> nir_loop *loop;
> nir_variable *return_flag;
> @@ -180,6 +181,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->impl))
> + return true;
> +
> nir_builder *b = &state->builder;
>
> /* Set the return flag */
> @@ -252,6 +259,7 @@ nir_lower_returns_impl(nir_function_impl *impl)
> {
> struct lower_returns_state state;
>
> + state.impl = impl;
> state.cf_list = &impl->body;
> state.loop = NULL;
> state.return_flag = NULL;
> --
> 2.17.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180416/afdc48cd/attachment-0001.html>
More information about the mesa-dev
mailing list