Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -799,6 +799,8 @@ setOperationAction(ISD::FP_EXTEND, MVT::f128, Legal); setLoadExtAction(ISD::EXTLOAD, MVT::f128, MVT::f64, Expand); setOperationAction(ISD::FMA, MVT::f128, Legal); + setOperationAction(ISD::SINT_TO_FP, MVT::i64, Legal); + setOperationAction(ISD::UINT_TO_FP, MVT::i64, Legal); } } Index: lib/Target/PowerPC/PPCInstrVSX.td =================================================================== --- lib/Target/PowerPC/PPCInstrVSX.td +++ lib/Target/PowerPC/PPCInstrVSX.td @@ -2512,7 +2512,12 @@ // Convert (Un)Signed DWord -> QP def XSCVSDQP : X_VT5_XO5_VB5_TyVB<63, 10, 836, "xscvsdqp", vfrc, []>; + def : Pat<(f128 (sint_to_fp i64:$src)), + (f128 (XSCVSDQP (COPY_TO_REGCLASS $src, VFRC)))>; + def XSCVUDQP : X_VT5_XO5_VB5_TyVB<63, 2, 836, "xscvudqp", vfrc, []>; + def : Pat<(f128 (uint_to_fp i64:$src)), + (f128 (XSCVUDQP (COPY_TO_REGCLASS $src, VFRC)))>; let UseVSXReg = 1 in { //===--------------------------------------------------------------------===// @@ -3113,6 +3118,17 @@ (COPY_TO_REGCLASS (DFLOADf32 ixaddr:$src), VSFRC)>; def : Pat<(f32 (fpround (f64 (extloadf32 ixaddr:$src)))), (f32 (DFLOADf32 ixaddr:$src))>; + + // Convert (Un)Signed DWord in memory -> QP + def : Pat<(f128 (sint_to_fp (i64 (load xaddr:$src)))), + (f128 (XSCVSDQP (LXSDX xaddr:$src)))>; + def : Pat<(f128 (sint_to_fp (i64 (load ixaddr:$src)))), + (f128 (XSCVSDQP (LXSD ixaddr:$src)))>; + def : Pat<(f128 (uint_to_fp (i64 (load xaddr:$src)))), + (f128 (XSCVUDQP (LXSDX xaddr:$src)))>; + def : Pat<(f128 (uint_to_fp (i64 (load ixaddr:$src)))), + (f128 (XSCVUDQP (LXSD ixaddr:$src)))>; + } // end HasP9Vector, AddedComplexity let Predicates = [HasP9Vector] in { Index: test/CodeGen/PowerPC/f128-conv.ll =================================================================== --- /dev/null +++ test/CodeGen/PowerPC/f128-conv.ll @@ -0,0 +1,70 @@ +; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -enable-ppc-quad-precision -ppc-vsr-nums-as-vr < %s | FileCheck %s + +@mem = global [5 x i64] [i64 56, i64 63, i64 3, i64 5, i64 6], align 8 +@umem = global [5 x i64] [i64 560, i64 100, i64 34, i64 2, i64 5], align 8 + +; Function Attrs: norecurse nounwind +define void @sdwConv2qp(fp128* nocapture %a, i64 %b) { +entry: + %conv = sitofp i64 %b to fp128 + store fp128 %conv, fp128* %a, align 16 + ret void + +; CHECK-LABEL: sdwConv2qp +; CHECK: mtvsrd [[REG:[0-9]+]], 4 +; CHECK-NEXT: xscvsdqp [[REG]], [[REG]] +; CHECK-NEXT: stxv [[REG]], 0(3) +; CHECK-NEXT: blr +} + +; Function Attrs: norecurse nounwind +define void @sdwConv2qp_02(fp128* nocapture %a) { +entry: + %0 = load i64, i64* getelementptr inbounds + ([5 x i64], [5 x i64]* @mem, i64 0, i64 2), align 8 + %conv = sitofp i64 %0 to fp128 + store fp128 %conv, fp128* %a, align 16 + ret void + +; CHECK-LABEL: sdwConv2qp_02 +; CHECK: addis [[REG:[0-9]+]], 2, .LC0@toc@ha +; CHECK: ld [[REG]], .LC0@toc@l([[REG]]) +; CHECK: lxsd [[REG0:[0-9]+]], 16([[REG]]) +; CHECK-NEXT: xscvsdqp [[REG0]], [[REG0]] +; CHECK-NEXT: stxv [[REG0]], 0(3) +; CHECK-NEXT: blr +} + +; Function Attrs: norecurse nounwind +define void @udwConv2qp(fp128* nocapture %a, i64 %b) { +entry: + %conv = uitofp i64 %b to fp128 + store fp128 %conv, fp128* %a, align 16 + ret void + +; CHECK-LABEL: udwConv2qp +; CHECK: mtvsrd [[REG:[0-9]+]], 4 +; CHECK-NEXT: xscvudqp [[REG]], [[REG]] +; CHECK-NEXT: stxv [[REG]], 0(3) +; CHECK-NEXT: blr +} + +; Function Attrs: norecurse nounwind +define void @udwConv2qp_02(fp128* nocapture %a) { +entry: + %0 = load i64, i64* getelementptr inbounds + ([5 x i64], [5 x i64]* @umem, i64 0, i64 4), align 8 + %conv = uitofp i64 %0 to fp128 + store fp128 %conv, fp128* %a, align 16 + ret void + +; CHECK-LABEL: udwConv2qp_02 +; CHECK: addis [[REG:[0-9]+]], 2, .LC1@toc@ha +; CHECK: ld [[REG]], .LC1@toc@l([[REG]]) +; CHECK: lxsd [[REG0:[0-9]+]], 32([[REG]]) +; CHECK-NEXT: xscvudqp [[REG0]], [[REG0]] +; CHECK-NEXT: stxv [[REG0]], 0(3) +; CHECK-NEXT: blr +} +