aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog.omp8
-rw-r--r--gcc/omp-expand.cc5
-rw-r--r--gcc/omp-general.cc29
3 files changed, 35 insertions, 7 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 1052b36..712473c 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,11 @@
+2021-03-01 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * omp-expand.cc (expand_oacc_for): Convert .tile variable to
+ diff_type before multiplying.
+ * omp-general.cc (omp_extract_for_data): Use accumulated precision
+ of all collapsed for-loops as precision of iteration variable, up
+ to the precision of a long long.
+
2021-02-26 Andrew Stubbs <ams@codesourcery.com>
* dwarf2out.cc (gen_subprogram_die): Replace existing low/high PC
diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc
index e113231..3160207 100644
--- a/gcc/omp-expand.cc
+++ b/gcc/omp-expand.cc
@@ -7702,7 +7702,10 @@ expand_oacc_for (struct omp_region *region, struct omp_for_data *fd)
tile_size = create_tmp_var (diff_type, ".tile_size");
expr = build_int_cst (diff_type, 1);
for (int ix = 0; ix < fd->collapse; ix++)
- expr = fold_build2 (MULT_EXPR, diff_type, counts[ix].tile, expr);
+ {
+ tree tile = fold_convert (diff_type, counts[ix].tile);
+ expr = fold_build2 (MULT_EXPR, diff_type, tile, expr);
+ }
expr = force_gimple_operand_gsi (&gsi, expr, true,
NULL_TREE, true, GSI_SAME_STMT);
ass = gimple_build_assign (tile_size, expr);
diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc
index a406c57..8c7dce2 100644
--- a/gcc/omp-general.cc
+++ b/gcc/omp-general.cc
@@ -375,6 +375,7 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
fd->non_rect = true;
}
}
+ int accum_iter_precision = 0;
for (i = 0; i < cnt; i++)
{
if (i == 0
@@ -457,12 +458,28 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
{
if (fd->collapse == 1 && !fd->tiling)
iter_type = TREE_TYPE (loop->v);
- else if (i == 0
- || TYPE_PRECISION (iter_type)
- < TYPE_PRECISION (TREE_TYPE (loop->v)))
- iter_type
- = build_nonstandard_integer_type
- (TYPE_PRECISION (TREE_TYPE (loop->v)), 1);
+ else
+ {
+ int loop_precision = TYPE_PRECISION (TREE_TYPE (loop->v));
+ int iter_type_precision = 0;
+ const int max_accum_precision
+ = TYPE_PRECISION (long_long_unsigned_type_node);
+
+ accum_iter_precision += loop_precision;
+
+ if (i == 0
+ || (loop_precision >= max_accum_precision
+ && loop_precision >= TYPE_PRECISION (iter_type)))
+ iter_type_precision = loop_precision;
+ else if (TYPE_PRECISION (iter_type) < max_accum_precision)
+ iter_type_precision
+ = MIN (1 << ceil_log2 (accum_iter_precision),
+ max_accum_precision);
+
+ if (iter_type_precision)
+ iter_type = build_nonstandard_integer_type
+ (iter_type_precision, 1);
+ }
}
else if (iter_type != long_long_unsigned_type_node)
{