nir_to_tgsi: Remove the abs on fcsel's bool src.

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 <zboszor@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12921>
This commit is contained in:
Emma Anholt 2021-09-17 19:50:12 -07:00 committed by Marge Bot
parent 4b0975a8e1
commit ae01d856de
3 changed files with 5 additions and 12 deletions

View file

@ -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

View file

@ -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

View file

@ -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