[Mesa-dev] [PATCH 37/51] intel/compiler/fs: Consider original sizes when retyping alu ops

Topi Pohjolainen topi.pohjolainen at gmail.com
Fri Nov 24 12:27:04 UTC 2017


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/intel/compiler/brw_fs_nir.cpp | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index baa84b0f3c..d28ed57eca 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -655,6 +655,26 @@ emit_find_msb_using_lzd(const fs_builder &bld,
    inst->src[0].negate = true;
 }
 
+static enum brw_reg_type
+get_nir_alu_dest_type(const struct gen_device_info *devinfo,
+                      const nir_alu_instr *instr, unsigned size)
+{
+   brw_reg_type res = brw_type_for_nir_type(devinfo,
+      (nir_alu_type)(nir_op_infos[instr->op].output_type |
+                     nir_dest_bit_size(instr->dest.dest)));
+   return brw_reg_type_from_bit_size(size * 8, res);
+}
+
+static enum brw_reg_type
+get_nir_alu_src_type(const struct gen_device_info *devinfo,
+                     const nir_alu_instr *instr, unsigned i, unsigned size)
+{
+   brw_reg_type res = brw_type_for_nir_type(devinfo,
+      (nir_alu_type)(nir_op_infos[instr->op].input_types[i] |
+                     nir_src_bit_size(instr->src[i].src)));
+   return brw_reg_type_from_bit_size(size * 8, res);
+}
+
 void
 fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
 {
@@ -662,16 +682,14 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
    fs_inst *inst;
 
    fs_reg result = get_nir_alu_dest(instr);
-   result.type = brw_type_for_nir_type(devinfo,
-      (nir_alu_type)(nir_op_infos[instr->op].output_type |
-                     nir_dest_bit_size(instr->dest.dest)));
+   result.type = get_nir_alu_dest_type(devinfo, instr,
+                                       brw_reg_type_to_size(result.type));
 
    fs_reg op[4];
    for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
       op[i] = get_nir_src(instr->src[i].src);
-      op[i].type = brw_type_for_nir_type(devinfo,
-         (nir_alu_type)(nir_op_infos[instr->op].input_types[i] |
-                        nir_src_bit_size(instr->src[i].src)));
+      op[i].type = get_nir_alu_src_type(devinfo, instr, i,
+                                        brw_reg_type_to_size(op[i].type));
       op[i].abs = instr->src[i].abs;
       op[i].negate = instr->src[i].negate;
    }
-- 
2.11.0



More information about the mesa-dev mailing list