*/
if (alu->src[1-i].src.ssa == &phi->dest.ssa &&
alu_src_has_identity_swizzle(alu, 1 - i)) {
- nir_src *src = &alu->src[i].src;
- if (nir_src_is_const(*src))
- biv->alu = alu;
- else if (is_only_uniform_src(src)) {
- /* Update value of induction variable is a statement
- * contains only uniform and constant
- */
+ if (is_only_uniform_src(&alu->src[i].src)) {
var->update_src = alu->src + i;
biv->alu = alu;
}
nir_instr *inst = biv->def_outside_loop->parent_instr;
if (inst->type == nir_instr_type_load_const) {
/* Initial value of induction variable is a constant */
- if (var->update_src) {
- alu_src_var->update_src = var->update_src;
- ralloc_free(biv);
- } else {
- alu_src_var->type = basic_induction;
- alu_src_var->ind = biv;
- var->type = basic_induction;
- var->ind = biv;
-
- found_induction_var = true;
- }
+ alu_src_var->init_src = var->init_src;
+ alu_src_var->update_src = var->update_src;
+ alu_src_var->type = basic_induction;
+ alu_src_var->ind = biv;
+ var->type = basic_induction;
+ var->ind = biv;
+
+ found_induction_var = true;
num_induction_vars += 2;
} else if (is_only_uniform_src(init_src)) {
/* Initial value of induction variable is a uniform */
nir_const_value initial_val = nir_ssa_scalar_as_const_value(initial_s);
- /* We are guaranteed by earlier code that at least one of these sources
- * is a constant but we don't know which.
+ /* We are not guaranteed by that at one of these sources is a constant.
+ * Try to find one.
*/
nir_const_value step_val;
memset(&step_val, 0, sizeof(step_val));
- UNUSED bool found_step_value = false;
+ bool found_step_value = false;
assert(nir_op_infos[ind_var->alu->op].num_inputs == 2);
for (unsigned i = 0; i < 2; i++) {
nir_ssa_scalar alu_src = nir_ssa_scalar_chase_alu_src(alu_s, i);
break;
}
}
- assert(found_step_value);
+
+ if (!found_step_value)
+ continue;
int iterations = calculate_iterations(initial_val, step_val, limit_val,
ind_var->alu, cond,
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}
EXPECT_EQ(2, loop->info->num_induction_vars);
ASSERT_NE((void *)0, loop->info->induction_vars);
- /* Since the initializer and increments are constants, the init_src and
- * update_src fields will be NULL. The def field should not be NULL.
+ /* Since the initializer is a constant, the init_src field will be
+ * NULL. The def field should not be NULL. The update_src field should
+ * point to a load_const.
*/
const nir_loop_induction_variable *const ivars = loop->info->induction_vars;
for (unsigned i = 0; i < loop->info->num_induction_vars; i++) {
EXPECT_NE((void *)0, ivars[i].def);
EXPECT_EQ((void *)0, ivars[i].init_src);
- EXPECT_EQ((void *)0, ivars[i].update_src);
+ ASSERT_NE((void *)0, ivars[i].update_src);
+ EXPECT_TRUE(nir_src_is_const(ivars[i].update_src->src));
}
}