2 * Copyright © 2015 Thomas Helland
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include "nir_constant_expressions.h"
26 #include "nir_loop_analyze.h"
33 } nir_loop_variable_type
;
35 struct nir_basic_induction_var
;
38 /* A link for the work list */
39 struct list_head process_link
;
43 /* The ssa_def associated with this info */
46 /* The type of this ssa_def */
47 nir_loop_variable_type type
;
49 /* If this is of type basic_induction */
50 struct nir_basic_induction_var
*ind
;
52 /* True if variable is in an if branch or a nested loop */
57 typedef struct nir_basic_induction_var
{
58 nir_op alu_op
; /* The type of alu-operation */
59 nir_loop_variable
*alu_def
; /* The def of the alu-operation */
60 nir_loop_variable
*invariant
; /* The invariant alu-operand */
61 nir_loop_variable
*def_outside_loop
; /* The phi-src outside the loop */
62 } nir_basic_induction_var
;
65 /* The loop we store information for */
68 /* Loop_variable for all ssa_defs in function */
69 nir_loop_variable
*loop_vars
;
71 /* A list of the loop_vars to analyze */
72 struct list_head process_list
;
74 nir_variable_mode indirect_mask
;
78 static nir_loop_variable
*
79 get_loop_var(nir_ssa_def
*value
, loop_info_state
*state
)
81 return &(state
->loop_vars
[value
->index
]);
85 loop_info_state
*state
;
90 init_loop_def(nir_ssa_def
*def
, void *void_init_loop_state
)
92 init_loop_state
*loop_init_state
= void_init_loop_state
;
93 nir_loop_variable
*var
= get_loop_var(def
, loop_init_state
->state
);
95 if (loop_init_state
->in_control_flow
) {
96 var
->in_control_flow
= true;
98 /* Add to the tail of the list. That way we start at the beginning of
99 * the defs in the loop instead of the end when walking the list. This
100 * means less recursive calls. Only add defs that are not in nested
101 * loops or conditional blocks.
103 list_addtail(&var
->process_link
, &loop_init_state
->state
->process_list
);
112 init_loop_block(nir_block
*block
, loop_info_state
*state
,
113 bool in_control_flow
)
115 init_loop_state init_state
= {.in_control_flow
= in_control_flow
,
118 nir_foreach_instr(instr
, block
) {
119 if (instr
->type
== nir_instr_type_intrinsic
||
120 instr
->type
== nir_instr_type_alu
||
121 instr
->type
== nir_instr_type_tex
) {
122 state
->loop
->info
->num_instructions
++;
125 nir_foreach_ssa_def(instr
, init_loop_def
, &init_state
);
132 is_var_alu(nir_loop_variable
*var
)
134 return var
->def
->parent_instr
->type
== nir_instr_type_alu
;
138 is_var_constant(nir_loop_variable
*var
)
140 return var
->def
->parent_instr
->type
== nir_instr_type_load_const
;
144 is_var_phi(nir_loop_variable
*var
)
146 return var
->def
->parent_instr
->type
== nir_instr_type_phi
;
150 mark_invariant(nir_ssa_def
*def
, loop_info_state
*state
)
152 nir_loop_variable
*var
= get_loop_var(def
, state
);
154 if (var
->type
== invariant
)
158 var
->type
= invariant
;
162 if (var
->type
== not_invariant
)
165 if (is_var_alu(var
)) {
166 nir_alu_instr
*alu
= nir_instr_as_alu(def
->parent_instr
);
168 for (unsigned i
= 0; i
< nir_op_infos
[alu
->op
].num_inputs
; i
++) {
169 if (!mark_invariant(alu
->src
[i
].src
.ssa
, state
)) {
170 var
->type
= not_invariant
;
174 var
->type
= invariant
;
178 /* Phis shouldn't be invariant except if one operand is invariant, and the
179 * other is the phi itself. These should be removed by opt_remove_phis.
180 * load_consts are already set to invariant and constant during init,
181 * and so should return earlier. Remaining op_codes are set undefined.
183 var
->type
= not_invariant
;
188 compute_invariance_information(loop_info_state
*state
)
190 /* An expression is invariant in a loop L if:
193 * – it’s a variable use, all of whose single defs are outside of L
195 * – it’s a pure computation all of whose args are loop invariant
196 * – it’s a variable use whose single reaching def, and the
197 * rhs of that def is loop-invariant
199 list_for_each_entry_safe(nir_loop_variable
, var
, &state
->process_list
,
201 assert(!var
->in_control_flow
);
203 if (mark_invariant(var
->def
, state
))
204 list_del(&var
->process_link
);
209 compute_induction_information(loop_info_state
*state
)
211 bool found_induction_var
= false;
212 list_for_each_entry_safe(nir_loop_variable
, var
, &state
->process_list
,
215 /* It can't be an induction variable if it is invariant. Invariants and
216 * things in nested loops or conditionals should have been removed from
217 * the list by compute_invariance_information().
219 assert(!var
->in_control_flow
&& var
->type
!= invariant
);
221 /* We are only interested in checking phis for the basic induction
222 * variable case as its simple to detect. All basic induction variables
225 if (!is_var_phi(var
))
228 nir_phi_instr
*phi
= nir_instr_as_phi(var
->def
->parent_instr
);
229 nir_basic_induction_var
*biv
= rzalloc(state
, nir_basic_induction_var
);
231 nir_foreach_phi_src(src
, phi
) {
232 nir_loop_variable
*src_var
= get_loop_var(src
->src
.ssa
, state
);
234 /* If one of the sources is in a conditional or nested block then
237 if (src_var
->in_control_flow
)
240 if (!src_var
->in_loop
) {
241 biv
->def_outside_loop
= src_var
;
242 } else if (is_var_alu(src_var
)) {
243 nir_alu_instr
*alu
= nir_instr_as_alu(src_var
->def
->parent_instr
);
245 if (nir_op_infos
[alu
->op
].num_inputs
== 2) {
246 biv
->alu_def
= src_var
;
247 biv
->alu_op
= alu
->op
;
249 for (unsigned i
= 0; i
< 2; i
++) {
250 /* Is one of the operands const, and the other the phi */
251 if (alu
->src
[i
].src
.ssa
->parent_instr
->type
== nir_instr_type_load_const
&&
252 alu
->src
[1-i
].src
.ssa
== &phi
->dest
.ssa
)
253 biv
->invariant
= get_loop_var(alu
->src
[i
].src
.ssa
, state
);
259 if (biv
->alu_def
&& biv
->def_outside_loop
&& biv
->invariant
&&
260 is_var_constant(biv
->def_outside_loop
)) {
261 assert(is_var_constant(biv
->invariant
));
262 biv
->alu_def
->type
= basic_induction
;
263 biv
->alu_def
->ind
= biv
;
264 var
->type
= basic_induction
;
267 found_induction_var
= true;
272 return found_induction_var
;
276 initialize_ssa_def(nir_ssa_def
*def
, void *void_state
)
278 loop_info_state
*state
= void_state
;
279 nir_loop_variable
*var
= get_loop_var(def
, state
);
281 var
->in_loop
= false;
284 if (def
->parent_instr
->type
== nir_instr_type_load_const
) {
285 var
->type
= invariant
;
287 var
->type
= undefined
;
294 find_loop_terminators(loop_info_state
*state
)
296 bool success
= false;
297 foreach_list_typed_safe(nir_cf_node
, node
, node
, &state
->loop
->body
) {
298 if (node
->type
== nir_cf_node_if
) {
299 nir_if
*nif
= nir_cf_node_as_if(node
);
301 nir_block
*break_blk
= NULL
;
302 nir_block
*continue_from_blk
= NULL
;
303 bool continue_from_then
= true;
305 nir_block
*last_then
= nir_if_last_then_block(nif
);
306 nir_block
*last_else
= nir_if_last_else_block(nif
);
307 if (nir_block_ends_in_break(last_then
)) {
308 break_blk
= last_then
;
309 continue_from_blk
= last_else
;
310 continue_from_then
= false;
311 } else if (nir_block_ends_in_break(last_else
)) {
312 break_blk
= last_else
;
313 continue_from_blk
= last_then
;
316 /* If there is a break then we should find a terminator. If we can
317 * not find a loop terminator, but there is a break-statement then
318 * we should return false so that we do not try to find trip-count
320 if (!nir_is_trivial_loop_if(nif
, break_blk
))
323 /* Continue if the if contained no jumps at all */
327 if (nif
->condition
.ssa
->parent_instr
->type
== nir_instr_type_phi
)
330 nir_loop_terminator
*terminator
=
331 rzalloc(state
->loop
->info
, nir_loop_terminator
);
333 list_addtail(&terminator
->loop_terminator_link
,
334 &state
->loop
->info
->loop_terminator_list
);
336 terminator
->nif
= nif
;
337 terminator
->break_block
= break_blk
;
338 terminator
->continue_from_block
= continue_from_blk
;
339 terminator
->continue_from_then
= continue_from_then
;
340 terminator
->conditional_instr
= nif
->condition
.ssa
->parent_instr
;
350 get_iteration(nir_op cond_op
, nir_const_value
*initial
, nir_const_value
*step
,
351 nir_const_value
*limit
)
360 int32_t initial_val
= initial
->i32
[0];
361 int32_t span
= limit
->i32
[0] - initial_val
;
362 iter
= span
/ step
->i32
[0];
367 uint32_t initial_val
= initial
->u32
[0];
368 uint32_t span
= limit
->u32
[0] - initial_val
;
369 iter
= span
/ step
->u32
[0];
376 float initial_val
= initial
->f32
[0];
377 float span
= limit
->f32
[0] - initial_val
;
378 iter
= span
/ step
->f32
[0];
389 test_iterations(int32_t iter_int
, nir_const_value
*step
,
390 nir_const_value
*limit
, nir_op cond_op
, unsigned bit_size
,
391 nir_alu_type induction_base_type
,
392 nir_const_value
*initial
, bool limit_rhs
, bool invert_cond
)
394 assert(nir_op_infos
[cond_op
].num_inputs
== 2);
396 nir_const_value iter_src
= { {0, } };
399 switch (induction_base_type
) {
401 iter_src
.f32
[0] = (float) iter_int
;
402 mul_op
= nir_op_fmul
;
403 add_op
= nir_op_fadd
;
407 iter_src
.i32
[0] = iter_int
;
408 mul_op
= nir_op_imul
;
409 add_op
= nir_op_iadd
;
412 unreachable("Unhandled induction variable base type!");
415 /* Multiple the iteration count we are testing by the number of times we
416 * step the induction variable each iteration.
418 nir_const_value mul_src
[2] = { iter_src
, *step
};
419 nir_const_value mul_result
=
420 nir_eval_const_opcode(mul_op
, 1, bit_size
, mul_src
);
422 /* Add the initial value to the accumulated induction variable total */
423 nir_const_value add_src
[2] = { mul_result
, *initial
};
424 nir_const_value add_result
=
425 nir_eval_const_opcode(add_op
, 1, bit_size
, add_src
);
427 nir_const_value src
[2] = { { {0, } }, { {0, } } };
428 src
[limit_rhs
? 0 : 1] = add_result
;
429 src
[limit_rhs
? 1 : 0] = *limit
;
431 /* Evaluate the loop exit condition */
432 nir_const_value result
= nir_eval_const_opcode(cond_op
, 1, bit_size
, src
);
434 return invert_cond
? (result
.u32
[0] == 0) : (result
.u32
[0] != 0);
438 calculate_iterations(nir_const_value
*initial
, nir_const_value
*step
,
439 nir_const_value
*limit
, nir_loop_variable
*alu_def
,
440 nir_alu_instr
*cond_alu
, bool limit_rhs
, bool invert_cond
)
442 assert(initial
!= NULL
&& step
!= NULL
&& limit
!= NULL
);
444 nir_alu_instr
*alu
= nir_instr_as_alu(alu_def
->def
->parent_instr
);
446 /* nir_op_isub should have been lowered away by this point */
447 assert(alu
->op
!= nir_op_isub
);
449 /* Make sure the alu type for our induction variable is compatible with the
450 * conditional alus input type. If its not something has gone really wrong.
452 nir_alu_type induction_base_type
=
453 nir_alu_type_get_base_type(nir_op_infos
[alu
->op
].output_type
);
454 if (induction_base_type
== nir_type_int
|| induction_base_type
== nir_type_uint
) {
455 assert(nir_alu_type_get_base_type(nir_op_infos
[cond_alu
->op
].input_types
[1]) == nir_type_int
||
456 nir_alu_type_get_base_type(nir_op_infos
[cond_alu
->op
].input_types
[1]) == nir_type_uint
);
458 assert(nir_alu_type_get_base_type(nir_op_infos
[cond_alu
->op
].input_types
[0]) ==
459 induction_base_type
);
462 /* Check for nsupported alu operations */
463 if (alu
->op
!= nir_op_iadd
&& alu
->op
!= nir_op_fadd
)
466 /* do-while loops can increment the starting value before the condition is
473 * Here we check if the induction variable is used directly by the loop
474 * condition and if so we assume we need to step the initial value.
476 unsigned trip_offset
= 0;
477 if (cond_alu
->src
[0].src
.ssa
== alu_def
->def
||
478 cond_alu
->src
[1].src
.ssa
== alu_def
->def
) {
482 int iter_int
= get_iteration(cond_alu
->op
, initial
, step
, limit
);
484 /* If iter_int is negative the loop is ill-formed or is the conditional is
485 * unsigned with a huge iteration count so don't bother going any further.
490 /* An explanation from the GLSL unrolling pass:
492 * Make sure that the calculated number of iterations satisfies the exit
493 * condition. This is needed to catch off-by-one errors and some types of
494 * ill-formed loops. For example, we need to detect that the following
495 * loop does not have a maximum iteration count.
497 * for (float x = 0.0; x != 0.9; x += 0.2);
499 assert(nir_src_bit_size(alu
->src
[0].src
) ==
500 nir_src_bit_size(alu
->src
[1].src
));
501 unsigned bit_size
= nir_src_bit_size(alu
->src
[0].src
);
502 for (int bias
= -1; bias
<= 1; bias
++) {
503 const int iter_bias
= iter_int
+ bias
;
505 if (test_iterations(iter_bias
, step
, limit
, cond_alu
->op
, bit_size
,
506 induction_base_type
, initial
,
507 limit_rhs
, invert_cond
)) {
508 return iter_bias
> 0 ? iter_bias
- trip_offset
: iter_bias
;
515 /* Run through each of the terminators of the loop and try to infer a possible
516 * trip-count. We need to check them all, and set the lowest trip-count as the
517 * trip-count of our loop. If one of the terminators has an undecidable
518 * trip-count we can not safely assume anything about the duration of the
522 find_trip_count(loop_info_state
*state
)
524 bool trip_count_known
= true;
525 nir_loop_terminator
*limiting_terminator
= NULL
;
526 int min_trip_count
= -1;
528 list_for_each_entry(nir_loop_terminator
, terminator
,
529 &state
->loop
->info
->loop_terminator_list
,
530 loop_terminator_link
) {
532 if (terminator
->conditional_instr
->type
!= nir_instr_type_alu
) {
533 /* If we get here the loop is dead and will get cleaned up by the
534 * nir_opt_dead_cf pass.
536 trip_count_known
= false;
540 nir_alu_instr
*alu
= nir_instr_as_alu(terminator
->conditional_instr
);
541 nir_loop_variable
*basic_ind
= NULL
;
542 nir_loop_variable
*limit
= NULL
;
543 bool limit_rhs
= true;
546 case nir_op_fge
: case nir_op_ige
: case nir_op_uge
:
547 case nir_op_flt
: case nir_op_ilt
: case nir_op_ult
:
548 case nir_op_feq
: case nir_op_ieq
:
549 case nir_op_fne
: case nir_op_ine
:
551 /* We assume that the limit is the "right" operand */
552 basic_ind
= get_loop_var(alu
->src
[0].src
.ssa
, state
);
553 limit
= get_loop_var(alu
->src
[1].src
.ssa
, state
);
555 if (basic_ind
->type
!= basic_induction
) {
556 /* We had it the wrong way, flip things around */
557 basic_ind
= get_loop_var(alu
->src
[1].src
.ssa
, state
);
558 limit
= get_loop_var(alu
->src
[0].src
.ssa
, state
);
562 /* The comparison has to have a basic induction variable
563 * and a constant for us to be able to find trip counts
565 if (basic_ind
->type
!= basic_induction
|| !is_var_constant(limit
)) {
566 trip_count_known
= false;
570 /* We have determined that we have the following constants:
571 * (With the typical int i = 0; i < x; i++; as an example)
574 * - Step / iteration size
575 * Thats all thats needed to calculate the trip-count
578 nir_const_value initial_val
=
579 nir_instr_as_load_const(basic_ind
->ind
->def_outside_loop
->
580 def
->parent_instr
)->value
;
582 nir_const_value step_val
=
583 nir_instr_as_load_const(basic_ind
->ind
->invariant
->def
->
584 parent_instr
)->value
;
586 nir_const_value limit_val
=
587 nir_instr_as_load_const(limit
->def
->parent_instr
)->value
;
589 int iterations
= calculate_iterations(&initial_val
, &step_val
,
591 basic_ind
->ind
->alu_def
, alu
,
593 terminator
->continue_from_then
);
595 /* Where we not able to calculate the iteration count */
596 if (iterations
== -1) {
597 trip_count_known
= false;
601 /* If this is the first run or we have found a smaller amount of
602 * iterations than previously (we have identified a more limiting
603 * terminator) set the trip count and limiting terminator.
605 if (min_trip_count
== -1 || iterations
< min_trip_count
) {
606 min_trip_count
= iterations
;
607 limiting_terminator
= terminator
;
612 trip_count_known
= false;
616 state
->loop
->info
->is_trip_count_known
= trip_count_known
;
617 if (min_trip_count
> -1)
618 state
->loop
->info
->trip_count
= min_trip_count
;
619 state
->loop
->info
->limiting_terminator
= limiting_terminator
;
623 force_unroll_array_access(loop_info_state
*state
, nir_shader
*ns
,
624 nir_deref_instr
*deref
)
626 for (nir_deref_instr
*d
= deref
; d
; d
= nir_deref_instr_parent(d
)) {
627 if (d
->deref_type
!= nir_deref_type_array
)
630 assert(d
->arr
.index
.is_ssa
);
631 nir_loop_variable
*array_index
= get_loop_var(d
->arr
.index
.ssa
, state
);
633 if (array_index
->type
!= basic_induction
)
636 nir_deref_instr
*parent
= nir_deref_instr_parent(d
);
637 assert(glsl_type_is_array(parent
->type
) ||
638 glsl_type_is_matrix(parent
->type
));
639 if (glsl_get_length(parent
->type
) == state
->loop
->info
->trip_count
) {
640 state
->loop
->info
->force_unroll
= true;
644 if (deref
->mode
& state
->indirect_mask
) {
645 state
->loop
->info
->force_unroll
= true;
654 force_unroll_heuristics(loop_info_state
*state
, nir_shader
*ns
,
657 nir_foreach_instr(instr
, block
) {
658 if (instr
->type
!= nir_instr_type_intrinsic
)
661 nir_intrinsic_instr
*intrin
= nir_instr_as_intrinsic(instr
);
663 /* Check for arrays variably-indexed by a loop induction variable.
664 * Unrolling the loop may convert that access into constant-indexing.
666 if (intrin
->intrinsic
== nir_intrinsic_load_deref
||
667 intrin
->intrinsic
== nir_intrinsic_store_deref
||
668 intrin
->intrinsic
== nir_intrinsic_copy_deref
) {
669 if (force_unroll_array_access(state
, ns
,
670 nir_src_as_deref(intrin
->src
[0])))
673 if (intrin
->intrinsic
== nir_intrinsic_copy_deref
&&
674 force_unroll_array_access(state
, ns
,
675 nir_src_as_deref(intrin
->src
[1])))
684 get_loop_info(loop_info_state
*state
, nir_function_impl
*impl
)
686 /* Initialize all variables to "outside_loop". This also marks defs
687 * invariant and constant if they are nir_instr_type_load_consts
689 nir_foreach_block(block
, impl
) {
690 nir_foreach_instr(instr
, block
)
691 nir_foreach_ssa_def(instr
, initialize_ssa_def
, state
);
694 /* Add all entries in the outermost part of the loop to the processing list
695 * Mark the entries in conditionals or in nested loops accordingly
697 foreach_list_typed_safe(nir_cf_node
, node
, node
, &state
->loop
->body
) {
698 switch (node
->type
) {
700 case nir_cf_node_block
:
701 init_loop_block(nir_cf_node_as_block(node
), state
, false);
705 nir_foreach_block_in_cf_node(block
, node
)
706 init_loop_block(block
, state
, true);
709 case nir_cf_node_loop
:
710 nir_foreach_block_in_cf_node(block
, node
) {
711 init_loop_block(block
, state
, true);
715 case nir_cf_node_function
:
720 /* Induction analysis needs invariance information so get that first */
721 compute_invariance_information(state
);
723 /* We have invariance information so try to find induction variables */
724 if (!compute_induction_information(state
))
727 /* Try to find all simple terminators of the loop. If we can't find any,
728 * or we find possible terminators that have side effects then bail.
730 if (!find_loop_terminators(state
)) {
731 list_for_each_entry_safe(nir_loop_terminator
, terminator
,
732 &state
->loop
->info
->loop_terminator_list
,
733 loop_terminator_link
) {
734 list_del(&terminator
->loop_terminator_link
);
735 ralloc_free(terminator
);
740 /* Run through each of the terminators and try to compute a trip-count */
741 find_trip_count(state
);
743 nir_shader
*ns
= impl
->function
->shader
;
744 foreach_list_typed_safe(nir_cf_node
, node
, node
, &state
->loop
->body
) {
745 if (node
->type
== nir_cf_node_block
) {
746 if (force_unroll_heuristics(state
, ns
, nir_cf_node_as_block(node
)))
749 nir_foreach_block_in_cf_node(block
, node
) {
750 if (force_unroll_heuristics(state
, ns
, block
))
757 static loop_info_state
*
758 initialize_loop_info_state(nir_loop
*loop
, void *mem_ctx
,
759 nir_function_impl
*impl
)
761 loop_info_state
*state
= rzalloc(mem_ctx
, loop_info_state
);
762 state
->loop_vars
= rzalloc_array(mem_ctx
, nir_loop_variable
,
766 list_inithead(&state
->process_list
);
769 ralloc_free(loop
->info
);
771 loop
->info
= rzalloc(loop
, nir_loop_info
);
773 list_inithead(&loop
->info
->loop_terminator_list
);
779 process_loops(nir_cf_node
*cf_node
, nir_variable_mode indirect_mask
)
781 switch (cf_node
->type
) {
782 case nir_cf_node_block
:
784 case nir_cf_node_if
: {
785 nir_if
*if_stmt
= nir_cf_node_as_if(cf_node
);
786 foreach_list_typed(nir_cf_node
, nested_node
, node
, &if_stmt
->then_list
)
787 process_loops(nested_node
, indirect_mask
);
788 foreach_list_typed(nir_cf_node
, nested_node
, node
, &if_stmt
->else_list
)
789 process_loops(nested_node
, indirect_mask
);
792 case nir_cf_node_loop
: {
793 nir_loop
*loop
= nir_cf_node_as_loop(cf_node
);
794 foreach_list_typed(nir_cf_node
, nested_node
, node
, &loop
->body
)
795 process_loops(nested_node
, indirect_mask
);
799 unreachable("unknown cf node type");
802 nir_loop
*loop
= nir_cf_node_as_loop(cf_node
);
803 nir_function_impl
*impl
= nir_cf_node_get_function(cf_node
);
804 void *mem_ctx
= ralloc_context(NULL
);
806 loop_info_state
*state
= initialize_loop_info_state(loop
, mem_ctx
, impl
);
807 state
->indirect_mask
= indirect_mask
;
809 get_loop_info(state
, impl
);
811 ralloc_free(mem_ctx
);
815 nir_loop_analyze_impl(nir_function_impl
*impl
,
816 nir_variable_mode indirect_mask
)
818 nir_index_ssa_defs(impl
);
819 foreach_list_typed(nir_cf_node
, node
, node
, &impl
->body
)
820 process_loops(node
, indirect_mask
);