2025-07-21 Thomas Schwinge Backported from master: 2025-05-12 Thomas Schwinge * config/nvptx/nvptx-sm.def: Add '61'. * config/nvptx/nvptx-gen.h: Regenerate. * config/nvptx/nvptx-gen.opt: Likewise. * config/nvptx/nvptx.cc (first_ptx_version_supporting_sm): Adjust. * config/nvptx/nvptx.opt (-march-map=sm_61, -march-map=sm_62): Likewise. * config.gcc: Likewise. * doc/invoke.texi (Nvidia PTX Options): Document '-march=sm_61'. * config/nvptx/gen-multilib-matches-tests: Extend. 2025-07-21 Thomas Schwinge Backported from master: 2025-05-12 Thomas Schwinge * config/nvptx/nvptx-opts.h (enum ptx_version): Add 'PTX_VERSION_5_0'. * config/nvptx/nvptx.cc (ptx_version_to_string) (ptx_version_to_number): Adjust. * config/nvptx/nvptx.h (TARGET_PTX_5_0): New. * config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue' '5.0' for 'PTX_VERSION_5_0'. * doc/invoke.texi (Nvidia PTX Options): Document '-mptx=5.0'. 2025-06-17 Tobias Burnus Backported from master: 2025-06-17 Tobias Burnus * omp-offload.cc (omp_discover_declare_target_tgt_fn_r): Also walk external functions that are declare inline (and have a DECL_SAVED_TREE). 2025-06-10 Tobias Burnus Backported from master: 2025-06-10 Tobias Burnus * config/gcn/gcn-devices.def: Add gfx942, gfx950 and gfx9-4-generic. * config/gcn/gcn-opts.h (TARGET_CDNA3, TARGET_CDNA3_PLUS, TARGET_GLC_NAME, TARGET_TARGET_SC_CACHE): Define. (TARGET_ARCHITECTED_FLAT_SCRATCH): Use also for CDNA3. * config/gcn/gcn.h (gcn_isa): Add ISA_CDNA3 to the enum. * config/gcn/gcn.cc (print_operand): Update 'g' to use TARGET_GLC_NAME; add 'G' to print TARGET_GLC_NAME unconditionally. * config/gcn/gcn-valu.md (scatter, gather): Use TARGET_GLC_NAME. * config/gcn/gcn.md: Use %G instead of glc; use 'buffer_inv sc1' for TARGET_TARGET_SC_CACHE. * doc/invoke.texi (march): Add gfx942, gfx950 and gfx9-4-generic. * doc/install.texi (amdgcn*-*-*): Add gfx942, gfx950 and gfx9-4-generic. * config/gcn/gcn-tables.opt: Regenerate. 2025-06-06 Tobias Burnus Backported from master: 2025-06-06 Tobias Burnus Sandra Loosemore * gimple-fold.cc (gimple_fold_builtin_omp_get_initial_device, gimple_fold_builtin_omp_get_num_devices): New. (gimple_fold_builtin): Call them. * omp-builtins.def (BUILT_IN_OMP_GET_INITIAL_DEVICE): Add (BUILT_IN_OMP_GET_NUM_DEVICES): Make uservisible + pure. 2025-06-06 Tobias Burnus Backported from master: 2025-06-06 Tobias Burnus * builtins.def (DEF_GOACC_BUILTIN_COMPILER, DEF_GOMP_BUILTIN_COMPILER): Set NONANSI_P = false to enable those also with -fno-nonansi-builtins. 2025-06-05 Sandra Loosemore Backported from master: 2025-06-04 Sandra Loosemore PR c++/120518 * omp-general.cc (omp_device_num_check): Look inside a CLEANUP_POINT_EXPR when trying to optimize special cases. 2025-06-04 Thomas Schwinge Backported from master: 2025-06-04 Thomas Schwinge * config/nvptx/mkoffload.cc (process): Use an 'auto_vec' for 'file_idx'. 2025-05-30 Thomas Schwinge Backported from master: 2025-05-30 Thomas Schwinge Richard Biener PR middle-end/119835 * tree-nrv.cc (pass_nrv::execute): Defuse 'RESULT_DECL' check. 2025-05-22 Thomas Schwinge Backported from master: 2025-05-19 Thomas Schwinge PR lto/120308 * lto-streamer-out.cc (hash_tree): Don't handle 'TYPE_EMPTY_P' for 'lto_stream_offload_p'. * tree-streamer-in.cc (unpack_ts_type_common_value_fields): Likewise. * tree-streamer-out.cc (pack_ts_type_common_value_fields): Likewise. 2025-05-15 Sandra Loosemore Tobias Burnus * gimplify.cc (modify_call_for_omp_dispatch): Rework logic for need_device_ptr and need_device_addr adjustments. 2025-05-15 waffl3x PR c++/119659 PR c++/118859 PR c++/119601 PR c++/119602 PR c++/119775 * gimplify.cc (modify_call_for_omp_dispatch): Refactor and change attribute unpacking. For adjust_args variadic functions, expand numeric ranges with relative bounds. Refactor argument adjustment. 2025-05-15 Andrew Pinski Backported from master: 2025-04-25 Andrew Pinski Thomas Schwinge PR target/119737 * config/gcn/gcn.cc (gcn_hsa_declare_function_name): Properly switch sections. 2025-05-15 Kwok Cheung Yeung * langhooks-def.h (lhd_omp_deep_mapping): Add new argument. * langhooks.cc (lhd_omp_deep_mapping): Likewise. * langhooks.h (omp_deep_mapping): Likewise. * omp-low.cc (allocate_omp_iterator_elems): Work on the supplied iterator set instead of the iterators in a supplied set of clauses. (free_omp_iterator_elems): Likewise. (lower_omp_target): Maintain vector of new iterators generated by deep-mapping. Allocate and free iterator element arrays using iterators found in clauses and in the new iterator vector. 2025-05-15 Kwok Cheung Yeung * gimplify.cc (enter_omp_iterator_loop_context): New function variant. (enter_omp_iterator_loop_context): Delegate to new variant. (exit_omp_iterator_loop_context): New function variant. (exit_omp_iterator_loop_context): Delegate to new variant. (assign_to_iterator_elems_array): New. (add_new_omp_iterators_entry): New. (add_new_omp_iterators_clause): Delegate to add_new_omp_iterators_entry. * gimplify.h (enter_omp_iterator_loop_context): New prototype. (enter_omp_iterator_loop_context): Remove default argument. (exit_omp_iterator_loop_context): Remove argument. (assign_to_iterator_elems_array): New prototype. (add_new_omp_iterators_entry): New prototype. (add_new_omp_iterators_clause): New prototype. * langhooks-def.h (lhd_omp_deep_mapping_cnt): Remove const from argument. (lhd_omp_deep_mapping): Likewise. * langhooks.cc (lhd_omp_deep_mapping_cnt): Likewise. (lhd_omp_deep_mapping): Likewise. * langhooks.h (omp_deep_mapping_cnt): Likewise. (omp_deep_mapping): Likewise. * omp-low.cc (lower_omp_map_iterator_expr): Delegate to assign_to_iterator_elems_array. (lower_omp_map_iterator_size): Likewise. (lower_omp_target): Remove sorry for deep mapping. 2025-05-15 Kwok Cheung Yeung * gimplify.cc (add_new_omp_iterators_clause): New. (build_omp_struct_comp_nodes): Add extra argument for loops sequence. Call add_new_omp_iterators_clause on newly generated clauses. (omp_accumulate_sibling_list): Add extra argument for loops sequence. Pass to calls to build_omp_struct_comp_nodes. Add iterators to newly generator clauses for struct accesses. (omp_build_struct_sibling_lists): Add extra argument for loops sequence. Pass to call to omp_accumulate_sibling_list. (gimplify_adjust_omp_clauses): Pass loops sequence to omp_build_struct_sibling_lists. 2025-05-15 Kwok Cheung Yeung * gimplify.cc (gimplify_omp_affinity): Use macros for accessing iterator elements. (compute_omp_iterator_count): Likewise. (build_omp_iterator_loop): Likewise. (remove_unused_omp_iterator_vars): Likewise. (build_omp_iterators_loops): Likewise. (enter_omp_iterator_loop_context_1): Likewise. (extract_base_bit_offset): Likewise. * omp-low.cc (lower_omp_map_iterator_expr): Likewise. (lower_omp_map_iterator_size): Likewise. (allocate_omp_iterator_elems): Likewise. (free_omp_iterator_elems): Likewise. * tree-inline.cc (copy_tree_body_r): Likewise. * tree-pretty-print.cc (dump_omp_iterators): Likewise. * tree.h (OMP_ITERATORS_VAR, OMP_ITERATORS_BEGIN, OMP_ITERATORS_END, OMP_ITERATORS_STEP, OMP_ITERATORS_ORIG_STEP, OMP_ITERATORS_BLOCK, OMP_ITERATORS_LABEL, OMP_ITERATORS_INDEX, OMP_ITERATORS_ELEMS, OMP_ITERATORS_COUNT, OMP_ITERATORS_EXPANDED_P): New macros. 2025-05-15 Kwok Cheung Yeung * gimplify.cc (omp_iterator_elems_length): New. (build_omp_iterators_loops): Change type of elements array to pointer of pointers if array length is non-constant, and assign size with indirect reference. Reorder elements added to iterator vector and add element containing the iteration count. Use omp_iterator_elems_length to compute element array size required. * gimplify.h (omp_iterator_elems_length): New prototype. * omp-low.cc (lower_omp_map_iterator_expr): Reorder elements read from iterator vector. If elements field is a pointer type, assign using pointer arithmetic followed by indirect reference, and return the field directly. (lower_omp_map_iterator_size): Reorder elements read from iterator vector. If elements field is a pointer type, assign using pointer arithmetic followed by indirect reference. (allocate_omp_iterator_elems): New. (free_omp_iterator_elems): New. (lower_omp_target): Call allocate_omp_iterator_elems before inserting loops sequence, and call free_omp_iterator_elems afterwards. * tree-pretty-print.cc (dump_omp_iterators): Print extra elements in iterator vector. 2025-05-15 Kwok Cheung Yeung Andrew Stubbs * gimplify.cc (compute_omp_iterator_count): Account for difference in loop boundaries in Fortran. (build_omp_iterator_loop): Change upper boundary condition for Fortran. Insert block statements into innermost loop. (remove_unused_omp_iterator_vars): Copy block subblocks of old iterator to new iterator and remove original. (contains_vars_1): New. (contains_vars): New. (extract_base_bit_offset): Add iterator argument. Remove iterator variables from base. Do not set variable_offset if the offset does not contain any remaining variables. (omp_accumulate_sibling_list): Add iterator argument to extract_base_bit_offset. * tree-pretty-print.cc (dump_block_node): Ignore BLOCK_SUBBLOCKS containing iterator block statements. 2025-05-15 Kwok Cheung Yeung * gimplify.cc (gimplify_scan_omp_clauses): Add argument for iterator loop sequence. Gimplify the clause decl and size into the iterator loop if iterators are used. (gimplify_omp_workshare): Add argument for iterator loops sequence in call to gimplify_scan_omp_clauses. (gimplify_omp_target_update): Call remove_unused_omp_iterator_vars and build_omp_iterators_loops. Add loop sequence as argument when calling gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses and building the Gimple statement. * tree-pretty-print.cc (dump_omp_clause): Call dump_omp_iterators for to/from clauses with iterators. * tree.cc (omp_clause_num_ops): Add extra operand for OMP_CLAUSE_FROM and OMP_CLAUSE_TO. * tree.h (OMP_CLAUSE_HAS_ITERATORS): Add check for OMP_CLAUSE_TO and OMP_CLAUSE_FROM. (OMP_CLAUSE_ITERATORS): Likewise. 2025-05-15 Kwok Cheung Yeung Andrew Stubbs * gimple-pretty-print.cc (dump_gimple_omp_target): Print expanded iterator loops. * gimple.cc (gimple_build_omp_target): Add argument for iterator loops sequence. Initialize iterator loops field. * gimple.def (GIMPLE_OMP_TARGET): Set GSS symbol to GSS_OMP_TARGET. * gimple.h (gomp_target): Set GSS symbol to GSS_OMP_TARGET. Add extra field for iterator loops. (gimple_build_omp_target): Add argument for iterator loops sequence. (gimple_omp_target_iterator_loops): New. (gimple_omp_target_iterator_loops_ptr): New. (gimple_omp_target_set_iterator_loops): New. * gimplify.cc (find_var_decl): New. (copy_omp_iterator): New. (remap_omp_iterator_var_1): New. (remap_omp_iterator_var): New. (remove_unused_omp_iterator_vars): New. (struct iterator_loop_info_t): New type. (iterator_loop_info_map_t): New type. (build_omp_iterators_loops): New. (enter_omp_iterator_loop_context_1): New. (enter_omp_iterator_loop_context): New. (enter_omp_iterator_loop_context): New. (exit_omp_iterator_loop_context): New. (gimplify_adjust_omp_clauses): Add argument for iterator loop sequence. Gimplify the clause decl and size into the iterator loop if iterators are used. (gimplify_omp_workshare): Call remove_unused_omp_iterator_vars and build_omp_iterators_loops for OpenMP target expressions. Add loop sequence as argument when calling gimplify_adjust_omp_clauses and building the Gimple statement. * gimplify.h (enter_omp_iterator_loop_context): New prototype. (exit_omp_iterator_loop_context): New prototype. * gsstruct.def (GSS_OMP_TARGET): New. * omp-low.cc (lower_omp_map_iterator_expr): New. (lower_omp_map_iterator_size): New. (finish_omp_map_iterators): New. (lower_omp_target): Add sorry if iterators used with deep mapping. Call lower_omp_map_iterator_expr before assigning to sender ref. Call lower_omp_map_iterator_size before setting the size. Insert iterator loop sequence before the statements for the target clause. * tree-nested.cc (convert_nonlocal_reference_stmt): Walk the iterator loop sequence of OpenMP target statements. (convert_local_reference_stmt): Likewise. (convert_tramp_reference_stmt): Likewise. * tree-pretty-print.cc (dump_omp_iterators): Dump extra iterator information if present. (dump_omp_clause): Call dump_omp_iterators for iterators in map clauses. * tree.cc (omp_clause_num_ops): Add operand for OMP_CLAUSE_MAP. (walk_tree_1): Do not walk last operand of OMP_CLAUSE_MAP. * tree.h (OMP_CLAUSE_HAS_ITERATORS): New. (OMP_CLAUSE_ITERATORS): New. 2025-05-15 Kwok Cheung Yeung * gimplify.cc (gimplify_omp_affinity): Use OMP_ITERATOR_DECL_P. (compute_omp_iterator_count): New. (build_omp_iterator_loop): New. (gimplify_omp_depend): Use OMP_ITERATOR_DECL_P, compute_omp_iterator_count and build_omp_iterator_loop. * tree-inline.cc (copy_tree_body_r): Use OMP_ITERATOR_DECL_P. * tree-pretty-print.cc (dump_omp_clause): Likewise. * tree.h (OMP_ITERATOR_DECL_P): New macro. 2025-05-15 Chung-Lin Tang Sandra Loosemore * doc/extend.texi: Adjust version references to 2.7 from 2.6. 2025-05-15 Chung-Lin Tang * config/gcn/gcn-tree.cc (gcn_goacc_reduction_setup): Fix array case copy source into reduction buffer. * config/nvptx/nvptx.cc (nvptx_expand_shared_addr): Move default size init setting place. (enum nvptx_builtins): Add NVPTX_BUILTIN_BAR_WARPSYNC. (nvptx_init_builtins): Add DEF() of nvptx_builtin_bar_warpsync. (nvptx_expand_builtin): Expand NVPTX_BUILTIN_BAR_WARPSYNC. (nvptx_goacc_reduction_setup): Fix array case copy source into reduction buffer. (nvptx_goacc_reduction_fini): Add bar.warpsync for at end of vector-mode reductions for sm_70 and above. 2025-05-15 Chung-Lin Tang * config/gcn/gcn-tree.cc (#include "omp-offload.h"): Add include. (#include "memmodel.h"): Add include. (gcn_array_reduction_buffers): New vec for holding DECLs for reduction buffer pointer variables. (gcn_lockfull_update): Add pointer type fold_converts. (gcn_reduction_update): Additions for handling ARRAY_TYPE, pointer to ARRAY_TYPE, and RECORD_TYPE reductions. (gcn_goacc_get_worker_red_decl): Adjust parameters to handle non-constant offset case. (gcn_goacc_get_worker_array_reduction_buffer): New function. (gcn_create_if_else_seq): New function. (gcn_create_do_while_loop_seq): New function. (gcn_goacc_reduction_setup): Adjustments to handle arrays and records. (gcn_goacc_reduction_init): Likewise. (gcn_goacc_reduction_fini): Likewise. (gcn_goacc_reduction_teardown): Likewise. * config/nvptx/nvptx.cc (nvptx_gen_shuffle): Properly generate V2SI shuffle using vec_extract op. (nvptx_expand_shared_addr): Adjustments to handle non-constant size. (nvptx_get_shared_red_addr): Adjust type/alignment calculations to use TYPE_SIZE/ALIGN_UNIT instead of machine mode based. (nvptx_get_shared_red_addr): New function with array_max_idx parameter. (nvptx_reduction_update): Additions for handling ARRAY_TYPE, pointer to ARRA_TYPE, and RECORD_TYPE reductions. (nvptx_goacc_reduction_setup): Likewise. (nvptx_goacc_reduction_init): Likewise. (nvptx_goacc_reduction_fini): Likewise. (nvptx_goacc_reduction_teardown): Likewise. * gimplify.cc (gimplify_scan_omp_clauses): Gimplify inside COMPONENT_REF and convert codes for OMP_CLAUSE_REDUCTION cases. Add DECL_P check for do_add/do_add_decl goto case. (gimplify_adjust_omp_clauses): Avoid GOMP_MAP_POINTER OMP_CLAUSE_SIZE handling for OpenACC kernels. Call omp_add_variable for ARRAY_REF index. Peel away array MEM_REF for decl lookup. * omp-low.cc (struct omp_context): Add 'hash_map *block_vars_map' field. (omp_copy_decl_2): Create/lookup using ctx->block_vars_map first. Add new copy into ctx->block_vars_map. (install_var_field): Add 'bool field_may_exist = false' parameter. Adjust lookup assertions. (delete_omp_context): Add delete of ctx->block_vars_map. (scan_sharing_clauses): Adjust calls to install_var_field. Adjust ARRAY_REF pointer type building to use decl type, rather than generic ptr_type_node. For ARRAY_REFs on offloaded constructs, also add base expression as field lookup key. (omp_reduction_init_op): Add ARRAY_TYPE and RECORD_TYPE init op construction. (oacc_array_reduction_bias): New function. (lower_oacc_reductions): Add array reduction handling code. Arrays use a different mode of IFN parameters, using additional 'array_addr' and 'array_max_idx' arguments. The LHS var is a simple integer for dependency ordering. (lower_omp_target): Adjust 'offload' condition for GOMP_MAP_POINTER case. Generate BUILT_IN_ALLOCA_WITH_ALIGN to create private copy for reductions of non-constant size types. * omp-oacc-neuter-broadcast.cc (worker_single_copy): Add 'hash_set *array_reduction_base_vars' parameter. Avoid propagation for SSA_NAMEs used for array reduction accesses. (neuter_worker_single): Add 'hash_set *array_reduction_base_vars' parameter. Adjust recursive calls to self and worker_single_copy. (oacc_do_neutering): Add 'hash_set *array_reduction_base_vars' parameter. Adjust call to neuter_worker_single. (execute_omp_oacc_neuter_broadcast): Add local 'hash_set array_reduction_base_vars' declaration. Collect MEM_REF base-pointer SSA_NAMEs of arrays into array_reduction_base_vars. Add '&array_reduction_base_vars' argument to call of oacc_do_neutering. * omp-offload.cc (#include "cfghooks.h"): Add include. (oacc_build_array_copy): New function. (oacc_build_array_copy_loop): New function. (oacc_build_indexed_ssa_loop): New function. (default_goacc_reduction): Adjustments to handle arrays. * omp-offload.h (oacc_build_array_copy): New declaration. (oacc_build_array_copy_loop): New declaration. (oacc_build_indexed_ssa_loop): New declaration. * tree-loop-distribution.cc (generate_memset_builtin): Under OpenACC, when last stmt of pre-header block is a UNIQUE(OACC_FORK) internal-fn, split a new basic block to serve as place of insertion, otherwise may fail later checking because UNIQUE(OACC_FORK) counts as control flow stmt. (generate_memcpy_builtin): Likewise. 2025-05-15 Sandra Loosemore * omp-general.cc (omp_context_selector_matches): Add an optional bool argument for the code elision case. * omp-general.h (omp_context_selector_matches): Likewise. 2025-05-15 Sandra Loosemore * omp-general.cc (omp_mangle_variant_name): New. (omp_check_for_duplicate_variant): New. (omp_copy_trait_set): New. (omp_trait_selectors_equivalent): New. (omp_combine_trait_sets): New. (omp_merge_context_selectors): New. * omp-general.h (omp_mangle_variant_name): Declare. (omp_check_for_duplicate_variant): Declare. (omp_merge_context_selectors): Declare. 2025-05-15 Chung-Lin Tang * gimple-expr.cc (copy_var_decl): Copy VAR_POINTS_TO_READONLY for VAR_DECLs. * omp-low.cc (lower_omp_target): Set VAR_POINTS_TO_READONLY for variables of receiver refs. * tree-pretty-print.cc (dump_omp_clause): Print OMP_CLAUSE_MAP_POINTS_TO_READONLY. (dump_generic_node): Print SSA_NAME_POINTS_TO_READONLY_MEMORY. * tree-ssanames.cc (make_ssa_name_fn): Set SSA_NAME_POINTS_TO_READONLY_MEMORY if DECL_POINTS_TO_READONLY is set. * tree.h (OMP_CLAUSE_MAP_POINTS_TO_READONLY): New macro. (VAR_POINTS_TO_READONLY): New macro. 2025-05-15 waffl3x Tobias Burnus * cgraphunit.cc (varpool_node::finalize_decl): Add assert. * gimplify.cc (gimplify_bind_expr): Handle C++ specific implementation details. 2025-05-15 Julian Brown Sandra Loosemore * gimplify.cc (gimplify_adjust_omp_clauses): Don't gimplify VIEW_CONVERT_EXPR away in GOMP_MAP_TO_GRID/GOMP_MAP_FROM_GRID clauses. * omp-low.cc (omp_noncontig_descriptor_type): Add SPAN field. (scan_sharing_clauses): Don't store descriptor size in its OMP_CLAUSE_SIZE field. (lower_omp_target): Add missing OMP_CLAUSE_MAP check. Add special-case string handling. Handle span and bias. Use low bound instead of zero as index for trailing full dimensions. 2025-05-15 Julian Brown * gimplify.cc (omp_group_last, omp_group_base): Add GOMP_MAP_TO_GRID, GOMP_MAP_FROM_GRID support. (gimplify_adjust_omp_clauses): Support new GOMP_MAP_GRID_DIM, GOMP_MAP_GRID_STRIDE mapping nodes. Don't crash on e.g. misuse of ADDR_EXPR in mapping clauses. * omp-general.cc (omp_parse_noncontiguous_array): New function. (omp_parse_access_method): Add noncontiguous array support. (omp_parse_structure_base): Add array-shaping support. (debug_omp_tokenized_addr): Add ACCESS_NONCONTIG_ARRAY, ACCESS_NONCONTIG_REF_TO_ARRAY token support. * omp-general.h (access_method_kinds): Add ACCESS_NONCONTIG_ARRAY and ACCESS_NONCONTIG_REF_TO_ARRAY access kinds. * omp-low.cc (omp_noncontig_descriptor_type): New function. (scan_sharing_clauses): Support noncontiguous array updates. (lower_omp_target): Likewise. * tree-pretty-print.cc (dump_omp_clause): Add GOMP_MAP_TO_GRID, GOMP_MAP_FROM_GRID, GOMP_MAP_GRID_DIM, GOMP_MAP_GRID_STRIDE map kinds. (dump_generic_node): Add stride support for OMP_ARRAY_SECTION. * tree.def (OMP_ARRAY_SECTION): Add stride argument. 2025-05-15 Julian Brown * gimplify.cc (dwarf2out.h): Include. (omp_maybe_get_descriptor_from_ptr): New function. (build_omp_struct_comp_nodes): Use above function to locate array descriptor when necessary. (omp_mapping_group_data, omp_mapping_group_ptr, omp_mapping_group_pset): New functions. (omp_instantiate_mapper): Handle inlining of "declare mapper" function bodies containing setup code (e.g. for Fortran). Handle pointers to derived types. Handle GOMP_MAP_MAPPING_GROUPs. * tree-pretty-print.cc (dump_omp_clause): Handle GOMP_MAP_MAPPING_GROUP. 2025-05-15 Julian Brown * gimplify.cc (gimplify_omp_ctx): Add IMPLICIT_MAPPERS field. (new_omp_context): Initialise IMPLICIT_MAPPERS hash map. (delete_omp_context): Delete IMPLICIT_MAPPERS hash map. (instantiate_mapper_info): New structs. (remap_mapper_decl_1, omp_mapper_copy_decl, omp_instantiate_mapper, omp_instantiate_implicit_mappers): New functions. (gimplify_scan_omp_clauses): Handle MAPPER_BINDING clauses. (gimplify_adjust_omp_clauses): Instantiate implicit declared mappers. (gimplify_omp_declare_mapper): New function. (gimplify_expr): Call above function. * langhooks-def.h (lhd_omp_finish_mapper_clauses, lhd_omp_mapper_lookup, lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): Add prototypes. (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES, LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define macros. (LANG_HOOK_DECLS): Add above macros. * langhooks.cc (lhd_omp_finish_mapper_clauses, lhd_omp_mapper_lookup, lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): New dummy functions. * langhooks.h (lang_hooks_for_decls): Add OMP_FINISH_MAPPER_CLAUSES, OMP_MAPPER_LOOKUP, OMP_EXTRACT_MAPPER_DIRECTIVE, OMP_MAP_ARRAY_SECTION hooks. * omp-general.h (omp_name_type): Add templatized struct, hash type traits (for omp_name_type specialization). (omp_mapper_list): Add struct. * tree-core.h (omp_clause_code): Add OMP_CLAUSE__MAPPER_BINDING_. * tree-pretty-print.cc (dump_omp_clause): Support GOMP_MAP_UNSET, GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping clauses. Support OMP_CLAUSE__MAPPER_BINDING_ and OMP_DECLARE_MAPPER. * tree.cc (omp_clause_num_ops, omp_clause_code_name): Add OMP_CLAUSE__MAPPER_BINDING_. * tree.def (OMP_DECLARE_MAPPER): New tree code. * tree.h (OMP_DECLARE_MAPPER_ID, OMP_DECLARE_MAPPER_DECL, OMP_DECLARE_MAPPER_CLAUSES): New defines. (OMP_CLAUSE__MAPPER_BINDING__ID, OMP_CLAUSE__MAPPER_BINDING__DECL, OMP_CLAUSE__MAPPER_BINDING__MAPPER): New defines. 2025-05-15 Julian Brown Thomas Schwinge Sandra Loosemore * gimplify.cc (gimplify_adjust_omp_clauses_1): Set OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P for OpenACC also. 2025-05-15 Julian Brown Paul-Antoine Arras Sandra Loosemore * gimplify.cc (gimplify_adjust_omp_clauses_1): Handle "oacc declare create" attribute. 2025-05-15 Julian Brown * gimplify.cc (omp_tsort_mark, omp_mapping_group): Move before gimplify_omp_ctx. Add constructor to omp_mapping_group. (gimplify_omp_ctx): Add DECL_DATA_CLAUSE field. (new_omp_context, delete_omp_context): Initialise and free above field. (omp_gather_mapping_groups_1): Use constructor for omp_mapping_group. (gimplify_scan_omp_clauses): Record mappings that might be lexically inherited. Don't remove GOMP_MAP_FIRSTPRIVATE_POINTER/GOMP_MAP_FIRSTPRIVATE_REFERENCE yet. (gomp_oacc_needs_data_present): New function. (gimplify_adjust_omp_clauses_1): Implement lexical inheritance behaviour for OpenACC. (gimplify_adjust_omp_clauses): Remove GOMP_MAP_FIRSTPRIVATE_POINTER/GOMP_MAP_FIRSTPRIVATE_REFERENCE here instead, after lexical inheritance is done. 2025-05-15 Chung-Lin Tang Backported from master: 2023-05-19 Chung-Lin Tang * builtins.cc (expand_builtin_omp_builtins): New function. (expand_builtin): Add expand cases for BUILT_IN_GOMP_BARRIER, BUILT_IN_OMP_GET_THREAD_NUM, BUILT_IN_OMP_GET_NUM_THREADS, BUILT_IN_OMP_GET_TEAM_NUM, and BUILT_IN_OMP_GET_NUM_TEAMS using expand_builtin_omp_builtins, enabled under -fopenmp-target=acc. * cgraphunit.cc (analyze_functions): Add call to omp_ompacc_attribute_tagging, enabled under -fopenmp-target=acc. * common.opt (fopenmp-target=): Add new option and enums. * config/nvptx/mkoffload.cc (main): Handle -fopenmp-target=. * config/nvptx/nvptx-protos.h (nvptx_expand_omp_get_num_threads): New prototype. (nvptx_mem_shared_p): Likewise. * config/nvptx/nvptx.cc (omp_num_threads_sym): New global static RTX symbol for number of threads in team. (omp_num_threads_align): New var for alignment of omp_num_threads_sym. (need_omp_num_threads): New bool for if any function references omp_num_threads_sym. (nvptx_option_override): Initialize omp_num_threads_sym/align. (write_as_kernel): Disable normal OpenMP kernel entry under OMPACC mode. (nvptx_declare_function_name): Disable shim function under OMPACC mode. Disable soft-stack under OMPACC mode. Add generation of neutering init code under OMPACC mode. (nvptx_output_set_softstack): Return "" under OMPACC mode. (nvptx_expand_call): Set parallelism to vector for function calls with "ompacc for" attached. (nvptx_expand_oacc_fork): Set mode to GOMP_DIM_VECTOR under OMPACC mode. (nvptx_expand_oacc_join): Likewise. (nvptx_expand_omp_get_num_threads): New function. (nvptx_mem_shared_p): New function. (nvptx_mach_max_workers): Return 1 under OMPACC mode. (nvptx_mach_vector_length): Return 32 under OMPACC mode. (nvptx_single): Add adjustments for OMPACC mode, which have parallel-construct fork/joins, and regions of code where neutering is dynamically determined. (nvptx_reorg): Enable neutering under OMPACC mode when "ompacc for" attribute is attached to function. Disable uniform-simt when under OMPACC mode. (nvptx_file_end): Write __nvptx_omp_num_threads out when needed. (nvptx_goacc_fork_join): Return true under OMPACC mode. * config/nvptx/nvptx.h (struct GTY(()) machine_function): Add omp_parallel_predicate and omp_fn_entry_num_threads_reg fields. * config/nvptx/nvptx.md (unspecv): Add UNSPECV_GET_TID, UNSPECV_GET_NTID, UNSPECV_GET_CTAID, UNSPECV_GET_NCTAID, UNSPECV_OMP_PARALLEL_FORK, UNSPECV_OMP_PARALLEL_JOIN entries. (nvptx_shared_mem_operand): New predicate. (gomp_barrier): New expand pattern. (omp_get_num_threads): New expand pattern. (omp_get_num_teams): New insn pattern. (omp_get_thread_num): Likewise. (omp_get_team_num): Likewise. (get_ntid): Likewise. (nvptx_omp_parallel_fork): Likewise. (nvptx_omp_parallel_join): Likewise. * expr.cc (expand_expr_real_1): Call expand_var_decl target hook. * flag-types.h (omp_target_mode_kind): New flag value enum. * gimplify.cc (struct gimplify_omp_ctx): Add 'bool ompacc' field. (gimplify_scan_omp_clauses): Handle OMP_CLAUSE__OMPACC_. (gimplify_adjust_omp_clauses): Likewise. (gimplify_omp_ctx_ompacc_p): New function. (gimplify_omp_for): Handle combined loops under OMPACC. * lto-wrapper.cc (append_compiler_options): Add OPT_fopenmp_target_. * omp-builtins.def (BUILT_IN_OMP_GET_THREAD_NUM): Remove CONST. (BUILT_IN_OMP_GET_NUM_THREADS): Likewise. * omp-expand.cc (remove_exit_barrier): Disable addressable-var processing for parallel construct child functions under OMPACC mode. (expand_oacc_for): Add OMPACC mode handling. (get_target_arguments): Force thread_limit clause value to 1 under OMPACC mode. (expand_omp): Under OMPACC mode, avoid child function expanding of GIMPLE_OMP_PARALLEL. * omp-general.cc (omp_extract_for_data): Adjustments for OMPACC mode. * omp-low.cc (struct omp_context): Add 'bool ompacc_p' field. (scan_sharing_clauses): Handle OMP_CLAUSE__OMPACC_. (ompacc_ctx_p): New function. (scan_omp_parallel): Handle OMPACC mode, avoid creating child function. (scan_omp_target): Tag "ompacc"/"ompacc for" attributes for target construct child function, remove OMP_CLAUSE__OMPACC_ clauses. (lower_oacc_head_mark): Handle OMPACC mode cases. (lower_omp_for): Adjust OMP_FOR kind from OpenMP to OpenACC kinds, add vector/gang clauses as needed. Add other OMPACC handling. (lower_omp_taskreg): Add call to lower_oacc_head_tail for OMPACC case. (lower_omp_target): Do OpenACC gang privatization under OMPACC case. (lower_omp_teams): Forward OpenACC privatization variables to outer target region under OMPACC mode. (lower_omp_1): Do OpenACC gang privatization under OMPACC case for GIMPLE_BIND. * omp-offload.cc (ompacc_supported_clauses_p): New function. (struct target_region_data): New struct type for tree walk. (scan_fndecl_for_ompacc): New function. (scan_omp_target_region_r): New function. (scan_omp_target_construct_r): New function. (omp_ompacc_attribute_tagging): New function. (oacc_dim_call): Add OMPACC case handling. (execute_oacc_device_lower): Make parts explicitly only OpenACC enabled. (pass_oacc_device_lower::gate): Enable pass under OMPACC mode. * omp-offload.h (omp_ompacc_attribute_tagging): New prototype. * opts.cc (finish_options): Only allow -fopenmp-target= when -fopenmp and no -fopenacc. * target-insns.def (gomp_barrier): New defined insn pattern. (omp_get_thread_num): Likewise. (omp_get_num_threads): Likewise. (omp_get_team_num): Likewise. (omp_get_num_teams): Likewise. * tree-core.h (enum omp_clause_code): Add new OMP_CLAUSE__OMPACC_ entry for internal clause. * tree-nested.cc (convert_nonlocal_omp_clauses): Handle OMP_CLAUSE__OMPACC_. * tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE__OMPACC_. * tree.cc (omp_clause_num_ops): Add OMP_CLAUSE__OMPACC_ entry. (omp_clause_code_name): Likewise. * tree.h (OMP_CLAUSE__OMPACC__FOR): New macro for OMP_CLAUSE__OMPACC_. 2025-05-15 Andrew Stubbs * tree-vect-data-refs.cc (vect_analyze_data_refs): Workaround an address-space bug. 2025-05-15 Tobias Burnus * builtin-types.def (BT_FN_VOID_PTRMODE): Add. (BT_FN_PTRMODE_PTRMODE_INT_PTR): Add. * gimplify.cc (gimplify_bind_expr): Diagnose missing uses_allocators clause. (gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses, gimplify_omp_workshare): Handle uses_allocators. * omp-builtins.def (BUILT_IN_OMP_INIT_ALLOCATOR, BUILT_IN_OMP_DESTROY_ALLOCATOR): Add. * omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_USES_ALLOCATORS and OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR clauses. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_USES_ALLOCATORS. * tree.cc (omp_clause_num_ops, omp_clause_code_name): Likewise. * tree-pretty-print.cc (dump_omp_clause): Handle it. * tree.h (OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR, OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE, OMP_CLAUSE_USES_ALLOCATORS_TRAITS): New. 2025-05-15 Tobias Burnus Sandra Loosemore * omp-oacc-kernels-decompose.cc (top_level_omp_for_in_stmt, decompose_kernels_region_body): Handle GIMPLE_DEBUG like simple assignment. 2025-05-15 Andrew Stubbs * omp-builtins.def (BUILT_IN_GOMP_ENABLE_PINNED_MODE): New. * omp-low.cc (omp_enable_pinned_mode): New function. (execute_lower_omp): Call omp_enable_pinned_mode. 2025-05-15 Andrew Stubbs * common.opt: Add -foffload-memory and its enum values. * coretypes.h (enum offload_memory): New. * doc/invoke.texi: Document -foffload-memory. 2025-05-15 Kwok Cheung Yeung * omp-expand.cc (expand_oacc_for): Convert .tile variable to diff_type before multiplying. * omp-general.cc (omp_extract_for_data): Use accumulated precision of all collapsed for-loops as precision of iteration variable, up to the precision of a long long. 2025-05-15 Chung-Lin Tang Paul-Antoine Arras * omp-low.cc (install_var_field): Add new 'tree key_expr = NULL_TREE' default parameter. Set splay-tree lookup key to key_expr instead of var if key_expr is non-NULL. Adjust call to install_parm_decl. Update comments. (scan_sharing_clauses): Use clause tree expression as splay-tree key for map/to/from and OpenACC firstprivate cases when installing the variable field into the send/receive record type. (maybe_lookup_field_in_outer_ctx): Add code to search through construct clauses instead of entirely based on splay-tree lookup. (lower_oacc_reductions): Adjust to find map-clause of reduction variable, then create receiver-ref. (lower_omp_target): Adjust to lookup var field using clause expression. 2025-05-15 Andrew Stubbs * dwarf2out.cc (add_location_or_const_value_attribute): Set DW_AT_address_class, if appropriate. 2025-05-15 Andrew Stubbs * dwarf2out.cc (notional_parents_list): New file variable. (gen_subprogram_die): Record offload kernel functions in notional_parents_list. (fixup_notional_parents): New function. (dwarf2out_finish): Call fixup_notional_parents. (dwarf2out_c_finalize): Reset notional_parents_list. 2025-05-15 Julian Brown * omp-offload.cc (oacc_thread_numbers): Add VF_BY_VECTORIZER parameter. Add overloaded wrapper for previous arguments & behaviour. (oacc_xform_loop): Lower vector loops to iterate a multiple of omp_max_vf times over contiguous steps on non-SIMT targets. 2025-05-15 Cesar Philippidis Julian Brown Kwok Cheung Yeung Tobias Burnus Thomas Schwinge Paul-Antoine Arras * gimplify.cc (omp_group_base): Handle GOMP_MAP_DECLARE_ALLOCATE and GOMP_MAP_DECLARE_DEALLOCATE. (gimplify_adjust_omp_clauses): Likewise. * omp-low.cc (scan_sharing_clauses): Update handling of OpenACC declare create, declare copyin and declare deviceptr to have local lifetimes. (convert_to_firstprivate_int): Handle pointer types. (convert_from_firstprivate_int): Likewise. Create local storage for the values being pointed to. Add new orig_type argument. Use VIEW_CONVERT also for vectors. (lower_omp_target): Handle GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}. Add orig_type argument to convert_from_firstprivate_int call. Allow pointer types with GOMP_MAP_FIRSTPRIVATE_INT. Don't privatize firstprivate VLAs. * tree-pretty-print.cc (dump_omp_clause): Handle GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}. 2025-05-15 Julian Brown Tobias Burnus Sandra Loosemore * gimplify.cc (localize_reductions): Rewrite references for OMP_CLAUSE_PRIVATE also. Do not create local variable for privatized arrays as the size is not directly known by the type. 2025-05-15 Cesar Philippidis Julian Brown Sandra Loosemore * gimplify.cc (privatize_reduction): New struct. (localize_reductions_r, localize_reductions): New functions. (gimplify_omp_for): Call localize_reductions. (gimplify_omp_workshare): Likewise. * omp-low.cc (lower_oacc_reductions): Handle localized reductions. Create fewer temp vars. * tree-core.h (omp_clause_code): Add OMP_CLAUSE_REDUCTION_PRIVATE_DECL documentation. * tree.cc (omp_clause_num_ops): Bump number of ops for OMP_CLAUSE_REDUCTION to 6. (walk_tree_1): Adjust accordingly. * tree.h (OMP_CLAUSE_REDUCTION_PRIVATE_DECL): Add macro. 2025-05-15 Cesar Philippidis Chung-Lin Tang * gimplify.cc (omp_add_variable): Enable firstprivate reduction variables. 2025-05-15 Cesar Philippidis * omp-low.cc (lower_oacc_head_mark): Don't mark OpenACC auto loops as independent inside acc parallel regions. 2025-05-15 Cesar Philippidis Julian Brown Tobias Burnus Kwok Cheung Yeung * omp-low.cc (maybe_lookup_field_in_outer_ctx): New function. (convert_to_firstprivate_int): New function. (convert_from_firstprivate_int): New function. (lower_omp_target): Enable GOMP_MAP_FIRSTPRIVATE_INT in OpenACC. Remove unused variable. 2025-05-15 Nathan Sidwell Tom de Vries Thomas Schwinge Julian Brown * doc/invoke.texi (fopenacc-dim): Document syntax for using runtime value from environment variable. * omp-offload.cc (oacc_parse_default_dims): Implement it. 2025-05-15 Julian Brown Cesar Philippidis * config/nvptx/nvptx.cc (nvptx_propagate_unified): New. (nvptx_split_blocks): Call it for cond_uni insn. (nvptx_expand_cond_uni): New. (enum nvptx_builtins): Add NVPTX_BUILTIN_COND_UNI. (nvptx_init_builtins): Initialize it. (nvptx_expand_builtin): Handle NVPTX_BUILTIN_COND_UNI. (nvptx_generate_vector_shuffle): Change integral SHIFT operand to tree BITS operand. (nvptx_vector_reduction): New. (nvptx_adjust_reduction_type): New. (nvptx_goacc_reduction_setup): Use it to adjust the type of ref_to_res. (nvptx_goacc_reduction_init): Don't update LHS if it doesn't exist. (nvptx_goacc_reduction_fini): Call nvptx_vector_reduction for vector. Use it to adjust the type of ref_to_res. (nvptx_goacc_reduction_teardown): Call nvptx_adjust_reduction_type. * config/nvptx/nvptx.md (cond_uni): New pattern. * gimplify.cc (gimplify_adjust_omp_clauses): Add DECL_P check for OMP_CLAUSE_TASK_REDUCTION. * omp-low.cc (lower_oacc_reductions): Handle GOMP_MAP_FIRSTPRIVATE_POINTER. * omp-offload.cc (default_goacc_reduction): Likewise. 2025-05-15 Cesar Philippidis James Norris Julian Brown Tobias Burnus Thomas Schwinge * gimplify.cc (enum gimplify_omp_var_data): Add GOVD_DEVICETPR. (oacc_default_clause): Privatize fortran common blocks. (omp_notice_variable): Add GOVD_DEVICEPTR attribute when appropriate. Defer the expansion of DECL_VALUE_EXPR for common block decls. (gimplify_scan_omp_clauses): Add GOVD_DEVICEPTR attribute when appropriate. (gimplify_adjust_omp_clauses_1): Set GOMP_MAP_FORCE_DEVICEPTR for implicit deviceptr mappings. 2025-05-15 Chung-Lin Tang Kwok Cheung Yeung Paul-Antoine Arras PR other/76739 * builtin-types.def (BT_FN_VOID_INT_SIZE_PTR_PTR_PTR_VAR): New type. * gimplify.cc (omp_group_base): Handle GOMP_MAP_NONCONTIG_ARRAY_*. (gimplify_scan_omp_clauses): Handle OMP_TARGET_UPDATE. (gimplify_adjust_omp_clauses): Skip gimplification of OMP_CLAUSE_SIZE of non-contiguous array maps (which is a TREE_LIST). * omp-builtins.def (BUILT_IN_GOACC_DATA_START): Adjust function type to new BT_FN_VOID_INT_SIZE_PTR_PTR_PTR_VAR. * omp-expand.cc (expand_omp_target): Add non-contiguous array descriptor pointers to variadic arguments. * omp-low.cc (append_field_to_record_type): New function. (create_noncontig_array_descr_type): Likewise. (create_noncontig_array_descr_init_code): Likewise. (scan_sharing_clauses): For non-contiguous array map kinds, check for supported dimension structure, and install non-contiguous array variable into current omp_context. (reorder_noncontig_array_clauses): New function. (scan_omp_target): Call reorder_noncontig_array_clauses to place non-contiguous array map clauses at beginning of clause sequence. (lower_omp_target): Add handling for non-contiguous array map kinds, add all created non-contiguous array descriptors to gimple_omp_target_data_arg. * tree-pretty-print.cc (dump_omp_clause): Handle GOMP_MAP_NONCONTIG_ARRAY_*. 2025-05-15 Sandra Loosemore * Makefile.in (REVISION_s): Change default message.