Revert "intel/compiler: split is_partial_write() into two variants"
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Wed, 24 Apr 2019 10:38:28 +0000 (12:38 +0200)
committerJuan A. Suarez Romero <jasuarez@igalia.com>
Thu, 25 Apr 2019 07:19:10 +0000 (09:19 +0200)
This reverts commit 40b3abb4d16af4cef0307e1b4904c2ec0924299e.

It is not clear that this commit was entirely correct, and unfortunately
it was pushed by error.

CC: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_fs_cmod_propagation.cpp
src/intel/compiler/brw_fs_copy_propagation.cpp
src/intel/compiler/brw_fs_cse.cpp
src/intel/compiler/brw_fs_dead_code_eliminate.cpp
src/intel/compiler/brw_fs_live_variables.cpp
src/intel/compiler/brw_fs_reg_allocate.cpp
src/intel/compiler/brw_fs_register_coalesce.cpp
src/intel/compiler/brw_fs_saturate_propagation.cpp
src/intel/compiler/brw_fs_sel_peephole.cpp
src/intel/compiler/brw_ir_fs.h

index 22eefd4ef490c39d9c810549e5efe6e203a91b88..335eaa0e934a788f516f4cef9936833246535de6 100644 (file)
@@ -734,33 +734,14 @@ fs_visitor::limit_dispatch_width(unsigned n, const char *msg)
  * it.
  */
 bool
-fs_inst::is_partial_reg_write() const
+fs_inst::is_partial_write() const
 {
    return ((this->predicate && this->opcode != BRW_OPCODE_SEL) ||
+           (this->exec_size * type_sz(this->dst.type)) < 32 ||
            !this->dst.is_contiguous() ||
-           (this->exec_size * type_sz(this->dst.type)) < REG_SIZE ||
            this->dst.offset % REG_SIZE != 0);
 }
 
-/**
- * Returns true if the instruction has a flag that means it won't
- * update an entire variable for the given dispatch width.
- *
- * This is only different from is_partial_reg_write() for SIMD8
- * dispatches of 16-bit (or smaller) instructions.
- */
-bool
-fs_inst::is_partial_var_write(uint32_t dispatch_width) const
-{
-   const uint32_t type_size = type_sz(this->dst.type);
-   uint32_t var_size = MIN2(REG_SIZE, dispatch_width * type_size);
-
-   return ((this->predicate && this->opcode != BRW_OPCODE_SEL) ||
-           !this->dst.is_contiguous() ||
-           (this->exec_size * type_sz(this->dst.type)) < var_size ||
-           this->dst.offset % var_size != 0);
-}
-
 unsigned
 fs_inst::components_read(unsigned i) const
 {
@@ -2943,7 +2924,7 @@ fs_visitor::opt_register_renaming()
       if (depth == 0 &&
           inst->dst.file == VGRF &&
           alloc.sizes[inst->dst.nr] * REG_SIZE == inst->size_written &&
-          !inst->is_partial_reg_write()) {
+          !inst->is_partial_write()) {
          if (remap[dst] == ~0u) {
             remap[dst] = dst;
          } else {
@@ -3147,7 +3128,7 @@ fs_visitor::compute_to_mrf()
       next_ip++;
 
       if (inst->opcode != BRW_OPCODE_MOV ||
-         inst->is_partial_reg_write() ||
+         inst->is_partial_write() ||
          inst->dst.file != MRF || inst->src[0].file != VGRF ||
          inst->dst.type != inst->src[0].type ||
          inst->src[0].abs || inst->src[0].negate ||
@@ -3180,7 +3161,7 @@ fs_visitor::compute_to_mrf()
             * that writes that reg, but it would require smarter
             * tracking.
             */
-           if (scan_inst->is_partial_reg_write())
+           if (scan_inst->is_partial_write())
               break;
 
             /* Handling things not fully contained in the source of the copy
@@ -3498,7 +3479,7 @@ fs_visitor::remove_duplicate_mrf_writes()
       if (inst->opcode == BRW_OPCODE_MOV &&
          inst->dst.file == MRF &&
          inst->src[0].file != ARF &&
-         !inst->is_partial_reg_write()) {
+         !inst->is_partial_write()) {
          last_mrf_move[inst->dst.nr] = inst;
       }
    }
index a2c11e0959ccc83f3968614236f7024fdfc32046..c97252639290bd48c377a7aee6a73e9f9a422cf2 100644 (file)
 
 static bool
 cmod_propagate_cmp_to_add(const gen_device_info *devinfo, bblock_t *block,
-                          fs_inst *inst, unsigned dispatch_width)
+                          fs_inst *inst)
 {
    bool read_flag = false;
 
    foreach_inst_in_block_reverse_starting_from(fs_inst, scan_inst, inst) {
       if (scan_inst->opcode == BRW_OPCODE_ADD &&
-          !scan_inst->is_partial_var_write(dispatch_width) &&
+          !scan_inst->is_partial_write() &&
           scan_inst->exec_size == inst->exec_size) {
          bool negate;
 
@@ -126,7 +126,7 @@ cmod_propagate_cmp_to_add(const gen_device_info *devinfo, bblock_t *block,
  */
 static bool
 cmod_propagate_not(const gen_device_info *devinfo, bblock_t *block,
-                   fs_inst *inst, unsigned dispatch_width)
+                   fs_inst *inst)
 {
    const enum brw_conditional_mod cond = brw_negate_cmod(inst->conditional_mod);
    bool read_flag = false;
@@ -141,7 +141,7 @@ cmod_propagate_not(const gen_device_info *devinfo, bblock_t *block,
              scan_inst->opcode != BRW_OPCODE_AND)
             break;
 
-         if (scan_inst->is_partial_var_write(dispatch_width) ||
+         if (scan_inst->is_partial_write() ||
              scan_inst->dst.offset != inst->src[0].offset ||
              scan_inst->exec_size != inst->exec_size)
             break;
@@ -166,9 +166,7 @@ cmod_propagate_not(const gen_device_info *devinfo, bblock_t *block,
 }
 
 static bool
-opt_cmod_propagation_local(const gen_device_info *devinfo,
-                           bblock_t *block,
-                           unsigned dispatch_width)
+opt_cmod_propagation_local(const gen_device_info *devinfo, bblock_t *block)
 {
    bool progress = false;
    int ip = block->end_ip + 1;
@@ -221,14 +219,14 @@ opt_cmod_propagation_local(const gen_device_info *devinfo,
        */
       if (inst->opcode == BRW_OPCODE_CMP && !inst->src[1].is_zero()) {
          if (brw_reg_type_is_floating_point(inst->src[0].type) &&
-             cmod_propagate_cmp_to_add(devinfo, block, inst, dispatch_width))
+             cmod_propagate_cmp_to_add(devinfo, block, inst))
             progress = true;
 
          continue;
       }
 
       if (inst->opcode == BRW_OPCODE_NOT) {
-         progress = cmod_propagate_not(devinfo, block, inst, dispatch_width) || progress;
+         progress = cmod_propagate_not(devinfo, block, inst) || progress;
          continue;
       }
 
@@ -236,7 +234,7 @@ opt_cmod_propagation_local(const gen_device_info *devinfo,
       foreach_inst_in_block_reverse_starting_from(fs_inst, scan_inst, inst) {
          if (regions_overlap(scan_inst->dst, scan_inst->size_written,
                              inst->src[0], inst->size_read(0))) {
-            if (scan_inst->is_partial_var_write(dispatch_width) ||
+            if (scan_inst->is_partial_write() ||
                 scan_inst->dst.offset != inst->src[0].offset ||
                 scan_inst->exec_size != inst->exec_size)
                break;
@@ -371,7 +369,7 @@ fs_visitor::opt_cmod_propagation()
    bool progress = false;
 
    foreach_block_reverse(block, cfg) {
-      progress = opt_cmod_propagation_local(devinfo, block, dispatch_width) || progress;
+      progress = opt_cmod_propagation_local(devinfo, block) || progress;
    }
 
    if (progress)
index 1670eedce77bbb6a87c0f100fd7cecfc14e347b5..1f4e122e6c92190a0e016ebc2f34320256585056 100644 (file)
@@ -515,7 +515,7 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
    /* Compute the first component of the copy that the instruction is
     * reading, and the base byte offset within that component.
     */
-   assert(entry->dst.stride == 1);
+   assert(entry->dst.offset % REG_SIZE == 0 && entry->dst.stride == 1);
    const unsigned component = rel_offset / type_sz(entry->dst.type);
    const unsigned suboffset = rel_offset % type_sz(entry->dst.type);
 
@@ -767,7 +767,7 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry *entry)
 }
 
 static bool
-can_propagate_from(fs_inst *inst, unsigned dispatch_width)
+can_propagate_from(fs_inst *inst)
 {
    return (inst->opcode == BRW_OPCODE_MOV &&
            inst->dst.file == VGRF &&
@@ -778,7 +778,7 @@ can_propagate_from(fs_inst *inst, unsigned dispatch_width)
             inst->src[0].file == UNIFORM ||
             inst->src[0].file == IMM) &&
            inst->src[0].type == inst->dst.type &&
-           !inst->is_partial_var_write(dispatch_width));
+           !inst->is_partial_write());
 }
 
 /* Walks a basic block and does copy propagation on it using the acp
@@ -830,7 +830,7 @@ fs_visitor::opt_copy_propagation_local(void *copy_prop_ctx, bblock_t *block,
       /* If this instruction's source could potentially be folded into the
        * operand of another instruction, add it to the ACP.
        */
-      if (can_propagate_from(inst, dispatch_width)) {
+      if (can_propagate_from(inst)) {
          acp_entry *entry = ralloc(copy_prop_ctx, acp_entry);
          entry->dst = inst->dst;
          entry->src = inst->src[0];
index e955c35e145aa45a26cfff1b9ebd42f507e833cd..6efa111b1a43b3480cb58df1374cae6f0a4b74a2 100644 (file)
@@ -252,8 +252,7 @@ fs_visitor::opt_cse_local(bblock_t *block)
    int ip = block->start_ip;
    foreach_inst_in_block(fs_inst, inst, block) {
       /* Skip some cases. */
-      if (is_expression(this, inst) &&
-          !inst->is_partial_var_write(dispatch_width) &&
+      if (is_expression(this, inst) && !inst->is_partial_write() &&
           ((inst->dst.file != ARF && inst->dst.file != FIXED_GRF) ||
            inst->dst.is_null()))
       {
index 7c60a33eb58833c483f11827f9b5b6ed99355479..38ae1d41a6ad65fecf603f0d3e1bcd6fd85ac13a 100644 (file)
@@ -107,7 +107,7 @@ fs_visitor::dead_code_eliminate()
          }
 
          if (inst->dst.file == VGRF) {
-            if (!inst->is_partial_reg_write()) {
+            if (!inst->is_partial_write()) {
                int var = live_intervals->var_from_reg(inst->dst);
                for (unsigned i = 0; i < regs_written(inst); i++) {
                   BITSET_CLEAR(live, var + i);
index 30625aa586aeee97d62c490722a79c0b784b125e..059f076fa5153ebcc1f05c905c55e31cff677e3c 100644 (file)
@@ -84,7 +84,7 @@ fs_live_variables::setup_one_write(struct block_data *bd, fs_inst *inst,
     * screens off previous updates of that variable (VGRF channel).
     */
    if (inst->dst.file == VGRF) {
-      if (!inst->is_partial_reg_write() && !BITSET_TEST(bd->use, var))
+      if (!inst->is_partial_write() && !BITSET_TEST(bd->use, var))
          BITSET_SET(bd->def, var);
 
       BITSET_SET(bd->defout, var);
index d5c4f032182d4101cf6008ffc34381ff8099d59c..17a9dc8e9c44879ffe585cb28b10af56e79ace5b 100644 (file)
@@ -1066,7 +1066,7 @@ fs_visitor::spill_reg(unsigned spill_reg)
           * write, there should be no need for the unspill since the
           * instruction will be overwriting the whole destination in any case.
          */
-         if (inst->is_partial_reg_write() ||
+         if (inst->is_partial_write() ||
              (!inst->force_writemask_all && !per_channel))
             emit_unspill(ubld, spill_src, subset_spill_offset,
                          regs_written(inst));
index 27234292c30b70d4dd92c08c377ca2670351df2e..4fe6773da54b43e2b6d25dc85b90ed578ed5f38e 100644 (file)
@@ -70,7 +70,7 @@ is_coalesce_candidate(const fs_visitor *v, const fs_inst *inst)
 {
    if ((inst->opcode != BRW_OPCODE_MOV &&
         inst->opcode != SHADER_OPCODE_LOAD_PAYLOAD) ||
-       inst->is_partial_reg_write() ||
+       inst->is_partial_write() ||
        inst->saturate ||
        inst->src[0].file != VGRF ||
        inst->src[0].negate ||
index fe3fa7ecfead186d045df231f9b67f32baa698cc..8140de69749002b8c4a5bbf2464b8d3021ce8e84 100644 (file)
@@ -43,8 +43,7 @@
  */
 
 static bool
-opt_saturate_propagation_local(fs_visitor *v, bblock_t *block,
-                               unsigned dispatch_width)
+opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
 {
    bool progress = false;
    int ip = block->end_ip + 1;
@@ -68,7 +67,7 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block,
          if (scan_inst->exec_size == inst->exec_size &&
              regions_overlap(scan_inst->dst, scan_inst->size_written,
                              inst->src[0], inst->size_read(0))) {
-            if (scan_inst->is_partial_var_write(dispatch_width) ||
+            if (scan_inst->is_partial_write() ||
                 (scan_inst->dst.type != inst->dst.type &&
                  !scan_inst->can_change_types()))
                break;
@@ -155,7 +154,7 @@ fs_visitor::opt_saturate_propagation()
    calculate_live_intervals();
 
    foreach_block (block, cfg) {
-      progress = opt_saturate_propagation_local(this, block, dispatch_width) || progress;
+      progress = opt_saturate_propagation_local(this, block) || progress;
    }
 
    /* Live intervals are still valid. */
index 98d640a3bfefc28615c8e0cb1538d2af71e3d4d1..6395b409b7c54713aff1d408b9938999b6703992 100644 (file)
@@ -167,8 +167,8 @@ fs_visitor::opt_peephole_sel()
              then_mov[i]->exec_size != else_mov[i]->exec_size ||
              then_mov[i]->group != else_mov[i]->group ||
              then_mov[i]->force_writemask_all != else_mov[i]->force_writemask_all ||
-             then_mov[i]->is_partial_var_write(dispatch_width) ||
-             else_mov[i]->is_partial_var_write(dispatch_width) ||
+             then_mov[i]->is_partial_write() ||
+             else_mov[i]->is_partial_write() ||
              then_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE ||
              else_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE) {
             movs = i;
index 87e03258d932720e23f4001d5a817185da7a1e7d..56a4bdc6e526302409fde11f31d25b4365f5a4bf 100644 (file)
@@ -348,8 +348,7 @@ public:
    void resize_sources(uint8_t num_sources);
 
    bool is_send_from_grf() const;
-   bool is_partial_reg_write() const;
-   bool is_partial_var_write(unsigned dispatch_width) const;
+   bool is_partial_write() const;
    bool is_copy_payload(const brw::simple_allocator &grf_alloc) const;
    unsigned components_read(unsigned i) const;
    unsigned size_read(int arg) const;