[flang-commits] [PATCH] D149836: [flang][hlfir] Add hlfir.forall_index operation

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu May 4 03:03:55 PDT 2023


jeanPerier created this revision.
jeanPerier added reviewers: tblah, vzakhari, clementval.
jeanPerier added a project: Flang.
Herald added subscribers: sunshaoce, bzcheeseman, mehdi_amini, rriddle, jdoerfert, arphaman.
Herald added a project: All.
jeanPerier requested review of this revision.
Herald added a subscriber: stephenneuendorffer.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149836

Files:
  flang/include/flang/Optimizer/HLFIR/HLFIROps.td
  flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
  flang/test/HLFIR/forall-index.fir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149836.519414.patch
Type: text/x-patch
Size: 5607 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230504/f9ba11f7/attachment-0001.bin>


More information about the flang-commits mailing list