From 99bb2a4de66fa662fb4bcb29df8e2749972ee986 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 24 Aug 2020 11:26:18 -0500 Subject: [PATCH] nir/opt_deref: Don't remove casts with alignment information Generally, if a cast has alignment information, that information is useful and we don't want to loose it. Reviewed-by: Jesse Natalie Reviewed-by: Boris Brezillon Reviewed-by: Karol Herbst Part-of: --- src/compiler/nir/nir_deref.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c index ad0380aa28b..5b9f97b6620 100644 --- a/src/compiler/nir/nir_deref.c +++ b/src/compiler/nir/nir_deref.c @@ -924,6 +924,9 @@ opt_replace_struct_wrapper_cast(nir_builder *b, nir_deref_instr *cast) if (!parent) return false; + if (cast->cast.align_mul > 0) + return false; + if (!glsl_type_is_struct(parent->type)) return false; @@ -954,6 +957,12 @@ opt_deref_cast(nir_builder *b, nir_deref_instr *cast) if (!is_trivial_deref_cast(cast)) return progress; + /* If this deref still contains useful alignment information, we don't want + * to delete it. + */ + if (cast->cast.align_mul > 0) + return progress; + bool trivial_array_cast = is_trivial_array_deref_cast(cast); assert(cast->dest.is_ssa); -- 2.30.2