summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2019-09-23 14:48:22 +0100
committerDylan Baker <[email protected]>2019-09-26 08:47:50 -0700
commitf4faf5cbd7da4f00d9293f29d1212be91bc88314 (patch)
treeb76507d6916994c80bcef1dbff8d4d696db4d9ef /src
parentb29682c2909a483f9ad7f7051e5e077d07c870bd (diff)
nir/opt_remove_phis: handle phis with no sources
This can happen with loops with unreachable exits which are later optimized away. Fixes assertion in dEQP-VK.graphicsfuzz.unreachable-loops with RADV. Cc: [email protected] Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> (cherry picked from commit 12372d60fff676c458c7a54a934f619548337f0e)
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_opt_remove_phis.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c
index a3186116798..36e01ff7245 100644
--- a/src/compiler/nir/nir_opt_remove_phis.c
+++ b/src/compiler/nir/nir_opt_remove_phis.c
@@ -109,12 +109,13 @@ remove_phis_block(nir_block *block, nir_builder *b)
if (!srcs_same)
continue;
- /* We must have found at least one definition, since there must be at
- * least one forward edge.
- */
- assert(def != NULL);
+ if (!def) {
+ /* In this case, the phi had no sources. So turn it into an undef. */
- if (mov) {
+ b->cursor = nir_after_phis(block);
+ def = nir_ssa_undef(b, phi->dest.ssa.num_components,
+ phi->dest.ssa.bit_size);
+ } else if (mov) {
/* If the sources were all movs from the same source with the same
* swizzle, then we can't just pick a random move because it may not
* dominate the phi node. Instead, we need to emit our own move after