aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-general.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/omp-general.c')
-rw-r--r--gcc/omp-general.c86
1 files changed, 62 insertions, 24 deletions
diff --git a/gcc/omp-general.c b/gcc/omp-general.c
index cabbbbc..99d8226 100644
--- a/gcc/omp-general.c
+++ b/gcc/omp-general.c
@@ -36,6 +36,8 @@ along with GCC; see the file COPYING3. If not see
#include "stringpool.h"
#include "attribs.h"
+enum omp_requires omp_requires_mask;
+
tree
omp_find_clause (tree clauses, enum omp_clause_code kind)
{
@@ -136,6 +138,7 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
fd->pre = NULL;
fd->have_nowait = distribute || simd;
fd->have_ordered = false;
+ fd->have_reductemp = false;
fd->tiling = NULL_TREE;
fd->collapse = 1;
fd->ordered = 0;
@@ -186,6 +189,8 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
collapse_iter = &OMP_CLAUSE_TILE_ITERVAR (t);
collapse_count = &OMP_CLAUSE_TILE_COUNT (t);
break;
+ case OMP_CLAUSE__REDUCTEMP_:
+ fd->have_reductemp = true;
default:
break;
}
@@ -250,13 +255,45 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
loop->cond_code = gimple_omp_for_cond (for_stmt, i);
loop->n2 = gimple_omp_for_final (for_stmt, i);
- gcc_assert (loop->cond_code != NE_EXPR);
+ gcc_assert (loop->cond_code != NE_EXPR
+ || (gimple_omp_for_kind (for_stmt)
+ != GF_OMP_FOR_KIND_OACC_LOOP));
omp_adjust_for_condition (loc, &loop->cond_code, &loop->n2);
t = gimple_omp_for_incr (for_stmt, i);
gcc_assert (TREE_OPERAND (t, 0) == var);
loop->step = omp_get_for_step_from_incr (loc, t);
+ if (loop->cond_code == NE_EXPR)
+ {
+ gcc_assert (TREE_CODE (loop->step) == INTEGER_CST);
+ if (TREE_CODE (TREE_TYPE (loop->v)) == INTEGER_TYPE)
+ {
+ if (integer_onep (loop->step))
+ loop->cond_code = LT_EXPR;
+ else
+ {
+ gcc_assert (integer_minus_onep (loop->step));
+ loop->cond_code = GT_EXPR;
+ }
+ }
+ else
+ {
+ tree unit = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (loop->v)));
+ gcc_assert (TREE_CODE (unit) == INTEGER_CST);
+ if (tree_int_cst_equal (unit, loop->step))
+ loop->cond_code = LT_EXPR;
+ else
+ {
+ gcc_assert (wi::neg (wi::to_widest (unit))
+ == wi::to_widest (loop->step));
+ loop->cond_code = GT_EXPR;
+ }
+ }
+ }
+
+ omp_adjust_for_condition (loc, &loop->cond_code, &loop->n2);
+
if (simd
|| (fd->sched_kind == OMP_CLAUSE_SCHEDULE_STATIC
&& !fd->have_ordered))
@@ -281,9 +318,8 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
tree n;
if (loop->cond_code == LT_EXPR)
- n = fold_build2_loc (loc,
- PLUS_EXPR, TREE_TYPE (loop->v),
- loop->n2, loop->step);
+ n = fold_build2_loc (loc, PLUS_EXPR, TREE_TYPE (loop->v),
+ loop->n2, loop->step);
else
n = loop->n1;
if (TREE_CODE (n) != INTEGER_CST
@@ -298,15 +334,13 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
if (loop->cond_code == LT_EXPR)
{
n1 = loop->n1;
- n2 = fold_build2_loc (loc,
- PLUS_EXPR, TREE_TYPE (loop->v),
- loop->n2, loop->step);
+ n2 = fold_build2_loc (loc, PLUS_EXPR, TREE_TYPE (loop->v),
+ loop->n2, loop->step);
}
else
{
- n1 = fold_build2_loc (loc,
- MINUS_EXPR, TREE_TYPE (loop->v),
- loop->n2, loop->step);
+ n1 = fold_build2_loc (loc, MINUS_EXPR, TREE_TYPE (loop->v),
+ loop->n2, loop->step);
n2 = loop->n1;
}
if (TREE_CODE (n1) != INTEGER_CST
@@ -338,27 +372,31 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
if (POINTER_TYPE_P (itype))
itype = signed_type_for (itype);
t = build_int_cst (itype, (loop->cond_code == LT_EXPR ? -1 : 1));
- t = fold_build2_loc (loc,
- PLUS_EXPR, itype,
- fold_convert_loc (loc, itype, loop->step), t);
+ t = fold_build2_loc (loc, PLUS_EXPR, itype,
+ fold_convert_loc (loc, itype, loop->step),
+ t);
t = fold_build2_loc (loc, PLUS_EXPR, itype, t,
- fold_convert_loc (loc, itype, loop->n2));
+ fold_convert_loc (loc, itype, loop->n2));
t = fold_build2_loc (loc, MINUS_EXPR, itype, t,
- fold_convert_loc (loc, itype, loop->n1));
+ fold_convert_loc (loc, itype, loop->n1));
if (TYPE_UNSIGNED (itype) && loop->cond_code == GT_EXPR)
- t = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype,
- fold_build1_loc (loc, NEGATE_EXPR, itype, t),
- fold_build1_loc (loc, NEGATE_EXPR, itype,
- fold_convert_loc (loc, itype,
- loop->step)));
+ {
+ tree step = fold_convert_loc (loc, itype, loop->step);
+ t = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype,
+ fold_build1_loc (loc, NEGATE_EXPR,
+ itype, t),
+ fold_build1_loc (loc, NEGATE_EXPR,
+ itype, step));
+ }
else
t = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype, t,
- fold_convert_loc (loc, itype, loop->step));
+ fold_convert_loc (loc, itype,
+ loop->step));
t = fold_convert_loc (loc, long_long_unsigned_type_node, t);
if (count != NULL_TREE)
- count = fold_build2_loc (loc,
- MULT_EXPR, long_long_unsigned_type_node,
- count, t);
+ count = fold_build2_loc (loc, MULT_EXPR,
+ long_long_unsigned_type_node,
+ count, t);
else
count = t;
if (TREE_CODE (count) != INTEGER_CST)