[Bug libgomp/81778] libgomp.c/for-5.c failure on nvptx -- illegal memory access
vries at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 18 09:26:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81778
--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
A point fix could look like:
...
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 3990998..2439a89 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -4339,6 +4339,26 @@ expand_omp_for_static_chunk (struct omp_region *region,
L2:
V -= STEP * (simt_vf - 1)
+ fix could be:
+
+ V = N1 + simt_lane * STEP; // Can this overflow?
+ goto L1;
+ L0:
+ BODY;
+ if (overflow (V += STEP * simt_vf)) goto Loverflow; else goto Lincr;
+ // STEP > 0: if (STEP * simt_vf > max (type (V)) - V)
+ // STEP < 0: if (V < min (type (V)) - STEP * simt_vf)
+ Lincr:
+ V += STEP * simt_vf;
+ L1:
+ if (V cond N2) goto L0; else goto L2;
+ Loverflow:
+ V += STEP;
+ goto Lend;
+ L2:
+ V -= STEP * (simt_vf - 1)
+ Lend:
+
For collapsed loops, given parameters:
collapse(3)
for (V1 = N11; V1 cond1 N12; V1 += STEP1)
...
More information about the Gcc-bugs
mailing list