From 7174d155e9b2d3ecc1d60f71e202838fa9359f1d Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 4 Sep 2015 18:47:42 -0700 Subject: [PATCH] nir: Add a lower_fdiv option and use it in i965 --- src/glsl/nir/nir.h | 1 + src/glsl/nir/nir_opt_algebraic.py | 1 + src/mesa/drivers/dri/i965/brw_shader.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 4c60dbd645a..415dda7712d 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1433,6 +1433,7 @@ typedef struct nir_function { typedef struct nir_shader_compiler_options { bool lower_ffma; + bool lower_fdiv; bool lower_flrp; bool lower_fpow; bool lower_fsat; diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index 226e0a8d85c..880408bc367 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -66,6 +66,7 @@ optimizations = [ (('imul', a, 1), a), (('fmul', a, -1.0), ('fneg', a)), (('imul', a, -1), ('ineg', a)), + (('fdiv', a, b), ('fmul', a, ('frcp', b)), 'options->lower_fdiv'), (('ffma', 0.0, a, b), b), (('ffma', a, 0.0, b), b), (('ffma', a, b, 0.0), ('fmul', a, b)), diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 0007e5c07a5..4ef2777559f 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -96,6 +96,7 @@ brw_compiler_create(void *mem_ctx, const struct brw_device_info *devinfo) */ nir_options->lower_ffma = true; nir_options->lower_sub = true; + nir_options->lower_fdiv = true; /* We want the GLSL compiler to emit code that uses condition codes */ for (int i = 0; i < MESA_SHADER_STAGES; i++) { -- 2.30.2