platform/upstream/gcc.git
2 years ago[Ada] Switch to SR0660
Doug Rupp [Mon, 26 Jul 2021 20:07:30 +0000 (13:07 -0700)]
[Ada] Switch to SR0660

gcc/ada/

* libgnat/s-parame__vxworks.ads (time_t_bits): Change to
Long_Long_Integer'Size.

2 years agoDaily bump.
GCC Administrator [Fri, 1 Oct 2021 00:16:27 +0000 (00:16 +0000)]
Daily bump.

2 years agotestsuite: Fix cf-descriptor-5.f90
David Edelsohn [Thu, 30 Sep 2021 20:43:58 +0000 (16:43 -0400)]
testsuite: Fix cf-descriptor-5.f90

gcc/testsuite/ChangeLog

* gfortran.dg/c-interop/cf-descriptor-5-c.c: Include alloca.h.

2 years agoarm: Enable Cortex-R52+ CPU
Przemyslaw Wirkus [Thu, 30 Sep 2021 20:32:48 +0000 (21:32 +0100)]
arm: Enable Cortex-R52+ CPU

Patch is adding Cortex-R52+ as 'cortex-r52plus' command line
flag for -mcpu option.

gcc/ChangeLog:

* config/arm/arm-cpus.in: Add Cortex-R52+ CPU.
* config/arm/arm-tables.opt: Regenerate.
* config/arm/arm-tune.md: Regenerate.
* doc/invoke.texi: Update docs.

2 years agoc++: __is_trivially_xible and multi-arg aggr paren init [PR102535]
Patrick Palka [Thu, 30 Sep 2021 21:34:23 +0000 (17:34 -0400)]
c++: __is_trivially_xible and multi-arg aggr paren init [PR102535]

is_xible_helper assumes only 0- and 1-argument ctors can be trivial, but
C++20 aggregate paren init means multi-arg ctors can now be trivial too.
This patch relaxes the relevant early exit check accordingly.

PR c++/102535

gcc/cp/ChangeLog:

* method.c (is_xible_helper): Don't exit early for multi-arg
ctors in C++20.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_trivially_constructible7.C: New test.

2 years agoc++: argument order in a variadic type trait intrinsic
Patrick Palka [Thu, 30 Sep 2021 21:29:18 +0000 (17:29 -0400)]
c++: argument order in a variadic type trait intrinsic

When parsing a variadic type trait intrinsic, we build up the list of
trailing arguments in reverse, but we neglect to reverse the list to
the true order afterwards.  This causes us to confuse the meaning of
e.g. __is_xible(x, y, z) vs __is_xible(x, z, y).

Note that this bug doesn't affect the library traits because they pass a
pack expansion as the single trailing argument to __is_xible, which gets
expanded in the correct order by tsubst_tree_list.

gcc/cp/ChangeLog:

* parser.c (cp_parser_trait_expr): Call nreverse on the reversed
list of trailing arguments.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_constructible6.C: New test.

2 years agoc++: defaulted comparisons and vptr fields [PR95567]
Patrick Palka [Thu, 30 Sep 2021 21:29:05 +0000 (17:29 -0400)]
c++: defaulted comparisons and vptr fields [PR95567]

We need to explicitly skip over vptr fields when synthesizing a
defaulted comparison operator, because next_initializable_field
doesn't do so for us.

PR c++/95567

gcc/cp/ChangeLog:

* method.c (build_comparison_op): Skip DECL_VIRTUAL_P fields.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-virtual1.C: New test.

2 years agocompiler: avoid calling Expression::type before lowering
Ian Lance Taylor [Thu, 30 Sep 2021 04:48:48 +0000 (21:48 -0700)]
compiler: avoid calling Expression::type before lowering

This is a minor cleanup to ensure that the various Expression::do_type
methods don't have to worry about the possibility that the Expression
has not been lowered.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/353140

2 years agoFortran: resolve expressions during SIZE simplification
Harald Anlauf [Thu, 30 Sep 2021 18:29:31 +0000 (20:29 +0200)]
Fortran: resolve expressions during SIZE simplification

gcc/fortran/ChangeLog:

PR fortran/102458
* simplify.c (simplify_size): Resolve expressions used in array
specifications so that SIZE can be simplified.

gcc/testsuite/ChangeLog:

PR fortran/102458
* gfortran.dg/pr102458b.f90: New test.

2 years agoFortran: fix reference to Fortran standard in comment
Harald Anlauf [Thu, 30 Sep 2021 18:28:39 +0000 (20:28 +0200)]
Fortran: fix reference to Fortran standard in comment

gcc/fortran/
* expr.c: The correct reference to Fortran standard is: F2018:10.1.12.

2 years agoi386: Eliminate sign extension after logic operation [PR89954]
Uros Bizjak [Thu, 30 Sep 2021 17:33:49 +0000 (19:33 +0200)]
i386: Eliminate sign extension after logic operation [PR89954]

Convert (sign_extend:WIDE (any_logic:NARROW (memory, immediate)))
to (any_logic:WIDE (sign_extend (memory)), (sign_extend (immediate))).
This eliminates sign extension after logic operation.

2021-09-30  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/89954
* config/i386/i386.md
(sign_extend:WIDE (any_logic:NARROW (memory, immediate)) splitters):
New splitters.

gcc/testsuite/
PR target/89954
* gcc.target/i386/pr89954.c: New test.

2 years agoFortran: Fix same_type_as
Tobias Burnus [Thu, 30 Sep 2021 17:08:25 +0000 (19:08 +0200)]
Fortran: Fix same_type_as

A test for CLASS(*) + assumed rank was missing; adding a test to
unlimited_polymorphic_1.f03 showed an ICE as backend_decl wasn't
set. While gfc_get_symbol_decl would fix it, the code also assumed
that the class(*) was a variable and could not be a subobject of
a derived type.

PR fortran/71703
PR fortran/84007

gcc/fortran/ChangeLog:

* trans-intrinsic.c (gfc_conv_same_type_as): Fix handling
of UNLIMITED_POLY.
* trans.h (gfc_vtpr_hash_get): Renamed prototype to ...
(gfc_vptr_hash_get): ... this to match function name.

gcc/testsuite/ChangeLog:

* gfortran.dg/c-interop/c535b-1.f90: Remove wrong comment.
* gfortran.dg/unlimited_polymorphic_1.f03: Extend.
* gfortran.dg/unlimited_polymorphic_32.f90: New test.

2 years agolibphobos: Select the appropriate exception handler in getClassInfo
Iain Buclaw [Sat, 25 Sep 2021 21:18:53 +0000 (23:18 +0200)]
libphobos: Select the appropriate exception handler in getClassInfo

This is analogous to __gdc_personality, which ignores in-flight
exceptions that we haven't collided with yet.

libphobos/ChangeLog:

* libdruntime/gcc/deh.d (ExceptionHeader.getClassInfo): Move to...
(getClassInfo): ...here as free function.  Add lsda parameter.
(scanLSDA): Pass lsda to actionTableLookup.
(actionTableLookup): Add lsda parameter, pass to getClassInfo.
(__gdc_personality): Remove currentCfa variable.

2 years agolibphobos: Print stacktrace before terminating program due to uncaught exception.
Iain Buclaw [Sat, 25 Sep 2021 21:03:41 +0000 (23:03 +0200)]
libphobos: Print stacktrace before terminating program due to uncaught exception.

By default, D run-time has a top level exception handler to catch
anything that was uncaught by user code.  However when the
`rt_trapExceptions' flag is cleared, this handler would not be enabled,
and this termination would occur, aborting the program, but without any
information about the exception.

libphobos/ChangeLog:

* libdruntime/gcc/deh.d (_d_print_throwable): Declare.
(_d_throw): Print stacktrace before terminating program due to
uncaught exception.

2 years agolibphobos: Remove unused variables in gcc.backtrace.
Iain Buclaw [Fri, 24 Sep 2021 08:49:13 +0000 (10:49 +0200)]
libphobos: Remove unused variables in gcc.backtrace.

The core.runtime module always overrides the default parameter value for
constructor calls.  MaxAlignment is not required because a class can be
created on the stack with the `scope' keyword.

libphobos/ChangeLog:

* libdruntime/core/runtime.d (runModuleUnitTests): Use scope to new
LibBacktrace on the stack.
* libdruntime/gcc/backtrace.d (FIRSTFRAME): Remove.
(LibBacktrace.MaxAlignment): Remove.
(LibBacktrace.this): Remove default initialization of firstFrame.
(UnwindBacktrace.this): Likewise.

2 years agolibphobos: Give _Unwind_Exception an alignment that best resembles __attribute__...
Iain Buclaw [Sat, 25 Sep 2021 17:50:52 +0000 (19:50 +0200)]
libphobos: Give _Unwind_Exception an alignment that best resembles __attribute__((aligned))

For interoperability with C++ EH, the alignment should match, otherwise
D may not be able to intercept exceptions thrown from C++.

libphobos/ChangeLog:

* libdruntime/gcc/unwind/generic.d (__aligned__): Define.
(_Unwind_Exception): Align struct to __aligned__.

2 years agolibphobos: Define main function as extern(C) when compiling without D runtime (PR102476)
Iain Buclaw [Fri, 24 Sep 2021 08:59:47 +0000 (10:59 +0200)]
libphobos: Define main function as extern(C) when compiling without D runtime (PR102476)

The default supplied main function as read when compiling with `-fmain'
has extern(D) linkage.  However this does not work when mixing this
option together with `-fno-druntime'.

PR d/102476

gcc/testsuite/ChangeLog:

* gdc.dg/pr102476.d: New test.

libphobos/ChangeLog:

* libdruntime/__main.di: Define main function as extern(C) when
compiling without D runtime.

2 years agolibgomp.fortran/alloc-*.f90: Add missing dg-prune-output
Tobias Burnus [Thu, 30 Sep 2021 12:44:06 +0000 (14:44 +0200)]
libgomp.fortran/alloc-*.f90: Add missing dg-prune-output

libgomp/
* testsuite/libgomp.fortran/alloc-7.f90: Add dg-prune-output
for -fintrinsic-modules-path= warning of the C compiler.
* testsuite/libgomp.fortran/alloc-9.f90: Likewise.
* testsuite/libgomp.fortran/alloc-10.f90: Likewise.

2 years agoopenmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran
Tobias Burnus [Thu, 30 Sep 2021 12:26:46 +0000 (14:26 +0200)]
openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc for Fortran

gcc/ChangeLog:

* omp-low.c (omp_runtime_api_call): Add omp_aligned_{,c}alloc and
omp_{c,re}alloc, fix omp_alloc/omp_free.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.1): Set implementation status to Y for
omp_aligned_{,c}alloc and omp_{c,re}alloc routines.
* omp_lib.f90.in (omp_aligned_alloc, omp_aligned_calloc, omp_calloc,
omp_realloc): Add.
* omp_lib.h.in (omp_aligned_alloc, omp_aligned_calloc, omp_calloc,
omp_realloc): Add.
* testsuite/libgomp.fortran/alloc-10.f90: New test.
* testsuite/libgomp.fortran/alloc-6.f90: New test.
* testsuite/libgomp.fortran/alloc-7.c: New test.
* testsuite/libgomp.fortran/alloc-7.f90: New test.
* testsuite/libgomp.fortran/alloc-8.f90: New test.
* testsuite/libgomp.fortran/alloc-9.f90: New test.

2 years agotestsuite: Skip a test-case when LTO is used [PR102509]
Martin Liska [Thu, 30 Sep 2021 12:12:35 +0000 (14:12 +0200)]
testsuite: Skip a test-case when LTO is used [PR102509]

PR testsuite/102509

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/attr-complex-method.c: Skip if LTO is
  used.
* gcc.c-torture/compile/attr-complex-method-2.c: Likewise.

2 years agoDo not hide asm_out_file in ASM_OUTPUT_ASCII.
Martin Liska [Wed, 15 Sep 2021 11:52:35 +0000 (13:52 +0200)]
Do not hide asm_out_file in ASM_OUTPUT_ASCII.

gcc/ChangeLog:

* defaults.h (ASM_OUTPUT_ASCII): Do not hide global variable
asm_out_file and stream directly to MYFILE.

2 years agoRefine alingment peeling fix
Richard Biener [Thu, 30 Sep 2021 11:05:45 +0000 (13:05 +0200)]
Refine alingment peeling fix

This refines the previous fix further by reverting to the original
code since the API is a bit of a mess.  It also fixes the vector type
used to query the misalignment - that was what triggered the original
bogus change.

2021-09-30  Richard Biener  <rguenther@suse.de>

* tree-vect-data-refs.c (vect_update_misalignment_for_peel):
Restore and fix condition under which we apply npeel to
the DRs misalignment value.

2 years agoFix thinko in previous alignment peeling change
Richard Biener [Thu, 30 Sep 2021 08:21:36 +0000 (10:21 +0200)]
Fix thinko in previous alignment peeling change

I was mistaken in that npeel is -1 for variable peeling - it is 0.

2021-09-30  Richard Biener  <rguenther@suse.de>

* tree-vect-data-refs.c (vect_update_misalignment_for_peel):
Fix npeel check for variable amount of peeling.

2 years agolibstdc++: Fix preprocessor check for C++17
Jonathan Wakely [Thu, 30 Sep 2021 07:59:21 +0000 (08:59 +0100)]
libstdc++: Fix preprocessor check for C++17

libstdc++-v3/ChangeLog:

* include/bits/regex.h (basic_regex::multiline): Fix #if
condition.

2 years agoPlug possible snprintf overflow in lto-wrapper.
Aldy Hernandez [Tue, 28 Sep 2021 13:54:20 +0000 (15:54 +0200)]
Plug possible snprintf overflow in lto-wrapper.

My upcoming improvements to the DOM threader triggered a warning in
this code.  It looks like the format string is ".ltrans%u.ltrans", but
we're only writing a max of ".ltrans" + whatever the MAX_INT is here.

Tested on x86-64 Linux.

gcc/ChangeLog:

* lto-wrapper.c (run_gcc): Plug snprintf overflow.

2 years agoopenmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc
Jakub Jelinek [Thu, 30 Sep 2021 07:30:18 +0000 (09:30 +0200)]
openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc

This patch adds new OpenMP 5.1 allocator entrypoints and in addition to that
fixes an omp_alloc bug which is hard to test for - if the first allocator
fails but has a larger alignment trait and has a fallback allocator, either
the default behavior or a user fallback, then the extra alignment will be used
even in the fallback allocation, rather than just starting with whatever
alignment has been requested (in GOMP_alloc or the minimum one in omp_alloc).

Jonathan's comment on IRC this morning made me realize that I should add
alloc_align attributes to 2 of the prototypes and I still need to add testsuite
coverage for omp_realloc, will do that in a follow-up.

2021-09-30  Jakub Jelinek  <jakub@redhat.com>

* omp.h.in (omp_aligned_alloc, omp_calloc, omp_aligned_calloc,
omp_realloc): New prototypes.
(omp_alloc): Move after omp_free prototype, add __malloc__ (omp_free)
attribute.
* allocator.c: Include string.h.
(omp_aligned_alloc): No longer static, add ialias.  Add new_alignment
variable and use it instead of alignment so that when retrying the old
alignment is used again.  Don't retry if new alignment is the same
as old alignment, unless allocator had pool size.
(omp_alloc, GOMP_alloc, GOMP_free): Use ialias_call.
(omp_aligned_calloc, omp_calloc, omp_realloc): New functions.
* libgomp.map (OMP_5.0.2): Export omp_aligned_alloc, omp_calloc,
omp_aligned_calloc and omp_realloc.
* testsuite/libgomp.c-c++-common/alloc-4.c (main): Add
omp_aligned_alloc, omp_calloc and omp_aligned_calloc tests.
* testsuite/libgomp.c-c++-common/alloc-5.c: New test.
* testsuite/libgomp.c-c++-common/alloc-6.c: New test.
* testsuite/libgomp.c-c++-common/alloc-7.c: New test.
* testsuite/libgomp.c-c++-common/alloc-8.c: New test.

2 years agoAdd gimple_ranger::debug.
Aldy Hernandez [Wed, 29 Sep 2021 18:50:20 +0000 (20:50 +0200)]
Add gimple_ranger::debug.

I'm trying to add one debug() for each dump() to the dumping aids.

Tested on x86-64 Linux.

gcc/ChangeLog:

* gimple-range.cc (gimple_ranger::debug): New.
* gimple-range.h (class gimple_ranger): Add debug.

2 years agoPlug memory leak in hybrid_threader.
Aldy Hernandez [Thu, 30 Sep 2021 00:19:36 +0000 (02:19 +0200)]
Plug memory leak in hybrid_threader.

Tested on x86-64 Linux.

gcc/ChangeLog:

PR middle-end/102519
* tree-vrp.c (hybrid_threader::~hybrid_threader): Free m_query.

2 years agoDaily bump.
GCC Administrator [Thu, 30 Sep 2021 00:16:20 +0000 (00:16 +0000)]
Daily bump.

2 years agodebug/102507: ICE in btf_finalize when compiling with -gbtf
Indu Bhagat [Wed, 29 Sep 2021 20:25:39 +0000 (13:25 -0700)]
debug/102507: ICE in btf_finalize when compiling with -gbtf

Fix the free up of btf_var_ids hash_map in btf_finalize ().

gcc/ChangeLog:

PR debug/102507
* btfout.c (GTY): Add GTY (()) albeit for cosmetic only purpose.
(btf_finalize): Empty the hash_map btf_var_ids.

2 years agoMAINTAINERS: Add myself to DCO section
Jonathan Wakely [Wed, 29 Sep 2021 20:00:30 +0000 (21:00 +0100)]
MAINTAINERS: Add myself to DCO section

ChangeLog:

* MAINTAINERS: Add myself to DCO section.

2 years ago[PR102501] Adjust jump threading testcases for ppc64* and others.
Aldy Hernandez [Tue, 28 Sep 2021 15:53:57 +0000 (17:53 +0200)]
[PR102501] Adjust jump threading testcases for ppc64* and others.

I really don't know what to do here.  This is a bit of whack-o-mole.
The IL is sufficiently different for various architectures that any
tweak can cause the number of jump threads to vary.

For the pr7745-2.c testcase, we have less threading candidates because 2
of them now cross loop boundaries.  Interestingly, this test matches
"Jumps threaded", not threads registered, so the block copier can
drop threads at copying time adding further confusion.

For example, we can register N threads, but the old copier can cancel
N-M threads while updating the CFG for a variety of different reasons
(removed edges, threading through loop exits, etc).  This makes the
"Registering jump threads" not to match the total number of threads this
test checks for with "Jumps threaded".

The pr66752-3.c test OTOH, is just a matter of thread4 eliminating the
"if".  I had erroneously thought it would always be eliminated by
thread3, but we really don't care where it gets cleaned up.  All we know
is that DCE can't depend on the early threaders doing this work, because
it may cross loop boundaries.  I've chosen thread4 arbitrarily, but we
could just as easily pick the ".optimized" dump.

Sorry, I'm really at my wits end here.  I don't see any clean path
forward, except rewrite these tests as gimple IL.  They're close to useless
as they sit.

gcc/testsuite/ChangeLog:

PR testsuite/102501
* gcc.dg/tree-ssa/pr66752-3.c: Adjust.
* gcc.dg/tree-ssa/pr77445-2.c: Adjust.

2 years agoAvoid CFG updates in VRP threader if nothing changed.
Aldy Hernandez [Wed, 29 Sep 2021 08:02:12 +0000 (10:02 +0200)]
Avoid CFG updates in VRP threader if nothing changed.

There is no need to update the CFG or SSAs if nothing has changed in VRP
threading.

gcc/ChangeLog:

* tree-vrp.c (thread_through_all_blocks): Return bool.
(execute_vrp_threader): Return TODO_* flags.
(pass_data_vrp_threader): Set todo_flags_finish to 0.

2 years agoUse a separate TV_* timer for the VRP threader.
Aldy Hernandez [Wed, 29 Sep 2021 15:16:49 +0000 (17:16 +0200)]
Use a separate TV_* timer for the VRP threader.

There seems to be a memory consumption issue on 32 bit hosts after the
hybrid threader patchset.  I'm having a hard time reproducing, and in
the process I've noticed that the threader is using the TV_TREE_VRP
timer.  Having a distinct one could help diagnose this and other
issues going forward.

gcc/ChangeLog:

* timevar.def (TV_TREE_VRP_THREADER): New.
* tree-vrp.c: Use TV_TREE_VRP_THREADER for VRP threader pass.

2 years agoFortran: fix error recovery for invalid constructor
Harald Anlauf [Wed, 29 Sep 2021 18:11:53 +0000 (20:11 +0200)]
Fortran: fix error recovery for invalid constructor

gcc/fortran/ChangeLog:

PR fortran/102520
* array.c (expand_constructor): Do not dereference NULL pointer.

gcc/testsuite/ChangeLog:

PR fortran/102520
* gfortran.dg/pr102520.f90: New test.

2 years agobpf: correct extra_headers
David Faust [Tue, 28 Sep 2021 17:29:50 +0000 (10:29 -0700)]
bpf: correct extra_headers

The BPF CO-RE support (commit 8bdabb37549f12ce727800a1c8aa182c0b1dd42a)
mistakenly overwrote bpf-*-* extra_headers in config.gcc, causing
bpf-helpers.h to not be installed. The redefinition with coreout.h is
unneeded, so delete it.

gcc/ChangeLog:

* config.gcc (bpf-*-*): Do not overwrite extra_headers.

2 years agoFix more testsuite fallout from computed goto changes
Jeff Law [Wed, 29 Sep 2021 15:21:42 +0000 (11:21 -0400)]
Fix more testsuite fallout from computed goto changes

gcc/testsuite
* gcc.c-torture/compile/920831-1.c: Fix computed goto types.
* gcc.c-torture/compile/pr27863.c: Likewise.

2 years agoaarch64: Fix type qualifiers for qtbl1 and qtbx1 Neon builtins
Jonathan Wright [Thu, 23 Sep 2021 13:27:22 +0000 (14:27 +0100)]
aarch64: Fix type qualifiers for qtbl1 and qtbx1 Neon builtins

Fix type qualifiers for qtbl1 and qtbx1 Neon builtins and remove
casts from the Neon intrinsic function bodies that use these
builtins.

gcc/ChangeLog:

2021-09-23  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-builtins.c (TYPES_BINOP_PPU): Define
new type qualifier enum.
(TYPES_TERNOP_SSSU): Likewise.
(TYPES_TERNOP_PPPU): Likewise.
* config/aarch64/aarch64-simd-builtins.def: Define PPU, SSU,
PPPU and SSSU builtin generator macros for qtbl1 and qtbx1
Neon builtins.
* config/aarch64/arm_neon.h (vqtbl1_p8): Use type-qualified
builtin and remove casts.
(vqtbl1_s8): Likewise.
(vqtbl1q_p8): Likewise.
(vqtbl1q_s8): Likewise.
(vqtbx1_s8): Likewise.
(vqtbx1_p8): Likewise.
(vqtbx1q_s8): Likewise.
(vqtbx1q_p8): Likewise.
(vtbl1_p8): Likewise.
(vtbl2_p8): Likewise.
(vtbx2_p8): Likewise.

2 years agolibstdc++: Implement std::regex_constants::multiline (LWG 2503)
Jonathan Wakely [Wed, 29 Sep 2021 12:48:19 +0000 (13:48 +0100)]
libstdc++: Implement std::regex_constants::multiline (LWG 2503)

This implements LWG 2503, which allows ^ and $ to match line terminator
characters, rather than only matching the beginning and end of the
entire input. The multiline option is only valid for ECMAScript, but
for other grammars we ignore it rather than throwing an exception.

This is related to PR libstdc++/102480, which incorrectly said that
ECMAscript should match the beginning of a line when match_prev_avail
is used. I think that's only supposed to happen when multiline is used.

The new regex_constants::multiline and basic_regex::multiline constants
are not defined for strict -std=c++11 and -std=c++14 modes, but
regex_constants::__multiline is always defined, so that the
implementation can use it internally.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/regex.h (basic_regex::multiline): Define constant
for C++17.
* include/bits/regex_constants.h (regex_constants::multiline):
Define constant for C++17.
(regex_constants::__multiline): Define duplicate constant for
internal use in C++11 and C++14.
* include/bits/regex_executor.h (_Executor::_M_match_multiline()):
New member function.
(_Executor::_M_is_line_terminator(_CharT)): New member function.
(_Executor::_M_at_begin(), _Executor::_M_at_end()): Use new
member functions to support multiline matches.
* testsuite/28_regex/algorithms/regex_match/multiline.cc: New test.

2 years agolibstdc++: Check for invalid syntax_option_type values in <regex>
Jonathan Wakely [Wed, 29 Sep 2021 12:48:15 +0000 (13:48 +0100)]
libstdc++: Check for invalid syntax_option_type values in <regex>

The standard says that it is invalid for more than one grammar element
to be set in a value of type regex_constants::syntax_option_type. This
adds a check in the regex compiler andthrows an exception if an invalid
value is used.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/regex_compiler.h (_Compiler::_S_validate): New
function.
* include/bits/regex_compiler.tcc (_Compiler::_Compiler): Use
_S_validate to check flags.
* include/bits/regex_error.h (_S_grammar): New error code for
internal use.
* testsuite/28_regex/basic_regex/ctors/grammar.cc: New test.

2 years agolibstdc++: std::basic_regex should treat '\0' as an ordinary char [PR84110]
Jonathan Wakely [Wed, 29 Sep 2021 12:48:11 +0000 (13:48 +0100)]
libstdc++: std::basic_regex should treat '\0' as an ordinary char [PR84110]

When the input sequence contains a _CharT(0) character, the strchr call
in _Scanner<_CharT>::_M_scan_normal() will search for '\0' and so return
a pointer to the terminating null at the end of the string. This makes
the scanner think it's found a special character. Because it doesn't
match any of the actual special characters, we fall off the end of the
function (or assert in debug mode).

We should check for a null character explicitly and either treat it as
an ordinary character (for the ECMAScript grammar) or an error (for all
others). I'm not 100% sure that's right, but it seems consistent with
the POSIX RE rules where a '\0' means the end of the regex pattern or
the end of the sequence being matched.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/84110
* include/bits/regex_error.h (regex_constants::_S_null): New
error code for internal use.
* include/bits/regex_scanner.tcc (_Scanner::_M_scan_normal()):
Check for null character.
* testsuite/28_regex/basic_regex/84110.cc: New test.

2 years agolibstdc++: Simplify std::basic_regex construction and assignment
Jonathan Wakely [Wed, 29 Sep 2021 12:48:02 +0000 (13:48 +0100)]
libstdc++: Simplify std::basic_regex construction and assignment

Introduce a new _M_compile function which does the common work needed by
all constructors and assignment. Call that directly to avoid multiple
levels of constructor delegation or calls to basic_regex::assign
overloads.

For assignment, there is no need to construct a std::basic_string if we
already have a contiguous sequence of the correct character type, and no
need to construct a temporary basic_regex when assigning from an
existing basic_regex.

Also define the copy and move assignment operators as defaulted, which
does the right thing without constructing a temporary and swapping it.
Copying or moving the shared_ptr member cannot fail, so they can be
noexcept. The assign(const basic_regex&) and assign(basic_regex&&)
member can then be defined in terms of copy or move assignment.

The new _M_compile function takes pointer arguments, so the caller has
to convert arbitrary iterator ranges into a contiguous sequence of
characters. With that simplification, the __compile_nfa helpers are not
needed and can be removed.

This also fixes a bug where construction from a contiguous sequence with
the wrong character type would fail to compile, rather than converting
the elements to the regex character type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/regex.h (__detail::__is_contiguous_iter): Move
here from <bits/regex_compiler.h>.
(basic_regex::_M_compile): New function to compile an NFA from
a regular expression string.
(basic_regex::basic_regex): Use _M_compile instead of delegating
to other constructors.
(basic_regex::operator=(const basic_regex&)): Define as
defaulted.
(basic_regex::operator=(initializer_list<C>)): Use _M_compile.
(basic_regex::assign(const basic_regex&)): Use copy assignment.
(basic_regex::assign(basic_regex&&)): Use move assignment.
(basic_regex::assign(const C*, flag_type)): Use _M_compile
instead of constructing a temporary string.
(basic_regex::assign(const C*, size_t, flag_type)): Likewise.
(basic_regex::assign(const basic_string<C,T,A>&, flag_type)):
Use _M_compile instead of constructing a temporary basic_regex.
(basic_regex::assign(InputIter, InputIter, flag_type)): Avoid
constructing a temporary string for contiguous iterators of the
right value type.
* include/bits/regex_compiler.h (__is_contiguous_iter): Move to
<bits/regex.h>.
(__enable_if_contiguous_iter, __disable_if_contiguous_iter)
(__compile_nfa): Remove.
* testsuite/28_regex/basic_regex/assign/exception_safety.cc: New
test.
* testsuite/28_regex/basic_regex/ctors/char/other.cc: New test.

2 years agotestsuite/102517 - fix FAIL of gcc.dg/pr78408-1.c with OImode availability
Richard Biener [Wed, 29 Sep 2021 12:32:32 +0000 (14:32 +0200)]
testsuite/102517 - fix FAIL of gcc.dg/pr78408-1.c with OImode availability

This fixes the testcase which looks for variants of memcpy after
memset folding which is disturbed when we expand the memcpy inline
earlier which in fact performs the desired optimization but makes
the dump file not match.  For the ease of testing the following
adjusts the smaller structure size to be no longer power-of-two
which avoids the inline expansion.

2021-09-29  Richard Biener  <rguenther@suse.de>

PR testsuite/102517
* gcc.dg/pr78408-1.c: Make S not power-of-two size.

2 years agoFix peeling for alignment with negative step
Richard Biener [Wed, 29 Sep 2021 09:18:23 +0000 (11:18 +0200)]
Fix peeling for alignment with negative step

The following fixes a regression causing us to no longer peel
negative step loops for alignment.  With dr_misalignment now
applying the bias for negative step we have to do the reverse
when adjusting the misalignment for peeled DRs.

2021-09-29  Richard Biener  <rguenther@suse.de>

* tree-vect-data-refs.c (vect_dr_misalign_for_aligned_access):
New helper.
(vect_update_misalignment_for_peel): Use it to update
misaligned to the value necessary for an aligned access.
(vect_get_peeling_costs_all_drs): Likewise.
(vect_enhance_data_refs_alignment): Likewise.

* gcc.target/i386/vect-alignment-peeling-1.c: New testcase.
* gcc.target/i386/vect-alignment-peeling-2.c: Likewise.

2 years agoaarch64: Improve size heuristic for cpymem expansion
Kyrylo Tkachov [Wed, 29 Sep 2021 10:21:45 +0000 (11:21 +0100)]
aarch64: Improve size heuristic for cpymem expansion

Similar to my previous patch for setmem this one does the same for the cpymem expansion.
We count the number of ops emitted and compare it against the alternative of just calling
the library function when optimising for size.
For the code:
void
cpy_127 (char *out, char *in)
{
  __builtin_memcpy (out, in, 127);
}

void
cpy_128 (char *out, char *in)
{
  __builtin_memcpy (out, in, 128);
}

we now emit a call to memcpy (with an extra MOV-immediate instruction for the size) instead of:
cpy_127(char*, char*):
        ldp     q0, q1, [x1]
        stp     q0, q1, [x0]
        ldp     q0, q1, [x1, 32]
        stp     q0, q1, [x0, 32]
        ldp     q0, q1, [x1, 64]
        stp     q0, q1, [x0, 64]
        ldr     q0, [x1, 96]
        str     q0, [x0, 96]
        ldr     q0, [x1, 111]
        str     q0, [x0, 111]
        ret
cpy_128(char*, char*):
        ldp     q0, q1, [x1]
        stp     q0, q1, [x0]
        ldp     q0, q1, [x1, 32]
        stp     q0, q1, [x0, 32]
        ldp     q0, q1, [x1, 64]
        stp     q0, q1, [x0, 64]
        ldp     q0, q1, [x1, 96]
        stp     q0, q1, [x0, 96]
        ret

which is a clear code size win. Speed optimisation heuristics remain unchanged.

2021-09-29  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* config/aarch64/aarch64.c (aarch64_expand_cpymem): Count number of
emitted operations and adjust heuristic for code size.

2021-09-29  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* gcc.target/aarch64/cpymem-size.c: New test.

2 years agoaarch64: Improve size optimisation heuristic for setmem expansion
Kyrylo Tkachov [Wed, 29 Sep 2021 10:00:14 +0000 (11:00 +0100)]
aarch64: Improve size optimisation heuristic for setmem expansion

This patch adjusts the setmem expansion in the backend to track the number of ops it generates
for the DUP + STR/STP inline sequences. This way we can compare the size/complexity of the sequence
against alternatives, notably just returning "false" and thus just emitting a call to memset.

The simple heuristic change here is that if we were going to emit more than 4 operations then
we shouldn't bother and just call memset. The number 4 is chosen because in the worst case for memset
we need to emit 4 instructions: 3 to move the arguments into the right registers and 1 for the call.

The speed optimisation decisions are not affected, though I do want to extend these expansions in a later
patch and I'd like to reuse this ops counting logic there. In any case this patch should make sense on its own.

For the code:
void __attribute__((__noinline__))
set127byte (int64_t *src, int c)
{
  __builtin_memset (src, c, 127);
}

void __attribute__((__noinline__))
set128byte (int64_t *src, int c)
{
  __builtin_memset (src, c, 128);
}

when optimising for size we now get just an immediate move + a call to memset (2 instructions) where before we'd have generated:
set127byte(long*, int):
        dup     v0.16b, w1
        str     q0, [x0, 96]
        stp     q0, q0, [x0]
        stp     q0, q0, [x0, 32]
        stp     q0, q0, [x0, 64]
        str     q0, [x0, 111]
        ret
set128byte(long*, int):
        dup     v0.16b, w1
        stp     q0, q0, [x0]
        stp     q0, q0, [x0, 32]
        stp     q0, q0, [x0, 64]
        stp     q0, q0, [x0, 96]
        ret

which is clearly undesirable for -Os.

I've adjusted the recently-added gcc.target/aarch64/memset-strict-align-1.c testcase to use a bigger struct
and switch to speed optimisation as with this patch we'll just call memset rather than expanding inline.
That is the right decision for size optimisation (the resulting code is indeed shorter).
With -O2 and the new struct size we still try the SIMD expansion and still trigger the path that the testcase is supposed to exercise.

2021-09-27  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* config/aarch64/aarch64.c (aarch64_expand_setmem): Count number of
emitted operations and adjust heuristic for code size.

2021-09-27  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* gcc.target/aarch64/memset-corner-cases-2.c: New test.
* gcc.target/aarch64/memset-strict-align-1.c: Adjust.

2 years agoopenmp: Disallow reduction with var private in containing parallel even on scope...
Jakub Jelinek [Wed, 29 Sep 2021 08:17:52 +0000 (10:17 +0200)]
openmp: Disallow reduction with var private in containing parallel even on scope [PR102504]

The standard has a restriction:
"A list item that appears in a reduction clause of a scope construct must be
shared in the parallel region to which a corresponding scope region binds."
similar to the restriction for worksharing constructs, but we were checking
it only on worksharing constructs and not for scope and ICEd later on during
omp expansion.

2021-09-29  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/102504
* gimplify.c (gimplify_scan_omp_clauses): Use omp_check_private even
in OMP_SCOPE clauses, not just on worksharing construct clauses.

* c-c++-common/gomp/scope-4.c: New test.

2 years agoFix some testcases after my computed goto patch
Andrew Pinski [Wed, 29 Sep 2021 02:01:52 +0000 (02:01 +0000)]
Fix some testcases after my computed goto patch

For some reason I did not see these failures in my testing.
Sorry about that.  Anyways this fixes the testcases by
adding a cast to __INTPTR_TYPE__ and then a cast to void*.

Committed after testing them on x86_64-linux-gnu.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/920826-1.c: Fix computed goto.
* gcc.c-torture/compile/pr27863.c: Likewise.
* gcc.c-torture/compile/pr70190.c: Likewise.
* gcc.dg/torture/pr89135.c: Likewise.
* gcc.dg/torture/pr90071.c: Likewise.
* gcc.dg/vect/bb-slp-pr97709.c: Likewise.

2 years agoAvoid memcpy inline expansion in gcc.dg/out-of-bounds-1.c
Richard Biener [Wed, 29 Sep 2021 06:06:09 +0000 (08:06 +0200)]
Avoid memcpy inline expansion in gcc.dg/out-of-bounds-1.c

This avoids inline expansion to preserve the warning by making
the memcpy size a non-power-of-two as suggested by Martin Sebor.

2021-09-29  Richard Biener  <rguenther@suse.de>

* gcc.dg/out-of-bounds-1.c: Make memcpied size not power-of-two.

2 years agoDaily bump.
GCC Administrator [Wed, 29 Sep 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.

2 years agoRISC-V: Pattern name fix mul*3_highpart -> smul*3_highpart.
Geng Qi [Mon, 27 Sep 2021 11:37:45 +0000 (19:37 +0800)]
RISC-V: Pattern name fix mul*3_highpart -> smul*3_highpart.

No known code changes, just fixes an inconsistency that was noticed.

gcc/
* config/riscv/riscv.md (mulv<mode>4): Call gen_smul<mode>3_highpart.
(<u>mulditi3): Call <su>muldi3_highpart.
(<u>muldi3_highpart): Rename to <su>muldi3_highpart.
(<u>mulsidi3): Call <su>mulsi3_highpart.
(<u>mulsi3_highpart): Rename to <su>mulsi3_highpart.

2 years agoc++: ttp matching with constrained auto parm [PR99909]
Patrick Palka [Tue, 28 Sep 2021 21:26:20 +0000 (17:26 -0400)]
c++: ttp matching with constrained auto parm [PR99909]

Here, when unifying TT with S, processing_template_decl is unset, and
this foils the dependence checks in do_auto_deduction for avoiding
checking constraints on an auto when the initializer is dependent.

This patch fixes this by making sure processing_template_decl is set
around the call to unify from coerce_template_template_parms; this seems
sensible because we're unifying one set of template parameters with
another, so we're dealing with templated trees throughout.

PR c++/99909

gcc/cp/ChangeLog:

* pt.c (coerce_template_template_parms): Keep
processing_template_decl set around the call to unify as well.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp3.C: New test.

2 years agolibstdc++: Fix return values for atomic wait on futex
Jonathan Wakely [Tue, 28 Sep 2021 19:41:46 +0000 (20:41 +0100)]
libstdc++: Fix return values for atomic wait on futex

This fixes a logic error in the futex-based timed wait.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h (__platform_wait_until_impl):
Return false for ETIMEDOUT and true otherwise.

2 years agolibstdc++: Fix 48631_neg test in _GLIBCXX_INLINE_VERSION mode
François Dumont [Tue, 28 Sep 2021 19:45:08 +0000 (21:45 +0200)]
libstdc++: Fix 48631_neg test in _GLIBCXX_INLINE_VERSION mode

libstdc++-v3/ChangeLog:

* testsuite/20_util/default_delete/48631_neg.cc: Adapt dg-prune-output message
to also match message with '__8' in it.

2 years agoc: [PR32122] Require pointer types for computed gotos
Andrew Pinski [Fri, 17 Sep 2021 04:59:03 +0000 (04:59 +0000)]
c: [PR32122] Require pointer types for computed gotos

So GCC has always accepted non-pointer types in computed gotos but
that was wrong based on the documentation:
Any expression of type void * is allowed.

So this fixes the problem by requiring the type to
be a pointer type.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR c/32122

gcc/c/ChangeLog:

* c-parser.c (c_parser_statement_after_labels): Pass
the c_expr instead of the tree to c_finish_goto_ptr.
* c-typeck.c (c_finish_goto_ptr): Change the second
argument type to c_expr.
* c-tree.h (c_finish_goto_ptr): Likewise.
Error out if the expression was not of a pointer type.

gcc/testsuite/ChangeLog:

* gcc.dg/comp-goto-5.c: New test.
* gcc.dg/comp-goto-6.c: New test.

2 years agolibstdc++: Remove obfuscating typedefs in <regex>
Jonathan Wakely [Tue, 28 Sep 2021 12:39:36 +0000 (13:39 +0100)]
libstdc++: Remove obfuscating typedefs in <regex>

There is no benefit to using _SizeT instead of size_t, and IterT tells
you less about the type than const _CharT*. This removes some unhelpful
typedefs.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/regex_automaton.h (_NFA_base::_SizeT): Remove.
* include/bits/regex_compiler.h (_Compiler::_IterT): Remove.
* include/bits/regex_compiler.tcc: Likewise.
* include/bits/regex_scanner.h (_Scanner::_IterT): Remove.
* include/bits/regex_scanner.tcc: Likewise.

2 years agolibstdc++: Tweaks to <regex> to avoid warnings
Jonathan Wakely [Mon, 27 Sep 2021 19:44:24 +0000 (20:44 +0100)]
libstdc++: Tweaks to <regex> to avoid warnings

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/regex_compiler.tcc: Add line break in empty while
statement.
* include/bits/regex_executor.tcc: Avoid unused parameter
warning.

2 years agolibstdc++: Add noexcept to functions in <regex>
Jonathan Wakely [Mon, 27 Sep 2021 19:42:17 +0000 (20:42 +0100)]
libstdc++: Add noexcept to functions in <regex>

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/regex.h (basic_regex, swap): Add noexcept to
non-throwing functions.
* include/bits/regex_automaton.h (_State_base, _State)
(_NFA_base): Likewise.
* include/bits/regex_compiler.h (_Compiler): Likewise.
* include/bits/regex_error.h (regex_error::code()): Likewise.
* include/bits/regex_scanner.h (_Scanner): Likewise.

2 years agolibstdc++: Define macro before it is first checked
Jonathan Wakely [Tue, 31 Aug 2021 14:51:09 +0000 (15:51 +0100)]
libstdc++: Define macro before it is first checked

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h (_GLIBCXX_HAVE_PLATFORM_WAIT):
Define before first attempt to check it.

2 years agoDarwin, D : Add .d suffix to the list for invoking dsymutil.
Iain Sandoe [Fri, 11 Dec 2020 00:34:39 +0000 (00:34 +0000)]
Darwin, D : Add .d suffix to the list for invoking dsymutil.

Recognise .d for D source files on the command line.  This will
trigger an invocation of dsymutil when a D source is present.

gcc/ChangeLog:

* config/darwin.h (DSYMUTIL_SPEC): Recognize D sources.

2 years agolibstdc++: Skip container adaptor tests that fail concept checks
Jonathan Wakely [Fri, 24 Sep 2021 13:32:34 +0000 (14:32 +0100)]
libstdc++: Skip container adaptor tests that fail concept checks

As an extension, our container adaptors SFINAE away the default
constructor if the adapted sequence container is not default
constructible. When _GLIBCXX_CONCEPT_CHECKS is defined we enforce that
the sequence is default constructible, so the tests for the extension
fail. This disables the relevant parts of the tests.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1.cc:
Do not check non-default constructible sequences when
_GLIBCXX_CONCEPT_CHECKS is defined.
* testsuite/23_containers/priority_queue/requirements/explicit_instantiation/1_c++98.cc:
Likewise.
* testsuite/23_containers/queue/requirements/explicit_instantiation/1.cc:
Likewise.
* testsuite/23_containers/queue/requirements/explicit_instantiation/1_c++98.cc:
Likewise.
* testsuite/23_containers/stack/requirements/explicit_instantiation/1.cc:
Likewise.
* testsuite/23_containers/stack/requirements/explicit_instantiation/1_c++98.cc:
Likewise.

2 years agolibstdc++: Skip tests that fail with _GLIBCXX_CONCEPT_CHECKS
Jonathan Wakely [Fri, 24 Sep 2021 13:23:36 +0000 (14:23 +0100)]
libstdc++: Skip tests that fail with _GLIBCXX_CONCEPT_CHECKS

The extension that allows implicitly rebinding a container's allocator
is not allowed when _GLIBCXX_CONCEPT_CHECKS is defined, so skip the
tests for that extension.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* testsuite/23_containers/deque/requirements/explicit_instantiation/3.cc:
Do not test implicit allocator rebinding when _GLIBCXX_CONCEPT_CHECKS
is defined.
* testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/list/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/list/requirements/explicit_instantiation/5.cc:
Likewise.
* testsuite/23_containers/map/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/map/requirements/explicit_instantiation/5.cc:
Likewise.
* testsuite/23_containers/multimap/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/multimap/requirements/explicit_instantiation/5.cc:
Likewise.
* testsuite/23_containers/multiset/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/multiset/requirements/explicit_instantiation/5.cc:
Likewise.
* testsuite/23_containers/set/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/set/requirements/explicit_instantiation/5.cc:
Likewise.
* testsuite/23_containers/unordered_map/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc:
Likewise.
* testsuite/23_containers/vector/requirements/explicit_instantiation/3.cc:
Likewise.

2 years agolibstdc++: Fix concept checks for iterators
Jonathan Wakely [Fri, 24 Sep 2021 12:56:33 +0000 (13:56 +0100)]
libstdc++: Fix concept checks for iterators

This adds some additional checks the the C++98-style concept checks for
iterators, and removes some bogus checks for mutable iterators. Instead
of requiring that the result of dereferencing a mutable iterator is
assignable (which is a property of the value type, not required for the
iterator) check that the reference type is a non-const reference to the
value type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/boost_concept_check.h (_ForwardIteratorConcept)
(_BidirectionalIteratorConcept, _RandomAccessIteratorConcept):
Check result types of iterator operations.
(_Mutable_ForwardIteratorConcept): Check that iterator's
reference type is a reference to its value type.
(_Mutable_BidirectionalIteratorConcept): Do not require the
value type to be assignable.
(_Mutable_RandomAccessIteratorConcept): Likewise.
* testsuite/24_iterators/operations/prev_neg.cc: Adjust dg-error
line number.

2 years agolibstdc++: Improve types used as iterators in testsuite
Jonathan Wakely [Fri, 24 Sep 2021 12:23:34 +0000 (13:23 +0100)]
libstdc++: Improve types used as iterators in testsuite

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/copy/34595.cc: Add missing operation
for type used as an iterator.
* testsuite/25_algorithms/unique_copy/check_type.cc: Likewise.

2 years agolibstdc++: Fix tests that use invalid types in ordered containers
Jonathan Wakely [Fri, 24 Sep 2021 12:21:34 +0000 (13:21 +0100)]
libstdc++: Fix tests that use invalid types in ordered containers

Types used in ordered containers need to be comparable, or the container
needs to use a custom comparison function. These tests fail when
_GLIBCXX_CONCEPT_CHECKS is defined, because the element types aren't
comparable.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* testsuite/20_util/is_nothrow_swappable/value.h: Use custom
comparison function for priority_queue of type with no
relational operators.
* testsuite/20_util/is_swappable/value.h: Likewise.
* testsuite/24_iterators/output/concept.cc: Add operator< to
type used in set.

2 years agolibstdc++: Fix _OutputIteratorConcept checks in algorithms
Jonathan Wakely [Fri, 24 Sep 2021 14:35:20 +0000 (15:35 +0100)]
libstdc++: Fix _OutputIteratorConcept checks in algorithms

The _OutputIteratorConcept should be checked using the correct value
category. The std::move_backward and std::copy_backward algorithms
should use _OutputIteratorConcept instead of _ConvertibleConcept.

In order to use the correct value category, the concept should use a
function that returns _ValueT instead of using an lvalue data member.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/boost_concept_check.h (_OutputIteratorConcept):
Use a function to preserve value category of the type.
* include/bits/stl_algobase.h (copy, move, fill_n): Use a
reference as the second argument for _OutputIteratorConcept.
(copy_backward, move_backward): Use _OutputIteratorConcept
instead of _ConvertibleConcept.

2 years agolibstdc++: Specialize std::pointer_traits<__normal_iterator<I,C>>
Jonathan Wakely [Tue, 28 Sep 2021 14:26:46 +0000 (15:26 +0100)]
libstdc++: Specialize std::pointer_traits<__normal_iterator<I,C>>

This allows std::__to_address to be used with __normal_iterator in
C++11/14/17 modes. Without the partial specialization the deduced
pointer_traits::element_type is incorrect, and so the return type of
__to_address is wrong.

A similar partial specialization is probably needed for
__gnu_debug::_Safe_iterator.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (pointer_traits): Define partial
specialization for __normal_iterator.
* testsuite/24_iterators/normal_iterator/to_address.cc: New test.

2 years agoDarwin, PPC : Fix R13 for PPC64.
Iain Sandoe [Fri, 11 Dec 2020 00:29:42 +0000 (00:29 +0000)]
Darwin, PPC : Fix R13 for PPC64.

We have a somewhat unusual situation in that for PPC64, R13 is
both reserved and callee-saved (it is used internally by the
pthreads implementation to contain pthread_self).

So add R13 to the fixed regs, but also keep it in the callee-
saved set.

gcc/ChangeLog:

* config/rs6000/darwin.h (FIXED_R13): Add for PPC64.
(FIRST_SAVED_GP_REGNO): Save from R13 even when it is one
of the fixed regs.

2 years agolibgcc, X86, Darwin: Export cpu_model and indicator.
Iain Sandoe [Sun, 19 Sep 2021 19:36:49 +0000 (20:36 +0100)]
libgcc, X86, Darwin: Export cpu_model and indicator.

These two symbols have been emitted since 4.8, but were not added
to the Darwin exports, so we have been using the ones from libgcc.a.

Added to libgcc_s now.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libgcc/ChangeLog:

* config/i386/libgcc-darwin.ver: Add Symbols for
__cpu_model, __cpu_indicator_init.

2 years agocoroutines: Only set parm copy guard vars if we have exceptions [PR 102454].
Iain Sandoe [Mon, 27 Sep 2021 19:21:40 +0000 (20:21 +0100)]
coroutines: Only set parm copy guard vars if we have exceptions [PR 102454].

For coroutines, we make copies of the original function arguments into
the coroutine frame.  Normally, these are destroyed on the proper exit
from the coroutine when the frame is destroyed.

However, if an exception is thrown before the first suspend point is
reached, the cleanup has to happen in the ramp function.  These cleanups
are guarded such that they are only applied to any param copies actually
made.

The ICE is caused by an attempt to set the guard variable when there are
no exceptions enabled (the guard var is not created in this case).

Fixed by checking for flag_exceptions in this case too.

While touching this code paths, also clean up the synthetic names used
when a function parm is unnamed.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/102454

gcc/cp/ChangeLog:

* coroutines.cc (analyze_fn_parms): Clean up synthetic names for
unnamed function params.
(morph_fn_to_coro): Do not try to set a guard variable for param
DTORs in the ramp, unless we have exceptions active.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr102454.C: New test.

2 years agolibstdc++: Improve std::forward static assert message
Jonathan Wakely [Tue, 28 Sep 2021 11:35:29 +0000 (12:35 +0100)]
libstdc++: Improve std::forward static assert message

The previous message told you something was wrong, but not why it
happened or why it's bad. This changes it to explain that the function
is being misused.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/move.h (forward(remove_reference_t<T>&&)):
Improve text of static_assert.
* testsuite/20_util/forward/c_neg.cc: Adjust dg-error.
* testsuite/20_util/forward/f_neg.cc: Likewise.

2 years agolibstdc++: Fix mismatched noexcept-specifiers in filesystem::path [PR102499]
Jonathan Wakely [Mon, 27 Sep 2021 21:07:12 +0000 (22:07 +0100)]
libstdc++: Fix mismatched noexcept-specifiers in filesystem::path [PR102499]

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/102499
* include/bits/fs_path.h (path::begin, path::end): Add noexcept
to declarations, to match definitions.

2 years agoaarch64: Add command-line support for Armv8.7-a
Kyrylo Tkachov [Tue, 28 Sep 2021 15:13:26 +0000 (16:13 +0100)]
aarch64: Add command-line support for Armv8.7-a

This patch adds support for -march=armv8.7-a in GCC.
It adds the +ls64 extension that's included in this architecture revision.
Currently this is just the command-line option and +ls64 allows the relevant instructions
to be used in inline assembly. The ACLE defines some intrinsics for them but those can be
added separately later (together with the appropriate __ARM_FEATURE_* predefine).

2021-09-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* config/aarch64/aarch64.h (AARCH64_FL_LS64): Define
(AARCH64_FL_V8_7): Likewise.
(AARCH64_FL_FOR_ARCH8_7): Likewise.
* config/aarch64/aarch64-arches.def (armv8.7-a): Define.
* config/aarch64/aarch64-option-extensions.def (ls64): Define.
* doc/invoke.texi: Document the above.

2 years agoImprove jump threading dump output.
Aldy Hernandez [Tue, 28 Sep 2021 08:19:57 +0000 (10:19 +0200)]
Improve jump threading dump output.

In analyzing PR102511, it has become abundantly clear that we need
better debugging aids for the jump threader solver.  Currently
debugging these issues is a nightmare if you're not intimately
familiar with the code.  This patch attempts to improve this.

First, I'm enabling path solver dumps with TDF_THREADING.  None of the
available TDF_* flags are a good match, and using TDF_DETAILS would blow
up the dump file, since both threaders continually call the solver to
try out candidates.  This will allow dumping path solver details without
having to resort to hacking the source.

I am also dumping the current registered_jump_thread dbg counter used
by the registry, in the solver.  That way narrowing down a problematic
thread can then be examined by -fdump-*-threading and looking at the
solver details surrounding the appropriate counter (which the dbgcnt
also dumps to the dump file).

You still need knowledge of the solver to debug these issues, but at
least now it's not entirely opaque.

Tested on x86-64 Linux.

gcc/ChangeLog:

* dbgcnt.c (dbg_cnt_counter): New.
* dbgcnt.h (dbg_cnt_counter): New.
* dumpfile.c (dump_options): Add entry for TDF_THREADING.
* dumpfile.h (enum dump_flag): Add TDF_THREADING.
* gimple-range-path.cc (DEBUG_SOLVER): Use TDF_THREADING.
* tree-ssa-threadupdate.c (dump_jump_thread_path): Dump out
debug counter.

2 years agolibgomp: Only check for 2*sizeof(void*) int type with Fortran [PR96661]
Tobias Burnus [Tue, 28 Sep 2021 13:15:47 +0000 (15:15 +0200)]
libgomp: Only check for 2*sizeof(void*) int type with Fortran [PR96661]

The depend type is a struct with two pointer members for C/C++ - but for
Fortran OpenMP requires an integer type with kind = omp_depend_kind. Thus,
libgomp's configure checks that an integer type/kind with size 2*sizeof(void*)
is available. However, this integer type/kind is not needed when building without
Fortran support. Thus, only check this when Fortran is enabled.

libgomp/
PR libgomp/96661
* configure.ac: Only check for int-type = 2*size_t support when
building with Fortran support.
* configure: Regenerate.

2 years agoreassoc: Test rank biasing
Ilya Leoshkevich [Tue, 14 Sep 2021 19:31:31 +0000 (21:31 +0200)]
reassoc: Test rank biasing

Add both positive and negative tests.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/reassoc-46.c: New test.
* gcc.dg/tree-ssa/reassoc-46.h: Common code for new tests.
* gcc.dg/tree-ssa/reassoc-47.c: New test.
* gcc.dg/tree-ssa/reassoc-48.c: New test.
* gcc.dg/tree-ssa/reassoc-49.c: New test.
* gcc.dg/tree-ssa/reassoc-50.c: New test.
* gcc.dg/tree-ssa/reassoc-51.c: New test.

2 years agoEnable jump threading at -O1.
Aldy Hernandez [Tue, 28 Sep 2021 09:33:11 +0000 (11:33 +0200)]
Enable jump threading at -O1.

My previous patch gating all jump threading by -fthread-jumps had the
side effect of turning off DOM jump threading at -O1.  This causes
numerous -Wuninitialized false positives.  This patch turns on jump
threading at -O1 to minimize the disruption.

gcc/ChangeLog:

* cfgcleanup.c (pass_jump::execute): Check
flag_expensive_optimizations.
(pass_jump_after_combine::gate): Same.
* doc/invoke.texi (-fthread-jumps): Enable for -O1.
* opts.c (default_options_table): Enable -fthread-jumps at -O1.
* tree-ssa-threadupdate.c
(fwd_jt_path_registry::remove_jump_threads_including): Bail unless
flag_thread_jumps.

gcc/testsuite/ChangeLog:

* gcc.dg/auto-init-uninit-1.c: Adjust.
* gcc.dg/auto-init-uninit-15.c: Same.
* gcc.dg/guality/example.c: Same.
* gcc.dg/loop-8.c: Same.
* gcc.dg/strlenopt-40.c: Same.
* gcc.dg/tree-ssa/pr18133-2.c: Same.
* gcc.dg/tree-ssa/pr18134.c: Same.
* gcc.dg/uninit-1.c: Same.
* gcc.dg/uninit-pr44547.c: Same.
* gcc.dg/uninit-pr59970.c: Same.

2 years ago'gfortran.dg/assumed_rank_22_aux.c' messages printed vs. DejaGnu
Thomas Schwinge [Tue, 28 Sep 2021 07:02:56 +0000 (09:02 +0200)]
'gfortran.dg/assumed_rank_22_aux.c' messages printed vs. DejaGnu

Print lower-case 'error: [...]' instead of upper-case 'ERROR: [...]', to not
confuse the DejaGnu log processing harness into thinking these are DejaGnu
harness ERRORs:

    Running /scratch/tschwing/build2-trusty-cs/gcc/build/submit-big/source-gcc/gcc/testsuite/gfortran.dg/dg.exp ...
    +ERROR: c_assumed num=100: x->dim[2].extent = -1 != 0
    +ERROR: c_assumed num=100: x->dim[2].extent = -1 != 0
    +ERROR: c_assumed num=100: x->dim[2].extent = -1 != 0
    +ERROR: c_assumed num=100: x->dim[2].extent = -1 != 0
    +ERROR: c_assumed num=100: x->dim[2].extent = -1 != 0
    +ERROR: c_assumed num=100: x->dim[2].extent = -1 != 0
    [...]

Fix-up for recent commit 00f6de9c69119594f7dad3bd525937c94c8200d0
"Fortran: Fix assumed-size to assumed-rank passing [PR94070]".

gcc/testsuite/
* gfortran.dg/assumed_rank_22_aux.c: Adjust messages printed.

2 years agoFurther test case adjustment re "Fortran: Fix assumed-size to assumed-rank passing"
Thomas Schwinge [Tue, 28 Sep 2021 06:05:28 +0000 (08:05 +0200)]
Further test case adjustment re "Fortran: Fix assumed-size to assumed-rank passing"

Fix-up for recent commit 00f6de9c69119594f7dad3bd525937c94c8200d0
"Fortran: Fix assumed-size to assumed-rank passing [PR94070]",
and commit da1f6391b7c255e4e2eea983832120eff4f7d3df
"libgomp.oacc-fortran/privatized-ref-2.f90: Fix dg-note".

Due to use of '#if !ACC_MEM_SHARED' conditionals in
'libgomp.oacc-fortran/if-1.f90', 'target { !  openacc_host_selected }'
needs some special care (ignoring the pre-existing mismatch of
'ACC_MEM_SHARED' vs. 'openacc_host_selected').

As seen with GCN offloading, we need to revert to another bit of the
original code in 'libgomp.oacc-fortran/privatized-ref-2.f90'.

libgomp/
* testsuite/libgomp.oacc-fortran/if-1.f90: Adjust.
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Likewise.

2 years agoreassoc: Propagate PHI_LOOP_BIAS along single uses
Ilya Leoshkevich [Tue, 23 Jun 2020 23:30:47 +0000 (01:30 +0200)]
reassoc: Propagate PHI_LOOP_BIAS along single uses

PR tree-optimization/49749 introduced code that shortens dependency
chains containing loop accumulators by placing them last on operand
lists of associative operations.

456.hmmer benchmark on s390 could benefit from this, however, the code
that needs it modifies loop accumulator before using it, and since only
so-called loop-carried phis are are treated as loop accumulators, the
code in the present form doesn't really help.   According to Bill
Schmidt - the original author - such a conservative approach was chosen
so as to avoid unnecessarily swapping operands, which might cause
unpredictable effects.  However, giving special treatment to forms of
loop accumulators is acceptable.

The definition of loop-carried phi is: it's a single-use phi, which is
used in the same innermost loop it's defined in, at least one argument
of which is defined in the same innermost loop as the phi itself.
Given this, it seems natural to treat single uses of such phis as phis
themselves.

gcc/ChangeLog:

* tree-ssa-reassoc.c (biased_names): New global.
(propagate_bias_p): New function.
(loop_carried_phi): Remove.
(propagate_rank): Propagate bias along single uses.
(get_rank): Update biased_names when needed.

2 years agoreassoc: Do not bias loop-carried PHIs early
Ilya Leoshkevich [Tue, 14 Sep 2021 18:41:18 +0000 (20:41 +0200)]
reassoc: Do not bias loop-carried PHIs early

Biasing loop-carried PHIs during the 1st reassociation pass interferes
with reduction chains and does not bring measurable benefits, so do it
only during the 2nd reassociation pass.

gcc/ChangeLog:

* passes.def (pass_reassoc): Rename parameter to early_p.
* tree-ssa-reassoc.c (reassoc_bias_loop_carried_phi_ranks_p):
New variable.
(phi_rank): Don't bias loop-carried phi ranks
before vectorization pass.
(execute_reassoc): Add bias_loop_carried_phi_ranks_p parameter.
(pass_reassoc::pass_reassoc): Add bias_loop_carried_phi_ranks_p
initializer.
(pass_reassoc::set_param): Set bias_loop_carried_phi_ranks_p
value.
(pass_reassoc::execute): Pass bias_loop_carried_phi_ranks_p to
execute_reassoc.
(pass_reassoc::bias_loop_carried_phi_ranks_p): New member.

2 years agoi386: Don't emit fldpi etc. if -frounding-math [PR102498]
Jakub Jelinek [Tue, 28 Sep 2021 11:02:51 +0000 (13:02 +0200)]
i386: Don't emit fldpi etc. if -frounding-math [PR102498]

i387 has instructions to store some transcedental numbers into the top of
stack.  The problem is that what exact bit in the last place one gets for
those depends on the current rounding mode, the CPU knows the number with
slightly higher precision.  The compiler assumes rounding to nearest when
comparing them against constants in the IL, but at runtime the rounding
can be different and so some of these depending on rounding mode and the
constant could be 1 ulp higher or smaller than expected.
We only support changing the rounding mode at runtime if the non-default
-frounding-mode option is used, so the following patch just disables
using those constants if that flag is on.

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

PR target/102498
* config/i386/i386.c (standard_80387_constant_p): Don't recognize
special 80387 instruction XFmode constants if flag_rounding_math.

* gcc.target/i386/pr102498.c: New test.

2 years agotree-optimization/99793 - testcase for the PR
Richard Biener [Tue, 28 Sep 2021 10:48:50 +0000 (12:48 +0200)]
tree-optimization/99793 - testcase for the PR

This adds a testcase for the PR which was fixed with the fix for
PR100112.

2021-09-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99793
* gcc.dg/tree-ssa/pr99793.c: New testcase.

2 years agotree-optimization/100112 - VN last_vuse and redundant store elimination
Richard Biener [Mon, 27 Sep 2021 10:01:38 +0000 (12:01 +0200)]
tree-optimization/100112 - VN last_vuse and redundant store elimination

This avoids the last_vuse optimization hindering redundant store
elimination by always also recording the original VUSE that was
in effect on the load.

In stage3 gcc/*.o we have 3182752 times recorded a single
entry and 903409 times two entries (that's ~20% overhead).

With just recording a single entry the number of hashtable lookups
done when walking the vuse->vdef links to find an earlier access
is 28961618.  When recording the second entry this makes us find
that earlier for donwnstream redundant accesses, reducing the number
of hashtable lookups to 25401052 (that's a ~10% reduction).

2021-09-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100112
* tree-ssa-sccvn.c (visit_reference_op_load): Record the
referece into the hashtable twice in case last_vuse is
different from the original vuse on the stmt.

* gcc.dg/tree-ssa/ssa-fre-95.c: New testcase.

2 years agoopenmp: Don't call omp_finish_clause on implicitly added private clauses on simd...
Jakub Jelinek [Tue, 28 Sep 2021 09:38:03 +0000 (11:38 +0200)]
openmp: Don't call omp_finish_clause on implicitly added private clauses on simd [PR102492]

The gimplifier adds implicit private clauses on SIMD constructs for local
variables in the SIMD body if they are addressable to make sure they use
the magic arrays with "omp simd array" attribute (such that each SIMD lane
has its own copy), but we actually don't need to default privatize etc. those,
the construction for them is done in the SIMD body and so is destruction.
omp_finish_clause for C++ now requires default constructor (and dtor) for private,
so that OpenMP 5.1 default(private) works, but that will never be needed on
SIMD.  So, this patch just doesn't call omp_finish_clause for private on simd.
The C and Fortran langhooks don't do anything for private.

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

PR middle-end/102492
* gimplify.c (gimplify_adjust_omp_clauses_1): Don't call the
omp_finish_clause langhook on implicitly added OMP_CLAUSE_PRIVATE
clauses on SIMD constructs.

* g++.dg/gomp/simd-3.C: New test.

2 years agoReturn VARYING in range_on_path_entry if nothing found.
Aldy Hernandez [Tue, 28 Sep 2021 07:38:50 +0000 (09:38 +0200)]
Return VARYING in range_on_path_entry if nothing found.

The problem here is that the solver's code solving unknown SSAs on entry
to a path was returning UNDEFINED if there were no incoming edges to the
start of the path that were not the function entry block.  This caused a
cascade of pain down stream.

Tested on x86-64 Linux.

PR tree-optimization/102511

gcc/ChangeLog:

* gimple-range-path.cc (path_range_query::range_on_path_entry):
Return VARYING when nothing found.

gcc/testsuite/ChangeLog:

* gcc.dg/pr102511.c: New test.
* gcc.dg/tree-ssa/ssa-dom-thread-14.c: Adjust.

2 years agotop-level configure: setup target_configdirs based on repository
Andrew Burgess [Wed, 22 Sep 2021 14:15:41 +0000 (15:15 +0100)]
top-level configure: setup target_configdirs based on repository

The top-level configure script is shared between the gcc repository
and the binutils-gdb repository.

The target_configdirs variable in the configure.ac script, defines
sub-directories that contain components that should be built for the
target using the target tools.

Some components, e.g. zlib, are built as both host and target
libraries.

This causes problems for binutils-gdb.  If we run 'make all' in the
binutils-gdb repository we end up trying to build a target version of
the zlib library, which requires the target compiler be available.
Often the target compiler isn't immediately available, and so the
build fails.

The problem with zlib impacted a previous attempt to synchronise the
top-level configure scripts from gcc to binutils-gdb, see this thread:

  https://sourceware.org/pipermail/binutils/2019-May/107094.html

And I'm in the process of importing libbacktrace in to binutils-gdb,
which is also a host and target library, and triggers the same issues.

I believe that for binutils-gdb, at least at the moment, there are no
target libraries that we need to build.

In the configure script we build three lists of things we want to
build, $configdirs, $build_configdirs, and $target_configdirs, we also
build two lists of things we don't want to build, $skipdirs and
$noconfigdirs.  We then remove anything that is in the lists of things
not to build, from the list of things that should be built.

My proposal is to add everything in target_configdirs into skipdirs,
if the source tree doesn't contain a gcc/ sub-directory.  The result
is that for binutils-gdb no target tools or libraries will be built,
while for the gcc repository, nothing should change.

If a user builds a unified source tree, then the target tools and
libraries should still be built as the gcc/ directory will be present.

I've tested a build of gcc on x86-64, and the same set of target
libraries still seem to get built.  On binutils-gdb this change
resolves the issues with 'make all'.

ChangeLog:

* configure: Regenerate.
* configure.ac (skipdirs): Add the contents of target_configdirs if
we are not building gcc.

2 years agoAVX512FP16: Support basic 64/32bit vector type and operation.
Hongyu Wang [Thu, 15 Jul 2021 05:31:24 +0000 (13:31 +0800)]
AVX512FP16: Support basic 64/32bit vector type and operation.

For 32bit target, V4HF vector is parsed same as __m64 type, V2HF
is parsed by stack and returned from GPR since it is not specified
by ABI.

gcc/ChangeLog:

PR target/102230
* config/i386/i386.h (VALID_AVX512FP16_REG_MODE): Add
V2HF mode check.
(VALID_SSE2_REG_VHF_MODE): Add V4HFmode and V2HFmode.
(VALID_MMX_REG_MODE): Add V4HFmode.
(SSE_REG_MODE_P): Replace VALID_AVX512FP16_REG_MODE with
vector mode condition.
* config/i386/i386.c (classify_argument): Parse V4HF/V2HF
via sse regs.
(function_arg_32): Add V4HFmode.
(function_arg_advance_32): Likewise.
* config/i386/i386.md (mode): Add V4HF/V2HF.
(MODE_SIZE): Likewise.
* config/i386/mmx.md (MMXMODE): Add V4HF mode.
(V_32): Add V2HF mode.
(VHF_32_64): New mode iterator.
(*mov<mode>_internal): Adjust sse alternatives to support
V4HF mode move.
(*mov<mode>_internal): Adjust sse alternatives to support
V2HF mode move.
(<insn><mode>3): New define_insn for add/sub/mul/div.

gcc/testsuite/ChangeLog:

PR target/102230
* gcc.target/i386/avx512fp16-floatvnhf.c: Remove xfail.
* gcc.target/i386/avx512fp16-trunc-extendvnhf.c: Ditto.
* gcc.target/i386/avx512fp16-truncvnhf.c: Ditto.
* gcc.target/i386/avx512fp16-64-32-vecop-1.c: New test.
* gcc.target/i386/avx512fp16-64-32-vecop-2.c: Ditto.
* gcc.target/i386/pr102230.c: Ditto.

2 years agoFix gcc.target/i386/vect-pr97352.c for -m32 -march=cascadelake
Richard Biener [Tue, 28 Sep 2021 08:04:00 +0000 (10:04 +0200)]
Fix gcc.target/i386/vect-pr97352.c for -m32 -march=cascadelake

The easiest is to disable AVX2 and AVX512F explicitely.

2021-09-28  Richard Biener  <rguenther@suse.de>

* gcc.target/i386/vect-pr97352.c: Pass -mno-avx2 -mno-avx512f.

2 years agogfortran.dg/include_15.f90: Add dg-prune-output [PR102500]
Tobias Burnus [Tue, 28 Sep 2021 07:49:12 +0000 (09:49 +0200)]
gfortran.dg/include_15.f90: Add dg-prune-output [PR102500]

gcc/testsuite/
PR fortran/102500
* gfortran.dg/include_15.f90: Add 'dg-prune-output' to prune
-Wmissing-include-dirs output printed or not depending on
how the testsuite is run.

2 years agoFix gcc.dg/vect/bb-slp-pr65935.c FAIL with AVX after recent change
Richard Biener [Tue, 28 Sep 2021 06:59:49 +0000 (08:59 +0200)]
Fix gcc.dg/vect/bb-slp-pr65935.c FAIL with AVX after recent change

This avoids bigger than V2DF vectorization which disturbs the ability
to consistently check for the vectorization result after us now
also vectorizing the V2DF tail of a V4DF vectorization variant.

2021-09-28  Richard Biener  <rguenther@suse.de>

* gcc.dg/vect/bb-slp-pr65935.c: Prefer 128bit vectorization
on x86.

2 years agoControl all jump threading passes with -fjump-threads.
Aldy Hernandez [Mon, 27 Sep 2021 14:41:01 +0000 (16:41 +0200)]
Control all jump threading passes with -fjump-threads.

Last year I mentioned that -fthread-jumps was being ignored by the
majority of our jump threading passes, and Jeff said he'd be in favor
of fixing this.

This patch remedies the situation, but it does change existing behavior.
Currently -fthread-jumps is only enabled for -O2, -O3, and -Os.  This
means that even if we restricted all jump threading passes with
-fthread-jumps, DOM jump threading would still seep through since it
runs at -O1.

I propose this patch, but it does mean that DOM jump threading would
have to be explicitly enabled with -O1 -fthread-jumps.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (pass_thread_jumps::gate): Check
flag_thread_jumps.
(pass_early_thread_jumps::gate): Same.
* tree-ssa-threadedge.c (jump_threader::thread_outgoing_edges):
Return if !flag_thread_jumps.
* tree-ssa-threadupdate.c
(jt_path_registry::register_jump_thread): Assert that
flag_thread_jumps is true.

gcc/testsuite/ChangeLog:

* gcc.dg/auto-init-uninit-1.c: Add -fthread-jumps.
* gcc.dg/auto-init-uninit-15.c: Same.
* gcc.dg/guality/example.c: Same.
* gcc.dg/loop-8.c: Same.
* gcc.dg/strlenopt-40.c: Same.
* gcc.dg/tree-ssa/pr18133-2.c: Same.
* gcc.dg/tree-ssa/pr18134.c: Same.
* gcc.dg/uninit-1.c: Same.
* gcc.dg/uninit-pr44547.c: Same.
* gcc.dg/uninit-pr59970.c: Same.

2 years agoRelax condition of (vec_concat:M(vec_select op0 idx0)(vec_select op0 idx1)) to allow...
liuhongt [Fri, 10 Sep 2021 02:15:58 +0000 (10:15 +0800)]
Relax condition of (vec_concat:M(vec_select op0 idx0)(vec_select op0 idx1)) to allow different modes between op0 and M, but have same inner mode.

This will enable optimization for below pattern.

(set (reg:V2DF 87 [ xx ])
    (vec_concat:V2DF (vec_select:DF (reg:V4DF 92)
            (parallel [
                    (const_int 2 [0x2])
                ]))
        (vec_select:DF (reg:V4DF 92)
            (parallel [
                    (const_int 3 [0x3])
                ]))))

gcc/ChangeLog:

* simplify-rtx.c
(simplify_context::simplify_binary_operation_1): Relax
condition of simplifying (vec_concat:M (vec_select op0
index0)(vec_select op1 index1)) to allow different modes
between op0 and M, but have same inner mode.

gcc/testsuite/ChangeLog:

* gcc.target/i386/vect-rebuild.c: Adjust testcases.
* gcc.target/i386/avx512f-vect-rebuild.c: New test.

2 years agoSupport 128/256/512-bit vector plus/smin/smax reduction for _Float16.
liuhongt [Mon, 27 Sep 2021 06:57:38 +0000 (14:57 +0800)]
Support 128/256/512-bit vector plus/smin/smax reduction for _Float16.

gcc/ChangeLog:

* config/i386/i386-expand.c (emit_reduc_half): Handle
V8HF/V16HF/V32HFmode.
* config/i386/sse.md (REDUC_SSE_PLUS_MODE): Add V8HF.
(REDUC_SSE_SMINMAX_MODE): Ditto.
(REDUC_PLUS_MODE): Add V16HF and V32HF.
(REDUC_SMINMAX_MODE): Ditto.

gcc/testsuite

* gcc.target/i386/avx512fp16-reduce-op-2.c: New test.
* gcc.target/i386/avx512fp16-reduce-op-3.c: New test.

2 years agoDaily bump.
GCC Administrator [Tue, 28 Sep 2021 00:16:21 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: deduction guides and ttp rewriting [PR102479]
Patrick Palka [Mon, 27 Sep 2021 20:01:10 +0000 (16:01 -0400)]
c++: deduction guides and ttp rewriting [PR102479]

The problem here is ultimately that rewrite_tparm_list when rewriting a
TEMPLATE_TEMPLATE_PARM introduces a tree cycle in the rewritten
ttp that structural_comptypes can't cope with.  In particular the
DECL_TEMPLATE_PARMS of a ttp's TEMPLATE_DECL normally captures an empty
parameter list at its own level (and so the TEMPLATE_DECL doesn't appear
in its own DECL_TEMPLATE_PARMS), but rewrite_tparm_list ends up giving
it a complete parameter list.  In the new testcase below, this causes
infinite recursion from structural_comptypes when comparing Tmpl<char>
with Tmpl<long> (where both 'Tmpl's are rewritten ttps).

This patch fixes this by making rewrite_template_parm give a rewritten
template template parm an empty parameter list at its own level, thereby
avoiding the tree cycle.  Testing the alias CTAD case revealed that
we're not setting current_template_parms in alias_ctad_tweaks, which
this patch also fixes.

PR c++/102479

gcc/cp/ChangeLog:

* pt.c (rewrite_template_parm): Handle single-level tsubst_args.
Avoid a tree cycle when assigning the DECL_TEMPLATE_PARMS for a
rewritten ttp.
(alias_ctad_tweaks): Set current_template_parms accordingly.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction12.C: Also test alias CTAD in the
same way.
* g++.dg/cpp1z/class-deduction99.C: New test.

2 years agoMinor cleanups to solver.
Aldy Hernandez [Sat, 25 Sep 2021 07:28:10 +0000 (09:28 +0200)]
Minor cleanups to solver.

These are some minor cleanups and renames that surfaced after the
hybrid_threader work.

gcc/ChangeLog:

* gimple-range-path.cc
(path_range_query::precompute_ranges_in_block): Rename to...
(path_range_query::compute_ranges_in_block): ...this.
(path_range_query::precompute_ranges): Rename to...
(path_range_query::compute_ranges): ...this.
(path_range_query::precompute_relations): Rename to...
(path_range_query::compute_relations): ...this.
(path_range_query::precompute_phi_relations): Rename to...
(path_range_query::compute_phi_relations): ...this.
* gimple-range-path.h: Rename precompute* to compute*.
* tree-ssa-threadbackward.c
(back_threader::find_taken_edge_switch): Same.
(back_threader::find_taken_edge_cond): Same.
* tree-ssa-threadedge.c
(hybrid_jt_simplifier::compute_ranges_from_state): Same.
(hybrid_jt_state::register_equivs_stmt): Inline...
* tree-ssa-threadedge.h: ...here.

2 years agoRemove old VRP jump threader code.
Aldy Hernandez [Fri, 24 Sep 2021 16:39:47 +0000 (18:39 +0200)]
Remove old VRP jump threader code.

There's a lot of code that melts away without the ASSERT_EXPR based jump
threader.  Also, I cleaned up the include files as part of the process.

gcc/ChangeLog:

* tree-vrp.c (lhs_of_dominating_assert): Remove.
(class vrp_jt_state): Remove.
(class vrp_jt_simplifier): Remove.
(vrp_jt_simplifier::simplify): Remove.
(class vrp_jump_threader): Remove.
(vrp_jump_threader::vrp_jump_threader): Remove.
(vrp_jump_threader::~vrp_jump_threader): Remove.
(vrp_jump_threader::before_dom_children): Remove.
(vrp_jump_threader::after_dom_children): Remove.

2 years agoReplace VRP threader with a hybrid forward threader.
Aldy Hernandez [Tue, 21 Sep 2021 08:27:53 +0000 (10:27 +0200)]
Replace VRP threader with a hybrid forward threader.

This patch implements the new hybrid forward threader and replaces the
embedded VRP threader with it.

With all the pieces that have gone in, the implementation of the hybrid
threader is straightforward: convert the current state into
SSA imports that the solver will understand, and let the path solver
precompute ranges and relations for the path.  After this setup is done,
we can use the range_query API to solve gimple statements in the threader.
The forward threader is now engine agnostic so there are no changes to
the threader per se.

I have put the hybrid bits in tree-ssa-threadedge.*, instead of VRP,
because they will also be used in the evrp removal of the DOM/threader,
which is my next task.

Most of the patch, is actually test changes.  I have gone through every
single one and verified that we're correct.  Most were trivial dump
file name changes, but others required going through the IL an
certifying that the different IL was expected.

For example, in pr59597.c, we have one less thread because the
ASSERT_EXPR was getting in the way, and making it seem like things were
not crossing loops.  The hybrid threader sees the correct representation
of the IL, and avoids threading this one case.

The final numbers are a 12.16% improvement in jump threads immediately
after VRP, and a 0.82% improvement in overall jump threads.  The
performance drop is 0.6% (plus the 1.43% hit from moving the embedded
threader into its own pass).  As I've said, I'd prefer to keep the
threader in its own pass, but if this is an issue, we can address this
with a shared ranger when VRP is replaced with an evrp instance
(upcoming).

Note, that these numbers are slightly different than what I originally
posted.  A few correctness tweaks, plus restricting loop threads, made
the difference.  That being said, I was aiming for par.  A 12% gain is
just gravy ;-).  When we merge the threaders, we should see even better
numbers-- and we'll have the benefit of an entire release stress testing
the solver.

As I mentioned in my introductory note, paths ending in MEM_REF
conditional are missing.  In reality, this didn't make a difference, as
it was so rare.  However, as a follow-up, I will distill a test and add
a suitable PR to keep us honest.

There is a one-line change to libgomp/team.c silencing a new used
uninitialized warning.  As my previous work with the threaders has
shown, warnings flare up after each improvement to jump threading.  I
expect this to be no different.  I've promised Jakub to investigate
fully, so I will analyze and add the appropriate PR for the warning
experts.

Oh yeah, the new pass dump is called vrp-threader[12] to match each
VRP[12] pass.  However, there's no reason for it to either be named
vrp-threader, or for it to live in tree-vrp.c.

Tested on x86-64 Linux.

OK?

p.s. "Did I say 5 weeks?  My bad, I meant 5 months."

gcc/ChangeLog:

* passes.def (pass_vrp_threader): New.
* tree-pass.h (make_pass_vrp_threader): Add make_pass_vrp_threader.
* tree-ssa-threadedge.c (hybrid_jt_state::register_equivs_stmt): New.
(hybrid_jt_simplifier::hybrid_jt_simplifier): New.
(hybrid_jt_simplifier::simplify): New.
(hybrid_jt_simplifier::compute_ranges_from_state): New.
* tree-ssa-threadedge.h (class hybrid_jt_state): New.
(class hybrid_jt_simplifier): New.
* tree-vrp.c (execute_vrp): Remove ASSERT_EXPR based jump
threader.
(class hybrid_threader): New.
(hybrid_threader::hybrid_threader): New.
(hybrid_threader::~hybrid_threader): New.
(hybrid_threader::before_dom_children): New.
(hybrid_threader::after_dom_children): New.
(execute_vrp_threader): New.
(class pass_vrp_threader): New.
(make_pass_vrp_threader): New.

libgomp/ChangeLog:

* team.c: Initialize start_data.
* testsuite/libgomp.graphite/force-parallel-4.c: Adjust.
* testsuite/libgomp.graphite/force-parallel-8.c: Adjust.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr55107.c: Adjust.
* gcc.dg/tree-ssa/phi_on_compare-1.c: Adjust.
* gcc.dg/tree-ssa/phi_on_compare-2.c: Adjust.
* gcc.dg/tree-ssa/phi_on_compare-3.c: Adjust.
* gcc.dg/tree-ssa/phi_on_compare-4.c: Adjust.
* gcc.dg/tree-ssa/pr21559.c: Adjust.
* gcc.dg/tree-ssa/pr59597.c: Adjust.
* gcc.dg/tree-ssa/pr61839_1.c: Adjust.
* gcc.dg/tree-ssa/pr61839_3.c: Adjust.
* gcc.dg/tree-ssa/pr71437.c: Adjust.
* gcc.dg/tree-ssa/ssa-dom-thread-11.c: Adjust.
* gcc.dg/tree-ssa/ssa-dom-thread-16.c: Adjust.
* gcc.dg/tree-ssa/ssa-dom-thread-18.c: Adjust.
* gcc.dg/tree-ssa/ssa-dom-thread-2a.c: Adjust.
* gcc.dg/tree-ssa/ssa-dom-thread-4.c: Adjust.
* gcc.dg/tree-ssa/ssa-thread-14.c: Adjust.
* gcc.dg/tree-ssa/ssa-vrp-thread-1.c: Adjust.
* gcc.dg/tree-ssa/vrp106.c: Adjust.
* gcc.dg/tree-ssa/vrp55.c: Adjust.

2 years agoCome up with section_flag enum.
Martin Liska [Mon, 6 Sep 2021 15:40:16 +0000 (17:40 +0200)]
Come up with section_flag enum.

gcc/ChangeLog:

* output.h (enum section_flag): New.
(SECTION_FORGET): Remove.
(SECTION_ENTSIZE): Make it (1UL << 8) - 1.
(SECTION_STYLE_MASK): Define it based on other enum
values.
* varasm.c (switch_to_section): Remove unused handling of
SECTION_FORGET.