Mesa (main): nir: Use nir_vector_extract to generate code for ir_binop_vector_extract

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 16 16:50:11 UTC 2022


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Jan 14 13:44:31 2022 -0800

nir: Use nir_vector_extract to generate code for ir_binop_vector_extract

Tiger Lake and Ice Lake had similar results. (Ice Lake shown)
total cycles in shared programs: 861153442 -> 861153533 (<.01%)
cycles in affected programs: 14748 -> 14839 (0.62%)
helped: 5
HURT: 10
helped stats (abs) min: 1 max: 2 x̄: 1.80 x̃: 2
helped stats (rel) min: 0.09% max: 0.18% x̄: 0.16% x̃: 0.17%
HURT stats (abs)   min: 2 max: 18 x̄: 10.00 x̃: 10
HURT stats (rel)   min: 0.17% max: 1.54% x̄: 1.06% x̃: 1.24%
95% mean confidence interval for cycles value: 1.15 10.99
95% mean confidence interval for cycles %-change: 0.25% 1.07%
Cycles are HURT.

Skylake and Broadwell had similar results. (Skylake shown)
total cycles in shared programs: 844405063 -> 844405073 (<.01%)
cycles in affected programs: 1710 -> 1720 (0.58%)
helped: 0
HURT: 4
HURT stats (abs)   min: 2 max: 4 x̄: 2.50 x̃: 2
HURT stats (rel)   min: 0.35% max: 1.16% x̄: 0.88% x̃: 1.00%
95% mean confidence interval for cycles value: 0.91 4.09
95% mean confidence interval for cycles %-change: 0.30% 1.45%
Cycles are HURT.

Haswell and all earlier Intel GPUs had similar results. (Haswell shown)
total instructions in shared programs: 16710016 -> 16709769 (<.01%)
instructions in affected programs: 5842 -> 5595 (-4.23%)
helped: 64
HURT: 0
helped stats (abs) min: 3 max: 4 x̄: 3.86 x̃: 4
helped stats (rel) min: 3.36% max: 7.69% x̄: 4.52% x̃: 4.17%
95% mean confidence interval for instructions value: -3.95 -3.77
95% mean confidence interval for instructions %-change: -4.83% -4.22%
Instructions are helped.

total cycles in shared programs: 881088472 -> 881086722 (<.01%)
cycles in affected programs: 68696 -> 66946 (-2.55%)
helped: 58
HURT: 6
helped stats (abs) min: 10 max: 202 x̄: 36.41 x̃: 18
helped stats (rel) min: 0.81% max: 16.42% x̄: 4.15% x̃: 1.51%
HURT stats (abs)   min: 2 max: 88 x̄: 60.33 x̃: 68
HURT stats (rel)   min: 0.17% max: 7.06% x̄: 4.94% x̃: 5.60%
95% mean confidence interval for cycles value: -42.14 -12.54
95% mean confidence interval for cycles %-change: -4.66% -1.94%
Cycles are helped.

No fossil-db changes on any Intel platform.

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16440>

---

 src/compiler/glsl/glsl_to_nir.cpp        | 10 ++--------
 src/mesa/state_tracker/st_glsl_to_ir.cpp |  2 +-
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 601b87fc2ad..536bedd316b 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -2329,15 +2329,9 @@ nir_visitor::visit(ir_expression *ir)
    case ir_binop_dot:
       result = nir_fdot(&b, srcs[0], srcs[1]);
       break;
-   case ir_binop_vector_extract: {
-      result = nir_channel(&b, srcs[0], 0);
-      for (unsigned i = 1; i < ir->operands[0]->type->vector_elements; i++) {
-         nir_ssa_def *swizzled = nir_channel(&b, srcs[0], i);
-         result = nir_bcsel(&b, nir_ieq_imm(&b, srcs[1], i),
-                            swizzled, result);
-      }
+   case ir_binop_vector_extract:
+      result = nir_vector_extract(&b, srcs[0], srcs[1]);
       break;
-   }
 
    case ir_binop_atan2:
       result = nir_atan2(&b, srcs[0], srcs[1]);
diff --git a/src/mesa/state_tracker/st_glsl_to_ir.cpp b/src/mesa/state_tracker/st_glsl_to_ir.cpp
index d2bc5e604e2..130f8c82682 100644
--- a/src/mesa/state_tracker/st_glsl_to_ir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_ir.cpp
@@ -130,7 +130,7 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                             IMUL_HIGH_TO_MUL
                           : 0));
 
-      do_vec_index_to_cond_assign(ir, true);
+      do_vec_index_to_cond_assign(ir, false);
       lower_vector_insert(ir, true);
       if (options->MaxIfDepth == 0) {
          lower_discard(ir);



More information about the mesa-commit mailing list