#include "brw_fs.h"
#include "brw_cfg.h"
#include "brw_vs.h"
+#include "brw_vec4_live_variables.h"
#include "brw_dead_control_flow.h"
extern "C" {
/* Can't coalesce this GRF if someone else was going to
* read it later.
*/
- if (this->virtual_grf_end[inst->src[0].reg * 4 + 0] > ip ||
- this->virtual_grf_end[inst->src[0].reg * 4 + 1] > ip ||
- this->virtual_grf_end[inst->src[0].reg * 4 + 2] > ip ||
- this->virtual_grf_end[inst->src[0].reg * 4 + 3] > ip)
+ if (var_range_end(var_from_reg(alloc, inst->src[0]), 4) > ip)
continue;
/* We need to check interference with the final destination between this
bool opt_vector_float();
bool opt_reduce_swizzle();
bool dead_code_eliminate();
+ int var_range_start(unsigned v, unsigned n) const;
+ int var_range_end(unsigned v, unsigned n) const;
bool virtual_grf_interferes(int a, int b);
bool opt_copy_propagation(bool do_constant_prop = true);
bool opt_cse_local(bblock_t *block);
* more -- a sure sign they'll fail operands_match().
*/
if (src->file == GRF) {
- assert((unsigned)(src->reg * 4 + 3) < (alloc.count * 4));
-
- int last_reg_use = MAX2(MAX2(virtual_grf_end[src->reg * 4 + 0],
- virtual_grf_end[src->reg * 4 + 1]),
- MAX2(virtual_grf_end[src->reg * 4 + 2],
- virtual_grf_end[src->reg * 4 + 3]));
- if (last_reg_use < ip) {
+ if (var_range_end(var_from_reg(alloc, *src), 4) < ip) {
entry->remove();
ralloc_free(entry);
break;
live_intervals = NULL;
}
+int
+vec4_visitor::var_range_start(unsigned v, unsigned n) const
+{
+ int start = INT_MAX;
+
+ for (unsigned i = 0; i < n; i++)
+ start = MIN2(start, virtual_grf_start[v + i]);
+
+ return start;
+}
+
+int
+vec4_visitor::var_range_end(unsigned v, unsigned n) const
+{
+ int end = INT_MIN;
+
+ for (unsigned i = 0; i < n; i++)
+ end = MAX2(end, virtual_grf_end[v + i]);
+
+ return end;
+}
+
bool
vec4_visitor::virtual_grf_interferes(int a, int b)
{
- int start_a = MIN2(MIN2(virtual_grf_start[a * 4 + 0],
- virtual_grf_start[a * 4 + 1]),
- MIN2(virtual_grf_start[a * 4 + 2],
- virtual_grf_start[a * 4 + 3]));
- int start_b = MIN2(MIN2(virtual_grf_start[b * 4 + 0],
- virtual_grf_start[b * 4 + 1]),
- MIN2(virtual_grf_start[b * 4 + 2],
- virtual_grf_start[b * 4 + 3]));
- int end_a = MAX2(MAX2(virtual_grf_end[a * 4 + 0],
- virtual_grf_end[a * 4 + 1]),
- MAX2(virtual_grf_end[a * 4 + 2],
- virtual_grf_end[a * 4 + 3]));
- int end_b = MAX2(MAX2(virtual_grf_end[b * 4 + 0],
- virtual_grf_end[b * 4 + 1]),
- MAX2(virtual_grf_end[b * 4 + 2],
- virtual_grf_end[b * 4 + 3]));
- return !(end_a <= start_b ||
- end_b <= start_a);
+ return !((var_range_end(4 * a, 4) <=
+ var_range_start(4 * b, 4)) ||
+ (var_range_end(4 * b, 4) <=
+ var_range_start(4 * a, 4)));
}