Skip to content

Commit b72ca79

Browse files
committed
[VE] Support intrinsic to isnert/extract_subreg of v512i1
Support insert/extract_subreg intrinsic instructions for v512i1 registers and add regression tests. Reviewed By: simoll Differential Revision: https://reviews.llvm.org/D94298
1 parent 5963229 commit b72ca79

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

llvm/include/llvm/IR/IntrinsicsVE.td

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ let TargetPrefix = "ve" in {
1111
def int_ve_vl_pack_f32a : GCCBuiltin<"__builtin_ve_vl_pack_f32a">,
1212
Intrinsic<[llvm_i64_ty], [llvm_ptr_ty],
1313
[IntrReadMem]>;
14+
15+
def int_ve_vl_extract_vm512u :
16+
GCCBuiltin<"__builtin_ve_vl_extract_vm512u">,
17+
Intrinsic<[LLVMType<v256i1>], [LLVMType<v512i1>], [IntrNoMem]>;
18+
19+
def int_ve_vl_extract_vm512l :
20+
GCCBuiltin<"__builtin_ve_vl_extract_vm512l">,
21+
Intrinsic<[LLVMType<v256i1>], [LLVMType<v512i1>], [IntrNoMem]>;
22+
23+
def int_ve_vl_insert_vm512u :
24+
GCCBuiltin<"__builtin_ve_vl_insert_vm512u">,
25+
Intrinsic<[LLVMType<v512i1>], [LLVMType<v512i1>, LLVMType<v256i1>],
26+
[IntrNoMem]>;
27+
28+
def int_ve_vl_insert_vm512l :
29+
GCCBuiltin<"__builtin_ve_vl_insert_vm512l">,
30+
Intrinsic<[LLVMType<v512i1>], [LLVMType<v512i1>, LLVMType<v256i1>],
31+
[IntrNoMem]>;
1432
}
1533

1634
// Define intrinsics automatically generated

llvm/lib/Target/VE/VEInstrIntrinsicVL.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ def : Pat<(i64 (int_ve_vl_pack_f32a ADDRrii:$addr)),
1717
!add(32, 64)), 0,
1818
(HI32 (i64 0x0000000100000001))))>;
1919

20+
// The extract/insert patterns.
21+
def : Pat<(v256i1 (int_ve_vl_extract_vm512u v512i1:$vm)),
22+
(EXTRACT_SUBREG v512i1:$vm, sub_vm_even)>;
23+
24+
def : Pat<(v256i1 (int_ve_vl_extract_vm512l v512i1:$vm)),
25+
(EXTRACT_SUBREG v512i1:$vm, sub_vm_odd)>;
26+
27+
def : Pat<(v512i1 (int_ve_vl_insert_vm512u v512i1:$vmx, v256i1:$vmy)),
28+
(INSERT_SUBREG v512i1:$vmx, v256i1:$vmy, sub_vm_even)>;
29+
30+
def : Pat<(v512i1 (int_ve_vl_insert_vm512l v512i1:$vmx, v256i1:$vmy)),
31+
(INSERT_SUBREG v512i1:$vmx, v256i1:$vmy, sub_vm_odd)>;
32+
2033
// LSV patterns.
2134
def : Pat<(int_ve_vl_lsv_vvss v256f64:$pt, i32:$sy, i64:$sz),
2235
(LSVrr_v (i2l i32:$sy), i64:$sz, v256f64:$pt)>;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; RUN: llc < %s -mtriple=ve -mattr=+vpu | FileCheck %s
2+
3+
;;; Test extract intrinsic instructions
4+
;;;
5+
;;; Note:
6+
;;; We test extract_vm512u and extract_vm512l pseudo instructions.
7+
8+
; Function Attrs: nounwind readnone
9+
define fastcc <256 x i1> @extract_vm512u(<512 x i1> %0) {
10+
; CHECK-LABEL: extract_vm512u:
11+
; CHECK: # %bb.0:
12+
; CHECK-NEXT: andm %vm1, %vm0, %vm2
13+
; CHECK-NEXT: b.l.t (, %s10)
14+
%2 = tail call <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1> %0)
15+
ret <256 x i1> %2
16+
}
17+
18+
; Function Attrs: nounwind readnone
19+
declare <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1>)
20+
21+
; Function Attrs: nounwind readnone
22+
define fastcc <256 x i1> @extract_vm512l(<512 x i1> %0) {
23+
; CHECK-LABEL: extract_vm512l:
24+
; CHECK: # %bb.0:
25+
; CHECK-NEXT: andm %vm0, %vm0, %vm2
26+
; CHECK-NEXT: andm %vm1, %vm0, %vm3
27+
; CHECK-NEXT: b.l.t (, %s10)
28+
%2 = tail call <256 x i1> @llvm.ve.vl.extract.vm512l(<512 x i1> %0)
29+
ret <256 x i1> %2
30+
}
31+
32+
; Function Attrs: nounwind readnone
33+
declare <256 x i1> @llvm.ve.vl.extract.vm512l(<512 x i1>)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; RUN: llc < %s -mtriple=ve -mattr=+vpu | FileCheck %s
2+
3+
;;; Test insert intrinsic instructions
4+
;;;
5+
;;; Note:
6+
;;; We test insert_vm512u and insert_vm512l pseudo instructions.
7+
8+
; Function Attrs: nounwind readnone
9+
define fastcc <512 x i1> @insert_vm512u(<512 x i1> %0, <256 x i1> %1) {
10+
; CHECK-LABEL: insert_vm512u:
11+
; CHECK: # %bb.0:
12+
; CHECK-NEXT: andm %vm2, %vm0, %vm4
13+
; CHECK-NEXT: b.l.t (, %s10)
14+
%3 = tail call <512 x i1> @llvm.ve.vl.insert.vm512u(<512 x i1> %0, <256 x i1> %1)
15+
ret <512 x i1> %3
16+
}
17+
18+
; Function Attrs: nounwind readnone
19+
declare <512 x i1> @llvm.ve.vl.insert.vm512u(<512 x i1>, <256 x i1>)
20+
21+
; Function Attrs: nounwind readnone
22+
define fastcc <512 x i1> @insert_vm512l(<512 x i1> %0, <256 x i1> %1) {
23+
; CHECK-LABEL: insert_vm512l:
24+
; CHECK: # %bb.0:
25+
; CHECK-NEXT: andm %vm3, %vm0, %vm4
26+
; CHECK-NEXT: b.l.t (, %s10)
27+
%3 = tail call <512 x i1> @llvm.ve.vl.insert.vm512l(<512 x i1> %0, <256 x i1> %1)
28+
ret <512 x i1> %3
29+
}
30+
31+
; Function Attrs: nounwind readnone
32+
declare <512 x i1> @llvm.ve.vl.insert.vm512l(<512 x i1>, <256 x i1>)

0 commit comments

Comments
 (0)