This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp5] Small testcase fix
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 18 Oct 2018 20:44:28 +0200
- Subject: [gomp5] Small testcase fix
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
I've realized there is UB in this testcase, because taskloop simd
non-collapsed iterator is linear on simd, which implies lastprivate on
taskloop, but with nogroup the last iteration's value might be stored
when bar is out of scope already.
Fixed by declaring it in the construct, then nothing is written anywhere
(other possibility would be private (i)).
2018-10-18 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c-c++-common/taskloop-reduction-3.c (bar): Define
iterator inside of the construct.
--- libgomp/testsuite/libgomp.c-c++-common/taskloop-reduction-3.c.jj 2018-10-18 13:49:18.531282016 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/taskloop-reduction-3.c 2018-10-18 20:38:55.501725608 +0200
@@ -19,9 +19,8 @@ foo (void)
__attribute__((noipa)) void
bar (int x)
{
- int i;
#pragma omp taskloop simd in_reduction (+:n) grainsize (64) nogroup
- for (i = (x & 1) * (N / 2); i < (x & 1) * (N / 2) + (N / 2); i++)
+ for (int i = (x & 1) * (N / 2); i < (x & 1) * (N / 2) + (N / 2); i++)
n += 2 * u[i];
}
Jakub