Mesa (main): nir: Add optional lowering for mul_32x16.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 1 17:59:53 UTC 2022


Module: Mesa
Branch: main
Commit: bfc25d6ec9f34329792d74934cc588e9ad0563c7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bfc25d6ec9f34329792d74934cc588e9ad0563c7

Author: Georg Lehmann <dadschoorse at gmail.com>
Date:   Fri Nov 19 22:38:30 2021 +0100

nir: Add optional lowering for mul_32x16.

Signed-off-by: Georg Lehmann <dadschoorse at gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13895>

---

 src/compiler/nir/nir.h                | 6 ++++++
 src/compiler/nir/nir_opt_algebraic.py | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 520f906be84..7f7ed57b366 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3455,6 +3455,12 @@ typedef struct nir_shader_compiler_options {
     */
    bool lower_iadd_sat;
 
+   /**
+    * Set if imul_32x16 and umul_32x16 should be lowered to simple
+    * arithmetic.
+    */
+   bool lower_mul_32x16;
+
    /**
     * Should IO be re-vectorized?  Some scalar ISAs still operate on vec4's
     * for IO purposes and would prefer loads/stores be vectorized.
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index b399e005335..c851cd76c72 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1685,6 +1685,9 @@ optimizations.extend([
    (('irhadd at 64', a, b), ('isub', ('ior', a, b), ('ishr', ('ixor', a, b), 1)), 'options->lower_hadd64 || (options->lower_int64_options & nir_lower_iadd64) != 0'),
    (('urhadd at 64', a, b), ('isub', ('ior', a, b), ('ushr', ('ixor', a, b), 1)), 'options->lower_hadd64 || (options->lower_int64_options & nir_lower_iadd64) != 0'),
 
+   (('imul_32x16', a, b), ('imul', a, ('extract_i16', b, 0)), 'options->lower_mul_32x16'),
+   (('umul_32x16', a, b), ('imul', a, ('extract_u16', b, 0)), 'options->lower_mul_32x16'),
+
    (('uadd_sat at 64', a, b), ('bcsel', ('ult', ('iadd', a, b), a), -1, ('iadd', a, b)), 'options->lower_uadd_sat || (options->lower_int64_options & nir_lower_iadd64) != 0'),
    (('uadd_sat', a, b), ('bcsel', ('ult', ('iadd', a, b), a), -1, ('iadd', a, b)), 'options->lower_uadd_sat'),
    (('usub_sat', a, b), ('bcsel', ('ult', a, b), 0, ('isub', a, b)), 'options->lower_uadd_sat'),



More information about the mesa-commit mailing list