[Mesa-dev] [PATCH] i965/fs: Remove redundant hand-unrolled first iteration of loop.

Francisco Jerez currojerez at riseup.net
Mon Jul 20 07:49:40 PDT 2015


This seems rather silly and would lead to memory corruption if the
size of a VGRF was allowed to be zero.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 960ea54..eafd676 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1565,16 +1565,12 @@ fs_visitor::split_virtual_grfs()
 
    int reg = 0;
    for (int i = 0; i < num_vars; i++) {
+      int offset = 0;
+
       /* The first one should always be 0 as a quick sanity check. */
       assert(split_points[reg] == false);
 
-      /* j = 0 case */
-      new_reg_offset[reg] = 0;
-      reg++;
-      int offset = 1;
-
-      /* j > 0 case */
-      for (unsigned j = 1; j < alloc.sizes[i]; j++) {
+      for (unsigned j = 0; j < alloc.sizes[i]; j++) {
          /* If this is a split point, reset the offset to 0 and allocate a
           * new virtual GRF for the previous offset many registers
           */
-- 
2.4.3



More information about the mesa-dev mailing list