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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Generate reduction operation for MAX intrinsic reduction
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          kavitha-natarajan
      </td>
    </tr>
</table>

<pre>
    Flang does not generate reduction operation for OpenMP MAX intrinsic reduction when the reduction is implemented in the following way:

!$omp parallel
!$omp do reduction(max:x)
do i=1, 100
  if (y(i) .gt. x) x = y(i)
end do
!$omp end do
!$omp end parallel

Currently, flang generates reduction operation for the below implementation only:

!$omp parallel
!$omp do reduction(max:x)
do i=1, 100
 x = max(y(i), x)
end do
!$omp end do
!$omp end parallel

Refer test case flang/test/Lower/OpenMP/wsloop-reduction-max.f90 and update this testcase to test reduction operation generation for the above first case as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8k01vnDwQxz-NuYwWgb0QOHBIsuK5PFGrnnod8ABOjY1sE3a_fQVku1HUVS9VLwaN__P28wx6r3pDVLHsiWWnCOcwWFf9wDcVBjwYDOjwFU3UWHmpao2mB2nJg7EBejLkMBA4knMblDVgp9Wy_nXWwZeJzMtXeHn8DsoEp4xX7QfxMpCBMHz0Vx7UOGkayQSSoPb7zmptF2V6WPDCxCNLTiy5njxl_GjHCSZ0qDXpz3ZpbwkYL0Y8M_F4ZrzchdKCYuKUMv4MaZLsRgDVAePFhfFCMV5C3IcYVic4AxMnuF7scjISpP2c-L71U6nb-Tw7Ryboy1pIt5G-AvZ3Ca90GtJ2uWHbL63R_4jUzmPV3nCtivNfpfONOnIQyAdo0dMOiPF6tTBe_28XcozX-8QxXi9eWzsdfrVzGPEcd2UCaCTMk1zHNgzKbyG3iMHu4X-H-v0hPlLHxr4RdMpdK0IPC2kdR7ISshQlRlSleZGk6VHkIhqqrjhiIbHNeZc-JCnPH1LkbUqt4KmQRRapiidcJIKXacHzRMTFUcomQ1EWostknrFjQiMqHWv9NsbW9ZHyfqYqT4ukiDQ2pP11k121ig7N3Ht2TLTywd_cggp62_lto1l2YtnTO7rsBP_9aa_vLHQ0O10NIUx-nTxeM173KgxzE7d2ZLxe079_DpOzr9SuT7e14Bmvty5-BgAA__87hXOn">