[all-commits] [llvm/llvm-project] c85c0e: [flang][fir] Lower `do concurrent` loop nests to `...

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Tue Mar 25 02:27:04 PDT 2025


  Branch: refs/heads/users/ergawy/pft_to_do_concurrent
  Home:   https://github.com/llvm/llvm-project
  Commit: c85c0ef5d1aee334ff5c9705ec2257fcec825e09
      https://github.com/llvm/llvm-project/commit/c85c0ef5d1aee334ff5c9705ec2257fcec825e09
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-03-25 (Tue, 25 Mar 2025)

  Changed paths:
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Optimizer/Builder/FIRBuilder.cpp
    M flang/test/Lower/do_concurrent.f90
    M flang/test/Lower/do_concurrent_local_default_init.f90
    M flang/test/Lower/loops.f90
    M flang/test/Lower/loops3.f90
    M flang/test/Lower/nsw.f90

  Log Message:
  -----------
  [flang][fir] Lower `do concurrent` loop nests to `fir.do_concurrent`

Adds support for lowering `do concurrent` nests from PFT to the new
`fir.do_concurrent` MLIR op as well as its special terminator
`fir.do_concurrent.loop` which models the actual loop nest.

To that end, this PR emits the allocations for the iteration variables
within the block of the `fir.do_concurrent` op and creates a region for
the `fir.do_concurrent.loop` op that accepts arguments equal in number
to the number of the input `do concurrent` iteration ranges.

For example, given the following input:
```fortran
   do concurrent(i=1:10, j=11:20)
   end do
```
the changes in this PR emit the following MLIR:
```mlir
    fir.do_concurrent {
      %22 = fir.alloca i32 {bindc_name = "i"}
      %23:2 = hlfir.declare %22 {uniq_name = "_QFsub1Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
      %24 = fir.alloca i32 {bindc_name = "j"}
      %25:2 = hlfir.declare %24 {uniq_name = "_QFsub1Ej"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
      fir.do_concurrent.loop (%arg1, %arg2) = (%18, %20) to (%19, %21) step (%c1, %c1_0) {
        %26 = fir.convert %arg1 : (index) -> i32
        fir.store %26 to %23#0 : !fir.ref<i32>
        %27 = fir.convert %arg2 : (index) -> i32
        fir.store %27 to %25#0 : !fir.ref<i32>
      }
    }
```



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list