I am looking at a couple of libgomp failures on IA64 HP-UX and I am pretty sure what the problem is and that it is in omp-low.c but I am not sure exactly where in omp-low.c it is.
The tests (libgomp.c/loop-5.c and libgomp.c++/loop-8.C) only fail in 32 bit mode on IA64 HP-UX where we use the addp4 instruction to extend pointers. I think only these two fail because they are they only ones to use negative indexes (see the simplified test case at the end of this email). The problem is in the call to GOMP_loop_ull_dynamic_start and in the 'end' argument to that routine. In the OMP library the 'start' and 'end' arguments are defined to be type gomp_ull (unsigned long long) but seem to actually contain pointers. When I look at the code generated by GCC the argument 'start' is being extended from 32 to 64 bits correctly (via the ptr_extend unspec 24 in instruction 42 below) but the argument 'end' is being extended by a zero_extend (instruction 45 below), which is wrong because it is really a pointer and should be extended via the unspec like 'start' is.. Some where in omp-low.c I think I need to make a POINTER_PLUS_EXPR instead of a PLUS_EXPR but I am not sure where I need to do that. Can someone point me to the right place? Where are the arguments (and particulary the 'end' argument) to GOMP_loop_ull_dynamic_start generated? ----- >From x.c.128r.expand: ;; D.3075 = __builtin_GOMP_loop_ull_dynamic_start (1, (long long unsigned int) &(*D.3067)[3], (long long unsigned int) (&(*D.3067)[63] + 1), 8, 3, &.istart0.3, &.iend0.4); (insn 41 40 42 x.c:14 (set (reg:SI 379) (plus:SI (subreg/s/v:SI (reg/f:DI 375 [ D.3067+-4 ]) 4) (const_int 12 [0xc]))) -1 (nil)) (insn 42 41 43 x.c:14 (set (reg:DI 380) (unspec:DI [ (reg:SI 379) ] 24)) -1 (nil)) (insn 43 42 44 x.c:14 (set (reg:SI 381) (plus:SI (subreg/s/v:SI (reg/f:DI 375 [ D.3067+-4 ]) 4) (const_int 252 [0xfc]))) -1 (nil)) (insn 44 43 45 x.c:14 (set (reg:SI 382) (plus:SI (reg:SI 381) (const_int 1 [0x1]))) -1 (nil)) (insn 45 44 46 x.c:14 (set (reg:DI 383) (zero_extend:DI (reg:SI 382))) -1 (nil)) ===================== Test case: #include <omp.h> #include <stdlib.h> #include <string.h> int test3 (void) { int buf[64], *p; int i; memset (buf, '\0', sizeof (buf)); #pragma omp parallel for schedule (dynamic, 3) for (p = &buf[3]; p <= &buf[63]; p += 2) p[-2] = 6; for (i = 0; i < 64; i++) if (buf[i] != 6 * ((i & 1) && i <= 61)) abort (); return 0; } int main (void) { test3 (); return 0; }