[llvm] [RISCV] Limit VLEN in getOptimalMemOpType to prevent creating invalid MVTs. (PR #139116)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 10:46:57 PDT 2025
https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/139116
>From d3b19aee05f40dbe46c783fe8f8c034c0a5408de Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 8 May 2025 10:39:25 -0700
Subject: [PATCH 1/2] [RISCV] Limit VLEN in getOptimalMemOpType to prevent
creating invalid MVTs.
We only guarantee that types that are 1024 bytes or smaller exist
in the MVT enum.
Fixes #139075.
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index f2bc1765bc4c6..1bc601a0c399d 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -23487,7 +23487,9 @@ EVT RISCVTargetLowering::getOptimalMemOpType(const MemOp &Op,
// combining will typically form larger LMUL operations from the LMUL1
// operations emitted here, and that's okay because combining isn't
// introducing new memory operations; it's just merging existing ones.
- const unsigned MinVLenInBytes = Subtarget.getRealMinVLen()/8;
+ // NOTE: We limit to 1024 bytes to avoid creating an invalid MVT.
+ const unsigned MinVLenInBytes = std::min(Subtarget.getRealMinVLen()/8, 1024U);
+
if (Op.size() < MinVLenInBytes)
// TODO: Figure out short memops. For the moment, do the default thing
// which ends up using scalar sequences.
>From dfb9d8338326662bb0453ce22d90bc28459d1eb3 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 8 May 2025 10:46:41 -0700
Subject: [PATCH 2/2] fixup! clang-format/
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 1bc601a0c399d..d1c8de754b8b3 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -23488,7 +23488,8 @@ EVT RISCVTargetLowering::getOptimalMemOpType(const MemOp &Op,
// operations emitted here, and that's okay because combining isn't
// introducing new memory operations; it's just merging existing ones.
// NOTE: We limit to 1024 bytes to avoid creating an invalid MVT.
- const unsigned MinVLenInBytes = std::min(Subtarget.getRealMinVLen()/8, 1024U);
+ const unsigned MinVLenInBytes =
+ std::min(Subtarget.getRealMinVLen() / 8, 1024U);
if (Op.size() < MinVLenInBytes)
// TODO: Figure out short memops. For the moment, do the default thing
More information about the llvm-commits
mailing list