diff options
author | Rob Clark <[email protected]> | 2019-06-20 16:31:00 +0000 |
---|---|---|
committer | Kristian H. Kristensen <[email protected]> | 2020-02-07 09:51:25 -0800 |
commit | 3eca6d9ce14abfc542031248be6a53c31cd113f9 (patch) | |
tree | e6f550e1c0b86586fadfd4a6d700a60e430cc83b | |
parent | 5e2012d5c7496d04772c83e89d9fa1c9bc4087e2 (diff) |
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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3737>
-rw-r--r-- | src/freedreno/ir3/ir3.h | 19 | ||||
-rw-r--r-- | src/freedreno/ir3/ir3_cp.c | 2 |
2 files changed, 20 insertions, 1 deletions
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: */ |