From ae01d856de18b698bc94ff1e6f4bbd5ea18b230d Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Fri, 17 Sep 2021 19:50:12 -0700 Subject: [PATCH] nir_to_tgsi: Remove the abs on fcsel's bool src. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the nir fcsel opcode specifies src0 != 0.0, as the comment says, it's only ever used on bools-as-floats, so we know that src0 is non-negative. This saves an instruction per CMP on i915. Reviewed-by: Zoltán Böszörményi Reviewed-by: Rob Clark Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 8 +++++--- src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt | 3 --- src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt | 6 ------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index c30718215fc..aaa5cd43d4d 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -1123,10 +1123,12 @@ ntt_emit_alu(struct ntt_compile *c, nir_alu_instr *instr) /* NIR is src0 != 0 ? src1 : src2. * TGSI is src0 < 0 ? src1 : src2. * - * However, fcsel so far as I can find only appears on - * bools-as-floats (1.0 or 0.0), so we can negate it for the TGSI op. + * However, fcsel so far as I can find only appears on bools-as-floats + * (1.0 or 0.0), so we can just negate it for the TGSI op. It's + * important to not have an abs here, as i915g has to make extra + * instructions to do the abs. */ - ureg_CMP(c->ureg, dst, ureg_negate(ureg_abs(src[0])), src[1], src[2]); + ureg_CMP(c->ureg, dst, ureg_negate(src[0]), src[1], src[2]); break; /* It would be nice if we could get this left as scalar in NIR, since diff --git a/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt b/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt index 4cd540a76e1..52277428cbc 100644 --- a/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt +++ b/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt @@ -56,15 +56,12 @@ dEQP-GLES2.functional.shaders.functions.control_flow.return_in_loop_if_fragment, dEQP-GLES2.functional.shaders.functions.control_flow.return_in_nested_loop_fragment,Fail dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat4_dynamic_write_dynamic_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.tmp_array.float_const_write_dynamic_read_fragment,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.float_dynamic_write_dynamic_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.tmp_array.vec2_const_write_dynamic_read_fragment,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec2_dynamic_write_dynamic_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.tmp_array.vec3_const_write_dynamic_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.tmp_array.vec3_dynamic_write_dynamic_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_const_write_dynamic_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_dynamic_write_dynamic_read_fragment,Fail -dEQP-GLES2.functional.shaders.indexing.vector_subscript.vec3_dynamic_subscript_write_dynamic_subscript_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.vector_subscript.vec4_dynamic_subscript_write_static_loop_subscript_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.vector_subscript.vec4_dynamic_subscript_write_component_read_fragment,Fail dEQP-GLES2.functional.shaders.indexing.vector_subscript.vec4_dynamic_subscript_write_direct_read_fragment,Fail diff --git a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt index 42b01068324..11b1be0cdc2 100644 --- a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt +++ b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt @@ -596,8 +596,6 @@ spec@ext_texture_srgb@texwrap formats-s3tc bordercolor@GL_COMPRESSED_SRGB_S3TC_D # that uses dynamic loops spec@ext_timer_query@time-elapsed,Fail -spec@glsl-1.10@execution@built-in-functions@fs-atan-vec3-vec3,Fail -spec@glsl-1.10@execution@built-in-functions@fs-atan-vec4-vec4,Fail spec@glsl-1.10@execution@built-in-functions@fs-degrees-float,Fail spec@glsl-1.10@execution@built-in-functions@fs-degrees-vec2,Fail spec@glsl-1.10@execution@built-in-functions@fs-degrees-vec3,Fail @@ -857,7 +855,6 @@ spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat3-index-row-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat4-index-col-row-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat4-index-col-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat4-index-row-wr,Fail -spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat4-index-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-uniform-array-mat4-index-col-row-rd,Fail spec@glsl-1.10@execution@variable-indexing@fs-varying-array-mat3-index-col-rd,Fail spec@glsl-1.10@execution@variable-indexing@fs-varying-array-mat3-index-col-row-rd,Fail @@ -1070,8 +1067,6 @@ spec@glsl-1.20@execution@uniform-initializer@fs-mat4,Fail spec@glsl-1.20@execution@uniform-initializer@fs-mat4-array,Fail spec@glsl-1.20@execution@uniform-initializer@fs-mat4-from-const,Fail spec@glsl-1.20@execution@uniform-initializer@fs-mat4-set-by-other-stage,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat2-index-col-wr,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat2-index-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat2-index-col-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat3-index-col-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat3-index-col-wr,Fail @@ -1079,7 +1074,6 @@ spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat3-index-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-col-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-col-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-row-wr,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-uniform-array-mat4-index-col-row-rd,Fail spec@glsl-1.20@execution@variable-indexing@fs-varying-array-mat3-index-col-rd,Fail spec@glsl-1.20@execution@variable-indexing@fs-varying-array-mat3-index-col-row-rd,Fail