From: Jason Ekstrand Date: Tue, 25 Jun 2019 01:27:26 +0000 (-0500) Subject: nir/loop_analyze: Pass nir_const_values directly to helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e0fcea7273bab87b0788e56d4da9b2ea06bdeea;p=mesa.git nir/loop_analyze: Pass nir_const_values directly to helpers Reviewed-by: Timothy Arceri --- diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index 587cf08fa02..0ac04b82799 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -648,10 +648,10 @@ get_iteration(nir_op cond_op, nir_const_value initial, nir_const_value step, } static bool -test_iterations(int32_t iter_int, nir_const_value *step, - nir_const_value *limit, nir_op cond_op, unsigned bit_size, +test_iterations(int32_t iter_int, nir_const_value step, + nir_const_value limit, nir_op cond_op, unsigned bit_size, nir_alu_type induction_base_type, - nir_const_value *initial, bool limit_rhs, bool invert_cond) + nir_const_value initial, bool limit_rhs, bool invert_cond) { assert(nir_op_infos[cond_op].num_inputs == 2); @@ -678,15 +678,15 @@ test_iterations(int32_t iter_int, nir_const_value *step, * step the induction variable each iteration. */ nir_const_value mul_result = - eval_const_binop(mul_op, bit_size, iter_src, *step); + eval_const_binop(mul_op, bit_size, iter_src, step); /* Add the initial value to the accumulated induction variable total */ nir_const_value add_result = - eval_const_binop(add_op, bit_size, mul_result, *initial); + eval_const_binop(add_op, bit_size, mul_result, initial); nir_const_value *src[2]; src[limit_rhs ? 0 : 1] = &add_result; - src[limit_rhs ? 1 : 0] = limit; + src[limit_rhs ? 1 : 0] = &limit; /* Evaluate the loop exit condition */ nir_const_value result; @@ -696,13 +696,11 @@ test_iterations(int32_t iter_int, nir_const_value *step, } static int -calculate_iterations(nir_const_value *initial, nir_const_value *step, - nir_const_value *limit, nir_alu_instr *alu, +calculate_iterations(nir_const_value initial, nir_const_value step, + nir_const_value limit, nir_alu_instr *alu, nir_ssa_scalar cond, nir_op alu_op, bool limit_rhs, bool invert_cond) { - assert(initial != NULL && step != NULL && limit != NULL); - /* nir_op_isub should have been lowered away by this point */ assert(alu->op != nir_op_isub); @@ -743,7 +741,7 @@ calculate_iterations(nir_const_value *initial, nir_const_value *step, assert(nir_src_bit_size(alu->src[0].src) == nir_src_bit_size(alu->src[1].src)); unsigned bit_size = nir_src_bit_size(alu->src[0].src); - int iter_int = get_iteration(alu_op, *initial, *step, *limit, bit_size); + int iter_int = get_iteration(alu_op, initial, step, limit, bit_size); /* If iter_int is negative the loop is ill-formed or is the conditional is * unsigned with a huge iteration count so don't bother going any further. @@ -1013,8 +1011,7 @@ find_trip_count(loop_info_state *state) } assert(found_step_value); - int iterations = calculate_iterations(&initial_val, &step_val, - &limit_val, + int iterations = calculate_iterations(initial_val, step_val, limit_val, ind_var->alu, cond, alu_op, limit_rhs, terminator->continue_from_then);