From da294f9b2f666f487001b2a25627c867c40eb3d9 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 23 Mar 2015 17:11:49 -0700 Subject: [PATCH] nir/algebraic: Add a seperate section for "late" optimizations i965/nir: Use the late optimizations Reviewed-by: Matt Turner --- src/glsl/nir/nir.h | 1 + src/glsl/nir/nir_opt_algebraic.py | 9 +++++++++ src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 3 +++ 3 files changed, 13 insertions(+) diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 7b886e3d36f..24deb82d2e7 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1613,6 +1613,7 @@ void nir_convert_to_ssa(nir_shader *shader); void nir_convert_from_ssa(nir_shader *shader); bool nir_opt_algebraic(nir_shader *shader); +bool nir_opt_algebraic_late(nir_shader *shader); bool nir_opt_constant_folding(nir_shader *shader); bool nir_opt_global_to_local(nir_shader *shader); diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index ddf78be7721..2079235b351 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -195,4 +195,13 @@ for op in ['flt', 'fge', 'feq', 'fne', ('bcsel', 'a', (op, 'd', 'b'), (op, 'd', 'c'))), ] +# This section contains "late" optimizations that should be run after the +# regular optimizations have finished. Optimizations should go here if +# they help code generation but do not necessarily produce code that is +# more easily optimizable. +late_optimizations = [ +] + print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render() +print nir_algebraic.AlgebraicPass("nir_opt_algebraic_late", + late_optimizations).render() diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 21e52fe0e45..204e713ea55 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -147,6 +147,9 @@ fs_visitor::emit_nir_code() nir_optimize(nir); + nir_opt_algebraic_late(nir); + nir_validate_shader(nir); + nir_lower_locals_to_regs(nir); nir_validate_shader(nir); -- 2.30.2