From 02ff26be38413e6283f653c2400b799d87a7b08f Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Sat, 29 Mar 2025 09:51:49 +0100 Subject: [PATCH] ir3: run opt_if after opt_vectorize nir_opt_vectorize could replace swizzled movs with vectorized movs in a different block. If this happens with swizzled movs in a then block, it could leave this block empty. ir3 assumes only the else block can be empty (e.g., when lowering predicates) so make sure ifs are in that canonical form again. This fixes empty predication blocks in some shaders, for example: predt predf ... prede Signed-off-by: Job Noorman Part-of: --- src/freedreno/ir3/ir3_context.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/freedreno/ir3/ir3_context.c b/src/freedreno/ir3/ir3_context.c index 54f2d72717e..a590749a8a6 100644 --- a/src/freedreno/ir3/ir3_context.c +++ b/src/freedreno/ir3/ir3_context.c @@ -120,6 +120,14 @@ ir3_context_init(struct ir3_compiler *compiler, struct ir3_shader *shader, NIR_PASS(_, ctx->s, nir_opt_undef); NIR_PASS(_, ctx->s, nir_copy_prop); NIR_PASS(_, ctx->s, nir_opt_dce); + + /* nir_opt_vectorize could replace swizzled movs with vectorized movs in a + * different block. If this happens with swizzled movs in a then block, it + * could leave this block empty. ir3 assumes only the else block can be + * empty (e.g., when lowering predicates) so make sure ifs are in that + * canonical form again. + */ + NIR_PASS(_, ctx->s, nir_opt_if, 0); } NIR_PASS(progress, ctx->s, nir_convert_to_lcssa, true, true);