diff --git a/src/intel/compiler/brw_fs_copy_propagation.cpp b/src/intel/compiler/brw_fs_copy_propagation.cpp index 6896987055f..343bac23889 100644 --- a/src/intel/compiler/brw_fs_copy_propagation.cpp +++ b/src/intel/compiler/brw_fs_copy_propagation.cpp @@ -510,11 +510,17 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) bool has_source_modifiers = entry->src.abs || entry->src.negate; - if ((has_source_modifiers || entry->src.file == UNIFORM || - !entry->src.is_contiguous()) && - !inst->can_do_source_mods(devinfo)) + if (has_source_modifiers && !inst->can_do_source_mods(devinfo)) return false; + /* Reject cases that would violate register regioning restrictions. */ + if ((entry->src.file == UNIFORM || !entry->src.is_contiguous()) && + ((devinfo->gen == 6 && inst->is_math()) || + inst->is_send_from_grf() || + inst->uses_indirect_addressing())) { + return false; + } + if (has_source_modifiers && inst->opcode == SHADER_OPCODE_GEN4_SCRATCH_WRITE) return false; diff --git a/src/intel/compiler/brw_ir.h b/src/intel/compiler/brw_ir.h index 01f81feddb4..a98eab9f8fb 100644 --- a/src/intel/compiler/brw_ir.h +++ b/src/intel/compiler/brw_ir.h @@ -101,6 +101,12 @@ struct backend_instruction : public exec_node { bool reads_accumulator_implicitly() const; bool writes_accumulator_implicitly(const struct gen_device_info *devinfo) const; + /** + * Instructions that use indirect addressing have additional register + * regioning restrictions. + */ + bool uses_indirect_addressing() const; + void remove(bblock_t *block); void insert_after(bblock_t *block, backend_instruction *inst); void insert_before(bblock_t *block, backend_instruction *inst); diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index f52295fa310..cba0b589dde 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -931,6 +931,19 @@ backend_instruction::is_control_flow() const } } +bool +backend_instruction::uses_indirect_addressing() const +{ + switch (opcode) { + case SHADER_OPCODE_BROADCAST: + case SHADER_OPCODE_CLUSTER_BROADCAST: + case SHADER_OPCODE_MOV_INDIRECT: + return true; + default: + return false; + } +} + bool backend_instruction::can_do_source_mods() const { diff --git a/src/intel/compiler/brw_vec4_copy_propagation.cpp b/src/intel/compiler/brw_vec4_copy_propagation.cpp index 9e4637e9753..a0df115d4a3 100644 --- a/src/intel/compiler/brw_vec4_copy_propagation.cpp +++ b/src/intel/compiler/brw_vec4_copy_propagation.cpp @@ -349,10 +349,17 @@ try_copy_propagate(const struct gen_device_info *devinfo, /* gen6 math and gen7+ SENDs from GRFs ignore source modifiers on * instructions. */ - if ((has_source_modifiers || value.file == UNIFORM || - value.swizzle != BRW_SWIZZLE_XYZW) && !inst->can_do_source_mods(devinfo)) + if (has_source_modifiers && !inst->can_do_source_mods(devinfo)) return false; + /* Reject cases that would violate register regioning restrictions. */ + if ((value.file == UNIFORM || value.swizzle != BRW_SWIZZLE_XYZW) && + ((devinfo->gen == 6 && inst->is_math()) || + inst->is_send_from_grf() || + inst->uses_indirect_addressing())) { + return false; + } + if (has_source_modifiers && value.type != inst->src[arg].type && !inst->can_change_types())