Skip to content

Commit 70180ee

Browse files
committed
[AArch64][SME]: Generate streaming-compatible code for fp_to_int and int_to_fp.
1-To generate code compatible to streaming mode: - enable custom lowering fp_to_int, int_to_fp, fp_round, fmul, trunc. - disable fp_to_int combining into invalid NEON intrinsic. 2-Add testing files: fp_to_int.ll fp-convert.ll int_to_fp.ll trunc.ll Differential Revision: https://reviews.llvm.org/D138281
1 parent bc010ce commit 70180ee

File tree

5 files changed

+1461
-779
lines changed

5 files changed

+1461
-779
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,8 @@ void AArch64TargetLowering::addTypeForStreamingSVE(MVT VT) {
16261626
setOperationAction(ISD::MULHU, VT, Custom);
16271627
setOperationAction(ISD::ABS, VT, Custom);
16281628
setOperationAction(ISD::XOR, VT, Custom);
1629+
setOperationAction(ISD::TRUNCATE, VT, Custom);
1630+
setOperationAction(ISD::FMUL, VT, Custom);
16291631
}
16301632

16311633
void AArch64TargetLowering::addTypeForFixedLengthSVE(MVT VT) {
@@ -3784,7 +3786,8 @@ SDValue AArch64TargetLowering::LowerFP_ROUND(SDValue Op,
37843786
SDValue SrcVal = Op.getOperand(IsStrict ? 1 : 0);
37853787
EVT SrcVT = SrcVal.getValueType();
37863788

3787-
if (useSVEForFixedLengthVectorVT(SrcVT))
3789+
if (useSVEForFixedLengthVectorVT(SrcVT,
3790+
Subtarget->forceStreamingCompatibleSVE()))
37883791
return LowerFixedLengthFPRoundToSVE(Op, DAG);
37893792

37903793
if (SrcVT != MVT::f128) {
@@ -3815,7 +3818,10 @@ SDValue AArch64TargetLowering::LowerVectorFP_TO_INT(SDValue Op,
38153818
return LowerToPredicatedOp(Op, DAG, Opcode);
38163819
}
38173820

3818-
if (useSVEForFixedLengthVectorVT(VT) || useSVEForFixedLengthVectorVT(InVT))
3821+
if (useSVEForFixedLengthVectorVT(VT,
3822+
Subtarget->forceStreamingCompatibleSVE()) ||
3823+
useSVEForFixedLengthVectorVT(InVT,
3824+
Subtarget->forceStreamingCompatibleSVE()))
38193825
return LowerFixedLengthFPToIntToSVE(Op, DAG);
38203826

38213827
unsigned NumElts = InVT.getVectorNumElements();
@@ -4069,7 +4075,10 @@ SDValue AArch64TargetLowering::LowerVectorINT_TO_FP(SDValue Op,
40694075
return LowerToPredicatedOp(Op, DAG, Opcode);
40704076
}
40714077

4072-
if (useSVEForFixedLengthVectorVT(VT) || useSVEForFixedLengthVectorVT(InVT))
4078+
if (useSVEForFixedLengthVectorVT(VT,
4079+
Subtarget->forceStreamingCompatibleSVE()) ||
4080+
useSVEForFixedLengthVectorVT(InVT,
4081+
Subtarget->forceStreamingCompatibleSVE()))
40734082
return LowerFixedLengthIntToFPToSVE(Op, DAG);
40744083

40754084
uint64_t VTSize = VT.getFixedSizeInBits();
@@ -15422,7 +15431,7 @@ static SDValue performIntToFpCombine(SDNode *N, SelectionDAG &DAG,
1542215431
static SDValue performFpToIntCombine(SDNode *N, SelectionDAG &DAG,
1542315432
TargetLowering::DAGCombinerInfo &DCI,
1542415433
const AArch64Subtarget *Subtarget) {
15425-
if (!Subtarget->hasNEON())
15434+
if (!Subtarget->hasNEON() || Subtarget->forceStreamingCompatibleSVE())
1542615435
return SDValue();
1542715436

1542815437
if (!N->getValueType(0).isSimple())

llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-fp-convert.ll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ target triple = "aarch64-unknown-linux-gnu"
77
define void @fp_convert_combine_crash(<8 x float> *%a, <8 x i32> *%b) #0 {
88
; CHECK-LABEL: fp_convert_combine_crash:
99
; CHECK: // %bb.0:
10-
; CHECK-NEXT: ldp q0, q1, [x0]
11-
; CHECK-NEXT: fcvtzs v0.4s, v0.4s, #3
12-
; CHECK-NEXT: fcvtzs v1.4s, v1.4s, #3
10+
; CHECK-NEXT: adrp x8, .LCPI0_0
11+
; CHECK-NEXT: ptrue p0.s, vl4
12+
; CHECK-NEXT: ldp q0, q2, [x0]
13+
; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI0_0]
14+
; CHECK-NEXT: fmul z0.s, p0/m, z0.s, z1.s
15+
; CHECK-NEXT: fmul z1.s, p0/m, z1.s, z2.s
16+
; CHECK-NEXT: fcvtzs z0.s, p0/m, z0.s
17+
; CHECK-NEXT: fcvtzs z1.s, p0/m, z1.s
1318
; CHECK-NEXT: stp q0, q1, [x1]
1419
; CHECK-NEXT: ret
1520
%f = load <8 x float>, <8 x float>* %a

0 commit comments

Comments
 (0)