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]

Re: [Patch, omp] Patch to omp-low.c to fix failures on IA64 HP-UX


On Thu, Oct 30, 2008 at 03:02:38PM -0700, Steve Ellcey wrote:
> Tested on IA64 HP-UX and Linux with no regressions.

Using long_unsigned_type_node in this case is wrong, that may be correct for
IA-64 32-bit HPUX, but not generally.  The reason why iter_type in omp-low.c
is either long_integer_type_node, or long_long_unsigned_type_node is that
those are the types of the iterators in libgomp (for signed and unsigned
loops).  But in this case you want to cast to an integer with the same
precision as the pointer.

So IMHO you want something like this instead.  type_for_size langhook
might not be best for LTO SSA expansion, but it is ATM used all around
omp expansion, so we can use it here too for now and when LTO needs it, switch to
build_nonstandard_integer_type or something better (ideally something that
caches the types rather than creating a new one each time).
Can you test it on HPUX?

--- gcc/omp-low.c.jj	2008-09-30 16:57:11.000000000 +0200
+++ gcc/omp-low.c	2008-10-31 13:03:00.000000000 +0100
@@ -3681,8 +3681,20 @@ expand_omp_for_generic (struct omp_regio
       t4 = build_fold_addr_expr (iend0);
       t3 = build_fold_addr_expr (istart0);
       t2 = fold_convert (fd->iter_type, fd->loop.step);
-      t1 = fold_convert (fd->iter_type, fd->loop.n2);
-      t0 = fold_convert (fd->iter_type, fd->loop.n1);
+      if (POINTER_TYPE_P (type)
+	  && TYPE_PRECISION (type) != TYPE_PRECISION (fd->iter_type))
+	{
+	  /* Avoid casting pointers to integer of a different size.  */
+	  tree itype
+	    = lang_hooks.types.type_for_size (TYPE_PRECISION (itype), 0);
+	  t1 = fold_convert (fd->iter_type, fold_convert (itype, fd->loop.n2));
+	  t0 = fold_convert (fd->iter_type, fold_convert (itype, fd->loop.n1));
+	}
+      else
+	{
+	  t1 = fold_convert (fd->iter_type, fd->loop.n2);
+	  t0 = fold_convert (fd->iter_type, fd->loop.n1);
+	}
       if (bias)
 	{
 	  t1 = fold_build2 (PLUS_EXPR, fd->iter_type, t1, bias);

	Jakub


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