Hi,
If the type is unusable for -mrvv-max-lmul=conv-dynamic in
record_type_sizes, we just return. It can happen that all types
are unusable and we end up dereferencing a NULL largest_type.
This patch always records a char type so we have something to work with
later, even if we don't raise LMUL.
Regtested on rva23u64_zvl512b.
Regards
Robin
PR target/128841
gcc/ChangeLog:
* config/riscv/riscv-vector-costs.cc (costs::record_type_sizes):
Record char as largest_type if type is unusable.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr128841.c: New test.
---
gcc/config/riscv/riscv-vector-costs.cc | 5 ++++-
.../gcc.target/riscv/rvv/autovec/pr128841.c | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr128841.c
diff --git a/gcc/config/riscv/riscv-vector-costs.cc
b/gcc/config/riscv/riscv-vector-costs.cc
index d26a390793c..ff37d8c4a8a 100644
--- a/gcc/config/riscv/riscv-vector-costs.cc
+++ b/gcc/config/riscv/riscv-vector-costs.cc
@@ -1545,7 +1545,10 @@ costs::record_type_sizes (vect_cost_for_stmt kind,
stmt_vec_info stmt_info,
|| TREE_CODE (type) == BOOLEAN_TYPE
|| !TYPE_SIZE (type)
|| !tree_fits_uhwi_p (TYPE_SIZE (type)))
- return;
+ {
+ m_largest_type = char_type_node;
+ return;
+ }
unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE (type));
if (!m_largest_type || size > tree_to_uhwi (TYPE_SIZE (m_largest_type)))
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr128841.c
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr128841.c
new file mode 100644
index 00000000000..271d5e0f9af
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr128841.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=rv64gcbv -mabi=lp64d -mrvv-max-lmul=conv-dynamic"
} */
+
+short selectend_nurb_bp_1;
+char selectend_nurb_sel;
+void swap_selection_bpoint();
+void selectend_nurb(char doswap) {
+ int nu_3;
+ while (nu_3--)
+ if (selectend_nurb_bp_1) {
+ if (doswap)
+ swap_selection_bpoint();
+ else
+ selectend_nurb_sel = 1;
+ if (selectend_nurb_sel)
+ break;
+ }
+}
--
2.56.0