nir/loop_analyze: Fix phi-of-identical-alu detection
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 20 Jun 2019 21:13:39 +0000 (16:13 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Wed, 10 Jul 2019 00:20:59 +0000 (00:20 +0000)
commit9f7ffe41dd185487479ea8846df1f5cdbf1b83a6
tree2f4ee7bfc6e1f28fa5a70281ecee0c2f1ac13460
parent6e984bcb92cf5e8b7da7387bc73cf6519ea2f43d
nir/loop_analyze: Fix phi-of-identical-alu detection

One issue was that the original version didn't check that swizzles
matched when comparing ALU instructions so it could end up matching
very different instructions.  Using the nir_instrs_equal function from
nir_instr_set.c which we use for CSE should be much more reliable.
Another was that the loop assumes it will only run two iterations which
may not be true.  If there's something which guarantees that this case
only happens for phis after ifs, it wasn't documented.

Fixes: 9e6b39e1d521 "nir: detect more induction variables"
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/nir/nir_loop_analyze.c