@@ -442,14 +442,11 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
442442 setLoadExtAction(ISD::EXTLOAD, MVT::f64, MVT::f32, Expand);
443443
444444 // If we're enabling GP optimizations, use hardware square root
445- if (!Subtarget.hasFSQRT() &&
446- !(TM.Options.UnsafeFPMath && Subtarget.hasFRSQRTE() &&
447- Subtarget.hasFRE()))
445+ if (!Subtarget.hasFSQRT() && !(Subtarget.hasFRSQRTE() && Subtarget.hasFRE()))
448446 setOperationAction(ISD::FSQRT, MVT::f64, Expand);
449447
450448 if (!Subtarget.hasFSQRT() &&
451- !(TM.Options.UnsafeFPMath && Subtarget.hasFRSQRTES() &&
452- Subtarget.hasFRES()))
449+ !(Subtarget.hasFRSQRTES() && Subtarget.hasFRES()))
453450 setOperationAction(ISD::FSQRT, MVT::f32, Expand);
454451
455452 if (Subtarget.hasFCPSGN()) {
@@ -565,16 +562,15 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
565562 setOperationAction(ISD::BITCAST, MVT::i32, Legal);
566563 setOperationAction(ISD::BITCAST, MVT::i64, Legal);
567564 setOperationAction(ISD::BITCAST, MVT::f64, Legal);
568- if (TM.Options.UnsafeFPMath) {
569- setOperationAction(ISD::LRINT, MVT::f64, Legal);
570- setOperationAction(ISD::LRINT, MVT::f32, Legal);
571- setOperationAction(ISD::LLRINT, MVT::f64, Legal);
572- setOperationAction(ISD::LLRINT, MVT::f32, Legal);
573- setOperationAction(ISD::LROUND, MVT::f64, Legal);
574- setOperationAction(ISD::LROUND, MVT::f32, Legal);
575- setOperationAction(ISD::LLROUND, MVT::f64, Legal);
576- setOperationAction(ISD::LLROUND, MVT::f32, Legal);
577- }
565+
566+ setOperationAction(ISD::STRICT_LRINT, MVT::f64, Custom);
567+ setOperationAction(ISD::STRICT_LRINT, MVT::f32, Custom);
568+ setOperationAction(ISD::STRICT_LLRINT, MVT::f64, Custom);
569+ setOperationAction(ISD::STRICT_LLRINT, MVT::f32, Custom);
570+ setOperationAction(ISD::STRICT_LROUND, MVT::f64, Custom);
571+ setOperationAction(ISD::STRICT_LROUND, MVT::f32, Custom);
572+ setOperationAction(ISD::STRICT_LLROUND, MVT::f64, Custom);
573+ setOperationAction(ISD::STRICT_LLROUND, MVT::f32, Custom);
578574 } else {
579575 setOperationAction(ISD::BITCAST, MVT::f32, Expand);
580576 setOperationAction(ISD::BITCAST, MVT::i32, Expand);
@@ -1034,11 +1030,9 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
10341030 setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2f64, Legal);
10351031
10361032 // The nearbyint variants are not allowed to raise the inexact exception
1037- // so we can only code-gen them with unsafe math.
1038- if (TM.Options.UnsafeFPMath) {
1039- setOperationAction(ISD::FNEARBYINT, MVT::f64, Legal);
1040- setOperationAction(ISD::FNEARBYINT, MVT::f32, Legal);
1041- }
1033+ // so we can only code-gen them with fpexcept.ignore.
1034+ setOperationAction(ISD::STRICT_FNEARBYINT, MVT::f64, Custom);
1035+ setOperationAction(ISD::STRICT_FNEARBYINT, MVT::f32, Custom);
10421036
10431037 setOperationAction(ISD::FFLOOR, MVT::v2f64, Legal);
10441038 setOperationAction(ISD::FCEIL, MVT::v2f64, Legal);
@@ -8913,9 +8907,8 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
89138907 //
89148908 // However, if -enable-unsafe-fp-math is in effect, accept double
89158909 // rounding to avoid the extra overhead.
8916- if (Op.getValueType() == MVT::f32 &&
8917- !Subtarget.hasFPCVT() &&
8918- !DAG.getTarget().Options.UnsafeFPMath) {
8910+ if (Op.getValueType() == MVT::f32 && !Subtarget.hasFPCVT() &&
8911+ !Op->getFlags().hasNoFPExcept()) {
89198912
89208913 // Twiddle input to make sure the low 11 bits are zero. (If this
89218914 // is the case, we are guaranteed the value will fit into the 53 bit
@@ -12759,6 +12752,14 @@ SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
1275912752 return LowerADDSUBO_CARRY(Op, DAG);
1276012753 case ISD::UCMP:
1276112754 return LowerUCMP(Op, DAG);
12755+ case ISD::STRICT_LRINT:
12756+ case ISD::STRICT_LLRINT:
12757+ case ISD::STRICT_LROUND:
12758+ case ISD::STRICT_LLROUND:
12759+ case ISD::STRICT_FNEARBYINT:
12760+ if (Op->getFlags().hasNoFPExcept())
12761+ return Op;
12762+ return SDValue();
1276212763 }
1276312764}
1276412765
@@ -18707,11 +18708,12 @@ bool PPCTargetLowering::isProfitableToHoist(Instruction *I) const {
1870718708 const Function *F = I->getFunction();
1870818709 const DataLayout &DL = F->getDataLayout();
1870918710 Type *Ty = User->getOperand(0)->getType();
18711+ bool AllowContract = I->getFastMathFlags().allowContract() &&
18712+ User->getFastMathFlags().allowContract();
1871018713
18711- return !(
18712- isFMAFasterThanFMulAndFAdd(*F, Ty) &&
18713- isOperationLegalOrCustom(ISD::FMA, getValueType(DL, Ty)) &&
18714- (Options.AllowFPOpFusion == FPOpFusion::Fast || Options.UnsafeFPMath));
18714+ return !(isFMAFasterThanFMulAndFAdd(*F, Ty) &&
18715+ isOperationLegalOrCustom(ISD::FMA, getValueType(DL, Ty)) &&
18716+ (AllowContract || Options.AllowFPOpFusion == FPOpFusion::Fast));
1871518717 }
1871618718 case Instruction::Load: {
1871718719 // Don't break "store (load float*)" pattern, this pattern will be combined
0 commit comments