Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions llvm/lib/Target/AArch64/AArch64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ def HasNEONandIsStreamingSafe
: Predicate<"Subtarget->hasNEON()">,
AssemblerPredicateWithAll<(any_of FeatureNEON), "neon">;
// A subset of NEON instructions are legal in Streaming SVE mode only with +sme2p2.
def HasNEONandIsSME2p2StreamingSafe
: Predicate<"Subtarget->isNeonAvailable() || (Subtarget->hasNEON() && Subtarget->hasSME2p2())">,
def HasNEONandFPRCVTIsStreamingSafe
: Predicate<"Subtarget->isNeonAvailable() || (Subtarget->hasNEON() && Subtarget->isFPRCVTStreamingSafe())">,
AssemblerPredicateWithAll<(any_of FeatureNEON), "neon">;
def HasRCPC : Predicate<"Subtarget->hasRCPC()">,
AssemblerPredicateWithAll<(all_of FeatureRCPC), "rcpc">;
Expand Down Expand Up @@ -6952,7 +6952,7 @@ let HasOneUse = 1 in {
def any_fp_to_sint_oneuse: PatFrag<(ops node:$src0), (any_fp_to_sint $src0)>;
def any_fp_to_uint_oneuse: PatFrag<(ops node:$src0), (any_fp_to_uint $src0)>;
}
let Predicates = [HasNEONandIsSME2p2StreamingSafe] in {
let Predicates = [HasNEONandFPRCVTIsStreamingSafe] in {
def : Pat<(f64 (any_sint_to_fp (i64 (any_fp_to_sint_oneuse f64:$Rn)))),
(SCVTFv1i64 (i64 (FCVTZSv1i64 f64:$Rn)))>;
def : Pat<(f32 (any_sint_to_fp (i32 (any_fp_to_sint_oneuse f32:$Rn)))),
Expand All @@ -6962,7 +6962,7 @@ def : Pat<(f64 (any_uint_to_fp (i64 (any_fp_to_uint_oneuse f64:$Rn)))),
def : Pat<(f32 (any_uint_to_fp (i32 (any_fp_to_uint_oneuse f32:$Rn)))),
(UCVTFv1i32 (i32 (FCVTZUv1i32 f32:$Rn)))>;

let Predicates = [HasNEONandIsSME2p2StreamingSafe, HasFullFP16] in {
let Predicates = [HasNEONandFPRCVTIsStreamingSafe, HasFullFP16] in {
def : Pat<(f16 (any_sint_to_fp (i32 (any_fp_to_sint_oneuse f16:$Rn)))),
(SCVTFv1i16 (f16 (FCVTZSv1f16 f16:$Rn)))>;
def : Pat<(f16 (any_uint_to_fp (i32 (any_fp_to_uint_oneuse f16:$Rn)))),
Expand Down Expand Up @@ -6994,7 +6994,7 @@ def : Pat<(f64 (uint_to_fp (i64 (vector_extract (v2i64 FPR128:$Rn), (i64 0))))),

// fp16: integer extraction from vector must be at least 32-bits to be legal.
// Actual extraction result is then an in-reg sign-extension of lower 16-bits.
let Predicates = [HasNEONandIsSME2p2StreamingSafe, HasFullFP16] in {
let Predicates = [HasNEONandFPRCVTIsStreamingSafe, HasFullFP16] in {
def : Pat<(f16 (sint_to_fp (i32 (sext_inreg (i32 (vector_extract
(v8i16 FPR128:$Rn), (i64 0))), i16)))),
(SCVTFv1i16 (f16 (EXTRACT_SUBREG (v8i16 FPR128:$Rn), hsub)))>;
Expand Down Expand Up @@ -7028,7 +7028,7 @@ multiclass UIntToFPROLoadPat<ValueType DstTy, ValueType SrcTy,
sub))>;
}

let Predicates = [HasNEONandIsSME2p2StreamingSafe, HasFullFP16] in {
let Predicates = [HasNEONandFPRCVTIsStreamingSafe, HasFullFP16] in {
defm : UIntToFPROLoadPat<f16, i32, zextloadi8,
UCVTFv1i16, ro8, LDRBroW, LDRBroX, bsub>;
def : Pat <(f16 (uint_to_fp (i32
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Target/AArch64/AArch64Subtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
return isSVEAvailable() || (isSVEorStreamingSVEAvailable() && hasSME2());
}

bool isFPRCVTStreamingSafe() const {
return hasFPRCVT() &&
(!hasSMEFA64() && (isStreaming() || isStreamingCompatible()));
}

unsigned getMinVectorRegisterBitWidth() const {
// Don't assume any minimum vector size when PSTATE.SM may not be 0, because
// we don't yet support streaming-compatible codegen support that we trust
Expand Down
80 changes: 79 additions & 1 deletion llvm/test/CodeGen/AArch64/sve-streaming-mode-cvt-fp-int-fp.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mattr=+sve -force-streaming-compatible < %s | FileCheck %s
; RUN: llc -mattr=+sme -force-streaming < %s | FileCheck %s
; RUN: llc -mattr=+sme2p2 -force-streaming-compatible < %s | FileCheck %s --check-prefix=USE-NEON-NO-GPRS
; RUN: llc -force-streaming-compatible < %s | FileCheck %s --check-prefix=CHECK-STREAMING
; RUN: llc -force-streaming-compatible -mattr=+fprcvt,+fullfp16 < %s | FileCheck %s --check-prefix=USE-NEON-NO-GPRS
; RUN: llc -force-streaming-compatible -mattr=+fprcvt,+fullfp16,-neon < %s | FileCheck %s --check-prefix=NO-NEON
; RUN: llc -force-streaming-compatible < %s | FileCheck %s --check-prefix=NONEON-NOSVE

target triple = "aarch64-unknown-linux-gnu"
Expand All @@ -16,12 +18,24 @@ define double @t1(double %x) {
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
; CHECK-NEXT: ret
;
; CHECK-STREAMING-LABEL: t1:
; CHECK-STREAMING: // %bb.0: // %entry
; CHECK-STREAMING-NEXT: fcvtzs x8, d0
; CHECK-STREAMING-NEXT: scvtf d0, x8
; CHECK-STREAMING-NEXT: ret
;
; USE-NEON-NO-GPRS-LABEL: t1:
; USE-NEON-NO-GPRS: // %bb.0: // %entry
; USE-NEON-NO-GPRS-NEXT: fcvtzs d0, d0
; USE-NEON-NO-GPRS-NEXT: scvtf d0, d0
; USE-NEON-NO-GPRS-NEXT: ret
;
; NO-NEON-LABEL: t1:
; NO-NEON: // %bb.0: // %entry
; NO-NEON-NEXT: fcvtzs x8, d0
; NO-NEON-NEXT: scvtf d0, x8
; NO-NEON-NEXT: ret
;
; NONEON-NOSVE-LABEL: t1:
; NONEON-NOSVE: // %bb.0: // %entry
; NONEON-NOSVE-NEXT: fcvtzs x8, d0
Expand All @@ -43,12 +57,24 @@ define float @t2(float %x) {
; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0
; CHECK-NEXT: ret
;
; CHECK-STREAMING-LABEL: t2:
; CHECK-STREAMING: // %bb.0: // %entry
; CHECK-STREAMING-NEXT: fcvtzs w8, s0
; CHECK-STREAMING-NEXT: scvtf s0, w8
; CHECK-STREAMING-NEXT: ret
;
; USE-NEON-NO-GPRS-LABEL: t2:
; USE-NEON-NO-GPRS: // %bb.0: // %entry
; USE-NEON-NO-GPRS-NEXT: fcvtzs s0, s0
; USE-NEON-NO-GPRS-NEXT: scvtf s0, s0
; USE-NEON-NO-GPRS-NEXT: ret
;
; NO-NEON-LABEL: t2:
; NO-NEON: // %bb.0: // %entry
; NO-NEON-NEXT: fcvtzs w8, s0
; NO-NEON-NEXT: scvtf s0, w8
; NO-NEON-NEXT: ret
;
; NONEON-NOSVE-LABEL: t2:
; NONEON-NOSVE: // %bb.0: // %entry
; NONEON-NOSVE-NEXT: fcvtzs w8, s0
Expand All @@ -70,12 +96,26 @@ define half @t3(half %x) {
; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0
; CHECK-NEXT: ret
;
; CHECK-STREAMING-LABEL: t3:
; CHECK-STREAMING: // %bb.0: // %entry
; CHECK-STREAMING-NEXT: fcvt s0, h0
; CHECK-STREAMING-NEXT: fcvtzs w8, s0
; CHECK-STREAMING-NEXT: scvtf s0, w8
; CHECK-STREAMING-NEXT: fcvt h0, s0
; CHECK-STREAMING-NEXT: ret
;
; USE-NEON-NO-GPRS-LABEL: t3:
; USE-NEON-NO-GPRS: // %bb.0: // %entry
; USE-NEON-NO-GPRS-NEXT: fcvtzs h0, h0
; USE-NEON-NO-GPRS-NEXT: scvtf h0, h0
; USE-NEON-NO-GPRS-NEXT: ret
;
; NO-NEON-LABEL: t3:
; NO-NEON: // %bb.0: // %entry
; NO-NEON-NEXT: fcvtzs w8, h0
; NO-NEON-NEXT: scvtf h0, w8
; NO-NEON-NEXT: ret
;
; NONEON-NOSVE-LABEL: t3:
; NONEON-NOSVE: // %bb.0: // %entry
; NONEON-NOSVE-NEXT: fcvt s0, h0
Expand All @@ -99,12 +139,24 @@ define double @t4(double %x) {
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
; CHECK-NEXT: ret
;
; CHECK-STREAMING-LABEL: t4:
; CHECK-STREAMING: // %bb.0: // %entry
; CHECK-STREAMING-NEXT: fcvtzu x8, d0
; CHECK-STREAMING-NEXT: ucvtf d0, x8
; CHECK-STREAMING-NEXT: ret
;
; USE-NEON-NO-GPRS-LABEL: t4:
; USE-NEON-NO-GPRS: // %bb.0: // %entry
; USE-NEON-NO-GPRS-NEXT: fcvtzu d0, d0
; USE-NEON-NO-GPRS-NEXT: ucvtf d0, d0
; USE-NEON-NO-GPRS-NEXT: ret
;
; NO-NEON-LABEL: t4:
; NO-NEON: // %bb.0: // %entry
; NO-NEON-NEXT: fcvtzu x8, d0
; NO-NEON-NEXT: ucvtf d0, x8
; NO-NEON-NEXT: ret
;
; NONEON-NOSVE-LABEL: t4:
; NONEON-NOSVE: // %bb.0: // %entry
; NONEON-NOSVE-NEXT: fcvtzu x8, d0
Expand All @@ -126,12 +178,24 @@ define float @t5(float %x) {
; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0
; CHECK-NEXT: ret
;
; CHECK-STREAMING-LABEL: t5:
; CHECK-STREAMING: // %bb.0: // %entry
; CHECK-STREAMING-NEXT: fcvtzu w8, s0
; CHECK-STREAMING-NEXT: ucvtf s0, w8
; CHECK-STREAMING-NEXT: ret
;
; USE-NEON-NO-GPRS-LABEL: t5:
; USE-NEON-NO-GPRS: // %bb.0: // %entry
; USE-NEON-NO-GPRS-NEXT: fcvtzu s0, s0
; USE-NEON-NO-GPRS-NEXT: ucvtf s0, s0
; USE-NEON-NO-GPRS-NEXT: ret
;
; NO-NEON-LABEL: t5:
; NO-NEON: // %bb.0: // %entry
; NO-NEON-NEXT: fcvtzu w8, s0
; NO-NEON-NEXT: ucvtf s0, w8
; NO-NEON-NEXT: ret
;
; NONEON-NOSVE-LABEL: t5:
; NONEON-NOSVE: // %bb.0: // %entry
; NONEON-NOSVE-NEXT: fcvtzu w8, s0
Expand All @@ -153,12 +217,26 @@ define half @t6(half %x) {
; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0
; CHECK-NEXT: ret
;
; CHECK-STREAMING-LABEL: t6:
; CHECK-STREAMING: // %bb.0: // %entry
; CHECK-STREAMING-NEXT: fcvt s0, h0
; CHECK-STREAMING-NEXT: fcvtzu w8, s0
; CHECK-STREAMING-NEXT: ucvtf s0, w8
; CHECK-STREAMING-NEXT: fcvt h0, s0
; CHECK-STREAMING-NEXT: ret
;
; USE-NEON-NO-GPRS-LABEL: t6:
; USE-NEON-NO-GPRS: // %bb.0: // %entry
; USE-NEON-NO-GPRS-NEXT: fcvtzu h0, h0
; USE-NEON-NO-GPRS-NEXT: ucvtf h0, h0
; USE-NEON-NO-GPRS-NEXT: ret
;
; NO-NEON-LABEL: t6:
; NO-NEON: // %bb.0: // %entry
; NO-NEON-NEXT: fcvtzu w8, h0
; NO-NEON-NEXT: ucvtf h0, w8
; NO-NEON-NEXT: ret
;
; NONEON-NOSVE-LABEL: t6:
; NONEON-NOSVE: // %bb.0: // %entry
; NONEON-NOSVE-NEXT: fcvt s0, h0
Expand Down