[Mesa-dev] [PATCH 38/57] i965/fs: Change region_contained_in() to use byte units.

Francisco Jerez currojerez at riseup.net
Thu Sep 8 01:49:05 UTC 2016


This makes the function less annoying to use and more accurate -- We
shouldn't propagate a copy into a register region that wasn't fully
contained in the destination of the copy (IOW, a source region that
wasn't fully defined by the copy) just because the number of registers
written and read by each instruction happened to get rounded up to the
same GRF multiple.
---
 .../drivers/dri/i965/brw_fs_copy_propagation.cpp   | 25 +++++++++-------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 0da5f13..80ad4b4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -333,18 +333,17 @@ can_take_stride(fs_inst *inst, unsigned arg, unsigned stride,
 }
 
 /**
- * Check that the register region read by src [src.reg_offset,
- * src.reg_offset + regs_read] is contained inside the register
- * region written by dst [dst.reg_offset, dst.reg_offset + regs_written]
- * Both src and dst must have the same register number and file.
+ * Check that the register region read by src [src.offset,
+ * src.offset + size_read[ is fully contained inside the register
+ * region written by dst [dst.offset, dst.offset + size_written[.
  */
 static inline bool
-region_contained_in(const fs_reg &src, unsigned regs_read,
-                    const fs_reg &dst, unsigned regs_written)
+region_contained_in(const fs_reg &src, unsigned size_read,
+                    const fs_reg &dst, unsigned size_written)
 {
    return src.file == dst.file && src.nr == dst.nr &&
           src.offset >= dst.offset &&
-      src.offset / REG_SIZE + regs_read <= dst.offset / REG_SIZE + regs_written;
+          src.offset + size_read <= dst.offset + size_written;
 }
 
 bool
@@ -369,10 +368,8 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
    /* Bail if inst is reading a range that isn't contained in the range
     * that entry is writing.
     */
-   if (!region_contained_in(inst->src[arg], DIV_ROUND_UP(inst->size_read(arg),
-                                                         REG_SIZE),
-                            entry->dst, DIV_ROUND_UP(entry->size_written,
-                                                     REG_SIZE)))
+   if (!region_contained_in(inst->src[arg], inst->size_read(arg),
+                            entry->dst, entry->size_written))
       return false;
 
    /* we can't generally copy-propagate UD negations because we
@@ -527,10 +524,8 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry *entry)
       /* Bail if inst is reading a range that isn't contained in the range
        * that entry is writing.
        */
-      if (!region_contained_in(inst->src[i], DIV_ROUND_UP(inst->size_read(i),
-                                                          REG_SIZE),
-                               entry->dst, DIV_ROUND_UP(entry->size_written,
-                                                        REG_SIZE)))
+      if (!region_contained_in(inst->src[i], inst->size_read(i),
+                               entry->dst, entry->size_written))
          continue;
 
       /* If the type sizes don't match each channel of the instruction is
-- 
2.9.0



More information about the mesa-dev mailing list