[Mlir-commits] [mlir] [mlir][complex] Require fastmath for the add/sub and exp/log folds (PR #221384)
Hung-Kuan Tseng
llvmlistbot at llvm.org
Fri Sep 11 07:36:22 PDT 2026
================
@@ -313,8 +322,12 @@ OpFoldResult NegOp::fold(FoldAdaptor adaptor) {
OpFoldResult ExpOp::fold(FoldAdaptor adaptor) {
// complex.exp(complex.log(a)) -> a
+ // exp(log(a)) is only an approximation of a, so both ops need `afn`.
if (auto logOp = getOperand().getDefiningOp<LogOp>())
- return logOp.getOperand();
+ if (arith::bitEnumContainsAll(getFastmath(), arith::FastMathFlags::afn) &&
+ arith::bitEnumContainsAll(logOp.getFastmath(),
+ arith::FastMathFlags::afn))
----------------
Tim096 wrote:
Done, it is `reassoc` on the exp only now.
https://github.com/llvm/llvm-project/pull/221384
More information about the Mlir-commits
mailing list