From 233a820f2c3fb0a008a84a16a0920c3bbdbd61f5 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 3 Nov 2020 13:21:37 +0000 Subject: [PATCH] nir: skip bcsel with non-trivial swizzle in opt_simplify_bcsel_of_phi() Fixes validation error in a Dota 2 shader. Signed-off-by: Rhys Perry Reviewed-by: Jason Ekstrand Fixes: b031c643491 ("nir: Convert a bcsel with only phi node sources to a phi node") Part-of: --- src/compiler/nir/nir_opt_if.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c index 4283d445912..31195b12bb7 100644 --- a/src/compiler/nir/nir_opt_if.c +++ b/src/compiler/nir/nir_opt_if.c @@ -635,14 +635,13 @@ opt_simplify_bcsel_of_phi(nir_builder *b, nir_loop *loop) bool match = true; for (unsigned i = 0; i < 3; i++) { - /* FINISHME: The abs and negate cases could be handled by adding - * move instructions at the bottom of the continue block and more - * phi nodes in the header_block. + /* FINISHME: The abs, negate and swizzled cases could be handled by + * adding move instructions at the bottom of the continue block and + * more phi nodes in the header_block. */ - if (!bcsel->src[i].src.is_ssa || + if (!nir_alu_src_is_trivial_ssa(bcsel, i) || bcsel->src[i].src.ssa->parent_instr->type != nir_instr_type_phi || - bcsel->src[i].src.ssa->parent_instr->block != header_block || - bcsel->src[i].negate || bcsel->src[i].abs) { + bcsel->src[i].src.ssa->parent_instr->block != header_block) { match = false; break; }