This is an archive of the discontinued LLVM Phabricator instance.

[mlir][math] Added math::FPowI conversion to LLVM dialect.
ClosedPublic

Authored by vzakhari on Jul 14 2022, 3:30 PM.

Details

Diff Detail

Event Timeline

vzakhari created this revision.Jul 14 2022, 3:30 PM
vzakhari requested review of this revision.Jul 14 2022, 3:30 PM

Hi @wsmoses, can you please read through the TBD comments in this change and see if you have any comments? This is related to LLVM::PowIOp added in https://reviews.llvm.org/D116364. It is not quite aligned with the supported forms of llvm.powi.* LLVM intrinsic, so I wonder what the plan for this MLIR operation is.

vzakhari updated this revision to Diff 445032.Jul 15 2022, 9:45 AM

@wsmoses, friendly ping regarding the questions above.

vzakhari updated this revision to Diff 446943.Jul 22 2022, 12:31 PM
vzakhari retitled this revision from [WIP][mlir][math] Added math::FPowSI conversion to LLVM dialect. to [WIP][mlir][math] Added math::FPowI conversion to LLVM dialect..
vzakhari planned changes to this revision.Jul 22 2022, 2:30 PM
Mogball requested changes to this revision.Aug 11 2022, 10:18 AM
Mogball added a subscriber: Mogball.
Mogball added inline comments.
mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
285

Can you try VectorConvertToLLVMPattern<FPowIOp, PowIOp>?

vzakhari added inline comments.Aug 11 2022, 10:24 AM
mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
285

LLVM::PowIOp is only guaranteed to support i32 exponent, so for other cases LLVM backend will not be able to handle the resulting LLVM IR. I described the two options here: https://discourse.llvm.org/t/rfc-adding-more-power-operations-into-math-dialect/63975/3?u=szakharin

I am leaning toward using LLVM::PowIOp for i32 exponent and use the outlined implementation otherwise.

Mogball added inline comments.Aug 11 2022, 10:25 AM
mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
285

Do you need an exponent greater than i32?

vzakhari added inline comments.Aug 11 2022, 10:29 AM
mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
285

I am going to use it for lowering Fortran exponentiation operator (**), and it does support i64 exponent.

vzakhari updated this revision to Diff 481983.Dec 11 2022, 7:44 PM
vzakhari retitled this revision from [WIP][mlir][math] Added math::FPowI conversion to LLVM dialect. to [mlir][math] Added math::FPowI conversion to LLVM dialect..
vzakhari edited the summary of this revision. (Show Details)

This is a one-to-one conversion to LLVM::PowIOp. Flang will use MathToFuncs convertor (D139804) to convert unsupported exponent-width cases before engaging MathToLLVM.

Mogball accepted this revision.Dec 13 2022, 9:37 AM
This revision is now accepted and ready to land.Dec 13 2022, 9:37 AM