]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Fix potential ICE of global vsetvl elimination
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Wed, 23 Aug 2023 02:42:01 +0000 (10:42 +0800)
committerPan Li <pan2.li@intel.com>
Wed, 23 Aug 2023 02:48:45 +0000 (10:48 +0800)
Committed for following VSETVL refactor patch to make V2 patch easier to review.
gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc
(pass_vsetvl::global_eliminate_vsetvl_insn): Fix potential ICE.

gcc/config/riscv/riscv-vsetvl.cc

index ec1aaa4b442dec7fbdea01b69a6440baf2a314e8..f7558cad2e22b2e5e37da2e6f711d23fbdfc1380 100644 (file)
@@ -4383,7 +4383,7 @@ pass_vsetvl::global_eliminate_vsetvl_insn (const bb_info *bb) const
 
   unsigned int bb_index;
   sbitmap_iterator sbi;
-  rtx avl = get_avl (dem.get_insn ()->rtl ());
+  rtx avl = dem.get_avl ();
   hash_set<set_info *> sets
     = get_all_sets (dem.get_avl_source (), true, false, false);
   /* Condition 2: All VL/VTYPE available in are all compatible.  */
@@ -4407,7 +4407,10 @@ pass_vsetvl::global_eliminate_vsetvl_insn (const bb_info *bb) const
     {
       sbitmap avout = m_vector_manager->vector_avout[e->src->index];
       if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun)
-         || e->src == EXIT_BLOCK_PTR_FOR_FN (cfun) || bitmap_empty_p (avout))
+         || e->src == EXIT_BLOCK_PTR_FOR_FN (cfun)
+         || (unsigned int) e->src->index
+              >= m_vector_manager->vector_block_infos.length ()
+         || bitmap_empty_p (avout))
        return false;
 
       EXECUTE_IF_SET_IN_BITMAP (avout, 0, bb_index, sbi)