intel/fs: Don't emit empty ELSE blocks.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 3 Apr 2019 21:24:31 +0000 (14:24 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 29 Apr 2019 05:36:09 +0000 (22:36 -0700)
While we can clean this up later, it's trivial to not generate the
stupid code in the first place, which saves some optimization work.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/intel/compiler/brw_fs_nir.cpp

index 71fe0ff7e2f9925fe82c487af1581426f7442327..526cc13c71ad7d4c7f53ad3b87033449153b35b7 100644 (file)
@@ -409,10 +409,10 @@ fs_visitor::nir_emit_if(nir_if *if_stmt)
 
    nir_emit_cf_list(&if_stmt->then_list);
 
-   /* note: if the else is empty, dead CF elimination will remove it */
-   bld.emit(BRW_OPCODE_ELSE);
-
-   nir_emit_cf_list(&if_stmt->else_list);
+   if (!nir_cf_list_is_empty_block(&if_stmt->else_list)) {
+      bld.emit(BRW_OPCODE_ELSE);
+      nir_emit_cf_list(&if_stmt->else_list);
+   }
 
    bld.emit(BRW_OPCODE_ENDIF);