<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62826>62826</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] [OpenMP] Assertion `redType.isIntOrIndexOrFloat() && "Unsupported reduction type"' failed
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    An assertion failure is hit. I will provide the source-level reproducer and the version information.

Assertion
```
OpenMP.cpp:1664: void genOMP(Fortran::lower::AbstractConverter &, Fortran::lower::pft::Evaluation &, const Fortran::parser::OpenMPLoopConstruct &): Assertion `redType.isIntOrIndexOrFloat() && "Unsupported reduction type"' failed.
```

Reproducer
```console
$ cat test.f90
program test
   integer :: i
   integer, dimension(1:5) :: a, b
   a = 1
 print *, a
!$omp parallel
!$omp do reduction(max: a) private (b)
 do i = 1, 5
     b = (/ i, i + 1, i + 2 , i + 3 , i + 4 /)
     a = max(a, b(i))
   end do
!$omp end do
!$omp end parallel
   print *, a
end program
```

Version
```console
$ flang-new --version
flang-new version 17.0.0 (https://github.com/llvm/llvm-project.git e335e8a43287b8258c719d7a21c4264b0550c554)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```

With the old flang-new (llvm-16.0.3), the following TODO message is output.
```
OpenMP.cpp:1180: not yet implemented: Reduction of intrinsic procedures is not supported
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU2P4ygQ_TXkUoplg79yyMHdvZFa2lFGo97d4wqbisMOBgQ46f73K3CS_lDPrPYwUuTg4j2q6hVV5t7LUSNuSXVHqocVn8PRuO33NXfOnP2qN-Jl22ng3qML0mg4cKlmhyA9HGXI4BHOUimwzpykQAhHBG9mN-Ba4QkVOLTOiHlAB1yLtH9C5-NRUh-Mm3g8NiP5A8m75dldnV2Md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