Skip to content

[RISCV] Disable fixed vectors in getOptimalMemOpType if minimum VLEN is 32. #102974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions llvm/test/CodeGen/RISCV/rvv/memcpy-crash-zvl32b.ll
Original file line number Diff line number Diff line change
@@ -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
Loading