Lines Matching full:create
35 Value one = b.create<arith::ConstantOp>(real.getType(),
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);
47 Value ratio = b.create<arith::DivFOp>(min, max, fmfWithNaNInf);
48 Value ratioSq = b.create<arith::MulFOp>(ratio, ratio, fmfWithNaNInf);
49 Value ratioSqPlusOne = b.create<arith::AddFOp>(ratioSq, one, fmfWithNaNInf);
53 ratioSqPlusOne = b.create<math::RsqrtOp>(ratioSqPlusOne, fmfWithNaNInf);
54 min = b.create<math::RsqrtOp>(min, fmfWithNaNInf);
55 max = b.create<math::RsqrtOp>(max, fmfWithNaNInf);
59 Value quarter = b.create<arith::ConstantOp>(
62 Value sqrt = b.create<math::SqrtOp>(max, fmfWithNaNInf);
63 Value p025 = b.create<math::PowFOp>(ratioSqPlusOne, quarter, fmfWithNaNInf);
64 result = b.create<arith::MulFOp>(sqrt, p025, fmfWithNaNInf);
66 Value sqrt = b.create<math::SqrtOp>(ratioSqPlusOne, fmfWithNaNInf);
67 result = b.create<arith::MulFOp>(max, sqrt, fmfWithNaNInf);
70 Value isNaN = b.create<arith::CmpFOp>(arith::CmpFPredicate::UNO, result,
72 return b.create<arith::SelectOp>(isNaN, min, result);
85 Value real = b.create<complex::ReOp>(adaptor.getComplex());
86 Value imag = b.create<complex::ImOp>(adaptor.getComplex());
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);
117 b.create<arith::ConstantOp>(elementType, b.getZeroAttr(elementType));
118 Value one = b.create<arith::ConstantOp>(elementType,
120 Value i = b.create<complex::CreateOp>(type, zero, one);
121 Value iTimesLhs = b.create<complex::MulOp>(i, lhs, fmf);
122 Value rhsPlusILhs = b.create<complex::AddOp>(rhs, iTimesLhs, fmf);
124 Value divResult = b.create<complex::DivOp>(
126 Value logResult = b.create<complex::LogOp>(divResult, fmf);
128 Value negativeOne = b.create<arith::ConstantOp>(
130 Value negativeI = b.create<complex::CreateOp>(type, zero, negativeOne);
150 Value realLhs = rewriter.create<complex::ReOp>(loc, type, adaptor.getLhs());
151 Value imagLhs = rewriter.create<complex::ImOp>(loc, type, adaptor.getLhs());
152 Value realRhs = rewriter.create<complex::ReOp>(loc, type, adaptor.getRhs());
153 Value imagRhs = rewriter.create<complex::ImOp>(loc, type, adaptor.getRhs());
155 rewriter.create<arith::CmpFOp>(loc, p, realLhs, realRhs);
157 rewriter.create<arith::CmpFOp>(loc, p, imagLhs, imagRhs);
180 Value realLhs = b.create<complex::ReOp>(elementType, adaptor.getLhs());
181 Value realRhs = b.create<complex::ReOp>(elementType, adaptor.getRhs());
182 Value resultReal = b.create<BinaryStandardOp>(elementType, realLhs, realRhs,
184 Value imagLhs = b.create<complex::ImOp>(elementType, adaptor.getLhs());
185 Value imagRhs = b.create<complex::ImOp>(elementType, adaptor.getRhs());
186 Value resultImag = b.create<BinaryStandardOp>(elementType, imagLhs, imagRhs,
209 rewriter.create<complex::ReOp>(loc, elementType, adaptor.getComplex());
211 rewriter.create<complex::ImOp>(loc, elementType, adaptor.getComplex());
214 // ops. Here we create these building blocks and call into an op-specific
216 Value half = rewriter.create<arith::ConstantOp>(
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);
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);
276 rewriter.create<complex::ReOp>(loc, elementType, adaptor.getLhs());
278 rewriter.create<complex::ImOp>(loc, elementType, adaptor.getLhs());
280 rewriter.create<complex::ReOp>(loc, elementType, adaptor.getRhs());
282 rewriter.create<complex::ImOp>(loc, elementType, adaptor.getRhs());
307 rewriter.create<arith::DivFOp>(loc, rhsReal, rhsImag, fmf);
308 Value rhsRealImagDenom = rewriter.create<arith::AddFOp>(
310 rewriter.create<arith::MulFOp>(loc, rhsRealImagRatio, rhsReal, fmf),
312 Value realNumerator1 = rewriter.create<arith::AddFOp>(
314 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsRealImagRatio, fmf),
316 Value resultReal1 = rewriter.create<arith::DivFOp>(loc, realNumerator1,
318 Value imagNumerator1 = rewriter.create<arith::SubFOp>(
320 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsRealImagRatio, fmf),
322 Value resultImag1 = rewriter.create<arith::DivFOp>(loc, imagNumerator1,
326 rewriter.create<arith::DivFOp>(loc, rhsImag, rhsReal, fmf);
327 Value rhsImagRealDenom = rewriter.create<arith::AddFOp>(
329 rewriter.create<arith::MulFOp>(loc, rhsImagRealRatio, rhsImag, fmf),
331 Value realNumerator2 = rewriter.create<arith::AddFOp>(
333 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsImagRealRatio, fmf),
335 Value resultReal2 = rewriter.create<arith::DivFOp>(loc, realNumerator2,
337 Value imagNumerator2 = rewriter.create<arith::SubFOp>(
339 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsImagRealRatio, fmf),
341 Value resultImag2 = rewriter.create<arith::DivFOp>(loc, imagNumerator2,
346 Value zero = rewriter.create<arith::ConstantOp>(
348 Value rhsRealAbs = rewriter.create<math::AbsFOp>(loc, rhsReal, fmf);
349 Value rhsRealIsZero = rewriter.create<arith::CmpFOp>(
351 Value rhsImagAbs = rewriter.create<math::AbsFOp>(loc, rhsImag, fmf);
352 Value rhsImagIsZero = rewriter.create<arith::CmpFOp>(
354 Value lhsRealIsNotNaN = rewriter.create<arith::CmpFOp>(
356 Value lhsImagIsNotNaN = rewriter.create<arith::CmpFOp>(
359 rewriter.create<arith::OrIOp>(loc, lhsRealIsNotNaN, lhsImagIsNotNaN);
360 Value resultIsInfinity = rewriter.create<arith::AndIOp>(
362 rewriter.create<arith::AndIOp>(loc, rhsRealIsZero, rhsImagIsZero));
363 Value inf = rewriter.create<arith::ConstantOp>(
368 rewriter.create<math::CopySignOp>(loc, inf, rhsReal);
370 rewriter.create<arith::MulFOp>(loc, infWithSignOfRhsReal, lhsReal, fmf);
372 rewriter.create<arith::MulFOp>(loc, infWithSignOfRhsReal, lhsImag, fmf);
375 Value rhsRealFinite = rewriter.create<arith::CmpFOp>(
377 Value rhsImagFinite = rewriter.create<arith::CmpFOp>(
380 rewriter.create<arith::AndIOp>(loc, rhsRealFinite, rhsImagFinite);
381 Value lhsRealAbs = rewriter.create<math::AbsFOp>(loc, lhsReal, fmf);
382 Value lhsRealInfinite = rewriter.create<arith::CmpFOp>(
384 Value lhsImagAbs = rewriter.create<math::AbsFOp>(loc, lhsImag, fmf);
385 Value lhsImagInfinite = rewriter.create<arith::CmpFOp>(
388 rewriter.create<arith::OrIOp>(loc, lhsRealInfinite, lhsImagInfinite);
390 rewriter.create<arith::AndIOp>(loc, lhsInfinite, rhsFinite);
391 Value one = rewriter.create<arith::ConstantOp>(
393 Value lhsRealIsInfWithSign = rewriter.create<math::CopySignOp>(
394 loc, rewriter.create<arith::SelectOp>(loc, lhsRealInfinite, one, zero),
396 Value lhsImagIsInfWithSign = rewriter.create<math::CopySignOp>(
397 loc, rewriter.create<arith::SelectOp>(loc, lhsImagInfinite, one, zero),
400 rewriter.create<arith::MulFOp>(loc, lhsRealIsInfWithSign, rhsReal, fmf);
402 rewriter.create<arith::MulFOp>(loc, lhsImagIsInfWithSign, rhsImag, fmf);
403 Value resultReal3 = rewriter.create<arith::MulFOp>(
405 rewriter.create<arith::AddFOp>(loc, lhsRealIsInfWithSignTimesRhsReal,
409 rewriter.create<arith::MulFOp>(loc, lhsRealIsInfWithSign, rhsImag, fmf);
411 rewriter.create<arith::MulFOp>(loc, lhsImagIsInfWithSign, rhsReal, fmf);
412 Value resultImag3 = rewriter.create<arith::MulFOp>(
414 rewriter.create<arith::SubFOp>(loc, lhsImagIsInfWithSignTimesRhsReal,
419 Value lhsRealFinite = rewriter.create<arith::CmpFOp>(
421 Value lhsImagFinite = rewriter.create<arith::CmpFOp>(
424 rewriter.create<arith::AndIOp>(loc, lhsRealFinite, lhsImagFinite);
425 Value rhsRealInfinite = rewriter.create<arith::CmpFOp>(
427 Value rhsImagInfinite = rewriter.create<arith::CmpFOp>(
430 rewriter.create<arith::OrIOp>(loc, rhsRealInfinite, rhsImagInfinite);
432 rewriter.create<arith::AndIOp>(loc, lhsFinite, rhsInfinite);
433 Value rhsRealIsInfWithSign = rewriter.create<math::CopySignOp>(
434 loc, rewriter.create<arith::SelectOp>(loc, rhsRealInfinite, one, zero),
436 Value rhsImagIsInfWithSign = rewriter.create<math::CopySignOp>(
437 loc, rewriter.create<arith::SelectOp>(loc, rhsImagInfinite, one, zero),
440 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsRealIsInfWithSign, fmf);
442 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsImagIsInfWithSign, fmf);
443 Value resultReal4 = rewriter.create<arith::MulFOp>(
445 rewriter.create<arith::AddFOp>(loc, rhsRealIsInfWithSignTimesLhsReal,
449 rewriter.create<arith::MulFOp>(loc, lhsImag, rhsRealIsInfWithSign, fmf);
451 rewriter.create<arith::MulFOp>(loc, lhsReal, rhsImagIsInfWithSign, fmf);
452 Value resultImag4 = rewriter.create<arith::MulFOp>(
454 rewriter.create<arith::SubFOp>(loc, rhsRealIsInfWithSignTimesLhsImag,
458 Value realAbsSmallerThanImagAbs = rewriter.create<arith::CmpFOp>(
460 Value resultReal = rewriter.create<arith::SelectOp>(
462 Value resultImag = rewriter.create<arith::SelectOp>(
464 Value resultRealSpecialCase3 = rewriter.create<arith::SelectOp>(
466 Value resultImagSpecialCase3 = rewriter.create<arith::SelectOp>(
468 Value resultRealSpecialCase2 = rewriter.create<arith::SelectOp>(
470 Value resultImagSpecialCase2 = rewriter.create<arith::SelectOp>(
472 Value resultRealSpecialCase1 = rewriter.create<arith::SelectOp>(
474 Value resultImagSpecialCase1 = rewriter.create<arith::SelectOp>(
477 Value resultRealIsNaN = rewriter.create<arith::CmpFOp>(
479 Value resultImagIsNaN = rewriter.create<arith::CmpFOp>(
482 rewriter.create<arith::AndIOp>(loc, resultRealIsNaN, resultImagIsNaN);
483 Value resultRealWithSpecialCases = rewriter.create<arith::SelectOp>(
485 Value resultImagWithSpecialCases = rewriter.create<arith::SelectOp>(
506 rewriter.create<complex::ReOp>(loc, elementType, adaptor.getComplex());
508 rewriter.create<complex::ImOp>(loc, elementType, adaptor.getComplex());
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());
528 b.create<arith::ConstantOp>(b.getFloatAttr(argType, coefficients[0]));
530 poly = b.create<math::FmaOp>(
532 b.create<arith::ConstantOp>(b.getFloatAttr(argType, coefficients[i])),
553 Value real = b.create<complex::ReOp>(adaptor.getComplex());
554 Value imag = b.create<complex::ImOp>(adaptor.getComplex());
556 Value zero = b.create<arith::ConstantOp>(b.getFloatAttr(elemType, 0.0));
557 Value one = b.create<arith::ConstantOp>(b.getFloatAttr(elemType, 1.0));
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);
564 Value cosImag = b.create<arith::AddFOp>(cosm1Imag, one, fmf);
566 Value realResult = b.create<arith::AddFOp>(
567 b.create<arith::MulFOp>(expm1Real, cosImag, fmf), cosm1Imag, fmf);
569 Value imagIsZero = b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, imag,
571 Value imagResult = b.create<arith::SelectOp>(
572 imagIsZero, zero, b.create<arith::MulFOp>(expReal, sinImag, fmf));
583 auto negHalf = b.create<arith::ConstantOp>(b.getFloatAttr(argType, -0.5));
584 auto negOne = b.create<arith::ConstantOp>(b.getFloatAttr(argType, -1.0));
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);
601 b.create<arith::AddFOp>(b.create<arith::MulFOp>(argPow4, poly, fmf),
602 b.create<arith::MulFOp>(negHalf, argPow2, fmf));
606 b.create<arith::ConstantOp>(b.getFloatAttr(argType, 0.61685));
607 Value cond = b.create<arith::CmpFOp>(arith::CmpFPredicate::OGE, argPow2,
609 return b.create<arith::SelectOp>(cond, forLargeArg, forSmallArg);
624 Value abs = b.create<complex::AbsOp>(elementType, adaptor.getComplex(),
626 Value resultReal = b.create<math::LogOp>(elementType, abs, fmf.getValue());
627 Value real = b.create<complex::ReOp>(elementType, adaptor.getComplex());
628 Value imag = b.create<complex::ImOp>(elementType, adaptor.getComplex());
630 b.create<math::Atan2Op>(elementType, imag, real, fmf.getValue());
648 Value real = b.create<complex::ReOp>(adaptor.getComplex());
649 Value imag = b.create<complex::ImOp>(adaptor.getComplex());
651 Value half = b.create<arith::ConstantOp>(elementType,
653 Value one = b.create<arith::ConstantOp>(elementType,
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);
662 Value useReal = b.create<arith::CmpFOp>(arith::CmpFPredicate::OGT,
664 Value maxMinusOne = b.create<arith::SubFOp>(maxAbs, one, fmf);
666 b.create<arith::SelectOp>(useReal, real, maxMinusOne);
669 Value minMaxRatio = b.create<arith::DivFOp>(minAbs, maxAbs, fmfWithNaNInf);
671 b.create<math::Log1pOp>(maxAbsOfRealPlusOneAndImagMinusOne, fmf);
672 Value logOfSqrtPart = b.create<math::Log1pOp>(
673 b.create<arith::MulFOp>(minMaxRatio, minMaxRatio, fmfWithNaNInf),
675 Value r = b.create<arith::AddFOp>(
676 b.create<arith::MulFOp>(half, logOfSqrtPart, fmfWithNaNInf),
678 Value resultReal = b.create<arith::SelectOp>(
679 b.create<arith::CmpFOp>(arith::CmpFPredicate::UNO, r, r, fmfWithNaNInf),
681 Value resultImag = b.create<math::Atan2Op>(imag, realPlusOne, fmf);
699 Value lhsReal = b.create<complex::ReOp>(elementType, adaptor.getLhs());
700 Value lhsImag = b.create<complex::ImOp>(elementType, adaptor.getLhs());
701 Value rhsReal = b.create<complex::ReOp>(elementType, adaptor.getRhs());
702 Value rhsImag = b.create<complex::ImOp>(elementType, adaptor.getRhs());
704 b.create<arith::MulFOp>(lhsReal, rhsReal, fmfValue);
706 b.create<arith::MulFOp>(lhsImag, rhsImag, fmfValue);
707 Value real = b.create<arith::SubFOp>(lhsRealTimesRhsReal,
710 b.create<arith::MulFOp>(lhsImag, rhsReal, fmfValue);
712 b.create<arith::MulFOp>(lhsReal, rhsImag, fmfValue);
713 Value imag = b.create<arith::AddFOp>(lhsImagTimesRhsReal,
731 rewriter.create<complex::ReOp>(loc, elementType, adaptor.getComplex());
733 rewriter.create<complex::ImOp>(loc, elementType, adaptor.getComplex());
734 Value negReal = rewriter.create<arith::NegFOp>(loc, real);
735 Value negImag = rewriter.create<arith::NegFOp>(loc, imag);
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);
781 return b.create<arith::ConstantOp>(elementType,
786 Value half = b.create<arith::ConstantOp>(elementType,
789 Value real = b.create<complex::ReOp>(elementType, adaptor.getComplex());
790 Value imag = b.create<complex::ImOp>(elementType, adaptor.getComplex());
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);
802 Value resultImag = b.create<arith::SelectOp>(
803 sinIsZero, zero, b.create<arith::MulFOp>(absSqrt, sin, fmf));
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);
820 resultReal = b.create<arith::SelectOp>(
821 b.create<arith::AndIOp>(realIsNegInf, absImagIsNotInf), zero,
823 resultReal = b.create<arith::SelectOp>(
824 b.create<arith::OrIOp>(absImagIsInf, realIsInf), inf, resultReal);
826 Value imagSignInf = b.create<math::CopySignOp>(inf, imag, fmf);
827 resultImag = b.create<arith::SelectOp>(
828 b.create<arith::CmpFOp>(arith::CmpFPredicate::UNO, absSqrt, absSqrt),
830 resultImag = b.create<arith::SelectOp>(
831 b.create<arith::OrIOp>(absImagIsInf, realIsNegInf), imagSignInf,
836 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, absSqrt, zero, fmf);
837 resultReal = b.create<arith::SelectOp>(resultIsZero, zero, resultReal);
838 resultImag = b.create<arith::SelectOp>(resultIsZero, zero, resultImag);
857 Value real = b.create<complex::ReOp>(elementType, adaptor.getComplex());
858 Value imag = b.create<complex::ImOp>(elementType, adaptor.getComplex());
860 b.create<arith::ConstantOp>(elementType, b.getZeroAttr(elementType));
862 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, real, zero);
864 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, imag, zero);
865 Value isZero = b.create<arith::AndIOp>(realIsZero, imagIsZero);
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);
869 Value sign = b.create<complex::CreateOp>(type, realSign, imagSign);
891 b.create<complex::ReOp>(loc, elementType, adaptor.getComplex());
893 b.create<complex::ImOp>(loc, elementType, adaptor.getComplex());
894 Value negOne = b.create<arith::ConstantOp>(
900 real = b.create<arith::MulFOp>(real, negOne, fmf);
904 return b.create<arith::ConstantOp>(elementType,
908 Value four = b.create<arith::ConstantOp>(elementType,
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);
923 Value imagNum = b.create<arith::MulFOp>(
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);
931 Value isInf = b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ,
933 Value realLimit = b.create<math::CopySignOp>(negOne, real, fmf);
935 Value resultReal = b.create<arith::SelectOp>(
936 isInf, realLimit, b.create<arith::DivFOp>(realNum, denom, fmf));
937 Value resultImag = b.create<arith::DivFOp>(imagNum, denom, fmf);
941 Value absReal = b.create<math::AbsFOp>(real, fmf);
942 Value zero = b.create<arith::ConstantOp>(
947 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, absReal, inf, fmf);
949 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, imag, zero, fmf);
950 Value absRealIsNotInf = b.create<arith::XOrIOp>(
951 absRealIsInf, b.create<arith::ConstantIntOp>(true, /*width=*/1));
953 Value imagNumIsNaN = b.create<arith::CmpFOp>(arith::CmpFPredicate::UNO,
956 b.create<arith::AndIOp>(imagNumIsNaN, absRealIsNotInf);
957 Value resultImagIsZero = b.create<arith::OrIOp>(
958 imagIsZero, b.create<arith::AndIOp>(absRealIsInf, imagNumIsNaN));
960 resultReal = b.create<arith::SelectOp>(resultRealIsNaN, nan, resultReal);
962 b.create<arith::SelectOp>(resultImagIsZero, zero, resultImag);
968 resultImag = b.create<arith::MulFOp>(resultImag, negOne, fmf);
987 rewriter.create<complex::ReOp>(loc, elementType, adaptor.getComplex());
989 rewriter.create<complex::ImOp>(loc, elementType, adaptor.getComplex());
990 Value negImag = rewriter.create<arith::NegFOp>(loc, elementType, imag);
1006 Value a = builder.create<complex::ReOp>(lhs);
1007 Value b = builder.create<complex::ImOp>(lhs);
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);
1025 Value inf = builder.create<arith::ConstantOp>(
1029 Value zero = builder.create<arith::ConstantOp>(
1031 Value one = builder.create<arith::ConstantOp>(
1033 Value complexOne = builder.create<complex::CreateOp>(type, one, zero);
1034 Value complexZero = builder.create<complex::CreateOp>(type, zero, zero);
1035 Value complexInf = builder.create<complex::CreateOp>(type, inf, zero);
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);
1055 builder.create<arith::SelectOp>(cEqZero, complexOne, complexZero);
1057 builder.create<complex::CreateOp>(type, coeffCosQ, coeffSinQ);
1058 Value cutoff0 = builder.create<arith::SelectOp>(
1059 builder.create<arith::AndIOp>(
1060 builder.create<arith::AndIOp>(absEqZero, dEqZero), zeroLeC),
1067 Value rhsEqZero = builder.create<arith::AndIOp>(cEqZero, dEqZero);
1069 builder.create<arith::SelectOp>(rhsEqZero, complexOne, cutoff0);
1073 Value lhsEqOne = builder.create<arith::AndIOp>(
1074 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, a, one, fmf),
1077 builder.create<arith::SelectOp>(lhsEqOne, complexOne, cutoff1);
1081 Value lhsEqInf = builder.create<arith::AndIOp>(
1082 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, a, inf, fmf),
1084 Value rhsGt0 = builder.create<arith::AndIOp>(
1086 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OGT, c, zero, fmf));
1087 Value cutoff3 = builder.create<arith::SelectOp>(
1088 builder.create<arith::AndIOp>(lhsEqInf, rhsGt0), complexInf, cutoff2);
1092 Value rhsLt0 = builder.create<arith::AndIOp>(
1094 builder.create<arith::CmpFOp>(arith::CmpFPredicate::OLT, c, zero, fmf));
1095 Value cutoff4 = builder.create<arith::SelectOp>(
1096 builder.create<arith::AndIOp>(lhsEqInf, rhsLt0), complexZero, cutoff3);
1111 Value c = builder.create<complex::ReOp>(elementType, adaptor.getRhs());
1112 Value d = builder.create<complex::ImOp>(elementType, adaptor.getRhs());
1133 return b.create<arith::ConstantOp>(elementType,
1139 Value negHalf = b.create<arith::ConstantOp>(
1143 Value real = b.create<complex::ReOp>(elementType, adaptor.getComplex());
1144 Value imag = b.create<complex::ImOp>(elementType, adaptor.getComplex());
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);
1156 Value negOne = b.create<arith::ConstantOp>(
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);
1173 Value inIsNanInf = b.create<arith::AndIOp>(absImagIsInf, realIsNan);
1175 Value resultIsZero = b.create<arith::OrIOp>(inIsNanInf, realIsInf);
1178 b.create<arith::SelectOp>(resultIsZero, realSignedZero, resultReal);
1179 resultImag = b.create<arith::SelectOp>(resultIsZero, negImagSignedZero,
1184 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, real, zero, fmf);
1186 b.create<arith::CmpFOp>(arith::CmpFPredicate::OEQ, imag, zero, fmf);
1187 Value isZero = b.create<arith::AndIOp>(isRealZero, isImagZero);
1189 resultReal = b.create<arith::SelectOp>(isZero, inf, resultReal);
1190 resultImag = b.create<arith::SelectOp>(isZero, nan, resultImag);
1209 rewriter.create<complex::ReOp>(loc, type, adaptor.getComplex());
1211 rewriter.create<complex::ImOp>(loc, type, adaptor.getComplex());