Page MenuHomePhabricator

[Flang][OpenMP] Fix conversion to LLVM IR for Fortran code with OpenMP SIMD directive and nested loop

Authored by domada on Aug 8 2022, 8:19 AM.



Flang cannot convert to LLVM IR the following Fortran code:

subroutine simdloop_with_nested_loop
integer :: i, j
integer :: a(10)
  do i=1, 10
   do j=1, 10
     a(i) = i
    end do
  end do
end subroutine

bin/bbc simdloop_with_nested_loop.f90 -fopenmp -emit-fir -o - | bin/tco
Fails with the error message:
loc("<stdin>":16:10): error: failed to legalize operation ''

This patch enables compilation of the test case with SIMD directive and nested loop.

Diff Detail

Event Timeline

domada created this revision.Aug 8 2022, 8:19 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
domada requested review of this revision.Aug 8 2022, 8:19 AM
peixin requested changes to this revision.Aug 9 2022, 2:17 AM
peixin added inline comments.
4 ↗(On Diff #450809)

This is not expected. You should add the test in flang/test/Fir/convert-to-llvm-openmp-and-fir.fir.


SectionsOp is already there. Why do you add it repeatedly?

This revision now requires changes to proceed.Aug 9 2022, 2:17 AM
peixin edited reviewers, added: arnamoy10; removed: Restricted Project.Aug 9 2022, 2:19 AM
peixin removed a project: Restricted Project.
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 2:19 AM
domada updated this revision to Diff 451100.Aug 9 2022, 4:19 AM

Scope of changes:

  1. moved test from flang/test/Lower/OpenMP/simd.f90 to flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
  2. removed duplicated addition of SectionsOp in populateOpenMPToLLVMConversionPatterns function
domada marked 2 inline comments as done.Aug 9 2022, 4:20 AM
domada added inline comments.

Copy-paste error.

domada marked an inline comment as done.Aug 9 2022, 4:42 AM
peixin accepted this revision.Aug 9 2022, 6:05 PM

LGTM. Please enable the CI passed before landing this patch. It seems the build bot stuck.

This revision is now accepted and ready to land.Aug 9 2022, 6:05 PM

Changes to MLIR code should ideally be tested with MLIR tree dialect tests. The test for this code should have been in