Skip to content

Commit c1df380

Browse files
committed
scalable vectorized G_ADD, G_SUB, G_AND, G_OR, G_XOR don't fall back to DAGISel
1 parent 9a14008 commit c1df380

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19874,11 +19874,13 @@ unsigned RISCVTargetLowering::getCustomCtpopCost(EVT VT,
1987419874
}
1987519875

1987619876
bool RISCVTargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
19877-
// At the moment, the only scalable instruction GISel knows how to lower is
19878-
// ret with scalable argument.
1987919877

19880-
if (Inst.getType()->isScalableTy())
19881-
return true;
19878+
// GISel support is in progress or complete for G_ADD, G_SUB, G_AND, G_OR, and
19879+
// G_XOR.
19880+
unsigned Op = Inst.getOpcode();
19881+
if (Op == Instruction::Add || Op == Instruction::Sub ||
19882+
Op == Instruction::And || Op == Instruction::Or || Op == Instruction::Xor)
19883+
return false;
1988219884

1988319885
for (unsigned i = 0; i < Inst.getNumOperands(); ++i)
1988419886
if (Inst.getOperand(i)->getType()->isScalableTy() &&
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
; RUN: llc -mtriple=riscv32 -mattr=+v -global-isel -stop-before=legalizer -simplify-mir < %s | FileCheck %s --check-prefixes=CHECK,RV32I %s
3+
; RUN: llc -mtriple=riscv64 -mattr=+v -global-isel -stop-before=legalizer -simplify-mir < %s | FileCheck %s --check-prefixes=CHECK,RV64I %s
4+
5+
define void @add_nxv2i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b) {
6+
; CHECK-LABEL: name: add_nxv2i32
7+
; CHECK: bb.1 (%ir-block.0):
8+
; CHECK-NEXT: liveins: $v8, $v9
9+
; CHECK-NEXT: {{ $}}
10+
; CHECK-NEXT: PseudoRET
11+
%c = add <vscale x 2 x i32> %a, %b
12+
ret void
13+
}
14+
15+
define void @sub_nxv2i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b) {
16+
; CHECK-LABEL: name: sub_nxv2i32
17+
; CHECK: bb.1 (%ir-block.0):
18+
; CHECK-NEXT: liveins: $v8, $v9
19+
; CHECK-NEXT: {{ $}}
20+
; CHECK-NEXT: PseudoRET
21+
%c = sub <vscale x 2 x i32> %a, %b
22+
ret void
23+
}
24+
25+
define void @and_nxv2i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b) {
26+
; CHECK-LABEL: name: and_nxv2i32
27+
; CHECK: bb.1 (%ir-block.0):
28+
; CHECK-NEXT: liveins: $v8, $v9
29+
; CHECK-NEXT: {{ $}}
30+
; CHECK-NEXT: PseudoRET
31+
%c = and <vscale x 2 x i32> %a, %b
32+
ret void
33+
}
34+
35+
define void @or_nxv2i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b) {
36+
; CHECK-LABEL: name: or_nxv2i32
37+
; CHECK: bb.1 (%ir-block.0):
38+
; CHECK-NEXT: liveins: $v8, $v9
39+
; CHECK-NEXT: {{ $}}
40+
; CHECK-NEXT: PseudoRET
41+
%c = or <vscale x 2 x i32> %a, %b
42+
ret void
43+
}
44+
45+
define void @xor_nxv2i32(<vscale x 2 x i32> %a, <vscale x 2 x i32> %b) {
46+
; CHECK-LABEL: name: xor_nxv2i32
47+
; CHECK: bb.1 (%ir-block.0):
48+
; CHECK-NEXT: liveins: $v8, $v9
49+
; CHECK-NEXT: {{ $}}
50+
; CHECK-NEXT: PseudoRET
51+
%c = xor <vscale x 2 x i32> %a, %b
52+
ret void
53+
}

0 commit comments

Comments
 (0)