This makes sure that overlap checks are done correctly throughout the
back-end when the '*this' register starts before the register/size
pair provided as argument, and is actually less annoying to use than
in_range() at this point since regions_overlap() takes its size
arguments in bytes.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
return file == ARF && nr == BRW_ARF_ACCUMULATOR;
}
return file == ARF && nr == BRW_ARF_ACCUMULATOR;
}
-bool
-backend_reg::in_range(const backend_reg &r, unsigned n) const
-{
- return (file == r.file &&
- nr == r.nr &&
- offset >= r.offset &&
- offset < r.offset + n * REG_SIZE);
-}
-
bool
backend_instruction::is_commutative() const
{
bool
backend_instruction::is_commutative() const
{
bool is_negative_one() const;
bool is_null() const;
bool is_accumulator() const;
bool is_negative_one() const;
bool is_null() const;
bool is_accumulator() const;
- bool in_range(const backend_reg &r, unsigned n) const;
/** Offset from the start of the (virtual) register in bytes. */
uint16_t offset;
/** Offset from the start of the (virtual) register in bytes. */
uint16_t offset;
inst) {
_scan_inst = scan_inst;
inst) {
_scan_inst = scan_inst;
- if (inst->src[0].in_range(scan_inst->dst, DIV_ROUND_UP(scan_inst->size_written, REG_SIZE))) {
+ if (regions_overlap(inst->src[0], inst->size_read(0),
+ scan_inst->dst, scan_inst->size_written)) {
/* Found something writing to the reg we want to coalesce away. */
if (to_mrf) {
/* SEND instructions can't have MRF as a destination. */
/* Found something writing to the reg we want to coalesce away. */
if (to_mrf) {
/* SEND instructions can't have MRF as a destination. */
*/
bool interfered = false;
for (int i = 0; i < 3; i++) {
*/
bool interfered = false;
for (int i = 0; i < 3; i++) {
- if (inst->src[0].in_range(scan_inst->src[i],
- DIV_ROUND_UP(scan_inst->size_read(i), REG_SIZE)))
+ if (regions_overlap(inst->src[0], inst->size_read(0),
+ scan_inst->src[i], scan_inst->size_read(i)))
interfered = true;
}
if (interfered)
interfered = true;
}
if (interfered)
/* If somebody else writes the same channels of our destination here,
* we can't coalesce before that.
*/
/* If somebody else writes the same channels of our destination here,
* we can't coalesce before that.
*/
- if (inst->dst.in_range(scan_inst->dst, DIV_ROUND_UP(scan_inst->size_written, REG_SIZE)) &&
+ if (regions_overlap(inst->dst, inst->size_written,
+ scan_inst->dst, scan_inst->size_written) &&
(inst->dst.writemask & scan_inst->dst.writemask) != 0) {
break;
}
(inst->dst.writemask & scan_inst->dst.writemask) != 0) {
break;
}
}
} else {
for (int i = 0; i < 3; i++) {
}
} else {
for (int i = 0; i < 3; i++) {
- if (inst->dst.in_range(scan_inst->src[i],
- DIV_ROUND_UP(scan_inst->size_read(i), REG_SIZE)))
+ if (regions_overlap(inst->dst, inst->size_written,
+ scan_inst->src[i], scan_inst->size_read(i)))
interfered = true;
}
if (interfered)
interfered = true;
}
if (interfered)
bool read_flag = false;
foreach_inst_in_block_reverse_starting_from(vec4_instruction, scan_inst, inst) {
bool read_flag = false;
foreach_inst_in_block_reverse_starting_from(vec4_instruction, scan_inst, inst) {
- if (inst->src[0].in_range(scan_inst->dst,
- DIV_ROUND_UP(scan_inst->size_written, REG_SIZE))) {
+ if (regions_overlap(inst->src[0], inst->size_read(0),
+ scan_inst->dst, scan_inst->size_written)) {
if ((scan_inst->predicate && scan_inst->opcode != BRW_OPCODE_SEL) ||
scan_inst->dst.offset / REG_SIZE != inst->src[0].offset / REG_SIZE ||
(scan_inst->dst.writemask != WRITEMASK_X &&
if ((scan_inst->predicate && scan_inst->opcode != BRW_OPCODE_SEL) ||
scan_inst->dst.offset / REG_SIZE != inst->src[0].offset / REG_SIZE ||
(scan_inst->dst.writemask != WRITEMASK_X &&
if (!src || src->file != VGRF)
return false;
if (!src || src->file != VGRF)
return false;
- return (src->in_range(inst->dst, DIV_ROUND_UP(inst->size_written, REG_SIZE)) &&
- inst->dst.writemask & (1 << BRW_GET_SWZ(src->swizzle, ch)));
+ return regions_overlap(*src, REG_SIZE, inst->dst, inst->size_written) &&
+ inst->dst.writemask & (1 << BRW_GET_SWZ(src->swizzle, ch));