Lines Matching defs:fmf
33 Value computeAbs(Value real, Value imag, arith::FastMathFlags fmf,
38 Value absReal = b.create<math::AbsFOp>(real, fmf);
39 Value absImag = b.create<math::AbsFOp>(imag, fmf);
41 Value max = b.create<arith::MaximumFOp>(absReal, absImag, fmf);
42 Value min = b.create<arith::MinimumFOp>(absReal, absImag, fmf);
46 fmf, arith::FastMathFlags::nnan | arith::FastMathFlags::ninf);
83 arith::FastMathFlags fmf = op.getFastMathFlagsAttr().getValue();
87 rewriter.replaceOp(op, computeAbs(real, imag, fmf, b));
104 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
109 Value rhsSquared = b.create<complex::MulOp>(type, rhs, rhs, fmf);
110 Value lhsSquared = b.create<complex::MulOp>(type, lhs, lhs, fmf);
112 b.create<complex::AddOp>(type, rhsSquared, lhsSquared, fmf);
114 b.create<complex::SqrtOp>(type, rhsSquaredPlusLhsSquared, fmf);
121 Value iTimesLhs = b.create<complex::MulOp>(i, lhs, fmf);
122 Value rhsPlusILhs = b.create<complex::AddOp>(rhs, iTimesLhs, fmf);
125 rhsPlusILhs, sqrtOfRhsSquaredPlusLhsSquared, fmf);
126 Value logResult = b.create<complex::LogOp>(divResult, fmf);
132 rewriter.replaceOpWithNewOp<complex::MulOp>(op, negativeI, logResult, fmf);
178 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
183 fmf.getValue());
187 fmf.getValue());
206 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
218 Value exp = rewriter.create<math::ExpOp>(loc, imag, fmf);
219 Value scaledExp = rewriter.create<arith::MulFOp>(loc, half, exp, fmf);
220 Value reciprocalExp = rewriter.create<arith::DivFOp>(loc, half, exp, fmf);
221 Value sin = rewriter.create<math::SinOp>(loc, real, fmf);
222 Value cos = rewriter.create<math::CosOp>(loc, real, fmf);
225 combine(loc, scaledExp, reciprocalExp, sin, cos, rewriter, fmf);
235 arith::FastMathFlagsAttr fmf) const = 0;
244 arith::FastMathFlagsAttr fmf) const override {
255 rewriter.create<arith::AddFOp>(loc, reciprocalExp, scaledExp, fmf);
256 Value resultReal = rewriter.create<arith::MulFOp>(loc, sum, cos, fmf);
258 rewriter.create<arith::SubFOp>(loc, reciprocalExp, scaledExp, fmf);
259 Value resultImag = rewriter.create<arith::MulFOp>(loc, diff, sin, fmf);
273 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
307 rewriter.create<arith::DivFOp>(loc, rhsReal, rhsImag, fmf);
310 rewriter.create<arith::MulFOp>(loc, rhsRealImagRatio, rhsReal, fmf),
311 fmf);
314 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsRealImagRatio, fmf),
315 lhsImag, fmf);
317 rhsRealImagDenom, fmf);
320 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsRealImagRatio, fmf),
321 lhsReal, fmf);
323 rhsRealImagDenom, fmf);
326 rewriter.create<arith::DivFOp>(loc, rhsImag, rhsReal, fmf);
329 rewriter.create<arith::MulFOp>(loc, rhsImagRealRatio, rhsImag, fmf),
330 fmf);
333 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsImagRealRatio, fmf),
334 fmf);
336 rhsImagRealDenom, fmf);
339 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsImagRealRatio, fmf),
340 fmf);
342 rhsImagRealDenom, fmf);
348 Value rhsRealAbs = rewriter.create<math::AbsFOp>(loc, rhsReal, fmf);
351 Value rhsImagAbs = rewriter.create<math::AbsFOp>(loc, rhsImag, fmf);
370 rewriter.create<arith::MulFOp>(loc, infWithSignOfRhsReal, lhsReal, fmf);
372 rewriter.create<arith::MulFOp>(loc, infWithSignOfRhsReal, lhsImag, fmf);
381 Value lhsRealAbs = rewriter.create<math::AbsFOp>(loc, lhsReal, fmf);
384 Value lhsImagAbs = rewriter.create<math::AbsFOp>(loc, lhsImag, fmf);
400 rewriter.create<arith::MulFOp>(loc, lhsRealIsInfWithSign, rhsReal, fmf);
402 rewriter.create<arith::MulFOp>(loc, lhsImagIsInfWithSign, rhsImag, fmf);
406 lhsImagIsInfWithSignTimesRhsImag, fmf),
407 fmf);
409 rewriter.create<arith::MulFOp>(loc, lhsRealIsInfWithSign, rhsImag, fmf);
411 rewriter.create<arith::MulFOp>(loc, lhsImagIsInfWithSign, rhsReal, fmf);
415 lhsRealIsInfWithSignTimesRhsImag, fmf),
416 fmf);
440 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsRealIsInfWithSign, fmf);
442 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsImagIsInfWithSign, fmf);
446 rhsImagIsInfWithSignTimesLhsImag, fmf),
447 fmf);
449 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsRealIsInfWithSign, fmf);
451 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsImagIsInfWithSign, fmf);
455 rhsImagIsInfWithSignTimesLhsReal, fmf),
456 fmf);
503 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
509 Value expReal = rewriter.create<math::ExpOp>(loc, real, fmf.getValue());
510 Value cosImag = rewriter.create<math::CosOp>(loc, imag, fmf.getValue());
512 rewriter.create<arith::MulFOp>(loc, expReal, cosImag, fmf.getValue());
513 Value sinImag = rewriter.create<math::SinOp>(loc, imag, fmf.getValue());
515 rewriter.create<arith::MulFOp>(loc, expReal, sinImag, fmf.getValue());
525 arith::FastMathFlagsAttr fmf) {
533 fmf);
551 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
559 Value expm1Real = b.create<math::ExpM1Op>(real, fmf);
560 Value expReal = b.create<arith::AddFOp>(expm1Real, one, fmf);
562 Value sinImag = b.create<math::SinOp>(imag, fmf);
563 Value cosm1Imag = emitCosm1(imag, fmf, b);
564 Value cosImag = b.create<arith::AddFOp>(cosm1Imag, one, fmf);
567 b.create<arith::MulFOp>(expm1Real, cosImag, fmf), cosm1Imag, fmf);
570 zero, fmf.getValue());
572 imagIsZero, zero, b.create<arith::MulFOp>(expReal, sinImag, fmf));
580 Value emitCosm1(Value arg, arith::FastMathFlagsAttr fmf,
593 Value cos = b.create<math::CosOp>(arg, fmf);
594 Value forLargeArg = b.create<arith::AddFOp>(cos, negOne, fmf);
596 Value argPow2 = b.create<arith::MulFOp>(arg, arg, fmf);
597 Value argPow4 = b.create<arith::MulFOp>(argPow2, argPow2, fmf);
598 Value poly = evaluatePolynomial(b, argPow2, kCoeffs, fmf);
601 b.create<arith::AddFOp>(b.create<arith::MulFOp>(argPow4, poly, fmf),
602 b.create<arith::MulFOp>(negHalf, argPow2, fmf));
608 piOver4Pow2, fmf.getValue());
621 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
625 fmf.getValue());
626 Value resultReal = b.create<math::LogOp>(elementType, abs, fmf.getValue());
630 b.create<math::Atan2Op>(elementType, imag, real, fmf.getValue());
645 arith::FastMathFlags fmf = op.getFastMathFlagsAttr().getValue();
655 Value realPlusOne = b.create<arith::AddFOp>(real, one, fmf);
656 Value absRealPlusOne = b.create<math::AbsFOp>(realPlusOne, fmf);
657 Value absImag = b.create<math::AbsFOp>(imag, fmf);
659 Value maxAbs = b.create<arith::MaximumFOp>(absRealPlusOne, absImag, fmf);
660 Value minAbs = b.create<arith::MinimumFOp>(absRealPlusOne, absImag, fmf);
663 realPlusOne, absImag, fmf);
664 Value maxMinusOne = b.create<arith::SubFOp>(maxAbs, one, fmf);
668 fmf, arith::FastMathFlags::nnan | arith::FastMathFlags::ninf);
671 b.create<math::Log1pOp>(maxAbsOfRealPlusOneAndImagMinusOne, fmf);
681 Value resultImag = b.create<math::Atan2Op>(imag, realPlusOne, fmf);
697 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
698 auto fmfValue = fmf.getValue();
747 arith::FastMathFlagsAttr fmf) const override {
758 rewriter.create<arith::AddFOp>(loc, scaledExp, reciprocalExp, fmf);
759 Value resultReal = rewriter.create<arith::MulFOp>(loc, sum, sin, fmf);
761 rewriter.create<arith::SubFOp>(loc, scaledExp, reciprocalExp, fmf);
762 Value resultImag = rewriter.create<arith::MulFOp>(loc, diff, cos, fmf);
778 arith::FastMathFlags fmf = op.getFastMathFlagsAttr().getValue();
791 Value absSqrt = computeAbs(real, imag, fmf, b, AbsFn::sqrt);
792 Value argArg = b.create<math::Atan2Op>(imag, real, fmf);
793 Value sqrtArg = b.create<arith::MulFOp>(argArg, half, fmf);
794 Value cos = b.create<math::CosOp>(sqrtArg, fmf);
795 Value sin = b.create<math::SinOp>(sqrtArg, fmf);
799 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, sin, zero, fmf);
801 Value resultReal = b.create<arith::MulFOp>(absSqrt, cos, fmf);
803 sinIsZero, zero, b.create<arith::MulFOp>(absSqrt, sin, fmf));
804 if (!arith::bitEnumContainsAll(fmf, arith::FastMathFlags::nnan |
809 Value absImag = b.create<math::AbsFOp>(elementType, imag, fmf);
812 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, absImag, inf, fmf);
814 b.create<arith::CmpFOp>(arith::CmpFPredicate::ONE, absImag, inf, fmf);
816 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, real, inf, fmf);
818 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, real, negInf, fmf);
826 Value imagSignInf = b.create<math::CopySignOp>(inf, imag, fmf);
836 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, absSqrt, zero, fmf);
855 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
866 auto abs = b.create<complex::AbsOp>(elementType, adaptor.getComplex(), fmf);
867 Value realSign = b.create<arith::DivFOp>(real, abs, fmf);
868 Value imagSign = b.create<arith::DivFOp>(imag, abs, fmf);
887 arith::FastMathFlags fmf = op.getFastMathFlagsAttr().getValue();
900 real = b.create<arith::MulFOp>(real, negOne, fmf);
910 Value twoReal = b.create<arith::AddFOp>(real, real, fmf);
911 Value negTwoReal = b.create<arith::MulFOp>(negOne, twoReal, fmf);
913 Value expTwoRealMinusOne = b.create<math::ExpM1Op>(twoReal, fmf);
914 Value expNegTwoRealMinusOne = b.create<math::ExpM1Op>(negTwoReal, fmf);
916 b.create<arith::SubFOp>(expTwoRealMinusOne, expNegTwoRealMinusOne, fmf);
918 Value cosImag = b.create<math::CosOp>(imag, fmf);
919 Value cosImagSq = b.create<arith::MulFOp>(cosImag, cosImag, fmf);
920 Value twoCosTwoImagPlusOne = b.create<arith::MulFOp>(cosImagSq, four, fmf);
921 Value sinImag = b.create<math::SinOp>(imag, fmf);
924 four, b.create<arith::MulFOp>(cosImag, sinImag, fmf), fmf);
927 b.create<arith::AddFOp>(expTwoRealMinusOne, expNegTwoRealMinusOne, fmf);
929 b.create<arith::AddFOp>(expSumMinusTwo, twoCosTwoImagPlusOne, fmf);
932 expSumMinusTwo, inf, fmf);
933 Value realLimit = b.create<math::CopySignOp>(negOne, real, fmf);
936 isInf, realLimit, b.create<arith::DivFOp>(realNum, denom, fmf));
937 Value resultImag = b.create<arith::DivFOp>(imagNum, denom, fmf);
939 if (!arith::bitEnumContainsAll(fmf, arith::FastMathFlags::nnan |
941 Value absReal = b.create<math::AbsFOp>(real, fmf);
947 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, absReal, inf, fmf);
949 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, imag, zero, fmf);
954 imagNum, imagNum, fmf);
968 resultImag = b.create<arith::MulFOp>(resultImag, negOne, fmf);
1003 arith::FastMathFlags fmf) {
1009 Value abs = builder.create<complex::AbsOp>(lhs, fmf);
1010 Value absToC = builder.create<math::PowFOp>(abs, c, fmf);
1012 Value negD = builder.create<arith::NegFOp>(d, fmf);
1013 Value argLhs = builder.create<math::Atan2Op>(b, a, fmf);
1014 Value negDArgLhs = builder.create<arith::MulFOp>(negD, argLhs, fmf);
1015 Value expNegDArgLhs = builder.create<math::ExpOp>(negDArgLhs, fmf);
1017 Value coeff = builder.create<arith::MulFOp>(absToC, expNegDArgLhs, fmf);
1018 Value lnAbs = builder.create<math::LogOp>(abs, fmf);
1019 Value cArgLhs = builder.create<arith::MulFOp>(c, argLhs, fmf);
1020 Value dLnAbs = builder.create<arith::MulFOp>(d, lnAbs, fmf);
1021 Value q = builder.create<arith::AddFOp>(cArgLhs, dLnAbs, fmf);
1022 Value cosQ = builder.create<math::CosOp>(q, fmf);
1023 Value sinQ = builder.create<math::SinOp>(q, fmf);
1042 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, abs, zero, fmf);
1044 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, d, zero, fmf);
1046 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, c, zero, fmf);
1048 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, b, zero, fmf);
1051 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OLE, zero, c, fmf);
1052 Value coeffCosQ = builder.create<arith::MulFOp>(coeff, cosQ, fmf);
1053 Value coeffSinQ = builder.create<arith::MulFOp>(coeff, sinQ, fmf);
1074 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, a, one, fmf),
1082 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, a, inf, fmf),
1086 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OGT, c, zero, fmf));
1094 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OLT, c, zero, fmf));
1130 arith::FastMathFlags fmf = op.getFastMathFlagsAttr().getValue();
1145 Value absRsqrt = computeAbs(real, imag, fmf, b, AbsFn::rsqrt);
1146 Value argArg = b.create<math::Atan2Op>(imag, real, fmf);
1147 Value rsqrtArg = b.create<arith::MulFOp>(argArg, negHalf, fmf);
1148 Value cos = b.create<math::CosOp>(rsqrtArg, fmf);
1149 Value sin = b.create<math::SinOp>(rsqrtArg, fmf);
1151 Value resultReal = b.create<arith::MulFOp>(absRsqrt, cos, fmf);
1152 Value resultImag = b.create<arith::MulFOp>(absRsqrt, sin, fmf);
1154 if (!arith::bitEnumContainsAll(fmf, arith::FastMathFlags::nnan |
1159 Value realSignedZero = b.create<math::CopySignOp>(zero, real, fmf);
1160 Value imagSignedZero = b.create<math::CopySignOp>(zero, imag, fmf);
1162 b.create<arith::MulFOp>(negOne, imagSignedZero, fmf);
1164 Value absReal = b.create<math::AbsFOp>(real, fmf);
1165 Value absImag = b.create<math::AbsFOp>(imag, fmf);
1168 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, absImag, inf, fmf);
1170 b.create<arith::CmpFOp>(arith::CmpFPredicate::UNO, real, real, fmf);
1172 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, absReal, inf, fmf);
1184 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, real, zero, fmf);
1186 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, imag, zero, fmf);
1206 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
1213 rewriter.replaceOpWithNewOp<math::Atan2Op>(op, imag, real, fmf);