[all-commits] [llvm/llvm-project] 0aa80b: [flang][hlfir] Add hlfir.forall_index operation

jeanPerier via All-commits all-commits at lists.llvm.org
Fri May 5 00:19:49 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0aa80b42ac975a10087c4356b475a188ef1f5afa
      https://github.com/llvm/llvm-project/commit/0aa80b42ac975a10087c4356b475a188ef1f5afa
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2023-05-05 (Fri, 05 May 2023)

  Changed paths:
    M flang/include/flang/Optimizer/HLFIR/HLFIROps.td
    M flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
    A flang/test/HLFIR/forall-index.fir

  Log Message:
  -----------
  [flang][hlfir] Add hlfir.forall_index operation

This is the last piece required to lower Forall (except pointer
assignments, where an operation may be needed to deal with bounds
remapping).

Lowering requires symbols to be mapped to memory SSA values produced
by a fir_FortranVariableOpInterface operation. This applies to
forall index-values, that are symbols.

fir.alloca/fir.store/hlfir.declare are not allowed inside the body of
an hlfir.forall that only accept operations with the
hlfir_OrderedAssignmentTreeOpInterface so that the forall structure is
well defined and easy to transform.
Allowing such operations in the forall body would open the doors to
generating ill-formed programs where such operation would be used for
non index-values.

Instead, add an hlfir.forall_index with both required interface to
produce a memory address for a forall index.

As a bonus, since forall index-value are by nature read-only, the
loads of hlfir.forall_index can be canonicalized, which will help
simplifying the hlfir.forall nested code (it is unclear we will be
able to tell MLIR enough about hlfir.forall and hlfir.where structure
so that it could safely do a generic mem-to-reg inside it, and getting
rid of read-effect operations will benefit the forall rewrite pass).

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




More information about the All-commits mailing list