@@ -18832,7 +18832,8 @@ static SDValue LowerShiftParts(SDValue Op, SelectionDAG &DAG) {
18832
18832
18833
18833
// Try to use a packed vector operation to handle i64 on 32-bit targets when
18834
18834
// AVX512DQ is enabled.
18835
- static SDValue LowerI64IntToFP_AVX512DQ(SDValue Op, SelectionDAG &DAG,
18835
+ static SDValue LowerI64IntToFP_AVX512DQ(SDValue Op, const SDLoc &dl,
18836
+ SelectionDAG &DAG,
18836
18837
const X86Subtarget &Subtarget) {
18837
18838
assert((Op.getOpcode() == ISD::SINT_TO_FP ||
18838
18839
Op.getOpcode() == ISD::STRICT_SINT_TO_FP ||
@@ -18856,7 +18857,6 @@ static SDValue LowerI64IntToFP_AVX512DQ(SDValue Op, SelectionDAG &DAG,
18856
18857
MVT VecInVT = MVT::getVectorVT(MVT::i64, NumElts);
18857
18858
MVT VecVT = MVT::getVectorVT(VT, NumElts);
18858
18859
18859
- SDLoc dl(Op);
18860
18860
SDValue InVec = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, VecInVT, Src);
18861
18861
if (IsStrict) {
18862
18862
SDValue CvtVec = DAG.getNode(Op.getOpcode(), dl, {VecVT, MVT::Other},
@@ -18874,7 +18874,7 @@ static SDValue LowerI64IntToFP_AVX512DQ(SDValue Op, SelectionDAG &DAG,
18874
18874
}
18875
18875
18876
18876
// Try to use a packed vector operation to handle i64 on 32-bit targets.
18877
- static SDValue LowerI64IntToFP16(SDValue Op, SelectionDAG &DAG,
18877
+ static SDValue LowerI64IntToFP16(SDValue Op, const SDLoc &dl, SelectionDAG &DAG,
18878
18878
const X86Subtarget &Subtarget) {
18879
18879
assert((Op.getOpcode() == ISD::SINT_TO_FP ||
18880
18880
Op.getOpcode() == ISD::STRICT_SINT_TO_FP ||
@@ -18893,7 +18893,6 @@ static SDValue LowerI64IntToFP16(SDValue Op, SelectionDAG &DAG,
18893
18893
18894
18894
assert(Subtarget.hasFP16() && "Expected FP16");
18895
18895
18896
- SDLoc dl(Op);
18897
18896
SDValue InVec = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v2i64, Src);
18898
18897
if (IsStrict) {
18899
18898
SDValue CvtVec = DAG.getNode(Op.getOpcode(), dl, {MVT::v2f16, MVT::Other},
@@ -18935,7 +18934,8 @@ static bool useVectorCast(unsigned Opcode, MVT FromVT, MVT ToVT,
18935
18934
/// Given a scalar cast operation that is extracted from a vector, try to
18936
18935
/// vectorize the cast op followed by extraction. This will avoid an expensive
18937
18936
/// round-trip between XMM and GPR.
18938
- static SDValue vectorizeExtractedCast(SDValue Cast, SelectionDAG &DAG,
18937
+ static SDValue vectorizeExtractedCast(SDValue Cast, const SDLoc &DL,
18938
+ SelectionDAG &DAG,
18939
18939
const X86Subtarget &Subtarget) {
18940
18940
// TODO: This could be enhanced to handle smaller integer types by peeking
18941
18941
// through an extend.
@@ -18956,7 +18956,6 @@ static SDValue vectorizeExtractedCast(SDValue Cast, SelectionDAG &DAG,
18956
18956
18957
18957
// If we are extracting from a non-zero element, first shuffle the source
18958
18958
// vector to allow extracting from element zero.
18959
- SDLoc DL(Cast);
18960
18959
if (!isNullConstant(Extract.getOperand(1))) {
18961
18960
SmallVector<int, 16> Mask(FromVT.getVectorNumElements(), -1);
18962
18961
Mask[0] = Extract.getConstantOperandVal(1);
@@ -18977,7 +18976,8 @@ static SDValue vectorizeExtractedCast(SDValue Cast, SelectionDAG &DAG,
18977
18976
/// Given a scalar cast to FP with a cast to integer operand (almost an ftrunc),
18978
18977
/// try to vectorize the cast ops. This will avoid an expensive round-trip
18979
18978
/// between XMM and GPR.
18980
- static SDValue lowerFPToIntToFP(SDValue CastToFP, SelectionDAG &DAG,
18979
+ static SDValue lowerFPToIntToFP(SDValue CastToFP, const SDLoc &DL,
18980
+ SelectionDAG &DAG,
18981
18981
const X86Subtarget &Subtarget) {
18982
18982
// TODO: Allow FP_TO_UINT.
18983
18983
SDValue CastToInt = CastToFP.getOperand(0);
@@ -19016,17 +19016,16 @@ static SDValue lowerFPToIntToFP(SDValue CastToFP, SelectionDAG &DAG,
19016
19016
// that could nullify any performance advantage that we hoped to gain from
19017
19017
// this vector op hack. We do not expect any adverse effects (like denorm
19018
19018
// penalties) with cast ops.
19019
- SDLoc DL(CastToFP);
19020
19019
SDValue ZeroIdx = DAG.getIntPtrConstant(0, DL);
19021
19020
SDValue VecX = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, VecSrcVT, X);
19022
19021
SDValue VCastToInt = DAG.getNode(ToIntOpcode, DL, VecIntVT, VecX);
19023
19022
SDValue VCastToFP = DAG.getNode(ToFPOpcode, DL, VecVT, VCastToInt);
19024
19023
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, VCastToFP, ZeroIdx);
19025
19024
}
19026
19025
19027
- static SDValue lowerINT_TO_FP_vXi64(SDValue Op, SelectionDAG &DAG,
19026
+ static SDValue lowerINT_TO_FP_vXi64(SDValue Op, const SDLoc &DL,
19027
+ SelectionDAG &DAG,
19028
19028
const X86Subtarget &Subtarget) {
19029
- SDLoc DL(Op);
19030
19029
bool IsStrict = Op->isStrictFPOpcode();
19031
19030
MVT VT = Op->getSimpleValueType(0);
19032
19031
SDValue Src = Op->getOperand(IsStrict ? 1 : 0);
@@ -19113,13 +19112,13 @@ static SDValue lowerINT_TO_FP_vXi64(SDValue Op, SelectionDAG &DAG,
19113
19112
return Cvt;
19114
19113
}
19115
19114
19116
- static SDValue promoteXINT_TO_FP(SDValue Op, SelectionDAG &DAG) {
19115
+ static SDValue promoteXINT_TO_FP(SDValue Op, const SDLoc &dl,
19116
+ SelectionDAG &DAG) {
19117
19117
bool IsStrict = Op->isStrictFPOpcode();
19118
19118
SDValue Src = Op.getOperand(IsStrict ? 1 : 0);
19119
19119
SDValue Chain = IsStrict ? Op->getOperand(0) : DAG.getEntryNode();
19120
19120
MVT VT = Op.getSimpleValueType();
19121
19121
MVT NVT = VT.isVector() ? VT.changeVectorElementType(MVT::f32) : MVT::f32;
19122
- SDLoc dl(Op);
19123
19122
19124
19123
SDValue Rnd = DAG.getIntPtrConstant(0, dl);
19125
19124
if (IsStrict)
@@ -19163,17 +19162,17 @@ SDValue X86TargetLowering::LowerSINT_TO_FP(SDValue Op,
19163
19162
SDLoc dl(Op);
19164
19163
19165
19164
if (isSoftF16(VT, Subtarget))
19166
- return promoteXINT_TO_FP(Op, DAG);
19165
+ return promoteXINT_TO_FP(Op, dl, DAG);
19167
19166
else if (isLegalConversion(SrcVT, true, Subtarget))
19168
19167
return Op;
19169
19168
19170
19169
if (Subtarget.isTargetWin64() && SrcVT == MVT::i128)
19171
19170
return LowerWin64_INT128_TO_FP(Op, DAG);
19172
19171
19173
- if (SDValue Extract = vectorizeExtractedCast(Op, DAG, Subtarget))
19172
+ if (SDValue Extract = vectorizeExtractedCast(Op, dl, DAG, Subtarget))
19174
19173
return Extract;
19175
19174
19176
- if (SDValue R = lowerFPToIntToFP(Op, DAG, Subtarget))
19175
+ if (SDValue R = lowerFPToIntToFP(Op, dl, DAG, Subtarget))
19177
19176
return R;
19178
19177
19179
19178
if (SrcVT.isVector()) {
@@ -19190,7 +19189,7 @@ SDValue X86TargetLowering::LowerSINT_TO_FP(SDValue Op,
19190
19189
DAG.getUNDEF(SrcVT)));
19191
19190
}
19192
19191
if (SrcVT == MVT::v2i64 || SrcVT == MVT::v4i64)
19193
- return lowerINT_TO_FP_vXi64(Op, DAG, Subtarget);
19192
+ return lowerINT_TO_FP_vXi64(Op, dl, DAG, Subtarget);
19194
19193
19195
19194
return SDValue();
19196
19195
}
@@ -19207,9 +19206,9 @@ SDValue X86TargetLowering::LowerSINT_TO_FP(SDValue Op,
19207
19206
if (SrcVT == MVT::i64 && UseSSEReg && Subtarget.is64Bit())
19208
19207
return Op;
19209
19208
19210
- if (SDValue V = LowerI64IntToFP_AVX512DQ(Op, DAG, Subtarget))
19209
+ if (SDValue V = LowerI64IntToFP_AVX512DQ(Op, dl, DAG, Subtarget))
19211
19210
return V;
19212
- if (SDValue V = LowerI64IntToFP16(Op, DAG, Subtarget))
19211
+ if (SDValue V = LowerI64IntToFP16(Op, dl, DAG, Subtarget))
19213
19212
return V;
19214
19213
19215
19214
// SSE doesn't have an i16 conversion so we need to promote.
@@ -19302,7 +19301,8 @@ static bool shouldUseHorizontalOp(bool IsSingleSource, SelectionDAG &DAG,
19302
19301
}
19303
19302
19304
19303
/// 64-bit unsigned integer to double expansion.
19305
- static SDValue LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG,
19304
+ static SDValue LowerUINT_TO_FP_i64(SDValue Op, const SDLoc &dl,
19305
+ SelectionDAG &DAG,
19306
19306
const X86Subtarget &Subtarget) {
19307
19307
// We can't use this algorithm for strict fp. It produces -0.0 instead of +0.0
19308
19308
// when converting 0 when rounding toward negative infinity. Caller will
@@ -19321,7 +19321,6 @@ static SDValue LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG,
19321
19321
#endif
19322
19322
*/
19323
19323
19324
- SDLoc dl(Op);
19325
19324
LLVMContext *Context = DAG.getContext();
19326
19325
19327
19326
// Build some magic constants.
@@ -19370,10 +19369,10 @@ static SDValue LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG,
19370
19369
}
19371
19370
19372
19371
/// 32-bit unsigned integer to float expansion.
19373
- static SDValue LowerUINT_TO_FP_i32(SDValue Op, SelectionDAG &DAG,
19372
+ static SDValue LowerUINT_TO_FP_i32(SDValue Op, const SDLoc &dl,
19373
+ SelectionDAG &DAG,
19374
19374
const X86Subtarget &Subtarget) {
19375
19375
unsigned OpNo = Op.getNode()->isStrictFPOpcode() ? 1 : 0;
19376
- SDLoc dl(Op);
19377
19376
// FP constant to bias correct the final result.
19378
19377
SDValue Bias = DAG.getConstantFP(
19379
19378
llvm::bit_cast<double>(0x4330000000000000ULL), dl, MVT::f64);
@@ -19420,9 +19419,9 @@ static SDValue LowerUINT_TO_FP_i32(SDValue Op, SelectionDAG &DAG,
19420
19419
return DAG.getFPExtendOrRound(Sub, dl, Op.getSimpleValueType());
19421
19420
}
19422
19421
19423
- static SDValue lowerUINT_TO_FP_v2i32(SDValue Op, SelectionDAG &DAG ,
19424
- const X86Subtarget &Subtarget ,
19425
- const SDLoc &DL ) {
19422
+ static SDValue lowerUINT_TO_FP_v2i32(SDValue Op, const SDLoc &DL ,
19423
+ SelectionDAG &DAG ,
19424
+ const X86Subtarget &Subtarget ) {
19426
19425
if (Op.getSimpleValueType() != MVT::v2f64)
19427
19426
return SDValue();
19428
19427
@@ -19473,9 +19472,9 @@ static SDValue lowerUINT_TO_FP_v2i32(SDValue Op, SelectionDAG &DAG,
19473
19472
return DAG.getNode(ISD::FSUB, DL, MVT::v2f64, Or, VBias);
19474
19473
}
19475
19474
19476
- static SDValue lowerUINT_TO_FP_vXi32(SDValue Op, SelectionDAG &DAG,
19475
+ static SDValue lowerUINT_TO_FP_vXi32(SDValue Op, const SDLoc &DL,
19476
+ SelectionDAG &DAG,
19477
19477
const X86Subtarget &Subtarget) {
19478
- SDLoc DL(Op);
19479
19478
bool IsStrict = Op->isStrictFPOpcode();
19480
19479
SDValue V = Op->getOperand(IsStrict ? 1 : 0);
19481
19480
MVT VecIntVT = V.getSimpleValueType();
@@ -19631,24 +19630,23 @@ static SDValue lowerUINT_TO_FP_vXi32(SDValue Op, SelectionDAG &DAG,
19631
19630
return DAG.getNode(ISD::FADD, DL, VecFloatVT, LowBitcast, FHigh);
19632
19631
}
19633
19632
19634
- static SDValue lowerUINT_TO_FP_vec(SDValue Op, SelectionDAG &DAG,
19633
+ static SDValue lowerUINT_TO_FP_vec(SDValue Op, const SDLoc &dl, SelectionDAG &DAG,
19635
19634
const X86Subtarget &Subtarget) {
19636
19635
unsigned OpNo = Op.getNode()->isStrictFPOpcode() ? 1 : 0;
19637
19636
SDValue N0 = Op.getOperand(OpNo);
19638
19637
MVT SrcVT = N0.getSimpleValueType();
19639
- SDLoc dl(Op);
19640
19638
19641
19639
switch (SrcVT.SimpleTy) {
19642
19640
default:
19643
19641
llvm_unreachable("Custom UINT_TO_FP is not supported!");
19644
19642
case MVT::v2i32:
19645
- return lowerUINT_TO_FP_v2i32(Op, DAG, Subtarget, dl );
19643
+ return lowerUINT_TO_FP_v2i32(Op, dl, DAG, Subtarget );
19646
19644
case MVT::v4i32:
19647
19645
case MVT::v8i32:
19648
- return lowerUINT_TO_FP_vXi32(Op, DAG, Subtarget);
19646
+ return lowerUINT_TO_FP_vXi32(Op, dl, DAG, Subtarget);
19649
19647
case MVT::v2i64:
19650
19648
case MVT::v4i64:
19651
- return lowerINT_TO_FP_vXi64(Op, DAG, Subtarget);
19649
+ return lowerINT_TO_FP_vXi64(Op, dl, DAG, Subtarget);
19652
19650
}
19653
19651
}
19654
19652
@@ -19668,17 +19666,17 @@ SDValue X86TargetLowering::LowerUINT_TO_FP(SDValue Op,
19668
19666
return SDValue();
19669
19667
19670
19668
if (isSoftF16(DstVT, Subtarget))
19671
- return promoteXINT_TO_FP(Op, DAG);
19669
+ return promoteXINT_TO_FP(Op, dl, DAG);
19672
19670
else if (isLegalConversion(SrcVT, false, Subtarget))
19673
19671
return Op;
19674
19672
19675
19673
if (DstVT.isVector())
19676
- return lowerUINT_TO_FP_vec(Op, DAG, Subtarget);
19674
+ return lowerUINT_TO_FP_vec(Op, dl, DAG, Subtarget);
19677
19675
19678
19676
if (Subtarget.isTargetWin64() && SrcVT == MVT::i128)
19679
19677
return LowerWin64_INT128_TO_FP(Op, DAG);
19680
19678
19681
- if (SDValue Extract = vectorizeExtractedCast(Op, DAG, Subtarget))
19679
+ if (SDValue Extract = vectorizeExtractedCast(Op, dl, DAG, Subtarget))
19682
19680
return Extract;
19683
19681
19684
19682
if (Subtarget.hasAVX512() && isScalarFPTypeInSSEReg(DstVT) &&
@@ -19697,21 +19695,21 @@ SDValue X86TargetLowering::LowerUINT_TO_FP(SDValue Op,
19697
19695
return DAG.getNode(ISD::SINT_TO_FP, dl, DstVT, Src);
19698
19696
}
19699
19697
19700
- if (SDValue V = LowerI64IntToFP_AVX512DQ(Op, DAG, Subtarget))
19698
+ if (SDValue V = LowerI64IntToFP_AVX512DQ(Op, dl, DAG, Subtarget))
19701
19699
return V;
19702
- if (SDValue V = LowerI64IntToFP16(Op, DAG, Subtarget))
19700
+ if (SDValue V = LowerI64IntToFP16(Op, dl, DAG, Subtarget))
19703
19701
return V;
19704
19702
19705
19703
// The transform for i64->f64 isn't correct for 0 when rounding to negative
19706
19704
// infinity. It produces -0.0, so disable under strictfp.
19707
19705
if (SrcVT == MVT::i64 && DstVT == MVT::f64 && Subtarget.hasSSE2() &&
19708
19706
!IsStrict)
19709
- return LowerUINT_TO_FP_i64(Op, DAG, Subtarget);
19707
+ return LowerUINT_TO_FP_i64(Op, dl, DAG, Subtarget);
19710
19708
// The transform for i32->f64/f32 isn't correct for 0 when rounding to
19711
19709
// negative infinity. So disable under strictfp. Using FILD instead.
19712
19710
if (SrcVT == MVT::i32 && Subtarget.hasSSE2() && DstVT != MVT::f80 &&
19713
19711
!IsStrict)
19714
- return LowerUINT_TO_FP_i32(Op, DAG, Subtarget);
19712
+ return LowerUINT_TO_FP_i32(Op, dl, DAG, Subtarget);
19715
19713
if (Subtarget.is64Bit() && SrcVT == MVT::i64 &&
19716
19714
(DstVT == MVT::f32 || DstVT == MVT::f64))
19717
19715
return SDValue();
@@ -19721,7 +19719,7 @@ SDValue X86TargetLowering::LowerUINT_TO_FP(SDValue Op,
19721
19719
int SSFI = cast<FrameIndexSDNode>(StackSlot)->getIndex();
19722
19720
Align SlotAlign(8);
19723
19721
MachinePointerInfo MPI =
19724
- MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), SSFI);
19722
+ MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), SSFI);
19725
19723
if (SrcVT == MVT::i32) {
19726
19724
SDValue OffsetSlot =
19727
19725
DAG.getMemBasePlusOffset(StackSlot, TypeSize::getFixed(4), dl);
@@ -19750,22 +19748,21 @@ SDValue X86TargetLowering::LowerUINT_TO_FP(SDValue Op,
19750
19748
// was negative. We must be careful to do the computation in x87 extended
19751
19749
// precision, not in SSE.
19752
19750
SDVTList Tys = DAG.getVTList(MVT::f80, MVT::Other);
19753
- SDValue Ops[] = { Store, StackSlot };
19751
+ SDValue Ops[] = {Store, StackSlot};
19754
19752
SDValue Fild =
19755
19753
DAG.getMemIntrinsicNode(X86ISD::FILD, dl, Tys, Ops, MVT::i64, MPI,
19756
19754
SlotAlign, MachineMemOperand::MOLoad);
19757
19755
Chain = Fild.getValue(1);
19758
19756
19759
-
19760
19757
// Check whether the sign bit is set.
19761
19758
SDValue SignSet = DAG.getSetCC(
19762
19759
dl, getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), MVT::i64),
19763
19760
Op.getOperand(OpNo), DAG.getConstant(0, dl, MVT::i64), ISD::SETLT);
19764
19761
19765
19762
// Build a 64 bit pair (FF, 0) in the constant pool, with FF in the hi bits.
19766
19763
APInt FF(64, 0x5F80000000000000ULL);
19767
- SDValue FudgePtr = DAG.getConstantPool(
19768
- ConstantInt::get(*DAG.getContext(), FF), PtrVT);
19764
+ SDValue FudgePtr =
19765
+ DAG.getConstantPool( ConstantInt::get(*DAG.getContext(), FF), PtrVT);
19769
19766
Align CPAlignment = cast<ConstantPoolSDNode>(FudgePtr)->getAlign();
19770
19767
19771
19768
// Get a pointer to FF if the sign bit was set, or to 0 otherwise.
@@ -19812,9 +19809,9 @@ SDValue X86TargetLowering::LowerUINT_TO_FP(SDValue Op,
19812
19809
// Otherwise it is assumed to be a conversion from one of f32, f64 or f80
19813
19810
// to i16, i32 or i64, and we lower it to a legal sequence and return the
19814
19811
// result.
19815
- SDValue
19816
- X86TargetLowering::FP_TO_INTHelper(SDValue Op, SelectionDAG &DAG ,
19817
- bool IsSigned, SDValue &Chain) const {
19812
+ SDValue X86TargetLowering::FP_TO_INTHelper(SDValue Op, SelectionDAG &DAG,
19813
+ bool IsSigned ,
19814
+ SDValue &Chain) const {
19818
19815
bool IsStrict = Op->isStrictFPOpcode();
19819
19816
SDLoc DL(Op);
19820
19817
0 commit comments