[Mesa-dev] [PATCH 09/44] intel/fs: Protect opt_algebraic from OOB BROADCAST indices

Jason Ekstrand jason at jlekstrand.net
Tue Sep 5 15:13:01 UTC 2017


---
 src/intel/compiler/brw_fs.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index eb9b4c3..f29e47c 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -2417,8 +2417,14 @@ fs_visitor::opt_algebraic()
             progress = true;
          } else if (inst->src[1].file == IMM) {
             inst->opcode = BRW_OPCODE_MOV;
-            inst->src[0] = component(inst->src[0],
-                                     inst->src[1].ud);
+            /* It's possible that the selected component will be too large and
+             * overflow the register.  If this happens and we some how manage
+             * to constant fold it in and get here, it would cause an assert
+             * in component() below.  Instead, just let it wrap around if it
+             * goes over exec_size.
+             */
+            const unsigned comp = inst->src[1].ud & (inst->exec_size - 1);
+            inst->src[0] = component(inst->src[0], comp);
             inst->sources = 1;
             inst->force_writemask_all = true;
             progress = true;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list