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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP]Incorrect execution result when reduction-identifier(+) is used in REDUCTION clause during the reduction(-) operation
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 17.0.0(359f170f5f712ee714193b46bad45a45656b2c59)
```

Using the `reduction-identifier(+)` in the `REDUCTION` clause during a reduction(-) operation results in incorrect execution.

The result is correct when the test program is modified as follows:
- Before the change
```
 ia = ia-i
```
- After the change
```
         ia = ia+(-i)
```

z012.f90:
```fortran
      program main
 integer*4 ia
      integer*4 :: loop=10
      ia = 0
!$omp parallel do reduction(+:ia)
      do i=1, loop
         ia = ia-i
      end do
!$omp end parallel do
      write(*,*) "     ia=",ia,"  It must be -55"
      end
```

```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp z012.f90; ./a.out
      ia= 55   It must be -55
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp z012.f90; ./a.out
      ia=         -55   It must be -55
$
```

```
$ export OMP_NUM_THREADS=2; ifort -qopenmp z012.f90; ./a.out
      ia=         -55   It must be -55
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VVGPmzgQ_jXOywhkxkDwAw_J0uj2YbtVb_deKwMDcUUwZ5vb3v36k0nYZrftnk6qiiIijcfffPPNMKOc0_1IVLJsz7Jqo2Z_NLY0x9FE3edNbdq_S5bzy49XjO_-IOu0GcF00A1q7KORnoCJHSTbmMecYSEy2SVb3mXdNkGibZImUtRpXqs2zVSa5VleY5NJhvIM-SrC-f3o9NiDPxKwnFtq58ZrM0a6pdHrTpNlWDDcB5Ccgx5X14_vqsebh9v798HcDGp2BO1sA5iCZxyGRcRQgpnIqmAAS24evAtIemyMtdR4oC_UzOE4vqb2cKSLO2gHq-_Tkc4kPDkPkzW9VafgcDJtINyCctCZYTBPjokLVAR76oyl5WJzVGNP39UEtAImKtAq0t91iGDXebL_ibM-z3iLhkWk367GPzzBuJP8mfizV2est2q8hl9zPym92vXoqQ8126Uh5pXz9UlAFzsYjJmYqJIXnC-EV1aYMEzNaYJJWTUMNEBrXpQ35CV2IT95DdMa0AGb4c05zg9kWWU-m2lsoTWvQwfrVfjrC09We1pY7BjeLG8JDPEShImKITK8CfxuFvuth9PsPNQEUZaF05fx3yjOayOmQF8mYz3c33349P7x7tPDbx_f7arfmaiQif3Vhxt1ZqLxNMHXAu8hZnhQsZn9S_2DMFkG31Bdg_5Mhv2lrf43wfWJfhVTHZhC9OevorlpS9FKIdWGyiSXfFuIQiabY8llW9SZkkWbyFrWNUeVJqlE2TRcdXmx0SVyFHwrEp4niUhivt3KJhFpUmORtmnLUk4npYd4GP46xcb2G-3cTGWeYpptBlXT4JZNgXjO9tzDDHFpKCZ2nTWjD82KGNaJLQNSVM-9YykftPPuK7bXflgWz2G5nFUs299PNN59YFl1--0IXkfuMmffXAhh6M6O2jDLn9fBq13glxn-o22wme1QHr2flkmNB4aHXvvjXMeNOTE8hCQuf9FkzWdqPMPDopZjeFgE-zcAAP__J8YJVw">