aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-expand.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-07-15 16:34:54 +0200
committerJakub Jelinek <jakub@redhat.com>2020-07-15 16:45:02 +0200
commit79c12969ec3e9185fdbb90d3b1699d64b1cd0901 (patch)
treeaec0feded362940cca6749ea627409f3e9fcc89f /gcc/omp-expand.c
parent765fbbf9bb398560f45987ea9858dfaaefff5ce0 (diff)
downloadgcc-79c12969ec3e9185fdbb90d3b1699d64b1cd0901.zip
gcc-79c12969ec3e9185fdbb90d3b1699d64b1cd0901.tar.gz
gcc-79c12969ec3e9185fdbb90d3b1699d64b1cd0901.tar.bz2
openmp: Fix up loop-21.c
I've missed +FAIL: libgomp.c/loop-21.c execution test during testing of the recent patch. The problem is that while for the number of iterations computation it doesn't matter if we compute min_inner_iterations as (m2 * first + n2 + (adjusted step) + m1 * first + n1) / step or (m2 * last + n2 + (adjusted step) + m1 * last + n1) / step provided that in the second case we use as factor (m1 - m2) * ostep / step rather than (m2 - m1) * ostep / step, for the logical to actual iterator values computation it does matter and in my hand written C implementations of all the cases (outer vs. inner loop with increasing vs. decreasing iterator) I'm using the same computation and it worked well for all the pseudo-random iterators testing it was doing. It also means min_inner_iterations is misnamed, because it is not really minimum number of inner iterations, whether the first or last outer iteration results in the smaller or larger value of this can be (sometimes) only determined at runtime. So this patch also renames it to first_inner_iterations. 2020-07-15 Jakub Jelinek <jakub@redhat.com> PR libgomp/96198 * omp-general.h (struct omp_for_data): Rename min_inner_iterations member to first_inner_iterations, adjust comment. * omp-general.c (omp_extract_for_data): Adjust for the above change. Always use n1first and n2first to compute it, rather than depending on single_nonrect_cond_code. Similarly, always compute factor as (m2 - m1) * outer_step / inner_step rather than sometimes m1 - m2 depending on single_nonrect_cond_code. * omp-expand.c (expand_omp_for_init_vars): Rename min_inner_iterations to first_inner_iterations and min_inner_iterationsd to first_inner_iterationsd.
Diffstat (limited to 'gcc/omp-expand.c')
-rw-r--r--gcc/omp-expand.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index a721940..ee354b7 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -2264,7 +2264,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
{
tree outer_n1 = fd->adjn1 ? fd->adjn1 : fd->loops[i - 1].n1;
tree itype = TREE_TYPE (fd->loops[i].v);
- tree min_inner_iterations = fd->min_inner_iterations;
+ tree first_inner_iterations = fd->first_inner_iterations;
tree factor = fd->factor;
gcond *cond_stmt
= gimple_build_cond (NE_EXPR, factor,
@@ -2282,21 +2282,21 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
stopvalull
= force_gimple_operand_gsi (gsi, stopvalull, true, NULL_TREE,
false, GSI_CONTINUE_LINKING);
- min_inner_iterations
- = fold_convert (slltype, min_inner_iterations);
- min_inner_iterations
- = force_gimple_operand_gsi (gsi, min_inner_iterations, true,
+ first_inner_iterations
+ = fold_convert (slltype, first_inner_iterations);
+ first_inner_iterations
+ = force_gimple_operand_gsi (gsi, first_inner_iterations, true,
NULL_TREE, false,
GSI_CONTINUE_LINKING);
factor = fold_convert (slltype, factor);
factor
= force_gimple_operand_gsi (gsi, factor, true, NULL_TREE,
false, GSI_CONTINUE_LINKING);
- tree min_inner_iterationsd
+ tree first_inner_iterationsd
= fold_build1 (FLOAT_EXPR, double_type_node,
- min_inner_iterations);
- min_inner_iterationsd
- = force_gimple_operand_gsi (gsi, min_inner_iterationsd, true,
+ first_inner_iterations);
+ first_inner_iterationsd
+ = force_gimple_operand_gsi (gsi, first_inner_iterationsd, true,
NULL_TREE, false,
GSI_CONTINUE_LINKING);
tree factord = fold_build1 (FLOAT_EXPR, double_type_node,
@@ -2318,7 +2318,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
t = fold_build2 (RDIV_EXPR, double_type_node, factord,
build_real (double_type_node, dconst2));
tree t3 = fold_build2 (MINUS_EXPR, double_type_node,
- min_inner_iterationsd, t);
+ first_inner_iterationsd, t);
t3 = force_gimple_operand_gsi (gsi, t3, true, NULL_TREE, false,
GSI_CONTINUE_LINKING);
t = fold_build2 (MULT_EXPR, double_type_node, factord,
@@ -2356,12 +2356,12 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
t = fold_build2 (RSHIFT_EXPR, ulltype, t, integer_one_node);
t = fold_build2 (MULT_EXPR, ulltype, fd->factor, t);
tree t2 = fold_build2 (MULT_EXPR, ulltype, c,
- fd->min_inner_iterations);
+ fd->first_inner_iterations);
t = fold_build2 (PLUS_EXPR, ulltype, t, t2);
expand_omp_build_assign (gsi, d, t, true);
t = fold_build2 (MULT_EXPR, ulltype, fd->factor, c);
t = fold_build2 (PLUS_EXPR, ulltype,
- t, fd->min_inner_iterations);
+ t, fd->first_inner_iterations);
t2 = force_gimple_operand_gsi (gsi, t, true, NULL_TREE, false,
GSI_CONTINUE_LINKING);
cond_stmt = gimple_build_cond (GE_EXPR, stopvalull, d,