platform/upstream/gcc.git
2 years agoFactor out removal of write only stores from execute_fixup_cfg
Andrew Pinski [Sat, 16 Oct 2021 03:09:05 +0000 (03:09 +0000)]
Factor out removal of write only stores from execute_fixup_cfg

To make it easier to fix PR 102703, factoring this code out
to its own function makes it easier to read and less indentions
too.

gcc/ChangeLog:

* tree-cfg.c (maybe_remove_writeonly_store): New function
factored out from ...
(execute_fixup_cfg): Here. Call maybe_remove_writeonly_store.

2 years agoRemove outdated comment about execute_fixup_cfg
Andrew Pinski [Sat, 16 Oct 2021 02:48:06 +0000 (02:48 +0000)]
Remove outdated comment about execute_fixup_cfg

The comment about execute_fixup_cfg not being able to
run as a standalone pass is not true for a long time
now.  It has been a standalone pass for a while now.

gcc/ChangeLog:

* tree-cfg.c (execute_fixup_cfg): Remove comment
about standalone pass.

2 years agoAdd dump prints when execute_fixup_cfg removes a write only var store.
Andrew Pinski [Sat, 16 Oct 2021 02:30:55 +0000 (02:30 +0000)]
Add dump prints when execute_fixup_cfg removes a write only var store.

While debugging PR 102703, I found it was hard to figure out where
the store was being removed as there was no pass which was outputting
why the store was removed.
This adds to execute_fixup_cfg the output.
Also note most of removals happen when execute_fixup_cfg is called
from the inliner.

gcc/ChangeLog:

* tree-cfg.c (execute_fixup_cfg): Output when the statement
is removed when it is a write only var.

2 years agoAvoid threading circular paths.
Aldy Hernandez [Wed, 20 Oct 2021 16:52:45 +0000 (18:52 +0200)]
Avoid threading circular paths.

The backward threader keeps a hash of visited blocks to avoid crossing
the same block twice.  Interestingly, we haven't been checking it for
the final block out of the path.  This may be inherited from the old
code, as it was simple enough that it didn't matter.  With the
upcoming changes enabling the fully resolving threader, it gets
tripped often enough to cause wrong code to be generated.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::maybe_register_path):
Avoid threading circular paths.

2 years agotestsuite/102861 - adjust gcc.dg/vect/bb-slp-16.c change
Richard Biener [Thu, 21 Oct 2021 08:00:27 +0000 (10:00 +0200)]
testsuite/102861 - adjust gcc.dg/vect/bb-slp-16.c change

This reverts the bogus previous change causing runtime failures
and instead realizes that we now have the loop condition
if-converted and the BB vectorization opportunity realized during
the loop vectorization pass.

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

PR testsuite/102861
* gcc.dg/vect/bb-slp-16.c: Revert previous change, scan
the vect dump instead.

2 years agoopenmp: Fortran strictly-structured blocks support
Chung-Lin Tang [Thu, 21 Oct 2021 06:56:20 +0000 (14:56 +0800)]
openmp: Fortran strictly-structured blocks support

This implements strictly-structured blocks support for Fortran, as specified in
OpenMP 5.2. This now allows using a Fortran BLOCK construct as the body of most
OpenMP constructs, with a "!$omp end ..." ending directive optional for that
form.

gcc/fortran/ChangeLog:

* decl.c (gfc_match_end): Add COMP_OMP_STRICTLY_STRUCTURED_BLOCK case
together with COMP_BLOCK.
* parse.c (parse_omp_structured_block): Change return type to
'gfc_statement', add handling for strictly-structured block case, adjust
recursive calls to parse_omp_structured_block.
(parse_executable): Adjust calls to parse_omp_structured_block.
* parse.h (enum gfc_compile_state): Add
COMP_OMP_STRICTLY_STRUCTURED_BLOCK.
* trans-openmp.c (gfc_trans_omp_workshare): Add EXEC_BLOCK case
handling.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/cancel-1.f90: Adjust testcase.
* gfortran.dg/gomp/nesting-3.f90: Adjust testcase.
* gfortran.dg/gomp/strictly-structured-block-1.f90: New test.
* gfortran.dg/gomp/strictly-structured-block-2.f90: New test.
* gfortran.dg/gomp/strictly-structured-block-3.f90: New test.

libgomp/ChangeLog:

* libgomp.texi (Support of strictly structured blocks in Fortran):
Adjust to 'Y'.
* testsuite/libgomp.fortran/task-reduction-16.f90: Adjust testcase.

2 years agoFortran: Fixes and additional tests for shape/ubound/size [PR94070]
Sandra Loosemore [Wed, 20 Oct 2021 04:11:15 +0000 (21:11 -0700)]
Fortran: Fixes and additional tests for shape/ubound/size [PR94070]

This patch reimplements the SHAPE intrinsic to be inlined similarly to
LBOUND and UBOUND, instead of as a library call, to avoid an
unnecessary array copy.  Various bugs are also fixed.

gcc/fortran/
PR fortran/94070

* expr.c (gfc_simplify_expr): Handle GFC_ISYM_SHAPE along with
GFC_ISYM_LBOUND and GFC_ISYM_UBOUND.
* trans-array.c (gfc_conv_ss_startstride): Likewise.
(set_loop_bounds): Likewise.
* trans-intrinsic.c (gfc_trans_intrinsic_bound): Extend to
handle SHAPE.  Correct logic for zero-size special cases and
detecting assumed-rank arrays associated with an assumed-size
argument.
(gfc_conv_intrinsic_shape): Deleted.
(gfc_conv_intrinsic_function): Handle GFC_ISYM_SHAPE like
GFC_ISYM_LBOUND and GFC_ISYM_UBOUND.
(gfc_add_intrinsic_ss_code): Likewise.
(gfc_walk_intrinsic_bound): Likewise.

gcc/testsuite/
PR fortran/94070

* gfortran.dg/c-interop/shape-bindc.f90: New test.
* gfortran.dg/c-interop/shape-poly.f90: New test.
* gfortran.dg/c-interop/size-bindc.f90: New test.
* gfortran.dg/c-interop/size-poly.f90: New test.
* gfortran.dg/c-interop/ubound-bindc.f90: New test.
* gfortran.dg/c-interop/ubound-poly.f90: New test.

2 years agolibstdc++: Implement LWG 3595 changes to common_iterator
Patrick Palka [Thu, 21 Oct 2021 01:43:42 +0000 (21:43 -0400)]
libstdc++: Implement LWG 3595 changes to common_iterator

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (common_iterator::__arrow_proxy):
Make fully constexpr as per LWG 3595.
(common_iterator::__postfix_proxy): Likewise.

2 years agolibstdc++: Implement LWG 3590-3592 changes to split_view/lazy_split_view
Patrick Palka [Thu, 21 Oct 2021 01:34:23 +0000 (21:34 -0400)]
libstdc++: Implement LWG 3590-3592 changes to split_view/lazy_split_view

libstdc++-v3/ChangeLog:

* include/std/ranges (lazy_split_view::base): Add forward_range
constraint as per LWG 3591.
(lazy_split_view::begin, lazy_split_view::end): Also check
simpleness of _Pattern as per LWG 3592.
(split_view::base): Relax copyable constraint as per LWG 3590.

2 years agolibstdc++: Implement LWG 3535 changes to ranges::join_view
Patrick Palka [Thu, 21 Oct 2021 01:34:21 +0000 (21:34 -0400)]
libstdc++: Implement LWG 3535 changes to ranges::join_view

libstdc++-v3/ChangeLog:

* include/std/ranges (join_view::__iter_cat::_S_iter_cat): Adjust
criteria for returning bidirectional_iterator_tag as per LWG 3535.
(join_view::_Iterator::_S_iter_concept): Likewise.

2 years agolibstdc++: Implement LWG 3481 change to ranges::viewable_range
Patrick Palka [Thu, 21 Oct 2021 01:34:18 +0000 (21:34 -0400)]
libstdc++: Implement LWG 3481 change to ranges::viewable_range

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (viewable_range): Adjust as per
LWG 3481.
* testsuite/std/ranges/adaptors/all.cc (test07): New test.

2 years agolibstdc++: Remove constraints from std::optional monadic ops [PR102863]
Jonathan Wakely [Thu, 21 Oct 2021 00:19:45 +0000 (01:19 +0100)]
libstdc++: Remove constraints from std::optional monadic ops [PR102863]

The constraints on transform and and_then can cause errors when checking
satisfaction. The constraints that were present in R6 of the paper were
moved for he final F8 revision, and so should have been included in the
implementation.

libstdc++-v3/ChangeLog:

PR libstdc++/102863
* include/std/optional (optional::and_then, optional::transform):
Remove requires-clause.
* testsuite/20_util/optional/monadic/and_then.cc: Check
overload resolution doesn't cause errors.
* testsuite/20_util/optional/monadic/transform.cc: Likewise.

2 years agoDaily bump.
GCC Administrator [Thu, 21 Oct 2021 00:16:29 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: tweak parsing of invalid types
Jason Merrill [Mon, 18 Oct 2021 20:12:15 +0000 (16:12 -0400)]
c++: tweak parsing of invalid types

cp_parser_parse_and_diagnose_invalid_type_name is called during declaration
parsing, so it should pass 'true' for the declarator_p argument.  But that
caused a diagnostic regression on template/pr84789.C due to undesired lookup
in dependent scopes.  To fix that, cp_parser_nested_name_specifier_opt needs
to respect the value of check_dependency_p.

This patch avoids a regression from Andrew Sharp's WIP patch for PR70417.

It would make more sense to test only check_dependency_p, not declarator_p,
but removing the declarator_p condition turns out to reveal complicated
interactions of cp_parser_constructor_declarator_p and caching of
nested-name-specifiers and template-ids that I've already spent too much
time trying to sort out.

gcc/cp/ChangeLog:

* parser.c (cp_parser_parse_and_diagnose_invalid_type_name):
Pass true for declarator_p.
(cp_parser_nested_name_specifier_opt): Only look through
TYPENAME_TYPE if check_dependency_p is false.

2 years agocalls.c: Remove some dead code and target hooks
Alex Coplan [Wed, 20 Oct 2021 20:02:52 +0000 (21:02 +0100)]
calls.c: Remove some dead code and target hooks

Looking at calls.c:initialize_argument_information, I spotted some dead
code that seems to have been left behind from when MPX support was
removed.

This change removes that code as well as the associated target hooks
(which appear to be unused).

gcc/ChangeLog:

* calls.c (initialize_argument_information): Remove some dead
code, remove handling for function_arg returning const_int.
* doc/tm.texi: Delete documentation for unused target hooks.
* doc/tm.texi.in: Likewise.
* target.def (load_bounds_for_arg): Delete.
(store_bounds_for_arg): Delete.
(load_returned_bounds): Delete.
(store_returned_bounds): Delete.
* targhooks.c (default_load_bounds_for_arg): Delete.
(default_store_bounds_for_arg): Delete.
(default_load_returned_bounds): Delete.
(default_store_returned_bounds): Delete.
* targhooks.h (default_load_bounds_for_arg): Delete.
(default_store_bounds_for_arg): Delete.
(default_load_returned_bounds): Delete.
(default_store_returned_bounds): Delete.

2 years agolibstdc++: Add missing test for std::optional::transform(F&&)
Jonathan Wakely [Wed, 20 Oct 2021 19:12:28 +0000 (20:12 +0100)]
libstdc++: Add missing test for std::optional::transform(F&&)

The test_copy_elision() function was supposed to ensure that the result
is constructed directly in the std::optional, without early temporary
materialization. But I forgot to write the test.

libstdc++-v3/ChangeLog:

* testsuite/20_util/optional/monadic/transform.cc: Check that
an rvalue result is not materialized too soon.

2 years agodoc: Fix documentation around 'asm' keyword in C++
Jonathan Wakely [Wed, 20 Oct 2021 18:41:49 +0000 (19:41 +0100)]
doc: Fix documentation around 'asm' keyword in C++

The documentation on asm statements suggests asm is always a GNU
extension, but it's been part of ISO C++ since the first standard.

The documentation of -fno-asm is wrong for C++ as it states that it only
affects typeof, but actually it affects typeof and asm (despite asm
being part of ISO C++).

gcc/ChangeLog:

* doc/extend.texi (Basic Asm): Clarify that asm is not an
extension in C++.
* doc/invoke.texi (-fno-asm): Fix description for C++.

2 years agodoc: Remove broken link to old.html docs
Jonathan Wakely [Wed, 20 Oct 2021 18:39:15 +0000 (19:39 +0100)]
doc: Remove broken link to old.html docs

The target of this link was removed in r12-1061.

gcc/ChangeLog:

* doc/install.texi: Remove link to old.html

2 years agoAArch64: Combine cmeq 0 + not into cmtst
Tamar Christina [Wed, 20 Oct 2021 16:11:52 +0000 (17:11 +0100)]
AArch64: Combine cmeq 0 + not into cmtst

This turns a bitwise inverse of an equality comparison with 0 into a compare of
bitwise nonzero (cmtst).

We already have one pattern for cmsts, this adds an additional one which does
not require an additional bitwise and.

i.e.

#include <arm_neon.h>

uint8x8_t bar(int16x8_t abs_row0, int16x8_t row0) {
  uint16x8_t row0_diff =
    vreinterpretq_u16_s16(veorq_s16(abs_row0, vshrq_n_s16(row0, 15)));
  uint8x8_t abs_row0_gt0 =
    vmovn_u16(vcgtq_u16(vreinterpretq_u16_s16(abs_row0), vdupq_n_u16(0)));
  return abs_row0_gt0;
}

now generates:

bar:
        cmtst   v0.8h, v0.8h, v0.8h
        xtn     v0.8b, v0.8h
        ret

instead of:

bar:
        cmeq    v0.8h, v0.8h, #0
        not     v0.16b, v0.16b
        xtn     v0.8b, v0.8h
        ret

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (*aarch64_cmtst_same_<mode>): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mvn-cmeq0-1.c: New test.

2 years agoAArch64: Add pattern xtn+xtn2 to uzp1
Tamar Christina [Wed, 20 Oct 2021 16:10:25 +0000 (17:10 +0100)]
AArch64: Add pattern xtn+xtn2 to uzp1

This turns truncate operations with a hi/lo pair into a single permute of half
the bit size of the input and just ignoring the top bits (which are truncated
out).

i.e.

void d2 (short * restrict a, int *b, int n)
{
    for (int i = 0; i < n; i++)
      a[i] = b[i];
}

now generates:

.L4:
        ldp     q0, q1, [x3]
        add     x3, x3, 32
        uzp1    v0.8h, v0.8h, v1.8h
        str     q0, [x5], 16
        cmp     x4, x3
        bne     .L4

instead of

.L4:
        ldp     q0, q1, [x3]
        add     x3, x3, 32
        xtn     v0.4h, v0.4s
        xtn2    v0.8h, v1.4s
        str     q0, [x5], 16
        cmp     x4, x3
        bne     .L4

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (*aarch64_narrow_trunc<mode>): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/narrow_high_combine.c: Update case.
* gcc.target/aarch64/xtn-combine-1.c: New test.
* gcc.target/aarch64/xtn-combine-2.c: New test.
* gcc.target/aarch64/xtn-combine-3.c: New test.
* gcc.target/aarch64/xtn-combine-4.c: New test.
* gcc.target/aarch64/xtn-combine-5.c: New test.
* gcc.target/aarch64/xtn-combine-6.c: New test.

2 years agoAArch64: Add pattern for sshr to cmlt
Tamar Christina [Wed, 20 Oct 2021 16:09:00 +0000 (17:09 +0100)]
AArch64: Add pattern for sshr to cmlt

This optimizes signed right shift by BITSIZE-1 into a cmlt operation which is
more optimal because generally compares have a higher throughput than shifts.

On AArch64 the result of the shift would have been either -1 or 0 which is the
results of the compare.

i.e.

void e (int * restrict a, int *b, int n)
{
    for (int i = 0; i < n; i++)
      b[i] = a[i] >> 31;
}

now generates:

.L4:
        ldr     q0, [x0, x3]
        cmlt    v0.4s, v0.4s, #0
        str     q0, [x1, x3]
        add     x3, x3, 16
        cmp     x4, x3
        bne     .L4

instead of:

.L4:
        ldr     q0, [x0, x3]
        sshr    v0.4s, v0.4s, 31
        str     q0, [x1, x3]
        add     x3, x3, 16
        cmp     x4, x3
        bne     .L4

Thanks,
Tamar

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (aarch64_simd_ashr<mode>): Add case cmp
case.
* config/aarch64/constraints.md (D1): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/shl-combine-2.c: New test.
* gcc.target/aarch64/shl-combine-3.c: New test.
* gcc.target/aarch64/shl-combine-4.c: New test.
* gcc.target/aarch64/shl-combine-5.c: New test.

2 years agoAArch64: Add combine patterns for narrowing shift of half top bits (shuffle)
Tamar Christina [Wed, 20 Oct 2021 16:07:54 +0000 (17:07 +0100)]
AArch64: Add combine patterns for narrowing shift of half top bits (shuffle)

When doing a (narrowing) right shift by half the width of the original type then
we are essentially shuffling the top bits from the first number down.

If we have a hi/lo pair we can just use a single shuffle instead of needing two
shifts.

i.e.

typedef short int16_t;
typedef unsigned short uint16_t;

void foo (uint16_t * restrict a, int16_t * restrict d, int n)
{
    for( int i = 0; i < n; i++ )
      d[i] = (a[i] * a[i]) >> 16;
}

now generates:

.L4:
        ldr     q0, [x0, x3]
        umull   v1.4s, v0.4h, v0.4h
        umull2  v0.4s, v0.8h, v0.8h
        uzp2    v0.8h, v1.8h, v0.8h
        str     q0, [x1, x3]
        add     x3, x3, 16
        cmp     x4, x3
        bne     .L4

instead of

.L4:
        ldr     q0, [x0, x3]
        umull   v1.4s, v0.4h, v0.4h
        umull2  v0.4s, v0.8h, v0.8h
        sshr    v1.4s, v1.4s, 16
        sshr    v0.4s, v0.4s, 16
        xtn     v1.4h, v1.4s
        xtn2    v1.8h, v0.4s
        str     q1, [x1, x3]
        add     x3, x3, 16
        cmp     x4, x3
        bne     .L4

Thanks,
Tamar

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md
(*aarch64_<srn_op>topbits_shuffle<mode>_le): New.
(*aarch64_topbits_shuffle<mode>_le): New.
(*aarch64_<srn_op>topbits_shuffle<mode>_be): New.
(*aarch64_topbits_shuffle<mode>_be): New.
* config/aarch64/predicates.md
(aarch64_simd_shift_imm_vec_exact_top): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/shrn-combine-10.c: New test.
* gcc.target/aarch64/shrn-combine-5.c: New test.
* gcc.target/aarch64/shrn-combine-6.c: New test.
* gcc.target/aarch64/shrn-combine-7.c: New test.
* gcc.target/aarch64/shrn-combine-8.c: New test.
* gcc.target/aarch64/shrn-combine-9.c: New test.

2 years agoaarch64: Add combine patterns for right shift and narrow
Tamar Christina [Wed, 20 Oct 2021 16:06:31 +0000 (17:06 +0100)]
aarch64: Add combine patterns for right shift and narrow

This adds a simple pattern for combining right shifts and narrows into
shifted narrows.

i.e.

typedef short int16_t;
typedef unsigned short uint16_t;

void foo (uint16_t * restrict a, int16_t * restrict d, int n)
{
    for( int i = 0; i < n; i++ )
      d[i] = (a[i] * a[i]) >> 10;
}

now generates:

.L4:
        ldr     q0, [x0, x3]
        umull   v1.4s, v0.4h, v0.4h
        umull2  v0.4s, v0.8h, v0.8h
        shrn    v1.4h, v1.4s, 10
        shrn2   v1.8h, v0.4s, 10
        str     q1, [x1, x3]
        add     x3, x3, 16
        cmp     x4, x3
        bne     .L4

instead of:

.L4:
        ldr     q0, [x0, x3]
        umull   v1.4s, v0.4h, v0.4h
        umull2  v0.4s, v0.8h, v0.8h
        sshr    v1.4s, v1.4s, 10
        sshr    v0.4s, v0.4s, 10
        xtn     v1.4h, v1.4s
        xtn2    v1.8h, v0.4s
        str     q1, [x1, x3]
        add     x3, x3, 16
        cmp     x4, x3
        bne     .L4

Thanks,
Tamar

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (*aarch64_<srn_op>shrn<mode>_vect,
*aarch64_<srn_op>shrn<mode>2_vect_le,
*aarch64_<srn_op>shrn<mode>2_vect_be): New.
* config/aarch64/iterators.md (srn_op): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/shrn-combine-1.c: New test.
* gcc.target/aarch64/shrn-combine-2.c: New test.
* gcc.target/aarch64/shrn-combine-3.c: New test.
* gcc.target/aarch64/shrn-combine-4.c: New test.

2 years agoopenmp: in_reduction support for Fortran
Chung-Lin Tang [Wed, 20 Oct 2021 15:25:02 +0000 (23:25 +0800)]
openmp: in_reduction support for Fortran

This patch implements support for the in_reduction clause for Fortran.
It also includes more completion of the taskgroup construct inside the
Fortran front-end, thus allowing task_reduction to work for task and
target constructs.

gcc/fortran/ChangeLog:

* openmp.c (gfc_match_omp_clause_reduction): Add 'openmp_target' default
false parameter. Add 'always,tofrom' map for OMP_LIST_IN_REDUCTION case.
(gfc_match_omp_clauses): Add 'openmp_target' default false parameter,
adjust call to gfc_match_omp_clause_reduction.
(match_omp): Adjust call to gfc_match_omp_clauses
* trans-openmp.c (gfc_trans_omp_taskgroup): Add call to
gfc_match_omp_clause, create and return block.

gcc/ChangeLog:

* omp-low.c (omp_copy_decl_2): For !ctx, use record_vars to add new copy
as local variable.
(scan_sharing_clauses): Place copy of OMP_CLAUSE_IN_REDUCTION decl in
ctx->outer instead of ctx.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/reduction4.f90: Adjust omp target in_reduction' scan
pattern.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/target-in-reduction-1.f90: New test.
* testsuite/libgomp.fortran/target-in-reduction-2.f90: New test.

2 years agolibffi: Update ChangeLog.libffi for libffi 3.4.2
H.J. Lu [Wed, 20 Oct 2021 12:46:15 +0000 (05:46 -0700)]
libffi: Update ChangeLog.libffi for libffi 3.4.2

* ChangeLog.libffi: Copied from ChangeLog.old in libffi 3.4.2.

2 years agoRevert "target: support spaces in target attribute."
Martin Liska [Wed, 20 Oct 2021 12:49:35 +0000 (14:49 +0200)]
Revert "target: support spaces in target attribute."

This reverts commit df592811f950301ed3b10a08e476dad0f2eff26a.

2 years agoRevert "target: Support whitespaces in target attr/pragma."
Martin Liska [Wed, 20 Oct 2021 12:49:12 +0000 (14:49 +0200)]
Revert "target: Support whitespaces in target attr/pragma."

This reverts commit 6b34f5c5ec75823d656b6882f12d46248402a2aa.

2 years agolibffi: Add LOCAL_PATCHES
H.J. Lu [Mon, 30 Aug 2021 23:25:58 +0000 (16:25 -0700)]
libffi: Add LOCAL_PATCHES

* LOCAL_PATCHES: New file.

2 years agoAArch64: Tune case-values-threshold
Wilco Dijkstra [Wed, 20 Oct 2021 12:16:54 +0000 (13:16 +0100)]
AArch64: Tune case-values-threshold

Tune the case-values-threshold setting for modern cores.  A value of 11 improves
SPECINT2017 by 0.2% and reduces codesize by 0.04%.  With -Os use value 8 which
reduces codesize by 0.07%.

2021-10-18  Wilco Dijkstra  <wdijkstr@arm.com>

gcc/
* config/aarch64/aarch64.c (aarch64_case_values_threshold):
Change to 8 with -Os, 11 otherwise.

2 years agoAArch64: Enable fast shifts on Neoverse V1/N2
Wilco Dijkstra [Wed, 20 Oct 2021 12:12:32 +0000 (13:12 +0100)]
AArch64: Enable fast shifts on Neoverse V1/N2

Enable the fast shift feature in Neoverse V1 and N2 tunings as well.

2021-10-20  Wilco Dijkstra  <wdijkstr@arm.com>

gcc/
* config/aarch64/aarch64.c (neoversev1_tunings):
Enable AARCH64_EXTRA_TUNE_CHEAP_SHIFT_EXTEND.
(neoversen2_tunings): Likewise.

2 years agoAArch64: Add support for __builtin_roundeven[f] (PR100966)
Wilco Dijkstra [Wed, 20 Oct 2021 12:09:30 +0000 (13:09 +0100)]
AArch64: Add support for __builtin_roundeven[f] (PR100966)

Enable __builtin_roundeven[f] by changing existing frintn to roundeven.

2021-10-20  Wilco Dijkstra  <wdijkstr@arm.com>

gcc/
PR target/100966
* config/aarch64/aarch64.md (frint_pattern): Update comment.
* config/aarch64/aarch64-simd-builtins.def: Change frintn to roundeven.
* config/aarch64/arm_fp16.h: Change frintn to roundeven.
* config/aarch64/arm_neon.h: Likewise.
* config/aarch64/iterators.md (frint_pattern): Use roundeven for FRINTN.

gcc/testsuite/
PR target/100966
* gcc.target/aarch64/frint.x: Add roundeven tests.
* gcc.target/aarch64/frint_double.c: Likewise.
* gcc.target/aarch64/frint_float.c: Likewise.

2 years agolibffi: Integrate testsuite with GCC testsuite
H.J. Lu [Mon, 30 Aug 2021 21:31:46 +0000 (14:31 -0700)]
libffi: Integrate testsuite with GCC testsuite

* testsuite/lib/libffi.exp (load_gcc_lib): Load library from GCC
testsuite.
Load target-supports.exp and target-supports-dg.exp.
(libffi-init): Use libraries in GCC build tree.
(libffi_target_compile): Link with -shared-libgcc -lstdc++ for
C++ sources.

2 years agolibffi: Integrate build with GCC
H.J. Lu [Mon, 30 Aug 2021 21:31:19 +0000 (14:31 -0700)]
libffi: Integrate build with GCC

1. Integrate with GCC build.
2. Disable static trampolines by default.
3. Support multilib.

* Makefile.am (AUTOMAKE_OPTIONS): Add info-in-builddir.
(ACLOCAL_AMFLAGS): Set to -I .. -I ../config.
(SUBDIRS): Don't add doc.
(TEXINFO_TEX): New.
(MAKEINFOFLAGS): Likewise.
(info_TEXINFOS): Likewise.
(STAMP_GENINSRC): Likewise.
(STAMP_BUILD_INFO): Likewise.
(all-local): Likewise.
(stamp-geninsrc): Likewise.
(doc/libffi.info): Likewise.
(stamp-build-info:): Likewise.
(CLEANFILES): Likewise.
(MAINTAINERCLEANFILES): Likewise.
(AM_MAKEFLAGS): Likewise.
(all-recursive): Likewise.
(install-recursive): Likewise.
(mostlyclean-recursive): Likewise.
(clean-recursive): Likewise.
(distclean-recursive): Likewise.
(maintainer-clean-recursive): Likewise.
(LTLDFLAGS): Replace libtool-ldflags with ../libtool-ldflags.
(AM_CFLAGS): Add -g -fexceptions.
(libffi.map-sun): Replace make_sunver.pl with
../contrib/make_sunver.pl.
(dist-hook): Removed.
Include $(top_srcdir)/../multilib.am.
* configure.ac: Add AM_ENABLE_MULTILIB.
Remove the frv*-elf check.
(AX_ENABLE_BUILDDIR): Removed.
(AM_INIT_AUTOMAKE): Add [no-dist].
Add --enable-generated-files-in-srcdir.
(C_CONFIG_MACRO_DIR): Removed.
(AX_COMPILER_VENDOR): Likewise.
(AX_CC_MAXOPT): Likewise.
(AX_CFLAGS_WARN_ALL): Likewise.
Remove the GCC check.
(SYMBOL_UNDERSCORE): Removed.
(AX_CHECK_COMPILE_FLAG): Likewise.
Remove --disable-docs.
(ACX_CHECK_PROG_VER): Check makeinfo.
(BUILD_DOCS): Updated.
(exec-static-tramp): Don't enable use of static exec trampolines
by default.
Remove --disable-multi-os-directory.
(GCC_WITH_TOOLEXECLIBDIR): New.
Support cross host.
Support --enable-multilib.
* include/Makefile.am (nodist_include_HEADERS): Removed.
(gcc_version): New.
(toollibffidir): Likewise.
(toollibffi_HEADERS): Likewise.
* Makefile.in: Regenerate.
(GCC_BASE_VER): New.
(AC_CONFIG_FILES): Remove doc/Makefile.
(AC_CONFIG_LINKS): New.
* aclocal.m4: Likewise.
* configure: Likewise.
* fficonfig.h.in: Likewise.
* mdate-sh: Likewise.
* include/Makefile.in: Likewise.
* man/Makefile.in: Likewise.
* testsuite/Makefile.in: Likewise.

2 years agolibffi: Sync with libffi 3.4.2
H.J. Lu [Tue, 31 Aug 2021 14:14:47 +0000 (07:14 -0700)]
libffi: Sync with libffi 3.4.2

Merged commit: f9ea41683444ebe11cfa45b05223899764df28fb

2 years agolibffi: Add HOWTO_MERGE, autogen.sh and merge.sh
H.J. Lu [Mon, 30 Aug 2021 21:36:52 +0000 (14:36 -0700)]
libffi: Add HOWTO_MERGE, autogen.sh and merge.sh

Add scripts for syncing with libffi upstream:

1. Clone libffi repo.
2. Checkout the specific commit.
3. Remove the unused files.
4. Add new files and remove old files if needed.

* HOWTO_MERGE: New file.
* autogen.sh: Likewise.
* merge.sh: Likewise.

2 years agoRename asm_out_file function arguments.
Martin Liska [Wed, 15 Sep 2021 13:49:02 +0000 (15:49 +0200)]
Rename asm_out_file function arguments.

As preparation for a new global object that will encapsulate
asm_out_file, we would need to live with a macro that will
define asm_out_file as casm->out_file and thus the name
can't be used in function arguments.

gcc/ChangeLog:

* config/arm/arm.c (arm_unwind_emit_sequence): Do not declare
already declared global variable.
(arm_unwind_emit_set): Use out_file as function argument.
(arm_unwind_emit): Likewise.
* config/darwin.c (machopic_output_data_section_indirection): Likewise.
(machopic_output_stub_indirection): Likewise.
(machopic_output_indirection): Likewise.
(machopic_finish): Likewise.
* config/i386/i386.c (ix86_asm_output_function_label): Likewise.
* config/i386/winnt.c (i386_pe_seh_unwind_emit): Likewise.
* config/ia64/ia64.c (process_epilogue): Likewise.
(process_cfa_adjust_cfa): Likewise.
(process_cfa_register): Likewise.
(process_cfa_offset): Likewise.
(ia64_asm_unwind_emit): Likewise.
* config/s390/s390.c (s390_asm_output_function_label): Likewise.

2 years agogcc-changelog: Add libffi/ to ignored_prefixes
H.J. Lu [Tue, 19 Oct 2021 23:19:44 +0000 (16:19 -0700)]
gcc-changelog: Add libffi/ to ignored_prefixes

Add libffi/ to ignored_prefixes for syncing with libffi upstream:

commit c095f8f2e6f26bfc2ff8e3276c6af23ab153f5ff
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Aug 31 07:14:47 2021 -0700

    libffi: Sync with libffi 3.4.2

    Merged commit: f9ea41683444ebe11cfa45b05223899764df28fb

to avoid

remote: *** The following commit was rejected by your hooks.commit-extra-checker script (status: 1)
remote: *** commit: c095f8f2e6f26bfc2ff8e3276c6af23ab153f5ff
remote: *** ChangeLog format failed:
remote: *** ERR: cannot find a ChangeLog location in message
remote: ***
remote: *** Please see: https://gcc.gnu.org/codingconventions.html#ChangeLogs
remote: ***
remote: error: hook declined to update refs/heads/master

* gcc-changelog/git_commit.py (ignored_prefixes): Add libffi/.

2 years ago[Patch][GCC][AArch64] - Lower store and load neon builtins to gimple
Andre Simoes Dias Vieira [Wed, 20 Oct 2021 12:19:10 +0000 (13:19 +0100)]
[Patch][GCC][AArch64] - Lower store and load neon builtins to gimple

20-10-2021  Andre Vieira  <andre.simoesdiasvieira@arm.com>
    Jirui Wu  <jirui.wu@arm.com>
gcc/ChangeLog:

* config/aarch64/aarch64-builtins.c
(aarch64_general_gimple_fold_builtin):
lower vld1 and vst1 variants of the neon builtins
* config/aarch64/aarch64-protos.h:
(aarch64_general_gimple_fold_builtin): Add gsi parameter.
* config/aarch64/aarch64.c (aarch64_general_gimple_fold_builtin):
Likwise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/fmla_intrinsic_1.c: prevent over optimization.
* gcc.target/aarch64/fmls_intrinsic_1.c: Likewise.
* gcc.target/aarch64/fmul_intrinsic_1.c: Likewise.
* gcc.target/aarch64/mla_intrinsic_1.c: Likewise.
* gcc.target/aarch64/mls_intrinsic_1.c: Likewise.
* gcc.target/aarch64/mul_intrinsic_1.c: Likewise.
* gcc.target/aarch64/simd/vmul_elem_1.c: Likewise.
* gcc.target/aarch64/vclz.c: Likewise.
* gcc.target/aarch64/vneg_s.c: Likewise.

2 years ago[Patch][GCC][middle-end] - Generate FRINTZ for (double)(int) under -ffast-math on...
Andre Simoes Dias Vieira [Wed, 20 Oct 2021 12:12:09 +0000 (13:12 +0100)]
[Patch][GCC][middle-end] - Generate FRINTZ for (double)(int) under -ffast-math on aarch64

20-10-2021  Andre Vieira  <andre.simoesdiasvieira@arm.com>
    Jirui Wu  <jirui.wu@arm.com>
gcc/ChangeLog:

* match.pd: Generate IFN_TRUNC.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/merge_trunc1.c: New test.

2 years agotree-optimization/102853 - avoid trapping types in split_constant_offset
Richard Biener [Wed, 20 Oct 2021 10:54:59 +0000 (12:54 +0200)]
tree-optimization/102853 - avoid trapping types in split_constant_offset

This avoids running into the assert in compute_distributive_range when
starting the analysis with operations in a trapping type.

2021-10-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102853
* tree-data-ref.c (split_constant_offset_1): Bail out
immediately if the expression traps on overflow.

2 years agoRemove unused back_threader destructor.
Aldy Hernandez [Wed, 20 Oct 2021 05:15:17 +0000 (07:15 +0200)]
Remove unused back_threader destructor.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::~back_threader): Remove.

2 years agoRemove superflous debugging messages from the threading registry.
Aldy Hernandez [Tue, 19 Oct 2021 08:26:47 +0000 (10:26 +0200)]
Remove superflous debugging messages from the threading registry.

These are some random obvious cleanups to the threading dumps, since
it seems I'm not the only one looking at dumps these days.

The "just threaded" debugging message is redundant since there's
already an equivalent "Registering jump thread" message.

The "about to thread" message is actually confusing, because the source
block doesn't match the IL, since the CFG update is mid-flight.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadupdate.c (back_jt_path_registry::adjust_paths_after_duplication):
Remove superflous debugging message.
(back_jt_path_registry::duplicate_thread_path): Same.

2 years ago[Ada] Remove unnecessary call to No_Uint_To_0
Bob Duff [Sat, 16 Oct 2021 19:30:45 +0000 (15:30 -0400)]
[Ada] Remove unnecessary call to No_Uint_To_0

gcc/ada/

* gcc-interface/decl.c (gnat_to_gnu_entity): Remove unnecessary
call to No_Uint_To_0.

2 years ago[Ada] Never treat intrinsic subprograms as nested
Richard Kenner [Thu, 14 Oct 2021 19:31:38 +0000 (15:31 -0400)]
[Ada] Never treat intrinsic subprograms as nested

gcc/ada/

* exp_unst.adb (Visit_Node, when N_Subprogram_Call): Never treat
instrinsic subprograms as nested.

2 years ago[Ada] Proof of the runtime support for attribute 'Width
Yannick Moy [Mon, 30 Aug 2021 14:33:00 +0000 (16:33 +0200)]
[Ada] Proof of the runtime support for attribute 'Width

gcc/ada/

* libgnat/s-widlllu.ads: Mark in SPARK.
* libgnat/s-widllu.ads: Likewise.
* libgnat/s-widuns.ads: Likewise.
* libgnat/s-widthu.adb: Add ghost code and a
pseudo-postcondition.

2 years ago[Ada] Provide dummy body for big integers library used in reduced runtimes
Yannick Moy [Fri, 15 Oct 2021 10:00:16 +0000 (12:00 +0200)]
[Ada] Provide dummy body for big integers library used in reduced runtimes

gcc/ada/

* libgnat/a-nbnbin__ghost.adb (Signed_Conversions,
Unsigned_Conversions): Mark subprograms as not imported.
* libgnat/a-nbnbin__ghost.ads: Provide a dummy body.

2 years ago[Ada] Fix problematic conversion of real literal in static context
Eric Botcazou [Thu, 14 Oct 2021 13:44:48 +0000 (15:44 +0200)]
[Ada] Fix problematic conversion of real literal in static context

gcc/ada/

* sem_eval.adb (Eval_Type_Conversion): If the target subtype is
a static floating-point subtype and the result is a real literal,
consider its machine-rounded value to raise Constraint_Error.
(Test_In_Range): Turn local variables into constants.

2 years ago[Ada] Delete unused runtime files
Doug Rupp [Thu, 14 Oct 2021 15:41:56 +0000 (08:41 -0700)]
[Ada] Delete unused runtime files

gcc/ada/

* libgnat/g-io-put__vxworks.adb: Remove (unused)
* libgnat/s-parame__ae653.ads: Likewise.
* libgnat/s-thread.ads: Likewise.
* libgnat/s-thread__ae653.adb: Likewise.

2 years ago[Ada] Factor out machine rounding operations
Eric Botcazou [Wed, 13 Oct 2021 18:50:28 +0000 (20:50 +0200)]
[Ada] Factor out machine rounding operations

gcc/ada/

* sem_eval.ads (Machine_Number): New inline function.
* sem_eval.adb (Machine_Number): New function body implementing
the machine rounding operation specified by RM 4.9(38/2).
(Check_Non_Static_Context): Call Machine_Number and set the
Is_Machine_Number flag consistently on the resulting node.
* sem_attr.adb (Eval_Attribute) <Attribute_Machine>: Likewise.
* checks.adb (Apply_Float_Conversion_Check): Call Machine_Number.
(Round_Machine): Likewise.

2 years ago[Ada] Define __wrs_rtp_base in linker spec
Johannes Kliemann [Fri, 8 Oct 2021 15:55:33 +0000 (15:55 +0000)]
[Ada] Define __wrs_rtp_base in linker spec

gcc/ada/

* vxworks7-cert-rtp-link.spec: Add the definition of
__wrs_rtp_base.

2 years ago[Ada] Reject boxes in delta record aggregates
Piotr Trojanek [Wed, 13 Oct 2021 11:40:28 +0000 (13:40 +0200)]
[Ada] Reject boxes in delta record aggregates

gcc/ada/

* sem_aggr.adb (Resolve_Delta_Record_Aggregate): Reject boxes in
record delta aggregates.

2 years ago[Ada] Missing accessibility check when returning discriminated types
Justin Squirek [Thu, 23 Sep 2021 15:04:25 +0000 (11:04 -0400)]
[Ada] Missing accessibility check when returning discriminated types

gcc/ada/

* sem_ch6.adb (Check_Return_Construct_Accessibility): Modify
generation of accessibility checks to be more consolidated and
get triggered properly in required cases.
* sem_util.adb (Accessibility_Level): Add extra check within
condition to handle aliased formals properly in more cases.

2 years ago[Ada] Crash on object of protected type with defaulted access component
Justin Squirek [Tue, 12 Oct 2021 18:04:16 +0000 (14:04 -0400)]
[Ada] Crash on object of protected type with defaulted access component

gcc/ada/

* exp_ch7.adb (Make_Final_Call): Detect expanded protected types
and use original protected type in order to calculate
appropriate finalization routine.

2 years ago[Ada] Add ghost code version of Ada.Numerics.Big_Numbers.Big_Integers
Johannes Kliemann [Thu, 30 Sep 2021 11:41:13 +0000 (13:41 +0200)]
[Ada] Add ghost code version of Ada.Numerics.Big_Numbers.Big_Integers

gcc/ada/

* libgnat/a-nbnbin__ghost.ads: Add ghost package.

2 years ago[Ada] Refine type of a counter function for record delta aggregate
Piotr Trojanek [Wed, 13 Oct 2021 11:48:42 +0000 (13:48 +0200)]
[Ada] Refine type of a counter function for record delta aggregate

gcc/ada/

* sem_aggr.adb (Variant_Depth): Refine type from Integer to
Natural.

2 years ago[Ada] tech debt: Clean up Uint fields, such as Esize
Bob Duff [Wed, 6 Oct 2021 13:03:53 +0000 (09:03 -0400)]
[Ada] tech debt: Clean up Uint fields, such as Esize

gcc/ada/

* atree.ads: Comment improvements. How is a "completely new
node" different from a "new node"? Document default values
corresponding to field types.
* exp_ch7.adb (Process_Tagged_Type_Declaration): Use
higher-level Scope_Depth instead of Scope_Depth_Value.  Remove
confusing comment: not clear what a "true" library level package
is.
* uintp.adb (Image_Out): Print No_Uint in a more readable way.
* gen_il-gen.adb, gen_il-gen-gen_entities.adb,
gen_il-gen-gen_nodes.adb, gen_il-types.ads: Tighten up the
subtypes of fields whose type is Uint, where possible; use
more-constrained subtypes such as Unat.
* einfo-utils.adb, einfo-utils.ads, exp_attr.adb,
exp_ch3.adb, exp_intr.adb, exp_unst.adb, exp_util.adb,
freeze.adb, repinfo.adb, sem.adb, sem_ch12.adb, sem_ch13.adb,
sem_ch3.adb, sem_ch8.adb, sem_util.adb, sprint.adb, treepr.adb:
No longer use Uint_0 to indicate "unknown" or "not yet known"
for various fields whose type is Uint. Use No_Uint for that,
except in a small number of legacy cases that cause test
failures. Protect many queries of such fields with calls to
Known_... functions. Improve comments.
* exp_aggr.adb: Likewise.
(Is_OK_Aggregate): Check whether Csiz is present.
(Aggr_Assignment_OK_For_Backend): Ensure we do not access an
uninitialized size.
* exp_strm.adb (Build_Elementary_Input_Call,
Build_Elementary_Write_Call): Check whether P_Size is present.
* cstand.adb: Leave Component_Size of Any_Composite unknown.
Similar for RM_Size of Standard_Exception_Type.  These should
not be used.
* einfo.ads: Comment improvements.
* exp_disp.ads: Minor.
* gen_il-internals.ads, gen_il-internals.adb: Minor.
* sinfo-utils.adb: Take advantage of full-coverage rules.
* types.h: Minor.

2 years ago[Ada] Warning on nonmatching subtypes in fully conforming subprogram specs and bodies
Gary Dismukes [Fri, 8 Oct 2021 21:57:37 +0000 (17:57 -0400)]
[Ada] Warning on nonmatching subtypes in fully conforming subprogram specs and bodies

gcc/ada/

* sem_ch6.adb: Add with and use of Warnsw.
(Check_Conformance): Report a warning when subtypes or
designated subtypes of formal parameters or result subtypes
denote different declarations between the spec and body of the
(Subprogram_Subtypes_Have_Same_Declaration): New function nested
within Check_Conformance that determines whether two subtype
entities referenced in a subprogram come from the same
declaration. Returns True immediately if the subprogram is in a
generic instantiation, or the subprogram is marked Is_Internal
or is declared in an internal (GNAT library) unit, or GNAT_Mode
is enabled, otherwise compares the nonlimited views of the
entities (or their designated subtypes' nonlimited views in the
anonymous access cases).
(Nonlimited_View_Of_Subtype): New function nested within
function Subprogram_Subtypes_Have_Same_Declaration that returns
Non_Limited_View of a type or subtype that is an incomplete or
class-wide type that comes from a limited of a
package (From_Limited_With is True for the entity), or returns
Full_View when the nonlimited view is an incomplete type.
Otherwise returns the entity passed in.
* warnsw.ads (Warn_On_Pedantic_Checks): New warning flag.
(type Warning_Record): New component Warn_On_Pedantic_Checks.
* warnsw.adb (All_Warnings): Set Warn_On_Pedantic_Checks from
parameter Setting.
(Restore_Warnings): Restore the value of the
Warn_On_Pedantic_Checks flag.
(Save_Warnings): Save the value of the Warn_On_Pedantic_Checks
flag.
(Set_Underscore_Warning_Switch): Add settings of the
Warn_On_Pedantic flag according to the switch ("-gnatw_p" vs.
"-gnatw_P").
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add
documentation of new switches -gnatw_p and -gnatw_P (warnings
for pedantic checks).
* gnat_ugn.texi: Regenerate.
* usage.adb: Add Warn_On_Pedantic_Checks.

2 years ago[Ada] Prevent use of an uninitialized AST field with universal integer
Piotr Trojanek [Tue, 12 Oct 2021 15:42:05 +0000 (17:42 +0200)]
[Ada] Prevent use of an uninitialized AST field with universal integer

gcc/ada/

* exp_spark.adb (Expand_SPARK_N_Attribute_Reference): Guard
against equality of an uninitialized RM_Size field.

2 years ago[Ada] Expose and use type-generic GCC atomic builtins
Eric Botcazou [Mon, 11 Oct 2021 14:16:41 +0000 (16:16 +0200)]
[Ada] Expose and use type-generic GCC atomic builtins

gcc/ada/

* sem_ch12.adb (Analyze_Subprogram_Instantiation): Also propagate an
interface name on an intrinsic subprogram.  Remove obsolete comment.
* libgnat/s-atopri.ads (Atomic_Load): New generic intrinsic function
(Atomic_Load_8): Rewrite into instantiation.
(Atomic_Load_16): Likewise.
(Atomic_Load_32): Likewise.
(Atomic_Load_64): Likewise.
(Sync_Compare_And_Swap): New generic intrinsic function.
(Sync_Compare_And_Swap_8): Rewrite into instantiation.
(Sync_Compare_And_Swap_16): Likewise.
(Sync_Compare_And_Swap_32): Likewise.
(Sync_Compare_And_Swap_64): Likewise.
(Lock_Free_Read): New generic inline function.
(Lock_Free_Read_8): Rewrite into instantiation.
(Lock_Free_Read_16): Likewise.
(Lock_Free_Read_32): Likewise.
(Lock_Free_Read_64): Likewise.
(Lock_Free_Try_Write): New generic inline function.
(Lock_Free_Try_Write_8): Rewrite into instantiation.
(Lock_Free_Try_Write_16): Likewise.
(Lock_Free_Try_Write_32): Likewise.
(Lock_Free_Try_Write_64): Likewise.
* libgnat/s-atopri.adb (Lock_Free_Read): New function body.
(Lock_Free_Read_8): Delete.
(Lock_Free_Read_16): Likewise.
(Lock_Free_Read_32): Likewise.
(Lock_Free_Read_64): Likewise.
(Lock_Free_Try_Write): New function body.
(Lock_Free_Try_Write_8): Delete.
(Lock_Free_Try_Write_16): Likewise.
(Lock_Free_Try_Write_32): Likewise.
(Lock_Free_Try_Write_64): Likewise.
* libgnat/s-aoinar.adb (Atomic_Fetch_And_Add): Use type-generic GCC
atomic builtin and tidy up implementation.
(Atomic_Fetch_And_Subtract): Likewise.
* libgnat/s-aomoar.adb (Atomic_Fetch_And_Add): Likewise.
(Atomic_Fetch_And_Subtract): Likewise.
* libgnat/s-atopex.adb (Atomic_Exchange): Likewise.
(Atomic_Compare_And_Exchange): Likewise.

2 years ago[Ada] Rewrite tests on Convention_Intrinsic
Eric Botcazou [Tue, 12 Oct 2021 09:56:46 +0000 (11:56 +0200)]
[Ada] Rewrite tests on Convention_Intrinsic

gcc/ada/

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Subprogram_Type>:
Replace test on Convention_Intrinsic with Is_Intrinsic_Subprogram.
(gnat_to_gnu_param): Likewise.
(gnat_to_gnu_subprog_type): Likewise.
* gcc-interface/trans.c (elaborate_all_entities_for_package): Ditto.

2 years ago[Ada] Small cleanup in Eval_Integer_Literal
Eric Botcazou [Mon, 11 Oct 2021 14:56:06 +0000 (16:56 +0200)]
[Ada] Small cleanup in Eval_Integer_Literal

gcc/ada/

* sem_eval.ads (Check_Non_Static_Context): Update documentation.
* sem_eval.adb (In_Any_Integer_Context): Change parameter type,
adjust accordingly and remove unreachable case.
(Eval_Integer_Literal): Consider the node kind throughout and
trim down verbose condition.

2 years ago[Ada] Get rid of Frontend_Exceptions refs
Doug Rupp [Mon, 20 Sep 2021 17:31:02 +0000 (10:31 -0700)]
[Ada] Get rid of Frontend_Exceptions refs

gcc/ada/

* Makefile.rtl: Remove references to system-vxworks-ppc.ads
and system-vxworks-x86.ads.
* libgnat/system-vxworks-ppc.ads: Remove.
* libgnat/system-vxworks-ppc-ravenscar.ads: Likewise.
* libgnat/system-vxworks-x86.ads: Likewise.

2 years ago[Ada] Issue warning on unused quantified expression
Yannick Moy [Thu, 7 Oct 2021 07:05:45 +0000 (09:05 +0200)]
[Ada] Issue warning on unused quantified expression

gcc/ada/

* sem_ch4.adb (Analyze_QUantified_Expression): Issue warning on
conjunct/disjunct sub-expression of the full expression inside a
quantified expression, when it does not reference the quantified
variable.

2 years ago[Ada] Fix type conversion handling in validity checks
Marc Poulhiès [Fri, 8 Oct 2021 08:02:11 +0000 (10:02 +0200)]
[Ada] Fix type conversion handling in validity checks

gcc/ada/

* checks.adb (Insert_Valid_Check): in case of checked type
conversion, update Typ to match Exp's type and add call to
Analyze_And_Resolve.

2 years agoRemove unused back_threader_registry::m_threaded_paths.
Aldy Hernandez [Wed, 20 Oct 2021 07:06:18 +0000 (09:06 +0200)]
Remove unused back_threader_registry::m_threaded_paths.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader_registry::back_threader_registry):
Remove.
(back_threader_registry::register_path): Remove m_threaded_paths.

2 years agoRestore --param=max-fsm-thread-length
Aldy Hernandez [Wed, 20 Oct 2021 07:05:23 +0000 (09:05 +0200)]
Restore --param=max-fsm-thread-length

The removal of --param=max-fsm-thread-length is causing code
explosion.  I thought that --param=max-fsm-thread-path-insns was a
better gague for path profitability than raw BB length, but it turns
out that we don't take into account PHIs when estimating the number of
statements.

In this PR, we have a sequence of very large PHIs that have us
traversing extremely large paths that blow up the compilation.

We could fix this a couple of different ways.  We could avoid
traversing more than a certain number of PHI arguments, or ignore
large PHIs altogether.  The old implementation certainly had this
knob, and we could cut things off before we even got to the ranger.
We could also adjust the instruction estimation to take into account
PHIs, but I'm sure we'll mess something else in the process ;-).

The easiest thing to do is just restore the knob.

At a later time we could tweak this further, for instance,
disregarding empty blocks in the count.  BTW, this is the reason I
didn't chop things off in the lowlevel registry for all threaders: the
forward threader can't really explore too deep paths, but it could
theoretically get there while threading over empty blocks.

This fixes 102814, 102852, and I bet it solves the Linux kernel cross
compile issue.

Tested on x86-64 Linux.

gcc/ChangeLog:

PR tree-optimization/102814
* doc/invoke.texi: Document --param=max-fsm-thread-length.
* params.opt: Add --param=max-fsm-thread-length.
* tree-ssa-threadbackward.c
(back_threader_profitability::profitable_path_p): Fail on paths
longer than max-fsm-thread-length.

2 years agoFix PR middle-end/102764
Eric Botcazou [Wed, 20 Oct 2021 08:42:56 +0000 (10:42 +0200)]
Fix PR middle-end/102764

This is a regression present on the mainline in the form of -fcompare-debug
failure at -O3 on a compiler-generated testcase.  Fixed by disregarding a
debug statement in the last position of a basic block to reset the current
location for the outgoing edges.

gcc/
PR middle-end/102764
* cfgexpand.c (expand_gimple_basic_block): Disregard a final debug
statement to reset the current location for the outgoing edges.

gcc/testsuite/
* gcc.dg/pr102764.c: New test.

2 years agoAvoid exception propagation during bootstrap
Arnaud Charlet [Wed, 20 Oct 2021 08:23:40 +0000 (10:23 +0200)]
Avoid exception propagation during bootstrap

This addresses PR ada/100486, which is the bootstrap failure of GCC 11 for
32-bit Windows in the MSYS setup.  The PR shows that we cannot rely on
exception propagation being operational during the bootstrap, at least on
the 11 branch, so fix this by removing the problematic raise statement.

gcc/ada/
PR ada/100486
* sem_prag.adb (Check_Valid_Library_Unit_Pragma): Do not raise an
exception as part of the bootstrap.

2 years agoopenmp: Fix up struct gomp_work_share handling [PR102838]
Jakub Jelinek [Wed, 20 Oct 2021 07:34:51 +0000 (09:34 +0200)]
openmp: Fix up struct gomp_work_share handling [PR102838]

If GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC is not defined, the intent was to
treat the split of the structure between first cacheline (64 bytes)
as mostly write-once, use afterwards and second cacheline as rw just
as an optimization.  But as has been reported, with vectorization enabled
at -O2 it can now result in aligned vector 16-byte or larger stores.
When not having posix_memalign/aligned_alloc/memalign or other similar API,
alloc.c emulates it but it needs to allocate extra memory for the dynamic
realignment.
So, for the GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC not defined case, this patch
stops using aligned (64) attribute in the middle of the structure and instead
inserts padding that puts the second half of the structure at offset 64 bytes.

And when GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC is defined, usually it was allocated
as aligned, but for the orphaned case it could still be allocated just with
gomp_malloc without guaranteed proper alignment.

2021-10-20  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/102838
* libgomp.h (struct gomp_work_share_1st_cacheline): New type.
(struct gomp_work_share): Only use aligned(64) attribute if
GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC is defined, otherwise just
add padding before lock to ensure lock is at offset 64 bytes
into the structure.
(gomp_workshare_struct_check1, gomp_workshare_struct_check2):
New poor man's static assertions.
* work.c (gomp_work_share_start): Use gomp_aligned_alloc instead of
gomp_malloc if GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC.

2 years agogfortran.dg/bind-c-contiguous-5.c: Big-endian fix
Tobias Burnus [Wed, 20 Oct 2021 06:32:16 +0000 (08:32 +0200)]
gfortran.dg/bind-c-contiguous-5.c: Big-endian fix

gcc/testsuite/

PR fortran/102815
* gfortran.dg/bind-c-contiguous-5.c (do_call, reset_var): Handle
big andian.

2 years agoc++: Fix up push_local_extern_decl_alias error recovery [PR102642]
Jakub Jelinek [Wed, 20 Oct 2021 06:38:58 +0000 (08:38 +0200)]
c++: Fix up push_local_extern_decl_alias error recovery [PR102642]

My recent push_local_extern_decl_alias change broke error-recovery,
do_pushdecl can return error_mark_node and set_decl_tls_model can't be
called on that.  There are other code paths that store error_mark_node
into DECL_LOCAL_DECL_ALIAS, with the intent to differentiate the cases
where we haven't yet tried to push it into the namespace scope (NULL)
and one where we have tried it but it failed (error_mark_node), but looking
around, there are other spots where we call functions or do processing
which doesn't tolerate error_mark_node.

So, the first hunk with the testcase fixes the testcase, the others
fix what I've spotted and the fix was easy to figure out (there are I think
3 other spots mainly for function multiversioning).

2021-10-20  Jakub Jelinek  <jakub@redhat.com>

PR c++/102642
* name-lookup.c (push_local_extern_decl_alias): Don't call
set_decl_tls_model on error_mark_node.
* decl.c (make_rtl_for_nonlocal_decl): Don't call
set_user_assembler_name on error_mark_node.
* parser.c (cp_parser_oacc_declare): Ignore DECL_LOCAL_DECL_ALIAS
if it is error_mark_node.
(cp_parser_omp_declare_target): Likewise.

* g++.dg/tls/pr102642.C: New test.

2 years agoDisallow loop rotation and loop header crossing in jump threaders.
Aldy Hernandez [Mon, 4 Oct 2021 07:47:02 +0000 (09:47 +0200)]
Disallow loop rotation and loop header crossing in jump threaders.

There is a lot of fall-out from this patch, as there were many threading
tests that assumed the restrictions introduced by this patch were valid.
Some tests have merely shifted the threading to after loop
optimizations, but others ended up with no threading opportunities at
all.  Surprisingly some tests ended up with more total threads.  It was
a crapshoot all around.

On a postive note, there are 6 tests that no longer XFAIL, and one
guality test which now passes.

I felt a bit queasy about such a fundamental change wrt threading, so I
ran it through my callgrind test harness (.ii files from a bootstrap).
There was no change in overall compilation, DOM, or the VRP threaders.

However, there was a slight increase of 1.63% in the backward threader.
I'm pretty sure we could reduce this if we incorporated the restrictions
into their profitability code.  This way we could stop the search when
we ran into one of these restrictions.  Not sure it's worth it at this
point.

Tested on x86-64 Linux.

Co-authored-by: Richard Biener <rguenther@suse.de>
gcc/ChangeLog:

* tree-ssa-threadupdate.c (cancel_thread): Dump threading reason
on the same line as the threading cancellation.
(jt_path_registry::cancel_invalid_paths): Avoid rotating loops.
Avoid threading through loop headers where the path remains in the
loop.

libgomp/ChangeLog:

* testsuite/libgomp.graphite/force-parallel-5.c: Remove xfail.

gcc/testsuite/ChangeLog:

* gcc.dg/Warray-bounds-87.c: Remove xfail.
* gcc.dg/analyzer/pr94851-2.c: Remove xfail.
* gcc.dg/graphite/pr69728.c: Remove xfail.
* gcc.dg/graphite/scop-dsyr2k.c: Remove xfail.
* gcc.dg/graphite/scop-dsyrk.c: Remove xfail.
* gcc.dg/shrink-wrap-loop.c: Remove xfail.
* gcc.dg/loop-8.c: Adjust for new threading restrictions.
* gcc.dg/tree-ssa/ifc-20040816-1.c: Same.
* gcc.dg/tree-ssa/pr21559.c: Same.
* gcc.dg/tree-ssa/pr59597.c: Same.
* gcc.dg/tree-ssa/pr71437.c: Same.
* gcc.dg/tree-ssa/pr77445-2.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-4.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Same.
* gcc.dg/vect/bb-slp-16.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-6.c: Remove.
* gcc.dg/tree-ssa/ssa-dom-thread-18.c: Remove.
* gcc.dg/tree-ssa/ssa-dom-thread-2a.c: Remove.
* gcc.dg/tree-ssa/ssa-thread-invalid.c: New test.

2 years agoTrivial fix to gil-1.c when analyzer is not enabled
Jeff Law [Wed, 20 Oct 2021 04:26:59 +0000 (00:26 -0400)]
Trivial fix to gil-1.c when analyzer is not enabled

gcc/testsuite
* gcc.dg/plugin/gil-1.c: Add dg-require-effective-target marker.

2 years agotree-object-size: Make unknown a computation
Siddhesh Poyarekar [Tue, 19 Oct 2021 04:06:35 +0000 (09:36 +0530)]
tree-object-size: Make unknown a computation

Compute the unknown size value as a function of the min/max bit of
object_size_type.  This transforms into a neat little branchless
sequence on x86_64:

movl %edi, %eax
sarl %eax
xorl $1, %eax
negl %eax
cltq

which should be faster than loading the value from memory.  A quick
unscientific test using

`time make check-gcc RUNTESTFLAGS="dg.exp=builtin*"`

shaves about half a second off execution time with this.  Also simplify
implementation of unknown_object_size.

gcc/ChangeLog:

* tree-object-size.c (unknown): Make into a function.  Adjust
all uses.
(unknown_object_size): Simplify implementation.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2 years agoAdjust testcase for O2 vectorization.
liuhongt [Thu, 14 Oct 2021 01:31:03 +0000 (09:31 +0800)]
Adjust testcase for O2 vectorization.

As discussed in [1], this patch add xfail/target selector to those
testcases, also make a copy of them so that they can be tested w/o
vectorization.

Newly added xfail/target selectors are used to check the vectorization
capability of continuous byte/double bytes storage, these scenarios
are exactly the part of the testcases that regressed after O2
vectorization.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581456.html.

2021-10-19  Hongtao Liu  <hongtao.liu@intel.com>
    Kewen Lin  <linkw@linux.ibm.com>

gcc/ChangeLog

* doc/sourcebuild.texi (Effective-Target Keywords): Document
vect_slp_v2qi_store, vect_slp_v4qi_store, vect_slp_v8qi_store,
vect_slp_v16qi_store, vect_slp_v2hi_store,
vect_slp_v4hi_store, vect_slp_v2si_store, vect_slp_v4si_store.

gcc/testsuite/ChangeLog

PR middle-end/102722
PR middle-end/102697
PR middle-end/102462
PR middle-end/102706
PR middle-end/102744
* c-c++-common/Wstringop-overflow-2.c: Adjust testcase with new
xfail/target selector.
* gcc.dg/Warray-bounds-51.c: Ditto.
* gcc.dg/Warray-parameter-3.c: Ditto.
* gcc.dg/Wstringop-overflow-14.c: Ditto.
* gcc.dg/Wstringop-overflow-21.c: Ditto.
* gcc.dg/Wstringop-overflow-68.c: Ditto.
* gcc.dg/Wstringop-overflow-76.c: Ditto.
* gcc.dg/Warray-bounds-48.c: Ditto.
* gcc.dg/Wzero-length-array-bounds-2.c: Ditto.
* lib/target-supports.exp (check_vect_slp_aligned_store_usage):
New function.
(check_effective_target_vect_slp_v2qi_store): Ditto.
(check_effective_target_vect_slp_v4qi_store): Ditto.
(check_effective_target_vect_slp_v8qi_store): Ditto.
(check_effective_target_vect_slp_v16qi_store): Ditto.
(check_effective_target_vect_slp_v2hi_store): Ditto.
(check_effective_target_vect_slp_v4hi_store): Ditto.
(check_effective_target_vect_slp_v2si_store): Ditto.
(check_effective_target_vect_slp_v4si_store): Ditto.
* c-c++-common/Wstringop-overflow-2-novec.c: New test.
* gcc.dg/Warray-bounds-51-novec.c: New test.
* gcc.dg/Warray-bounds-48-novec.c: New test.
* gcc.dg/Warray-parameter-3-novec.c: New test.
* gcc.dg/Wstringop-overflow-14-novec.c: New test.
* gcc.dg/Wstringop-overflow-21-novec.c: New test.
* gcc.dg/Wstringop-overflow-76-novec.c: New test.
* gcc.dg/Wzero-length-array-bounds-2-novec.c: New test.

2 years agoDaily bump.
GCC Administrator [Wed, 20 Oct 2021 00:16:43 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Implement LWG 3580 change to ranges::iota_view
Patrick Palka [Tue, 19 Oct 2021 22:07:19 +0000 (18:07 -0400)]
libstdc++: Implement LWG 3580 change to ranges::iota_view

libstdc++-v3/ChangeLog:

* include/std/ranges (iota_view::_Iterator::operator+): Adjust
definition as per LWG 3580.
(iota_view::_Iterator::operator-): Likewise.

2 years agolibstdc++: Implement LWG 3568 change to ranges::basic_istream_view
Patrick Palka [Tue, 19 Oct 2021 22:07:16 +0000 (18:07 -0400)]
libstdc++: Implement LWG 3568 change to ranges::basic_istream_view

libstdc++-v3/ChangeLog:

* include/std/ranges (basic_istream_view::_M_object): Value
initialize as per LWG 3568.

2 years agolibstdc++: Implement LWG 3470 change to ranges::subrange
Patrick Palka [Tue, 19 Oct 2021 22:07:05 +0000 (18:07 -0400)]
libstdc++: Implement LWG 3470 change to ranges::subrange

libstdc++-v3/ChangeLog:

* include/bits/ranges_util.h
(__detail::__uses_nonqualification_pointer_conversion): Define
and use it ...
(__detail::__convertible_to_nonslicing): ... here, as per LWG 3470.
* testsuite/std/ranges/subrange/1.cc: New test.

2 years agolibstdc++: Implement LWG 3523 changes to ranges::iota_view
Patrick Palka [Tue, 19 Oct 2021 21:54:24 +0000 (17:54 -0400)]
libstdc++: Implement LWG 3523 changes to ranges::iota_view

libstdc++-v3/ChangeLog:

* include/std/ranges (iota_view::_Iterator): Befriend iota_view.
(iota_view::_Sentinel): Likewise.
(iota_view::iota_view): Add three overloads, each taking an
iterator/sentinel pair as per LWG 3523.
* testsuite/std/ranges/iota/iota_view.cc (test06): New test.

2 years agolibstdc++: Implement LWG 3549 changes to ranges::enable_view
Patrick Palka [Tue, 19 Oct 2021 21:50:56 +0000 (17:50 -0400)]
libstdc++: Implement LWG 3549 changes to ranges::enable_view

This patch also reverts r11-3504 since that workaround is now obsolete
after this resolution.

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (view_interface): Forward declare.
(__detail::__is_derived_from_view_interface_fn): Declare.
(__detail::__is_derived_from_view_interface): Define as per LWG 3549.
(enable_view): Adjust as per LWG 3549.
* include/bits/ranges_util.h (view_interface): Don't derive from
view_base.
* include/std/ranges (filter_view): Revert r11-3504 change.
(transform_view): Likewise.
(take_view): Likewise.
(take_while_view): Likewise.
(drop_view): Likewise.
(drop_while_view): Likewise.
(join_view): Likewise.
(lazy_split_view): Likewise.
(split_view): Likewise.
(reverse_view): Likewise.
* testsuite/std/ranges/adaptors/sizeof.cc: Update expected sizes.
* testsuite/std/ranges/view.cc (test_view::test_view): Remove
this default ctor since views no longer need to be default initable.
(test01): New test.

2 years agodoc: Fix typo in name of PowerPC __builtin_cpu_supports built-in
Jonathan Wakely [Tue, 19 Oct 2021 19:37:53 +0000 (20:37 +0100)]
doc: Fix typo in name of PowerPC __builtin_cpu_supports built-in

gcc/ChangeLog:

* doc/extend.texi (Basic PowerPC Built-in Functions): Fix typo.

2 years agolibstdc++: Implement std::random_device::entropy() for other sources
Jonathan Wakely [Tue, 19 Oct 2021 11:31:06 +0000 (12:31 +0100)]
libstdc++: Implement std::random_device::entropy() for other sources

Currently this function only returns a non-zero value for /dev/random
and /dev/urandom. When a hardware instruction such as RDRAND is in use
it should (in theory) be perfectly random and produce 32 bits of entropy
in each 32-bit result. Add a helper function to identify the source of
randomness from the _M_func and _M_file data members, and return a
suitable value when RDRAND or RDSEED is being used.

libstdc++-v3/ChangeLog:

* src/c++11/random.cc (which_source): New helper function.
(random_device::_M_getentropy()): Use which_source and return
suitable values for sources other than device files.
* testsuite/26_numerics/random/random_device/entropy.cc: New test.

2 years agors6000: Guard some x86 intrinsics implementations
Paul A. Clarke [Mon, 9 Aug 2021 18:08:25 +0000 (13:08 -0500)]
rs6000: Guard some x86 intrinsics implementations

Some compatibility implementations of x86 intrinsics include
Power intrinsics which require POWER8.  Guard them.

emmintrin.h:
- _mm_cmpord_pd: Remove code which was ostensibly for pre-POWER8,
  but which indeed depended on POWER8 (vec_cmpgt(v2du)/vcmpgtud).
  The "POWER8" version works fine on pre-POWER8.
- _mm_mul_epu32: vec_mule(v4su) uses vmuleuw.
pmmintrin.h:
- _mm_movehdup_ps: vec_mergeo(v4su) uses vmrgow.
- _mm_moveldup_ps: vec_mergee(v4su) uses vmrgew.
smmintrin.h:
- _mm_cmpeq_epi64: vec_cmpeq(v2di) uses vcmpequd.
- _mm_mul_epi32: vec_mule(v4si) uses vmuluwm.
- _mm_cmpgt_epi64: vec_cmpgt(v2di) uses vcmpgtsd.
tmmintrin.h:
- _mm_sign_epi8: vec_neg(v4si) uses vsububm.
- _mm_sign_epi16: vec_neg(v4si) uses vsubuhm.
- _mm_sign_epi32: vec_neg(v4si) uses vsubuwm.
  Note that the above three could actually be supported pre-POWER8,
  but current GCC does not support them before POWER8.
- _mm_sign_pi8: depends on _mm_sign_epi8.
- _mm_sign_pi16: depends on _mm_sign_epi16.
- _mm_sign_pi32: depends on _mm_sign_epi32.

sse4_2-pcmpgtq.c:
- _mm_cmpgt_epi64: vec_cmpeq(v2di) uses vcmpequd.

2021-10-19  Paul A. Clarke  <pc@us.ibm.com>

gcc
PR target/101893
PR target/102719
* config/rs6000/emmintrin.h: Guard POWER8 intrinsics.
* config/rs6000/pmmintrin.h: Same.
* config/rs6000/smmintrin.h: Same.
* config/rs6000/tmmintrin.h: Same.

gcc/testsuite
* gcc.target/powerpc/sse4_2-pcmpgtq.c: Tighten dg constraints
to minimally Power8.

2 years agors6000: Add nmmintrin.h to extra_headers
Paul A. Clarke [Tue, 19 Oct 2021 00:12:12 +0000 (19:12 -0500)]
rs6000: Add nmmintrin.h to extra_headers

Fix an omission in commit 29fb1e831bf1c25e4574bf2f98a9f534e5c67665.

2021-10-19  Paul A. Clarke  <pc@us.ibm.com>

gcc
* config.gcc (extra_headers): Add nmmintrin.h.

2 years agolibstdc++: Fix doxygen generation to work with relative paths
Jonathan Wakely [Tue, 19 Oct 2021 15:00:13 +0000 (16:00 +0100)]
libstdc++: Fix doxygen generation to work with relative paths

In r12-826 I tried to remove some redundant steps from the doxygen
build, but they are needed when configure is run as a relative path. The
use of pwd is to resolve the relative path to an absolute one.

libstdc++-v3/ChangeLog:

* doc/Makefile.am (stamp-html-doxygen, stamp-html-doxygen)
(stamp-latex-doxygen, stamp-man-doxygen): Fix recipes for
relative ${top_srcdir}.
* doc/Makefile.in: Regenerate.

2 years agoFortran: Fix 'fn spec' for deferred character length
Tobias Burnus [Tue, 19 Oct 2021 14:38:56 +0000 (16:38 +0200)]
Fortran: Fix 'fn spec' for deferred character length

Shows now up with gfortran.dg/deferred_type_param_6.f90 due to more ME
optimizations, causing fails without this commit.

gcc/fortran/ChangeLog:

* trans-types.c (create_fn_spec): For allocatable/pointer
character(len=:), use 'w' not 'R' as fn spec for the length dummy
argument.

2 years agoMake file utf8 valid input.
Martin Liska [Tue, 19 Oct 2021 14:12:42 +0000 (16:12 +0200)]
Make file utf8 valid input.

liboffloadmic/ChangeLog:

* include/coi/source/COIBuffer_source.h: Convert 2 chars to
unicode.

2 years agoRefactor vect_supportable_dr_alignment
Richard Biener [Mon, 18 Oct 2021 13:55:22 +0000 (15:55 +0200)]
Refactor vect_supportable_dr_alignment

This refactors vect_supportable_dr_alignment to get the misalignment
as input parameter which allows us to elide modifying/restoring
of DR_MISALIGNMENT during alignment peeling analysis which eventually
makes it more straight-forward to split out the negative step
handling.

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

* tree-vectorizer.h (vect_supportable_dr_alignment): Add
misalignment parameter.
* tree-vect-data-refs.c (vect_get_peeling_costs_all_drs):
Do not change DR_MISALIGNMENT in place, instead pass the
adjusted misalignment to vect_supportable_dr_alignment.
(vect_peeling_supportable): Likewise.
(vect_peeling_hash_get_lowest_cost): Adjust.
(vect_enhance_data_refs_alignment): Likewise.
(vect_vfa_access_size): Likewise.
(vect_supportable_dr_alignment): Add misalignment
parameter and simplify.
* tree-vect-stmts.c (get_negative_load_store_type): Adjust.
(get_group_load_store_type): Likewise.
(get_load_store_type): Likewise.

2 years agolibstdc++: Change std::variant union member to empty struct
Jonathan Wakely [Tue, 19 Oct 2021 10:53:27 +0000 (11:53 +0100)]
libstdc++: Change std::variant union member to empty struct

This more clearly expresses the intent (a completely unused, trivial
type) than using char. It's also consistent with the unions in
std::optional.

libstdc++-v3/ChangeLog:

* include/std/variant (_Uninitialized): Use an empty struct
for the unused union member, instead of char.

2 years agolibstdc++: Fix std::stack deduction guide
Jonathan Wakely [Tue, 19 Oct 2021 10:38:26 +0000 (11:38 +0100)]
libstdc++: Fix std::stack deduction guide

libstdc++-v3/ChangeLog:

* include/bits/stl_stack.h (stack(Iterator, Iterator)): Remove
non-deducible template parameter from deduction guide.
* testsuite/23_containers/stack/deduction.cc: Check new C++23
deduction guides.

2 years agolibstdc++: Implement monadic operations for std::optional (P0798R8)
Jonathan Wakely [Tue, 19 Oct 2021 10:06:56 +0000 (11:06 +0100)]
libstdc++: Implement monadic operations for std::optional (P0798R8)

Another new addition to the C++23 working draft.

The new member functions of std::optional are only defined for C++23,
but the new members of _Optional_payload_base are defined for C++20 so
that they can be used in non-propagating-cache in <ranges>. The
_Optional_payload_base::_M_construct member can also be used in
non-propagating-cache now, because it's constexpr since r12-4389.

There will be an LWG issue about the feature test macro, suggesting that
we should just bump the value of __cpp_lib_optional instead. I haven't
done that here, but it can be changed once consensus is reached on the
change.

libstdc++-v3/ChangeLog:

* include/std/optional (_Optional_payload_base::_Storage): Add
constructor taking a callable function to invoke.
(_Optional_payload_base::_M_apply): New function.
(__cpp_lib_monadic_optional): Define for C++23.
(optional::and_then, optional::transform, optional::or_else):
Define for C++23.
* include/std/ranges (__detail::__cached): Remove.
(__detail::__non_propagating_cache): Remove use of __cached for
contained value. Use _Optional_payload_base::_M_construct and
_Optional_payload_base::_M_apply to set the contained value.
* include/std/version (__cpp_lib_monadic_optional): Define.
* testsuite/20_util/optional/monadic/and_then.cc: New test.
* testsuite/20_util/optional/monadic/or_else.cc: New test.
* testsuite/20_util/optional/monadic/or_else_neg.cc: New test.
* testsuite/20_util/optional/monadic/transform.cc: New test.
* testsuite/20_util/optional/monadic/version.cc: New test.

2 years agoFortran: Fix "str" to scalar descriptor conversion [PR92482]
Tobias Burnus [Tue, 19 Oct 2021 13:16:01 +0000 (15:16 +0200)]
Fortran: Fix "str" to scalar descriptor conversion [PR92482]

PR fortran/92482
gcc/fortran/ChangeLog:

* trans-expr.c (gfc_conv_procedure_call): Use TREE_OPERAND not
build_fold_indirect_ref_loc to undo an ADDR_EXPR.

gcc/testsuite/ChangeLog:

* gfortran.dg/bind-c-char-descr.f90: Remove xfail; extend a bit.

2 years agoaix: ensure reference to __tls_get_addr is in text section.
Clément Chigot [Thu, 14 Oct 2021 07:03:13 +0000 (09:03 +0200)]
aix: ensure reference to __tls_get_addr is in text section.

The garbage collector of AIX linker might remove the reference to
__tls_get_addr if it's added inside an unused csect, which can be
the case of .data with very simple programs.

gcc/ChangeLog:
2021-10-19  Clément Chigot  <clement.chigot@atos.net>

* config/rs6000/rs6000.c (rs6000_xcoff_file_end): Move
__tls_get_addr reference to .text csect.

2 years agotarget: Support whitespaces in target attr/pragma.
Martin Liska [Tue, 19 Oct 2021 09:11:16 +0000 (11:11 +0200)]
target: Support whitespaces in target attr/pragma.

PR target/102375

gcc/ChangeLog:

* config/aarch64/aarch64.c (aarch64_process_one_target_attr):
Strip whitespaces.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr102375.c: New test.

2 years agoMAINTAINERS: Add myself for write after approval
Clément Chigot [Tue, 19 Oct 2021 11:20:14 +0000 (13:20 +0200)]
MAINTAINERS: Add myself for write after approval

ChangeLog:
2021-10-19  Clément Chigot  <clement.chigot@atos.net>

* MAINTAINERS: Add myself for write after approval.

2 years agoRefactor load/store costing
Richard Biener [Tue, 19 Oct 2021 10:40:59 +0000 (12:40 +0200)]
Refactor load/store costing

This passes down the already available alignment scheme and
misalignment to the load/store costing routines, removing
redundant queries.

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

* tree-vectorizer.h (vect_get_store_cost): Adjust signature.
(vect_get_load_cost): Likewise.
* tree-vect-data-refs.c (vect_get_data_access_cost): Get
alignment support scheme and misalignment as arguments
and pass them down.
(vect_get_peeling_costs_all_drs): Compute that info here
and note that we shouldn't need to.
* tree-vect-stmts.c (vect_model_store_cost): Get
alignment support scheme and misalignment as arguments.
(vect_get_store_cost): Likewise.
(vect_model_load_cost): Likewise.
(vect_get_load_cost): Likewise.
(vectorizable_store): Pass down alignment support scheme
and misalignment to costing.
(vectorizable_load): Likewise.

2 years agolibstdc++: Fix mem-initializer in std::move_only_function [PR102825]
Jonathan Wakely [Tue, 19 Oct 2021 08:16:56 +0000 (09:16 +0100)]
libstdc++: Fix mem-initializer in std::move_only_function [PR102825]

libstdc++-v3/ChangeLog:

PR libstdc++/102825
* include/bits/mofunc_impl.h (move_only_function): Remove
invalid base initializer.
* testsuite/20_util/move_only_function/cons.cc: Instantiate
constructors to check bodies.

2 years agoCompute negative offset in get_load_store_type
Richard Biener [Tue, 19 Oct 2021 09:36:13 +0000 (11:36 +0200)]
Compute negative offset in get_load_store_type

This moves the computation of a negative offset that needs to be
applied when we vectorize a negative stride access to
get_load_store_type alongside where we compute the actual access
method.

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

* tree-vect-stmts.c (get_negative_load_store_type): Add
offset output parameter and initialize it.
(get_group_load_store_type): Likewise.
(get_load_store_type): Likewise.
(vectorizable_store): Use offset as computed by
get_load_store_type.
(vectorizable_load): Likewise.

2 years agotree-optimization/102827 - avoid stmts in preheader
Richard Biener [Tue, 19 Oct 2021 08:19:12 +0000 (10:19 +0200)]
tree-optimization/102827 - avoid stmts in preheader

The PR shows that when carefully crafting the runtime alias
condition in the vectorizer we might end up using defs from
the loop preheader but will end up inserting the condition
before the .LOOP_VECTORIZED call.  So the following makes
sure to insert invariants before that when we versioned the
loop, preserving the invariant the vectorizer relies on.

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

PR tree-optimization/102827
* tree-if-conv.c (predicate_statements): Add pe parameter
and use that edge to insert invariant stmts on.
(combine_blocks): Pass through pe.
(tree_if_conversion): Compute the edge to insert invariant
stmts on and pass it along.

* gcc.dg/pr102827.c: New testcase.