+2019-02-21 Martin Jambor <mjambor@suse.cz>
+
+ PR hsa/89302
+ * omp-general.c (omp_extract_for_data): Removed a duplicate call
+ to omp_adjust_for_condition, moved NE_EXPR code_cond processing...
+ (omp_adjust_for_condition): ...here. Added necessary parameters.
+ * omp-general.h (omp_adjust_for_condition): Updated declaration.
+ * omp-grid.c (grid_attempt_target_gridification): Adjust to pass
+ proper values to new parameters of omp_adjust_for_condition.
+
2019-02-20 Jakub Jelinek <jakub@redhat.com>
PR middle-end/89412
return lang_hooks.decls.omp_privatize_by_reference (decl);
}
-/* Adjust *COND_CODE and *N2 so that the former is either LT_EXPR or
- GT_EXPR. */
+/* Adjust *COND_CODE and *N2 so that the former is either LT_EXPR or GT_EXPR,
+ given that V is the loop index variable and STEP is loop step. */
void
-omp_adjust_for_condition (location_t loc, enum tree_code *cond_code, tree *n2)
+omp_adjust_for_condition (location_t loc, enum tree_code *cond_code, tree *n2,
+ tree v, tree step)
{
switch (*cond_code)
{
case LT_EXPR:
case GT_EXPR:
+ break;
+
case NE_EXPR:
+ gcc_assert (TREE_CODE (step) == INTEGER_CST);
+ if (TREE_CODE (TREE_TYPE (v)) == INTEGER_TYPE)
+ {
+ if (integer_onep (step))
+ *cond_code = LT_EXPR;
+ else
+ {
+ gcc_assert (integer_minus_onep (step));
+ *cond_code = GT_EXPR;
+ }
+ }
+ else
+ {
+ tree unit = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (v)));
+ gcc_assert (TREE_CODE (unit) == INTEGER_CST);
+ if (tree_int_cst_equal (unit, step))
+ *cond_code = LT_EXPR;
+ else
+ {
+ gcc_assert (wi::neg (wi::to_widest (unit))
+ == wi::to_widest (step));
+ *cond_code = GT_EXPR;
+ }
+ }
+
break;
+
case LE_EXPR:
if (POINTER_TYPE_P (TREE_TYPE (*n2)))
*n2 = fold_build_pointer_plus_hwi_loc (loc, *n2, 1);
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);
+ omp_adjust_for_condition (loc, &loop->cond_code, &loop->n2, loop->v,
+ loop->step);
if (simd
|| (fd->sched_kind == OMP_CLAUSE_SCHEDULE_STATIC
extern tree omp_find_clause (tree clauses, enum omp_clause_code kind);
extern bool omp_is_reference (tree decl);
extern void omp_adjust_for_condition (location_t loc, enum tree_code *cond_code,
- tree *n2);
+ tree *n2, tree v, tree step);
extern tree omp_get_for_step_from_incr (location_t loc, tree incr);
extern void omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
struct omp_for_data_loop *loops);
push_gimplify_context ();
for (size_t i = 0; i < grid.collapse; i++)
{
- tree itype, type = TREE_TYPE (gimple_omp_for_index (inner_loop, i));
+ tree index_var = gimple_omp_for_index (inner_loop, i);
+ tree itype, type = TREE_TYPE (index_var);
if (POINTER_TYPE_P (type))
itype = signed_type_for (type);
else
walk_tree (&n1, grid_remap_prebody_decls, &wi, NULL);
tree n2 = unshare_expr (gimple_omp_for_final (inner_loop, i));
walk_tree (&n2, grid_remap_prebody_decls, &wi, NULL);
- omp_adjust_for_condition (loc, &cond_code, &n2);
+ tree step
+ = omp_get_for_step_from_incr (loc, gimple_omp_for_incr (inner_loop, i));
+ omp_adjust_for_condition (loc, &cond_code, &n2, index_var, step);
n1 = fold_convert (itype, n1);
n2 = fold_convert (itype, n2);
tree cond = fold_build2 (cond_code, boolean_type_node, n1, n2);
- tree step
- = omp_get_for_step_from_incr (loc, gimple_omp_for_incr (inner_loop, i));
tree t = build_int_cst (itype, (cond_code == LT_EXPR ? -1 : 1));
t = fold_build2 (PLUS_EXPR, itype, step, t);