2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-03-03 15:06:19 +08:00
Commit Graph

191191 Commits

Author SHA1 Message Date
David Malcolm
c4b8f3730a analyzer: reject ((i + 1 > 0) && (i < 0)) for integers [PR94362]
PR analyzer/94362 reports a false positive from
-Wanalyzer-null-dereference seen when analyzing OpenSSL.

The root cause is that the analyzer's path feasibility checker
erroneously considers this to be feasible:
  (R + 1 > 0) && (R < 0)
for int R (the return value from sk_EVP_PKEY_ASN1_METHOD_num),
whereas it's not satisfiable for any int R.

This patch makes the constraint manager try harder to reject
such combinations of conditions, fixing the false positive;
perhaps in the longer term we ought to use an SMT solver.

gcc/analyzer/ChangeLog:
	PR analyzer/94362
	* constraint-manager.cc (bound::ensure_closed): Convert param to
	enum bound_kind.
	(range::constrained_to_single_element): Likewise.
	(range::add_bound): New.
	(constraint_manager::add_constraint): Handle SVAL + OFFSET
	compared to a constant.
	(constraint_manager::get_ec_bounds): Rewrite in terms of
	range::add_bound.
	(constraint_manager::eval_condition): Reject if range::add_bound
	fails.
	(selftest::test_constant_comparisons): Add test coverage for
	various impossible combinations of integer comparisons.
	* constraint-manager.h (enum bound_kind): New.
	(struct bound): Likewise.
	(bound::ensure_closed): Convert to param to enum bound_kind.
	(struct range): Convert to...
	(class range): ...this, making fields private.
	(range::add_bound): New decls.
	* region-model.cc (region_model::add_constraint): Fail if
	constraint_manager::add_constraint fails.

gcc/testsuite/ChangeLog:
	PR analyzer/94362
	* gcc.dg/analyzer/pr94362-1.c: New test.
	* gcc.dg/analyzer/pr94362-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-20 18:43:28 -05:00
David Malcolm
f5a9d76be8 analyzer: add regression test [PR103685]
PR analyzer/103685 reports a false positive from -Wanalyzer-null-dereference
seen at -O2 with GCC 11.  I can reproduce it with GCC 11, but not with
trunk; this patch adds a reduced test case that reproduces it with
GCC 11 as a regression test for GCC 12 onwards.

gcc/testsuite/ChangeLog:
	PR analyzer/103685
	* gcc.dg/analyzer/torture/pr103685.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-20 18:42:33 -05:00
Sandra Loosemore
d2ad748eee Fortran: Fix scope for OMP AFFINITY clause iterator variables [PR103695]
gfc_finish_var_decl was confused by the undocumented overloading of
the proc_name field in struct gfc_namespace to contain iterator
variables for the OpenMP AFFINITY clause, causing it to insert the
decls in the wrong scope.  This patch adds a new distinct field to
hold these variables.

2022-01-20  Sandra Loosemore  <sandra@codesourcery.com>

	PR fortran/103695
	PR fortran/102621

	gcc/fortran
	* gfortran.h (struct gfc_namespace) Add omp_affinity_iterator
	field.
	* dump-parse-tree.cc (show_iterator): Use it.
	* openmp.cc (gfc_match_iterator): Likewise.
	(resolve_omp_clauses): Likewise.
	* trans-decl.cc (gfc_finish_var_decl): Likewise.
	* trans-openmp.cc (handle_iterator): Likewise.

	gcc/testsuite/
	* gfortran.dg/gomp/affinity-clause-3.f90: Adjust pattern.
	* gfortran.dg/gomp/pr102621.f90: New.
	* gfortran.dg/gomp/pr103695.f90: New.
2022-01-20 13:29:48 -08:00
Jason Merrill
cc01cd9397 c++: designator for base class member [PR101405]
A C++20 designator must name a direct non-static member of the class; in
this case it names a member of a base class, and we should give an error
instead of crashing.

	PR c++/101405

gcc/cp/ChangeLog:

	* decl.cc (reshape_init_class): Reject designator for a member of
	another class.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/desig20.C: New test.
2022-01-20 15:23:43 -05:00
Marek Polacek
30b38394b4 c++: Add test for fixed PR [PR102338]
This was fixed by r12-6025 and is sufficiently different from
noexcept71.C that I think we should add it.

	PR c++/102338

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/noexcept2.C: New test.
2022-01-20 15:02:21 -05:00
Patrick Palka
2f34d7ef3d c++: add testcase for recently fixed PR [PR103631]
We accept this testcase after r12-6773.

	PR c++/103631

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/nontype-class51.C: New test.
2022-01-20 13:12:16 -05:00
Richard Biener
5c12507f5d middle-end/100786 - constant folding from incompatible alias
The following avoids us ICEing doing constant folding from variables
with aliases of different types.  The issue appears both in
folding and CCP and FRE can do more fancy stuff to still constant
fold cases where the load is smaller than the initializer so
defer it to there.

2022-01-20  Richard Biener  <rguenther@suse.de>

	PR middle-end/100786
	* gimple-fold.cc (get_symbol_constant_value): Only return
	values of compatible type to the symbol.

	* gcc.dg/torture/pr100786.c: New testcase.
2022-01-20 16:50:34 +01:00
Richard Earnshaw
62eb400b51 aarch64: allow ld1/stq in test output [PR102517]
Following the changes to the inline memcpy operations get expanded, we
now generate ld1/st1 using a 128-bit vector register rather than ldp
with Q registers.  The behaviour is equivalent, so relax the tests to
permit either variant.

gcc/testsuite/ChangeLog:

	PR target/102517
	* gcc.target/aarch64/cpymem-q-reg_1.c: Allow ld1 and st1 for the
	memcpy expansion.
2022-01-20 15:44:11 +00:00
Andrew MacLeod
6b73c07ec2 Only add equivalencies that are still valid.
When equivalencies sets are merged, each member of the set should be queried
to ensure its still valid rather than a bulk union.

	* value-relation.cc (relation_oracle::valid_equivs): Query and add
	if valid members of a set.
	(equiv_oracle::register_equiv): Call valid_equivs rather than
	bitmap direct operations.
	(path_oracle::register_equiv): Ditto.
	* value-relation.h (relation_oracle::valid_equivs): New prototype.
2022-01-20 10:26:01 -05:00
Patrick Palka
09845ad756 c++: CTAD inside alias template [PR91911, PR103672]
In the first testcase below, when processing the alias template
ConstSpanType, transparency of alias template specializations means we
replace SpanType<T> with its instantiated definition.  But this
instantiation lowers the level of the CTAD placeholder for span{T()} from
2 to 1, and so the later instantiation of ConstSpanType<int> erroneously
substitutes this CTAD placeholder with the template argument at level 1
index 0, i.e. with int, before we get a chance to perform the CTAD.

Although we represent CTAD placeholders as template parameters, we never
actually want to replace them via tsubst.  So this patch adjusts tsubst
to handle CTAD placeholders by simply substituting the template and
returning a new CTAD placeholder.  Moreover, this means that the level
of a CTAD placeholder doesn't matter, so we may as well give them all
the same level.  This patch gives them the special level 0.

The change in tsubst_decl removes a likely dead !CHECKING_P safeguard
added in 2017, which would otherwise now get triggered for variables
with CTAD placeholder types (since their level is 0).

	PR c++/91911
	PR c++/103672

gcc/cp/ChangeLog:

	* pt.cc (keep_template_parm): Punt on a level 0 template parm.
	(tsubst_decl) <case VAR_DECL>: Remove !CHECKING_P safeguard.
	(tsubst) <case TEMPLATE_TYPE_PARM>: Handle CTAD placeholders
	specially.
	(make_auto_1): Add defaulted 'level' parameter.
	(make_template_placeholder): Pass 0 as 'level' to make_auto_1.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction101.C: New test.
	* g++.dg/cpp1z/class-deduction101a.C: New test.
	* g++.dg/cpp1z/class-deduction101b.C: New test.
	* g++.dg/cpp1z/class-deduction102.C: New test.
	* g++.dg/cpp1z/class-deduction102a.C: New test.
	* g++.dg/cpp1z/class-deduction102b.C: New test.
	* g++.dg/cpp1z/class-deduction103.C: New test.
2022-01-20 09:25:49 -05:00
Patrick Palka
2cda2bfa3f c++: consistently diagnose bare CTAD placeholder in fn return type
Relax slightly the existing check for diagnosing a bare CTAD placeholder
as the return type of a function declarator to also handle the abstract
declarator case.

gcc/cp/ChangeLog:

	* decl.cc (grokdeclarator): Diagnose a CTAD placeholder as
	function return type even when !funcdecl_p.

gcc/testsuite/ChangeLog:

	* g++.dg/other/pr88187.C: Adjust expected C++17 diagnostic.
2022-01-20 09:22:27 -05:00
Richard Biener
d63d9c3dd1 target/100784 - avoid ICE with folding __builtin_ia32_shufpd
This avoids ICEing when there is no LHS on the call by following
what foldings of other builtins do in , namely not folding.

2022-01-20  Richard Biener  <rguenther@suse.de>

	PR target/100784
	* config/i386/i386.cc (ix86_gimple_fold_builtin): Check for
	LHS before folding __builtin_ia32_shufpd and friends.
2022-01-20 15:19:15 +01:00
Martin Liska
ce9e0cc5da MAINTAINERS: adjust requested email address
ChangeLog:

	* MAINTAINERS: Adjust email address based on IRC request.
2022-01-20 13:40:42 +01:00
Jonathan Wakely
109f8af3d3 libstdc++: Use Clang attribute instead of __constinit
Clang doesn't support the __constinit extension that we use pre-C++20,
but it does have its own equivalent attribute that can be used instead.

This makes it a little easier to use Clang to build libstdc++ (which
isn't supported. but is sometimes attempted for esoteric targets).

libstdc++-v3/ChangeLog:

	* src/c++11/cxx11-ios_failure.cc (__constinit): Define as
	equivalent attribute for Clang.
	* src/c++11/future.cc (__constinit): Likewise.
	* src/c++11/system_error.cc (__constinit): Likewise.
	* src/c++17/memory_resource.cc (__constinit): Likewise.
2022-01-20 12:29:29 +00:00
Jonathan Wakely
5929f253fc libstdc++: Only add valid -L paths to testsuite linker options
The MacOS linker warns about -L arguments that don't exist, which causes
all tests to fail for the defauly configuration (because libbacktrace
isn't built).

libstdc++-v3/ChangeLog:

	* scripts/testsuite_flags.in: Only add src/filesystem/.libs and
	src/libbacktrace/.libs to LDFLAGS if those directories exist.
2022-01-20 12:29:29 +00:00
Richard Earnshaw
9b42782366 arm: Add test for AES erratum mitigation
Add a testcase for the erratum mitigation.  To improve coverage
use -dp on the assembler output and match the pattern names (and where
needed the alternative number).

gcc/testsuite/ChangeLog:

	* gcc.target/arm/crypto-vaese-erratum1.c: New test.
2022-01-20 11:15:27 +00:00
Richard Earnshaw
997070498b arm: elide some cases where the AES erratum workaround is not required.
Some common cases where the AES erratum workaround are not required
are when there are 64- or 128-bit loads from memory, moving a 128-bit
value from core registers, and where a 128-bit constant is being
loaded from a literal pool.  The loads may also be misaligned or
generated via a neon intrinsic function.

gcc/ChangeLog:

	* config/arm/crypto.md (aes_op_protect): Allow moves from core
	registers and from memory.
	(aes_op_protect_misalign_load): New pattern.
	(aes_op_protect_neon_vld1v16qi): New pattern.
2022-01-20 11:15:26 +00:00
Richard Earnshaw
2078550a00 arm: suppress aes erratum when forwarding from aes
AES operations are commonly chained and since the result of one AES
operation is never a 32-bit value, they do not need an additional
mitigation instruction for the forwarded result.  We handle this
common case by adding additional patterns that allow for this.

gcc/ChangeLog:

	* config/arm/crypto.md (crypto_<CRYPTO_AESMC:crypto_pattern>_protected):
	New pattern.
	(aarch32_crypto_aese_fused_protected): Likewise.
	(aarch32_crypto_aesd_fused_protected): Likewise.
2022-01-20 11:15:22 +00:00
Richard Earnshaw
bc13384e19 arm: add basic mitigation for Cortex-A AES errata
This patch adds the basic patterns for mitigation of the erratum, but no
attempt is made at this point to optimize the results for the cases where
the erratum mitigation is not needed.

The mitigation is done by guaranteeing that the input operands are fed
from a full-width operation by using an identity operation on the input
values.

gcc/ChangeLog:

	* config/arm/crypto.md (crypto_<CRYPTO_AES:crypto_pattern>): Convert
	to define_expand.  Add mitigation for the Cortex-A AES erratum
	when enabled.
	(*crypto_<CRYPTO_AES:crypto_pattern>_insn): New pattern, based
	on original crypto_<CRYPTO_AES:crypto_pattern> insn.
	(aes_op_protect): New pattern.
	* config/arm/unspecs.md (unspec): Add UNSPEC_AES_PROTECT.
2022-01-20 11:14:44 +00:00
Richard Earnshaw
facbc2368c arm: Add option for mitigating against Cortex-A CPU erratum for AES
Add a new option -mfix-cortex-a-aes for enabling the Cortex-A AES
erratum work-around and enable it automatically for the affected
products (Cortex-A57 and Cortex-A72).

gcc/ChangeLog:

	* config/arm/arm-cpus.in (quirk_aes_1742098): New quirk feature
	(ALL_QUIRKS): Add it.
	(cortex-a57, cortex-a72): Enable it.
	(cortex-a57.cortex-a53, cortex-a72.cortex-a53): Likewise.
	* config/arm/arm.opt (mfix-cortex-a57-aes-1742098): New command-line
	option.
	(mfix-cortex-a72-aes-1655431): New option alias.
	* config/arm/arm.cc (arm_option_override): Handle default settings
	for AES erratum switch.
	* doc/invoke.texi (Arm Options): Document new options.
2022-01-20 11:14:43 +00:00
Richard Earnshaw
c471ee0f05 arm: Consistently use crypto_mode attribute in crypto patterns
A couple of patterns in the crypto support code were hard-coding the
mode rather than using the iterators.  While not incorrect, it was
slightly confusing, so adapt those patterns to the style of the rest
of the file.

Also fix some white space issues.

gcc/ChangeLog:

	* config/arm/crypto.md (crypto_<CYRPTO_AES:crypto_pattern>): Use
	<crypto_mode> rather than hard-coding the mode.
	(crypto_<CRYPTO_AESMC:crypto_pattern>): Fix white space.
	(crypto_<CRYPTO_AES:crypto_pattern>): Likewise.
	(*aarch32_crypto_aese_fused): Likewise.
	(*aarch32_crypto_aesd_fused): Likewise.
	(crypto_<CRYPTO_BINARY:crypto_pattern>): Likewise.
	(crypto_<CRYPTO_TERNARY:crypto_pattern>): Likewise.
	(crypto_sha1h_lb): Likewise.
	(crypto_vmullp64): Likewise.
	(crypto_<CRYPTO_SELECTING:crypto_pattern>): Likewise.
	(crypto_<CRYPTO_SELECTING:crypto_pattern>_lb): Likewise.
2022-01-20 11:14:43 +00:00
Richard Earnshaw
0042ca7b77 arm: Disambiguate multiple crypto patterns with the same name.
No functional change, but arm/crypto.md has multiple pattenrs all
called crypto_<crypto_pattern>, which makes references to them
ambiguous, so add the iterator base to the pattern name so that it is
distinct in the commit logs.

gcc/ChangeLog:

	* config/arm/crypto.md (crypto_<CRYPTO_AESMC:crypto_pattern>): Add
	iterator to pattern name to disambiguate.
	(crypto_<CRYPTO_AES:crypto_pattern>): Likewise.
	(crypto_<CRYPTO_BINARY:crypto_pattern>): Likewise.
	(crypto_<CRYPTO_TERNARY:crypto_pattern>): Likewise.
	(crypto_<CRYPTO_SELECTING:crypto_pattern>): Likewise.
	(crypto_<CRYPTO_SELECTING:crypto_pattern>_lb): Likewise.
2022-01-20 11:14:43 +00:00
Martin Liska
6d51a27fb1 Fix Werror=format-diag with --disable-nls.
PR c++/104134

gcc/cp/ChangeLog:

	* error.cc (dump_aggr_type): Partially disable the warning.
2022-01-20 12:03:06 +01:00
Martin Liska
e744aa373d Fix -Werror=format-diag with RTL checking
PR bootstrap/104135

gcc/ChangeLog:

	* emit-rtl.cc (make_insn_raw): Fix -Wformat-diag warnings.
	* rtl.cc: Partially disable -Wformat-diag for RTL checking
	error messages.
2022-01-20 12:03:06 +01:00
Jakub Jelinek
68f03ac49c dwarf2out: Fix -gsplit-dwarf on riscv [PR103874]
riscv*-*-* are the only modern targets that !HAVE_AS_LEB128 (apparently
due to some aggressive linker optimizations).
As the following testcase shows, we mishandle in index_rnglists the
!HAVE_AS_LEB128 && !have_multiple_function_sections case.

output_rnglists does roughly:
  FOR_EACH_VEC_SAFE_ELT (ranges_table, i, r)
    {
...
      if (block_num > 0)
        {
...
          if (HAVE_AS_LEB128)
            {
              if (!have_multiple_function_sections)
                {
                  // code not using r->*_entry
                  continue;
                }
              // code that sometimes doesn't use r->*_entry,
              // sometimes r->begin_entry
            }
          else if (dwarf_split_debug_info)
            {
              // code that uses both r->begin_entry and r->end_entry
            }
          else
            {
              // code not using r->*_entry
            }
        }
      else if (block_num < 0)
        {
          if (!have_multiple_function_sections)
            gcc_unreachable ();
...
        }
    }
and index_rnglists is what sets up those r->{begin,end}_entry members.
The code did an early if (!have_multiple_function_sections) continue;
which is fine for the HAVE_AS_LEB128 case, because r->*_entry is not
used in that case, but not for !HAVE_AS_LEB128 that uses it anyway.

2022-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR debug/103874
	* dwarf2out.cc (index_rnglists): For !HAVE_AS_LEB128 and
	block_num > 0, index entry even if !have_multiple_function_sections.

	* gcc.dg/debug/dwarf2/pr103874.c: New test.
2022-01-20 11:58:20 +01:00
Jakub Jelinek
7b78dee64d testsuite: Add -Wno-psabi to pr47639.C testcase
This patch fixes
gcc/testsuite/g++.dg/opt/pr47639.C:6:24: warning: MMX vector return without MMX enabled changes the ABI [-Wpsabi]
gcc/testsuite/g++.dg/opt/pr47639.C:6:5: warning: MMX vector argument without MMX enabled changes the ABI [-Wpsabi]
FAILs on i686-linux.

2022-01-20  Jakub Jelinek  <jakub@redhat.com>

	* g++.dg/opt/pr47639.C: Add -Wno-psabi to dg-options.
2022-01-20 11:32:29 +01:00
liuhongt
8bc700f4c3 Enhance vec_pack_trunc for integral mode mask.
For testcase in PR, the patch supports QI:4 -> HI:16 pack with
multi steps(first pack QI:4 -> QI:8 through vec_pack_sbool_trunc_qi,
then pack QI:8 -> HI:16 through vec_pack_trunc_hi).
Similar for QI:2 -> HI:16 which is test4 in mask-pack-prefer-128.c.

gcc/ChangeLog:

	PR target/103771
	* tree-vect-stmts.cc (supportable_narrowing_operation): Enhance
	integral mode mask pack by multi steps which takes
	vec_pack_sbool_trunc_optab as start when elements number is
	less than BITS_PER_UNITS.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/mask-pack-prefer128.c: New test.
	* gcc.target/i386/mask-pack-prefer256.c: New test.
	* gcc.target/i386/pr103771.c: New test.
2022-01-20 16:51:10 +08:00
Richard Biener
ad4188f838 tree-optimization/104114 - avoid diagnosing V1mode lowering
Currently we diagnose vector lowering of V1mode operations that
are not natively supported into V_C_E, scalar op plus CTOR with
-Wvector-operation-performance but that's hardly useful behavior
even though the way we lower things can be improved.

The following disables the diagnostics for the cases the vect.exp
testsuite runs into, on x86 that are vect-cond-11.c and
vect-singleton_1.c.

2022-01-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104114
	* tree-vect-generic.cc (expand_vector_piecewise): Do not diagnose
	single element vector decomposition.
2022-01-20 09:04:20 +01:00
Jason Merrill
30f2c22def c++: template-id with current inst qualifier [PR102300]
The patch for PR41723 properly changed one place to look into the current
instantiation; now we need to fix this place as well.

	PR c++/102300

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_template_name): Use dependent_scope_p.

gcc/testsuite/ChangeLog:

	* g++.dg/parse/no-typename1.C: Remove expected error.
	* g++.dg/template/nested7.C: New test.
2022-01-19 22:42:17 -05:00
David Edelsohn
64655e7bdb testsuite: sldoi requires VSX.
gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/sldoi_to_mov.c: Require VSX.
2022-01-19 19:26:07 -05:00
GCC Administrator
fe1ad14165 Daily bump. 2022-01-20 00:16:54 +00:00
Jonathan Wakely
fe3e978027 libstdc++: Remove -gdwarf-4 from flags for debug library
The default is -gdwarf-5 now, so this is hurting rather than improving
things.

libstdc++-v3/ChangeLog:

	* configure.ac (GLIBCXX_ENABLE_DEBUG_FLAGS): Remove -gdwarf-4
	from default flags.
	* configure: Regenerate.
2022-01-19 19:31:00 +00:00
Jonathan Wakely
f5c50748f3 libstdc++: Include <stddef.h> for size_t and ptrdiff_t [PR104123]
libstdc++-v3/ChangeLog:

	PR libstdc++/104123
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: Include
	<stddef.h>.
2022-01-19 17:40:37 +00:00
Robin Dapp
92efc019ed ifcvt: Run second pass if it is possible to omit a temporary.
If one of the to-be-converted SETs requires the original comparison
(i.e. in order to generate a min/max insn) but no other insn after it
does, we can omit creating temporaries, thus facilitating costing.

gcc/ChangeLog:

	* ifcvt.cc (noce_convert_multiple_sets_1): New function.
	(noce_convert_multiple_sets): Call function a second time if we can
	improve the first try.
2022-01-19 18:37:46 +01:00
Robin Dapp
d249933e6b testsuite/s390: Add tests for noce_convert_multiple.
Add new s390-specific tests that check if we convert two SETs into two
loads on condition.  Remove the s390-specific target-check in
gcc.dg/ifcvt-4.c.

gcc/testsuite/ChangeLog:

	* gcc.dg/ifcvt-4.c: Remove s390-specific check.
	* gcc.target/s390/ifcvt-two-insns-bool.c: New test.
	* gcc.target/s390/ifcvt-two-insns-int.c: New test.
	* gcc.target/s390/ifcvt-two-insns-long.c: New test.
2022-01-19 18:37:46 +01:00
Robin Dapp
aa8cfe7859 ifcvt: Try re-using CC for conditional moves.
Following up on the previous patch, this patch makes
noce_convert_multiple emit two cmov sequences:  The same one as before
and a second one that tries to re-use the existing CC.  Then their costs
are compared and the cheaper one is selected.

gcc/ChangeLog:

	* ifcvt.cc (cond_exec_get_condition): New parameter to allow getting the
	reversed comparison.
	(try_emit_cmove_seq): New function to facilitate creating a cmov
	sequence.
	(noce_convert_multiple_sets): Create two sequences and use the less
	expensive one.
2022-01-19 18:37:46 +01:00
Robin Dapp
e9ebb86799 ifcvt/optabs: Allow using a CC comparison for emit_conditional_move.
Currently we only ever call emit_conditional_move with the comparison
(as well as its comparands) we got from the jump.  Thus, backends are
going to emit a CC comparison for every conditional move that is being
generated instead of re-using the existing CC.
This, combined with emitting temporaries for each conditional move,
causes sky-high costs for conditional moves.

This patch allows to re-use a CC so the costing situation is improved a
bit.

gcc/ChangeLog:

	* rtl.h (struct rtx_comparison): New struct that holds an rtx
	comparison.
	* config/rs6000/rs6000.cc (rs6000_emit_minmax): Use struct instead of
	single parameters.
	(rs6000_emit_swsqrt): Likewise.
	* expmed.cc (expand_sdiv_pow2): Likewise.
	(emit_store_flag): Likewise.
	* expr.cc (expand_cond_expr_using_cmove): Likewise.
	(expand_expr_real_2): Likewise.
	* ifcvt.cc (noce_emit_cmove): Add compare and reversed compare
	parameters.
	* optabs.cc (emit_conditional_move_1): New function.
	(expand_doubleword_shift_condmove): Use struct.
	(emit_conditional_move): Use struct and allow to call directly
	without going through preparation steps.
	* optabs.h (emit_conditional_move): Use struct.
2022-01-19 18:36:04 +01:00
Robin Dapp
46346d8d76 ifcvt: Improve costs handling for noce_convert_multiple.
When noce_convert_multiple is called the original costs are not yet
initialized.  Therefore, up to now, costs were only ever unfairly
compared against COSTS_N_INSNS (2).  This would lead to
default_noce_conversion_profitable_p () rejecting all but the most
contrived of sequences.

This patch temporarily initializes the original costs by counting
adding costs for all sets inside the then_bb.

gcc/ChangeLog:

	* ifcvt.cc (bb_ok_for_noce_convert_multiple_sets): Estimate insns costs.
	(noce_process_if_block): Use potential costs.
2022-01-19 18:34:10 +01:00
Robin Dapp
9b8eaa2822 ifcvt: Allow constants for noce_convert_multiple.
This lifts the restriction of not allowing constants for
noce_convert_multiple.  The code later checks if a valid sequence
is produced anyway.

gcc/ChangeLog:

	* ifcvt.cc (noce_convert_multiple_sets): Allow constants.
	(bb_ok_for_noce_convert_multiple_sets): Likewise.
2022-01-19 18:34:02 +01:00
Robin Dapp
4c46f5a471 ifcvt: Check if cmovs are needed.
When if-converting multiple SETs and we encounter a swap-style idiom

  if (a > b)
    {
      tmp = c;   // [1]
      c = d;
      d = tmp;
    }

ifcvt should not generate a conditional move for the instruction at
[1].

In order to achieve that, this patch goes through all relevant SETs
and marks the relevant instructions.  This helps to evaluate costs.

On top, only generate temporaries if the current cmov is going to
overwrite one of the comparands of the initial compare.

gcc/ChangeLog:

	* ifcvt.cc (need_cmov_or_rewire): New function.
	(noce_convert_multiple_sets): Call it.
2022-01-19 18:33:53 +01:00
David Malcolm
d5148d4faa Update per-file selftest and finalization hooks for .c to .cc renaming
This is mostly a mechanical change, apart from:
- fix the name of attribute_c_tests to match its filename (attribs.cc)
- fix the name of opt_proposer_c to match its filename (opt-suggestions.cc)
- delete a bogus "modref_c_tests" decl from ipa-modref-tree.h that's been
  present since the initial commit of that file
  (d119f34c95)

gcc/ChangeLog:
	* attribs.cc (attribute_c_tests): Rename to...
	(attribs_cc_tests): ...this.
	* bitmap.cc (bitmap_c_tests): Rename to...
	(bitmap_cc_tests): ...this.
	* cgraph.cc (cgraph_c_finalize): Rename to...
	(cgraph_cc_finalize): ...this.
	(cgraph_c_tests): Rename to...
	(cgraph_cc_tests): ...this.
	* cgraph.h (cgraph_c_finalize): Rename to...
	(cgraph_cc_finalize): ...this.
	(cgraphunit_c_finalize): Rename to...
	(cgraphunit_cc_finalize): ...this.
	* cgraphunit.cc (cgraphunit_c_finalize): Rename to...
	(cgraphunit_cc_finalize): ...this.
	* convert.cc (convert_c_tests): Rename to...
	(convert_cc_tests): ...this.
	* dbgcnt.cc (dbgcnt_c_tests): Rename to...
	(dbgcnt_cc_tests): ...this.
	* diagnostic-show-locus.cc (diagnostic_show_locus_c_tests): Rename to...
	(diagnostic_show_locus_cc_tests): ...this.
	* diagnostic.cc (diagnostic_c_tests): Rename to...
	(diagnostic_cc_tests): ...this.
	* dumpfile.cc (dumpfile_c_tests): Rename to...
	(dumpfile_cc_tests): ...this.
	* dwarf2out.cc (dwarf2out_c_finalize): Rename to...
	(dwarf2out_cc_finalize): ...this.
	* dwarf2out.h (dwarf2out_c_finalize): Rename to...
	(dwarf2out_cc_finalize): ...this.
	* edit-context.cc (edit_context_c_tests): Rename to...
	(edit_context_cc_tests): ...this.
	* et-forest.cc (et_forest_c_tests): Rename to...
	(et_forest_cc_tests): ...this.
	* fibonacci_heap.cc (fibonacci_heap_c_tests): Rename to...
	(fibonacci_heap_cc_tests): ...this.
	* fold-const.cc (fold_const_c_tests): Rename to...
	(fold_const_cc_tests): ...this.
	* function-tests.cc (function_tests_c_tests): Rename to...
	(function_tests_cc_tests): ...this.
	* gcse.cc (gcse_c_finalize): Rename to...
	(gcse_cc_finalize): ...this.
	* gcse.h (gcse_c_finalize): Rename to...
	(gcse_cc_finalize): ...this.
	* ggc-tests.cc (ggc_tests_c_tests): Rename to...
	(ggc_tests_cc_tests): ...this.
	* gimple-ssa-store-merging.cc (store_merging_c_tests): Rename to...
	(store_merging_cc_tests): ...this.
	* gimple.cc (gimple_c_tests): Rename to...
	(gimple_cc_tests): ...this.
	* hash-map-tests.cc (hash_map_tests_c_tests): Rename to...
	(hash_map_tests_cc_tests): ...this.
	* hash-set-tests.cc (hash_set_tests_c_tests): Rename to...
	(hash_set_tests_cc_tests): ...this.
	* input.cc (input_c_tests): Rename to...
	(input_cc_tests): ...this.
	* ipa-cp.cc (ipa_cp_c_finalize): Rename to...
	(ipa_cp_cc_finalize): ...this.
	* ipa-fnsummary.cc (ipa_fnsummary_c_finalize): Rename to...
	(ipa_fnsummary_cc_finalize): ...this.
	* ipa-fnsummary.h (ipa_fnsummary_c_finalize): Rename to...
	(ipa_fnsummary_cc_finalize): ...this.
	* ipa-modref-tree.cc (ipa_modref_tree_c_tests): Rename to...
	(ipa_modref_tree_cc_tests): ...this.
	* ipa-modref-tree.h (modref_c_tests): Delete bogus decl.
	* ipa-modref.cc (ipa_modref_c_finalize): Rename to...
	(ipa_modref_cc_finalize): ...this.
	* ipa-modref.h (ipa_modref_c_finalize): Rename to...
	(ipa_modref_cc_finalize): ...this.
	* ipa-prop.h (ipa_cp_c_finalize): Rename to...
	(ipa_cp_cc_finalize): ...this.
	* ipa-reference.cc (ipa_reference_c_finalize): Rename to...
	(ipa_reference_cc_finalize): ...this.
	* ipa-reference.h (ipa_reference_c_finalize): Rename to...
	(ipa_reference_cc_finalize): ...this.
	* ira-costs.cc (ira_costs_c_finalize): Rename to...
	(ira_costs_cc_finalize): ...this.
	* ira.h (ira_costs_c_finalize): Rename to...
	(ira_costs_cc_finalize): ...this.
	* opt-suggestions.cc (opt_proposer_c_tests): Rename to...
	(opt_suggestions_cc_tests): ...this.
	* opts.cc (opts_c_tests): Rename to...
	(opts_cc_tests): ...this.
	* predict.cc (predict_c_tests): Rename to...
	(predict_cc_tests): ...this.
	* pretty-print.cc (pretty_print_c_tests): Rename to...
	(pretty_print_cc_tests): ...this.
	* read-rtl-function.cc (read_rtl_function_c_tests): Rename to...
	(read_rtl_function_cc_tests): ...this.
	* rtl-tests.cc (rtl_tests_c_tests): Rename to...
	(rtl_tests_cc_tests): ...this.
	* sbitmap.cc (sbitmap_c_tests): Rename to...
	(sbitmap_cc_tests): ...this.
	* selftest-run-tests.cc (selftest::run_tests): Update calls for
	_c_ to _cc_ function renamings; fix names of attribs and
	opt-suggestions tests.
	* selftest.cc (selftest_c_tests): Rename to...
	(selftest_cc_tests): ...this.
	* selftest.h (attribute_c_tests): Rename to...
	(attribs_cc_tests): ...this.
	(bitmap_c_tests): Rename to...
	(bitmap_cc_tests): ...this.
	(cgraph_c_tests): Rename to...
	(cgraph_cc_tests): ...this.
	(convert_c_tests): Rename to...
	(convert_cc_tests): ...this.
	(diagnostic_c_tests): Rename to...
	(diagnostic_cc_tests): ...this.
	(diagnostic_show_locus_c_tests): Rename to...
	(diagnostic_show_locus_cc_tests): ...this.
	(dumpfile_c_tests): Rename to...
	(dumpfile_cc_tests): ...this.
	(edit_context_c_tests): Rename to...
	(edit_context_cc_tests): ...this.
	(et_forest_c_tests): Rename to...
	(et_forest_cc_tests): ...this.
	(fibonacci_heap_c_tests): Rename to...
	(fibonacci_heap_cc_tests): ...this.
	(fold_const_c_tests): Rename to...
	(fold_const_cc_tests): ...this.
	(function_tests_c_tests): Rename to...
	(function_tests_cc_tests): ...this.
	(ggc_tests_c_tests): Rename to...
	(ggc_tests_cc_tests): ...this.
	(gimple_c_tests): Rename to...
	(gimple_cc_tests): ...this.
	(hash_map_tests_c_tests): Rename to...
	(hash_map_tests_cc_tests): ...this.
	(hash_set_tests_c_tests): Rename to...
	(hash_set_tests_cc_tests): ...this.
	(input_c_tests): Rename to...
	(input_cc_tests): ...this.
	(opts_c_tests): Rename to...
	(opts_cc_tests): ...this.
	(predict_c_tests): Rename to...
	(predict_cc_tests): ...this.
	(pretty_print_c_tests): Rename to...
	(pretty_print_cc_tests): ...this.
	(read_rtl_function_c_tests): Rename to...
	(read_rtl_function_cc_tests): ...this.
	(rtl_tests_c_tests): Rename to...
	(rtl_tests_cc_tests): ...this.
	(sbitmap_c_tests): Rename to...
	(sbitmap_cc_tests): ...this.
	(selftest_c_tests): Rename to...
	(selftest_cc_tests): ...this.
	(simplify_rtx_c_tests): Rename to...
	(simplify_rtx_cc_tests): ...this.
	(spellcheck_c_tests): Rename to...
	(spellcheck_cc_tests): ...this.
	(spellcheck_tree_c_tests): Rename to...
	(spellcheck_tree_cc_tests): ...this.
	(sreal_c_tests): Rename to...
	(sreal_cc_tests): ...this.
	(store_merging_c_tests): Rename to...
	(store_merging_cc_tests): ...this.
	(tree_c_tests): Rename to...
	(tree_cc_tests): ...this.
	(tree_cfg_c_tests): Rename to...
	(tree_cfg_cc_tests): ...this.
	(typed_splay_tree_c_tests): Rename to...
	(typed_splay_tree_cc_tests): ...this.
	(vec_c_tests): Rename to...
	(vec_cc_tests): ...this.
	(vec_perm_indices_c_tests): Rename to...
	(vec_perm_indices_cc_tests): ..this.
	(opt_proposer_c_tests): Rename to...
	(opt_suggestions_cc_tests): ...this.
	(dbgcnt_c_tests): Rename to...
	(dbgcnt_cc_tests): ...this.
	(ipa_modref_tree_c_tests): Rename to...
	(ipa_modref_tree_cc_tests): ...this.
	* simplify-rtx.cc (simplify_rtx_c_tests): Rename to...
	(simplify_rtx_cc_tests): ...this.
	* spellcheck-tree.cc (spellcheck_tree_c_tests): Rename to...
	(spellcheck_tree_cc_tests): ...this.
	* spellcheck.cc (spellcheck_c_tests): Rename to...
	(spellcheck_cc_tests): ...this.
	* sreal.cc (sreal_c_tests): Rename to...
	(sreal_cc_tests): ...this.
	* toplev.cc (toplev::finalize): Update calls for _c_ to _cc_
	function renamings.
	* tree-cfg.cc (tree_cfg_c_tests): Rename to...
	(tree_cfg_cc_tests): ...this.
	* tree.cc (tree_c_tests): Rename to...
	(tree_cc_tests): ...this.
	* typed-splay-tree.cc (typed_splay_tree_c_tests): Rename to...
	(typed_splay_tree_cc_tests): ...this.
	* vec-perm-indices.cc (vec_perm_indices_c_tests): Rename to...
	(vec_perm_indices_cc_tests): ...this.
	* vec.cc (vec_c_tests): Rename to...
	(vec_cc_tests): ...this.

gcc/c-family/ChangeLog:
	* c-common.cc (c_common_c_tests): Rename to...
	(c_common_cc_tests): ...this.
	(c_family_tests): Update calls for .c to .cc renaming.
	* c-common.h (c_format_c_tests): Rename to...
	(c_format_cc_tests): ...this.
	(c_indentation_c_tests): Rename to...
	(c_indentation_cc_tests): ...this.
	(c_pretty_print_c_tests): Rename to...
	(c_pretty_print_cc_tests): ...this.
	* c-format.cc (c_format_c_tests): Rename to...
	(c_format_cc_tests): ...this.
	* c-indentation.cc (c_indentation_c_tests): Rename to...
	(c_indentation_cc_tests): ...this.
	* c-pretty-print.cc (c_pretty_print_c_tests): Rename to...
	(c_pretty_print_cc_tests): ...this.

gcc/cp/ChangeLog:
	* cp-lang.cc (selftest::run_cp_tests): Update calls for .c to .cc
	renaming.
	* cp-tree.h (cp_pt_c_tests): Rename to...
	(cp_pt_cc_tests): ...this.
	(cp_tree_c_tests): Rename to...
	(cp_tree_cc_tests): ...this.
	* pt.cc (cp_pt_c_tests): Rename to...
	(cp_pt_cc_tests): ...this.
	* tree.cc (cp_tree_c_tests): Rename to...
	(cp_tree_cc_tests): ...this.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-19 11:33:53 -05:00
Jonathan Wakely
6a26ad6736 libstdc++: Fix libbacktrace build files
This makes it possible to combine --enable-libstdcxx-debug with
--enable-libstdcxx-backtrace, by adding a rule to src/Makefile to copy
the backtrace-supported.h header into the src/debug/libbacktrace
directory.

Add libbacktrace path to testsuite flags so the tests can link without
having the library installed.

Also fix some warnings when running automake for the libbacktrace
makefile.

Use a per-library CPPFLAGS variable to fix:

src/libbacktrace/Makefile.am:38: warning: AM_CPPFLAGS multiply defined in condition TRUE ...
fragment.am:43: ... 'AM_CPPFLAGS' previously defined here
src/libbacktrace/Makefile.am:32:   'fragment.am' included from here

Create symlinks to the libbacktrace sources to fix:

src/libbacktrace/Makefile.am:55: warning: source file '../../../libbacktrace/atomic.c' is in a subdirectory,
src/libbacktrace/Makefile.am:55: but option 'subdir-objects' is disabled

libstdc++-v3/ChangeLog:

	* scripts/testsuite_flags.in: Add src/libbacktrace/.libs to
	linker search paths.
	* src/Makefile.am: Fix src/debug/libbacktrace build.
	* src/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: Use per-library CPPFLAGS
	variable. Use symlinks for the source files.
	* src/libbacktrace/Makefile.in: Regenerate.
2022-01-19 14:23:13 +00:00
Andre Vieira
f4ca0a53be vect: Fix epilogue mode skipping
gcc/ChangeLog:

	PR tree-optimization/103997
	* tree-vect-loop.cc (vect_analyze_loop): Fix mode skipping for epilogue
	vectorization.
2022-01-19 14:14:47 +00:00
Jakub Jelinek
ffc7f200ad match.pd, optabs: Avoid vectorization of {FLOOR,CEIL,ROUND}_{DIV,MOD}_EXPR [PR102860]
power10 has modv4si3 expander and so vectorizes the following testcase
where Fortran modulo is FLOOR_MOD_EXPR.
optabs_for_tree_code indicates that the optab for all the *_MOD_EXPR
variants is umod_optab or smod_optab, but that isn't true, that optab
actually expands just TRUNC_MOD_EXPR.  For the other tree codes expmed.cc
has code how to adjust the TRUNC_MOD_EXPR into those by emitting some
extra comparisons and conditional updates.  Similarly for *_DIV_EXPR,
except in that case it actually needs both division and modulo.

While it would be possible to handle it in expmed.cc for vectors as well,
we'd need to be sure all the vector operations we need for that are
available, and furthermore we wouldn't account for that in the costing.

So, IMHO it is better to stop pretending those non-truncating (and
non-exact) div/mod operations have an optab.  For GCC 13, we should
IMHO pattern match these in tree-vect-patterns.cc and transform them
to truncating div/mod with follow-up adjustments and let the vectorizer
vectorize that.  As written in the PR, for signed operands:
r = x %[fl] y;
is
r = x % y; if (r && (x ^ y) < 0) r += y;
and
d = x /[fl] y;
is
r = x % y; d = x / y; if (r && (x ^ y) < 0) --d;
and
r = x %[cl] y;
is
r = x % y; if (r && (x ^ y) >= 0) r -= y;
and
d = /[cl] y;
is
r = x % y; d = x / y; if (r && (x ^ y) >= 0) ++d;
(too lazy to figure out rounding div/mod now).  I'll create a PR
for that.
The patch also extends a match.pd optimization that floor_mod on
unsigned operands is actually trunc_mod.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/102860
	* match.pd (x %[fl] y -> x % y): New simplification for
	unsigned integral types.
	* optabs-tree.cc (optab_for_tree_code): Return unknown_optab
	for {CEIL,FLOOR,ROUND}_{DIV,MOD}_EXPR with VECTOR_TYPE.

	* gfortran.dg/pr102860.f90: New test.
2022-01-19 15:03:45 +01:00
Jakub Jelinek
f35bb467a0 testsuite: Test evrp-trans.c also with unsigned types [PR104115]
The testcase from the PR got fixed with r12-3119-g675a3e40567e1d
and looks quite similar to the evrp-trans.c test, except evrp-trans.c
is tested on signed integer types.
I think it would be useful to test it for unsigned comparisons too.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR c/104115
	* gcc.dg/tree-ssa/evrp-trans2.c: New test.
2022-01-19 15:02:31 +01:00
Richard Biener
5b6788ae5a tree-optimization/104112 - add check for vect epilogue reduc reuse
This adds a missing check for the availability of intermediate vector
types required to re-use the accumulator of a vectorized reduction
in the vectorized epilogue.  For SVE and VNx2DF vs V2DF with
-msve-vector-bits=512 for example V4DF is not available.

In addition to that we have to verify the reduction operation is
supported, otherwise we for example on i?86 get vector code that's
later decomposed again by vector lowering when trying to use
a V2HI epilogue for a V8HI reduction with a target without
TARGET_MMX_WITH_SSE.

It might be we want -Wvector-operation-performance for all vect.exp
tests but that seems to have existing regressions.

2022-01-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104112
	* tree-vect-loop.cc (vect_find_reusable_accumulator): Check
	for required intermediate vector types.

	* gcc.dg/vect/pr104112-1.c: New testcase.
	* gcc.dg/vect/pr104112-2.c: New testcase.
2022-01-19 14:55:15 +01:00
Martin Liska
68aa3c08ef check_GNU_style_lib: skip .py files (one should use flake8).
contrib/ChangeLog:

	* check_GNU_style_lib.py: Skip Python files.
2022-01-19 14:54:03 +01:00
Marcel Vollweiler
0bd247bbbe libgomp, OpenMP: Fix issue for omp_get_device_num on gcn targets.
Currently omp_get_device_num does not work on gcn targets with more than one
offload device. The reason is that GOMP_DEVICE_NUM_VAR is static in
icv-device.c and thus "__gomp_device_num" is not visible in the offload image.

This patch removes "static" such that "__gomp_device_num" is now part of the
offload image and can now be found in GOMP_OFFLOAD_load_image in the plugin.

This is not an issue for nvptx. There, "__gomp_device_num" is in the offload
image even with "static".

libgomp/ChangeLog:

	* config/gcn/icv-device.c: Make GOMP_DEVICE_NUM_VAR public (remove
	"static") to make the device num available in the offload image.
2022-01-19 05:03:54 -08:00
Matthias Kretz
39f581028c libstdc++: Fix for non-constexpr math_errhandling
Use SFINAE magic to support: "It is unspecified whether math_errhandling
is a macro or an identifier with external linkage." [C Standard]

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h (__floating_point_flags): Do
	not rely on math_errhandling to expand to a constant expression.
2022-01-19 13:45:58 +01:00
H.J. Lu
2cef99175a [Ada] Set target_cpu to x32 for x86_64-linux-gnux32
Since the x86_64-linux-gnux32 compiler is actually an x32 compiler, set
target_cpu to x32 for x86_64-linux-gnux32.

	PR ada/103538
	* gcc-interface/Makefile.in (target_cpu): Set to x32 for
	x86_64-linux-gnux32.
2022-01-19 04:37:23 -08:00