[all-commits] [llvm/llvm-project] 559f55: [flang] implement simple pointer assignments insid...

jeanPerier via All-commits all-commits at lists.llvm.org
Mon Mar 3 04:06:26 PST 2025


  Branch: refs/heads/users/jeanPerier/pointer-forall
  Home:   https://github.com/llvm/llvm-project
  Commit: 559f55d20bc87f3737757e76c70b64ecbef5098e
      https://github.com/llvm/llvm-project/commit/559f55d20bc87f3737757e76c70b64ecbef5098e
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2025-03-03 (Mon, 03 Mar 2025)

  Changed paths:
    M flang/include/flang/Optimizer/Builder/HLFIRTools.h
    M flang/include/flang/Optimizer/Builder/TemporaryStorage.h
    M flang/include/flang/Optimizer/Dialect/FIRType.h
    M flang/include/flang/Optimizer/HLFIR/HLFIROps.td
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Optimizer/Builder/HLFIRTools.cpp
    M flang/lib/Optimizer/Builder/TemporaryStorage.cpp
    M flang/lib/Optimizer/Dialect/FIRType.cpp
    M flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/ScheduleOrderedAssignments.cpp
    A flang/test/HLFIR/order_assignments/forall-pointer-assignment-codegen.fir
    A flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling.f90

  Log Message:
  -----------
  [flang] implement simple pointer assignments inside FORALL

The semantic of pointer assignments inside FORALL requires evaluating
the targets (RHS) and pointer variables (LHS) of all iterations before
evaluating the assignments.

In practice, if the compiler can prove that the RHS and LHS evaluations
are not impacted by the assignments, the evaluation of the FORALL
assignment statement can be done in a single loop.
However, if the compiler cannot prove this, it needs to "save" the addresses
of the targets and/or the pointer descriptors of each iterations before doing
the assignments.

This patch implement the most common cases where there is no lower bound spec,
no bounds remapping, the LHS is not polymorphic, and the RHS is not NULL.

The HLFIR operation used to represent assignments inside FORALL can be used
for pointer assignments to (the only difference being that the LHS is a
descriptor address).

The analysis for intrinsic assignment can be reused, with the distinction that
the RHS data is not read during the assignment.

The logic that is used to save LHS in intrinsic assignments inside FORALL is
extracted to be used for the RHS of pointer assignments when needed (saving
a descriptor value).
Pointer assignment LHS are just descriptor addresses and are saved as int_ptr
values.

Note than pointer assignments inside Forall do not seem to be vastly used
outside of trivial cases given none gfortran, nvfortran, xlf, ifx, and nagfor
pass the added Fortran test when ran end-to-end (some correctly deal with
conflict with the RHS, but none is able to "save" the LHS correctly).

Remaining cases will be implemented in a separate patch.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list