test_jj.git
2 years agoDaily bump.
GCC Administrator [Sun, 5 Dec 2021 00:16:28 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: Add fixed test [PR93614]
Marek Polacek [Sat, 4 Dec 2021 20:29:18 +0000 (15:29 -0500)]
c++: Add fixed test [PR93614]

This was fixed by r11-86.

PR c++/93614

gcc/testsuite/ChangeLog:

* g++.dg/template/lookup18.C: New test.

2 years agoFortran/OpenMP: Support most of 5.1 atomic extensions
Tobias Burnus [Sat, 4 Dec 2021 18:39:43 +0000 (19:39 +0100)]
Fortran/OpenMP: Support most of 5.1 atomic extensions

Implements moste of OpenMP 5.1 atomic extensions,
except that 'compare' is parsed but rejected during
resolution. (As the trans-openmp.c handling is missing.)

gcc/fortran/ChangeLog:

* dump-parse-tree.c (show_omp_clauses): Handle
weak/compare/fail clause.
* gfortran.h (gfc_omp_clauses): Add weak, compare, fail.
* openmp.c (enum omp_mask1, gfc_match_omp_clauses,
OMP_ATOMIC_CLAUSES): Update for new clauses.
(gfc_match_omp_atomic): Update for 5.1 atomic changes.
(is_conversion): Support widening in one go.
(is_scalar_intrinsic_expr): New.
(resolve_omp_atomic): Update for 5.1 atomic changes.
* parse.c (parse_omp_oacc_atomic): Update for compare.
* resolve.c (gfc_resolve_blocks): Update asserts.
* trans-openmp.c (gfc_trans_omp_atomic): Handle new clauses.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/atomic-2.f90: Move now supported code to ...
* gfortran.dg/gomp/atomic.f90: here.
* gfortran.dg/gomp/atomic-10.f90: New test.
* gfortran.dg/gomp/atomic-12.f90: New test.
* gfortran.dg/gomp/atomic-15.f90: New test.
* gfortran.dg/gomp/atomic-16.f90: New test.
* gfortran.dg/gomp/atomic-17.f90: New test.
* gfortran.dg/gomp/atomic-18.f90: New test.
* gfortran.dg/gomp/atomic-19.f90: New test.
* gfortran.dg/gomp/atomic-20.f90: New test.
* gfortran.dg/gomp/atomic-22.f90: New test.
* gfortran.dg/gomp/atomic-24.f90: New test.
* gfortran.dg/gomp/atomic-25.f90: New test.
* gfortran.dg/gomp/atomic-26.f90: New test.

libgomp/ChangeLog

* libgomp.texi (OpenMP 5.1): Update status.

2 years agolibstdc++: Initialize member in std::match_results [PR103549]
Jonathan Wakely [Sat, 4 Dec 2021 11:38:25 +0000 (11:38 +0000)]
libstdc++: Initialize member in std::match_results [PR103549]

This fixes a -Wuninitialized warning for std::cmatch m1, m2; m1=m2;

Also name the template parameters in the forward declaration, to get rid
of the <template-parameter-1-1> noise in diagnostics.

libstdc++-v3/ChangeLog:

PR libstdc++/103549
* include/bits/regex.h (match_results): Give names to template
parameters in first declaration.
(match_results::_M_begin): Add default member-initializer.

2 years agolibgomp.texi: Update OMP_PLACES
Tobias Burnus [Sat, 4 Dec 2021 12:28:03 +0000 (13:28 +0100)]
libgomp.texi: Update OMP_PLACES

libgomp/ChangeLog:

* libgomp.texi (OMP_PLACES): Extend description for OMP 5.1 changes.

2 years agoi386, ipa-modref: Comment spelling fix
Jakub Jelinek [Sat, 4 Dec 2021 10:09:33 +0000 (11:09 +0100)]
i386, ipa-modref: Comment spelling fix

This patch fixes spelling of prefer (misspelled as preffer).

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

* config/i386/x86-tune.def (X86_TUNE_PARTIAL_REG_DEPENDENCY): Fix
comment typo, Preffer -> prefer.
* ipa-modref-tree.c (modref_access_node::closer_pair_p): Likewise.

2 years agoc++: Allow indeterminate unsigned char or std::byte in bit_cast - P1272R4
Jakub Jelinek [Sat, 4 Dec 2021 10:02:15 +0000 (11:02 +0100)]
c++: Allow indeterminate unsigned char or std::byte in bit_cast - P1272R4

P1272R4 has added to the std::byteswap new stuff to me quite unrelated
clarification for std::bit_cast.
The patch treats it as DR, applying to all languages.
We no longer diagnose if padding bits are stored into unsigned char
or std::byte result, fields or bitfields, instead arrange for that result,
those fields or bitfields to get indeterminate value (empty
CONSTRUCTOR with CONSTRUCTOR_NO_ZEROING or just leaving the member's
initializer out and setting CONSTRUCTOR_NO_ZEROING on parent).

We still have a bug that we don't diagnose in lots of places lvalue-to-rvalue
conversions of indeterminate values or class objects with some indeterminate
members.

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

* cp-tree.h (is_byte_access_type_not_plain_char): Declare.
* tree.c (is_byte_access_type_not_plain_char): New function.
* constexpr.c (clear_uchar_or_std_byte_in_mask): New function.
(cxx_eval_bit_cast): Don't error about padding bits if target
type is unsigned char or std::byte, instead return no clearing
ctor.  Use clear_uchar_or_std_byte_in_mask.

* g++.dg/cpp2a/bit-cast11.C: New test.
* g++.dg/cpp2a/bit-cast12.C: New test.
* g++.dg/cpp2a/bit-cast13.C: New test.
* g++.dg/cpp2a/bit-cast14.C: New test.

2 years agolibcpp: Fix up handling of deferred pragmas [PR102432]
Jakub Jelinek [Sat, 4 Dec 2021 10:00:09 +0000 (11:00 +0100)]
libcpp: Fix up handling of deferred pragmas [PR102432]

The https://gcc.gnu.org/pipermail/gcc-patches/2020-November/557903.html
change broke the following testcases.  The problem is when a pragma
namespace allows expansion (i.e. p->is_nspace && p->allow_expansion),
e.g. the omp or acc namespaces do, then when parsing the second pragma
token we do it with pfile->state.in_directive set,
pfile->state.prevent_expansion clear and pfile->state.in_deferred_pragma
clear (the last one because we don't know yet if it will be a deferred
pragma or not).  If the pragma line only contains a single name
and newline after it, and there exists a function-like macro with the
same name, the preprocessor needs to peek in funlike_invocation_p
the next token whether it isn't ( but in this case it will see a newline.
As pfile->state.in_directive is set, we don't read anything after the
newline, pfile->buffer->need_line is set and CPP_EOF is lexed, which
funlike_invocation_p doesn't push back.  Because name is a function-like
macro and on the pragma line there is no ( after the name, it isn't
expanded, and control flow returns to do_pragma.  If name is valid
deferred pragma, we set pfile->state.in_deferred_pragma (and really
need it set so that e.g. end_directive later on doesn't eat all the
tokens from the pragma line).

Before Nathan's change (which unfortunately didn't contain rationale
on why it is better to do it like that), this wasn't a problem,
next _cpp_lex_direct called when we want next token would return
CPP_PRAGMA_EOF when it saw buffer->need_line, which would turn off
pfile->state.in_deferred_pragma and following get token would already
read the next line.  But Nathan's patch replaced it with an assertion
failure that now triggers and CPP_PRAGMA_EOL is done only when lexing
the '\n'.  Except for this special case that works fine, but in
this case it doesn't because when peeking the token we still didn't know
that it will be a deferred pragma.
I've tried to fix that up in do_pragma by detecting this and pushing
CPP_PRAGMA_EOL as lookahead, but that doesn't work because end_directive
still needs to see pfile->state.in_deferred_pragma set.

So, this patch affectively reverts part of Nathan's change, CPP_PRAGMA_EOL
addition isn't done only when parsing the '\n', but is now done in both
places, in the first one instead of the assertion failure.

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

PR preprocessor/102432
* lex.c (_cpp_lex_direct): If buffer->need_line while
pfile->state.in_deferred_pragma, return CPP_PRAGMA_EOL token instead
of assertion failure.

* c-c++-common/gomp/pr102432.c: New test.
* c-c++-common/goacc/pr102432.c: New test.

2 years ago[PR103028] test ifcvt trap_if seq more strictly after reload
Alexandre Oliva [Sat, 4 Dec 2021 03:17:16 +0000 (00:17 -0300)]
[PR103028] test ifcvt trap_if seq more strictly after reload

When -fif-conversion2 is enabled, we attempt to replace conditional
branches around unconditional traps with conditional traps.  That
canonicalizes compares, which may change an immediate that barely fits
into one that doesn't.

The compare for the trap is first checked using the predicates of
cbranch predicates, and then, compare and conditional trap insns are
emitted and recognized.

In the failing s390x testcase, i <=u 0xffff_ffff is canonicalized into
i <u 0x1_0000_0000, and the latter immediate doesn't fit.  The insn
predicates (both cbranch and cmpdi_ccu) happily accept it, since the
register allocator has no trouble getting them into registers.  The
problem is that ifcvt2 runs after reload, so we recognize the compare
insn successfully, but later on we barf when we find that none of the
constraints fit.

This patch arranges for the trap_if-issuing bits in ifcvt to validate
post-reload insns using a stricter test that also checks that operands
fit the constraints.

for  gcc/ChangeLog

PR rtl-optimization/103028
* ifcvt.c (find_cond_trap): Validate new insns more strictly
after reload.

for  gcc/testsuite/ChangeLog

PR rtl-optimization/103028
* gcc.dg/pr103028.c: New.

2 years agotestsuite: powerpc/vec_reve_1.c requires VSX.
David Edelsohn [Fri, 3 Dec 2021 19:47:48 +0000 (14:47 -0500)]
testsuite: powerpc/vec_reve_1.c requires VSX.

vector long long int and vector double require VSX not just Altivec.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/vec_reve_1.c: Require VSX.

2 years agoDaily bump.
GCC Administrator [Sat, 4 Dec 2021 00:16:46 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Simplify emplace member functions in _Rb_tree
Jonathan Wakely [Fri, 3 Dec 2021 11:16:30 +0000 (11:16 +0000)]
libstdc++: Simplify emplace member functions in _Rb_tree

This introduces a new RAII type to simplify the emplace members which
currently use try-catch blocks to deallocate a node if an exception is
thrown by the comparisons done during insertion. The new type is created
on the stack and manages the allocation of a new node and deallocates it
in the destructor if it wasn't inserted into the tree. It also provides
helper functions for doing the insertion, releasing ownership of the
node to the tree.

Also, we don't need to use long qualified names if we put the return
type after the nested-name-specifier.

libstdc++-v3/ChangeLog:

* include/bits/stl_tree.h (_Rb_tree::_Auto_node): Define new
RAII helper for creating and inserting new nodes.
(_Rb_tree::_M_insert_node): Use trailing-return-type to simplify
out-of-line definition.
(_Rb_tree::_M_insert_lower_node): Likewise.
(_Rb_tree::_M_insert_equal_lower_node): Likewise.
(_Rb_tree::_M_emplace_unique): Likewise. Use _Auto_node.
(_Rb_tree::_M_emplace_equal): Likewise.
(_Rb_tree::_M_emplace_hint_unique): Likewise.
(_Rb_tree::_M_emplace_hint_equal): Likewise.

2 years agoc++: avoid redundant scope in diagnostics
Jason Merrill [Fri, 18 Jun 2021 20:04:28 +0000 (16:04 -0400)]
c++: avoid redundant scope in diagnostics

We can make some function signatures shorter to print by omitting redundant
nested-name-specifiers in the rest of the declarator.

gcc/cp/ChangeLog:

* error.c (current_dump_scope): New variable.
(dump_scope): Check it.
(dump_function_decl): Set it.

gcc/testsuite/ChangeLog:

* g++.dg/diagnostic/scope1.C: New test.

2 years agoFix typos in libstdc++-v3/ChangeLog
Jonathan Wakely [Fri, 3 Dec 2021 20:50:50 +0000 (20:50 +0000)]
Fix typos in libstdc++-v3/ChangeLog

2 years agors6000: Fix up flag_shrink_wrap handling in presence of -mrop-protect [PR101324]
Martin Liska [Fri, 3 Dec 2021 17:58:25 +0000 (11:58 -0600)]
rs6000: Fix up flag_shrink_wrap handling in presence of -mrop-protect [PR101324]

PR101324 shows a problem in disabling shrink-wrapping when using -mrop-protect
when there is a attribute optimize/pragma.  The fix envolves moving the handling
of flag_shrink_wrap so it gets re-disbled when we change or add options.

2021-12-03  Martin Liska  <mliska@suse.cz>

gcc/
PR target/101324
* config/rs6000/rs6000.c (rs6000_option_override_internal): Move the
disabling of shrink-wrapping when using -mrop-protect from here...
(rs6000_override_options_after_change): ...to here.

2021-12-03  Peter Bergner  <bergner@linux.ibm.com>

gcc/testsuite/
PR target/101324
* gcc.target/powerpc/pr101324.c: New test.

2 years agors6000: testsuite: Add rop_ok effective-target function
Peter Bergner [Fri, 3 Dec 2021 17:46:22 +0000 (11:46 -0600)]
rs6000: testsuite: Add rop_ok effective-target function

This patch adds a new effective-target function that tests whether
it is safe to emit the ROP-protect instructions and updates the
ROP test cases to use it.

2021-12-03  Peter Bergner  <bergner@linux.ibm.com>

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_rop_ok): New function.
* gcc.target/powerpc/rop-1.c: Use it.
* gcc.target/powerpc/rop-2.c: Likewise.
* gcc.target/powerpc/rop-3.c: Likewise.
* gcc.target/powerpc/rop-4.c: Likewise.
* gcc.target/powerpc/rop-5.c: Likewise.

2 years agoFortran: improve checking of array specifications
Harald Anlauf [Thu, 2 Dec 2021 21:33:49 +0000 (22:33 +0100)]
Fortran: improve checking of array specifications

gcc/fortran/ChangeLog:

PR fortran/103505
* array.c (match_array_element_spec): Try to simplify array
element specifications to improve early checking.
* expr.c (gfc_try_simplify_expr): New.  Try simplification of an
expression via gfc_simplify_expr.  When an error occurs, roll
back.
* gfortran.h (gfc_try_simplify_expr): Declare it.

gcc/testsuite/ChangeLog:

PR fortran/103505
* gfortran.dg/pr103505.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2 years agoc++: Fix for decltype(auto) and parenthesized expr [PR103403]
Marek Polacek [Wed, 1 Dec 2021 02:07:25 +0000 (21:07 -0500)]
c++: Fix for decltype(auto) and parenthesized expr [PR103403]

In r11-4758, I tried to fix this problem:

  int &&i = 0;
  decltype(auto) j = i; // should behave like int &&j = i; error

wherein do_auto_deduction was getting confused with a REFERENCE_REF_P
and it didn't realize its operand was a name, not an expression, and
deduced the wrong type.

Unfortunately that fix broke this:

  int&& r = 1;
  decltype(auto) rr = (r);

where 'rr' should be 'int &' since '(r)' is an expression, not a name.  But
because I stripped the INDIRECT_REF with the r11-4758 change, we deduced
'rr's type as if decltype had gotten a name, resulting in 'int &&'.

I suspect I thought that the REF_PARENTHESIZED_P check when setting
'bool id' in do_auto_deduction would handle the (r) case, but that's not
the case; while the documentation for REF_PARENTHESIZED_P specifically says
it can be set in INDIRECT_REF, we don't actually do so.

This patch sets REF_PARENTHESIZED_P even on REFERENCE_REF_P, so that
do_auto_deduction can use it.

It also removes code in maybe_undo_parenthesized_ref that I think is
dead -- and we don't hit it while running dg.exp.  To adduce more data,
it also looks dead here:
https://splichal.eu/lcov/gcc/cp/semantics.c.gcov.html
(It's dead since r9-1417.)

Also add a fixed test for c++/81176.

PR c++/103403

gcc/cp/ChangeLog:

* cp-gimplify.c (cp_fold): Don't recurse if maybe_undo_parenthesized_ref
doesn't change its argument.
* pt.c (do_auto_deduction): Don't strip REFERENCE_REF_P trees if they
are REF_PARENTHESIZED_P.  Use stripped_init when checking for
id-expression.
* semantics.c (force_paren_expr): Set REF_PARENTHESIZED_P on
REFERENCE_REF_P trees too.
(maybe_undo_parenthesized_ref): Remove dead code.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/decltype-auto2.C: New test.
* g++.dg/cpp1y/decltype-auto3.C: New test.
* g++.dg/cpp1y/decltype-auto4.C: New test.
* g++.dg/cpp1z/decomp-decltype1.C: New test.

2 years agox86: Add -mmove-max=bits and -mstore-max=bits
H.J. Lu [Tue, 16 Nov 2021 02:52:56 +0000 (18:52 -0800)]
x86: Add -mmove-max=bits and -mstore-max=bits

Add -mmove-max=bits and -mstore-max=bits to enable 256-bit/512-bit move
and store, independent of -mprefer-vector-width=bits:

1. Add X86_TUNE_AVX512_MOVE_BY_PIECES and X86_TUNE_AVX512_STORE_BY_PIECES
which are enabled for Intel Sapphire Rapids processor.
2. Add -mmove-max=bits to set the maximum number of bits can be moved from
memory to memory efficiently.  The default value is derived from
X86_TUNE_AVX512_MOVE_BY_PIECES, X86_TUNE_AVX256_MOVE_BY_PIECES, and the
preferred vector width.
3. Add -mstore-max=bits to set the maximum number of bits can be stored to
memory efficiently.  The default value is derived from
X86_TUNE_AVX512_STORE_BY_PIECES, X86_TUNE_AVX256_STORE_BY_PIECES and the
preferred vector width.

gcc/

PR target/103269
* config/i386/i386-expand.c (ix86_expand_builtin): Pass PVW_NONE
and PVW_NONE to ix86_target_string.
* config/i386/i386-options.c (ix86_target_string): Add arguments
for move_max and store_max.
(ix86_target_string::add_vector_width): New lambda.
(ix86_debug_options): Pass ix86_move_max and ix86_store_max to
ix86_target_string.
(ix86_function_specific_print): Pass ptr->x_ix86_move_max and
ptr->x_ix86_store_max to ix86_target_string.
(ix86_valid_target_attribute_tree): Handle x_ix86_move_max and
x_ix86_store_max.
(ix86_option_override_internal): Set the default x_ix86_move_max
and x_ix86_store_max.
* config/i386/i386-options.h (ix86_target_string): Add
prefer_vector_width and prefer_vector_width.
* config/i386/i386.h (TARGET_AVX256_MOVE_BY_PIECES): Removed.
(TARGET_AVX256_STORE_BY_PIECES): Likewise.
(MOVE_MAX): Use 64 if ix86_move_max or ix86_store_max ==
PVW_AVX512.  Use 32 if ix86_move_max or ix86_store_max >=
PVW_AVX256.
(STORE_MAX_PIECES): Use 64 if ix86_store_max == PVW_AVX512.
Use 32 if ix86_store_max >= PVW_AVX256.
* config/i386/i386.opt: Add -mmove-max=bits and -mstore-max=bits.
* config/i386/x86-tune.def (X86_TUNE_AVX512_MOVE_BY_PIECES): New.
(X86_TUNE_AVX512_STORE_BY_PIECES): Likewise.
* doc/invoke.texi: Document -mmove-max=bits and -mstore-max=bits.

gcc/testsuite/

PR target/103269
* gcc.target/i386/pieces-memcpy-17.c: New test.
* gcc.target/i386/pieces-memcpy-18.c: Likewise.
* gcc.target/i386/pieces-memcpy-19.c: Likewise.
* gcc.target/i386/pieces-memcpy-20.c: Likewise.
* gcc.target/i386/pieces-memcpy-21.c: Likewise.
* gcc.target/i386/pieces-memset-45.c: Likewise.
* gcc.target/i386/pieces-memset-46.c: Likewise.
* gcc.target/i386/pieces-memset-47.c: Likewise.
* gcc.target/i386/pieces-memset-48.c: Likewise.
* gcc.target/i386/pieces-memset-49.c: Likewise.

2 years agors6000: Fix use of wrong enum for built-in function code
Bill Schmidt [Thu, 2 Dec 2021 22:29:12 +0000 (16:29 -0600)]
rs6000: Fix use of wrong enum for built-in function code

I discovered this bug while working on patches to remove the old built-ins
infrastructure.  I missed a spot in converting from the rs6000_builtins enum to
the rs6000_gen_builtins_enum.  This fixes it.  The fix is technically not right
if new_builtins_are_enabled were to be set to zero, but we're not going to do
that anymore, and the remnants of that code will be removed shortly.

2021-12-02  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (rs6000_builtin_reciprocal): Fix builtin
identifiers.

2 years agox86: Scan leal in PR target/83782 tests for x32
H.J. Lu [Fri, 3 Dec 2021 17:00:54 +0000 (09:00 -0800)]
x86: Scan leal in PR target/83782 tests for x32

Update PR target/83782 tests to scan leal for x32 to fix:

FAIL: gcc.target/i386/pr83782-1.c scan-assembler leaq[ \\t]foo\\(%rip\\),[ \\t]%rax
FAIL: gcc.target/i386/pr83782-2.c scan-assembler leaq[ \\t]foo\\(%rip\\),[ \\t]%rax

PR target/83782
* gcc.target/i386/pr83782-1.c: Also scan leal x32.
* gcc.target/i386/pr83782-2.c: Likewise.

2 years agoRISC-V: Add implied defines of Zk, Zkn and Zks
SiYu Wu [Mon, 22 Nov 2021 08:19:10 +0000 (16:19 +0800)]
RISC-V: Add implied defines of Zk, Zkn and Zks

gcc/ChangeLog:

2021-11-22  SiYu Wu  <siyu@isrc.iscas.ac.cn>

* common/config/riscv/riscv-common.c (riscv_implied_info):
Add K-ext related entry.
(riscv_supported_std_ext): Add 'k'.
* config/riscv/arch-canonicalize (CANONICAL_ORDER): Add 'k'.
(IMPLIED_EXT): Add K-ext related entry.

2 years agoRISC-V: Add option defines for Scalar Cryptography
SiYu Wu [Mon, 22 Nov 2021 08:19:09 +0000 (16:19 +0800)]
RISC-V: Add option defines for Scalar Cryptography

gcc/ChangeLog:

2021-11-21  SiYu Wu  <siyu@isrc.iscas.ac.cn>

* common/config/riscv/riscv-common.c (riscv_ext_version_table):
Add zbk* and zk*.
* config/riscv/riscv-opts.h (MASK_ZBKB): New.
(MASK_ZBKC): Ditto.
(MASK_ZBKX): Ditto.
(MASK_ZKNE): Ditto.
(MASK_ZKND): Ditto.
(MASK_ZKNH): Ditto.
(MASK_ZKR): Ditto.
(MASK_ZKSED): Ditto.
(MASK_ZKSH): Ditto.
(MASK_ZKT): Ditto.
(TARGET_ZBKB): Ditto.
(TARGET_ZBKC): Ditto.
(TARGET_ZBKX): Ditto.
(TARGET_ZKNE): Ditto.
(TARGET_ZKND): Ditto.
(TARGET_ZKNH): Ditto.
(TARGET_ZKR): Ditto.
(TARGET_ZKSED): Ditto.
(TARGET_ZKSH): Ditto.
(TARGET_ZKT): Ditto.
* config/riscv/riscv.opt (riscv_zk_subext): New.

2 years agosve: combine nested if predicates
Tamar Christina [Fri, 3 Dec 2021 15:25:44 +0000 (15:25 +0000)]
sve: combine nested if predicates

The following example

void f5(float * restrict z0, float * restrict z1, float *restrict x,
float * restrict y, float c, int n)
{
    for (int i = 0; i < n; i++) {
        float a = x[i];
        float b = y[i];
        if (a > b) {
            z0[i] = a + b;
            if (a > c) {
                z1[i] = a - b;
            }
        }
    }
}

generates currently:

        ptrue   p3.b, all
        ld1w    z1.s, p1/z, [x2, x5, lsl 2]
        ld1w    z2.s, p1/z, [x3, x5, lsl 2]
        fcmgt   p0.s, p3/z, z1.s, z0.s
        fcmgt   p2.s, p1/z, z1.s, z2.s
        fcmgt   p0.s, p0/z, z1.s, z2.s
        and     p0.b, p0/z, p1.b, p1.b

The conditions for a > b and a > c become separate comparisons.

After this patch we generate:

        ld1w    z1.s, p0/z, [x2, x5, lsl 2]
        ld1w    z2.s, p0/z, [x3, x5, lsl 2]
        fcmgt   p1.s, p0/z, z1.s, z2.s
        fcmgt   p1.s, p1/z, z1.s, z0.s

Where the condition a > b && a > c are folded by using the predicate result of
the previous compare and thus allows the removal of one of the compares.

When never a mask is being generated from an BIT_AND we mask the operands of
the and instead and then just AND the result.

This allows us to be able to CSE the masks and generate the right combination.
However because re-assoc will try to re-order the masks in the & we have to now
perform a small local CSE on the vectorized loop is vectorization is successful.

Note: This patch series is working incrementally towards generating the most
      efficient code for this and other loops in small steps.

gcc/ChangeLog:

* tree-vect-stmts.c (prepare_load_store_mask): Rename to...
(prepare_vec_mask): ...This and record operations that have already been
masked.
(vectorizable_call): Use it.
(vectorizable_operation): Likewise.
(vectorizable_store): Likewise.
(vectorizable_load): Likewise.
* tree-vectorizer.h (class _loop_vec_info): Add vec_cond_masked_set.
(vec_cond_masked_set_type, tree_cond_mask_hash): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/pred-combine-and.c: New test.

2 years agoAdd TARGET_IFUNC_REF_LOCAL_OK
H.J. Lu [Sat, 19 Jun 2021 15:16:45 +0000 (08:16 -0700)]
Add TARGET_IFUNC_REF_LOCAL_OK

1. On some targets, like PowerPC, reference to ifunc function resolver
must be non-local so that compiler will properly emit PLT call.  Add
TARGET_IFUNC_REF_LOCAL_OK to allow binding indirect function resolver
locally for targets which don't require special PLT call sequence.
2. Add ix86_call_use_plt_p to call local ifunc function resolvers via
PLT.

gcc/

PR target/51469
PR target/83782
* target.def (ifunc_ref_local_ok): Add a target hook.
* varasm.c (default_binds_local_p_3): Force indirect function
resolver non-local only if targetm.ifunc_ref_local_ok returns
false.
* config/i386/i386-expand.c (ix86_expand_call): Call
ix86_call_use_plt_p to check if PLT should be used.
* config/i386/i386-protos.h (ix86_call_use_plt_p): New.
* config/i386/i386.c (output_pic_addr_const): Call
ix86_call_use_plt_p to check if "@PLT" is needed.
(ix86_call_use_plt_p): New.
(TARGET_IFUNC_REF_LOCAL_OK): New.
* doc/tm.texi.in: Add TARGET_IFUNC_REF_LOCAL_OK.
* doc/tm.texi: Regenerated.

gcc/testsuite/

PR target/51469
PR target/83782
* gcc.target/i386/pr83782-1.c: New test.
* gcc.target/i386/pr83782-2.c: Likewise.

2 years agotestsuite: Fix up pr103456.c testcase [PR103456]
Jakub Jelinek [Fri, 3 Dec 2021 11:09:04 +0000 (12:09 +0100)]
testsuite: Fix up pr103456.c testcase [PR103456]

ubsan.exp cycles through torture options, and that includes
-O2 -flto -fno-fat-lto-objects.  But with those options
tree dump scans don't work for post-IPA passes, for dg-do
compile tests nothing after IPA is done.  So we get an
unresolved testcase:
gcc.dg/ubsan/pr103456.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  : dump file does not exist
UNRESOLVED: gcc.dg/ubsan/pr103456.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-not objsz1 "maximum object size 0"

Fixed by adding -ffat-lto-objects so that we perform the post-IPA
passes.

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

PR tree-optimization/103456
* gcc.dg/ubsan/pr103456.c: Add -ffat-lto-objects to dg-options.

2 years agox86: Speed up target attribute handling by using a cache
Jakub Jelinek [Fri, 3 Dec 2021 10:07:44 +0000 (11:07 +0100)]
x86: Speed up target attribute handling by using a cache

The target attribute handling is very expensive and for the common case
from x86intrin.h where many functions get implicitly the same target
attribute, we can speed up compilation a lot by caching it.

The following patches both create a single entry cache, where they cache
for a particular target attribute argument list the resulting
DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_SPECIFIC_OPTIMIZATION
values from ix86_valid_target_attribute_p and use the cache if the
args are the same as last time and we start either from NULL values
of those, or from the recorded values for those from last time.

Compiling a simple:
 #include <x86intrin.h>

 int i;
testcase with ./cc1 -quiet -O2 -isystem include/ test.c
takes on my WS without the patches ~0.392s and with either of the
patches ~0.182s, i.e. roughly half the time as before.
For ./cc1plus -quiet -O2 -isystem include/ test.c
it is slightly worse, the speed up is from ~0.613s to ~0.403s.

The difference between the 2 patches is that the first one uses copy_list
while the second one uses a vec, so I think the second one has the advantage
of creating less GC garbage.
I've verified both patches achieve the same content of those
DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_SPECIFIC_OPTIMIZATION
nodes as before on x86intrin.h by doing debug_tree on those and comparing
the stderr from without these patches to with these patches.

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

* attribs.h (simple_cst_list_equal): Declare.
* attribs.c (simple_cst_list_equal): No longer static.
* config/i386/i386-options.c (target_attribute_cache): New variable.
(ix86_valid_target_attribute_p): Cache DECL_FUNCTION_SPECIFIC_TARGET
and DECL_FUNCTION_SPECIFIC_OPTIMIZATION based on args.

2 years agopch: Add support for PCH for relocatable executables [PR71934]
Jakub Jelinek [Fri, 3 Dec 2021 10:03:30 +0000 (11:03 +0100)]
pch: Add support for PCH for relocatable executables [PR71934]

So, if we want to make PCH work for PIEs, I'd say we can:
1) add a new GTY option, say callback, which would act like
   skip for non-PCH and for PCH would make us skip it but
   remember for address bias translation
2) drop the skip for tree_translation_unit_decl::language
3) change get_unnamed_section to have const char * as
   last argument instead of const void *, change
   unnamed_section::data also to const char * and update
   everything related to that
4) maybe add a host hook whether it is ok to support binaries
   changing addresses (the only thing I'm worried is if
   some host that uses function descriptors allocates them
   dynamically instead of having them somewhere in the
   executable)
5) maybe add a gengtype warning if it sees in GTY tracked
   structure a function pointer without that new callback
   option

Here is 1), 2), 3) implemented.

Note, on stdc++.h.gch/O2g.gch there are just those 10 relocations without
the second patch, with it a few more, but nothing huge.  And for non-PIEs
there isn't really any extra work on the load side except freading two scalar
values and fseek.

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

PR pch/71934
gcc/
* ggc.h (gt_pch_note_callback): Declare.
* gengtype.h (enum typekind): Add TYPE_CALLBACK.
(callback_type): Declare.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_CALLBACK.
(callback_type): New variable.
(process_gc_options): Add CALLBACK argument, handle callback
option.
(set_gc_used_type): Adjust process_gc_options caller, if callback,
set type to &callback_type.
(output_mangled_typename): Handle TYPE_CALLBACK.
(walk_type): Likewise.  Handle callback option.
(write_types_process_field): Handle TYPE_CALLBACK.
(write_types_local_user_process_field): Likewise.
(write_types_local_process_field): Likewise.
(write_root): Likewise.
(dump_typekind): Likewise.
(dump_type): Likewise.
* gengtype-state.c (type_lineloc): Handle TYPE_CALLBACK.
(state_writer::write_state_callback_type): New method.
(state_writer::write_state_type): Handle TYPE_CALLBACK.
(read_state_callback_type): New function.
(read_state_type): Handle TYPE_CALLBACK.
* ggc-common.c (callback_vec): New variable.
(gt_pch_note_callback): New function.
(gt_pch_save): Stream out gt_pch_save function address and relocation
table.
(gt_pch_restore): Stream in saved gt_pch_save function address and
relocation table and apply relocations if needed.
* doc/gty.texi (callback): Document new GTY option.
* varasm.c (get_unnamed_section): Change callback argument's type and
last argument's type from const void * to const char *.
(output_section_asm_op): Change argument's type from const void *
to const char *, remove unnecessary cast.
* tree-core.h (struct tree_translation_unit_decl): Drop GTY((skip))
from language member.
* output.h (unnamed_section_callback): Change argument type from
const void * to const char *.
(struct unnamed_section): Use GTY((callback)) instead of GTY((skip))
for callback member.  Change data member type from const void *
to const char *.
(struct noswitch_section): Use GTY((callback)) instead of GTY((skip))
for callback member.
(get_unnamed_section): Change callback argument's type and
last argument's type from const void * to const char *.
(output_section_asm_op): Change argument's type from const void *
to const char *.
* config/avr/avr.c (avr_output_progmem_section_asm_op): Likewise.
Remove unneeded cast.
* config/darwin.c (output_objc_section_asm_op): Change argument's type
from const void * to const char *.
* config/pa/pa.c (som_output_text_section_asm_op): Likewise.
(som_output_comdat_data_section_asm_op): Likewise.
* config/rs6000/rs6000.c (rs6000_elf_output_toc_section_asm_op):
Likewise.
(rs6000_xcoff_output_readonly_section_asm_op): Likewise.  Instead
of dereferencing directive hardcode variable names and decide based on
whether directive is NULL or not.
(rs6000_xcoff_output_readwrite_section_asm_op): Change argument's type
from const void * to const char *.
(rs6000_xcoff_output_tls_section_asm_op): Likewise.  Instead
of dereferencing directive hardcode variable names and decide based on
whether directive is NULL or not.
(rs6000_xcoff_output_toc_section_asm_op): Change argument's type
from const void * to const char *.
(rs6000_xcoff_asm_init_sections): Adjust get_unnamed_section callers.
gcc/c-family/
* c-pch.c (struct c_pch_validity): Remove pch_init member.
(pch_init): Don't initialize v.pch_init.
(c_common_valid_pch): Don't warn and punt if .text addresses change.
libcpp/
* include/line-map.h (class line_maps): Add GTY((callback)) to
reallocator and round_alloc_size members.

2 years agofortran: Fix setting of array lower bound for named arrays
Chung-Lin Tang [Fri, 3 Dec 2021 09:27:17 +0000 (17:27 +0800)]
fortran: Fix setting of array lower bound for named arrays

This patch fixes a case of setting array low-bounds, found for particular uses
of SOURCE=/MOLD=. This adjusts the relevant part in gfc_trans_allocate() to
set e3_has_nodescriptor only for non-named arrays.

2021-12-03  Tobias Burnus  <tobias@codesourcery.com>

gcc/fortran/ChangeLog:

* trans-stmt.c (gfc_trans_allocate): Set e3_has_nodescriptor to true
only for non-named arrays.

gcc/testsuite/ChangeLog:

* gfortran.dg/allocate_with_source_26.f90: Adjust testcase.
* gfortran.dg/allocate_with_mold_4.f90: New testcase.

2 years agoMake sure that we get unique test names if several DejaGnu directives refer to the...
Thomas Schwinge [Wed, 22 Sep 2021 10:42:41 +0000 (12:42 +0200)]
Make sure that we get unique test names if several DejaGnu directives refer to the same line [PR102735]

gcc/testsuite/
PR testsuite/102735
* lib/gcc-dg.exp (process-message): Make sure that we get unique
test names.

2 years ago[Committed] New testcase for C++/71792, bitfields and auto
Andrew Pinski [Fri, 3 Dec 2021 08:13:32 +0000 (08:13 +0000)]
[Committed] New testcase for C++/71792, bitfields and auto

This testcase used to fail before GCC 6.4.0 due to the wrong
type being used for auto when used with bitfields, the C++
front-end was using the "bitfield" type rather than the
underlaying type.

Committed the testcase after a quick check.

PR c++/71792

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr71792.C: New test.

2 years agogcc: Fix "argument list too long" from install-plugins
Richard Purdie [Fri, 3 Dec 2021 03:00:04 +0000 (22:00 -0500)]
gcc: Fix "argument list too long" from install-plugins

When building in longer build paths (200+ characters), the
"echo $(PLUGIN_HEADERS)" from the install-plugins target would cause an
"argument list too long error" on some systems.

Avoid this by calling make's sort function on the list which removes
duplicates and stops the overflow from reaching the echo command.
The original sort is left to handle the the .h and .def files.

2021-10-26 Richard Purdie <richard.purdie@linuxfoundation.org>

gcc/ChangeLog:

* Makefile.in: Fix "argument list too long" from install-plugins.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2 years agobuild: Implement --with-multilib-list for avr target
Matt Jacobson [Fri, 3 Dec 2021 02:51:28 +0000 (21:51 -0500)]
build: Implement --with-multilib-list for avr target

gcc

* config.gcc: For the AVR target, populate TM_MULTILIB_CONFIG.
* config/avr/genmultilib.awk: Add ability to filter generated multilib
list.
* config/avr/t-avr: Pass TM_MULTILIB_CONFIG to genmultilib.awk.
* configure.ac: Update help string for --with-multilib-list.
* configure: Regenerate.

2 years agoDaily bump.
GCC Administrator [Fri, 3 Dec 2021 00:17:04 +0000 (00:17 +0000)]
Daily bump.

2 years agoAdjust CPP_FOR_BUILD
Pekka Seppänen [Thu, 2 Dec 2021 20:58:49 +0000 (15:58 -0500)]
Adjust CPP_FOR_BUILD

Hi.

CPP/CPPFLAGS were changed by commit 84401ce5fb4ecab55decb472b168100e7593e01f.  That commit uses CPP as a default for CPP_FOR_BUILD.  Unless CPP is defined, GNU make defaults CPP as `$(CC) -E'.  Given the context, this is now incorrect, since CC_FOR_BUILD should be used.

Fixes PR103011.

-- Pekka

gcc/Changelog:

* configure: Regenerate.
* configure.ac: For CPP_FOR_BUILD use $(CC_FOR_BUILD) -E instead of
$(CPP).

2 years ago[PATCH v2] configure: define TARGET_LIBC_GNUSTACK on musl
Ilya Lipnitskiy [Thu, 2 Dec 2021 20:47:11 +0000 (15:47 -0500)]
[PATCH v2] configure: define TARGET_LIBC_GNUSTACK on musl

musl only uses PT_GNU_STACK to set default thread stack size and has no
executable stack support[0], so there is no reason not to emit the
.note.GNU-stack section on musl builds.

[0]: https://lore.kernel.org/all/20190423192534.GN23599@brightrain.aerifal.cx/T/#u

gcc

* configure: Regenerate.
* configure.ac: Define TARGET_LIBC_GNUSTACK on musl.

2 years agoDarwin: Rewrite host PCH support [PR 55610].
Iain Sandoe [Sat, 13 Nov 2021 12:39:09 +0000 (12:39 +0000)]
Darwin: Rewrite host PCH support [PR 55610].

We need to revise the PCH memory allocation scheme to enable
support for PIE on aarch64.  The rewrite uses a similar scheme
to the one used on Linux.

We attempt to identify VM segments for each arch/OS version that
are always available to the compiler (note this is not general,
it only needs to work for the cc1* exes).

If we cannot find the preferred segment we fall back to allowing
the kernel to supply one - this is more likely to fail when the
PCH read-in occurs (but that is trapped).

In doing this we obviate the need to unmap any part of the
compiler __DATA segment - thus fixing PR 55610.

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

PR target/55610
* config/host-darwin.c (TRY_EMPTY_VM_SPACE,
SAFE_ALLOC_SIZE): New.
(darwin_gt_pch_get_address): Rewrite to use nominated
memory segments rather than part of the compiler __DATA
segment.
(darwin_gt_pch_use_address): Likewise.

2 years agodoc: Remove references to FreeBSD 1 and 2
Gerald Pfeifer [Thu, 2 Dec 2021 19:08:38 +0000 (21:08 +0200)]
doc: Remove references to FreeBSD 1 and 2

FreeBSD 1 and FreeBSD 2, both still a.out, have been end of life for
over two decades and GCC has not been supporting them for ages, too,
so simply remove references.

gcc:
* doc/install.texi (*-*-freebsd*): Remove references to
FreeBSD 1 and FreeBSD 2.

2 years agoanalyzer: add regression test for leak false +ve [PR103526]
David Malcolm [Thu, 2 Dec 2021 16:48:04 +0000 (11:48 -0500)]
analyzer: add regression test for leak false +ve [PR103526]

gcc/testsuite/ChangeLog:
PR analyzer/103526
* gcc.dg/analyzer/pr103526.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years ago[PR103437] Make backup code for overflow conditional
Vladimir N. Makarov [Thu, 2 Dec 2021 17:31:28 +0000 (12:31 -0500)]
[PR103437] Make backup code for overflow conditional

Switch off long long variant overflow code by preprocessor if the
build compiler has __builtin_smul_overflow.

gcc/ChangeLog:
PR rtl-optimization/103437
* ira-color.c (setup_allocno_priorities): Switch off backup code
for overflow if compiler has __builtin_smul_overflow.  Use <
for comparison with -INT_MAX.

2 years agolibstdc++: Allow exception classes to move fully-dynamic strings
Jonathan Wakely [Thu, 2 Dec 2021 11:53:21 +0000 (11:53 +0000)]
libstdc++: Allow exception classes to move fully-dynamic strings

The move constructor for the fully-dynamic std::basic_string was not
noexcept until recently, so the std::logic_error and std::runtime_error
move constructors were defined to make non-throwing copies of their
string members, instead of potentially-throwing moves.

Now that move construction is always noexecpt, the exception classes can
always move the string. The fully-dynamic string move assignment was
always noexcept, so I don't know why I special-cased the move assignment
operators of the exception classes. That can be changed too.

libstdc++-v3/ChangeLog:

* src/c++11/cow-stdexcept.cc [_GLIBCXX_FULY_DYNAMIC_STRING]
(logic_error, runtime_error): Remove custom definitions.

2 years agolibstdc++: Remove broken std::allocator base classes [PR103340]
Jonathan Wakely [Wed, 1 Dec 2021 16:30:30 +0000 (16:30 +0000)]
libstdc++: Remove broken std::allocator base classes [PR103340]

The bitmap_allocator, __mt_alloc and __pool_alloc extensions are no
longer suitable for use as the base class of std::allocator, because
they have not been updated to meet the C++20 requirements.  There is a
patch attached to PR 103340 which addresses that, but more work would be
needed to solve the linking errors that occur when the library is
configured to use them.

Using --enable-libstdcxx-allocator=bitmap wouldn't even bootstrap for
the past few years, and I can't find any gcc-testresults reports using
any of these allocators. This patch removes the configure option to use
these as the std::allocator base class. The allocators are still in the
tree and can be used directly, you just can't configure the library to
use one of them as the base class of std::allocator.

libstdc++-v3/ChangeLog:

PR libstdc++/103340
PR libstdc++/103400
PR libstdc++/103381
* acinclude.m4 (GLIBCXX_ENABLE_ALLOCATOR): Remove mt, bitmap
and pool options.
* configure: Regenerate.
* config/allocator/bitmap_allocator_base.h: Removed.
* config/allocator/mt_allocator_base.h: Removed.
* config/allocator/pool_allocator_base.h: Removed.
* doc/xml/manual/allocator.xml: Update.
* doc/xml/manual/configure.xml: Update.
* doc/xml/manual/evolution.xml: Document removal.
* doc/xml/manual/mt_allocator.xml: Editorial tweaks.
* doc/html/manual/*: Regenerate.

2 years agolibstdc++: Restore unconditional atomic load in COW std::string
Jonathan Wakely [Wed, 1 Dec 2021 20:58:58 +0000 (20:58 +0000)]
libstdc++: Restore unconditional atomic load in COW std::string

The relaxed load is already optimal, checking the __single_threaded
global before doing a non-atomic load isn't an optimization.

libstdc++-v3/ChangeLog:

* include/bits/cow_string.h (basic_string::_M_is_leaked()):
Revert change to check __is_single_threaded() before using
atomic load.

2 years agors6000: Enable new built-in support, with test suite and altivec.h changes
Bill Schmidt [Thu, 2 Dec 2021 03:11:55 +0000 (21:11 -0600)]
rs6000: Enable new built-in support, with test suite and altivec.h changes

This patch enables the new built-in infastructure for the Power back end.
To avoid any patches causing regressions that would affect bisection, this is a
combined patch that also includes all the test suite changes and the necessary
modifications to altivec.h.  The patches included here are the following:

https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584638.html
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/578613.html
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584829.html
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/578614.html

The third of these four was broken up into multiple patches for review, but
effectively all pieces of it were accepted after an independent patch that
modified the error handling for overloaded builtins.

2021-12-02  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/altivec.h: Delete a number of #defines that are now
superfluous.  Alphabetize.  Include rs6000-vecdefines.h.  Include some
synonyms.
* config/rs6000/rs6000-builtin-new.def (CMPB): Flag as no32bit.
(BPERMD): Flag as 32bit (needing special handling for 32-bit).
(UNPACK_TD): Return unsigned long long instead of unsigned long.
(GET_TEXASR): Return unsigned long instead of unsigned long long.
(GET_TEXASRU): Likewise.
(GET_TFHAR): Likewise.
(GET_TFIAR): Likewise.
(SET_TEXASR): Pass unsigned long instead of unsigned long long.
(SET_TEXASRU): Likewise.
(SET_TFHAR): Likewise.
(SET_TFIAR): Likewise.
(TABORTDC): Likewise.
(TABORTDCI): Likewise.
* config/rs6000/rs6000-call.c (rs6000_expand_new_builtin): Fix error
handling for no32bit.  Add 32bit handling for RS6000_BIF_BPERMD.
* config/rs6000/rs6000-gen-builtins.c (write_init_file): Initialize
new_builtins_are_live to 1.

gcc/testsuite/
* gcc.target/powerpc/bfp/scalar-extract-exp-2.c: Adjust expected error
message.
* gcc.target/powerpc/bfp/scalar-extract-sig-2.c: Likewise.
* gcc.target/powerpc/bfp/scalar-insert-exp-2.c: Likewise.
* gcc.target/powerpc/bfp/scalar-insert-exp-5.c: Likewise.
* gcc.target/powerpc/bfp/scalar-insert-exp-8.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-neg-2.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-neg-3.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-neg-5.c: Likewise.
* gcc.target/powerpc/byte-in-set-2.c: Likewise.
* gcc.target/powerpc/cmpb-2.c: Likewise.
* gcc.target/powerpc/cmpb-3.c: Likewise.
* gcc.target/powerpc/cmpb32-2.c: Likewise.
* gcc.target/powerpc/crypto-builtin-2.c: Likewise.
* gcc.target/powerpc/fold-vec-splat-floatdouble.c: Remove invalid
test and adjust xxpermdi count.
* gcc.target/powerpc/fold-vec-splat-longlong.c: Remove invalid
tests and adjust instruction counts.
* gcc.target/powerpc/fold-vec-splat-misc-invalid.c: Adjust expected
error messages.
* gcc.target/powerpc/int_128bit-runnable.c: Adjust instruction counts.
* gcc.target/powerpc/pr80315-1.c: Adjust expected error message.
* gcc.target/powerpc/pr80315-2.c: Likewise.
* gcc.target/powerpc/pr80315-3.c: Likewise.
* gcc.target/powerpc/pr80315-4.c: Likewise.
* gcc.target/powerpc/pr88100.c: Likewise.
* gcc.target/powerpc/pragma_misc9.c: Likewise.
* gcc.target/powerpc/pragma_power8.c: Undef _RS6000_VECDEFINES_H.
* gcc.target/powerpc/pragma_power9.c: Likewise.
* gcc.target/powerpc/test_fpscr_drn_builtin_error.c: Adjust expected
error messages.
* gcc.target/powerpc/test_fpscr_rn_builtin_error.c: Likewise.
* gcc.target/powerpc/vec-gnb-2.c: Likewise.
* gcc.target/powerpc/vsu/vec-all-nez-7.c: Likewise.
* gcc.target/powerpc/vsu/vec-any-eqz-7.c: Likewise.
* gcc.target/powerpc/vsu/vec-cmpnez-7.c: Likewise.
* gcc.target/powerpc/vsu/vec-cntlz-lsbb-2.c: Likewise.
* gcc.target/powerpc/vsu/vec-cnttz-lsbb-2.c: Likewise.
* gcc.target/powerpc/vsu/vec-xl-len-13.c: Likewise.
* gcc.target/powerpc/vsu/vec-xst-len-12.c: Likewise.

2 years ago[Ada] Add warning in comment about files copied from libgnat
Eric Botcazou [Fri, 26 Nov 2021 10:06:36 +0000 (11:06 +0100)]
[Ada] Add warning in comment about files copied from libgnat

gcc/ada/

* gcc-interface/Make-lang.in (ADA_GENERATED_FILES): Add warning.

2 years ago[Ada] Remove obsolete a-assert
Marc Poulhiès [Tue, 23 Nov 2021 09:53:06 +0000 (10:53 +0100)]
[Ada] Remove obsolete a-assert

gcc/ada/

* gcc-interface/a-assert.ads, gcc-interface/a-assert.adb: Remove.

2 years ago[Ada] Do not back-annotate maximum size for limited types
Eric Botcazou [Thu, 18 Nov 2021 21:47:05 +0000 (22:47 +0100)]
[Ada] Do not back-annotate maximum size for limited types

gcc/ada/

* gcc-interface/decl.c (gnat_to_gnu_entity): Do not back-annotate a
maximum size for the Esize of limited record and concurrent types.

2 years ago[Ada] Fix packing for array component with discriminated part
Eric Botcazou [Tue, 16 Nov 2021 23:09:56 +0000 (00:09 +0100)]
[Ada] Fix packing for array component with discriminated part

gcc/ada/

* gcc-interface/gigi.h (aggregate_type_contains_array_p): Delete.
(type_has_variable_size): Declare.
* gcc-interface/decl.c (adjust_packed): Return 0 only if the field
type is an array with variable size.
* gcc-interface/utils.c (aggregate_type_contains_array_p): Make
static and remove SELF_REFERENTIAL parameter.
(type_has_variable_size): Make public.
(create_field_decl): Adjust call to aggregate_type_contains_array_p.

2 years ago[Ada] Invalid memory access on finalization of class-wide type
Justin Squirek [Mon, 15 Nov 2021 22:14:39 +0000 (22:14 +0000)]
[Ada] Invalid memory access on finalization of class-wide type

gcc/ada/

* gcc-interface/decl.c (gnat_to_gnu_entity): Skip normal
processing for Itypes that are E_Class_Wide_Subtype with
Equivalent_Type set.

2 years ago[Ada] Fix oversight in minor cleanup
Eric Botcazou [Tue, 9 Nov 2021 18:56:34 +0000 (19:56 +0100)]
[Ada] Fix oversight in minor cleanup

gcc/ada/

* gcc-interface/trans.c (Call_to_gnu): Rename GNAT_NAME variable
into GNAT_SUBPROG to avoid later shadowing.

2 years ago[Ada] Proof of System.Arith_32 for double arithmetic on 32bits
Yannick Moy [Thu, 25 Nov 2021 14:35:39 +0000 (15:35 +0100)]
[Ada] Proof of System.Arith_32 for double arithmetic on 32bits

gcc/ada/

* libgnat/s-arit32.adb: Add ghost instances and lemmas.
(Scaled_Divide32): Add ghost code to prove. Minor code
modification to return early in error when divisor is zero.
* libgnat/s-arit32.ads: Add ghost instances and utilities.
(Scaled_Divide32): Add contract.

2 years ago[Ada] Reset internal flags for -gnatD and -gnatG
Eric Botcazou [Sun, 28 Nov 2021 16:26:27 +0000 (17:26 +0100)]
[Ada] Reset internal flags for -gnatD and -gnatG

gcc/ada/

* sprint.adb (Source_Dump): Set both Print_Generated_Code and
Debug_Generated_Code to False at the end.

2 years ago[Ada] Fix obsolete array aggregate warning being triggered by expanded code
Marc Poulhiès [Fri, 26 Nov 2021 09:49:51 +0000 (10:49 +0100)]
[Ada] Fix obsolete array aggregate warning being triggered by expanded code

gcc/ada/

* sem_aggr.adb (Resolve_Array_Aggregate): Filter out nodes not
coming from source before emitting the warning.

2 years ago[Ada] Amend proof of System.Arith_Double to remove justifications
Yannick Moy [Fri, 26 Nov 2021 07:55:13 +0000 (08:55 +0100)]
[Ada] Amend proof of System.Arith_Double to remove justifications

gcc/ada/

* libgnat/s-aridou.adb (Log_Single_Size, Big_0): New ghost
constants.
(Lemma_Mult_Non_Negative, Lemma_Mult_Non_Positive,
Lemma_Not_In_Range_Big2xx64): New lemmas on big integers.
(Double_Divide): Remove justifications. Amend for that local
lemma Prove_Overflow_Case.
(Scaled_Divide): Remove justifications. Insert for that local
lemmas Prove_Negative_Dividend, Prove_Positive_Dividend and
Prove_Q_Too_Big, and amend local lemma Prove_Overflow.  To prove
the loop invariant on (Shift mod 2 = 0), introduce local ghost
variable Iter to count loop iterations, and relate its value to
the value of Shift through Log_Single_Size, with the help of
local lemma Prove_Power. Deal with proof regression by adding
new local lemma Prove_First_Iteration and local ghost variable
D123.
* libgnat/s-arit64.ads (Multiply_With_Ovflo_Check64): Remove
unnecessary Pure_Function on function as package is Pure.

2 years ago[Ada] Add pragma Annotate for CodePeer analysis
Yannick Moy [Fri, 26 Nov 2021 08:32:09 +0000 (09:32 +0100)]
[Ada] Add pragma Annotate for CodePeer analysis

gcc/ada/

* libgnat/s-widthi.adb: Add pragma Annotate.

2 years ago[Ada] Proof of support units for 'Width on signed integers
Yannick Moy [Wed, 24 Nov 2021 16:20:59 +0000 (17:20 +0100)]
[Ada] Proof of support units for 'Width on signed integers

gcc/ada/

* libgnat/s-widint.ads: Mark in SPARK.
* libgnat/s-widlli.ads: Likewise.
* libgnat/s-widllli.ads: Likewise.
* libgnat/s-widlllu.ads: Likewise.
* libgnat/s-widllu.ads: Disable ghost/contract.
* libgnat/s-widthi.adb: Replicate and adapt the proof from
s-widthu.adb.
* libgnat/s-widthi.ads: Add minimal postcondition.
* libgnat/s-widthu.adb: Fix comments in the modular case.
* libgnat/s-widthu.ads: Add minimal postcondition.
* libgnat/s-widuns.ads: Disable ghost/contract.

2 years ago[Ada] Cleanup detection of suspension objects
Piotr Trojanek [Thu, 25 Nov 2021 12:02:00 +0000 (13:02 +0100)]
[Ada] Cleanup detection of suspension objects

gcc/ada/

* rtsfind.ads (RE_Id, RE_Unit_Table): Add RE_Suspension_Object.
* sem_util.adb (Is_Descendant_Of_Suspension_Object): Use Is_RTE.
(Is_Suspension_Object): Remove body.
* sem_util.ads (Is_Suspension_Object): Remove spec.
* snames.ads-tmpl (Name_Suspension_Object): Remove, now
unreferenced.

2 years ago[Ada] Cleanup insertion of single freezing actions
Piotr Trojanek [Thu, 25 Nov 2021 13:54:17 +0000 (14:54 +0100)]
[Ada] Cleanup insertion of single freezing actions

gcc/ada/

* exp_util.adb (Append_Freeze_Action): Tune whitespace to make
the code look similar to Append_Freeze_Actions, which takes a
List_Id.
* sem_ch6.adb (Analyze_Return_Type): Cleanup with
Append_Freeze_Action.
* exp_ch3.adb (Build_Access_Subprogram_Wrapper_Body): Likewise.
* sem_ch3.adb (Build_Access_Subprogram_Wrapper): Likewise.
* contracts.adb (Add_Indirect_Call_Wrapper): Remove extra call
to Ensure_Freeze_Node.
(Add_Call_Helper): Likewise.
* freeze.adb (Check_Inherited_Conditions): Likewise.
(Attribute_Renaming): Likewise.
* sem_ch8.adb: Likewise.

2 years ago[Ada] Cleanups related to expansion of dispatching primitives
Piotr Trojanek [Wed, 24 Nov 2021 21:06:01 +0000 (22:06 +0100)]
[Ada] Cleanups related to expansion of dispatching primitives

gcc/ada/

* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst
(No_Dispatching_Calls): Fix whitespace in example code.
* gnat_rm.texi: Regenerate.
* exp_ch13.adb (Expand_N_Freeze_Entity): Replace low-level
membership test with a high-level wrapper.
* exp_ch3.adb (Expand_Freeze_Record_Type): Remove unnecessary
initialization of list of wrapper declarations and unnecessary
guard for list of their bodies (if no bodies are created then
Append_Freeze_Actions is a no-op).

2 years ago[Ada] Use bracket aggregates in Ada2022
Marc Poulhiès [Fri, 5 Nov 2021 09:24:27 +0000 (10:24 +0100)]
[Ada] Use bracket aggregates in Ada2022

gcc/ada/

* exp_imgv.adb (Append_Table_To): Add new parameter to
Make_Aggregate call.
* gen_il-fields.ads (Opt_Field_Enum):
Add Is_Parenthesis_Aggregate and Is_Enum_Array_Aggregate.
* gen_il-gen-gen_nodes.adb (Union): Add Is_Enum_Array_Aggregate
and Is_Parenthesis_Aggregate field to N_Aggregate.
* libgnarl/s-interr.adb (User_Handler, User_Entry, Blocked)
(Ignored, Last_Unblocker, Server_ID): Likewise.
* libgnarl/s-intman.ads (Keep_Unmasked, Reserve): Likewise.
* libgnarl/s-intman__posix.adb (Exception_Interrupts)
(Initialize): Likewise.
* libgnarl/s-mudido__affinity.adb (Create): Likewise.
* libgnarl/s-osinte__linux.ads (Unmasked, Reserved): Likewise.
* libgnarl/s-taprop__linux.adb (Create_Task, Set_Task_Affinity)
* libgnarl/s-tasdeb.adb (Trace_On): Likewise.
* libgnarl/s-tasdeb.ads (Known_Tasks): Likewise.
* libgnarl/s-tasinf__linux.ads (Any_CPU, No_CPU): Likewise.
* libgnarl/s-taskin.adb (Initialize_ATCB): Likewise.
* libgnarl/s-taskin.ads (Ada_Task_Control_Block): Likewise.
* libgnarl/s-tasren.adb (Default_Treatment)
(New_State): Likewise.
* libgnarl/s-tassta.adb (Trace_Unhandled_Exception_In_Task):
Likewise.
* libgnarl/s-tataat.adb (Index_Array): Likewise.
* libgnarl/s-tpobop.adb (New_State): Likewise.
* libgnat/a-calend.adb (Cumulative_Days_Before_Month)
(Leap_Second_Times): Likewise.
* libgnat/a-calend.ads (Days_In_Month): Likewise.
* libgnat/a-cfinve.adb (Insert): Likewise.
* libgnat/a-chahan.adb (Char_Map): Likewise.
* libgnat/a-chtgbo.adb (Clear): Likewise.
* libgnat/a-cobove.adb ("&", Insert, To_Vector): Likewise.
* libgnat/a-cofove.adb (Insert, To_Vector): Likewise.
* libgnat/a-cohata.ads (Hash_Table_Type): Likewise.
* libgnat/a-coinve.adb (Merge, Insert, Insert_Space): Likewise.
* libgnat/a-convec.adb (Insert, To_Vector): Likewise.
* libgnat/a-coprnu.ads (Primes): Likewise.
* libgnat/a-direct.adb (Empty_String): Use regular "" instead
of aggregate.
(Start_Search_Internal, Name_Case_Equivalence, Search)
(Start_Search, Start_Search_Internal): Use bracket for
aggregate.
* libgnat/a-direct.ads (Start_Search,Search): Likewise.
* libgnat/a-direio.adb (Zeroes): Likewise.
* libgnat/a-nbnbre.adb (Leading_Padding, Trailing_Padding)
(Numerator_Image): Likewise.
* libgnat/a-ngrear.adb (Jacobi): Likewise.
* libgnat/a-stbubo.adb (Get_UTF_8): Likewise.
* libgnat/a-stbufo.adb (Put): Likewise.
* libgnat/a-stbuun.adb (Get_UTF_8): Likewise.
* libgnat/a-stbuut.adb (Put_7bit, Put_Character)
(Put_Wide_Character, Put_Wide_Wide_Character): Likewise.
* libgnat/a-stmaco.ads (Control_Set,Graphic_Set,Letter_Set)
(Lower_Set, Upper_Set, Basic_Set, Decimal_Digit_Set)
(Hexadecimal_Digit_Set, Alphanumeric_Set, Special_Set)
(ISO_646_Set): Likewise.
* libgnat/a-strbou.ads (Insert, Tail, "*", Replicate)
(Null_Bounded_String): Likewise.
* libgnat/a-strfix.ads (Head, Tail): Likewise.
* libgnat/a-strmap.adb (To_Domain, Lemma_Is_Sorted): Likewise.
* libgnat/a-strmap.ads (Null_Set): Likewise.
* libgnat/a-strsup.adb (Super_Head, Super_Replicate)
(Super_Tail): Likewise.
* libgnat/a-strsup.ads (Super_Head, Super_Tail, Times)
(Super_Replicate): Likewise.
* libgnat/a-sttebu.adb (Put_UTF8, Wide_Put_UTF_16): Likewise.
* libgnat/a-stuten.ads (BOM_16): Likewise.
* libgnat/a-stwibo.ads (Null_Bounded_Wide_String): Likewise.
* libgnat/a-stwima.ads (Null_Range): Likewise.
* libgnat/a-stwisu.adb (Super_Head, Super_Replicate)
(Super_Tail): Likewise.
* libgnat/a-stzbou.ads
(Null_Bounded_Wide_Wide_String): Likewise.
* libgnat/a-stzmap.ads (Null_Range): Likewise.
* libgnat/a-stzsup.adb (Super_Head, Super_Replicate)
(Super_Tail, Super_Trim): Likewise.
* libgnat/a-swmwco.ads (Control_Ranges, Graphic_Ranges)
(Letter_Ranges, Lower_Ranges, Upeer_Ranges, Basic_Ranges)
(Decimal_Digit_Ranges, Hexadecimal_Digit_Ranges)
(Alphanumeric_Ranges, Special_Graphic_Ranges, ISO_646_Ranges)
(Character_Ranges, Lower_Case_Mapping, Upper_Case_Mapping)
(Basic_Mapping): Likewise.
* libgnat/a-szmzco.ads (Control_Ranges, Graphic_Ranges)
(Letter_Ranges, Lower_Ranges, Upeer_Ranges, Basic_Ranges)
(Decimal_Digit_Ranges, Hexadecimal_Digit_Ranges)
(Alphanumeric_Ranges, Special_Graphic_Ranges, ISO_646_Ranges)
(Character_Ranges, Lower_Case_Mapping, Upper_Case_Mapping)
(Basic_Mapping): Likewise.
* libgnat/a-teioed.adb (Format_Number): Likewise.
* libgnat/a-wtedit.adb (Format_Number): Likewise.
* libgnat/a-ztedit.adb (Format_Number): Likewise.
* libgnat/g-arrspl.adb (Separators): Likewise.
* libgnat/g-catiio.adb (Month_Name_To_Number): Likewise.
* libgnat/g-cgideb.adb (NL, Title): Likewise.
* libgnat/g-comlin.adb (Internal_Initialize_Option_Scan)
(Display_Section_Help): Likewise.
* libgnat/g-comlin.ads (Opt_Parser_Data): Likewise.
* libgnat/g-debpoo.adb (Set_Dead_Beef, Dump): Likewise.
* libgnat/g-expect.adb (Expect, Has_Process, Send): Likewise.
* libgnat/g-forstr.adb ("+", Get_Formatted): Likewise.
* libgnat/g-memdum.adb (Dump): Likewise.
* libgnat/g-rannum.adb (Image): Likewise.
* libgnat/g-sechas.adb (Final, HMAC_Initial_Context): Likewise.
* libgnat/g-sehamd.ads (Initial_State): Likewise.
* libgnat/g-sehash.ads (Initial_State): Likewise.
* libgnat/g-sercom.ads (Data_Rate_Value): Likewise.
* libgnat/g-sercom__linux.adb (C_Data_Rate, C_Bits, C_Stop_Bits)
(C_Parity): Likewise.
* libgnat/g-shsh32.ads (K, Transform): Likewise.
* libgnat/g-shsh64.ads (K, Transform): Likewise.
* libgnat/g-socket.adb (Levels, Modes, Shutmodes, Requests)
(Options, Flags, Get_Name_Info, Image): Likewise.
* libgnat/g-socket.ads (Inet_Addr_Bytes_Length, Inet_Addr_Type)
(IPv4_To_IPv6_Prefix, Any_Inet_Addr, Any_Inet6_Addr)
(No_Inet_Addr, Broadcast_Inet_Addr, Loopback_Inet_Addr)
(Loopback_Inet6_Addr, Unspecified_Group_Inet_Addr)
(All_Hosts_Group_Inet_Addr, All_Routers_Group_Inet_Addr)
(Unspecified_Group_Inet6_Addr, All_Hosts_Group_Inet6_Addr)
(All_Routers_Group_Inet6_Addr): Likewise.
* libgnat/g-socpol.adb (To_C, Status, Get_Events): Likewise.
* libgnat/g-socpol.ads (Input_Event, Output_Event, Both_Event)
(Error_Event): Likewise.
* libgnat/g-sothco.ads (Families, Lengths, Sockaddr): Likewise.
* libgnat/g-spipat.adb (OK_For_Simple_Arbno): Likewise.
* libgnat/i-cobol.ads (Ada_To_COBOL, COBOL_To_Ada): Likewise.
* libgnat/i-pacdec.adb (Packed_Byte): Likewise.
* libgnat/i-pacdec.ads (Packed_Size): Likewise.
* libgnat/s-bitops.adb (Masks): Likewise.
* libgnat/s-crc32.adb (Table): Likewise.
* libgnat/s-gearop.adb (Unit_Matrix, Unit_Vector): Likewise.
* libgnat/s-genbig.adb (Out_data, Zero_Data, Big_Exp, Big_Mul)
(To_Bignum, To_String, Image, Leading_Padding): Likewise.
* libgnat/s-htable.adb (Reset): Likewise.
* libgnat/s-imgcha.adb (C0, C1): Likewise.
* libgnat/s-powflt.ads (Powten): Likewise.
* libgnat/s-powlfl.ads (Powten): Likewise.
* libgnat/s-powllf.ads (Powten): Likewise.
* libgnat/s-rannum.adb (Matrix_A, Random_Float_Template, Image):
Likewise.
* libgnat/s-rannum.ads (Generator): Likewise.
* libgnat/s-regexp.adb (Compile,Create_Primary_Table)
(Create_Primary_Table_Glob, Create_Secondary_Table, Compile):
Likewise.
* libgnat/s-regpat.adb (Bit_Conversion, Set, Dump_Until)
(Dump_Current, Dump_Error, Try, Reset_Class): Likewise.
* libgnat/s-regpat.ads (Pattern_Matcher, Never_Match): Likewise.
* libgnat/s-scaval__128.adb (Initialize): Likewise.
* libgnat/s-statxd.adb (Fields, W_F, W_LF)
(W_LLF, W_SF): Likewise.
* libgnat/s-stausa.adb (Initialize, Initialize_Analyzer)
(Output_Results): Likewise.
* libgnat/s-strops.adb (Str_Concat_SC): Likewise.
* libgnat/s-valrea.adb (Maxexp32, Maxexp64, Maxexp80): Likewise.
* libgnat/s-wchcon.ads (WC_Encoding_Letters)
(WC_Longest_Sequences): Likewise.
* par-ch4.adb (P_Aggregate_Or_Paren_Expr): Set
Is_Parenthesis_Aggregate when creating a N_Aggregate using
parenthesis.
* scng.adb (Scan): Lower version needed for bracket syntax from
Extensions to Ada2022.
* sem_aggr.adb (Resolve_Aggregate): Raise error for container
aggregate using parenthesis instead of bracket.
(Resolve_Array_Aggregate): Raise warning for aggregate using
parenthesis in Ada2022 with obsolescent warning enabled and not
in GNAT mode.
* sem_util.ads (Check_Ambiguous_Aggregate): Typo fix in comment.

2 years ago[Ada] Inline all calls in Ada.Task_Identification
Piotr Trojanek [Wed, 17 Nov 2021 13:31:20 +0000 (14:31 +0100)]
[Ada] Inline all calls in Ada.Task_Identification

gcc/ada/

* libgnarl/a-taside.ads (Activation_Is_Complete): Add pragma
Inline.

2 years ago[Ada] Enhance freezing code for instantiations
Eric Botcazou [Wed, 17 Nov 2021 13:19:45 +0000 (14:19 +0100)]
[Ada] Enhance freezing code for instantiations

gcc/ada/

* sem_ch12.adb (Freeze_Package_Instance): Consistently consider
the freeze node of the parent and use large inequality for
Slocs.
(Freeze_Subprogram_Instance): Likewise.
(Insert_Freeze_Node_For_Instance): For an instance in a package
spec with no source body that immediately follows, consider the
body of the package for the placement of the freeze node and go
to the outer level if there is no such body.

2 years ago[Ada] Enable expansion of dispatching equality for GNATprove
Piotr Trojanek [Mon, 22 Nov 2021 18:01:33 +0000 (19:01 +0100)]
[Ada] Enable expansion of dispatching equality for GNATprove

gcc/ada/

* exp_ch13.ads (Expand_N_Freeze_Entity): Add note about a SPARK
twin.
* exp_ch3.ads (Freeze_Type): Likewise.
* exp_spark.adb (Expand_SPARK_N_Freeze_Entity): Mimic what is
done in Freeze_Entity.
(SPARK_Freeze_Type): Mimic what is done in Freeze_Type; add call
to Make_Predefined_Primitive_Eq_Spec.

2 years ago[Ada] Separate building of equality from other dispatching routines
Piotr Trojanek [Mon, 22 Nov 2021 16:58:06 +0000 (17:58 +0100)]
[Ada] Separate building of equality from other dispatching routines

gcc/ada/

* exp_ch3.adb (Make_Predefined_Primitive_Specs): Move code for
spec of dispatching equality.
(Predefined_Primitive_Bodies): Move code for body if dispatching
equality.
(Make_Predefined_Primitive_Eq_Spec): Separated code for spec of
dispatching equality.
(Predefined_Primitive_Eq_Body): Separated code for body of
dispatching equality.
* exp_ch3.ads: Update.

2 years ago[Ada] Split spec and body of expression function with Subprogram_Variant
Piotr Trojanek [Mon, 22 Nov 2021 20:12:41 +0000 (21:12 +0100)]
[Ada] Split spec and body of expression function with Subprogram_Variant

gcc/ada/

* libgnat/s-valuti.ads (Scan_Natural_Ghost): Split body from
spec and put it into private part, so that GNATprove can pick it
both when analysing the unit and its clients.

2 years ago[Ada] Remove extra space after assignment symbol
Piotr Trojanek [Tue, 23 Nov 2021 11:22:27 +0000 (12:22 +0100)]
[Ada] Remove extra space after assignment symbol

gcc/ada/

* exp_aggr.adb, exp_ch6.adb, par-ch4.adb, sem_ch13.adb: Remove
extra space after ":=" symbol.
* gen_il-gen.adb: Likewise; add missing headerbox.

2 years ago[Ada] Don't allow entry in implicit with chain to be ghost
Richard Kenner [Mon, 22 Nov 2021 22:38:50 +0000 (17:38 -0500)]
[Ada] Don't allow entry in implicit with chain to be ghost

gcc/ada/

* rtsfind.adb (Maybe_Add_With): Ensure that the added "with" is
never marked as ignored ghost code.

2 years ago[Ada] Simplify iteration over record components
Piotr Trojanek [Mon, 22 Nov 2021 11:53:15 +0000 (12:53 +0100)]
[Ada] Simplify iteration over record components

gcc/ada/

* freeze.adb (Freeze_Entity): Replace First_Entity/Next_Entity
with First_Component/Next_Component; remove condition with Ekind
equal to E_Component.
* sem_ch13.adb (Check_Record_Representation_Clause): Likewise
for component-or-discriminant.
* sem_util.adb (Is_Fully_Initialized_Type): Likewise; rename Ent
to a more specific Comp.
* sem_warn.adb (Check_References): Likewise.

2 years ago[Ada] Refactor nested loops in warning on unassigned out parameter
Piotr Trojanek [Mon, 22 Nov 2021 11:15:29 +0000 (12:15 +0100)]
[Ada] Refactor nested loops in warning on unassigned out parameter

gcc/ada/

* sem_warn.adb (Warn_On_Unassigned_Out_Parameter): Move inner
loop at the beginning of subprogram, so it is executed only
once; fix order in the "add an ad hoc" phrase.

2 years ago[Ada] Remove duplicated condition in warnings about read-before-write
Piotr Trojanek [Mon, 22 Nov 2021 11:11:46 +0000 (12:11 +0100)]
[Ada] Remove duplicated condition in warnings about read-before-write

gcc/ada/

* sem_warn.adb (Check_References): Remove redundant condition.

2 years ago[Ada] vx7r2cert/light-tasking-rtp: undefined refs on ppc/ppc64
Doug Rupp [Thu, 18 Nov 2021 20:44:22 +0000 (12:44 -0800)]
[Ada] vx7r2cert/light-tasking-rtp: undefined refs on ppc/ppc64

gcc/ada/

* vxworks7-cert-rtp-link__ppcXX.spec: New file.
* Makefile.rtl: Use it.

2 years ago[Ada] Proof of Interfaces.C with SPARK
Yannick Moy [Mon, 15 Nov 2021 20:36:34 +0000 (21:36 +0100)]
[Ada] Proof of Interfaces.C with SPARK

gcc/ada/

* libgnat/i-c.adb: Add ghost code.
(C_Length_Ghost): New ghost functions to query the C length of a
string.
(To_Ada): Insert constant Count_Cst where needed to comply with
SPARK.  Homogeneize code between variants for char, wchar_t,
char16_t and char32_t. Use char16_nul and char32_nul
systematically instead of their value. Fix the type of index To
to be Integer instead of Positive, to avoid a possible range
check failure on an empty Target. Insert an exit statement to
avoid a possible overflow failure when the last index in Target
is Natural'Last (possibly on a small string as well).
* libgnat/i-c.ads: Add contracts.
(C_Length_Ghost): New ghost functions to query the C length of a
string.
* libgnat/s-os_lib.adb: Remove pragma Compiler_Unit_Warning
causing a spurious error during compilation of GNAT, as this
pragma is not needed anymore now that we bootstrap (stage1) with
the base compiler runtime.

2 years ago[Ada] Add contract to Ada.Task_Identification.Activation_Is_Complete
Piotr Trojanek [Wed, 17 Nov 2021 13:24:25 +0000 (14:24 +0100)]
[Ada] Add contract to Ada.Task_Identification.Activation_Is_Complete

gcc/ada/

* libgnarl/a-taside.ads (Activation_Is_Complete): Add
precondition.

2 years ago[Ada] More intuitive names in sanity-checking of derived types
Piotr Trojanek [Sun, 21 Nov 2021 19:26:32 +0000 (20:26 +0100)]
[Ada] More intuitive names in sanity-checking of derived types

gcc/ada/

* sem_ch3.adb (Check_Derived_Type): Rename local variables; fix
style in comment.

2 years ago[Ada] Proof of System.Val_Util utilities for 'Value support
Yannick Moy [Fri, 19 Nov 2021 09:34:21 +0000 (10:34 +0100)]
[Ada] Proof of System.Val_Util utilities for 'Value support

gcc/ada/

* libgnat/s-valboo.adb (First_Non_Space_Ghost): Move to
utilities.
(Value_Boolean): Prefix call to First_Non_Space_Ghost.
* libgnat/s-valboo.ads (First_Non_Space_Ghost): Move to
utilities.
(Is_Boolean_Image_Ghost, Value_Boolean): Prefix call to
First_Non_Space_Ghost.
* libgnat/s-valuer.adb (Scan_Raw_Real): Adapt to change of
function Scan_Exponent to procedure.
* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Adapt to change of
function Scan_Exponent to procedure.
* libgnat/s-valuti.adb (First_Non_Space_Ghost): Function moved
here.
(Last_Number_Ghost): New ghost query function.
(Scan_Exponent): Change function with side-effects into
procedure, to mark in SPARK. Prove procedure wrt contract.
Change type of local P to avoid possible range check failure (it
is not known whether this can be activated by callers).
(Scan_Plus_Sign, Scan_Sign): Change type of local P to avoid
possible range check failure. Add loop invariants and assertions
for proof.
(Scan_Trailing_Blanks): Add loop invariant.
(Scan_Underscore): Remove SPARK_Mode Off.
* libgnat/s-valuti.ads (First_Non_Space_Ghost): Function moved
here.
(Last_Number_Ghost, Only_Number_Ghost, Is_Natural_Format_Ghost,
Scan_Natural_Ghost): New ghost query functions.
(Scan_Plus_Sign, Scan_Sign, Scan_Exponent, Scan_Trailing_Blanks,
Scan_Underscore): Add functional contracts.

2 years ago[Ada] Proof of Boolean'Image and Boolean'Value
Yannick Moy [Thu, 18 Nov 2021 08:10:02 +0000 (09:10 +0100)]
[Ada] Proof of Boolean'Image and Boolean'Value

gcc/ada/

* libgnat/s-imgboo.adb: Mark in SPARK.
* libgnat/s-imgboo.ads: Mark in SPARK. Change from Pure to
Preelaborate unit in order to be able to depend on
System.Val_Bool.
(Image_Boolean): Functionally specify the result of the
procedure by calling System.Val_Bool.Value_Boolean on the
result.
* libgnat/s-valboo.adb: Mark in SPARK.
(First_Non_Space_Ghost): New ghost function.
(Value_Boolean): Change type of L and F to avoid possible range
check failure on empty Str.
* libgnat/s-valboo.ads: Mark in SPARK. Duplicate with-clause
from body in the spec to be able to call
System.Val_Util.Only_Space_Ghost in the contract.
(First_Non_Space_Ghost): New ghost function computing the first
non-space character in a string.
(Is_Boolean_Image_Ghost): New ghost function computing whether a
string is the image of a boolean value.
(Value_Boolean): Add in precondition the conditions to avoid
raising Constraint_Error. This precondition is never executed,
and only used in proof, thanks to the use of pragma
Assertion_Policy. Given that precondition, the postcondition can
simply check the first non-space character to decide whether
True or False is read.
* libgnat/s-valuti.adb: Mark in SPARK, but use SPARK_Mode Off on
all subprograms not yet proved.
(Bad_Value): Annotate expected exception.
(Normalize_String): Rewrite to avoid possible overflow when
incrementing F in the first loop. Add loop invariants.
* libgnat/s-valuti.ads: Mark in SPARK.
(Bad_Value): Add Depends contract to avoid warning on unused S.
(Only_Space_Ghost): New ghost function to query if string has
only space in the specified range.
(Normalize_String): Add functional contract.
(Scan_Exponent): Mark spec as not in SPARK as this function has
side-effects.

2 years ago[Ada] Fix possible memory corruption for hostnames longer than 1024 bytes
Pascal Obry [Wed, 17 Nov 2021 16:20:32 +0000 (17:20 +0100)]
[Ada] Fix possible memory corruption for hostnames longer than 1024 bytes

gcc/ada/

* libgnat/g-socket.ads (Max_Name_Length): Initialize with
NI_MAXHOST.

2 years ago[Ada] Minor style fix (no dot on single line comment)
Pascal Obry [Wed, 17 Nov 2021 16:20:11 +0000 (17:20 +0100)]
[Ada] Minor style fix (no dot on single line comment)

gcc/ada/

* libgnat/g-socket.ads: Minor style fix.

2 years ago[PR103437] Use long long multiplication as backup for overflow processing
Vladimir N. Makarov [Thu, 2 Dec 2021 15:55:59 +0000 (10:55 -0500)]
[PR103437] Use long long multiplication as backup for overflow processing

__builtin_smul_overflow can be unavailable for some C++ compilers.
Add long long multiplication as backup for overflow processing.

gcc/ChangeLog:
PR rtl-optimization/103437
* ira-color.c (setup_allocno_priorities): Use long long
multiplication as backup for overflow processing.

2 years agolibphobos: Push all callee-save registers on the stack before GC scan on ARM
Iain Buclaw [Thu, 2 Dec 2021 00:53:51 +0000 (01:53 +0100)]
libphobos: Push all callee-save registers on the stack before GC scan on ARM

This is the library fix for PR103520 that also prevents the garbage
collector from releasing live memory.  However this requires that the
host compiler has been patched with this fix, so the GC will remain
disabled in the D front-end for now until enough time has passed for
this to have trickled down into enough releases.

libphobos/ChangeLog:

* libdruntime/core/thread/osthread.d (callWithStackShell): Push all
callee-save registers on the stack for AArch64 and ARM.

2 years agoAArch64: Optimize right shift rounding narrowing
Tamar Christina [Thu, 2 Dec 2021 14:39:22 +0000 (14:39 +0000)]
AArch64: Optimize right shift rounding narrowing

This optimizes right shift rounding narrow instructions to
rounding add narrow high where one vector is 0 when the shift amount is half
that of the original input type.

i.e.

uint32x4_t foo (uint64x2_t a, uint64x2_t b)
{
  return vrshrn_high_n_u64 (vrshrn_n_u64 (a, 32), b, 32);
}

now generates:

foo:
        movi    v3.4s, 0
        raddhn  v0.2s, v2.2d, v3.2d
        raddhn2 v0.4s, v2.2d, v3.2d

instead of:

foo:
        rshrn   v0.2s, v0.2d, 32
        rshrn2  v0.4s, v1.2d, 32
        ret

On Arm cores this is an improvement in both latency and throughput.
Because a vector zero is needed I created a new method
aarch64_gen_shareable_zero that creates zeros using V4SI and then takes a subreg
of the zero to the desired type.  This allows CSE to share all the zero
constants.

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h (aarch64_gen_shareable_zero): New.
* config/aarch64/aarch64-simd.md (aarch64_rshrn<mode>,
aarch64_rshrn2<mode>): Generate rounding half-ing add when appropriate.
* config/aarch64/aarch64.c (aarch64_gen_shareable_zero): New.

gcc/testsuite/ChangeLog:

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

2 years ago[PR103437] Process multiplication overflow in priority calculation for allocno assign...
Vladimir N. Makarov [Thu, 2 Dec 2021 13:29:45 +0000 (08:29 -0500)]
[PR103437] Process multiplication overflow in priority calculation for allocno assignments

We process overflows in cost calculations but for huge functions
priority calculation can overflow as priority can be bigger the cost
used for it.  The patch fixes the problem.

gcc/ChangeLog:

PR rtl-optimization/103437
* ira-color.c (setup_allocno_priorities): Process multiplication
overflow.

2 years agotestsuite: make bic-bitmask-18.c test more precise [PR103479]
Tamar Christina [Thu, 2 Dec 2021 13:30:08 +0000 (13:30 +0000)]
testsuite: make bic-bitmask-18.c test more precise [PR103479]

This updates the testcase bic-bitmask-18.c to seach for " = 0;" as an expression
so it doesn't match any other partial expressions.

gcc/testsuite/ChangeLog:

PR testsuite/103479
* gcc.dg/bic-bitmask-18.c: Update regexpr to expect = 0;.

2 years agoc++: Fix bogus error with __integer_pack [PR94490]
Marek Polacek [Sat, 6 Nov 2021 22:10:39 +0000 (18:10 -0400)]
c++: Fix bogus error with __integer_pack [PR94490]

Here we issue a bogus:

error: '(0 ? fake_tuple_size_v<int> : fake_tuple_size_v<int>)' is not a constant expression

because cxx_constant_value in expand_integer_pack gets

*(0 ? VIEW_CONVERT_EXPR<const int>(fake_tuple_size_v) : VIEW_CONVERT_EXPR<const int>(fake_tuple_size_v))

which is a REFERENCE_REF_P and we evaluate its operand to 3, so we end
up with *3 and that fails.  Sounds like we need to get rid of the
REFERENCE_REF_P then.  That is what tsubst_copy_and_build/INDIRECT_REF
will do:

        if (REFERENCE_REF_P (t))
          {
            /* A type conversion to reference type will be enclosed in
               such an indirect ref, but the substitution of the cast
               will have also added such an indirect ref.  */
            r = convert_from_reference (r);
          }

so I think it's reasonable to call instantiate_non_dependent_expr_sfinae.

PR c++/94490

gcc/cp/ChangeLog:

* pt.c (expand_integer_pack): Call
instantiate_non_dependent_expr_sfinae.

gcc/testsuite/ChangeLog:

* g++.dg/ext/integer-pack5.C: New test.

2 years agoImplement -fprofile-prefix-map.
Martin Liska [Thu, 11 Nov 2021 15:42:23 +0000 (16:42 +0100)]
Implement -fprofile-prefix-map.

PR gcov-profile/96092

gcc/ChangeLog:

* common.opt: New option.
* coverage.c (coverage_begin_function): Emit filename with
remap_profile_filename.
* doc/invoke.texi: Document the new option.
* file-prefix-map.c (add_profile_prefix_map): New.
(remap_profile_filename): Likewise.
* file-prefix-map.h (add_profile_prefix_map): Likewise.
(remap_profile_filename): Likewise.
* lto-opts.c (lto_write_options): Handle
OPT_fprofile_prefix_map_.
* opts-global.c (handle_common_deferred_options): Likewise.
* opts.c (common_handle_option): Likewise.
(gen_command_line_string): Likewise.
* profile.c (output_location): Emit filename with
remap_profile_filename.

2 years agoc++: ICE with unnamed tparm and concept [PR103408]
Marek Polacek [Tue, 30 Nov 2021 21:43:19 +0000 (16:43 -0500)]
c++: ICE with unnamed tparm and concept [PR103408]

Here we crash when issuing the "constraint C has type T, not bool"
error, because pp_cxx_parameter_mapping wasn't prepared to see an
anonymous template parameter.  With this patch we print

error: constraint 'auto(<lambda>) [with <unnamed> = 0]' has type '<lambda()>', not 'bool'

The "<unnamed>" is what this patch adds.

PR c++/103408

gcc/cp/ChangeLog:

* cxx-pretty-print.c (pp_cxx_parameter_mapping): Print "<unnamed>"
rather than crash on an unnamed template parameter.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/concepts-err1.C: New test.

2 years agomiddle-end/103271 - avoid VLA init of register
Richard Biener [Thu, 2 Dec 2021 11:23:22 +0000 (12:23 +0100)]
middle-end/103271 - avoid VLA init of register

This avoids using VLA types to initalize a register with
-ftrivial-auto-var-init in some cases.

2021-12-02  Richard Biener  <rguenther@suse.de>

PR middle-end/103271
* internal-fn.c (expand_DEFERRED_INIT): When the base
of the LHS is a decl with matching constant size use
that as the initialization target instead of an
eventual VLA typed one.

2 years agotree-optimization/103527 - always use thruth type forgather mask
Richard Biener [Thu, 2 Dec 2021 11:21:19 +0000 (12:21 +0100)]
tree-optimization/103527 - always use thruth type forgather mask

This makes sure to always use a truth type to build the gather
mask argument even when the target builtin prototype in the end
wants a float vector.

2021-12-02  Richard Biener  <rguenther@suse.de>

PR tree-optimization/103527
* tree-vect-stmts.c (vect_build_gather_load_calls): Always
use a truth type for building the vector mask.

2 years agofix spelling of -linker-output-auto-nolto-rel
Rasmus Villemoes [Wed, 1 Dec 2021 10:53:45 +0000 (11:53 +0100)]
fix spelling of -linker-output-auto-nolto-rel

The transposition nolto -> notlo is confusing and it makes the long
name even harder to read than it already is - I kept reading it as
"not lo" until I realized it was a simple typo.

Fixes: 5269b24605b1 (Silence warning in LTO mode on VxWorks)

lto-plugin/
* lto-plugin.c: Fix -linker-output-auto-notlo-rel ->
-linker-output-auto-nolto-rel typo.
(process_option): Adjust accordingly, accepting both old and
new spelling.

gcc/
* config/vxworks.h (LTO_PLUGIN_SPEC): Adapt to corrected
spelling of -linker-output-auto-nolto-rel.

2 years agofortran: OpenMP/OpenACC array mapping alignment fix (PR90030)
Chung-Lin Tang [Thu, 2 Dec 2021 10:24:03 +0000 (18:24 +0800)]
fortran: OpenMP/OpenACC array mapping alignment fix (PR90030)

Fix issue with the Fortran front-end when mapping arrays: when creating the
data MEM_REF for the map clause, there was a convention of casting the
referencing pointer to 'c_char *' by
fold_convert (build_pointer_type (char_type_node), ptr).

This causes the alignment passed to the libgomp runtime for array data
hardwared to '1', and causes alignment errors on the offload target.

This patch fixes this by removing the char_type_node pointer converts, and
adding gcc_asserts to ensure POINTER_TYPE_P (TREE_TYPE (ptr)).

PR fortran/90030

gcc/fortran/ChangeLog:

* trans-openmp.c (gfc_omp_finish_clause): Remove fold_convert to pointer
to char_type_node, add gcc_assert of POINTER_TYPE_P.
(gfc_trans_omp_array_section): Likewise.
(gfc_trans_omp_clauses): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/finalize-1.f: Adjust scan test.
* gfortran.dg/gomp/affinity-clause-1.f90: Likewise.
* gfortran.dg/gomp/affinity-clause-5.f90: Likewise.
* gfortran.dg/gomp/defaultmap-4.f90: Likewise.
* gfortran.dg/gomp/defaultmap-5.f90: Likewise.
* gfortran.dg/gomp/defaultmap-6.f90: Likewise.
* gfortran.dg/gomp/map-3.f90: Likewise.
* gfortran.dg/gomp/pr78260-2.f90: Likewise.
* gfortran.dg/gomp/pr78260-3.f90: Likewise.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-fortran/pr90030.f90: New test.
* testsuite/libgomp.fortran/pr90030.f90: New test.

2 years agolibphobos: Add missing ControlState variable for AArch64
Iain Buclaw [Thu, 2 Dec 2021 00:42:07 +0000 (01:42 +0100)]
libphobos: Add missing ControlState variable for AArch64

Fixes a typo that occurred during the splitting of the std.math module
into a package.

libphobos/ChangeLog:

* src/std/math/hardware.d (FloatingPointControl.getControlState): Add
missing ControlState variable for AArch64.

2 years agod: Disable the D runtime garbage collector after initializing (PR103520)
Iain Buclaw [Wed, 1 Dec 2021 22:56:28 +0000 (23:56 +0100)]
d: Disable the D runtime garbage collector after initializing (PR103520)

Not all targets that support building libdruntime have a stable garbage
collector, so to avoid running into problems where live memory allocated
by the D GC is freed, disable all in-flight collections until a time
when scanning is more reliably implemented everywhere.

PR d/103520

gcc/d/ChangeLog:

* d-frontend.h (gc_disable): Declare.
* d-lang.cc (d_init_options): Disable the D runtime garbage collector
after initializing.

2 years agod: Prefix object files from the root package with 'root-'
Iain Buclaw [Wed, 1 Dec 2021 22:50:01 +0000 (23:50 +0100)]
d: Prefix object files from the root package with 'root-'

None of the front-end module names in either the dmd or root package
collide just yet, but that does not mean they won't in the future.

gcc/d/ChangeLog:

* Make-lang.in (D_FRONTEND_OBJS): Prefix object files from the root
package with root-.
(d/root-%.o): New recipe.

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

2 years agoanalyzer: fix false leak seen in Juliet 1.3 [PR102471]
David Malcolm [Wed, 1 Dec 2021 19:12:33 +0000 (14:12 -0500)]
analyzer: fix false leak seen in Juliet 1.3 [PR102471]

Juliet 1.3's CWE415_Double_Free__malloc_free_*_67a.c
were showing leak false positives in non-LTO builds; fixed thusly.

gcc/analyzer/ChangeLog:
PR analyzer/102471
* region-model-reachability.cc (reachable_regions::handle_parm):
Treat all svalues within a compound parm has reachable, and those
wrapped in a cast.

gcc/testsuite/ChangeLog:
PR analyzer/102471
* gcc.dg/analyzer/leak-3.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoi386: Improve V8HI and V8HF inserts [PR102811]
Uros Bizjak [Wed, 1 Dec 2021 22:01:09 +0000 (23:01 +0100)]
i386: Improve V8HI and V8HF inserts [PR102811]

Introduce vec_set_0 pattern for V8HI and V8HF modes to implement scalar
element 0 inserts to from a GP register, SSE register or memory.  Also
add V8HI and V8HF AVX2 (x,x,x) alternative to PINSR insn pattern, which is
split after reload to a sequence of PBROADCASTW and PBLENDW.

The V8HF inserts from memory improve from:

-       vpbroadcastw    4(%esp), %xmm1
-       vpblendw        $16, %xmm1, %xmm0, %xmm0
+       vpinsrw $4, 4(%esp), %xmm0, %xmm0

and V8HF inserts from SSE register to element 0 improve from:

        vpxor   %xmm2, %xmm2, %xmm2
-       vpbroadcastw    %xmm0, %xmm0
        vpblendw        $1, %xmm0, %xmm2, %xmm0

Based on the above improvements, the register allocator is able to determine
the optimal instruction (or instruction sequence) based on the register set
of the input value, so there is no need to manually expand V8HI and V8HF
inserts to the sequence of VEC_DUPLICATE and VEC_MERGE RTXes.

2021-12-01  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/102811
* config/i386/sse.md (VI2F): Remove mode iterator.
(VI2F_256_512): New mode iterator.
(vec_set<V8_128:mode>_0): New insn pattern.
(vec_set<VI2F_256_512:mode>_0>): Rename from vec_set<VI2F:mode>mode.
Use VI2F_256_512 mode iterator instead of VI2F.
(*axv512fp16_movsh): Remove.
(<sse2p4_1>_pinsr<ssemodesuffix>): Add (x,x,x) AVX2 alternative.
Do not disable V8HF mode insn on AVX2 targets.
(pinsrw -> pbroadcast + pblendw peephole2): New peephole.
(pinsrw -> pbroadcast + pblendw splitter): New post-reload splitter.
* config/i386/i386.md (extendhfsf): Call gen_vec_setv8hf_0.
* config/i386/i386-expand.c (ix86_expand_vector_set)
<case E_V8HFmode>: Use vec_merge path for TARGET_AVX2.

gcc/testsuite/ChangeLog:

PR target/102881
* gcc.target/i386/pr102811-1.c: New test.
* gcc.target/i386/avx512fp16-1c.c (dg-final): Update
scan-assembler-times scan strings for ia32 targets.
* gcc.target/i386/pr102327-1.c (dg-final): Ditto.
* gcc.target/i386/pr102811.c: Rename from ...
* gcc.target/i386/avx512vl-vcvtps2ph-pr102811.c: ... this.

2 years agoFinal value replacement improvements for until-wrap loops.
Roger Sayle [Wed, 1 Dec 2021 19:58:40 +0000 (19:58 +0000)]
Final value replacement improvements for until-wrap loops.

This middle-end patch is inspired by the Richard Beiner's until-wrap
loop example in PR tree-optimization/101145.

unsigned foo(unsigned val, unsigned start)
{
  unsigned cnt = 0;
  for (unsigned i = start; i > val; ++i)
    cnt++;
  return cnt;
}

For this loop, the tree optimizers currently generate:

unsigned int foo (unsigned int val, unsigned int start)
{
  unsigned int cnt;
  unsigned int _1;
  unsigned int _5;

  <bb 2> [local count: 118111600]:
  if (start_3(D) > val_4(D))
    goto <bb 3>; [89.00%]
  else
    goto <bb 4>; [11.00%]

  <bb 3> [local count: 105119324]:
  _1 = start_3(D) + 1;
  _5 = -start_3(D);
  cnt_2 = _1 > val_4(D) ? _5 : 1;

  <bb 4> [local count: 118111600]:
  # cnt_11 = PHI <cnt_2(3), 0(2)>
  return cnt_11;
}

or perhaps slightly easier to read:

  if (start > val) {
    cnt = (start+1) > val ? -start : 1;
  } else cnt = 0;

In this snippet, if we know start > val, then (start+1) > val
unless start+1 overflows, i.e. (start+1) == 0 and start == ~0.
We can use this (loop header) context to simplify the ternary
expression to "(start != -1) ? -start : 1", which with a little
help from match.pd can be folded to -start.  Hence the optimal
final value replacement should be:

  cnt = (start > val) ? -start : 0;

Or as now generated by this patch:

unsigned int foo (unsigned int val, unsigned int start)
{
  unsigned int cnt;

  <bb 2> [local count: 118111600]:
  if (start_3(D) > val_4(D))
    goto <bb 3>; [89.00%]
  else
    goto <bb 4>; [11.00%]

  <bb 3> [local count: 105119324]:
  cnt_2 = -start_3(D);

  <bb 4> [local count: 118111600]:
  # cnt_11 = PHI <cnt_2(3), 0(2)>
  return cnt_11;
}

We can also improve until-wrap loops that don't have a (suitable) loop
header, as determined by simplify_using_initial_conditions.

unsigned bar(unsigned val, unsigned start)
{
  unsigned cnt = 0;
  unsigned i = start;
  do {
    cnt++;
    i++;
  } while (i > val);
  return cnt;
}

which is currently optimized to:

unsigned int foo (unsigned int val, unsigned int start)
{
  unsigned int cnt;
  unsigned int _9;
  unsigned int _10;

  <bb 2> [local count: 118111600]:
  _9 = start_4(D) + 1;
  _10 = -start_4(D);
  cnt_3 = val_7(D) < _9 ? _10 : 1;
  return cnt_3;
}

Here we have "val < (start+1) ? -start : 1", which again with the
help of match.pd can be slightly simplified to "val <= start ? -start : 1"
when dealing with unsigned types, because at the complicating value where
start == ~0, we fortunately have -start == 1, hence it doesn't matter
whether the second or third operand of the ternary operator is returned.

To summarize, this patch (in addition to tweaking may_be_zero in
number_of_iterations_until_wrap) adds three new constant folding
transforms to match.pd.

X != C1 ? -X : C2 simplifies to -X when -C1 == C2.
which is the generalized form of the simplification above.

X != C1 ? ~X : C2 simplifies to ~X when ~C1 == C2.
which is the BIT_NOT_EXPR analog of the NEGATE_EXPR case.

and the "until-wrap final value replacement without context":

(X + 1) > Y ? -X : 1 simplifies to X >= Y ? -X : 1 when
X is unsigned, as when X + 1 overflows, X is -1, so -X == 1.

2021-12-01  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
* tree-ssa-loop-niter.c (number_of_iterations_until_wrap):
Check if simplify_using_initial_conditions allows us to
simplify the expression for may_be_zero.
* match.pd (X != C ? -X : -C -> -X): New transform.
(X != C ? ~X : ~C -> ~X): Likewise.
((X+1) > Y ? -X : 1 -> X >= Y ? -X : 1): Likewise.

gcc/testsuite/ChangeLog
* gcc.dg/fold-condneg-1.c: New test case.
* gcc.dg/fold-condneg-2.c: New test case.
* gcc.dg/fold-condnot-1.c: New test case.
* gcc.dg/pr101145-1.c: New test case.
* gcc.dg/pr101145-2.c: New test case.

2 years agomiddle-end: Skip initialization of opaque type variables [PR103127]
Peter Bergner [Wed, 1 Dec 2021 19:17:52 +0000 (13:17 -0600)]
middle-end: Skip initialization of opaque type variables [PR103127]

For -ftrivial-auto-var-init=*, skip initializing the variable if it is an
opaque type, because CONST0_RTX(mode) is not defined for opaque modes.

2021-12-01  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR middle-end/103127
* gimplify.c (is_var_need_auto_init): Handle opaque types.

gcc/testsuite/
PR middle-end/103127
* gcc.target/powerpc/pr103127.c: New test.

2 years agodarwin, d: Support outfile substitution for libphobos
Iain Buclaw [Fri, 19 Nov 2021 08:09:54 +0000 (09:09 +0100)]
darwin, d: Support outfile substitution for libphobos

In the gdc driver, this takes the previous fix for the Darwin D
bootstrap, and extends it to the -static-libphobos option as well.
Rather than pushing the -static-libphobos option back onto the command
line, the setting of SKIPOPT is instead conditionally removed.  The same
change has been repeated for -static-libstdc++ so there is now no need
to call generate_option to re-add it.

In the gcc driver, -static-libphobos has been added as a common option,
validated, and a new outfile substition added to config/darwin.h to
correctly replace -lgphobos with libgphobos.a.

gcc/ChangeLog:

* common.opt (static-libphobos): Add option.
* config/darwin.h (LINK_SPEC): Substitute -lgphobos with libgphobos.a
when linking statically.
* gcc.c (driver_handle_option): Set -static-libphobos as always valid.

gcc/d/ChangeLog:

* d-spec.cc (lang_specific_driver): Set SKIPOPT on -static-libstdc++
and -static-libphobos only when target supports LD_STATIC_DYNAMIC.
Remove generate_option to re-add -static-libstdc++.

libphobos/ChangeLog:

* testsuite/testsuite_flags.in: Add libphobos library directory as
search path to --gdcldflags.

2 years agoc++: constexpr, fold, weak redecl, fp/0 [PR103310]
Jason Merrill [Wed, 24 Nov 2021 10:45:02 +0000 (05:45 -0500)]
c++: constexpr, fold, weak redecl, fp/0 [PR103310]

For PR61825, honza changed tree_single_nonzero_warnv_p to prevent a later
declaration from marking a function as weak after we've determined that it
wasn't weak before.  But we shouldn't do that for speculative folding; we
should only do it when we actually need a constant value.  In C++, such a
context is called "manifestly constant-evaluated".  In fold, this seems to
correspond to the folding_initializer flag, since in C this situation only
occurs in static initializers.

This change makes nonzero-1.c well-formed; I've added a nonzero-1a.c to
verify that we delete the null check eventually if there is no weak
redeclaration.

The varasm.c change is so that if we do get the weak redeclaration error, we
get it at the position of the weak declaration rather than the previous
declaration.

Using the FOLD_INIT paths also affects floating point arithmetic: notably,
this makes floating point division by zero in a manifestly
constant-evaluated context constant, as in a C static initializer.  I've had
some success convincing CWG that this is the right direction; C++ should
follow C's floating point semantics more than we have been doing, and Joseph
says that the C policy is that Annex F overrides other parts of the standard
that say that some operations are undefined.  But since we're in stage 3,
I'm only making this change with the new flag -fconstexpr-fp-except.  It may
turn on by default in a future release.

I think this distinction is only relevant for binary operations; arithmetic
for the floating point case, comparison for possibly non-zero addresses.

PR c++/103310

gcc/ChangeLog:

* fold-const.c (maybe_nonzero_address): Use get_create or get
depending on folding_initializer.
(fold_binary_initializer_loc): New.
* fold-const.h (fold_binary_initializer_loc): Declare.
* varasm.c (mark_weak): Don't use the decl location.
* doc/invoke.texi: Document -fconstexpr-fp-except.

gcc/c-family/ChangeLog:

* c.opt: Add -fconstexpr-fp-except.

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_binary_expression): Use
fold_binary_initializer_loc if manifestly cxeval.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-fp-except1.C: New test.
* g++.dg/cpp1z/constexpr-if36.C: New test.
* gcc.dg/tree-ssa/nonzero-1.c: Now well-formed.
* gcc.dg/tree-ssa/nonzero-1a.c: New test.