[flang-commits] [flang] [flang] Add fastmath attributes to complex arithmetic (PR #70690)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Mon Oct 30 10:37:05 PDT 2023


kiranchandramohan wrote:

The patch that added the same in MLIR complex is the following. That patch creates an LLVM::FastmathFlagsAttr and passes that during construction of the LLVM Ops rather than setting it separately.

https://reviews.llvm.org/D156310

```
    arith::FastMathFlagsAttr complexFMFAttr = op.getFastMathFlagsAttr();
    LLVM::FastmathFlagsAttr fmf = LLVM::FastmathFlagsAttr::get(
        op.getContext(),
        convertArithFastMathFlagsToLLVM(complexFMFAttr.getValue()));
    Value real =
        rewriter.create<LLVM::FAddOp>(loc, arg.lhs.real(), arg.rhs.real(), fmf);
    Value imag =
        rewriter.create<LLVM::FAddOp>(loc, arg.lhs.imag(), arg.rhs.imag(), fmf);
    result.setReal(rewriter, loc, real);
    result.setImaginary(rewriter, loc, imag);
```

https://github.com/llvm/llvm-project/pull/70690


More information about the flang-commits mailing list