i965/fs: Expose arbitrary pull constant load sizes to the IR.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vec4_dead_code_eliminate.cpp
index c643212494b24b841772aef4d7443996431dd4ee..65f9f3889883904c51900d3f4945b02666bf517e 100644 (file)
@@ -44,8 +44,8 @@ vec4_visitor::dead_code_eliminate()
    calculate_live_intervals();
 
    int num_vars = live_intervals->num_vars;
-   BITSET_WORD *live = ralloc_array(NULL, BITSET_WORD, BITSET_WORDS(num_vars));
-   BITSET_WORD *flag_live = ralloc_array(NULL, BITSET_WORD, 1);
+   BITSET_WORD *live = rzalloc_array(NULL, BITSET_WORD, BITSET_WORDS(num_vars));
+   BITSET_WORD *flag_live = rzalloc_array(NULL, BITSET_WORD, 1);
 
    foreach_block_reverse_safe(block, cfg) {
       memcpy(live, live_intervals->block_data[block->num].liveout,
@@ -59,10 +59,11 @@ vec4_visitor::dead_code_eliminate()
             bool result_live[4] = { false };
 
             if (inst->dst.file == VGRF) {
-               for (unsigned i = 0; i < inst->regs_written; i++) {
+               for (unsigned i = 0; i < regs_written(inst); i++) {
                   for (int c = 0; c < 4; c++)
-                     result_live[c] |= BITSET_TEST(
-                        live, var_from_reg(alloc, offset(inst->dst, i), c));
+                     result_live[c] |= BITSET_TEST(live,
+                        var_from_reg(alloc,
+                                     byte_offset(inst->dst, i * REG_SIZE), c));
                }
             } else {
                for (unsigned c = 0; c < 4; c++)
@@ -110,11 +111,14 @@ vec4_visitor::dead_code_eliminate()
          }
 
          if (inst->dst.file == VGRF && !inst->predicate) {
-            for (unsigned i = 0; i < inst->regs_written; i++) {
+            for (unsigned i = 0; i < regs_written(inst); i++) {
                for (int c = 0; c < 4; c++) {
                   if (inst->dst.writemask & (1 << c)) {
-                     BITSET_CLEAR(live, var_from_reg(alloc,
-                                                     offset(inst->dst, i), c));
+                     BITSET_CLEAR(live,
+                                  var_from_reg(alloc,
+                                               byte_offset(inst->dst,
+                                                           i * REG_SIZE),
+                                               c));
                   }
                }
             }
@@ -132,10 +136,12 @@ vec4_visitor::dead_code_eliminate()
 
          for (int i = 0; i < 3; i++) {
             if (inst->src[i].file == VGRF) {
-               for (unsigned j = 0; j < inst->regs_read(i); j++) {
+               for (unsigned j = 0; j < regs_read(inst, i); j++) {
                   for (int c = 0; c < 4; c++) {
                      BITSET_SET(live, var_from_reg(alloc,
-                                                   offset(inst->src[i], j), c));
+                                                   byte_offset(inst->src[i],
+                                                               j * REG_SIZE),
+                                                   c));
                   }
                }
             }