Lines Matching refs:cast
30 is_trivial_deref_cast(nir_deref_instr *cast)
32 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
36 return cast->modes == parent->modes &&
37 cast->type == parent->type &&
38 cast->dest.ssa.num_components == parent->dest.ssa.num_components &&
39 cast->dest.ssa.bit_size == parent->dest.ssa.bit_size;
271 return deref->cast.ptr_stride;
325 /* A cast doesn't contribute to the offset */
364 /* A cast doesn't contribute to the offset */
478 * paths. Look to see if either contains cast or a ptr_as_array deref. If
662 /* If they're not exactly the same cast, it's hard to compare them so we
771 new_deref->cast.ptr_stride = deref->cast.ptr_stride;
927 is_trivial_array_deref_cast(nir_deref_instr *cast)
929 assert(is_trivial_deref_cast(cast));
931 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
934 return cast->cast.ptr_stride ==
937 return cast->cast.ptr_stride ==
952 opt_remove_restricting_cast_alignments(nir_deref_instr *cast)
954 assert(cast->deref_type == nir_deref_type_cast);
955 if (cast->cast.align_mul == 0)
958 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
971 /* If this cast increases the alignment, we want to keep it.
973 * There is a possibility that the larger alignment provided by this cast
976 * memory operation which, in this case, is the cast and not its parent so
977 * keeping the cast alignment is the right thing to do.
979 if (parent_mul < cast->cast.align_mul)
995 * get here is if something further up the deref chain has a cast with
1005 * cast's alignment offset. In this case, we consider the cast as
1009 assert(cast->cast.align_mul <= parent_mul);
1010 if (parent_offset % cast->cast.align_mul != cast->cast.align_offset)
1016 cast->cast.align_mul = 0;
1017 cast->cast.align_offset = 0;
1025 opt_remove_cast_cast(nir_deref_instr *cast)
1027 nir_deref_instr *first_cast = cast;
1035 if (cast == first_cast)
1038 nir_instr_rewrite_src(&cast->instr, &cast->parent,
1046 * specific mode, we can cast to more general and back but we can never cast
1047 * across modes. For non-cast derefs, we should only ever do anything here if
1048 * the parent eventually comes from a cast that we restricted earlier.
1068 opt_remove_sampler_cast(nir_deref_instr *cast)
1070 assert(cast->deref_type == nir_deref_type_cast);
1071 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
1079 const struct glsl_type *cast_type = cast->type;
1095 /* We're a cast from a more detailed sampler type to a bare sampler or a
1098 nir_ssa_def_rewrite_uses(&cast->dest.ssa,
1100 nir_instr_remove(&cast->instr);
1118 opt_replace_struct_wrapper_cast(nir_builder *b, nir_deref_instr *cast)
1120 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
1124 if (cast->cast.align_mul > 0)
1137 if (cast->type != glsl_get_struct_field(parent->type, 0))
1141 nir_ssa_def_rewrite_uses(&cast->dest.ssa, &replace->dest.ssa);
1142 nir_deref_instr_remove_if_unused(cast);
1147 opt_deref_cast(nir_builder *b, nir_deref_instr *cast)
1151 progress |= opt_remove_restricting_cast_alignments(cast);
1153 if (opt_replace_struct_wrapper_cast(b, cast))
1156 if (opt_remove_sampler_cast(cast))
1159 progress |= opt_remove_cast_cast(cast);
1160 if (!is_trivial_deref_cast(cast))
1166 if (cast->cast.align_mul > 0)
1169 bool trivial_array_cast = is_trivial_array_deref_cast(cast);
1171 assert(cast->dest.is_ssa);
1172 assert(cast->parent.is_ssa);
1174 nir_foreach_use_safe(use_src, &cast->dest.ssa) {
1175 /* If this isn't a trivial array cast, we can't propagate into
1182 nir_instr_rewrite_src(use_src->parent_instr, use_src, cast->parent);
1187 assert(list_is_empty(&cast->dest.ssa.if_uses));
1189 if (nir_deref_instr_remove_if_unused(cast))
1209 * nir_deref_type_array or nir_deref_type_cast. If it's a cast, it
1211 * trivial cast of trivial cast cases should be handled already by
1215 parent->cast.align_mul == 0 &&
1245 is_vector_bitcast_deref(nir_deref_instr *cast,
1249 if (cast->deref_type != nir_deref_type_cast)
1253 if (cast->cast.align_mul > 0)
1256 /* It has to be a cast of another deref */
1257 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
1266 unsigned cast_bit_size = glsl_get_bit_size(cast->type);
1272 if (glsl_get_explicit_stride(cast->type) ||