From: Rob Clark Date: Thu, 20 Jun 2019 16:31:00 +0000 (+0000) Subject: freedreno/ir3: fold const conversion into consumer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3eca6d9ce14abfc542031248be6a53c31cd113f9;p=mesa.git freedreno/ir3: fold const conversion into consumer A sequence like: (nop3)cov.f32f16 hr0.x, c0.x mul.f hr4.y, hr1.z, hr0.x can be turned into: mul.f hr4.y, hr1.z, hc0.x Signed-off-by: Rob Clark Part-of: --- diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h index 6c286dcd7dd..fbe28ac3cc1 100644 --- a/src/freedreno/ir3/ir3.h +++ b/src/freedreno/ir3/ir3.h @@ -695,6 +695,25 @@ static inline bool is_same_type_mov(struct ir3_instruction *instr) return true; } +/* A move from const, which changes size but not type, can also be + * folded into dest instruction in some cases. + */ +static inline bool is_const_mov(struct ir3_instruction *instr) +{ + if (instr->opc != OPC_MOV) + return false; + + if (!(instr->regs[1]->flags & IR3_REG_CONST)) + return false; + + type_t src_type = instr->cat1.src_type; + type_t dst_type = instr->cat1.dst_type; + + return (type_float(src_type) && type_float(dst_type)) || + (type_uint(src_type) && type_uint(dst_type)) || + (type_sint(src_type) && type_sint(dst_type)); +} + static inline bool is_alu(struct ir3_instruction *instr) { return (1 <= opc_cat(instr->opc)) && (opc_cat(instr->opc) <= 3); diff --git a/src/freedreno/ir3/ir3_cp.c b/src/freedreno/ir3/ir3_cp.c index 28c9f82f3ae..b7fb86ec791 100644 --- a/src/freedreno/ir3/ir3_cp.c +++ b/src/freedreno/ir3/ir3_cp.c @@ -463,7 +463,7 @@ reg_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr, return true; } - } else if (is_same_type_mov(src) && + } else if ((is_same_type_mov(src) || is_const_mov(src)) && /* cannot collapse const/immed/etc into meta instrs: */ !is_meta(instr)) { /* immed/const/etc cases, which require some special handling: */