Skip to content

Commit 925fb05

Browse files
authored
[RISCV][GISel] Fallback to SelectionDAG for vleff intrinsics. (#167776)
Supporting this in GISel requires multiple changes to IRTranslator to support aggregate returns containing scalable vectors and non-scalable types. Falling back is the quickest way to fix the crash. Fixes #167618
1 parent dfe9838 commit 925fb05

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25401,8 +25401,10 @@ bool RISCVTargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
2540125401
if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
2540225402
// Mark RVV intrinsic as supported.
2540325403
if (RISCVVIntrinsicsTable::getRISCVVIntrinsicInfo(II->getIntrinsicID())) {
25404-
// GISel doesn't support tuple types yet.
25405-
if (Inst.getType()->isRISCVVectorTupleTy())
25404+
// GISel doesn't support tuple types yet. It also doesn't suport returning
25405+
// a struct containing a scalable vector like vleff.
25406+
if (Inst.getType()->isRISCVVectorTupleTy() ||
25407+
Inst.getType()->isStructTy())
2540625408
return true;
2540725409

2540825410
for (unsigned i = 0; i < II->arg_size(); ++i)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; RUN: not --crash llc -global-isel -mtriple=riscv64 -mattr=+v -filetype=null %s 2>&1 | FileCheck %s
2+
3+
; Intrinsics returning structs and extractvalue of scalable vector are not
4+
; supported yet.
5+
define <vscale x 1 x i64> @intrinsic_vleff_v_nxv1i64_nxv1i64(ptr %0, i64 %1, ptr %2) nounwind {
6+
entry:
7+
%a = call { <vscale x 1 x i64>, i64 } @llvm.riscv.vleff.nxv1i64(<vscale x 1 x i64> poison, ptr %0, i64 %1)
8+
%b = extractvalue { <vscale x 1 x i64>, i64 } %a, 0
9+
%c = extractvalue { <vscale x 1 x i64>, i64 } %a, 1
10+
store i64 %c, ptr %2
11+
ret <vscale x 1 x i64> %b
12+
}
13+
14+
; CHECK: LLVM ERROR: unable to translate instruction: call llvm.riscv.vleff.nxv1i64.i64.p0 (in function: intrinsic_vleff_v_nxv1i64_nxv1i64)

0 commit comments

Comments
 (0)