From: Alyssa Rosenzweig Date: Sat, 21 Mar 2020 22:12:31 +0000 (-0400) Subject: pan/bi: Add `soft` NIR->BIR condition translation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5a02c871f2367abf7d87569819d7ae4ebb1336d4;p=mesa.git pan/bi: Add `soft` NIR->BIR condition translation We would like to use this routine opportunistically when fusing conditions into csels and branches, so let's add a mode where we don't abort. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 43b44314fec..5d7604ecad3 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -411,8 +411,13 @@ bi_class_for_nir_alu(nir_op op) } } +/* Gets a bi_cond for a given NIR comparison opcode. In soft mode, it will + * return BI_COND_ALWAYS as a sentinel if it fails to do so (when used for + * optimizations). Otherwise it will bail (when used for primary code + * generation). */ + static enum bi_cond -bi_cond_for_nir(nir_op op) +bi_cond_for_nir(nir_op op, bool soft) { switch (op) { BI_CASE_CMP(nir_op_flt) @@ -431,7 +436,10 @@ bi_cond_for_nir(nir_op op) BI_CASE_CMP(nir_op_ine) return BI_COND_NE; default: - unreachable("Invalid compare"); + if (soft) + return BI_COND_ALWAYS; + else + unreachable("Invalid compare"); } } @@ -541,7 +549,7 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr) BI_CASE_CMP(nir_op_ieq) BI_CASE_CMP(nir_op_fne) BI_CASE_CMP(nir_op_ine) - alu.op.compare = bi_cond_for_nir(instr->op); + alu.op.compare = bi_cond_for_nir(instr->op, false); break; default: break;