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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] reduction on logical array causes LLVM IR type mismatch
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:openmp
      </td>
    </tr>

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

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

<pre>
    Reproducer:
https://godbolt.org/z/MM1hjbEjr
```f90
logical :: l1, l2(2)

!$omp parallel reduction (.and.:l1, l2)
l1 = .false.
l2(2) = .false.
!$omp end parallel
end
```

```console
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
Intrinsic has incorrect argument type!
ptr @llvm.memcpy.p0.i32.i32
Both operands to ICmp instruction are not of the same type!
  %28 = icmp ne ptr %1, i32 0
error: failed to create the LLVM module
Compiler returned: 1
```

With assertion-enabled flang, compiling the above reproducer results in the following assertion failure:
```txt
llvm-project/llvm/include/llvm/IR/Instructions.h:1182: void llvm::ICmpInst::AssertOK(): Assertion `getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"' failed.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVNFu6zYM_RrmhYgh03biPPjBbW6AYrfoUAy7z7LN2OpkyZDk9nZfP0hpm67b2wWSwFIOD8nDY0rv1WiYG6huoDpu5Bom65q_ttI5--I3nR1em0denB3Wnh0ULYh2CmHx8ZFOQKfRDp3VIbNuBDr9DXS6v8-np-7bkwPRwk5cPueDANFqO6peaozRRYs6B7pFTUA1AR0iXrRAOVBp5wUX6aTWrNHxsPZBWYNAdSbNkEHRXoNjoM4RiiNmZ6k9Z_HinfXL_ZWezfCRAkTLZvhc8Fsx78feGm81g2jPWppxS3ls4EU6o8wYHx8WNve_o1-XxbqAymACovLog9Ia-efCTs1sQhSgutn--HyztUtsEKojiPbOBKeMVz1O0qMyvXWO-4DSjWuEY3hdODYi2iU4hFJo_TxnM8_98potIlMFxS-I9saGCe3CTprBY7B4dzsvqIwP7k1S6RiNDWjPGCZGL2f-xI8IVFGdRFT9vKBhTDmpSvqrgjBqxc7Z6A88S6V5iJl6xzJwIv3-_c97nO2wJgVv7bwozQ4dh9UZHmJc_l_xf6gwofSeXSx0y0Z2kTrpGnP3iUeZMeWQnX1mdB9mRcd-1SHql_4_W63tS0R_UKZiV8cXX39kDz9DNJB-nreLs0_cB6BTPAKdlOn1OvD14u4x_lz19NkERZvnNcWunq0aMCGT46P4EXs5tamOh9-A6mjiosX2ozLYiZHDw2VwQLUAOmyh-DZy-CMNp36zdhzMv5D5_yNpB7RDIPo1RxAB7d-GnH0WbTM0xXAoDnLDTb6vRLWvy7zeTA11-1KUw35_3g-7at9RXfX9vpBVvaOzyOVGNSSoEjsisS93VZ2VhaxJlEVed9WZDiWUgmepdJZcbt24Ud6v3ORlRflho2XH2qcVRnQxR9Hahc28xHKr48Y1aZjdOvr4rigf_JUrqKDTAjyl0OoI1c3lZYbq-Gn1WIPv60s6J1-xl6tnf_H23WNSCGflZxn6abM63XxZlCpMa5f1dr6a54vHUlse6PTW2XND_wQAAP__ST7CwA">