[Mesa-dev] [PATCH] nir: split out lower_sub from lower_negate
Rob Clark
robdclark at gmail.com
Sat Apr 4 05:19:02 PDT 2015
From: Rob Clark <robclark at freedesktop.org>
Originally you had to have one or the other. But actually I don't want
either. (Or rather I want whatever is the minimum # of instructions.)
TODO: not sure where the best place to insert a check that driver hasn't
set *both* lower_negate and lower_sub?
Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
src/glsl/nir/nir.h | 2 ++
src/glsl/nir/nir_opt_algebraic.py | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 6f53052..84104de 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1371,6 +1371,8 @@ typedef struct nir_shader_compiler_options {
bool lower_fsqrt;
/** lowers fneg and ineg to fsub and isub. */
bool lower_negate;
+ /** lowers fsub and isub to fadd+fneg and iadd+ineg. */
+ bool lower_sub;
/* lower {slt,sge,seq,sne} to {flt,fge,feq,fne} + b2f: */
bool lower_scmp;
diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index a8c1745..319732d 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -192,8 +192,8 @@ optimizations = [
# Subtracts
(('fsub', a, ('fsub', 0.0, b)), ('fadd', a, b)),
(('isub', a, ('isub', 0, b)), ('iadd', a, b)),
- (('fsub', a, b), ('fadd', a, ('fneg', b)), '!options->lower_negate'),
- (('isub', a, b), ('iadd', a, ('ineg', b)), '!options->lower_negate'),
+ (('fsub', a, b), ('fadd', a, ('fneg', b)), 'options->lower_sub'),
+ (('isub', a, b), ('iadd', a, ('ineg', b)), 'options->lower_sub'),
(('fneg', a), ('fsub', 0.0, a), 'options->lower_negate'),
(('ineg', a), ('isub', 0, a), 'options->lower_negate'),
(('fadd', a, ('fsub', 0.0, b)), ('fsub', a, b)),
--
2.1.0
More information about the mesa-dev
mailing list