aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-11-05 16:08:08 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-11-05 16:08:08 +0100
commite01d41e553aae24572da3a067347a5f2c02cd620 (patch)
tree88a0767ea20a49ed4ad6baaa5116b7f228580c68 /gcc/c-family
parentbd7519757549bb0f61433767be4587d1d287fbae (diff)
downloadgcc-e01d41e553aae24572da3a067347a5f2c02cd620.zip
gcc-e01d41e553aae24572da3a067347a5f2c02cd620.tar.gz
gcc-e01d41e553aae24572da3a067347a5f2c02cd620.tar.bz2
gcc/
2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * builtin-types.def (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR): Remove. (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): New. * cgraph.h (enum cgraph_simd_clone_arg_type): Add SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP, SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP and SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP. (struct cgraph_simd_clone_arg): Adjust comment. * omp-builtins.def (BUILT_IN_GOMP_TARGET): Rename GOMP_target_41 to GOMP_target_ext. Add num_teams and thread_limit arguments. (BUILT_IN_GOMP_TARGET_DATA): Rename GOMP_target_data_41 to GOMP_target_data_ext. (BUILT_IN_GOMP_TARGET_UPDATE): Rename GOMP_target_update_41 to GOMP_target_update_ext. (BUILT_IN_GOMP_LOOP_NONMONOTONIC_DYNAMIC_START, BUILT_IN_GOMP_LOOP_NONMONOTONIC_GUIDED_START, BUILT_IN_GOMP_LOOP_NONMONOTONIC_DYNAMIC_NEXT, BUILT_IN_GOMP_LOOP_NONMONOTONIC_GUIDED_NEXT, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_START, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_START, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_NEXT, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_NEXT, BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC, BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_GUIDED): New built-ins. * tree-core.h (enum omp_clause_schedule_kind): Add OMP_CLAUSE_SCHEDULE_MASK, OMP_CLAUSE_SCHEDULE_MONOTONIC, OMP_CLAUSE_SCHEDULE_NONMONOTONIC and change OMP_CLAUSE_SCHEDULE_LAST value. * tree.def (OMP_SIMD, CILK_SIMD, CILK_FOR, OMP_DISTRIBUTE, OMP_TASKLOOP, OACC_LOOP): Add OMP_FOR_ORIG_DECLS argument. * tree.h (OMP_FOR_ORIG_DECLS): Use OMP_LOOP_CHECK instead of OMP_FOR_CHECK. Remove comment. * tree-pretty-print.c (dump_omp_clause): Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE and GOMP_MAP_ALWAYS_POINTER. Simplify. Print schedule clause modifiers. * tree-vect-stmts.c (vectorizable_simd_clone_call): Add SIMD_CLONE_ARG_TYPE_LINEAR_{REF,VAL,UVAL}_VARIABLE_STEP cases. * gimplify.c (enum gimplify_omp_var_data): Add GOVD_MAP_ALWAYS_TO. (omp_default_clause): Tweak for private/firstprivate/is_device_ptr variables on target construct and use_device_ptr on target data. (omp_check_private): Likewise. (omp_notice_variable): For references check whether what it refers to has mappable type, rather than the reference itself. (omp_is_private): Diagnose linear iteration variables on non-simd constructs. (omp_no_lastprivate): Return true only for Fortran. (gimplify_scan_omp_clauses): Or in GOVD_MAP_ALWAYS_TO for GOMP_MAP_ALWAYS_TO or GOMP_MAP_ALWAYS_TOFROM kinds. Add support for GOMP_MAP_FIRSTPRIVATE_REFERENCE and GOMP_MAP_ALWAYS_POINTER, remove old handling of structure element based array sections. Use GOMP_MAP_ALWAYS_P. Fix up handling of lastprivate and linear when combined with distribute. Gimplify variable low-bound for array reduction. Look through POINTER_PLUS_EXPR when looking for ADDR_EXPR for array section reductions. (gimplify_adjust_omp_clauses_1): For implicit references to variables with reference type and when not ref to scalar or ref to pointer, map what they refer to using tofrom and use GOMP_MAP_FIRSTPRIVATE_REFERENCE for the reference. (gimplify_adjust_omp_clauses): Remove GOMP_MAP_ALWAYS_POINTER from target exit data. Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE. Drop OMP_CLAUSE_MAP_PRIVATE support. Use GOMP_MAP_ALWAYS_P. Diagnose the same var on both firstprivate and lastprivate on distribute construct. (gimplify_omp_for): Fix up handling of predetermined lastprivate or linear iter vars when combined with distribute. (find_omp_teams, computable_teams_clause, optimize_target_teams): New functions. (gimplify_omp_workshare): Call optimize_target_teams. * omp-low.c (struct omp_region): Add sched_modifiers field. (struct omp_for_data): Likewise. (omp_any_child_fn_dumped): New variable. (extract_omp_for_data): Fill in sched_modifiers, and mask out OMP_CLAUSE_SCHEDULE_KIND bits outside of OMP_CLAUSE_SCHEDULE_MASK from sched_kind. (determine_parallel_type): Use only OMP_CLAUSE_SCHEDULE_MASK bits of OMP_CLAUSE_SCHED_KIND. (scan_sharing_clauses): Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE, drop OMP_CLAUSE_MAP_PRIVATE support. Look through POINTER_PLUS_EXPR for array section reductions. (add_taskreg_looptemp_clauses): Add one extra _looptemp_ clause even for distribute parallel for, if there are lastprivate clauses on the for. (lower_rec_input_clauses): Handle non-zero low-bound on array section reductions. (lower_reduction_clauses): Likewise. (lower_send_clauses): Look through POINTER_PLUS_EXPR for array section reductions. (expand_parallel_call): Use nonmonotonic entrypoints for nonmonotonic: dynamic/guided. (expand_omp_taskreg): Call assign_assembler_name_if_neeeded on child_fn if current_function_decl has assembler name set, but child_fn does not. Dump the header and IL of the child function when not in SSA form. (expand_omp_target): Likewise. Pass num_teams and thread_limit arguments to BUILT_IN_GOMP_TARGET. (expand_omp_for_static_nochunk, expand_omp_for_static_chunk): Initialize the extra _looptemp_ clause to fd->loop.n2. (expand_omp_for): Use nonmonotonic entrypoints for nonmonotonic: dynamic/guided. Initialize region->sched_modifiers. (expand_omp): Clear omp_any_child_fn_dumped. Dump function header again if we have dumped any child functions. (lower_omp_for_lastprivate): Determine the right count variable for distribute simd, or distribute parallel for{, simd}. (lower_omp_target): Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE and GOMP_MAP_ALWAYS_POINTER. Drop OMP_CLAUSE_MAP_PRIVATE support. (simd_clone_clauses_extract): Handle variable step for references and arguments passed by reference. (simd_clone_mangle): Mangle ref/uval/val variable steps. (simd_clone_adjust_argument_types): Handle SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP like SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP and SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP like SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP. (simd_clone_linear_addend): New function. (simd_clone_adjust): Handle variable step like similarly to constant step, use simd_clone_linear_addend to determine the actual step at runtime. gcc/c-family/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> * c-common.h (c_finish_omp_atomic): Add TEST argument. (c_omp_check_loop_iv, c_omp_check_loop_iv_exprs): New prototypes. * c-omp.c (c_finish_omp_atomic): Add TEST argument. Don't call save_expr or create_tmp_var* if TEST is true. (c_finish_omp_for): Store OMP_FOR_ORIG_DECLS always. Don't call add_stmt here. (struct c_omp_check_loop_iv_data): New type. (c_omp_check_loop_iv_r, c_omp_check_loop_iv, c_omp_check_loop_iv_exprs): New functions. (c_omp_split_clauses): Adjust for lastprivate being allowed on distribute. (c_omp_declare_simd_clauses_to_numbers): Change OMP_CLAUSE_LINEAR_VARIABLE_STRIDE OMP_CLAUSE_LINEAR_STEP into numbers. (c_omp_declare_simd_clauses_to_decls): Similarly change those from numbers to PARM_DECLs. gcc/c/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * c-parser.c: Include context.h and gimple-expr.h. (c_parser_omp_clause_schedule): Parse schedule modifiers, diagnose monotonic together with nonmonotonic. (c_parser_omp_for_loop): Call c_omp_check_loop_iv. Call add_stmt here. (OMP_DISTRIBUTE_CLAUSE_MASK): Add lastprivate clause. (c_parser_omp_target_data, c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Allow GOMP_MAP_ALWAYS_POINTER. (c_parser_omp_target): Likewise. Evaluate num_teams and thread_limit expressions on combined target teams before the target. (c_parser_omp_declare_target): If decl has "omp declare target" or "omp declare target link" attribute, and cgraph or varpool node already exists, then set corresponding flags. Call c_finish_omp_clauses in the parenthesized extended-list syntax case. * c-decl.c (c_decl_attributes): Don't diagnose block scope vars inside declare target. * c-typeck.c (handle_omp_array_sections_1): Allow non-zero low-bound on OMP_CLAUSE_REDUCTION array sections. (handle_omp_array_sections): Encode low-bound into the MEM_REF, either into the constant offset, or for variable low-bound using POINTER_PLUS_EXPR. For structure element based array sections use GOMP_MAP_ALWAYS_POINTER instead of GOMP_MAP_FIRSTPRIVATE_POINTER. (c_finish_omp_clauses): Drop generic_field_head, structure elements are now always mapped even as array section bases, diagnose same var in data sharing and mapping clauses. Diagnose if linear step on declare simd is neither a constant nor a uniform parameter. Look through POINTER_PLUS_EXPR for array section reductions. Diagnose the same var or function appearing multiple times on the same directive. Fix up wording for the to clause if t is neither a FUNCTION_DECL nor a VAR_DECL. Diagnose nonmonotonic modifier on kinds other than dynamic or guided or nonmonotonic modifier together with ordered clause. gcc/cp/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * cp-tree.h (finish_omp_for): Add ORIG_INITS argument. (omp_privatize_field): Add SHARED argument. * parser.c: Include context.h. (cp_parser_omp_clause_schedule): Parse schedule modifiers, diagnose monotonic together with nonmonotonic. (cp_parser_omp_clause_linear): Add DECLARE_SIMD argument. Parse parameter name as linear step as id-expression rather than expression. (cp_parser_omp_all_clauses): Adjust caller. (cp_parser_omp_for_loop_init): Add ORIG_INIT argument, initialize it. Adjust omp_privatize_field caller. (cp_parser_omp_for_loop): Compute orig_inits, pass it's address to finish_omp_for. (OMP_DISTRIBUTE_CLAUSE_MASK): Add lastprivate clause. (cp_parser_omp_target_data, cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data): Allow GOMP_MAP_ALWAYS_POINTER and GOMP_MAP_FIRSTPRIVATE_REFERENCE. (cp_parser_omp_target): Likewise. Evaluate num_teams and thread_limit expressions on combined target teams before the target. (cp_parser_omp_declare_target): If decl has "omp declare target" or "omp declare target link" attribute, and cgraph or varpool node already exists, then set corresponding flags. Call finish_omp_clauses in the parenthesized extended-list syntax case. Call cp_parser_require_pragma_eol instead of cp_parser_skip_to_pragma_eol. (cp_parser_omp_end_declare_target): Call cp_parser_require_pragma_eol instead of cp_parser_skip_to_pragma_eol. * decl2.c (cplus_decl_attributes): Don't diagnose block scope vars inside declare target. * pt.c (tsubst_omp_clauses): If OMP_CLAUSE_LINEAR_VARIABLE_STRIDE, use tsubst_omp_clause_decl instead of tsubst_expr on OMP_CLAUSE_LINEAR_STEP. Handle non-static data members in shared clauses. (tsubst_omp_for_iterator): Adjust omp_privatize_field caller. (tsubst_find_omp_teams): New function. (tsubst_expr): Evaluate num_teams and thread_limit expressions on combined target teams before the target. Use OMP_FOR_ORIG_DECLS for all OpenMP/OpenACC/Cilk+ looping constructs. Adjust finish_omp_for caller. * semantics.c (omp_privatize_field): Add SHARED argument, if true, always create artificial var and never put it into the hash table or vector. (handle_omp_array_sections_1): Adjust omp_privatize_field caller. Allow non-zero low-bound on OMP_CLAUSE_REDUCTION array sections. (handle_omp_array_sections): For structure element based array sections use GOMP_MAP_ALWAYS_POINTER instead of GOMP_MAP_FIRSTPRIVATE_POINTER. Encode low-bound into the MEM_REF, either into the constant offset, or for variable low-bound using POINTER_PLUS_EXPR. (finish_omp_clauses): Adjust omp_privatize_field caller. Drop generic_field_head, structure elements are now always mapped even as array section bases, diagnose same var in data sharing and mapping clauses. For references map what they refer to using GOMP_MAP_ALWAYS_POINTER for structure elements and GOMP_MAP_FIRSTPRIVATE_REFERENCE otherwise. Diagnose if linear step on declare simd is neither a constant nor a uniform parameter. Allow non-static data members on shared clauses. Look through POINTER_PLUS_EXPR for array section reductions. Diagnose nonmonotonic modifier on kinds other than dynamic or guided or nonmonotonic modifier together with ordered clause. Diagnose the same var or function appearing multiple times on the same directive. Fix up wording for the to clause if t is neither a FUNCTION_DECL nor a VAR_DECL, use special wording for OVERLOADs and TEMPLATE_ID_EXPR. (handle_omp_for_class_iterator): Add ORIG_DECLS argument. Call c_omp_check_loop_iv_exprs on cond. (finish_omp_for): Add ORIG_INITS argument. Call c_omp_check_loop_iv_exprs on ORIG_INITS elements. Adjust handle_omp_for_class_iterator caller. Call c_omp_check_loop_iv. Call add_stmt. (finish_omp_atomic): Adjust c_finish_omp_atomic caller. gcc/fortran/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> * types.def (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR): Remove. (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): New. gcc/testsuite/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> * c-c++-common/gomp/clauses-2.c (foo): Adjust for diagnostics of variables in both data sharing and mapping clauses and for structure element based array sections being mapped rather than privatized. * c-c++-common/gomp/declare-target-2.c: Add various new tests. Adjust expected diagnostics wording in one case. * c-c++-common/gomp/distribute-1.c: New test. * c-c++-common/gomp/element-1.c: New test. * c-c++-common/gomp/pr61486-2.c: Add #pragma omp declare target and #pragma omp end declare target pair around the function. Change s from a parameter to a file scope variable. * c-c++-common/gomp/pr67521.c: Add dg-error directives. * c-c++-common/gomp/reduction-1.c (foo): Don't expect diagnostics on non-zero low-bound in reduction array sections. Add further tests. * c-c++-common/gomp/schedule-modifiers-1.c: New test. * c-c++-common/gomp/target-teams-1.c: New test. * gcc.dg/gomp/declare-simd-1.c: Add scan-assembler-times directives for expected mangling on x86_64/i?86. * gcc.dg/gomp/declare-simd-3.c: New test. * gcc.dg/gomp/declare-simd-4.c: New test. * gcc.dg/gomp/for-20.c: New test. * gcc.dg/gomp/for-21.c: New test. * gcc.dg/gomp/for-22.c: New test. * gcc.dg/gomp/for-23.c: New test. * gcc.dg/gomp/for-24.c: New test. * gcc.dg/gomp/linear-1.c: New test. * gcc.dg/gomp/loop-1.c: New test. * g++.dg/gomp/atomic-17.C: New test. * g++.dg/gomp/clause-1.C (T::test): Don't expect error on non-static data member in shared clause. Add single construct. * g++.dg/gomp/declare-simd-1.C: Add dg-options. Add scan-assembler-times directives for expected mangling on x86_64/i?86. * g++.dg/gomp/declare-simd-3.C: Likewise. * g++.dg/gomp/declare-simd-4.C: New test. * g++.dg/gomp/declare-simd-5.C: New test. * g++.dg/gomp/declare-target-1.C: New test. * g++.dg/gomp/linear-2.C: New test. * g++.dg/gomp/loop-1.C: New test. * g++.dg/gomp/loop-2.C: New test. * g++.dg/gomp/loop-3.C: New test. * g++.dg/gomp/member-2.C (B::m2, B::m4): Don't expect error on non-static data member in shared clause. * g++.dg/gomp/member-3.C: New test. * g++.dg/gomp/member-4.C: New test. * g++.dg/gomp/pr38639.C (foo): Adjust dg-error. (bar): Remove dg-message. * g++.dg/gomp/target-teams-1.C: New test. include/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * gomp-constants.h (GOMP_MAP_FLAG_SPECIAL_2): Define. (GOMP_MAP_FLAG_ALWAYS): Remove. (enum gomp_map_kind): Use GOMP_MAP_FLAG_SPECIAL_2 instead of GOMP_MAP_FLAG_ALWAYS for GOMP_MAP_ALWAYS_TO, GOMP_MAP_ALWAYS_FROM, GOMP_MAP_ALWAYS_TOFROM, GOMP_MAP_STRUCT, GOMP_MAP_RELEASE. Add GOMP_MAP_ALWAYS_POINTER and GOMP_MAP_FIRSTPRIVATE_REFERENCE. (GOMP_MAP_ALWAYS_P): Define. (GOMP_TARGET_FLAG_NOWAIT): Adjust comment. libgomp/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * libgomp_g.h (GOMP_loop_nonmonotonic_dynamic_next, GOMP_loop_nonmonotonic_dynamic_start, GOMP_loop_nonmonotonic_guided_next, GOMP_loop_nonmonotonic_guided_start, GOMP_loop_ull_nonmonotonic_dynamic_next, GOMP_loop_ull_nonmonotonic_dynamic_start, GOMP_loop_ull_nonmonotonic_guided_next, GOMP_loop_ull_nonmonotonic_guided_start, GOMP_parallel_loop_nonmonotonic_dynamic, GOMP_parallel_loop_nonmonotonic_guided): New prototypes. (GOMP_target_41): Renamed to ... (GOMP_target_ext): ... this. Add num_teams and thread_limit arguments. (GOMP_target_data_41): Renamed to ... (GOMP_target_data_ext): ... this. (GOMP_target_update_41): Renamed to ... (GOMP_target_update_ext): ... this. * libgomp.map (GOMP_4.5): Export GOMP_target_ext, GOMP_target_data_ext and GOMP_target_update_ext instead of GOMP_target_41, GOMP_target_data_41 and GOMP_target_update_41. Export GOMP_loop_nonmonotonic_dynamic_next, GOMP_loop_nonmonotonic_dynamic_start, GOMP_loop_nonmonotonic_guided_next, GOMP_loop_nonmonotonic_guided_start, GOMP_loop_ull_nonmonotonic_dynamic_next, GOMP_loop_ull_nonmonotonic_dynamic_start, GOMP_loop_ull_nonmonotonic_guided_next, GOMP_loop_ull_nonmonotonic_guided_start, GOMP_parallel_loop_nonmonotonic_dynamic and GOMP_parallel_loop_nonmonotonic_guided. * loop.c (GOMP_parallel_loop_nonmonotonic_dynamic, GOMP_parallel_loop_nonmonotonic_guided, GOMP_loop_nonmonotonic_dynamic_start, GOMP_loop_nonmonotonic_guided_start, GOMP_loop_nonmonotonic_dynamic_next, GOMP_loop_nonmonotonic_guided_next): New aliases or functions. * loop_ull.c (GOMP_loop_ull_nonmonotonic_dynamic_start, GOMP_loop_ull_nonmonotonic_guided_start, GOMP_loop_ull_nonmonotonic_dynamic_next, GOMP_loop_ull_nonmonotonic_guided_next): Likewise. * target.c (gomp_map_0len_lookup, gomp_map_val): New inline functions. (gomp_map_vars): Handle GOMP_MAP_ALWAYS_POINTER. For GOMP_MAP_ZERO_LEN_ARRAY_SECTION use gomp_map_0len_lookup. Use gomp_map_val function. (gomp_target_fallback_firstprivate): New static function. (GOMP_target_41): Renamed to ... (GOMP_target_ext): ... this. Add num_teams and thread_limit arguments. Move firstprivate fallback handling into a new function. (GOMP_target_data_41): Renamed to ... (GOMP_target_data_ext): ... this. (GOMP_target_update_41): Renamed to ... (GOMP_target_update_ext): ... this. (gomp_exit_data): For GOMP_MAP_*ZERO_LEN* use gomp_map_0len_lookup instead of gomp_map_lookup. (omp_target_is_present): Use gomp_map_0len_lookup instead of gomp_map_lookup. * testsuite/libgomp.c/target-28.c: Likewise. * testsuite/libgomp.c/monotonic-1.c: New test. * testsuite/libgomp.c/monotonic-2.c: New test. * testsuite/libgomp.c/nonmonotonic-1.c: New test. * testsuite/libgomp.c/nonmonotonic-2.c: New test. * testsuite/libgomp.c/pr66199-5.c: New test. * testsuite/libgomp.c/pr66199-6.c: New test. * testsuite/libgomp.c/pr66199-7.c: New test. * testsuite/libgomp.c/pr66199-8.c: New test. * testsuite/libgomp.c/pr66199-9.c: New test. * testsuite/libgomp.c/reduction-11.c: New test. * testsuite/libgomp.c/reduction-12.c: New test. * testsuite/libgomp.c/reduction-13.c: New test. * testsuite/libgomp.c/reduction-14.c: New test. * testsuite/libgomp.c/reduction-15.c: New test. * testsuite/libgomp.c/target-12.c (main): Adjust for omp_target_is_present change for one-past-last element. * testsuite/libgomp.c/target-17.c (foo): Drop tests where the same var is both mapped and privatized. * testsuite/libgomp.c/target-19.c (foo): Adjust for different handling of zero-length array sections. * testsuite/libgomp.c/target-28.c: New test. * testsuite/libgomp.c/target-29.c: New test. * testsuite/libgomp.c/target-30.c: New test. * testsuite/libgomp.c/target-teams-1.c: New test. * testsuite/libgomp.c++/member-6.C: New test. * testsuite/libgomp.c++/member-7.C: New test. * testsuite/libgomp.c++/monotonic-1.C: New test. * testsuite/libgomp.c++/monotonic-2.C: New test. * testsuite/libgomp.c++/nonmonotonic-1.C: New test. * testsuite/libgomp.c++/nonmonotonic-2.C: New test. * testsuite/libgomp.c++/pr66199-3.C: New test. * testsuite/libgomp.c++/pr66199-4.C: New test. * testsuite/libgomp.c++/pr66199-5.C: New test. * testsuite/libgomp.c++/pr66199-6.C: New test. * testsuite/libgomp.c++/pr66199-7.C: New test. * testsuite/libgomp.c++/pr66199-8.C: New test. * testsuite/libgomp.c++/pr66199-9.C: New test. * testsuite/libgomp.c++/reduction-11.C: New test. * testsuite/libgomp.c++/reduction-12.C: New test. * testsuite/libgomp.c++/target-13.C: New test. * testsuite/libgomp.c++/target-14.C: New test. * testsuite/libgomp.c++/target-15.C: New test. * testsuite/libgomp.c++/target-16.C: New test. * testsuite/libgomp.c++/target-17.C: New test. * testsuite/libgomp.c++/target-18.C: New test. * testsuite/libgomp.c++/target-19.C: New test. Co-Authored-By: Ilya Verbin <ilya.verbin@intel.com> From-SVN: r229814
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog18
-rw-r--r--gcc/c-family/c-common.h6
-rw-r--r--gcc/c-family/c-omp.c241
3 files changed, 248 insertions, 17 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 97a2a84..ffb97c9 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,21 @@
+2015-11-05 Jakub Jelinek <jakub@redhat.com>
+
+ * c-common.h (c_finish_omp_atomic): Add TEST argument.
+ (c_omp_check_loop_iv, c_omp_check_loop_iv_exprs): New prototypes.
+ * c-omp.c (c_finish_omp_atomic): Add TEST argument. Don't call
+ save_expr or create_tmp_var* if TEST is true.
+ (c_finish_omp_for): Store OMP_FOR_ORIG_DECLS always.
+ Don't call add_stmt here.
+ (struct c_omp_check_loop_iv_data): New type.
+ (c_omp_check_loop_iv_r, c_omp_check_loop_iv,
+ c_omp_check_loop_iv_exprs): New functions.
+ (c_omp_split_clauses): Adjust for lastprivate being allowed on
+ distribute.
+ (c_omp_declare_simd_clauses_to_numbers): Change
+ OMP_CLAUSE_LINEAR_VARIABLE_STRIDE OMP_CLAUSE_LINEAR_STEP into numbers.
+ (c_omp_declare_simd_clauses_to_decls): Similarly change those
+ from numbers to PARM_DECLs.
+
2015-11-04 Mikhail Maltsev <maltsevm@gmail.com>
* c-omp.c (c_omp_split_clauses): Remove conditional compilation. Use
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 0da4b2e..de9768e 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1262,12 +1262,16 @@ extern tree c_finish_omp_critical (location_t, tree, tree, tree);
extern tree c_finish_omp_ordered (location_t, tree, tree);
extern void c_finish_omp_barrier (location_t);
extern tree c_finish_omp_atomic (location_t, enum tree_code, enum tree_code,
- tree, tree, tree, tree, tree, bool, bool);
+ tree, tree, tree, tree, tree, bool, bool,
+ bool = false);
extern void c_finish_omp_flush (location_t);
extern void c_finish_omp_taskwait (location_t);
extern void c_finish_omp_taskyield (location_t);
extern tree c_finish_omp_for (location_t, enum tree_code, tree, tree, tree,
tree, tree, tree, tree);
+extern bool c_omp_check_loop_iv (tree, tree, walk_tree_lh);
+extern bool c_omp_check_loop_iv_exprs (location_t, tree, tree, tree, tree,
+ walk_tree_lh);
extern tree c_finish_oacc_wait (location_t, tree, tree);
extern tree c_oacc_split_loop_clauses (tree, tree *);
extern void c_omp_split_clauses (location_t, enum tree_code, omp_clause_mask,
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index ca64eda..a51611c 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -175,12 +175,14 @@ c_finish_omp_taskyield (location_t loc)
LOC is the location of the atomic statement. The value returned
is either error_mark_node (if the construct was erroneous) or an
OMP_ATOMIC* node which should be added to the current statement
- tree with add_stmt. */
+ tree with add_stmt. If TEST is set, avoid calling save_expr
+ or create_tmp_var*. */
tree
c_finish_omp_atomic (location_t loc, enum tree_code code,
enum tree_code opcode, tree lhs, tree rhs,
- tree v, tree lhs1, tree rhs1, bool swapped, bool seq_cst)
+ tree v, tree lhs1, tree rhs1, bool swapped, bool seq_cst,
+ bool test)
{
tree x, type, addr, pre = NULL_TREE;
@@ -212,8 +214,10 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
addr = build_unary_op (loc, ADDR_EXPR, lhs, 0);
if (addr == error_mark_node)
return error_mark_node;
- addr = save_expr (addr);
- if (TREE_CODE (addr) != SAVE_EXPR
+ if (!test)
+ addr = save_expr (addr);
+ if (!test
+ && TREE_CODE (addr) != SAVE_EXPR
&& (TREE_CODE (addr) != ADDR_EXPR
|| !VAR_P (TREE_OPERAND (addr, 0))))
{
@@ -269,12 +273,15 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
if (rhs1
&& VAR_P (rhs1)
&& VAR_P (lhs)
- && rhs1 != lhs)
+ && rhs1 != lhs
+ && !test)
{
if (code == OMP_ATOMIC)
- error_at (loc, "%<#pragma omp atomic update%> uses two different variables for memory");
+ error_at (loc, "%<#pragma omp atomic update%> uses two different "
+ "variables for memory");
else
- error_at (loc, "%<#pragma omp atomic capture%> uses two different variables for memory");
+ error_at (loc, "%<#pragma omp atomic capture%> uses two different "
+ "variables for memory");
return error_mark_node;
}
@@ -284,9 +291,10 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
location, just diagnose different variables. */
if (lhs1 && VAR_P (lhs1) && VAR_P (lhs))
{
- if (lhs1 != lhs)
+ if (lhs1 != lhs && !test)
{
- error_at (loc, "%<#pragma omp atomic capture%> uses two different variables for memory");
+ error_at (loc, "%<#pragma omp atomic capture%> uses two "
+ "different variables for memory");
return error_mark_node;
}
}
@@ -308,7 +316,8 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
x = omit_one_operand_loc (loc, type, x, lhs1addr);
else
{
- x = save_expr (x);
+ if (!test)
+ x = save_expr (x);
x = omit_two_operands_loc (loc, type, x, x, lhs1addr);
}
}
@@ -683,19 +692,177 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv,
OMP_FOR_INCR (t) = incrv;
OMP_FOR_BODY (t) = body;
OMP_FOR_PRE_BODY (t) = pre_body;
- if (code == OMP_FOR)
- OMP_FOR_ORIG_DECLS (t) = orig_declv;
+ OMP_FOR_ORIG_DECLS (t) = orig_declv;
SET_EXPR_LOCATION (t, locus);
- return add_stmt (t);
+ return t;
}
}
+/* Type for passing data in between c_omp_check_loop_iv and
+ c_omp_check_loop_iv_r. */
+
+struct c_omp_check_loop_iv_data
+{
+ tree declv;
+ bool fail;
+ location_t stmt_loc;
+ location_t expr_loc;
+ int kind;
+ walk_tree_lh lh;
+ hash_set<tree> *ppset;
+};
+
+/* Helper function called via walk_tree, to diagnose uses
+ of associated loop IVs inside of lb, b and incr expressions
+ of OpenMP loops. */
+
+static tree
+c_omp_check_loop_iv_r (tree *tp, int *walk_subtrees, void *data)
+{
+ struct c_omp_check_loop_iv_data *d
+ = (struct c_omp_check_loop_iv_data *) data;
+ if (DECL_P (*tp))
+ {
+ int i;
+ for (i = 0; i < TREE_VEC_LENGTH (d->declv); i++)
+ if (*tp == TREE_VEC_ELT (d->declv, i))
+ {
+ location_t loc = d->expr_loc;
+ if (loc == UNKNOWN_LOCATION)
+ loc = d->stmt_loc;
+ switch (d->kind)
+ {
+ case 0:
+ error_at (loc, "initializer expression refers to "
+ "iteration variable %qD", *tp);
+ break;
+ case 1:
+ error_at (loc, "condition expression refers to "
+ "iteration variable %qD", *tp);
+ break;
+ case 2:
+ error_at (loc, "increment expression refers to "
+ "iteration variable %qD", *tp);
+ break;
+ }
+ d->fail = true;
+ }
+ }
+ /* Don't walk dtors added by C++ wrap_cleanups_r. */
+ else if (TREE_CODE (*tp) == TRY_CATCH_EXPR
+ && TRY_CATCH_IS_CLEANUP (*tp))
+ {
+ *walk_subtrees = 0;
+ return walk_tree_1 (&TREE_OPERAND (*tp, 0), c_omp_check_loop_iv_r, data,
+ d->ppset, d->lh);
+ }
+
+ return NULL_TREE;
+}
+
+/* Diagnose invalid references to loop iterators in lb, b and incr
+ expressions. */
+
+bool
+c_omp_check_loop_iv (tree stmt, tree declv, walk_tree_lh lh)
+{
+ hash_set<tree> pset;
+ struct c_omp_check_loop_iv_data data;
+ int i;
+
+ data.declv = declv;
+ data.fail = false;
+ data.stmt_loc = EXPR_LOCATION (stmt);
+ data.lh = lh;
+ data.ppset = &pset;
+ for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (stmt)); i++)
+ {
+ tree init = TREE_VEC_ELT (OMP_FOR_INIT (stmt), i);
+ gcc_assert (TREE_CODE (init) == MODIFY_EXPR);
+ tree decl = TREE_OPERAND (init, 0);
+ tree cond = TREE_VEC_ELT (OMP_FOR_COND (stmt), i);
+ gcc_assert (COMPARISON_CLASS_P (cond));
+ gcc_assert (TREE_OPERAND (cond, 0) == decl);
+ tree incr = TREE_VEC_ELT (OMP_FOR_INCR (stmt), i);
+ data.expr_loc = EXPR_LOCATION (TREE_OPERAND (init, 1));
+ data.kind = 0;
+ walk_tree_1 (&TREE_OPERAND (init, 1),
+ c_omp_check_loop_iv_r, &data, &pset, lh);
+ /* Don't warn for C++ random access iterators here, the
+ expression then involves the subtraction and always refers
+ to the original value. The C++ FE needs to warn on those
+ earlier. */
+ if (decl == TREE_VEC_ELT (declv, i))
+ {
+ data.expr_loc = EXPR_LOCATION (cond);
+ data.kind = 1;
+ walk_tree_1 (&TREE_OPERAND (cond, 1),
+ c_omp_check_loop_iv_r, &data, &pset, lh);
+ }
+ if (TREE_CODE (incr) == MODIFY_EXPR)
+ {
+ gcc_assert (TREE_OPERAND (incr, 0) == decl);
+ incr = TREE_OPERAND (incr, 1);
+ data.kind = 2;
+ if (TREE_CODE (incr) == PLUS_EXPR
+ && TREE_OPERAND (incr, 1) == decl)
+ {
+ data.expr_loc = EXPR_LOCATION (TREE_OPERAND (incr, 0));
+ walk_tree_1 (&TREE_OPERAND (incr, 0),
+ c_omp_check_loop_iv_r, &data, &pset, lh);
+ }
+ else
+ {
+ data.expr_loc = EXPR_LOCATION (TREE_OPERAND (incr, 1));
+ walk_tree_1 (&TREE_OPERAND (incr, 1),
+ c_omp_check_loop_iv_r, &data, &pset, lh);
+ }
+ }
+ }
+ return !data.fail;
+}
+
+/* Similar, but allows to check the init or cond expressions individually. */
+
+bool
+c_omp_check_loop_iv_exprs (location_t stmt_loc, tree declv, tree decl,
+ tree init, tree cond, walk_tree_lh lh)
+{
+ hash_set<tree> pset;
+ struct c_omp_check_loop_iv_data data;
+
+ data.declv = declv;
+ data.fail = false;
+ data.stmt_loc = stmt_loc;
+ data.lh = lh;
+ data.ppset = &pset;
+ if (init)
+ {
+ data.expr_loc = EXPR_LOCATION (init);
+ data.kind = 0;
+ walk_tree_1 (&init,
+ c_omp_check_loop_iv_r, &data, &pset, lh);
+ }
+ if (cond)
+ {
+ gcc_assert (COMPARISON_CLASS_P (cond));
+ data.expr_loc = EXPR_LOCATION (init);
+ data.kind = 1;
+ if (TREE_OPERAND (cond, 0) == decl)
+ walk_tree_1 (&TREE_OPERAND (cond, 1),
+ c_omp_check_loop_iv_r, &data, &pset, lh);
+ else
+ walk_tree_1 (&TREE_OPERAND (cond, 0),
+ c_omp_check_loop_iv_r, &data, &pset, lh);
+ }
+ return !data.fail;
+}
+
/* This function splits clauses for OpenACC combined loop
constructs. OpenACC combined loop constructs are:
#pragma acc kernels loop
- #pragma acc parallel loop
-*/
+ #pragma acc parallel loop */
tree
c_oacc_split_loop_clauses (tree clauses, tree *not_loop_clauses)
@@ -972,10 +1139,24 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
s = C_OMP_CLAUSE_SPLIT_FOR;
}
break;
- /* Lastprivate is allowed on for, sections and simd. In
+ /* Lastprivate is allowed on distribute, for, sections and simd. In
parallel {for{, simd},sections} we actually want to put it on
parallel rather than for or sections. */
case OMP_CLAUSE_LASTPRIVATE:
+ if (code == OMP_DISTRIBUTE)
+ {
+ s = C_OMP_CLAUSE_SPLIT_DISTRIBUTE;
+ break;
+ }
+ if ((mask & (OMP_CLAUSE_MASK_1
+ << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0)
+ {
+ c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses),
+ OMP_CLAUSE_LASTPRIVATE);
+ OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses);
+ OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_DISTRIBUTE];
+ cclauses[C_OMP_CLAUSE_SPLIT_DISTRIBUTE] = c;
+ }
if (code == OMP_FOR || code == OMP_SECTIONS)
{
if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS))
@@ -1212,6 +1393,23 @@ c_omp_declare_simd_clauses_to_numbers (tree parms, tree clauses)
continue;
}
OMP_CLAUSE_DECL (c) = build_int_cst (integer_type_node, idx);
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
+ && OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c))
+ {
+ decl = OMP_CLAUSE_LINEAR_STEP (c);
+ for (arg = parms, idx = 0; arg;
+ arg = TREE_CHAIN (arg), idx++)
+ if (arg == decl)
+ break;
+ if (arg == NULL_TREE)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not an function argument", decl);
+ continue;
+ }
+ OMP_CLAUSE_LINEAR_STEP (c)
+ = build_int_cst (integer_type_node, idx);
+ }
}
clvec.safe_push (c);
}
@@ -1249,6 +1447,17 @@ c_omp_declare_simd_clauses_to_decls (tree fndecl, tree clauses)
break;
gcc_assert (arg);
OMP_CLAUSE_DECL (c) = arg;
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
+ && OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c))
+ {
+ idx = tree_to_shwi (OMP_CLAUSE_LINEAR_STEP (c));
+ for (arg = DECL_ARGUMENTS (fndecl), i = 0; arg;
+ arg = TREE_CHAIN (arg), i++)
+ if (i == idx)
+ break;
+ gcc_assert (arg);
+ OMP_CLAUSE_LINEAR_STEP (c) = arg;
+ }
}
}