[flang-commits] [PATCH] D149442: [flang][hlfir] Add hlfir.region_assign and its hlfir.yield terminator

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Apr 28 06:14:39 PDT 2023


jeanPerier created this revision.
jeanPerier added reviewers: tblah, vzakhari, clementval.
jeanPerier added a project: Flang.
Herald added subscribers: sunshaoce, mehdi_amini, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
jeanPerier requested review of this revision.

hlfir.region_assign is a Region based version of hlfir.assign: the
right-hand side and left-hand-side are evaluated in their own region,
and an optional region can be added to implement user defined
assignment.

This will be used for:

- assignments inside where and forall
- user defined assignments
- assignments to vector subscripted entities.

Rational:

Forall and Where lowering requires solving an expression/assignment
evaluation scheduling problem based on data dependencies between the
variables being assigned and the one used in the expressions.
Keeping left-hand side and right-hand side in their own region will
make it really easy to analyse the dependency and move around the
expression evaluation as a whole. Operation DAGs are hard to scissor out
when the LHS and RHS evaluation are lowered in the same block. The pass
dealing with further forall/where lowering in HLFIR will need to
succeed. It is not acceptable for them to fail splitting the RHS/LHS
evaluation code. Keeping them in independent block is an approach that
cannot fail.

For user defined assignments, having a region allows implementing all
the call details in lowering, and even to allow inlining of the user
assignment, before it is decided if a temporary for the LHS or RHS is
required or not.

The operation description mention "hlfir.elemental_addr" (operation that
will be used for vector subscripted LHS) and "ordered assignment trees"
(concept/inetrface that will be used to represent forall/where structure
in HLFIR). These will be pushed in follow-up patch, but I do not want t
scissor out the descriptions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149442

Files:
  flang/include/flang/Optimizer/HLFIR/HLFIROps.h
  flang/include/flang/Optimizer/HLFIR/HLFIROps.td
  flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
  flang/test/HLFIR/invalid.fir
  flang/test/HLFIR/region-assign.fir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149442.517891.patch
Type: text/x-patch
Size: 15075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230428/0526cb4a/attachment-0001.bin>


More information about the flang-commits mailing list