This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp5] Small testcase fix


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]