@@ -1520,20 +1520,12 @@ class TanPattern : public SPIRVToLLVMConversion<spirv::GLTanOp> {
15201520 if (!dstType)
15211521 return rewriter.notifyMatchFailure (tanOp, " type conversion failed" );
15221522
1523- Location loc = tanOp.getLoc ();
1524- Value sin = LLVM::SinOp::create (rewriter, loc, dstType, tanOp.getOperand ());
1525- Value cos = LLVM::CosOp::create (rewriter, loc, dstType, tanOp.getOperand ());
1526- rewriter.replaceOpWithNewOp <LLVM::FDivOp>(tanOp, dstType, sin, cos);
1523+ rewriter.replaceOpWithNewOp <LLVM::TanOp>(tanOp, dstType,
1524+ adaptor.getOperands ());
15271525 return success ();
15281526 }
15291527};
15301528
1531- // / Convert `spirv.Tanh` to
1532- // /
1533- // / exp(2x) - 1
1534- // / -----------
1535- // / exp(2x) + 1
1536- // /
15371529class TanhPattern : public SPIRVToLLVMConversion <spirv::GLTanhOp> {
15381530public:
15391531 using SPIRVToLLVMConversion<spirv::GLTanhOp>::SPIRVToLLVMConversion;
@@ -1546,18 +1538,8 @@ class TanhPattern : public SPIRVToLLVMConversion<spirv::GLTanhOp> {
15461538 if (!dstType)
15471539 return rewriter.notifyMatchFailure (tanhOp, " type conversion failed" );
15481540
1549- Location loc = tanhOp.getLoc ();
1550- Value two = createFPConstant (loc, srcType, dstType, rewriter, 2.0 );
1551- Value multiplied =
1552- LLVM::FMulOp::create (rewriter, loc, dstType, two, tanhOp.getOperand ());
1553- Value exponential = LLVM::ExpOp::create (rewriter, loc, dstType, multiplied);
1554- Value one = createFPConstant (loc, srcType, dstType, rewriter, 1.0 );
1555- Value numerator =
1556- LLVM::FSubOp::create (rewriter, loc, dstType, exponential, one);
1557- Value denominator =
1558- LLVM::FAddOp::create (rewriter, loc, dstType, exponential, one);
1559- rewriter.replaceOpWithNewOp <LLVM::FDivOp>(tanhOp, dstType, numerator,
1560- denominator);
1541+ rewriter.replaceOpWithNewOp <LLVM::TanhOp>(tanhOp, dstType,
1542+ adaptor.getOperands ());
15611543 return success ();
15621544 }
15631545};
0 commit comments