@@ -316,8 +316,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
316
316
setOperationAction(ISD::FP_TO_UINT_SAT, VT, Custom);
317
317
setOperationAction(ISD::FP_TO_SINT_SAT, VT, Custom);
318
318
}
319
- setOperationAction(ISD::FCANONICALIZE, MVT::f32, Custom);
320
- setOperationAction(ISD::FCANONICALIZE, MVT::f64, Custom);
321
319
if (Subtarget.is64Bit()) {
322
320
setOperationAction(ISD::FP_TO_UINT_SAT, MVT::i64, Custom);
323
321
setOperationAction(ISD::FP_TO_SINT_SAT, MVT::i64, Custom);
@@ -348,9 +346,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
348
346
// TODO: when we have SSE, these could be more efficient, by using movd/movq.
349
347
if (!Subtarget.hasSSE2()) {
350
348
setOperationAction(ISD::BITCAST , MVT::f32 , Expand);
351
- setOperationAction(ISD::BITCAST , MVT::i32 , Expand);
352
- setOperationAction(ISD::FCANONICALIZE, MVT::f32, Custom);
353
- setOperationAction(ISD::FCANONICALIZE, MVT::f64, Custom);
349
+ setOperationAction(ISD::BITCAST, MVT::i32, Expand);
354
350
if (Subtarget.is64Bit()) {
355
351
setOperationAction(ISD::BITCAST , MVT::f64 , Expand);
356
352
// Without SSE, i64->f64 goes through memory.
@@ -716,7 +712,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
716
712
setOperationAction(ISD::STRICT_FROUNDEVEN, MVT::f16, Promote);
717
713
setOperationAction(ISD::STRICT_FTRUNC, MVT::f16, Promote);
718
714
setOperationAction(ISD::STRICT_FP_ROUND, MVT::f16, Custom);
719
- setOperationAction(ISD::FCANONICALIZE, MVT::f16, Custom);
720
715
setOperationAction(ISD::STRICT_FP_EXTEND, MVT::f32, Custom);
721
716
setOperationAction(ISD::STRICT_FP_EXTEND, MVT::f64, Custom);
722
717
setOperationAction(ISD::LRINT, MVT::f16, Expand);
@@ -871,7 +866,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
871
866
setOperationAction(ISD::STRICT_FMUL , MVT::f80, Legal);
872
867
setOperationAction(ISD::STRICT_FDIV , MVT::f80, Legal);
873
868
setOperationAction(ISD::STRICT_FSQRT , MVT::f80, Legal);
874
- setOperationAction(ISD::FCANONICALIZE , MVT::f80, Custom );
869
+ setOperationAction(ISD::FCANONICALIZE, MVT::f80, Expand );
875
870
if (isTypeLegal(MVT::f16)) {
876
871
setOperationAction(ISD::FP_EXTEND, MVT::f80, Custom);
877
872
setOperationAction(ISD::STRICT_FP_EXTEND, MVT::f80, Custom);
@@ -934,7 +929,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
934
929
if (isTypeLegal(MVT::f80)) {
935
930
setOperationAction(ISD::FP_ROUND, MVT::f80, Custom);
936
931
setOperationAction(ISD::STRICT_FP_ROUND, MVT::f80, Custom);
937
- setOperationAction(ISD::FCANONICALIZE, MVT::f80, Custom );
932
+ setOperationAction(ISD::FCANONICALIZE, MVT::f80, Expand );
938
933
}
939
934
940
935
setOperationAction(ISD::SETCC, MVT::f128, Custom);
@@ -1070,11 +1065,11 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1070
1065
setOperationAction(ISD::VSELECT, MVT::v4f32, Custom);
1071
1066
setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v4f32, Custom);
1072
1067
setOperationAction(ISD::SELECT, MVT::v4f32, Custom);
1073
- setOperationAction(ISD::FCANONICALIZE, MVT::v4f32, Custom );
1068
+ setOperationAction(ISD::FCANONICALIZE, MVT::v4f32, Expand );
1074
1069
1075
1070
setOperationAction(ISD::LOAD, MVT::v2f32, Custom);
1076
1071
setOperationAction(ISD::STORE, MVT::v2f32, Custom);
1077
- setOperationAction(ISD::FCANONICALIZE, MVT::v2f32, Custom );
1072
+ setOperationAction(ISD::FCANONICALIZE, MVT::v2f32, Expand );
1078
1073
1079
1074
setOperationAction(ISD::STRICT_FADD, MVT::v4f32, Legal);
1080
1075
setOperationAction(ISD::STRICT_FSUB, MVT::v4f32, Legal);
@@ -1137,7 +1132,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1137
1132
setOperationAction(ISD::UMULO, MVT::v2i32, Custom);
1138
1133
1139
1134
setOperationAction(ISD::FNEG, MVT::v2f64, Custom);
1140
- setOperationAction(ISD::FCANONICALIZE, MVT::v2f64, Custom );
1135
+ setOperationAction(ISD::FCANONICALIZE, MVT::v2f64, Expand );
1141
1136
setOperationAction(ISD::FABS, MVT::v2f64, Custom);
1142
1137
setOperationAction(ISD::FCOPYSIGN, MVT::v2f64, Custom);
1143
1138
@@ -1473,7 +1468,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1473
1468
setOperationAction(ISD::FMINIMUM, VT, Custom);
1474
1469
setOperationAction(ISD::FMAXIMUMNUM, VT, Custom);
1475
1470
setOperationAction(ISD::FMINIMUMNUM, VT, Custom);
1476
- setOperationAction(ISD::FCANONICALIZE, VT, Custom );
1471
+ setOperationAction(ISD::FCANONICALIZE, VT, Expand );
1477
1472
}
1478
1473
1479
1474
setOperationAction(ISD::LRINT, MVT::v8f32, Custom);
@@ -1741,9 +1736,9 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1741
1736
setOperationAction(ISD::FP_TO_UINT, MVT::v2i1, Custom);
1742
1737
setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::v2i1, Custom);
1743
1738
setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::v2i1, Custom);
1744
- setOperationAction(ISD::FCANONICALIZE, MVT::v8f16, Custom );
1745
- setOperationAction(ISD::FCANONICALIZE, MVT::v16f16, Custom );
1746
- setOperationAction(ISD::FCANONICALIZE, MVT::v32f16, Custom );
1739
+ setOperationAction(ISD::FCANONICALIZE, MVT::v8f16, Expand );
1740
+ setOperationAction(ISD::FCANONICALIZE, MVT::v16f16, Expand );
1741
+ setOperationAction(ISD::FCANONICALIZE, MVT::v32f16, Expand );
1747
1742
1748
1743
// There is no byte sized k-register load or store without AVX512DQ.
1749
1744
if (!Subtarget.hasDQI()) {
@@ -1825,7 +1820,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1825
1820
setOperationAction(ISD::FMA, VT, Legal);
1826
1821
setOperationAction(ISD::STRICT_FMA, VT, Legal);
1827
1822
setOperationAction(ISD::FCOPYSIGN, VT, Custom);
1828
- setOperationAction(ISD::FCANONICALIZE, VT, Custom );
1823
+ setOperationAction(ISD::FCANONICALIZE, VT, Expand );
1829
1824
}
1830
1825
setOperationAction(ISD::LRINT, MVT::v16f32,
1831
1826
Subtarget.hasDQI() ? Legal : Custom);
@@ -3318,6 +3313,13 @@ bool X86TargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
3318
3313
return true;
3319
3314
}
3320
3315
3316
+ // X86 prefers to defer vector FCANONICALIZE to DAG legalization
3317
+ // to avoid scalarization during vector legalization.
3318
+ bool X86TargetLowering::shouldExpandVectorFCANONICALIZEInVectorLegalizer()
3319
+ const {
3320
+ return true;
3321
+ }
3322
+
3321
3323
bool X86TargetLowering::reduceSelectOfFPConstantLoads(EVT CmpOpVT) const {
3322
3324
// If we are using XMM registers in the ABI and the condition of the select is
3323
3325
// a floating-point compare and we have blendv or conditional move, then it is
@@ -33426,24 +33428,6 @@ static SDValue LowerPREFETCH(SDValue Op, const X86Subtarget &Subtarget,
33426
33428
return Op;
33427
33429
}
33428
33430
33429
- static SDValue LowerFCanonicalize(SDValue Op, SelectionDAG &DAG) {
33430
- SDNode *N = Op.getNode();
33431
- SDValue Operand = N->getOperand(0);
33432
- EVT VT = Operand.getValueType();
33433
- SDLoc dl(N);
33434
-
33435
- SDValue One = DAG.getConstantFP(1.0, dl, VT);
33436
-
33437
- // TODO: Fix Crash for bf16 when generating strict_fmul as it
33438
- // leads to a error : SoftPromoteHalfResult #0: t11: bf16,ch = strict_fmul t0,
33439
- // ConstantFP:bf16<APFloat(16256)>, t5 LLVM ERROR: Do not know how to soft
33440
- // promote this operator's result!
33441
- SDValue Chain = DAG.getEntryNode();
33442
- SDValue StrictFmul = DAG.getNode(ISD::STRICT_FMUL, dl, {VT, MVT::Other},
33443
- {Chain, Operand, One});
33444
- return StrictFmul;
33445
- }
33446
-
33447
33431
static StringRef getInstrStrFromOpNo(const SmallVectorImpl<StringRef> &AsmStrs,
33448
33432
unsigned OpNo) {
33449
33433
const APInt Operand(32, OpNo);
@@ -33583,7 +33567,6 @@ SDValue X86TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
33583
33567
case ISD::SRL_PARTS: return LowerShiftParts(Op, DAG);
33584
33568
case ISD::FSHL:
33585
33569
case ISD::FSHR: return LowerFunnelShift(Op, Subtarget, DAG);
33586
- case ISD::FCANONICALIZE: return LowerFCanonicalize(Op, DAG);
33587
33570
case ISD::STRICT_SINT_TO_FP:
33588
33571
case ISD::SINT_TO_FP: return LowerSINT_TO_FP(Op, DAG);
33589
33572
case ISD::STRICT_UINT_TO_FP:
0 commit comments