summaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-11-03 21:47:44 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-11-03 21:47:44 +0000
commitc799f23307827fd8623b8d64d0130fd6e7219db8 (patch)
tree1d03e93415ed3811152d3b5d8fc4317b7d1913cc /gcc/omp-low.c
parentc0c1fba5a9c359f7c6e4c6a7f5a1b33aa723c7e1 (diff)
downloadgcc-c799f23307827fd8623b8d64d0130fd6e7219db8.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141563 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 7d32f21781f..8781418bd82 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -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);