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;
261 return deref->cast.ptr_stride;
315 /* A cast doesn't contribute to the offset */
354 /* A cast doesn't contribute to the offset */
515 /* If they're not exactly the same cast, it's hard to compare them so we
545 * paths. Look to see if either contains cast or a ptr_as_array deref. If
723 new_deref->cast.ptr_stride = deref->cast.ptr_stride;
855 is_trivial_array_deref_cast(nir_deref_instr *cast)
857 assert(is_trivial_deref_cast(cast));
859 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
862 return cast->cast.ptr_stride ==
865 return cast->cast.ptr_stride ==
880 opt_remove_restricting_cast_alignments(nir_deref_instr *cast)
882 assert(cast->deref_type == nir_deref_type_cast);
883 if (cast->cast.align_mul == 0)
886 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
899 /* If this cast increases the alignment, we want to keep it.
901 * There is a possibility that the larger alignment provided by this cast
904 * memory operation which, in this case, is the cast and not its parent so
905 * keeping the cast alignment is the right thing to do.
907 if (parent_mul < cast->cast.align_mul)
923 * get here is if something further up the deref chain has a cast with
933 * cast's alignment offset. In this case, we consider the cast as
937 assert(cast->cast.align_mul <= parent_mul);
938 if (parent_offset % cast->cast.align_mul != cast->cast.align_offset)
944 cast->cast.align_mul = 0;
945 cast->cast.align_offset = 0;
953 opt_remove_cast_cast(nir_deref_instr *cast)
955 nir_deref_instr *first_cast = cast;
963 if (cast == first_cast)
966 nir_instr_rewrite_src(&cast->instr, &cast->parent,
974 * specific mode, we can cast to more general and back but we can never cast
975 * across modes. For non-cast derefs, we should only ever do anything here if
976 * the parent eventually comes from a cast that we restricted earlier.
996 opt_remove_sampler_cast(nir_deref_instr *cast)
998 assert(cast->deref_type == nir_deref_type_cast);
999 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
1007 const struct glsl_type *cast_type = cast->type;
1022 /* We're a cast from a more detailed sampler type to a bare sampler */
1023 nir_ssa_def_rewrite_uses(&cast->dest.ssa,
1025 nir_instr_remove(&cast->instr);
1043 opt_replace_struct_wrapper_cast(nir_builder *b, nir_deref_instr *cast)
1045 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
1049 if (cast->cast.align_mul > 0)
1062 if (cast->type != glsl_get_struct_field(parent->type, 0))
1066 nir_ssa_def_rewrite_uses(&cast->dest.ssa, &replace->dest.ssa);
1067 nir_deref_instr_remove_if_unused(cast);
1072 opt_deref_cast(nir_builder *b, nir_deref_instr *cast)
1076 progress |= opt_remove_restricting_cast_alignments(cast);
1078 if (opt_replace_struct_wrapper_cast(b, cast))
1081 if (opt_remove_sampler_cast(cast))
1084 progress |= opt_remove_cast_cast(cast);
1085 if (!is_trivial_deref_cast(cast))
1091 if (cast->cast.align_mul > 0)
1094 bool trivial_array_cast = is_trivial_array_deref_cast(cast);
1096 assert(cast->dest.is_ssa);
1097 assert(cast->parent.is_ssa);
1099 nir_foreach_use_safe(use_src, &cast->dest.ssa) {
1100 /* If this isn't a trivial array cast, we can't propagate into
1107 nir_instr_rewrite_src(use_src->parent_instr, use_src, cast->parent);
1112 assert(list_is_empty(&cast->dest.ssa.if_uses));
1114 if (nir_deref_instr_remove_if_unused(cast))
1134 * nir_deref_type_array or nir_deref_type_cast. If it's a cast, it
1136 * trivial cast of trivial cast cases should be handled already by
1140 parent->cast.align_mul == 0 &&
1168 is_vector_bitcast_deref(nir_deref_instr *cast,
1172 if (cast->deref_type != nir_deref_type_cast)
1176 if (cast->cast.align_mul > 0)
1179 /* It has to be a cast of another deref */
1180 nir_deref_instr *parent = nir_src_as_deref(cast->parent);
1189 unsigned cast_bit_size = glsl_get_bit_size(cast->type);
1195 if (glsl_get_explicit_stride(cast->type) ||