llvm-project/flang/test/Driver/complex-range.f90
Shunsuke Watanabe c9900015a9
[flang] Add -fcomplex-arithmetic= option and select complex division algorithm (#146641)
This patch adds an option to select the method for computing complex
number division. It uses `LoweringOptions` to determine whether to lower
complex division to a runtime function call or to MLIR's `complex.div`,
and `CodeGenOptions` to select the computation algorithm for
`complex.div`. The available option values and their corresponding
algorithms are as follows:
- `full`: Lower to a runtime function call. (Default behavior)
- `improved`: Lower to `complex.div` and expand to Smith's algorithm.
- `basic`: Lower to `complex.div` and expand to the algebraic algorithm.

See also the discussion in the following discourse post:
https://discourse.llvm.org/t/optimization-of-complex-number-division/83468

---------

Co-authored-by: Tarun Prabhu <tarunprabhu@gmail.com>
2025-07-09 13:43:54 +09:00

24 lines
760 B
Fortran

! Test range options for complex multiplication and division.
! RUN: %flang -### -c %s 2>&1 \
! RUN: | FileCheck %s --check-prefix=RANGE
! RUN: %flang -### -fcomplex-arithmetic=full -c %s 2>&1 \
! RUN: | FileCheck %s --check-prefix=FULL
! RUN: %flang -### -fcomplex-arithmetic=improved -c %s 2>&1 \
! RUN: | FileCheck %s --check-prefix=IMPRVD
! RUN: %flang -### -fcomplex-arithmetic=basic -c %s 2>&1 \
! RUN: | FileCheck %s --check-prefix=BASIC
! RUN: not %flang -### -fcomplex-arithmetic=foo -c %s 2>&1 \
! RUN: | FileCheck %s --check-prefix=ERR
! RANGE-NOT: -complex-range=
! FULL: -complex-range=full
! IMPRVD: -complex-range=improved
! BASIC: -complex-range=basic
! ERR: error: unsupported argument 'foo' to option '-fcomplex-arithmetic='