[all-commits] [llvm/llvm-project] 1b9d0d: [Flang] Change complex divide lowering

kiranchandramohan via All-commits all-commits at lists.llvm.org
Fri May 5 06:08:33 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1b9d0deb6d53db760a91bcf63c9b2509f95af2bb
  Author: Kiran Chandramohan <kiran.chandramohan at arm.com>
  Date:   2023-05-05 (Fri, 05 May 2023)

  Changed paths:
    M flang/include/flang/Optimizer/Builder/IntrinsicCall.h
    M flang/lib/Lower/ConvertExpr.cpp
    M flang/lib/Optimizer/Builder/IntrinsicCall.cpp
    M flang/test/Lower/assignment.f90
    M flang/test/Lower/complex-operations.f90

  Log Message:
  [Flang] Change complex divide lowering

Currently complex division is lowered to a fir.divc operation and the
fir.divc is later converted to a sequence of llvm operations to perform
complex division, however this causes issues for extreme values when
the calculations overflow.

This patch changes the lowering of complex division to use the Intrinsic
Call functionality to lower into library calls (for single, double,
extended and quad precisions) or an MLIR complex dialect division operation
(for half and bfloat precisions).

Note 1: If the Complex To Standard conversion of division operation
matures then we can use it for all precisions. Currently it has the
same issues as the conversion of fir.divc.
Note 2: A previous patch (D145808) did the same but during conversion of
the fir.divc operation. But using function calls at that stage leads to
ABI issues since the conversion to LLVM is not aware of the complex target
Note 3: If the patch is accepted, fir.divc can be removed from FIR.

Reviewed By: vzakhari, PeteSteinfeld, DavidTruby

Differential Revision: https://reviews.llvm.org/D149546

More information about the All-commits mailing list