diff --git a/src/intel/compiler/brw_analysis.cpp b/src/intel/compiler/brw_analysis.cpp index 711819e428f..72d66327f99 100644 --- a/src/intel/compiler/brw_analysis.cpp +++ b/src/intel/compiler/brw_analysis.cpp @@ -112,8 +112,7 @@ brw_ip_ranges::validate(const brw_shader *s) const if (num_blocks) { bblock_t *last_block = s->cfg->blocks[num_blocks - 1]; - unsigned last_ip = range(last_block).end; - if (last_ip + 1 != s->cfg->total_instructions) + if (range(last_block).end != (int)s->cfg->total_instructions) return false; } @@ -129,7 +128,7 @@ brw_register_pressure::brw_register_pressure(const brw_shader *v) for (unsigned reg = 0; reg < v->alloc.count; reg++) { brw_range range = live.vgrf_range[reg]; - for (int ip = range.start; ip <= range.end; ip++) + for (int ip = range.start; ip < range.end; ip++) regs_live_at_ip[ip] += v->alloc.sizes[reg]; } diff --git a/src/intel/compiler/brw_analysis.h b/src/intel/compiler/brw_analysis.h index 7f9c6757c0b..5bfa15a49a3 100644 --- a/src/intel/compiler/brw_analysis.h +++ b/src/intel/compiler/brw_analysis.h @@ -232,7 +232,6 @@ private: bblock_t **parents; }; -/* TODO: Make these exclusive ranges, i.e. half-open at the end. */ struct brw_range { int start; int end; @@ -240,22 +239,22 @@ struct brw_range { /* If range not empty, this is the last value inside the range. */ inline int last() const { - return end; + return end - 1; } inline bool is_empty() const { - return end < start; + return end <= start; } inline int len() const { - return end - start + 1; + return end - start; } inline bool contains(int x) const { - return start <= x && x <= end; + return start <= x && x < end; } inline bool contains(brw_range r) const @@ -278,15 +277,15 @@ inline brw_range merge(brw_range r, int x) { if (r.is_empty()) - return { x, x }; - return { MIN2(r.start, x), MAX2(r.end, x) }; + return { x, x + 1 }; + return { MIN2(r.start, x), MAX2(r.end, x + 1) }; } inline bool overlaps(brw_range a, brw_range b) { - return a.start <= b.end && - b.start <= a.end; + return a.start < b.end && + b.start < a.end; } inline brw_range @@ -296,10 +295,9 @@ intersect(brw_range a, brw_range b) return { MAX2(a.start, b.start), MIN2(a.end, b.end) }; else - return { 0, -1 }; + return { 0, 0 }; } - inline brw_range clip_end(brw_range r, int n) { @@ -322,7 +320,7 @@ struct brw_ip_ranges { brw_range range(const bblock_t *block) const { int start = start_ip[block->num]; - return { start, start + (int)block->num_instructions - 1 }; + return { start, start + (int)block->num_instructions }; } private: diff --git a/src/intel/compiler/brw_analysis_liveness.cpp b/src/intel/compiler/brw_analysis_liveness.cpp index 3ed80953b21..53314eb91aa 100644 --- a/src/intel/compiler/brw_analysis_liveness.cpp +++ b/src/intel/compiler/brw_analysis_liveness.cpp @@ -106,7 +106,7 @@ brw_live_variables::setup_def_use() assert(ip == bd->ip_range.start); if (block->num > 0) - assert(block_data[block->num - 1].ip_range.end == ip - 1); + assert(block_data[block->num - 1].ip_range.end == ip); foreach_inst_in_block(brw_inst, inst, block) { /* Set use[] for this instruction */ @@ -259,14 +259,8 @@ brw_live_variables::brw_live_variables(const brw_shader *s) } } - vars_range = linear_alloc_array(lin_ctx, brw_range, num_vars); - for (int i = 0; i < num_vars; i++) - vars_range[i] = { MAX_INSTRUCTION, -1 }; - - vgrf_range = linear_alloc_array(lin_ctx, brw_range, num_vgrfs); - for (int i = 0; i < num_vgrfs; i++) - vgrf_range[i] = { MAX_INSTRUCTION, -1 }; - + vars_range = linear_zalloc_array(lin_ctx, brw_range, num_vars); + vgrf_range = linear_zalloc_array(lin_ctx, brw_range, num_vgrfs); block_data = linear_alloc_array(lin_ctx, struct block_data, cfg->num_blocks); bitset_words = BITSET_WORDS(num_vars); diff --git a/src/intel/compiler/brw_reg_allocate.cpp b/src/intel/compiler/brw_reg_allocate.cpp index 034d054dd5c..ab0206beca4 100644 --- a/src/intel/compiler/brw_reg_allocate.cpp +++ b/src/intel/compiler/brw_reg_allocate.cpp @@ -1086,7 +1086,7 @@ brw_reg_alloc::alloc_spill_reg(unsigned size, int ip) assert(n == first_vgrf_node + vgrf); assert(n == first_spill_node + spill_node_count); - brw_range spill_reg_range{ ip - 1, ip + 1 }; + brw_range spill_reg_range{ ip - 1, ip + 2 }; setup_live_interference(n, spill_reg_range); /* Add interference between this spill node and any other spill nodes for