From 72c1e3a66a7ead84e0b895a7bb11d5501238a013 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 21 May 2020 12:31:40 -0400 Subject: [PATCH] pan/mdg: Promote imov to fmov on a NIR level Avoids dedicated MIR promote_fmov pass which is unnecessary. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_compile.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 1d6d4a04fca..ed9452c20c2 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -961,6 +961,14 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) return; } + /* Promote imov to fmov if it might help inline a constant */ + if (op == midgard_alu_op_imov && nir_src_is_const(instr->src[0].src) + && nir_src_bit_size(instr->src[0].src) == 32 + && nir_is_same_comp_swizzle(instr->src[0].swizzle, + nir_src_num_components(instr->src[0].src))) { + op = midgard_alu_op_fmov; + } + /* Midgard can perform certain modifiers on output of an ALU op */ unsigned outmod = 0; @@ -2632,7 +2640,6 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b mir_foreach_block(ctx, _block) { midgard_block *block = (midgard_block *) _block; inline_alu_constants(ctx, block); - midgard_opt_promote_fmov(ctx, block); embedded_to_inline_constant(ctx, block); } /* MIR-level optimizations */ -- 2.30.2