]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
omp-low.c (expand_omp_for_generic): If iter_type has different precision than type...
authorSteve Ellcey <sje@cup.hp.com>
Mon, 3 Nov 2008 21:47:44 +0000 (21:47 +0000)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 3 Nov 2008 21:47:44 +0000 (22:47 +0100)
* omp-low.c (expand_omp_for_generic): If iter_type has different
precision than type and type is a pointer type, cast n1 and n2
first to an integer type with the same precision as pointers
and only afterwards to iter_type.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r141563

gcc/ChangeLog
gcc/omp-low.c

index 61203031e481406ae17a572da7d9a7765cafd8b3..0d698b9948c3707e9e4335d6fbf2c79dcc7dc86e 100644 (file)
@@ -1,3 +1,11 @@
+2008-11-03  Steve Ellcey <sje@cup.hp.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       * omp-low.c (expand_omp_for_generic): If iter_type has different
+       precision than type and type is a pointer type, cast n1 and n2
+       first to an integer type with the same precision as pointers
+       and only afterwards to iter_type.
+
 2008-11-03  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * config/arm/arm.md (UNSPEC_PIC_BASE): Update documentation.
index 7d32f21781f2fb08cf27cace3f6b281ca7204d1e..8781418bd82007df4efb6cb9525c1fb2eaab047f 100644 (file)
@@ -3681,8 +3681,20 @@ expand_omp_for_generic (struct omp_region *region,
       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 (type), 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);