<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55236>55236</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] 'omp unroll partial' loop generates too many iterations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
openmp,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mikerice1969
</td>
</tr>
</table>
<pre>
In the following test the loop executes one more time than expected:
```
void unroll_partial_remainder(int *A)
{
#pragma omp parallel for
#pragma omp unroll partial(4)
for (int i = 0; i < 12; ++i)
A[i] = i;
}
#include <stdio.h>
#include <assert.h>
int main() {
int A[24];
for(int i = 0; i<24; i++){ A[i]=0; }
// write 12 elements 0 thru 11.
unroll_partial_remainder(A);
// Off by one?
assert(A[12] == 0);
return 0;
}
```
$ clang -fopenmp -fopenmp-version=51 u.c && ./a.out
a.out: u.c:21: int main(): Assertion `A[12] == 0' failed.
Aborted (core dumped)
$ clang --version
clang version 15.0.0 (git@github.com:llvm/llvm-project ef87865b98fa25af1d2c045bab1268b2a1503374)
Target: x86_64-unknown-linux-gnu
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9VEuPmzAQ_jXOxQoydkzgwCFpulIP1fbQ-8rAQNwaGxmzj3_fsUnS3VVaZJnBM575vnnQuO6t_mZpOAPtnTHuRduBBphDOjLOTRReoV3wiDoLdHQeaNAjbmdlUTdBG6Aj4kDYibDrXrDLSp_PTnd0sR4DPE3KB63Mk4dRaduBJ7zUNlDCDwfCq8v9_XEVKD6Ei8mrYVTUjRPF-8oYMAjX_8tmDUUvoTDA7uY5GuNNeomqKREnyog4JvELzXmUCT_i0h9uxedAJJ7KU7ql0fIK9_SBPRfatmbpILqcQ6dddibi6z2tmmfw4b067RFbzA_CRBD0lo8rnKiPYPgO0dxwJGp3mGEcNExSIhZ57Y83NmiY7D7RiFl9wEVfvA6AmaFgYAQbZsqw-n6heZ5dTf9T3VRWcbzr-rHvafMWO4uIh6tuzUm6KY9YkDXfK507rjyExdtE9XM5PrYh4TvaGoUNvu3dBBY75Spsn8HP2lkMInO6ZC0CLHDRDFGqzC1hdbGK4hBN8MXzKH8sVjw5JAboj2Lweyz2tFfaQHfJ36FxHqcodmUbB6xbxgmH6jYOn-Hf4CbFeng5ornMWMaiq0EHsmO4n5cma92IyIx5HpFRfG0n737h8FLoy31ZyKYqe8Wl6vOOt2wnG9XkvCgbrnLJhNj_naGfyg-QsvBaFk_FbrvY39a92K3RdnndDnZ5D3vT1aKrRKU2QQcDNWbjEXP-_UfKCN_fG9j9-ucZwIJX8dcTnMMU2zeKnYgnyHPeLN7U5xCmOf58Uju9o7py_EQVP_U8LzCjICUXxeZc80K0SjRVLsqqLLtWMtmUZVPti1wJUYqNUQ2YOcImnK_dggLhXxA8T6nH-L13NoDtokaeNrrmjHMmccs5Y1UmWQ4Vw0jlrillB1iXOCEmi_Ay54eNrxPSZhlmVBo9h_mvEidCDxZS8qJ_tYSz8_Wof4PXLeRVUW0SszrR-gP6sKuu">