[2/2] nir/loop_analyze: handle swizzles on the loop limit

Submitted by Timothy Arceri on June 19, 2019, 8:09 a.m.

Details

Message ID 20190619080900.16648-2-tarceri@itsqueeze.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Timothy Arceri June 19, 2019, 8:09 a.m.
Fixes: 6772a17acc8e ("nir: Add a loop analysis pass")
---
 src/compiler/nir/nir_loop_analyze.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c
index 57d2d94cad2..79ed5bb2712 100644
--- a/src/compiler/nir/nir_loop_analyze.c
+++ b/src/compiler/nir/nir_loop_analyze.c
@@ -561,8 +561,10 @@  try_find_limit_of_alu(nir_alu_src *limit, nir_const_value *limit_val,
       if (limit->src.ssa->parent_instr->type != nir_instr_type_load_const)
          return false;
 
+      unsigned limit_swz = limit->swizzle[0];
       *limit_val =
-         nir_instr_as_load_const(limit->src.ssa->parent_instr)->value[0];
+         nir_instr_as_load_const(limit->src.ssa->parent_instr)
+            ->value[limit_swz];
 
       terminator->exact_trip_count_unknown = true;
 
@@ -933,8 +935,10 @@  find_trip_count(loop_info_state *state)
       /* Attempt to find a constant limit for the loop */
       nir_const_value limit_val;
       if (limit->src.ssa->parent_instr->type == nir_instr_type_load_const) {
+         unsigned limit_swz = limit->swizzle[0];
          limit_val =
-            nir_instr_as_load_const(limit->src.ssa->parent_instr)->value[0];
+            nir_instr_as_load_const(limit->src.ssa->parent_instr)
+               ->value[limit_swz];
       } else {
          trip_count_known = false;