Commit Graph

185017 Commits

Author SHA1 Message Date
GCC Administrator
389e4929ae Daily bump. 2021-08-15 00:18:14 +00:00
GCC Administrator
aa8b5b6e05 Daily bump. 2021-08-14 00:18:04 +00:00
Martin Liska
5f00ef3bc7 coverage: handle function beginning
PR gcov-profile/100788

gcc/ChangeLog:

	* coverage.c (coverage_begin_function): Update function
	  beginning when #line macro is used.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr100788.c: New test.
2021-08-13 12:07:00 +02:00
GCC Administrator
7319c2c9e6 Daily bump. 2021-08-13 00:18:24 +00:00
Jakub Jelinek
b1c4b1c100 libcpp: Fix ICE with -Wtraditional preprocessing [PR101638]
The following testcase ICEs in cpp_sys_macro_p, because cpp_sys_macro_p
is called for a builtin macro which doesn't use node->value.macro union
member but a different one and so dereferencing it ICEs.
As the testcase is distilled from contemporary glibc headers, it means
basically -Wtraditional now ICEs on almost everything.

The fix can be either the patch below, return true for builtin macros,
or we could instead return false for builtin macros, or the fix could
be also (untested):
--- libcpp/expr.c       2021-05-07 10:34:46.345122608 +0200
+++ libcpp/expr.c       2021-08-12 09:54:01.837556365 +0200
@@ -783,13 +783,13 @@ cpp_classify_number (cpp_reader *pfile,

       /* Traditional C only accepted the 'L' suffix.
          Suppress warning about 'LL' with -Wno-long-long.  */
-      if (CPP_WTRADITIONAL (pfile) && ! cpp_sys_macro_p (pfile))
+      if (CPP_WTRADITIONAL (pfile))
        {
          int u_or_i = (result & (CPP_N_UNSIGNED|CPP_N_IMAGINARY));
          int large = (result & CPP_N_WIDTH) == CPP_N_LARGE
                       && CPP_OPTION (pfile, cpp_warn_long_long);

-         if (u_or_i || large)
+         if ((u_or_i || large) && ! cpp_sys_macro_p (pfile))
            cpp_warning_with_line (pfile, large ? CPP_W_LONG_LONG : CPP_W_TRADITIONAL,
                                   virtual_location, 0,
                                   "traditional C rejects the \"%.*s\" suffix",
The builtin macros at least currently don't add any suffixes
or numbers -Wtraditional would like to warn about.  For floating
point suffixes, -Wtraditional calls cpp_sys_macro_p only right
away before emitting the warning, but in the above case the ICE
is because cpp_sys_macro_p is called even if the number doesn't
have any suffixes (that is I think always for builtin macros
right now).

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/101638
	* macro.c (cpp_sys_macro_p): Return true instead of
	crashing on builtin macros.

	* gcc.dg/cpp/pr101638.c: New test.

(cherry picked from commit 408d88af60)
2021-08-12 22:55:08 +02:00
Jakub Jelinek
13e44296ea sanitizer: Cherry-pick realpath fix
tsan in some cases starts ignoring interceptors and only calls the
intercepted functions.  But for realpath the behavior for NULL second argument
was only handled in the interceptor and intercepted function was the one
found by dlsym which is often one that doesn't handle NULL as second argument.

Fixed by using dlvsym with "GLIBC_2.3" if possible for intercepted function
and don't emulate behavior in the wrapper.

2021-08-11  Jakub Jelinek  <jakub@redhat.com>

	* sanitizer_common/sanitizer_common_interceptors.inc: Cherry-pick
	llvm-project revision faef0d042f523357fe5590e7cb6a8391cf0351a8.

(cherry picked from commit 0e6017f5b4)
2021-08-12 22:55:01 +02:00
Jakub Jelinek
dd34596183 c++: Fix up #pragma omp declare {simd,variant} and acc routine parsing
When parsing default arguments, we need to temporarily clear parser->omp_declare_simd
and parser->oacc_routine, otherwise it can clash with further declarations
inside of e.g. lambdas inside of those default arguments.

2021-08-04  Jakub Jelinek  <jakub@redhat.com>

	PR c++/101759
	* parser.c (cp_parser_default_argument): Temporarily override
	parser->omp_declare_simd and parser->oacc_routine to NULL.

	* g++.dg/gomp/pr101759.C: New test.
	* g++.dg/goacc/pr101759.C: New test.

(cherry picked from commit af31cab047)
2021-08-12 22:54:19 +02:00
Jakub Jelinek
e7fd8e978e ubsan: Fix ICEs with DECL_REGISTER tests [PR101624]
The following testcase ICEs, because the base is a CONST_DECL for
the Fortran parameter, and ubsan/sanopt uses DECL_REGISTER macro on it.
 /* In VAR_DECL and PARM_DECL nodes, nonzero means declared `register'.  */
 #define DECL_REGISTER(NODE) (DECL_WRTL_CHECK (NODE)->decl_common.decl_flag_0)
while CONST_DECL doesn't satisfy DECL_WRTL_CHECK.

The following patch checks explicitly for VAR_DECL/PARM_DECL/RESULT_DECL
only before using DECL_REGISTER, assumes other decls aren't DECL_REGISTER.
Not really sure about RESULT_DECL but it at least satisfies DECL_WRTL_CHECK...

2021-07-28  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/101624
	* ubsan.c (maybe_instrument_pointer_overflow,
	instrument_object_size): Only test DECL_REGISTER on VAR_DECLs,
	PARM_DECLs or RESULT_DECLs.
	* sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise.

	* gfortran.dg/ubsan/ubsan.exp: New file.
	* gfortran.dg/ubsan/pr101624.f90: New test.

(cherry picked from commit 49e28c02a9)
2021-08-12 22:53:42 +02:00
Patrick Palka
f65ae298d4 c++: constexpr std::construct_at on empty field [PR101663]
Here during constexpr evaluation of

  std::construct_at(&a._M_value)

we find ourselves in cxx_eval_store_expression where the target object
is 'a._M_value' and the initializer is {}.  Since _M_value is an empty
[[no_unique_address]] member we don't create a sub-CONSTRUCTOR for it,
so we end up in the early exit code path for empty stores with mismatched
types and trip over the assert therein

  gcc_assert (is_empty_class (TREE_TYPE (init)) && !lval);

because lval is true.  The reason it's true is because the INIT_EXPR in
question is the LHS of a COMPOUND_EXPR, and evaluation of the LHS is
always performed with lval=true (to indicate there's no lvalue-to-rvalue
conversion).

This patch makes the code path in question handle the lval=true case
appropriately rather than asserting.  In passing, it also consolidates
the duplicate implementations of std::construct_at/destroy_at in some
of the C++20 constexpr tests into a common header file.

	PR c++/101663

gcc/cp/ChangeLog:

	* constexpr.c (cxx_eval_store_expression): Handle the lval=true
	case in the early exit code path for empty stores with mismatched
	types.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/construct_at.h: New convenience header file that
	defines minimal implementations of std::construct_at/destroy_at,
	split out from ...
	* g++.dg/cpp2a/constexpr-new5.C: ... here.
	* g++.dg/cpp2a/constexpr-new6.C: Use the header.
	* g++.dg/cpp2a/constexpr-new14.C: Likewise.
	* g++.dg/cpp2a/constexpr-new20.C: New test.

(cherry picked from commit 21fd62e5ca)
2021-08-12 08:18:04 -04:00
Eric Botcazou
2e4e16f75e Make -no-pie option work for native Windows
Binutils 2.36/2.37 generate PIE executables by default on native Windows
(because --dynamicbase is the default) so it makes sense to have a simple
way to counter that and -no-pie seems appropriate, all the more so that
it is automatically passed when building the compiler itself.

gcc/
	* configure.ac (PE linker --disable-dynamicbase support): New check.
	* configure: Regenerate.
	* config.in: Likewise.
	* config/i386/mingw32.h (LINK_SPEC_DISABLE_DYNAMICBASE): New define.
	(LINK_SPEC): Use it.
	* config/i386/mingw-w64.h (LINK_SPEC_DISABLE_DYNAMICBASE): Likewise.
	(LINK_SPEC): Likewise.
2021-08-12 09:57:46 +02:00
GCC Administrator
a2beaebecd Daily bump. 2021-08-12 00:18:06 +00:00
Jonathan Wakely
6e3647c98e libstdc++: Fix test that fails randomly [PR101866]
This test assumes that the same sequence of three values cannot occur,
which is incorect. It's unlikely, but not impossible.

Perform the check in a loop, so that in the unlikely event of an
identical sequence, we retry. If the library code is buggy it will keep
producing the same sequence and the test will time out. If the code is
working correctly then we will usually break out of the loop after one
iteration, or very rarely after two or three.

libstdc++-v3/ChangeLog:

	PR libstdc++/101866
	* testsuite/experimental/random/randint.cc: Loop and retry if
	reseed() produces the same sequence.

(cherry picked from commit 93f1dbc7cd)
2021-08-11 23:50:33 +01:00
Patrick Palka
be45bc283e c++: parameterized requires-expr as default argument [PR101725]
Here we're rejecting the default template argument

  requires (T t) { x(t); }

because we consider the 't' in the requirement to be a local variable
(according to local_variable_p), and we generally forbid local variables
from appearing inside default arguments.  We can perhaps fix this by
giving special treatment to parameters introduced by requires-expressions,
but DR 2082 relaxed the restriction about local variables appearing within
default arguments to permit them inside unevaluated operands thereof.
So this patch just implements DR 2082 which also fixes this PR since a
requires-expression is an unevaluated context.

	PR c++/101725
	DR 2082

gcc/cp/ChangeLog:

	* cp-tree.h (unevaluated_p): Return true for REQUIRES_EXPR.
	* decl.c (local_variable_p_walkfn): Don't walk into unevaluated
	operands.
	* parser.c (cp_parser_primary_expression) <case CPP_NAME>: Never
	reject uses of local variables in unevaluated contexts.
	* tree.c (cp_walk_subtrees) <case REQUIRES_EXPR>: Increment
	cp_unevaluated_operand.  Use cp_walk_tree directly instead of
	WALK_SUBTREE to avoid the goto.  Use REQUIRES_EXPR_REQS instead
	of TREE_OPERAND directly.

gcc/testsuite/ChangeLog:

	* g++.dg/DRs/dr2082.C: New test.
	* g++.dg/cpp2a/concepts-uneval4.C: New test.

(cherry picked from commit 9707d2e5db)
2021-08-11 17:40:42 -04:00
Harald Anlauf
4ee9e57684 Fortran: ICE in resolve_allocate_deallocate for invalid STAT argument
gcc/fortran/ChangeLog:

	PR fortran/101564
	* expr.c (gfc_check_vardef_context): Add check for KIND and LEN
	parameter inquiries.
	* match.c (gfc_match): Fix comment for %v code.
	(gfc_match_allocate, gfc_match_deallocate): Replace use of %v code
	by %e in gfc_match to allow for function references as STAT and
	ERRMSG arguments.
	* resolve.c (resolve_allocate_deallocate): Avoid NULL pointer
	dereferences and shortcut for bad STAT and ERRMSG argument to
	(DE)ALLOCATE.  Remove bogus parts of checks for STAT and ERRMSG.

gcc/testsuite/ChangeLog:

	PR fortran/101564
	* gfortran.dg/allocate_stat_3.f90: New test.
	* gfortran.dg/allocate_stat.f90: Adjust error messages.
	* gfortran.dg/implicit_11.f90: Likewise.
	* gfortran.dg/inquiry_type_ref_3.f90: Likewise.

(cherry picked from commit 7bf582e6cf)
2021-08-11 21:36:34 +02:00
Patrick Palka
90f3dd128b c++: Improve memory usage of subsumption [PR100828]
Constraint subsumption is implemented in two steps.  The first step
computes the disjunctive (or conjunctive) normal form of one of the
constraints, and the second step verifies that each clause in the
decomposed form implies the other constraint.   Performing these two
steps separately is problematic because in the first step the DNF/CNF
can be exponentially larger than the original constraint, and by
computing it ahead of time we'd have to keep all of it in memory.

This patch fixes this exponential blowup in memory usage by interleaving
the two steps, so that as soon as we decompose one clause we check
implication for it.  In turn, memory usage during subsumption is now
worst case linear in the size of the constraints rather than
exponential, and so we can safely remove the hard limit of 16 clauses
without introducing runaway memory usage on some inputs.  (Note the
_time_ complexity of subsumption is still exponential in the worst case.)

In order for this to work we need to make formula::branch() insert the
copy of the current clause directly after the current clause rather than
at the end of the list, so that we fully decompose a clause shortly
after creating it.  Otherwise we'd end up accumulating exponentially
many (partially decomposed) clauses in memory anyway.

	PR c++/100828

gcc/cp/ChangeLog:

	* logic.cc (formula::formula): Use emplace_back instead of
	push_back.
	(formula::branch): Insert a copy of m_current directly after
	m_current instead of at the end of the list.
	(formula::erase): Define.
	(decompose_formula): Remove.
	(decompose_antecedents): Remove.
	(decompose_consequents): Remove.
	(derive_proofs): Remove.
	(max_problem_size): Remove.
	(diagnose_constraint_size): Remove.
	(subsumes_constraints_nonnull): Rewrite directly in terms of
	decompose_clause and derive_proof, interleaving decomposition
	with implication checking.  Remove limit on constraint complexity.
	Use formula::erase to free the current clause before moving on to
	the next one.

(cherry picked from commit f48c3cd2e3)
2021-08-11 11:54:19 -04:00
Jonathan Wakely
bde28c60c7 libstdc++: Fix create_directories to resolve symlinks [PR101510]
When filesystem__create_directories checks to see if the path already
exists and resolves to a directory, it uses filesystem::symlink_status,
which means it reports an error if the path is a symlink. It should use
filesystem::status, so that the target directory is detected, and no
error is reported.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101510
	* src/c++17/fs_ops.cc (fs::create_directories): Use status
	instead of symlink_status.
	* src/filesystem/ops.cc (fs::create_directories): Likewise.
	* testsuite/27_io/filesystem/operations/create_directories.cc:
	Check symlink to existing directory.
	* testsuite/27_io/filesystem/operations/create_directory.cc: Do
	not test with symlinks on Windows.
	* testsuite/experimental/filesystem/operations/create_directories.cc:
	Check symlink to existing directory.
	* testsuite/experimental/filesystem/operations/create_directory.cc:
	Do not test with symlinks on Windows.

(cherry picked from commit 124eaa50e0)
2021-08-11 15:30:38 +01:00
Jonathan Wakely
c5f17274aa libstdc++: Add more tests for filesystem::create_directory [PR101510]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101510
	* src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
	* testsuite/27_io/filesystem/operations/create_directory.cc:
	Test creating directory with name of existing symlink to
	directory.
	* testsuite/experimental/filesystem/operations/create_directory.cc:
	Likewise.

(cherry picked from commit 0c4ae4ff46)
2021-08-11 15:30:38 +01:00
Jonathan Wakely
546cf31755 libstdc++: Implement LWG 3465 for std::compare_partial_order_fallback [PR101056]
libstdc++-v3/ChangeLog:

	PR libstdc++/101056
	* libsupc++/compare (compare_partial_order_fallback): Add
	constraint using reversed parameter order, as per LWG 3465.
	* testsuite/18_support/comparisons/algorithms/fallback.cc:
	Adjust expected result.

(cherry picked from commit b76a529c09)
2021-08-11 15:30:38 +01:00
Jonathan Wakely
2fbb6039c5 libstdc++: Change [cmp.alg] assertions to constraints
This moves the same_as<decay_t<_Tp>, decay_t<_Up>> checks from the
[cmp.alg] function bodies into their constraints.

Also add a test for the compare_xxx_order_fallback algorithms.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (__decayed_same_as): New helper concept.
	(strong_order, weak_order, partial_order): Constrain with new
	concept instead of using static_assert.
	(compare_strong_order_fallback, compare_weak_order_fallback)
	(compare_partial_order_fallback): Likewise. Do not deduce return
	types. Remove redundant if-constexpr checks.
	* testsuite/18_support/comparisons/algorithms/fallback.cc: New test.

(cherry picked from commit e2c79b968f)
2021-08-11 15:30:38 +01:00
Jonathan Wakely
ea32f15d44 libstdc++: Improvements to Doxygen markup
This attempts to improve the doxygen output to work around what seems to
be some bugs in doxygen (issues 8635 and 8638).

The @addtogroup command doesn't work for entities inside a nested
namespace (see 8635) so we need to close and reopen groups on entering
and elaving nested namespaces. This fixes the problem that
chrono::duration and chrono::time_point were not documented in the
"Time" documentation group. I am unable to make the path classes appear
as part of their relevant groups (File System and Filesystem TS), nor
the contents of <exception> or <system_error>. I have made some minor
improvements to the docs for those types, including starting to address
PR 97001 by adding @since to the doxygen comments.

This change also excludes the <experimental/bits/net.h> header from
Doxygen processing, so we don't get an unwanted "Networking-ts" group
in the documentation.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* doc/doxygen/doxygroups.cc: Fix docs for std::literals.
	* doc/doxygen/user.cfg.in: Exclude the Networking TS header.
	Add some more predefined macros.
	* include/bits/fs_fwd.h: Move @addtogroup commands inside
	namespaces. Add better documentation.
	* include/bits/fs_path.h: Likewise.
	* include/experimental/bits/fs_fwd.h: Likewise.
	* include/experimental/bits/fs_path.h: Likewise.
	* include/ext/throw_allocator.h: Fix typo and improve docs.
	* include/std/chrono: Move @addtogroup commands.
	* include/std/system_error: Move @addtogroup commands.
	* libsupc++/exception: Improve documentation.
	* libsupc++/exception.h: Add @since documentation.

(cherry picked from commit f2ce64b53f)
2021-08-11 15:30:37 +01:00
Jonathan Wakely
63758bead0 libstdc++: Improve Doxygen documentation groups [PR 101258]
This defines some new Doxygen groups for C++17 variable templates and
for the contents of <experimental/type_traits>. By documenting the group
as a whole and adding each template to a group we don't need to document
them individually.

Also mark more internals with "@cond undocumented" so that Doxygen
ignores them by default. Also make Doxygen process <experimental/simd>.

For some reason, many of the class templates in <type_traits> do not
appear in the "Metaprogramming" group. For example, add_cv,
remove_extent, and all the is_xxx_constructible and is_xxx_assignable
traits. For some reason, Doxygen doesn't include them in the group,
despite doing it correctly for other traits in the same header.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101258
	* doc/doxygen/user.cfg.in (INPUT): Add <experimental/simd>.
	(COLS_IN_ALPHA_INDEX): Remove obsolete tag.
	(PREDEFINED): Add/fix some more macros that need to be expanded.
	* include/bits/random.h: Stop Doxygen from documenting internal
	implementation details.
	* include/bits/random.tcc: Likewise.
	* include/bits/this_thread_sleep.h: Fix @file name.
	* include/experimental/bits/simd.h: Add to Doxygen group. Do not
	document internal implementation details.
	* include/experimental/bits/simd_detail.h: Do not document
	internal implementation details.
	* include/experimental/simd: Define Doxygen groups.
	* include/experimental/type_traits: Improve documentation for
	the header file. Define groups. Use @since commands.
	* include/std/scoped_allocator (scoped_allocator_adaptor): Move
	declaration before undocumented region.
	* include/std/type_traits (true_type, false_type): Use using
	declaration instead of typedef.
	(is_invocable_v, is_nothrow_invocable_v, is_invocable_r_v)
	(is_nothrow_invocable_r_v): Move definitions next to other C++17
	variable templates.
	Do not document internal implementation details. Move misplaced
	group-end command. Define group for variable templates.
	* include/std/variant: Do not document internal implementation
	details.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.

(cherry picked from commit 6963c3b9ed)
2021-08-11 15:30:37 +01:00
GCC Administrator
fcb9be628e Daily bump. 2021-08-11 00:18:04 +00:00
GCC Administrator
85d87813fc Daily bump. 2021-08-10 00:18:01 +00:00
GCC Administrator
bde6489fe0 Daily bump. 2021-08-09 00:18:16 +00:00
GCC Administrator
990bea6f7e Daily bump. 2021-08-08 00:18:08 +00:00
GCC Administrator
41ddd56e5d Daily bump. 2021-08-07 00:18:16 +00:00
Richard Sandiford
484cc90311 aarch64: Add -mtune=neoverse-512tvb
This patch adds an option to tune for Neoverse cores that have
a total vector bandwidth of 512 bits (4x128 for Advanced SIMD
and a vector-length-dependent equivalent for SVE).  This is intended
to be a compromise between tuning aggressively for a single core like
Neoverse V1 (which can be too narrow) and tuning for AArch64 cores
in general (which can be too wide).

-mcpu=neoverse-512tvb is equivalent to -mcpu=neoverse-v1
-mtune=neoverse-512tvb.

gcc/
	* doc/invoke.texi: Document -mtune=neoverse-512tvb and
	-mcpu=neoverse-512tvb.
	* config/aarch64/aarch64-cores.def (neoverse-512tvb): New entry.
	* config/aarch64/aarch64-tune.md: Regenerate.
	* config/aarch64/aarch64.c (neoverse512tvb_sve_vector_cost)
	(neoverse512tvb_sve_issue_info, neoverse512tvb_vec_issue_info)
	(neoverse512tvb_vector_cost, neoverse512tvb_tunings): New structures.
	(aarch64_adjust_body_cost_sve): Handle -mtune=neoverse-512tvb.
	(aarch64_adjust_body_cost): Likewise.

(cherry picked from commit 048039c49b)
2021-08-06 15:36:58 +01:00
Richard Sandiford
65b5ab4744 aarch64: Restrict issue heuristics to inner vector loop
The AArch64 vector costs try to take issue rates into account.
However, when vectorising an outer loop, we lumped the inner
and outer operations together, which is somewhat meaningless.
This patch restricts the heuristic to the inner loop.

gcc/
	* config/aarch64/aarch64.c (aarch64_add_stmt_cost): Only
	record issue information for operations that occur in the
	innermost loop.

(cherry picked from commit 9690309baf)
2021-08-06 15:36:57 +01:00
Richard Sandiford
54c0d0dd9a aarch64: Tweak MLA vector costs
The issue-based vector costs currently assume that a multiply-add
sequence can be implemented using a single instruction.  This is
generally true for scalars (which have a 4-operand instruction)
and SVE (which allows the output to be tied to any input).
However, for Advanced SIMD, multiplying two values and adding
an invariant will end up being a move and an MLA.

The only target to use the issue-based vector costs is Neoverse V1,
which would generally prefer SVE in this case anyway.  I therefore
don't have a self-contained testcase.  However, the distinction
becomes more important with a later patch.

gcc/
	* config/aarch64/aarch64.c (aarch64_multiply_add_p): Add a vec_flags
	parameter.  Detect cases in which an Advanced SIMD MLA would almost
	certainly require a MOV.
	(aarch64_count_ops): Update accordingly.

(cherry picked from commit 028059b46e)
2021-08-06 15:36:56 +01:00
Richard Sandiford
0c2e1ed84d aarch64: Tweak the cost of elementwise stores
When the vectoriser scalarises a strided store, it counts one
scalar_store for each element plus one vec_to_scalar extraction
for each element.  However, extracting element 0 is free on AArch64,
so it should have zero cost.

I don't have a testcase that requires this for existing -mtune
options, but it becomes more important with a later patch.

gcc/
	* config/aarch64/aarch64.c (aarch64_is_store_elt_extraction): New
	function, split out from...
	(aarch64_detect_vector_stmt_subtype): ...here.
	(aarch64_add_stmt_cost): Treat extracting element 0 as free.

(cherry picked from commit 537afb0857)
2021-08-06 15:36:55 +01:00
Richard Sandiford
b28c5f682b aarch64: Add gather_load_xNN_cost tuning fields
This patch adds tuning fields for the total cost of a gather load
instruction.  Until now, we've costed them as one scalar load
per element instead.  Those scalar_load-based values are also
what the patch uses to fill in the new fields for existing
cost structures.

gcc/
	* config/aarch64/aarch64-protos.h (sve_vec_cost):
	Add gather_load_x32_cost and gather_load_x64_cost.
	* config/aarch64/aarch64.c (generic_sve_vector_cost)
	(a64fx_sve_vector_cost, neoversev1_sve_vector_cost): Update
	accordingly, using the values given by the scalar_load * number
	of elements calculation that we used previously.
	(aarch64_detect_vector_stmt_subtype): Use the new fields.

(cherry picked from commit 78770e0e5d)
2021-08-06 15:36:55 +01:00
Richard Sandiford
398305efe6 aarch64: Split out aarch64_adjust_body_cost_sve
This patch splits the SVE-specific part of aarch64_adjust_body_cost
out into its own subroutine, so that a future patch can call it
more than once.  I wondered about using a lambda to avoid having
to pass all the arguments, but in the end this way seemed clearer.

gcc/
	* config/aarch64/aarch64.c (aarch64_adjust_body_cost_sve): New
	function, split out from...
	(aarch64_adjust_body_cost): ...here.

(cherry picked from commit b585f0112f)
2021-08-06 15:36:54 +01:00
Richard Sandiford
d0d9602e3c aarch64: Add a simple fixed-point class for costing
This patch adds a simple fixed-point class for holding fractional
cost values.  It can exactly represent the reciprocal of any
single-vector SVE element count (including the non-power-of-2 ones).
This means that it can also hold 1/N for all N in [1, 16], which should
be enough for the various *_per_cycle fields.

For now the assumption is that the number of possible reciprocals
is fixed at compile time and so the class should always be able
to hold an exact value.

The class uses a uint64_t to hold the fixed-point value, which means
that it can hold any scaled uint32_t cost.  Normally we don't worry
about overflow when manipulating raw uint32_t costs, but just to be
on the safe side, the class uses saturating arithmetic for all
operations.

As far as the changes to the cost routines themselves go:

- The changes to aarch64_add_stmt_cost and its subroutines are
  just laying groundwork for future patches; no functional change
  intended.

- The changes to aarch64_adjust_body_cost mean that we now
  take fractional differences into account.

gcc/
	* config/aarch64/fractional-cost.h: New file.
	* config/aarch64/aarch64.c: Include <algorithm> (indirectly)
	and cost_fraction.h.
	(vec_cost_fraction): New typedef.
	(aarch64_detect_scalar_stmt_subtype): Use it for statement costs.
	(aarch64_detect_vector_stmt_subtype): Likewise.
	(aarch64_sve_adjust_stmt_cost, aarch64_adjust_stmt_cost): Likewise.
	(aarch64_estimate_min_cycles_per_iter): Use vec_cost_fraction
	for cycle counts.
	(aarch64_adjust_body_cost): Likewise.
	(aarch64_test_cost_fraction): New function.
	(aarch64_run_selftests): Call it.

(cherry picked from commit 83d796d3e5)
2021-08-06 15:36:53 +01:00
Richard Sandiford
32d307b851 aarch64: Turn sve_width tuning field into a bitmask
The tuning structures have an sve_width field that specifies the
number of bits in an SVE vector (or SVE_NOT_IMPLEMENTED if not
applicable).  This patch turns the field into a bitmask so that
it can specify multiple widths at the same time.  For now we
always treat the mininum width as the likely width.

An alternative would have been to add extra fields, which would
have coped correctly with non-power-of-2 widths.  However,
we're very far from supporting constant non-power-of-2 vectors
in GCC, so I think the non-power-of-2 case will in reality always
have to be hidden behind VLA.

gcc/
	* config/aarch64/aarch64-protos.h (tune_params::sve_width): Turn
	into a bitmask.
	* config/aarch64/aarch64.c (aarch64_cmp_autovec_modes): Update
	accordingly.
	(aarch64_estimated_poly_value): Likewise.  Use the least significant
	set bit for the minimum and likely values.  Use the most significant
	set bit for the maximum value.

(cherry picked from commit fa3ca6151c)
2021-08-06 15:36:52 +01:00
Richard Biener
c891d268c4 tree-optimization/101505 - properly determine stmt precision for PHIs
Loop vectorization pattern recog fails to walk PHIs when determining
stmt precisions.  This fails to recognize non-mask uses for bools
in PHIs and outer loop vectorization.

2021-07-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101505
	* tree-vect-patterns.c (vect_determine_precisions): Walk
	PHIs also for loop vectorization.

	* gcc.dg/vect/pr101505.c: New testcase.

(cherry picked from commit 8df3ee8f7d)
2021-08-06 10:43:38 +02:00
Richard Biener
129bf4f2ef c/101512 - fix missing address-taking in c_common_mark_addressable_vec
c_common_mark_addressable_vec fails to look through C_MAYBE_CONST_EXPR
in the case it isn't at the toplevel.

2021-07-21  Richard Biener  <rguenther@suse.de>

	PR c/101512
gcc/c-family/
	* c-common.c (c_common_mark_addressable_vec): Look through
	C_MAYBE_CONST_EXPR even if not at the toplevel.

gcc/testsuite/
	* gcc.dg/torture/pr101512.c: New testcase.

(cherry picked from commit e63d76234d)
2021-08-06 10:43:19 +02:00
GCC Administrator
3c50d31dcf Daily bump. 2021-08-06 00:18:03 +00:00
Martin Liska
91f8a7a34c sanitizer: cherry pick 414482751452e54710f16bae58458c66298aaf69
The patch is needed in order to support recent glibc (2.34).

libsanitizer/ChangeLog:

	PR sanitizer/101749
	* sanitizer_common/sanitizer_posix_libcdep.cpp: Prevent
	generation of dependency on _cxa_guard for static
	initialization.
2021-08-05 10:45:03 +02:00
GCC Administrator
5b857c033e Daily bump. 2021-08-05 00:18:41 +00:00
GCC Administrator
f56873dfdb Daily bump. 2021-08-04 00:18:24 +00:00
GCC Administrator
98e482761b Daily bump. 2021-08-03 07:50:56 +00:00
Haochen Gui
960135b264 Fix execution failure of parity_1.f90 on P10 [PR100952]
gcc/
	PR target/100952
	* config/rs6000/rs6000.md (cstore<mode>4): Fix wrong fall through.

(cherry picked from commit 3382846558)
2021-08-02 11:14:15 +08:00
Joseph Myers
396117287d Update gcc fr.po.
* fr.po: Update.
2021-07-31 19:31:09 +00:00
Xi Ruoyao
7db1795abe mips: Fix up mips_atomic_assign_expand_fenv [PR94780]
Commit message shamelessly copied from 1777beb6b1 by jakub:

This function, because it is sometimes called even outside of function
bodies, uses create_tmp_var_raw rather than create_tmp_var.  But in order
for that to work, when first referenced, the VAR_DECLs need to appear in a
TARGET_EXPR so that during gimplification the var gets the right
DECL_CONTEXT and is added to local decls.

gcc/

	PR target/94780
	* config/mips/mips.c (mips_atomic_assign_expand_fenv): Use
	  TARGET_EXPR instead of MODIFY_EXPR.

(cherry picked from commit 2065654435)
2021-07-31 01:08:29 +08:00
Xi Ruoyao
2a47ee788c mips: add MSA vec_cmp and vec_cmpu expand pattern [PR101132]
Middle-end started to emit vec_cmp and vec_cmpu since GCC 11, causing
ICE on MIPS with MSA enabled.  Add the pattern to prevent it.

gcc/

	PR target/101132
	* config/mips/mips-protos.h (mips_expand_vec_cmp_expr): Declare.
	* config/mips/mips.c (mips_expand_vec_cmp_expr): New function.
	* config/mips/mips-msa.md (vec_cmp<MSA:mode><mode_i>): New
	  expander.
	  (vec_cmpu<IMSA:mode><mode_i>): New expander.

gcc/testsuite/

	PR target/101132
	* gcc.target/mips/pr101132.c: New test.

(cherry picked from commit 45cb789e6a)
2021-07-31 01:07:50 +08:00
Joseph Myers
cbd9dc32f8 Update gcc de.po.
* de.po: Update.
2021-07-30 14:49:24 +00:00
Joseph Myers
d185445c8d Update gcc .po files.
* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
	ja.po, nl.po, ru.po, sr.po, sv.po, zh_CN.po, zh_TW.po: Update.
2021-07-29 21:18:59 +00:00
Bill Schmidt
868cb29b1d rs6000: Add int128 target check to pr101129.c (PR101531)
Backport from mainline.

2021-07-21  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/testsuite/
	PR target/101531
	* gcc.target/powerpc/pr101129.c: Adjust.
2021-07-29 10:25:54 -05:00
Iain Buclaw
0a3f1c2402 d: Return the correct value for C++ constructor calls (PR101664)
C++ constructors return void, even though the front-end semantic treats
them as implicitly returning `this'.  To handle this correctly, the
object reference is cached and used as the result of the expression.

	PR d/101664

gcc/d/ChangeLog:

	* expr.cc (ExprVisitor::visit (CallExp *)): Use object expression as
	result for C++ constructor calls.

gcc/testsuite/ChangeLog:

	* gdc.dg/extern-c++/extern-c++.exp: New.
	* gdc.dg/extern-c++/pr101664.d: New test.
	* gdc.dg/extern-c++/pr101664_1.cc: New test.

(cherry picked from commit 7616ed6307)
2021-07-29 17:18:26 +02:00
Iain Buclaw
2258958694 d: Ensure casting from bool results in either 0 or 1 (PR96435)
If casting from bool, the result is either 0 or 1, any other value
violates @safe code, so enforce that it is never invalid.

	PR d/96435

gcc/d/ChangeLog:

	* d-convert.cc (convert_for_rvalue): New function.
	* d-tree.h (convert_for_rvalue): Declare.
	* expr.cc (ExprVisitor::visit (CastExp *)): Use convert_for_rvalue.
	(build_return_dtor): Likewise.

gcc/testsuite/ChangeLog:

	* gdc.dg/torture/pr96435.d: New test.

(cherry picked from commit 5c9b7408dc)
2021-07-29 17:18:25 +02:00