[all-commits] [llvm/llvm-project] aa0e16: [Flang] Lower Unstructured do loops

kiranchandramohan via All-commits all-commits at lists.llvm.org
Fri May 6 02:19:36 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aa0e167fab88cbef4d3f301534c86d143f2274ec
      https://github.com/llvm/llvm-project/commit/aa0e167fab88cbef4d3f301534c86d143f2274ec
  Author: Kiran Chandramohan <kiran.chandramohan at arm.com>
  Date:   2022-05-06 (Fri, 06 May 2022)

  Changed paths:
    M flang/lib/Lower/Bridge.cpp
    A flang/test/Lower/do_loop_unstructured.f90

  Log Message:
  -----------
  [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 at nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Co-authored-by: Jean Perier <jperier at nvidia.com>
Co-authored-by: Peter Klausler <pklausler at nvidia.com>




More information about the All-commits mailing list