summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-01-05 05:09:46 -0800
committerKenneth Graunke <[email protected]>2016-01-05 19:22:11 -0800
commit7295f4fcc2b2dd1bc6a8d1d834774b8152a029cf (patch)
tree948332ade1aa90a7ed959f4d5e44edeaa8cfbf0b /src/glsl
parentbd21b54607615605b6335282029687bb0885f4ad (diff)
nir: Add a lower_fdiv option, turn fdiv into fmul/frcp.
The nir_opt_algebraic rule (('fadd', ('flog2', a), ('fneg', ('flog2', b))), ('flog2', ('fdiv', a, b))), can produce new fdiv operations, which need to be lowered on i965, as we don't actually implement fdiv. (Normally, we handle this in GLSL IR's lower_instructions pass, but in the above case we introduce an fdiv after that point. So, make NIR do it for us.) Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: [email protected]
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/nir.h1
-rw-r--r--src/glsl/nir/nir_opt_algebraic.py1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 42867382544..fed8a973416 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1440,6 +1440,7 @@ typedef struct nir_function {
} nir_function;
typedef struct nir_shader_compiler_options {
+ bool lower_fdiv;
bool lower_ffma;
bool lower_flrp;
bool lower_fpow;
diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 1fdad3d78a6..c553de577ee 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -183,6 +183,7 @@ optimizations = [
(('fmul', ('fexp2', a), ('fexp2', b)), ('fexp2', ('fadd', a, b))),
# Division and reciprocal
(('fdiv', 1.0, a), ('frcp', a)),
+ (('fdiv', a, b), ('fmul', a, ('frcp', b)), 'options->lower_fdiv'),
(('frcp', ('frcp', a)), a),
(('frcp', ('fsqrt', a)), ('frsq', a)),
(('fsqrt', a), ('frcp', ('frsq', a)), 'options->lower_fsqrt'),