@@ -973,6 +973,7 @@ struct TanhOpConversion : public OpConversionPattern<complex::TanhOp> {
973
973
auto loc = op.getLoc ();
974
974
auto type = cast<ComplexType>(adaptor.getComplex ().getType ());
975
975
auto elementType = cast<FloatType>(type.getElementType ());
976
+ arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr ();
976
977
977
978
// The hyperbolic tangent for complex number can be calculated as follows.
978
979
// tanh(x + i * y) = (tanh(x) + i * tan(y)) / (1 + tanh(x) * tan(y))
@@ -981,17 +982,18 @@ struct TanhOpConversion : public OpConversionPattern<complex::TanhOp> {
981
982
rewriter.create <complex::ReOp>(loc, elementType, adaptor.getComplex ());
982
983
Value imag =
983
984
rewriter.create <complex::ImOp>(loc, elementType, adaptor.getComplex ());
984
- Value tanhA = rewriter.create <math::TanhOp>(loc, real);
985
- Value cosB = rewriter.create <math::CosOp>(loc, imag);
986
- Value sinB = rewriter.create <math::SinOp>(loc, imag);
987
- Value tanB = rewriter.create <arith::DivFOp>(loc, sinB, cosB);
985
+ Value tanhA = rewriter.create <math::TanhOp>(loc, real, fmf );
986
+ Value cosB = rewriter.create <math::CosOp>(loc, imag, fmf );
987
+ Value sinB = rewriter.create <math::SinOp>(loc, imag, fmf );
988
+ Value tanB = rewriter.create <arith::DivFOp>(loc, sinB, cosB, fmf );
988
989
Value numerator =
989
990
rewriter.create <complex::CreateOp>(loc, type, tanhA, tanB);
990
991
Value one = rewriter.create <arith::ConstantOp>(
991
992
loc, elementType, rewriter.getFloatAttr (elementType, 1 ));
992
- Value mul = rewriter.create <arith::MulFOp>(loc, tanhA, tanB);
993
+ Value mul = rewriter.create <arith::MulFOp>(loc, tanhA, tanB, fmf );
993
994
Value denominator = rewriter.create <complex::CreateOp>(loc, type, one, mul);
994
- rewriter.replaceOpWithNewOp <complex::DivOp>(op, numerator, denominator);
995
+ rewriter.replaceOpWithNewOp <complex::DivOp>(op, numerator, denominator,
996
+ fmf);
995
997
return success ();
996
998
}
997
999
};
0 commit comments