Skip to content

Commit eec87bf

Browse files
committed
[RISCV][GISel] Fallback to SelectionDAG for vleff intrinsics.
Fixes #167618 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.
1 parent a799a8e commit eec87bf

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25418,8 +25418,10 @@ bool RISCVTargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
2541825418
if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
2541925419
// Mark RVV intrinsic as supported.
2542025420
if (RISCVVIntrinsicsTable::getRISCVVIntrinsicInfo(II->getIntrinsicID())) {
25421-
// GISel doesn't support tuple types yet.
25422-
if (Inst.getType()->isRISCVVectorTupleTy())
25421+
// GISel doesn't support tuple types yet. It also doesn't suport returning
25422+
// a struct containing a scalable vector like vleff.
25423+
if (Inst.getType()->isRISCVVectorTupleTy() ||
25424+
Inst.getType()->isStructTy())
2542325425
return true;
2542425426

2542525427
for (unsigned i = 0; i < II->arg_size(); ++i)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: not --crash llc -mtriple=riscv64 -mattr=+v -global-isel -stop-after=irtranslator \
2+
; RUN: -verify-machineinstrs < %s 2>&1 | FileCheck %s
3+
4+
; Intrinsics returning structs and extractvalue of scalable vector are not
5+
; supported yet.
6+
define <vscale x 1 x i64> @intrinsic_vleff_v_nxv1i64_nxv1i64(ptr %0, i64 %1, ptr %2) nounwind {
7+
entry:
8+
%a = call { <vscale x 1 x i64>, i64 } @llvm.riscv.vleff.nxv1i64(<vscale x 1 x i64> poison, ptr %0, i64 %1)
9+
%b = extractvalue { <vscale x 1 x i64>, i64 } %a, 0
10+
%c = extractvalue { <vscale x 1 x i64>, i64 } %a, 1
11+
store i64 %c, ptr %2
12+
ret <vscale x 1 x i64> %b
13+
}
14+
15+
; 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)