RISC-V: Avoid redundant flow in forward fusion
authorJu-Zhe Zhong <juzhe.zhong@rivai.ai>
Mon, 9 Jan 2023 22:40:07 +0000 (06:40 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 26 Jan 2023 19:10:16 +0000 (03:10 +0800)
gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (pass_vsetvl::forward_demand_fusion):
Add pre-check for redundant flow.

gcc/config/riscv/riscv-vsetvl.cc

index f67459c..9140b18 100644 (file)
@@ -2141,6 +2141,9 @@ pass_vsetvl::forward_demand_fusion (void)
       if (!prop.valid_or_dirty_p ())
        continue;
 
+      if (cfg_bb == ENTRY_BLOCK_PTR_FOR_FN (cfun))
+       continue;
+
       edge e;
       edge_iterator ei;
       /* Forward propagate to each successor.  */
@@ -2154,6 +2157,11 @@ pass_vsetvl::forward_demand_fusion (void)
          /* It's quite obvious, we don't need to propagate itself.  */
          if (e->dest->index == cfg_bb->index)
            continue;
+         /* We don't propagate through critical edges.  */
+         if (e->flags & EDGE_COMPLEX)
+           continue;
+         if (e->dest->index == EXIT_BLOCK_PTR_FOR_FN (cfun)->index)
+           continue;
 
          /* If there is nothing to propagate, just skip it.  */
          if (!local_dem.valid_or_dirty_p ())