From 93c4226585cc53fd86dfa3ca2d70d5b417d960b3 Mon Sep 17 00:00:00 2001
From: xuli <xuli1@eswincomputing.com>
Date: Tue, 22 Aug 2023 06:21:00 +0000
Subject: [PATCH] RISCV: Fix PR111074 [GCC13 BUG]

his patch fixes this issue happens on GCC-13.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111074

This patch should be backported to GCC-13.
GCC-14 has rewritten propagate_avl function, so there is no issue.

PR target/111074

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (extract_single_source): Fix bug.
---
 gcc/config/riscv/riscv-vsetvl.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 789eb04b78d0..bd45cb97e63b 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -1183,6 +1183,9 @@ extract_single_source (set_info *set)
     return nullptr;
   hash_set<set_info *> sets = get_all_sets (set, true, false, true);
 
+  if (sets.is_empty ())
+    return nullptr;
+
   insn_info *first_insn = (*sets.begin ())->insn ();
   if (first_insn->is_artificial ())
     return nullptr;
-- 
GitLab