[flang-commits] [flang] [Flang] Canonicalize divdc3 calls into arithmetic-based complex division (PR #146017)

Shunsuke Watanabe via flang-commits flang-commits at lists.llvm.org
Wed Jul 2 00:34:37 PDT 2025


s-watanabe314 wrote:

I've also submitted a patch as I was working on this independently and would like to share my approach. You can find my patch here: https://github.com/llvm/llvm-project/pull/146641

My patch takes a different approach to the `__divdc3` lowering. It allows us to choose whether to lower to a runtime function call or to a calculation using `complex.div` during the lowering phase. It also enables selection between the algebraic method and Smith's method for complex division by specifying a pass option in the conversion pass.

This implementation is based on the consensus reached in the Discourse discussion, and I believe it aligns well with the agreed-upon direction. It leverages the same driver options as Clang, which should contribute to easier maintenance and consistency. Furthermore, even if we need to change the method of calculating complex number division with other driver options like `-ffast-math`, we only need to modify the driver.

I'd be happy to discuss the differences between our approaches and see how we can best move forward. 


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


More information about the flang-commits mailing list