diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2020-11-05 23:16:19 -0600 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-11-09 18:58:51 +0000 |
commit | 3ad2d85995eccc5b79732f93a2ced4800275b19b (patch) | |
tree | 1745138e4448b7217c6a513a4e868b7ad4518fea | |
parent | f95665cfebbd943ca3795c026e3dabf4af3f262c (diff) |
intel/nir: Refactor lower_bit_size_callback
We want to use it for more than just ALU.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7482>
-rw-r--r-- | src/intel/compiler/brw_nir.c | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 61c1ef98338..71771a5fc58 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -635,37 +635,43 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler, static unsigned lower_bit_size_callback(const nir_instr *instr, UNUSED void *data) { - if (instr->type != nir_instr_type_alu) - return 0; - - nir_alu_instr *alu = nir_instr_as_alu(instr); - assert(alu->dest.dest.is_ssa); - if (alu->dest.dest.ssa.bit_size >= 32) - return 0; - const struct brw_compiler *compiler = (const struct brw_compiler *) data; + const struct gen_device_info *devinfo = compiler->devinfo; + + switch (instr->type) { + case nir_instr_type_alu: { + nir_alu_instr *alu = nir_instr_as_alu(instr); + assert(alu->dest.dest.is_ssa); + if (alu->dest.dest.ssa.bit_size >= 32) + return 0; + + switch (alu->op) { + case nir_op_idiv: + case nir_op_imod: + case nir_op_irem: + case nir_op_udiv: + case nir_op_umod: + case nir_op_fceil: + case nir_op_ffloor: + case nir_op_ffract: + case nir_op_fround_even: + case nir_op_ftrunc: + return 32; + case nir_op_frcp: + case nir_op_frsq: + case nir_op_fsqrt: + case nir_op_fpow: + case nir_op_fexp2: + case nir_op_flog2: + case nir_op_fsin: + case nir_op_fcos: + return devinfo->gen < 9 ? 32 : 0; + default: + return 0; + } + break; + } - switch (alu->op) { - case nir_op_idiv: - case nir_op_imod: - case nir_op_irem: - case nir_op_udiv: - case nir_op_umod: - case nir_op_fceil: - case nir_op_ffloor: - case nir_op_ffract: - case nir_op_fround_even: - case nir_op_ftrunc: - return 32; - case nir_op_frcp: - case nir_op_frsq: - case nir_op_fsqrt: - case nir_op_fpow: - case nir_op_fexp2: - case nir_op_flog2: - case nir_op_fsin: - case nir_op_fcos: - return compiler->devinfo->gen < 9 ? 32 : 0; default: return 0; } |