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

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Mon May 5 00:24:32 PDT 2025


  Branch: refs/heads/users/ergawy/do-pass-updates
  Home:   https://github.com/llvm/llvm-project
  Commit: bb9192c482e0c508e3be3ba8937e99cc54057415
      https://github.com/llvm/llvm-project/commit/bb9192c482e0c508e3be3ba8937e99cc54057415
  Author: Kareem Ergawy <kareem.ergawy at amd.com>
  Date:   2025-05-05 (Mon, 05 May 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
    M flang/test/Transforms/DoConcurrent/basic_host.f90
    M flang/test/Transforms/DoConcurrent/locally_destroyed_temp.f90
    M flang/test/Transforms/DoConcurrent/loop_nest_test.f90
    M flang/test/Transforms/DoConcurrent/multiple_iteration_ranges.f90
    M flang/test/Transforms/DoConcurrent/non_const_bounds.f90
    M flang/test/Transforms/DoConcurrent/not_perfectly_nested.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: 57c7fcf468e43dc64690301c264b31a3c36c54b3
      https://github.com/llvm/llvm-project/commit/57c7fcf468e43dc64690301c264b31a3c36c54b3
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-05-05 (Mon, 05 May 2025)

  Changed paths:
    M flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
    M flang/test/Transforms/DoConcurrent/basic_device.mlir
    M flang/test/Transforms/DoConcurrent/basic_host.f90
    M flang/test/Transforms/DoConcurrent/basic_host.mlir
    M flang/test/Transforms/DoConcurrent/locally_destroyed_temp.f90
    R flang/test/Transforms/DoConcurrent/loop_nest_test.f90
    M flang/test/Transforms/DoConcurrent/multiple_iteration_ranges.f90
    M flang/test/Transforms/DoConcurrent/non_const_bounds.f90
    M flang/test/Transforms/DoConcurrent/not_perfectly_nested.f90

  Log Message:
  -----------
  [flang][OpenMP] Update `do concurrent` mapping pass to use `fir.do_concurrent` op

This PR updates the `do concurrent` to OpenMP mapping pass to use the newly added `fir.do_concurrent` ops that were recently added upstream instead of handling nests of `fir.do_loop ... unordered` ops.

Parent PR: https://github.com/llvm/llvm-project/pull/137928.


Compare: https://github.com/llvm/llvm-project/compare/bb9192c482e0%5E...57c7fcf468e4

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