Mesa (master): freedreno/ir3: fold const conversion into consumer
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Feb 7 18:19:36 UTC 2020
Module: Mesa
Branch: master
Commit: 3eca6d9ce14abfc542031248be6a53c31cd113f9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3eca6d9ce14abfc542031248be6a53c31cd113f9
Author: Rob Clark <robdclark at chromium.org>
Date: Thu Jun 20 16:31:00 2019 +0000
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 <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3737>
---
src/freedreno/ir3/ir3.h | 19 +++++++++++++++++++
src/freedreno/ir3/ir3_cp.c | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
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: */
More information about the mesa-commit
mailing list