[Mesa-dev] [PATCH 5/5] i965/nir: use vectorization for non-scalar stages
Connor Abbott
cwabbott0 at gmail.com
Sat Nov 14 18:59:44 PST 2015
Shader-db results on bdw with INTEL_DEBUG=vec4:
total instructions in shared programs: 1634044 -> 1612936 (-1.29%)
instructions in affected programs: 802502 -> 781394 (-2.63%)
helped: 5036
HURT: 1442
total cycles in shared programs: 9397790 -> 9355382 (-0.45%)
cycles in affected programs: 5078600 -> 5036192 (-0.84%)
helped: 3875
HURT: 2554
LOST: 0
GAINED: 0
Most of the hurt programs seem to be because we generate extra MOV's due
to vectorizing things. For example, in
shaders/non-free/steam/anomaly-2/158.shader_test, this:
add(8) g116<1>.xyF g12<4,4,1>.xyyyF g1.4<0,4,1>.xyyyF { align16 NoDDClr 1Q };
add(8) g117<1>.xyF g12<4,4,1>.xyyyF g1.4<0,4,1>.zwwwF { align16 NoDDClr 1Q };
add(8) g116<1>.zwF g12<4,4,1>.xxxyF -g1.4<0,4,1>.xxxyF { align16 NoDDChk 1Q };
add(8) g117<1>.zwF g12<4,4,1>.xxxyF -g1.4<0,4,1>.zzzwF { align16 NoDDChk 1Q };
Turns into this:
add(8) g13<1>F g12<4,4,1>.xyxyF g1.4<0,4,1>F { align16 1Q };
add(8) g14<1>F g12<4,4,1>.xyxyF -g1.4<0,4,1>F { align16 1Q };
mov(8) g116<1>.xyD g13<4,4,1>.xyyyD { align16 NoDDClr 1Q };
mov(8) g117<1>.xyD g13<4,4,1>.zwwwD { align16 NoDDClr 1Q };
mov(8) g116<1>.zwD g14<4,4,1>.xxxyD { align16 NoDDChk 1Q };
mov(8) g117<1>.zwD g14<4,4,1>.zzzwD { align16 NoDDChk 1Q };
So we eliminated two add's, but then had to introduce four mov's to
transpose the result. I don't think there's much we can do about this at
the NIR level, unfortunately.
Signed-off-by: Connor Abbott <cwabbott0 at gmail.com>
---
src/mesa/drivers/dri/i965/brw_nir.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c
index fe5cad4..29cafe6 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -198,6 +198,14 @@ nir_optimize(nir_shader *nir, bool is_scalar)
nir_validate_shader(nir);
progress |= nir_opt_cse(nir);
nir_validate_shader(nir);
+
+ if (!is_scalar) {
+ progress |= nir_opt_vectorize(nir);
+ nir_validate_shader(nir);
+ progress |= nir_copy_prop(nir);
+ nir_validate_shader(nir);
+ }
+
progress |= nir_opt_peephole_select(nir);
nir_validate_shader(nir);
progress |= nir_opt_algebraic(nir);
--
2.4.3
More information about the mesa-dev
mailing list