nir: introduce new nir_alu_alu_width() with nir_vectorize_cb callback

This function allows to only scalarize instructions down to a desired
vectorization width. nir_lower_alu_to_scalar() was changed to use the
new function with a width of 1.

Swizzles outside vectorization width are considered and reduce
the target width.

This prevents ending up with code like
  vec2 16 ssa_2 = iadd ssa_0.xz, ssa_1.xz

which requires to emit shuffle code in backends
and usually is not beneficial.

Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13080>
This commit is contained in:
Daniel Schürmann
2021-07-06 19:08:04 +02:00
committed by Marge Bot
parent bd151a256e
commit be01e8711b
3 changed files with 108 additions and 26 deletions

View File

@@ -128,7 +128,7 @@ files_libnir = files(
'nir_loop_analyze.c',
'nir_loop_analyze.h',
'nir_lower_alu.c',
'nir_lower_alu_to_scalar.c',
'nir_lower_alu_width.c',
'nir_lower_alpha_test.c',
'nir_lower_amul.c',
'nir_lower_array_deref_of_vec.c',