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

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Wed Mar 26 21:48:37 PDT 2025


  Branch: refs/heads/users/ergawy/pft_to_do_concurrent
  Home:   https://github.com/llvm/llvm-project
  Commit: 837df80571ceda06bb82b6c139cb7c63cb9739fb
      https://github.com/llvm/llvm-project/commit/837df80571ceda06bb82b6c139cb7c63cb9739fb
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-03-26 (Wed, 26 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>
      }
    }
```


  Commit: 4cefbeacc323cd520e2af542b71909a35497ec6b
      https://github.com/llvm/llvm-project/commit/4cefbeacc323cd520e2af542b71909a35497ec6b
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-03-26 (Wed, 26 Mar 2025)

  Changed paths:
    M flang/lib/Lower/Bridge.cpp

  Log Message:
  -----------
  handle review comments


Compare: https://github.com/llvm/llvm-project/compare/252093c8ce9e...4cefbeacc323

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