[llvm][CodeGen] IR intrinsics for SVE2 contiguous conflict detection instructions.

Summary:
The IR intrinsics are mapped to the following SVE2 instructions:

* WHILERW <Pd>.<T>, <Xn>, <Xm>
* WHILEWR <Pd>.<T>, <Xn>, <Xm>

The intrinsics introduced in this patch are the IR counterpart of the
SVE ACLE functions `svwhilerw` and `svwhilewr` (all data type
variants).

Patch by Maciej Gąbka <maciej.gabka@arm.com>.

Reviewers: kmclaughlin, rengolin

Reviewed By: kmclaughlin

Subscribers: tschuett, kristof.beyls, hiraditya, danielkiss, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75862
This commit is contained in:
Francesco Petrogalli 2020-03-11 18:25:29 +00:00
parent fcfb1332a7
commit 73eebf7702
4 changed files with 166 additions and 3 deletions

View File

@ -1146,6 +1146,11 @@ let TargetPrefix = "aarch64" in { // All intrinsics start with "llvm.aarch64.".
llvm_i32_ty], llvm_i32_ty],
[IntrNoMem, ImmArg<2>]>; [IntrNoMem, ImmArg<2>]>;
class SVE2_CONFLICT_DETECT_Intrinsic
: Intrinsic<[llvm_anyvector_ty],
[LLVMAnyPointerType<llvm_any_ty>,
LLVMMatchType<1>]>;
class SVE2_3VectorArg_Indexed_Intrinsic class SVE2_3VectorArg_Indexed_Intrinsic
: Intrinsic<[llvm_anyvector_ty], : Intrinsic<[llvm_anyvector_ty],
[LLVMMatchType<0>, [LLVMMatchType<0>,
@ -2167,3 +2172,16 @@ def int_aarch64_sve_bext_x : AdvSIMD_2VectorArg_Intrinsic;
def int_aarch64_sve_bgrp_x : AdvSIMD_2VectorArg_Intrinsic; def int_aarch64_sve_bgrp_x : AdvSIMD_2VectorArg_Intrinsic;
} }
//
// SVE2 - Contiguous conflict detection
//
def int_aarch64_sve_whilerw_b : SVE2_CONFLICT_DETECT_Intrinsic;
def int_aarch64_sve_whilerw_h : SVE2_CONFLICT_DETECT_Intrinsic;
def int_aarch64_sve_whilerw_s : SVE2_CONFLICT_DETECT_Intrinsic;
def int_aarch64_sve_whilerw_d : SVE2_CONFLICT_DETECT_Intrinsic;
def int_aarch64_sve_whilewr_b : SVE2_CONFLICT_DETECT_Intrinsic;
def int_aarch64_sve_whilewr_h : SVE2_CONFLICT_DETECT_Intrinsic;
def int_aarch64_sve_whilewr_s : SVE2_CONFLICT_DETECT_Intrinsic;
def int_aarch64_sve_whilewr_d : SVE2_CONFLICT_DETECT_Intrinsic;

View File

@ -1975,8 +1975,8 @@ let Predicates = [HasSVE2] in {
defm WHILEHI_PXX : sve_int_while8_rr<0b101, "whilehi", int_aarch64_sve_whilehi>; defm WHILEHI_PXX : sve_int_while8_rr<0b101, "whilehi", int_aarch64_sve_whilehi>;
// SVE2 pointer conflict compare // SVE2 pointer conflict compare
defm WHILEWR_PXX : sve2_int_while_rr<0b0, "whilewr">; defm WHILEWR_PXX : sve2_int_while_rr<0b0, "whilewr", "int_aarch64_sve_whilewr">;
defm WHILERW_PXX : sve2_int_while_rr<0b1, "whilerw">; defm WHILERW_PXX : sve2_int_while_rr<0b1, "whilerw", "int_aarch64_sve_whilerw">;
} }
let Predicates = [HasSVE2AES] in { let Predicates = [HasSVE2AES] in {

View File

@ -4385,11 +4385,17 @@ class sve2_int_while_rr<bits<2> sz8_64, bits<1> rw, string asm,
let Defs = [NZCV]; let Defs = [NZCV];
} }
multiclass sve2_int_while_rr<bits<1> rw, string asm> { multiclass sve2_int_while_rr<bits<1> rw, string asm, string op> {
def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>; def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>;
def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>; def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>;
def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>; def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>;
def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>; def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>;
def : SVE_2_Op_Pat<nxv16i1, !cast<SDPatternOperator>(op # _b), i64, i64, !cast<Instruction>(NAME # _B)>;
def : SVE_2_Op_Pat<nxv8i1, !cast<SDPatternOperator>(op # _h), i64, i64, !cast<Instruction>(NAME # _H)>;
def : SVE_2_Op_Pat<nxv4i1, !cast<SDPatternOperator>(op # _s), i64, i64, !cast<Instruction>(NAME # _S)>;
def : SVE_2_Op_Pat<nxv2i1, !cast<SDPatternOperator>(op # _d), i64, i64, !cast<Instruction>(NAME # _D)>;
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -0,0 +1,139 @@
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -asm-verbose=0 < %s | FileCheck %s
;
; WHILERW
;
define <vscale x 16 x i1> @whilerw_i8(i8* %a, i8* %b) {
; CHECK-LABEL: whilerw_i8:
; CHECK: whilerw p0.b, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 16 x i1> @llvm.aarch64.sve.whilerw.b.nx16i1(i8* %a, i8* %b)
ret <vscale x 16 x i1> %out
}
define <vscale x 8 x i1> @whilerw_i16(i16* %a, i16* %b) {
; CHECK-LABEL: whilerw_i16:
; CHECK: whilerw p0.h, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 8 x i1> @llvm.aarch64.sve.whilerw.h.nx8i1(i16* %a, i16* %b)
ret <vscale x 8 x i1> %out
}
define <vscale x 4 x i1> @whilerw_i32(i32* %a, i32* %b) {
; CHECK-LABEL: whilerw_i32:
; CHECK: whilerw p0.s, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 4 x i1> @llvm.aarch64.sve.whilerw.s.nx4i1(i32* %a, i32* %b)
ret <vscale x 4 x i1> %out
}
define <vscale x 2 x i1> @whilerw_i64(i64* %a, i64* %b) {
; CHECK-LABEL: whilerw_i64:
; CHECK: whilerw p0.d, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 2 x i1> @llvm.aarch64.sve.whilerw.d.nx2i1(i64* %a, i64* %b)
ret <vscale x 2 x i1> %out
}
define <vscale x 8 x i1> @whilerw_half(half* %a, half* %b) {
; CHECK-LABEL: whilerw_half:
; CHECK: whilerw p0.h, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 8 x i1> @llvm.aarch64.sve.whilerw.h.nx8i1.f16.f16(half* %a, half* %b)
ret <vscale x 8 x i1> %out
}
define <vscale x 4 x i1> @whilerw_float(float* %a, float* %b) {
; CHECK-LABEL: whilerw_float:
; CHECK: whilerw p0.s, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 4 x i1> @llvm.aarch64.sve.whilerw.s.nx4i1.f32.f32(float* %a, float* %b)
ret <vscale x 4 x i1> %out
}
define <vscale x 2 x i1> @whilerw_double(double* %a, double* %b) {
; CHECK-LABEL: whilerw_double:
; CHECK: whilerw p0.d, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 2 x i1> @llvm.aarch64.sve.whilerw.d.nx2i1.f64.f64(double* %a, double* %b)
ret <vscale x 2 x i1> %out
}
;
; WHILEWR
;
define <vscale x 16 x i1> @whilewr_i8(i8* %a, i8* %b) {
; CHECK-LABEL: whilewr_i8:
; CHECK: whilewr p0.b, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 16 x i1> @llvm.aarch64.sve.whilewr.b.nx16i1(i8* %a, i8* %b)
ret <vscale x 16 x i1> %out
}
define <vscale x 8 x i1> @whilewr_i16(i16* %a, i16* %b) {
; CHECK-LABEL: whilewr_i16:
; CHECK: whilewr p0.h, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 8 x i1> @llvm.aarch64.sve.whilewr.h.nx8i1(i16* %a, i16* %b)
ret <vscale x 8 x i1> %out
}
define <vscale x 4 x i1> @whilewr_i32(i32* %a, i32* %b) {
; CHECK-LABEL: whilewr_i32:
; CHECK: whilewr p0.s, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 4 x i1> @llvm.aarch64.sve.whilewr.s.nx4i1(i32* %a, i32* %b)
ret <vscale x 4 x i1> %out
}
define <vscale x 2 x i1> @whilewr_i64(i64* %a, i64* %b) {
; CHECK-LABEL: whilewr_i64:
; CHECK: whilewr p0.d, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 2 x i1> @llvm.aarch64.sve.whilewr.d.nx2i1(i64* %a, i64* %b)
ret <vscale x 2 x i1> %out
}
define <vscale x 8 x i1> @whilewr_half(half* %a, half* %b) {
; CHECK-LABEL: whilewr_half:
; CHECK: whilewr p0.h, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 8 x i1> @llvm.aarch64.sve.whilewr.h.nx8i1.f16.f16(half* %a, half* %b)
ret <vscale x 8 x i1> %out
}
define <vscale x 4 x i1> @whilewr_float(float* %a, float* %b) {
; CHECK-LABEL: whilewr_float:
; CHECK: whilewr p0.s, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 4 x i1> @llvm.aarch64.sve.whilewr.s.nx4i1.f32.f32(float* %a, float* %b)
ret <vscale x 4 x i1> %out
}
define <vscale x 2 x i1> @whilewr_double(double* %a, double* %b) {
; CHECK-LABEL: whilewr_double:
; CHECK: whilewr p0.d, x0, x1
; CHECK-NEXT: ret
%out = call <vscale x 2 x i1> @llvm.aarch64.sve.whilewr.d.nx2i1.f64.f64(double* %a, double* %b)
ret <vscale x 2 x i1> %out
}
declare <vscale x 16 x i1> @llvm.aarch64.sve.whilerw.b.nx16i1(i8* %a, i8* %b)
declare <vscale x 8 x i1> @llvm.aarch64.sve.whilerw.h.nx8i1(i16* %a, i16* %b)
declare <vscale x 4 x i1> @llvm.aarch64.sve.whilerw.s.nx4i1(i32* %a, i32* %b)
declare <vscale x 2 x i1> @llvm.aarch64.sve.whilerw.d.nx2i1(i64* %a, i64* %b)
declare <vscale x 8 x i1> @llvm.aarch64.sve.whilerw.h.nx8i1.f16.f16(half* %a, half* %b)
declare <vscale x 4 x i1> @llvm.aarch64.sve.whilerw.s.nx4i1.f32.f32(float* %a, float* %b)
declare <vscale x 2 x i1> @llvm.aarch64.sve.whilerw.d.nx2i1.f64.f64(double* %a, double* %b)
declare <vscale x 16 x i1> @llvm.aarch64.sve.whilewr.b.nx16i1(i8* %a, i8* %b)
declare <vscale x 8 x i1> @llvm.aarch64.sve.whilewr.h.nx8i1(i16* %a, i16* %b)
declare <vscale x 4 x i1> @llvm.aarch64.sve.whilewr.s.nx4i1(i32* %a, i32* %b)
declare <vscale x 2 x i1> @llvm.aarch64.sve.whilewr.d.nx2i1(i64* %a, i64* %b)
declare <vscale x 8 x i1> @llvm.aarch64.sve.whilewr.h.nx8i1.f16.f16(half* %a, half* %b)
declare <vscale x 4 x i1> @llvm.aarch64.sve.whilewr.s.nx4i1.f32.f32(float* %a, float* %b)
declare <vscale x 2 x i1> @llvm.aarch64.sve.whilewr.d.nx2i1.f64.f64(double* %a, double* %b)