From 43302ead3830f423d7588596cf2e0dd9340edff6 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 5 Jan 2021 18:36:09 +0100 Subject: [PATCH] zink: use lower_scmp instead of open-coding We already have the proper lowering in NIR for this, so there's no point in doing our own implementations of these. The end result is the same code anyway. Reviewed-By: Mike Blumenkrantz Part-of: --- .../drivers/zink/nir_to_spirv/nir_to_spirv.c | 37 +------------------ src/gallium/drivers/zink/zink_compiler.c | 1 + 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 30eafa6b833..0a2c2605b57 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -1423,44 +1423,11 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) break; case nir_op_fdph: - unreachable("should already be lowered away"); - case nir_op_seq: case nir_op_sne: case nir_op_slt: - case nir_op_sge: { - assert(nir_op_infos[alu->op].num_inputs == 2); - int num_components = nir_dest_num_components(alu->dest.dest); - SpvId bool_type = get_bvec_type(ctx, num_components); - - SpvId zero = emit_float_const(ctx, bit_size, 0.0f); - SpvId one = emit_float_const(ctx, bit_size, 1.0f); - if (num_components > 1) { - SpvId zero_comps[num_components], one_comps[num_components]; - for (int i = 0; i < num_components; i++) { - zero_comps[i] = zero; - one_comps[i] = one; - } - - zero = spirv_builder_const_composite(&ctx->builder, dest_type, - zero_comps, num_components); - one = spirv_builder_const_composite(&ctx->builder, dest_type, - one_comps, num_components); - } - - SpvOp op; - switch (alu->op) { - case nir_op_seq: op = SpvOpFOrdEqual; break; - case nir_op_sne: op = SpvOpFOrdNotEqual; break; - case nir_op_slt: op = SpvOpFOrdLessThan; break; - case nir_op_sge: op = SpvOpFOrdGreaterThanEqual; break; - default: unreachable("unexpected op"); - } - - result = emit_binop(ctx, op, bool_type, src[0], src[1]); - result = emit_select(ctx, dest_type, result, one, zero); - } - break; + case nir_op_sge: + unreachable("should already be lowered away"); case nir_op_flrp: assert(nir_op_infos[alu->op].num_inputs == 3); diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 4f4de8dfff2..b286f625386 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -207,6 +207,7 @@ static const struct nir_shader_compiler_options nir_options = { .lower_ffma16 = true, .lower_ffma32 = true, .lower_ffma64 = true, + .lower_scmp = true, .lower_fdph = true, .lower_flrp32 = true, .lower_fpow = true,