aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2021-10-15c++: array cv-quals and template specialization [PR101402]Jason Merrill6-17/+204
PRs 101402, 102033, etc. demonstrated that the fix for PR92010 wasn't handling all cases of the CWG1001/1322 issue with parameter type qual stripping and arrays with templates. The problem turned out to be in determine_specialization, which did an extra substitution without the 92010 fix and then complained that the result didn't match. But just removing that wrong/redundant code meant that we were accepting specializations with different numbers of parameters, because the code in fn_type_unification that compares types in this case wasn't checking for length mismatch. After fixing that, I realized that fn_type_unification couldn't tell the difference between variadic and non-variadic function types, because the args array doesn't include the terminal void we use to indicate non-variadic function type. So I added it, and made the necessary adjustments. Thanks to qingzhe "nick" huang <nickhuang99@hotmail.com> for the patch that led me to dig more into this, and the extensive testcases. PR c++/51851 PR c++/101402 PR c++/102033 PR c++/102034 PR c++/102039 PR c++/102044 gcc/cp/ChangeLog: * pt.c (determine_specialization): Remove redundant code. (fn_type_unification): Check for mismatched length. (type_unification_real): Ignore terminal void. (get_bindings): Don't stop at void_list_node. * class.c (resolve_address_of_overloaded_function): Likewise. gcc/testsuite/ChangeLog: * g++.dg/template/fnspec2.C: New test. * g++.dg/template/parm-cv1.C: New test. * g++.dg/template/parm-cv2.C: New test. * g++.dg/template/parm-cv3.C: New test.
2021-10-15Fortran: validate shape of arrays in constructors against declarationsHarald Anlauf6-6/+68
gcc/fortran/ChangeLog: PR fortran/102685 * decl.c (match_clist_expr): Set rank/shape of clist initializer to match LHS. * resolve.c (resolve_structure_cons): In a structure constructor, compare shapes of array components against declared shape. gcc/testsuite/ChangeLog: PR fortran/102685 * gfortran.dg/derived_constructor_char_1.f90: Fix invalid code. * gfortran.dg/pr70931.f90: Likewise. * gfortran.dg/transfer_simplify_2.f90: Likewise. * gfortran.dg/pr102685.f90: New test. Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
2021-10-15Darwin: Update specs handling '-r'.Iain Sandoe1-15/+18
We were not wrapping all the default libraries in checks for whether they should be used. We were also wasting a process launch calling dsymutil for 'r' link lines (a NOP in practice). Order the checks that exclude linking from most likely to occur, downwards. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/darwin.h (LINK_COMMAND_SPEC_A): Update 'r' handling to skip gomp and itm when r or nodefaultlibs is given. (DSYMUTIL_SPEC): Do not call dsymutil for '-r' link lines. Update ordering of exclusions, remove duplicate 'v' addition (collect2 will add this from the main command line).
2021-10-15Darwin: Revise handling of some driver opts.Iain Sandoe4-264/+228
Darwin has a user convenience feature where some linker options are exposed at the driver level (so one can type '-all_load' instead of '-Wl,-all_load' or '-Xlinker -all_load'). We retain this feature, but now these options are all marked as 'Driver' and we process them as early as possible so that they get allocated to the right toolchain command. There are a couple of special cases where these driver opts are used multiple times, or to control operations on more than one command (e.g. dynamiclib). These are handled specially and we then add %<xxxx specs for the commands that _do not_ need them. NOTE: the ordering of 'shared' and 'dynamiclib' is significant, hence they are placed out of alphabetical order at the start. Likewise, we keep a couple of cases where a negative option originally appeared after the positive alternate, potentially overriding it. When we report an error with %e, it seems necessary to strip the option before doing so, otherwise it survives to the cc1 command line (%e does not appear to abort the program before this). Right now there is no mechanism to split up the 'variable portion' (%*) of the matched spec string, so where we have some driver specs that take 2 or 3 arguments, these cannot be processed here, but are deferred until the LINK_SPEC, where they are copied verbatim. We have a 'safe' version of the macOS version string, that has been sanity- checked and truncated to minor version. If the 'tiny' (3rd) portion of the value is not significant, it is better to use the safe one in version-compare(). Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/darwin-driver.c (darwin_driver_init): Revise comments, handle filelist and framework options in specs instead of code. * config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Update to handle link specs that are really driver ones. (DARWIN_CC1_SPEC): Likewise. (CPP_SPEC): Likewise. (SYSROOT_SPEC): Append space. (LINK_SYSROOT_SPEC): Remove most driver link specs. (STANDARD_STARTFILE_PREFIX_2): Update link-related specs. (STARTFILE_SPEC): Likewise. (ASM_MMACOSX_VERSION_MIN_SPEC): Fix line wrap. (ASM_SPEC): Update driver-related specs. (ASM_FINAL_SPEC): Likewise. * config/darwin.opt: Remove now unused option aliases. * config/i386/darwin.h (EXTRA_ASM_OPTS): Ensure space after opt. (ASM_SPEC): Update driver-related specs.
2021-10-15Allow early sets of SSE hard registers from standard_sse_constant_p.Roger Sayle1-1/+3
My previous patch, which was intended to reduce the differences seen by the combination of -march=cascadelake and -m32, has additionally found some more instances where this combination behaves differently to regular x86_64-pc-linux-gnu. The middle-end always, and backends usually, use emit_move_insn to emit/expand move instructions allowing the backend control over placing things in constant pools, adding REG_EQUAL notes, and so on. Several of the AVX512 built-in expanders bypass this logic, and instead generate moves directly using emit_insn(gen_rtx_SET (dst,src)). For example, i386-expand.c line 12004 contains: for (i = 0; i < 8; i++) emit_insn (gen_rtx_SET (xmm_regs[i], const0_rtx)); I suspect that in this case, loading of standard_sse_constant_p, my change to require loading of likely spilled hard registers via a pseudo is perhaps overly strict, so this patch/fix reallows these immediate constants values to be loaded directly prior to reload. 2021-10-15 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386.c (ix86_hardreg_mov_ok): For vector modes, allow standard_sse_constant_p immediate constants.
2021-10-15Darwin, D: Fix D bootstrap, include tm-dwarf2.h.Iain Sandoe1-0/+1
After r12-4432-g7bfe7d634f60b0a9 Darwin fails to bootstrap with D enabled since there is no definition of either DWARF2_DEBUG_INFO or PREFERRED_DEBUGGING_TYPE. Fixed here by adding the tm-dwarf2.h file to tm_d_file for Darwin. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config.gcc: Add tm-dwarf2.h to tm_d-file.
2021-10-15Ranger : Do not process abnormal ssa-names.Andrew MacLeod4-8/+39
* gimple-range-fold.h (gimple_range_ssa_p): Don't process names that occur in abnormal phis. * gimple-range.cc (gimple_ranger::range_on_edge): Return false for abnormal and EH edges. * gimple-ssa-evrp.c (rvrp_folder::value_of_expr): Ditto. (rvrp_folder::value_on_edge): Ditto. (rvrp_folder::value_of_stmt): Ditto. (hybrid_folder::value_of_expr): Ditto for ranger queries. (hybrid_folder::value_on_edge): Ditto. (hybrid_folder::value_of_stmt): Ditto. * value-query.cc (gimple_range_global): Always return a range if the type is supported.
2021-10-15Consistently use "rG" constraint for copy instruction in move patternsJohn David Anglin1-20/+20
2021-10-15 John David Anglin <danglin@gcc.gnu.org> gcc/ChangeLog: * config/pa/pa.md: Consistently use "rG" constraint for copy instruction in move patterns.
2021-10-15amdgcn: fix up offload debug linking with LLVM 13Andrew Stubbs3-29/+26
Between LLVM 9 and LLVM 13 the attribute works differently in several ways, and this needs to be allowed for in GCC and mkoffload independently. This patch fixes up mkoffload when debug info is enabled, which is made more complicated because the configure tests checks whether the attribute option is accepted silently, but does not check if the assembler actually sets the ELF flags for that attribute, and mkoffload needs to mimick that behaviour exactly. The patch therefore removes some of the conditionals. gcc/ChangeLog: * config/gcn/gcn-hsa.h (S_FIJI): Set unconditionally. (S_900): Likewise. (S_906): Likewise. * config/gcn/gcn.c: Hard code SRAM ECC settings for old architectures. * config/gcn/mkoffload.c (ELFABIVERSION_AMDGPU_HSA): Rename to ... (ELFABIVERSION_AMDGPU_HSA_V3): ... this. (ELFABIVERSION_AMDGPU_HSA_V4): New. (SET_SRAM_ECC_UNSUPPORTED): New. (copy_early_debug_info): Create elf flags to match the other objects. (main): Just let the attribute flags pass through.
2021-10-15tree-optimization/102752: Fix determining precission of reduction_varStefan Schulze Frielinghaus1-7/+8
While determining the precission of reduction_var an SSA_NAME instead of its TREE_TYPE is used. Streamlined with other TREE_TYPE (reduction_var) uses. gcc/ChangeLog: * tree-loop-distribution.c (reduction_var_overflows_first): Pass the type of reduction_var as first argument as it is also done for the load type. (loop_distribution::transform_reduction_loop): Add missing TREE_TYPE while determining precission of reduction_var.
2021-10-15Make signness explicit in tree-ssa/pr102736.cAldy Hernandez1-2/+2
This test is failing on ppc64* due to different default signness for chars. Tested on x86-64 Linux and ppc64le Linux. PR testsuite/pr102751 gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr102736.c: Make sign explicit.
2021-10-15Always default to DWARF2_DEBUG if not specified, warn about deprecated STABSRichard Biener6-30/+20
This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE is not specified by the target and errors out if DWARF DWARF is not supported. It also makes us warn when STABS is enabled but not the preferred debugging type and removes the corresponding diagnostic from the Ada frontend. The warnings are pruned from the testsuite output via prune_gcc_output. The following target configurations now explicitely default to STABS: pdp11-*-* pdp11 is a.out, dwarf support is difficult hppa[12]*-*-hpux10* does not support DWARF hppa[12]*-*-hpux11* likewise note that the hppa configs have been deprecated. Targets with DWARF support will now see > ./cc1 -quiet t.c -gstabs t.c: warning: STABS debugging information is obsolete and not supported anymore that is, -gstabs will still generate STABS but use will be diagnosed on targets where DWARF is available. I have built all targets from contrib/config-list.mk to make sure we don't run into the #error and the following makes the STABS usage explicit for pdp11 and hppa with SOM. This completes the series of deprecating STABS for GCC 12. 2021-09-21 Richard Biener <rguenther@suse.de> gcc/ * defaults.h (PREFERRED_DEBUGGING_TYPE): Choose DWARF2_DEBUG when not set. * toplev.c (process_options): Warn when STABS debugging is enabled but not the preferred format. * config/pa/som.h (PREFERRED_DEBUGGING_TYPE): Define to DBX_DEBUG. * config/pdp11/pdp11.h (PREFERRED_DEBUGGING_TYPE): Likewise. gcc/ada/ * gcc-interface/misc.c (gnat_post_options): Do not warn about DBX_DEBUG use here. gcc/testsuite/ * lib/prune.exp: Prune STABS obsoletion message.
2021-10-15c/102763 - fix ICE with invalid input to GIMPLE FERichard Biener2-0/+18
This fixes an ICE for the failure to verify we're dereferencing a pointer before throwing that at build_simple_mem_ref. 2021-10-15 Richard Biener <rguenther@suse.de> PR c/102763 gcc/c/ * gimple-parser.c (c_parser_gimple_postfix_expression_after_primary): Check for a pointer do be dereferenced by ->. gcc/testsuite/ * gcc.dg/gimplefe-error-12.c: New testcase.
2021-10-15ipa/102762 - fix ICE with invalid __builtin_va_arg_pack () useRichard Biener2-1/+18
We have to be careful to not break the argument space calculation. If there's not enough arguments just do not append any. 2021-10-15 Richard Biener <rguenther@suse.de> PR ipa/102762 * tree-inline.c (copy_bb): Avoid underflowing nargs. * gcc.dg/torture/pr102762.c: New testcase.
2021-10-15AVX512FP16: Enhance vector shuffle builtinsHongyu Wang5-1/+280
Support HFmode vector shuffle by creating HImode subreg when expanding permutation expr. gcc/ChangeLog: * config/i386/i386-expand.c (ix86_expand_vec_perm): Convert HFmode input operand to HImode. (ix86_vectorize_vec_perm_const): Likewise. * config/i386/sse.md (*avx512bw_permvar_truncv16siv16hi_1_hf): New define_insn. (*avx512f_permvar_truncv8siv8hi_1_hf): Likewise. gcc/testsuite/ChangeLog: * gcc.target/i386/avx512fp16-builtin_shuffle-1.c: New test. * gcc.target/i386/avx512fp16-pr101846.c: Ditto. * gcc.target/i386/avx512fp16-pr94680.c: Ditto.
2021-10-15middle-end/102682 - avoid invalid subreg on the LHSRichard Biener1-1/+2
The following avoids generating (insn 6 5 7 2 (set (subreg:OI (concatn/v:TI [ (reg:DI 92 [ buffer ]) (reg:DI 93 [ buffer+8 ]) ]) 0) (subreg:OI (reg/v:V8SI 85 [ __x ]) 0)) "t.ii":76:21 74 {*movoi_internal_avx} (nil)) via store_bit_field_1 when we try to store excess data into a register allocated temporary. The case was supposed to /* Use the subreg machinery either to narrow OP0 to the required words... but the check ensured only an register-aligned but not a large enough piece. The following adds such missed check which ends up decomposing the set to (insn 6 5 7 (set (subreg:DI (reg/v:TI 84 [ buffer ]) 0) (subreg:DI (reg/v:V8SI 85 [ __x ]) 0)) "t.ii":76:21 -1 (nil)) (insn 7 6 0 (set (subreg:DI (reg/v:TI 84 [ buffer ]) 8) (subreg:DI (reg/v:V8SI 85 [ __x ]) 8)) "t.ii":76:21 -1 (nil)) 2021-10-11 Richard Biener <rguenther@suse.de> PR middle-end/102682 * expmed.c (store_bit_field_1): Ensure a LHS subreg would not create a paradoxical subreg.
2021-10-15AVX512FP16: Fix ICE for 2 v4hf vector concatHongyu Wang2-1/+18
For V4HFmode, doing vector concat like __builtin_shufflevector (a, b, {0, 1, 2, 3, 4, 5, 6, 7}) could trigger ICE since it is not handled in ix86_vector_init (). Handle HFmode like HImode to avoid such ICE. gcc/ChangeLog: * config/i386/i386-expand.c (ix86_expand_vector_init): For half_vector concat for HFmode, handle them like HImode. gcc/testsuite/ChangeLog: * gcc.target/i386/avx512fp16-v4hf-concat.c: New test.
2021-10-15AVX512FP16: Fix testcase for complex intrinsicHongyu Wang6-2/+8
-march=cascadelake which contains -mavx512vl produces unmatched scan for vf[c]maddcsh test, so add -mno-avx512vl to vf[c]maddcsh-1a.c. Also add scan for vblendmps to vf[c]maddcph tests to check correctness. gcc/testsuite/ChangeLog: * gcc.target/i386/avx512fp16-vfcmaddcph-1a.c: Add scan for vblendmps. * gcc.target/i386/avx512fp16-vfmaddcph-1a.c: Likewise. * gcc.target/i386/avx512fp16vl-vfcmaddcph-1a.c: Likewise. * gcc.target/i386/avx512fp16vl-vfmaddcph-1a.c: Likewise. * gcc.target/i386/avx512fp16-vfmaddcsh-1a.c: Add -mno-avx512vl. * gcc.target/i386/avx512fp16-vfcmaddcsh-1a.c: Likewise.
2021-10-14c++: instantiate less for constant foldingJason Merrill4-29/+50
I've been experimenting with a change to make all inline functions implicitly constexpr; this revealed that we are instantiating too aggressively for speculative constant evaluation, leading to ordering difficulties with e.g. is_a_helper<cgraph_node*>::test. This patch tries to avoid such instantiation until we actually need the function definition to determine whether a call is constant, by limiting the initial instantiation of all used functions to manifestly-constant-evaluated expressions, and checking whether the function arguments are constant before instantiating the function. This change resulted in a change in the diagnostics for a few library tests due to instantiating the function with the static_assert later (during constant evaluation) than we did before (during instantiation of the intermediate function). gcc/cp/ChangeLog: * constexpr.c (cxx_bind_parameters_in_call): Replace new_call parameter with fun. (cxx_eval_call_expression): Call it before instantiation. (cxx_eval_outermost_constant_expr): Only instantiate fns when manifestly_const_eval. * typeck2.c (check_narrowing): This context is manifestly constant-evaluated. libstdc++-v3/ChangeLog: * testsuite/20_util/integer_comparisons/greater_equal_neg.cc: * testsuite/20_util/integer_comparisons/greater_neg.cc: * testsuite/20_util/integer_comparisons/less_equal_neg.cc: Adjust expected message. * testsuite/lib/prune.exp: Prune 'in constexpr expansion'. gcc/testsuite/ChangeLog: * g++.dg/ext/vla22.C: Don't expect a narrowing error. * g++.dg/cpp0x/constexpr-inst1.C: New test.
2021-10-14Add target int128 to testcase.Andrew MacLeod1-0/+1
gcc/testsuite * gcc.dg/pr102738.c: Add target int128.
2021-10-15Daily bump.GCC Administrator8-1/+365
2021-10-14Add ability to use full resolving path solver in the backward threader.Aldy Hernandez1-6/+35
The path solver runs in two modes: a quick mode which assumes any unknown SSA names are VARYING, and a fully resolving mode using the ranger. The backward threader currently uses the quick mode, because the fully resolving mode was not available initially. Since we now have the ability in the solver (used by the hybrid threader), I thought it'd be useful to have the knob for when the time comes. Note that enabling the fully resolving mode will require some experimenting, as enabling it would likely render other jump threading passes irrelevant (VRP threading comes to mind). There should be no functional changes as the resolver is set to false. Tested on x86-64 Linux. gcc/ChangeLog: * tree-ssa-threadbackward.c (class back_threader): Add m_resolve. (back_threader::back_threader): Same. (back_threader::resolve_phi): Try to solve without looking back if possible. (back_threader::find_paths_to_names): Same. (try_thread_blocks): Pass resolve argument to back threader. (pass_early_thread_jumps::execute): Same.
2021-10-14Cleanup --params for backward threader.Aldy Hernandez3-48/+3
The new backward threader makes some of the --param knobs used to control it questionable at best or no longer applicable at worst. The fsm-maximum-phi-arguments param is unused and can be removed. The max-fsm-thread-length param is block based which is a bit redundant, since we already restrict paths based on instruction estimates. The max-fsm-thread-paths restricts the total number of threadable paths in a function. We probably don't need this. Besides, the forward threader has no such restriction. Tested on x86-64 Linux. gcc/ChangeLog: * doc/invoke.texi: Remove max-fsm-thread-length, max-fsm-thread-paths, and fsm-maximum-phi-arguments. * params.opt: Same. * tree-ssa-threadbackward.c (back_threader::back_threader): Remove argument. (back_threader_registry::back_threader_registry): Same. (back_threader_profitability::profitable_path_p): Remove param_max_fsm_thread-length. (back_threader_registry::register_path): Remove m_max_allowable_paths.
2021-10-14Minor cleanups to backward threader.Aldy Hernandez1-4/+1
Tested on x86-64 Linux. gcc/ChangeLog: * tree-ssa-threadbackward.c (class back_threader): Make m_imports an auto_bitmap. (back_threader::~back_threader): Do not release m_path.
2021-10-14c-family: Support DFP printf/scanf formats for C2XJoseph Myers6-14/+154
When I enabled various decimal floating-point features for C2X / stopped them being diagnosed with -pedantic for C2X, I missed the format checking support. The DFP printf and scanf formats are included in C2X. Thus, adjust the data for those formats so that they are no longer diagnosed with -std=c2x -Wformat -pedantic. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c-family/ * c-format.c (printf_length_specs, scanf_length_specs) (print_char_table, scan_char_table): Support DFP formats for C2X. * c-format.h (TEX_D32, TEX_D64, TEX_D128): Remove. (T2X_D32, T2X_D64, T2X_D128): New macros. gcc/testsuite/ * gcc.dg/format/c11-dfp-printf-1.c, gcc.dg/format/c11-dfp-scanf-1.c, gcc.dg/format/c2x-dfp-printf-1.c, gcc.dg/format/c2x-dfp-scanf-1.c: New tests.
2021-10-14libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPCRaphael Moreira Zinsly1-0/+24
Without dwarf2 unwind tables available _Unwind_Backtrace() is not able to return the full backtrace. This patch adds a fallback function on powerpc to get the backtrace by doing a backchain, this code was originally at glibc. libgcc/ChangeLog: * config/rs6000/linux-unwind.h (struct rt_sigframe): Move it to outside of get_regs() in order to use it in another function, this is done twice: for __powerpc64__ and for !__powerpc64__. (struct trace_arg): New struct. (struct layout): New struct. (ppc_backchain_fallback): New function. * unwind.inc (_Unwind_Backtrace): Look for _URC_NORMAL_STOP code state and call MD_BACKCHAIN_FALLBACK. gcc/testsuite/ChangeLog: * gcc.target/powerpc/unwind-backchain.c: New test.
2021-10-14Fortran: generate error message for negative elements in SHAPE arrayHarald Anlauf2-1/+14
gcc/fortran/ChangeLog: PR fortran/102717 * simplify.c (gfc_simplify_reshape): Replace assert by error message for negative elements in SHAPE array. gcc/testsuite/ChangeLog: PR fortran/102717 * gfortran.dg/reshape_shape_2.f90: New test.
2021-10-14Fortran: fix order of checks for the SHAPE intrinsicHarald Anlauf2-7/+13
gcc/fortran/ChangeLog: PR fortran/102716 * check.c (gfc_check_shape): Reorder checks so that invalid KIND arguments can be detected. gcc/testsuite/ChangeLog: PR fortran/102716 * gfortran.dg/shape_10.f90: New test.
2021-10-14Simplification for right shift.Andrew MacLeod2-0/+70
When the first operand of a signed right shift is zero or negative one, the RHS doesn't matter and the shift can be converted to a copy. PR tree-optimization/102738 gcc/ * vr-values.c (simplify_using_ranges::simplify): Handle RSHIFT_EXPR. gcc/testsuite * gcc.dg/pr102738.c: New.
2021-10-14openmp, fortran: Add support for OpenMP declare variant directive in FortranKwok Cheung Yeung34-148/+2870
2021-10-14 Kwok Cheung Yeung <kcy@codesourcery.com> gcc/c-family/ * c-omp.c (c_omp_check_context_selector): Rename to omp_check_context_selector and move to omp-general.c. (c_omp_mark_declare_variant): Rename to omp_mark_declare_variant and move to omp-general.c. gcc/c/ * c-parser.c (c_finish_omp_declare_variant): Change call from c_omp_check_context_selector to omp_check_context_selector. Change call from c_omp_mark_declare_variant to omp_mark_declare_variant. gcc/cp/ * decl.c (omp_declare_variant_finalize_one): Change call from c_omp_mark_declare_variant to omp_mark_declare_variant. * parser.c (cp_finish_omp_declare_variant): Change call from c_omp_check_context_selector to omp_check_context_selector. gcc/fortran/ * gfortran.h (enum gfc_statement): Add ST_OMP_DECLARE_VARIANT. (enum gfc_omp_trait_property_kind): New. (struct gfc_omp_trait_property): New. (gfc_get_omp_trait_property): New macro. (struct gfc_omp_selector): New. (gfc_get_omp_selector): New macro. (struct gfc_omp_set_selector): New. (gfc_get_omp_set_selector): New macro. (struct gfc_omp_declare_variant): New. (gfc_get_omp_declare_variant): New macro. (struct gfc_namespace): Add omp_declare_variant field. (gfc_free_omp_declare_variant_list): New prototype. * match.h (gfc_match_omp_declare_variant): New prototype. * openmp.c (gfc_free_omp_trait_property_list): New. (gfc_free_omp_selector_list): New. (gfc_free_omp_set_selector_list): New. (gfc_free_omp_declare_variant_list): New. (gfc_match_omp_clauses): Add extra optional argument. Handle end of clauses for context selectors. (omp_construct_selectors, omp_device_selectors, omp_implementation_selectors, omp_user_selectors): New. (gfc_match_omp_context_selector): New. (gfc_match_omp_context_selector_specification): New. (gfc_match_omp_declare_variant): New. * parse.c: Include tree-core.h and omp-general.h. (decode_omp_directive): Handle 'declare variant'. (case_omp_decl): Include ST_OMP_DECLARE_VARIANT. (gfc_ascii_statement): Handle ST_OMP_DECLARE_VARIANT. (gfc_parse_file): Initialize omp_requires_mask. * symbol.c (gfc_free_namespace): Call gfc_free_omp_declare_variant_list. * trans-decl.c (gfc_get_extern_function_decl): Call gfc_trans_omp_declare_variant. (gfc_create_function_decl): Call gfc_trans_omp_declare_variant. * trans-openmp.c (gfc_trans_omp_declare_variant): New. * trans-stmt.h (gfc_trans_omp_declare_variant): New prototype. gcc/ * omp-general.c (omp_check_context_selector): Move from c-omp.c. (omp_mark_declare_variant): Move from c-omp.c. (omp_context_name_list_prop): Update for Fortran strings. * omp-general.h (omp_check_context_selector): New prototype. (omp_mark_declare_variant): New prototype. gcc/testsuite/ * gfortran.dg/gomp/declare-variant-1.f90: New test. * gfortran.dg/gomp/declare-variant-10.f90: New test. * gfortran.dg/gomp/declare-variant-11.f90: New test. * gfortran.dg/gomp/declare-variant-12.f90: New test. * gfortran.dg/gomp/declare-variant-13.f90: New test. * gfortran.dg/gomp/declare-variant-14.f90: New test. * gfortran.dg/gomp/declare-variant-15.f90: New test. * gfortran.dg/gomp/declare-variant-16.f90: New test. * gfortran.dg/gomp/declare-variant-17.f90: New test. * gfortran.dg/gomp/declare-variant-18.f90: New test. * gfortran.dg/gomp/declare-variant-19.f90: New test. * gfortran.dg/gomp/declare-variant-2.f90: New test. * gfortran.dg/gomp/declare-variant-2a.f90: New test. * gfortran.dg/gomp/declare-variant-3.f90: New test. * gfortran.dg/gomp/declare-variant-4.f90: New test. * gfortran.dg/gomp/declare-variant-5.f90: New test. * gfortran.dg/gomp/declare-variant-6.f90: New test. * gfortran.dg/gomp/declare-variant-7.f90: New test. * gfortran.dg/gomp/declare-variant-8.f90: New test. * gfortran.dg/gomp/declare-variant-9.f90: New test. libgomp/ * testsuite/libgomp.fortran/declare-variant-1.f90: New test.
2021-10-14rs6000: Fix memory leak in rs6000_density_testRichard Sandiford1-9/+8
rs6000_density_test has an early exit test between a call to get_loop_body and the corresponding free. This would lead to a memory leak if the early exit is taken. gcc/ * config/rs6000/rs6000.c (rs6000_density_test): Move early exit test further up the function.
2021-10-14arm: Remove add_stmt_cost hookRichard Sandiford1-40/+0
The arm implementation of add_stmt_cost was added alongside arm_builtin_vectorization_cost. At that time it was necessary to override the latter when overriding the former, since default_add_stmt_cost didn't indirect through the builtin_vectorization_cost target hook: int stmt_cost = default_builtin_vectorization_cost (kind, vectype, misalign); That was fixed by: | 2014-06-06 Bingfeng Mei <bmei@broadcom.com> | | * targhooks.c (default_add_stmt_cost): Call target specific | hook instead of default one. so the arm definition of add_stmt_cost is now equivalent to the default. gcc/ * config/arm/arm.c (arm_add_stmt_cost): Delete. (TARGET_VECTORIZE_ADD_STMT_COST): Delete.
2021-10-14Add forgotten documentation of param ipa-cp-recursive-freq-factorMartin Jambor1-0/+4
Martin Liška has noticed that I forgot to document the recently added parameter in the invoke.texi documentation. This patch fixes it. Tested by running make info and make pdf and examining the output. gcc/ChangeLog: 2021-10-14 Martin Jambor <mjambor@suse.cz> * doc/invoke.texi (Optimize Options): Add entry for ipa-cp-recursive-freq-factor.
2021-10-14Fix mips testsuite fallout from vectorizer changesJeff Law1-1/+1
gcc/testsuite * gcc.target/mips/msa-insert-split.c: Turn off vectorizer.
2021-10-14sve: optimize add reduction patternsTamar Christina2-0/+30
The following loop does a conditional reduction using an add: #include <stdint.h> int32_t f (int32_t *restrict array, int len, int min) { int32_t iSum = 0; for (int i=0; i<len; i++) { if (array[i] >= min) iSum += array[i]; } return iSum; } for this we currently generate: mov z1.b, #0 mov z2.s, w2 mov z3.d, z1.d ptrue p2.b, all ld1w z0.s, p0/z, [x0, x3, lsl 2] cmpge p1.s, p2/z, z0.s, z2.s add x3, x3, x4 sel z0.s, p1, z0.s, z3.s add z1.s, p0/m, z1.s, z0.s whilelo p0.s, w3, w1 where the SEL is unneeded as it's selecting between 0 or a value. This can be optimized to just doing the conditional add on p1 instead of p0. After this patch we generate: mov z2.s, w2 mov z0.b, #0 ptrue p1.b, all ld1w z1.s, p0/z, [x0, x3, lsl 2] cmpge p0.s, p0/z, z1.s, z2.s add x3, x3, x4 add z0.s, p0/m, z0.s, z1.s whilelo p0.s, w3, w1 and so we drop the SEL and the 0 move. gcc/ChangeLog: * match.pd: New rule. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/pred-cond-reduc.c: New test.
2021-10-14Fix ICE in insert_access.Jan Hubicka1-8/+8
gcc/ChangeLog: PR ipa/102557 * ipa-modref-tree.h (modref_access_node::update2): Also check that parm_offset is unchanged. (modref_ref_node::insert_access): Fix updating of parameter.
2021-10-14Add FIXME note to backward threader.Aldy Hernandez1-0/+7
There's a limitation in the path discovery bits in the backward threader that I ran into recently and I'd like to document it so we don't lose track of it. Basically we stop looking if we find a threadable path through a PHI, without taking into account that there could be multiple paths through a PHI that resolve the path. For example: x_5 = PHI <10(4), 20(5), ...> if (x_5 > 5) I don't remember how we ended up skipping this, but it could existing behavior from the old bits. It probably skipped multiple threads through a PHI since the generic copier couldn't re-using existing threading paths anyhow. Documenting for later fixing. gcc/ChangeLog: * tree-ssa-threadbackward.c (back_threader::resolve_phi): Add FIXME note.
2021-10-14Fix predcom-3.c on arc-elf after vectorizer changesJeff Law1-1/+1
gcc/testsuite * gcc.dg/tree-ssa/predcom-3.c: Disable vectorizer.
2021-10-14tree-optimization/102659 - really avoid undef overflow in if-conversionRichard Biener3-8/+33
This plugs the remaining hole of POINTER_PLUS_EXPR with undefined overflow. Unfortunately we have to go through some lengths to not put invariant conversions into the loop body since that confuses the vectorizers gather/scatter discovery which relies on identifying an invariant component of plus and minus expressions. We can emit those in the loop preheader but then we have to accept that being non-empty when looking for the LOOP_VECTORIZED internal function call in the vectorizer. 2021-10-14 Richard Biener <rguenther@suse.de> PR tree-optimization/102659 * tree-if-conv.c (if_convertible_gimple_assign_stmt_p): Also rewrite pointer typed undefined overflow operations. (predicate_statements): Likewise. Make sure to emit invariant conversions in the preheader. * tree-vectorizer.c (vect_loop_vectorized_call): Look through non-empty preheaders. * tree-data-ref.c (dr_analyze_indices): Strip useless conversions to the MEM_REF base type.
2021-10-14Eliminate AUTODETECT_VALUE usage in options.Martin Liska3-41/+25
gcc/ChangeLog: * common.opt: Stop using AUTODETECT_VALUE and use EnabledBy where possible. * opts.c: Enable OPT_fvar_tracking with optimize >= 1. * toplev.c (AUTODETECT_VALUE): Remove macro. (process_options): Simplify by using EnabledBy and OPT_fvar_tracking. Use OPTION_SET_P macro instead of AUTODETECT_VALUE.
2021-10-14aarch64: Fix pointer parameter type in LD1 Neon intrinsicsJonathan Wright1-2/+2
The pointer parameter to load a vector of signed values should itself be a signed type. This patch fixes two instances of this unsigned- signed implicit conversion in arm_neon.h. gcc/ChangeLog: 2021-10-14 Jonathan Wright <jonathan.wright@arm.com> * config/aarch64/arm_neon.h (vld1_s8_x3): Use signed type for pointer parameter. (vld1_s32_x3): Likewise.
2021-10-14Do not call range_on_path_entry for SSAs defined within the pathAldy Hernandez2-1/+26
In the path solver, when requesting the range of an SSA for which we know nothing, we ask the ranger for the range incoming to the path. We do this by asking for all the incoming ranges to the path entry block and unioning them. The problem here is that we're asking for a range on path entry for an SSA which *is* defined in the path, but for which we know nothing about: some_global.1_2 = some_global; _3 = (char) some_global.1_2; This request is causing us to ask for range_on_edge of _3 on the incoming edges to the path. This is a bit of nonsensical request because _3 isn't live on entry to the path, so ranger correctly returns UNDEFINED. The proper thing is to avoid asking this in the first place. I have added a relevant assert, since it doesn't make sense to call range_on_path_entry for SSAs defined within the path. Tested on x86-64 Linux. PR tree-optimization/102736 gcc/ChangeLog: PR tree-optimization/102736 * gimple-range-path.cc (path_range_query::range_on_path_entry): Assert that the requested range is defined outside the path. (path_range_query::ssa_range_in_phi): Do not call range_on_path_entry for SSA names that are defined within the path. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr102736.c: New test.
2021-10-14Darwin: Update quotes in driver warning messages.Iain Sandoe1-22/+30
This adds some missing quotes around options and option argument terms in warning messages. Avoid contractions in warning messages. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/darwin-driver.c (darwin_find_version_from_kernel): Quote internal identifiers and avoid contractions in warnings. (darwin_default_min_version): Likewise. (darwin_driver_init): Likewise.
2021-10-14ipa-cp: Propagation boost for recursion generated valuesMartin Jambor2-81/+84
Recursive call graph edges, even when they are hot and important for the compiled program, can never have frequency bigger than one, even when the actual time savings in the next recursion call are not realized just once but depend on the depth of recursion. The current IPA-CP effect propagation code did not take that into account and just used the frequency, thus severely underestimating the effect. This patch artificially boosts values taking part in such calls. If a value feeds into itself through a recursive call, the frequency of the edge is multiplied by a parameter with default value of 6, basically assuming that the recursion will take place 6 times. This value can of course be subject to change. Moreover, values which do not feed into themselves but which were generated for a self-recursive call with an arithmetic pass-function (aka the 548.exchange "hack" which however is generally applicable for recursive functions which count the recursion depth in a parameter) have the edge frequency multiplied as many times as there are generated values in the chain. In essence, we will assume they are all useful. This patch partially fixes the current situation when we fail to optimize 548.exchange with PGO. In the benchmark one recursive edge count overwhelmingly dominates all other counts in the program and so we fail to perform the first cloning (for the nonrecursive entry call) because it looks totally insignificant. gcc/ChangeLog: 2021-07-16 Martin Jambor <mjambor@suse.cz> * params.opt (ipa-cp-recursive-freq-factor): New. * ipa-cp.c (ipcp_value): Switch to inline initialization. New members scc_no, self_recursion_generated_level, same_scc and self_recursion_generated_p. (ipcp_lattice::add_value): Replaced parameter unlimited with same_lat_gen_level, usit it determine limit of values and store it to the value. (ipcp_lattice<valtype>::print): Dump the new fileds. (allocate_and_init_ipcp_value): Take same_lat_gen_level as a new parameter and store it to the new value. (self_recursively_generated_p): Removed. (propagate_vals_across_arith_jfunc): Use self_recursion_generated_p instead of self_recursively_generated_p, store self generation level to such values. (value_topo_info<valtype>::add_val): Set scc_no. (value_topo_info<valtype>::propagate_effects): Multiply frequencies of recursively feeding values and self generated values by appropriate new factors.
2021-10-14aarch64: Remove redundant flag_vect_cost_model testRichard Sandiford1-109/+105
The aarch64 version of add_stmt_cost has a redundant test of flag_vect_cost_model. The current structure was based on the contemporaneous definition of default_add_stmt_cost, but g:d6d1127249564146429009e0682f25bd58d7a791 later removed the flag_vect_cost_model test from the default version. gcc/ * config/aarch64/aarch64.c (aarch64_add_stmt_cost): Remove redundant test for flag_vect_cost_model.
2021-10-14Add debug helpers for auto_bitmap.Aldy Hernandez2-0/+15
Using debug() on an auto_bitmap from gdb doesn't work because the implicit conversion from auto_bitmap to bitmap_head doesn't work from within a debugging session. This patch adds the convenience functions for auto_bitmap. gcc/ChangeLog: * bitmap.c (debug): New overloaded function for auto_bitmaps. * bitmap.h (debug): Same.
2021-10-14[Ada] reenable ada83 library unit renaming errorAlexandre Oliva1-4/+5
for gcc/ada/ChangeLog * par-ch10.adb (P_Compilation_Unit): Reenable ada83 library unit renaming test and error.
2021-10-14AVX512FP16: Adjust builtin for mask complex fmaHongyu Wang13-216/+375
Current mask/mask3 implementation for complex fma contains duplicated parameter in macro, which may cause error at -O0. Refactor macro implementation to builtins to avoid potential error. For round intrinsic with NO_ROUND as input, ix86_erase_embedded_rounding erases embedded_rounding upspec but could break other emit_insn in expanders. Skip those expanders with multiple emit_insn for this function and check rounding in expander with subst. gcc/ChangeLog: * config/i386/avx512fp16intrin.h (_mm512_mask_fcmadd_pch): Adjust builtin call. (_mm512_mask3_fcmadd_pch): Likewise. (_mm512_mask_fmadd_pch): Likewise (_mm512_mask3_fmadd_pch): Likewise (_mm512_mask_fcmadd_round_pch): Likewise (_mm512_mask3_fcmadd_round_pch): Likewise (_mm512_mask_fmadd_round_pch): Likewise (_mm512_mask3_fmadd_round_pch): Likewise (_mm_mask_fcmadd_sch): Likewise (_mm_mask3_fcmadd_sch): Likewise (_mm_mask_fmadd_sch): Likewise (_mm_mask3_fmadd_sch): Likewise (_mm_mask_fcmadd_round_sch): Likewise (_mm_mask3_fcmadd_round_sch): Likewise (_mm_mask_fmadd_round_sch): Likewise (_mm_mask3_fmadd_round_sch): Likewise (_mm_fcmadd_round_sch): Likewise * config/i386/avx512fp16vlintrin.h (_mm_mask_fmadd_pch): Adjust builtin call. (_mm_mask3_fmadd_pch): Likewise (_mm256_mask_fmadd_pch): Likewise (_mm256_mask3_fmadd_pch): Likewise (_mm_mask_fcmadd_pch): Likewise (_mm_mask3_fcmadd_pch): Likewise (_mm256_mask_fcmadd_pch): Likewise (_mm256_mask3_fcmadd_pch): Likewise * config/i386/i386-builtin.def: Add mask3 builtin for complex fma, and adjust mask_builtin to corresponding expander. * config/i386/i386-expand.c (ix86_expand_round_builtin): Skip eraseing embedded rounding for expanders that emits multiple insns. * config/i386/sse.md (complexmove): New mode_attr. (<avx512>_fmaddc_<mode>_mask1<round_expand_name>): New expander. (<avx512>_fcmaddc_<mode>_mask1<round_expand_name>): Likewise. (avx512fp16_fmaddcsh_v8hf_mask1<round_expand_name>): Likewise. (avx512fp16_fcmaddcsh_v8hf_mask1<round_expand_name>): Likewise. (avx512fp16_fcmaddcsh_v8hf_mask3<round_expand_name>): Likewise. (avx512fp16_fmaddcsh_v8hf_mask3<round_expand_name>): Likewise. * config/i386/subst.md (round_embedded_complex): New subst. gcc/testsuite/ChangeLog: * gcc.target/i386/avx-1.c: Add new mask3 builtins. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-23.c: Ditto. * gcc.target/i386/avx512fp16-vfcmaddcsh-1a.c: Add scanning for mask/mask3 intrinsic. * gcc.target/i386/avx512fp16-vfmaddcsh-1a.c: Ditto. * gcc.target/i386/avx512fp16-vfcmaddcsh-1c.c: New test for -mavx512vl. * gcc.target/i386/avx512fp16-vfmaddcsh-1c.c: Ditto.
2021-10-14Adjust testcase for O2 vectorization[Wuninitialized]liuhongt1-2/+5
It looks like it's just the the location of the warning that's off, the warning itself is still issued but it's swallowed by the dg-prune-output directive. Since the test was added to verify the fix for an ICE without vectorization I think disabling vectorization should be fine. Ideally, we would understand why the location is wrong so let's keep this bug open and add a comment to the test referencing this bug. gcc/testsuite/ChangeLog: * g++.dg/warn/Wuninitialized-13.C: Add -fno-tree-vectorize.
2021-10-14Fix TARGET_SOFT_FLOAT patterns in pa.mdJohn David Anglin1-2/+83
2021-10-13 John David Anglin <danglin@gcc.gnu.org> gcc/ChangeLog: * config/pa/pa.md (cbranchsf4): Disable if TARGET_SOFT_FLOAT. (cbranchdf4): Likewise. Add missing move patterns for TARGET_SOFT_FLOAT.