Hi! On Thu, Nov 10, 2016 at 06:44:52PM +0800, Chung-Lin Tang wrote:
Above this it is fine. > @@ -9388,10 +9373,23 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) > (OMP_FOR_INIT (for_stmt)) > * 2); > } > - int collapse = 1; > - c = find_omp_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_COLLAPSE); > - if (c) > - collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); > + int collapse = 0; > + /* Find the first of COLLAPSE or TILE. */ > + for (c = OMP_FOR_CLAUSES (for_stmt); c; c = TREE_CHAIN (c)) > + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_COLLAPSE) > + { > + collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); > + if (collapse == 1) > + /* Not really collapsing. */ > + collapse = 0; > + break; > + } > + else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TILE) > + { > + collapse = list_length (OMP_CLAUSE_TILE_LIST (c)); > + break; > + } I don't really like this, especially pretending collapse(1) or lack of collapse clause e.g. on OpenMP construct is collapse(0). I'd keep what it does, i.e. int collapse = 1; c = find_omp_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_COLLAPSE); if (c) collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); and in the first switch in gimplify_omp_for you can: case OACC_LOOP: ort = ORT_ACC; c = find_omp_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_TILE); if (c) tile = list_length (OMP_CLAUSE_TILE_LIST (c)); break; and then just use tile != 0 or whatever || with collapse > 1 where needed. > + > for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)); i++) > { > t = TREE_VEC_ELT (OMP_FOR_INIT (for_stmt), i); > @@ -9807,7 +9805,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) > OMP_CLAUSE_LINEAR_STEP (c2) = OMP_CLAUSE_LINEAR_STEP (c); > } > > - if ((var != decl || collapse > 1) && orig_for_stmt == for_stmt) > + if ((var != decl || collapse) && orig_for_stmt == for_stmt) > { > for (c = OMP_FOR_CLAUSES (for_stmt); c ; c = OMP_CLAUSE_CHAIN (c)) > if (((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE Like here. > @@ -9817,7 +9815,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) > && OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c) == NULL)) > && OMP_CLAUSE_DECL (c) == decl) > { > - if (is_doacross && (collapse == 1 || i >= collapse)) > + if (is_doacross && (!collapse || i >= collapse)) > t = var; > else > { And not here. You don't really have doacross loops in OpenACC, do you? Jakub