From: Friedrich Vock Date: Thu, 8 Dec 2022 20:26:28 +0000 (+0100) Subject: nir: Do not consider phis with incompatible dests equal X-Git-Tag: upstream/23.3.3~15685 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a54c2c828941ef1325fc1a3b49eba32f3c964f0d;p=platform%2Fupstream%2Fmesa.git nir: Do not consider phis with incompatible dests equal CSE tries to collapse equal instructions, and collapsing two phis with incompatible dests is illegal. Reviewed-by: Konstantin Seurer Reviewed-by: Daniel Schürmann Reviewed-by: Jason Ekstrand Fixes: 6bdce55c ("nir: Add a basic CSE pass") Part-of: --- diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index 032fcbc..985db65 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -707,6 +707,14 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2) if (phi1->instr.block != phi2->instr.block) return false; + /* In case of phis with no sources, the dest needs to be checked + * to ensure that phis with incompatible dests won't get merged + * during CSE. */ + if (phi1->dest.ssa.num_components != phi2->dest.ssa.num_components) + return false; + if (phi1->dest.ssa.bit_size != phi2->dest.ssa.bit_size) + return false; + nir_foreach_phi_src(src1, phi1) { nir_foreach_phi_src(src2, phi2) { if (src1->pred == src2->pred) {