[Flang] Lower Unstructured do loops
The FIR `do_loop` is designed as a structured operation with a single block inside it. Presence of unstructured constructs like jumps, exits inside the loop will cause the loop to be marked as unstructured. These loops are lowered using the `control-flow` dialect branch operations. Fortran semantics do not allow the loop variable to be modified inside the loop. To prevent accidental modification, the iteration of the loop is modeled by two variables, trip-count and loop-variable. -> The trip-count and loop-variable are initialized in the pre-header. The trip-count is set as (end-start+step)/step where end, start and step have the usual meanings. The loop-variable is initialized to start. -> The header block contains a conditional branch instruction which selects between branching to the body of the loop or the exit block depending on the value of the trip-count. -> Inside the body, the trip-count is decremented and the loop-variable incremented by the step value. Finally it branches to the header of the loop. Part of the upstreaming effort to move LLVM Flang from fir-dev branch of https://github.com/flang-compiler/f18-llvm-project to the LLVM Project. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D124837 Co-authored-by:Val Donaldson <vdonaldson@nvidia.com> Co-authored-by:
Eric Schweitz <eschweitz@nvidia.com> Co-authored-by:
Jean Perier <jperier@nvidia.com> Co-authored-by:
Peter Klausler <pklausler@nvidia.com>
Loading
Please sign in to comment