if (nir_src_is_const(deref->arr.index) &&
nir_src_as_int(deref->arr.index) == 0) {
/* If it's a ptr_as_array deref with an index of 0, it does nothing
- * and we can just replace its uses with its parent.
+ * and we can just replace its uses with its parent, unless it has
+ * alignment information.
*
* The source of a ptr_as_array deref always has a deref_type of
* nir_deref_type_array or nir_deref_type_cast. If it's a cast, it
* opt_deref_cast() above.
*/
if (parent->deref_type == nir_deref_type_cast &&
+ parent->cast.align_mul == 0 &&
is_trivial_deref_cast(parent))
parent = nir_deref_instr_parent(parent);
nir_ssa_def_rewrite_uses(&deref->dest.ssa,