nir: Add alignment information to cast derefs
[mesa.git] / src / compiler / nir / nir_validate.c
index 11e9841e1784222d30d918245fc88b60290cce76..b7622cd06a98e7a0f2d3f7a9f1bce75090d5e067 100644 (file)
@@ -418,6 +418,12 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state)
       /* We just validate that the type and mode are there */
       validate_assert(state, instr->mode);
       validate_assert(state, instr->type);
+      if (instr->cast.align_mul > 0) {
+         validate_assert(state, util_is_power_of_two_nonzero(instr->cast.align_mul));
+         validate_assert(state, instr->cast.align_offset < instr->cast.align_mul);
+      } else {
+         validate_assert(state, instr->cast.align_offset == 0);
+      }
    } else {
       /* We require the parent to be SSA.  This may be lifted in the future */
       validate_assert(state, instr->parent.is_ssa);