[llvm] [RISCV] Disable fixed vectors in getOptimalMemOpType if minimum VLEN is 32. (PR #102974)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 13:46:25 PDT 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/102974
This is needed to match #102405 which disabled fixed to scalable vector lowering for VLEN=32.
Fixes #102566 and 102568.
>From d152f5ba8dae177f1b72a18d2c31ba6a70aa51ac Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 12 Aug 2024 13:35:07 -0700
Subject: [PATCH] [RISCV] Disable fixed vectors in getOptimalMemOpType if
minimum VLEN is 32.
This is needed to match #102405 which disabled fixed to scalable
vector lowering for VLEN=32.
Fixes #102566 and 102568.
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 5 +++++
.../CodeGen/RISCV/rvv/memcpy-crash-zvl32b.ll | 17 +++++++++++++++++
2 files changed, 22 insertions(+)
create mode 100644 llvm/test/CodeGen/RISCV/rvv/memcpy-crash-zvl32b.ll
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 3beaa5198259d0..6fde09d89e4839 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -21024,6 +21024,11 @@ EVT RISCVTargetLowering::getOptimalMemOpType(const MemOp &Op,
// which ends up using scalar sequences.
return MVT::Other;
+ // If the minimum VLEN is less than RISCV::RVVBitsPerBlock we don't support
+ // fixed vectors.
+ if (MinVLenInBytes <= RISCV::RVVBitsPerBlock / 8)
+ return MVT::Other;
+
// Prefer i8 for non-zero memset as it allows us to avoid materializing
// a large scalar constant and instead use vmv.v.x/i to do the
// broadcast. For everything else, prefer ELenVT to minimize VL and thus
diff --git a/llvm/test/CodeGen/RISCV/rvv/memcpy-crash-zvl32b.ll b/llvm/test/CodeGen/RISCV/rvv/memcpy-crash-zvl32b.ll
new file mode 100644
index 00000000000000..e020fe1a0aa1ac
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/rvv/memcpy-crash-zvl32b.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=riscv64 -mattr=+zve32x | FileCheck %s
+
+; Make sure we don't with VLEN=32.
+
+define void @c() {
+; CHECK-LABEL: c:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: lw a0, 0(zero)
+; CHECK-NEXT: sw a0, 0(zero)
+; CHECK-NEXT: ret
+entry:
+ call void @llvm.memcpy.p0.p0.i64(ptr null, ptr null, i64 4, i1 false)
+ ret void
+}
+
+declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1
More information about the llvm-commits
mailing list