intel/compiler: don't instantiate a builder for each instruction
Don't instantiate a builder for each instruction during lower_integer_multiplication(). Instantiate one only when needed. On the other hand, these unneeded builders don't seem to cost much to init, so I don't expect any significant difference in performance: this is mostly about code organization. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
This commit is contained in:

committed by
Caio Marcelo de Oliveira Filho

parent
75b3868dcc
commit
6ba4717924
@@ -3863,9 +3863,10 @@ fs_visitor::lower_load_payload()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fs_visitor::lower_mul_dword_inst(fs_inst *inst, bblock_t *block,
|
fs_visitor::lower_mul_dword_inst(fs_inst *inst, bblock_t *block)
|
||||||
const fs_builder &ibld)
|
|
||||||
{
|
{
|
||||||
|
const fs_builder ibld(this, block, inst);
|
||||||
|
|
||||||
if (inst->src[1].file == IMM && inst->src[1].ud < (1 << 16)) {
|
if (inst->src[1].file == IMM && inst->src[1].ud < (1 << 16)) {
|
||||||
/* The MUL instruction isn't commutative. On Gen <= 6, only the low
|
/* The MUL instruction isn't commutative. On Gen <= 6, only the low
|
||||||
* 16-bits of src0 are read, and on Gen >= 7 only the low 16-bits of
|
* 16-bits of src0 are read, and on Gen >= 7 only the low 16-bits of
|
||||||
@@ -3990,9 +3991,10 @@ fs_visitor::lower_mul_dword_inst(fs_inst *inst, bblock_t *block,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fs_visitor::lower_mulh_inst(fs_inst *inst, bblock_t *block,
|
fs_visitor::lower_mulh_inst(fs_inst *inst, bblock_t *block)
|
||||||
const fs_builder &ibld)
|
|
||||||
{
|
{
|
||||||
|
const fs_builder ibld(this, block, inst);
|
||||||
|
|
||||||
/* According to the BDW+ BSpec page for the "Multiply Accumulate
|
/* According to the BDW+ BSpec page for the "Multiply Accumulate
|
||||||
* High" instruction:
|
* High" instruction:
|
||||||
*
|
*
|
||||||
@@ -4059,8 +4061,6 @@ fs_visitor::lower_integer_multiplication()
|
|||||||
bool progress = false;
|
bool progress = false;
|
||||||
|
|
||||||
foreach_block_and_inst_safe(block, fs_inst, inst, cfg) {
|
foreach_block_and_inst_safe(block, fs_inst, inst, cfg) {
|
||||||
const fs_builder ibld(this, block, inst);
|
|
||||||
|
|
||||||
if (inst->opcode == BRW_OPCODE_MUL) {
|
if (inst->opcode == BRW_OPCODE_MUL) {
|
||||||
if (inst->dst.is_accumulator() ||
|
if (inst->dst.is_accumulator() ||
|
||||||
(inst->dst.type != BRW_REGISTER_TYPE_D &&
|
(inst->dst.type != BRW_REGISTER_TYPE_D &&
|
||||||
@@ -4070,9 +4070,9 @@ fs_visitor::lower_integer_multiplication()
|
|||||||
if (devinfo->has_integer_dword_mul)
|
if (devinfo->has_integer_dword_mul)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
lower_mul_dword_inst(inst, block, ibld);
|
lower_mul_dword_inst(inst, block);
|
||||||
} else if (inst->opcode == SHADER_OPCODE_MULH) {
|
} else if (inst->opcode == SHADER_OPCODE_MULH) {
|
||||||
lower_mulh_inst(inst, block, ibld);
|
lower_mulh_inst(inst, block);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -406,10 +406,8 @@ private:
|
|||||||
|
|
||||||
void resolve_inot_sources(const brw::fs_builder &bld, nir_alu_instr *instr,
|
void resolve_inot_sources(const brw::fs_builder &bld, nir_alu_instr *instr,
|
||||||
fs_reg *op);
|
fs_reg *op);
|
||||||
void lower_mul_dword_inst(fs_inst *inst, bblock_t *block,
|
void lower_mul_dword_inst(fs_inst *inst, bblock_t *block);
|
||||||
const brw::fs_builder &ibld);
|
void lower_mulh_inst(fs_inst *inst, bblock_t *block);
|
||||||
void lower_mulh_inst(fs_inst *inst, bblock_t *block,
|
|
||||||
const brw::fs_builder &ibld);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user