diff --git a/src/intel/compiler/brw_fs_copy_propagation.cpp b/src/intel/compiler/brw_fs_copy_propagation.cpp index 55daf49e176..93cb64de7ca 100644 --- a/src/intel/compiler/brw_fs_copy_propagation.cpp +++ b/src/intel/compiler/brw_fs_copy_propagation.cpp @@ -972,14 +972,14 @@ try_constant_propagate(const brw_compiler *compiler, fs_inst *inst, if (inst->src[arg].abs) { if (is_logic_op(inst->opcode) || - !brw_abs_immediate(val.type, &val.as_brw_reg())) { + !fs_reg_abs_immediate(&val)) { return false; } } if (inst->src[arg].negate) { if (is_logic_op(inst->opcode) || - !brw_negate_immediate(val.type, &val.as_brw_reg())) { + !fs_reg_negate_immediate(&val)) { return false; } } diff --git a/src/intel/compiler/brw_fs_opt_algebraic.cpp b/src/intel/compiler/brw_fs_opt_algebraic.cpp index 7d492f7fd70..f9bf88a841c 100644 --- a/src/intel/compiler/brw_fs_opt_algebraic.cpp +++ b/src/intel/compiler/brw_fs_opt_algebraic.cpp @@ -140,8 +140,7 @@ brw_fs_opt_algebraic(fs_visitor &s) inst->src[0].type != BRW_REGISTER_TYPE_F) assert(!"unimplemented: saturate mixed types"); - if (brw_saturate_immediate(inst->src[0].type, - &inst->src[0].as_brw_reg())) { + if (fs_reg_saturate_immediate(&inst->src[0])) { inst->saturate = false; progress = true; } diff --git a/src/intel/compiler/brw_fs_saturate_propagation.cpp b/src/intel/compiler/brw_fs_saturate_propagation.cpp index 5190b801903..47e62c746b9 100644 --- a/src/intel/compiler/brw_fs_saturate_propagation.cpp +++ b/src/intel/compiler/brw_fs_saturate_propagation.cpp @@ -93,8 +93,7 @@ opt_saturate_propagation_local(const fs_live_variables &live, bblock_t *block) } else if (scan_inst->opcode == BRW_OPCODE_MAD) { for (int i = 0; i < 2; i++) { if (scan_inst->src[i].file == IMM) { - brw_negate_immediate(scan_inst->src[i].type, - &scan_inst->src[i].as_brw_reg()); + fs_reg_negate_immediate(&scan_inst->src[i]); } else { scan_inst->src[i].negate = !scan_inst->src[i].negate; } @@ -102,8 +101,7 @@ opt_saturate_propagation_local(const fs_live_variables &live, bblock_t *block) inst->src[0].negate = false; } else if (scan_inst->opcode == BRW_OPCODE_ADD) { if (scan_inst->src[1].file == IMM) { - if (!brw_negate_immediate(scan_inst->src[1].type, - &scan_inst->src[1].as_brw_reg())) { + if (!fs_reg_negate_immediate(&scan_inst->src[1])) { break; } } else { diff --git a/src/intel/compiler/brw_ir_fs.h b/src/intel/compiler/brw_ir_fs.h index 6d55e16c683..279cd21b17f 100644 --- a/src/intel/compiler/brw_ir_fs.h +++ b/src/intel/compiler/brw_ir_fs.h @@ -365,6 +365,10 @@ horiz_stride(fs_reg reg, unsigned s) return reg; } +bool fs_reg_saturate_immediate(fs_reg *reg); +bool fs_reg_negate_immediate(fs_reg *reg); +bool fs_reg_abs_immediate(fs_reg *reg); + static const fs_reg reg_undef; struct fs_inst : public exec_node { diff --git a/src/intel/compiler/brw_reg.h b/src/intel/compiler/brw_reg.h index 17747089981..8e610a671c6 100644 --- a/src/intel/compiler/brw_reg.h +++ b/src/intel/compiler/brw_reg.h @@ -1280,10 +1280,6 @@ element_sz(struct brw_reg reg) int brw_float_to_vf(float f); float brw_vf_to_float(unsigned char vf); -bool brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg); -bool brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg); -bool brw_abs_immediate(enum brw_reg_type type, struct brw_reg *reg); - #ifdef __cplusplus } #endif diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index ff77178d752..46126130d6e 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -30,7 +30,7 @@ #include "util/macros.h" bool -brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg) +fs_reg_saturate_immediate(fs_reg *reg) { union { unsigned ud; @@ -39,7 +39,7 @@ brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg) double df; } imm, sat_imm = { 0 }; - const unsigned size = type_sz(type); + const unsigned size = type_sz(reg->type); /* We want to either do a 32-bit or 64-bit data copy, the type is otherwise * irrelevant, so just check the size of the type and copy from/to an @@ -50,7 +50,7 @@ brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg) else imm.df = reg->df; - switch (type) { + switch (reg->type) { case BRW_REGISTER_TYPE_UD: case BRW_REGISTER_TYPE_D: case BRW_REGISTER_TYPE_UW: @@ -93,9 +93,9 @@ brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg) } bool -brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg) +fs_reg_negate_immediate(fs_reg *reg) { - switch (type) { + switch (reg->type) { case BRW_REGISTER_TYPE_D: case BRW_REGISTER_TYPE_UD: reg->d = -reg->d; @@ -136,9 +136,9 @@ brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg) } bool -brw_abs_immediate(enum brw_reg_type type, struct brw_reg *reg) +fs_reg_abs_immediate(fs_reg *reg) { - switch (type) { + switch (reg->type) { case BRW_REGISTER_TYPE_D: reg->d = abs(reg->d); return true;