]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
6 months agoAVR: Provide built-ins for strlen where the string lives in some AS.
Georg-Johann Lay [Thu, 30 Jan 2025 11:16:50 +0000 (12:16 +0100)] 
AVR: Provide built-ins for strlen where the string lives in some AS.

This patch adds built-in functions __builtin_avr_strlen_flash,
__builtin_avr_strlen_flashx and __builtin_avr_strlen_memx.
Purpose is that higher-level functions can use __builtin_constant_p
on strlen without raising a diagnostic due to -Waddr-space-convert.

gcc/
* config/avr/builtins.def (STRLEN_FLASH, STRLEN_FLASHX)
(STRLEN_MEMX): New DEF_BUILTIN's.
* config/avr/avr.cc (avr_ftype_strlen): New static function.
(avr_builtin_supported_p): New built-ins are not for AVR_TINY.
(avr_init_builtins) <strlen_flash_node, strlen_flashx_node,
strlen_memx_node>: Provide new fntypes.
(avr_fold_builtin) [AVR_BUILTIN_STRLEN_FLASH]
[AVR_BUILTIN_STRLEN_FLASHX, AVR_BUILTIN_STRLEN_MEMX]: Fold if
possible.
* doc/extend.texi (AVR Built-in Functions): Document
__builtin_avr_strlen_flash, __builtin_avr_strlen_flashx,
__builtin_avr_strlen_memx.
libgcc/
* config/avr/t-avr (LIB1ASMFUNCS): Add _strlen_memx.
* config/avr/lib1funcs.S <L_strlen_memx, __strlen_memx>: Implement.

6 months agoAVR: Only provide a built-in when it is available.
Georg-Johann Lay [Thu, 30 Jan 2025 11:05:19 +0000 (12:05 +0100)] 
AVR: Only provide a built-in when it is available.

Some built-ins are not available for C++ since they are using
named address-spaces or fixed-point types.

gcc/
* config/avr/builtins.def (AVR_FIRST_C_ONLY_BUILTIN_ID): New macro.
* config/avr/avr-protos.h (avr_builtin_supported_p): New.
* config/avr/avr.cc (avr_builtin_supported_p): New function.
(avr_init_builtins): Only provide a built-in when it is supported.
* config/avr/avr-c.cc (avr_cpu_cpp_builtins): Only define the
__BUILTIN_AVR_<NAME> build-in defines when the associated built-in
function is supported.
* doc/extend.texi (AVR Built-in Functions): Add a note that
following built-ins are supported for only for GNU-C.

6 months agoOpenMP: Update documentation of metadirective implementation status.
Sandra Loosemore [Thu, 30 Jan 2025 16:45:27 +0000 (16:45 +0000)] 
OpenMP: Update documentation of metadirective implementation status.

libgomp/ChangeLog
* libgomp.texi (OpenMP 5.0): Mark metadirective and declare variant
as implemented.
(OpenMP 5.1): Mark target_device as supported.
Add changed interaction between declare target and OpenMP context
and dynamic selector support.
(OpenMP 5.2): Mark otherwise clause as supported, note that
default is also still accepted.

6 months agoOpenMP: Fortran support for metadirectives and dynamic selectors
Sandra Loosemore [Thu, 30 Jan 2025 17:03:06 +0000 (17:03 +0000)] 
OpenMP: Fortran support for metadirectives and dynamic selectors

gcc/fortran/ChangeLog
PR middle-end/112779
PR middle-end/113904
* decl.cc (gfc_match_end): Handle COMP_OMP_BEGIN_METADIRECTIVE and
COMP_OMP_METADIRECTIVE.
* dump-parse-tree.cc (show_omp_node): Handle EXEC_OMP_METADIRECTIVE.
(show_code_node): Likewise.
* gfortran.h (enum gfc_statement): Add ST_OMP_METADIRECTIVE,
ST_OMP_BEGIN_METADIRECTIVE, and ST_OMP_END_METADIRECTIVE.
(struct gfc_omp_clauses): Rename target_first_st_is_teams to
target_first_st_is_teams_or_meta.
(struct gfc_omp_variant): New.
(gfc_get_omp_variant): New.
(struct gfc_st_label): Add omp_region field.
(enum gfc_exec_op): Add EXEC_OMP_METADIRECTIVE.
(struct gfc_code): Add omp_variants fields.
(gfc_free_omp_variants): Declare.
(match_omp_directive): Declare.
(is_omp_declarative_stmt): Declare.
* io.cc (format_asterisk): Adjust initializer.
* match.h (gfc_match_omp_begin_metadirective): Declare.
(gfc_match_omp_metadirective): Declare.
* openmp.cc (gfc_omp_directives): Uncomment metadirective.
(gfc_match_omp_eos): Adjust to match context selectors.
(gfc_free_omp_variants): New.
(gfc_match_omp_clauses): Remove context_selector parameter and adjust
to use gfc_match_omp_eos instead.
(match_omp): Adjust call to gfc_match_omp_clauses.
(gfc_match_omp_context_selector): Add metadirective_p parameter and
adjust error-checking.  Adjust matching of simd clauses.
(gfc_match_omp_context_selector_specification): Adjust parameters
so it can be used for metadirective as well as declare variant.
(match_omp_metadirective): New.
(gfc_match_omp_begin_metadirective): New.
(gfc_match_omp_metadirective): New.
(resolve_omp_metadirective): New.
(resolve_omp_target): Handle metadirectives.
(gfc_resolve_omp_directive): Handle EXEC_OMP_METADIRECTIVE.
* parse.cc (gfc_matching_omp_context_selector): New.
(gfc_in_omp_metadirective_body): New.
(gfc_omp_region_count): New.
(decode_omp_directive): Handle ST_OMP_BEGIN_METADIRECTIVE and
ST_OMP_METADIRECTIVE.
(match_omp_directive): New.
(case_omp_structured_block): Define.
(case_omp_do): Define.
(gfc_ascii_statement): Handle ST_OMP_BEGIN_METADIRECTIVE,
ST_OMP_END_METADIRECTIVE, and ST_OMP_METADIRECTIVE.
(accept_statement):  Handle ST_OMP_METADIRECTIVE and
ST_OMP_BEGIN_METADIRECTIVE.
(gfc_omp_end_stmt): New, split from...
(parse_omp_do): ...here, and...
(parse_omp_structured_block): ...here.  Handle metadirectives,
plus "allocate", "atomic", and "dispatch" which were missing.
(parse_omp_oacc_atomic): Handle "end metadirective".
(parse_openmp_allocate_block): Likewise.
(parse_omp_dispatch): Likewise.
(parse_omp_metadirective_body): New.
(parse_executable): Handle metadirective.  Use new case macros
defined above.
(gfc_parse_file): Initialize metadirective state.
(is_omp_declarative_stmt): New.
* parse.h (enum gfc_compile_state): Add COMP_OMP_METADIRECTIVE
and COMP_OMP_BEGIN_METADIRECTIVE.
(gfc_omp_end_stmt): Declare.
(gfc_matching_omp_context_selector): Declare.
(gfc_in_omp_metadirective_body): Declare.
(gfc_omp_metadirective_region_count): Declare.
* resolve.cc (gfc_resolve_code): Handle EXEC_OMP_METADIRECTIVE.
* st.cc (gfc_free_statement): Likewise.
* symbol.cc (compare_st_labels): Handle labels within a metadirective
body.
(gfc_get_st_label): Likewise.
* trans-decl.cc (gfc_get_label_decl): Encode the metadirective region
in the label_name.
* trans-openmp.cc (gfc_trans_omp_directive): Handle
EXEC_OMP_METADIRECTIVE.
(gfc_trans_omp_set_selector): New, split/adapted from code....
(gfc_trans_omp_declare_variant): ...here.
(gfc_trans_omp_metadirective): New.
* trans-stmt.h  (gfc_trans_omp_metadirective): Declare.
* trans.cc (trans_code): Handle EXEC_OMP_METADIRECTIVE.

gcc/testsuite/ChangeLog
PR middle-end/112779
PR middle-end/113904
* gfortran.dg/gomp/metadirective-1.f90: New.
* gfortran.dg/gomp/metadirective-10.f90: New.
* gfortran.dg/gomp/metadirective-11.f90: New.
* gfortran.dg/gomp/metadirective-12.f90: New.
* gfortran.dg/gomp/metadirective-13.f90: New.
* gfortran.dg/gomp/metadirective-2.f90: New.
* gfortran.dg/gomp/metadirective-3.f90: New.
* gfortran.dg/gomp/metadirective-4.f90: New.
* gfortran.dg/gomp/metadirective-5.f90: New.
* gfortran.dg/gomp/metadirective-6.f90: New.
* gfortran.dg/gomp/metadirective-7.f90: New.
* gfortran.dg/gomp/metadirective-8.f90: New.
* gfortran.dg/gomp/metadirective-9.f90: New.
* gfortran.dg/gomp/metadirective-construct.f90: New.
* gfortran.dg/gomp/metadirective-no-score.f90: New.
* gfortran.dg/gomp/pure-1.f90 (func_metadirective): New.
(func_metadirective_2): New.
(func_metadirective_3): New.
* gfortran.dg/gomp/pure-2.f90 (func_metadirective): Delete.

libgomp/ChangeLog
PR middle-end/112779
PR middle-end/113904
* testsuite/libgomp.fortran/metadirective-1.f90: New.
* testsuite/libgomp.fortran/metadirective-2.f90: New.
* testsuite/libgomp.fortran/metadirective-3.f90: New.
* testsuite/libgomp.fortran/metadirective-4.f90: New.
* testsuite/libgomp.fortran/metadirective-5.f90: New.
* testsuite/libgomp.fortran/metadirective-6.f90: New.

Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com>
Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>
Co-Authored-By: Tobias Burnus <tobias@codesourcery.com>
Co-Authored-By: Paul-Antoine Arras <pa@codesourcery.com>
6 months agos390: Fix up *vec_cmpgt{,u}<mode><mode>_nocc_emu splitters [PR118696]
Jakub Jelinek [Thu, 30 Jan 2025 17:30:10 +0000 (18:30 +0100)] 
s390: Fix up *vec_cmpgt{,u}<mode><mode>_nocc_emu splitters [PR118696]

The following testcase is miscompiled on s390x-linux with e.g. -march=z13
(both -O0 and -O2) starting with r15-7053.
The problem is in the splitters which emulate TImode/V1TImode GT and GTU
comparisons.
For GT we want to do
(ior (gt (hi op1) (hi op2))
     (and (eq (hi op1) (hi op2)) (gtu (lo op1) (lo op2))))
and for GTU similarly except for gtu instead of gt in there.
Now, the splitter emulation is using V2DImode comparisons where on s390x
the hi part is in the first element of the vector, lo part in the second,
and for the gtu case it swaps the elements of the vector.
So, we get the right result in the first element of the result vector.
But vrepg was then broadcasting the second element of the result vector
rather than the first, and the value of the second element of the vector
is instead
(ior (gt (lo op1) (lo op2))
     (and (eq (lo op1) (lo op2)) (gtu (hi op1) (hi op2))))
so something not really usable for the emulated comparison.

The following patch fixes that.  The testcase tries to test behavior of
double-word smin/smax/umin/umax with various cases of the halves of both
operands (one that is sometimes EQ, sometimes GT, sometimes LT, sometimes
GTU, sometimes LTU).

2025-01-30  Jakub Jelinek  <jakub@redhat.com>
    Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>

PR target/118696
* config/s390/vector.md (*vec_cmpgt<mode><mode>_nocc_emu,
*vec_cmpgtu<mode><mode>_nocc_emu): Duplicate the first rather than
second V2DImode element.

* gcc.dg/pr118696.c: New test.
* gcc.target/s390/vector/pr118696.c: New test.
* gcc.target/s390/vector/vec-abs-emu.c: Expect vrepg with 0 as last
operand rather than 1.
* gcc.target/s390/vector/vec-max-emu.c: Likewise.
* gcc.target/s390/vector/vec-min-emu.c: Likewise.

6 months agoc++: remove LAMBDA_EXPR_CAPTURES_THIS_P
Patrick Palka [Thu, 30 Jan 2025 15:30:56 +0000 (10:30 -0500)] 
c++: remove LAMBDA_EXPR_CAPTURES_THIS_P

This unused accessor is just a simple alias of LAMBDA_EXPR_THIS_CAPTURE
and contrary to its documentation doesn't use TREE_LANG_FLAG_0.  Might
as well remove it.

gcc/cp/ChangeLog:

* cp-tree.h (LAMBDA_EXPR_CAPTURES_THIS_P): Remove.

Reviewed-by: Jason Merrill <jason@redhat.com>
6 months agoc++: Update const_decl handling after r15-7259 [PR118673].
Iain Sandoe [Wed, 29 Jan 2025 11:59:14 +0000 (11:59 +0000)] 
c++: Update const_decl handling after r15-7259 [PR118673].

Objective-C++ uses CONST_DECLs to hold constant string objects
these should also be treated as mergable lvalues.

PR c++/118673

gcc/cp/ChangeLog:

* tree.cc (lvalue_kind): Mark CONST_DECLs as mergable
when they are also TREE_STATIC.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
6 months agomiddle-end/118695 - missed misalign handling in MEM_REF expansion
Richard Biener [Thu, 30 Jan 2025 10:22:37 +0000 (11:22 +0100)] 
middle-end/118695 - missed misalign handling in MEM_REF expansion

When MEM_REF expansion of a non-MEM falls back to a stack temporary
we fail to handle the case where the offset adjusted reference to
the temporary is not aligned according to the requirement of the
mode.  We have to go through bitfield extraction or movmisalign
in this case.  Fortunately there's a helper for this.

This fixes an ICE observed on arm which has sanity checks in its
move patterns for this.

PR middle-end/118695
* expr.cc (expand_expr_real_1): When expanding a MEM_REF
to a non-MEM by committing it to a stack temporary make
sure to handle misaligned accesses correctly.

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

6 months agolibstdc++: Use safe integer comparisons in std::latch [PR98749]
Jonathan Wakely [Thu, 9 Jan 2025 21:50:31 +0000 (21:50 +0000)] 
libstdc++: Use safe integer comparisons in std::latch [PR98749]

The std::latch::max() function assumes that the returned value can be
represented by ptrdiff_t, which is true when __platform_wait_t is int
(e.g. on Linux) but not when it's unsigned long, which is the case for
most other 64-bit targets. We should use the smaller of PTRDIFF_MAX and
std::numeric_limits<__platform_wait_t>::max(). Use std::cmp_less to do a
safe comparison that works for all types. We can also use std::cmp_less
and std::cmp_equal in std::latch::count_down so that we don't need to
deal with comparisons between signed and unsigned.

Also add a missing precondition check to constructor and fix the
existing check in count_down which was duplicated by mistake.

libstdc++-v3/ChangeLog:

PR libstdc++/98749
* include/std/latch (latch::max()): Ensure the return value is
representable as the return type.
(latch::latch(ptrdiff_t)): Add assertion.
(latch::count_down): Fix copy & pasted duplicate assertion. Use
std::cmp_equal to compare __platform_wait_t and ptrdiff_t
values.
(latch::_M_a): Use defined constant for alignment.
* testsuite/30_threads/latch/1.cc: Check max(). Check constant
initialization works for values in the valid range. Check
alignment.

6 months agoOpenMP: append_args clause fixes + Fortran support
Tobias Burnus [Thu, 30 Jan 2025 10:28:50 +0000 (11:28 +0100)] 
OpenMP: append_args clause fixes + Fortran support

This fixes a large number of smaller and larger issues with the append_args
clause to 'declare variant' and adds Fortran support for it; it also contains
a larger number of testcases.

In particular, for Fortran, it also handles passing allocatable, pointer,
optional arguments to an interop dummy argument with or without value
attribute.  And it changes the internal representation such that dumping the
tree does not lead to an ICE.

gcc/c/ChangeLog:

* c-parser.cc (c_finish_omp_declare_variant): Modify how
append_args is saved internally.

gcc/cp/ChangeLog:

* parser.cc (cp_finish_omp_declare_variant): Modify how append_args
is saved internally.
* pt.cc (tsubst_attribute): Likewise.
(tsubst_omp_clauses): Remove C_ORT_OMP_DECLARE_SIMD from interop
handling as no longer called for it.
* decl.cc (omp_declare_variant_finalize_one): Update append_args
changes; fixes for ADL input.

gcc/fortran/ChangeLog:

* gfortran.h (gfc_omp_declare_variant): Add append_args_list.
* openmp.cc (gfc_parser_omp_clause_init_modifiers): New;
splitt of from ...
(gfc_match_omp_init): ... here; call it.
(gfc_match_omp_declare_variant): Update to handle append_args
clause; some syntax handling fixes.
* trans-openmp.cc (gfc_trans_omp_declare_variant): Handle
append_args clause; add some diagnostic.

gcc/ChangeLog:

* gimplify.cc (gimplify_call_expr): For OpenMP's append_args clause
processed by 'omp dispatch', update for internal-representation
changes; fix handling of hidden arguments, add some comments and
handle Fortran's value dummy and optional/pointer/allocatable actual
args.

libgomp/ChangeLog:

* libgomp.texi (Impl. Status): Update for accumpulated changes
related to 'dispatch' and interop.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/append-args-1.c: Update dg-*.
* c-c++-common/gomp/append-args-3.c: Likewise.
* g++.dg/gomp/append-args-1.C: Likewise.
* gfortran.dg/gomp/adjust-args-1.f90: Likewise.
* gfortran.dg/gomp/adjust-args-3.f90: Likewise.
* gfortran.dg/gomp/declare-variant-2.f90: Likewise.
* c-c++-common/gomp/append-args-6.c: New test.
* c-c++-common/gomp/append-args-7.c: New test.
* c-c++-common/gomp/append-args-8.c: New test.
* c-c++-common/gomp/append-args-9.c: New test.
* g++.dg/gomp/append-args-4.C: New test.
* g++.dg/gomp/append-args-5.C: New test.
* g++.dg/gomp/append-args-6.C: New test.
* g++.dg/gomp/append-args-7.C: New test.
* gcc.dg/gomp/append-args-1.c: New test.
* gfortran.dg/gomp/append_args-1.f90: New test.
* gfortran.dg/gomp/append_args-2.f90: New test.
* gfortran.dg/gomp/append_args-3.f90: New test.
* gfortran.dg/gomp/append_args-4.f90: New test.

6 months agomiddle-end/118692 - ICE with out-of-bound ref expansion
Richard Biener [Wed, 29 Jan 2025 14:09:35 +0000 (15:09 +0100)] 
middle-end/118692 - ICE with out-of-bound ref expansion

The following guards the BIT_FIELD_REF expansion fallback for
MEM_REFs of entities expanded to register (or constant) further,
avoiding large out-of-bound offsets by, when the access does not
overlap the base object, expanding the offset as if it were zero.

PR middle-end/118692
* expr.cc (expand_expr_real_1): When expanding a MEM_REF
as BIT_FIELD_REF avoid large offsets for accesses not
overlapping the base object.

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

6 months agotree-optimization/114052 - consider infinite sub-loops when lowering iter bound
Richard Biener [Wed, 29 Jan 2025 12:25:14 +0000 (13:25 +0100)] 
tree-optimization/114052 - consider infinite sub-loops when lowering iter bound

When we walk stmts to find always executed stmts with UB in the last
iteration to be able to reduce the iteration count by one we fail
to consider infinite subloops in the last iteration that would make
such stmt not execute.  The following adds this.

PR tree-optimization/114052
* tree-ssa-loop-niter.cc (maybe_lower_iteration_bound): Check
for infinite subloops we might not exit.

* gcc.dg/pr114052-1.c: New testcase.

6 months agopair-fusion: Check for invalid use arrays [PR118320]
Richard Sandiford [Thu, 30 Jan 2025 08:59:30 +0000 (08:59 +0000)] 
pair-fusion: Check for invalid use arrays [PR118320]

As Andrew says in the bugzilla comments, this PR is about a case where
we tried to fuse two stores of x0, one in which x0 was defined and one
in which it was undefined.  merge_access_arrays failed on the conflict,
but the failure wasn't caught.

Normally the hazard detection code would fail if the instructions
had incompatible uses.  However, an undefined use doesn't impose
many restrictions on movements.  I think this is likely to be the
only case where hazard detection isn't enough.

As Andrew notes in bugzilla, it might be possible to allow uses
of defined and undefined values to be merged to the defined value.
But that sounds dangerous in the general case, as an rtl-ssa-level
decision.  We might run the risk of turning conditional UB into
unconditional UB.  And LLVM proves that the definition of "undef"
isn't simple.

gcc/
PR rtl-optimization/118320
* pair-fusion.cc (pair_fusion_bb_info::fuse_pair): Commonize
the merge of input_uses and return early if it fails.

gcc/testsuite/
PR rtl-optimization/118320
* g++.dg/torture/pr118320.C: New test.

6 months ago[PR testsuite/116860] Testsuite adjustment for recently added tests
Jeff Law [Thu, 30 Jan 2025 02:42:11 +0000 (19:42 -0700)] 
[PR testsuite/116860] Testsuite adjustment for recently added tests

There's two new tests that are dependent on logical-op-non-short-circuit
settings.  The BZ is reported against ppc64 and ppc64le, but also applies to a
goodly number of the other targets.

The "regression" fix is trivial, just add the appropriate param to force the
behavior we're expecting.  I'm committing that fix momentarily.  It's been
verified on ppc64, ppc64le and x86_64 as well as the various embedded targets
in my tester where many FAILS flip to PASS.

I'm leaving the bug open without the regression marker as Jakub has noted a
couple of improvements that we can and probably should make.

PR target/116860
gcc/testsuite
* gcc.dg/tree-ssa/fold-xor-and-or.c: Set logical-op-non-short-circuit.
* gcc.dg/tree-ssa/fold-xor-or.c: Similarly.

6 months agoDaily bump.
GCC Administrator [Thu, 30 Jan 2025 00:19:12 +0000 (00:19 +0000)] 
Daily bump.

6 months agoPR modula2/116073 invalid rtl sharing compiling FileSystem.mod caused by ext-dce
Gaius Mulley [Wed, 29 Jan 2025 20:32:07 +0000 (20:32 +0000)] 
PR modula2/116073 invalid rtl sharing compiling FileSystem.mod caused by ext-dce

The bug fixes to PR modula2/118010 and PR modula2/118183 uncovered a bug
in the procedure interface to lseek which uses SYSTEM.COFF_T rather than
SYSTEM.CSSIZE_T.  This patch sets the default size for COFF_T to the same
as CSSIZE_T.

gcc/ChangeLog:
PR modula2/118010
PR modula2/118183
PR modula2/116073
* doc/gm2.texi (-fm2-file-offset-bits=): Change the default size
description to CSSIZE_T.
Add COFF_T to the list of data types exported by SYSTEM.def.

gcc/m2/ChangeLog:
PR modula2/118010
PR modula2/118183
PR modula2/116073
* gm2-compiler/M2Options.mod (OffTBits): Assign to 0.
* gm2-gcc/m2type.cc (build_m2_specific_size_type): Ensure that
layout_type is called before returning c.
(build_m2_offt_type_node): If GetFileOffsetBits returns 0 then
use the type size of ssize_t.

gcc/testsuite/ChangeLog:

PR modula2/118010
PR modula2/118183
PR modula2/116073
* gm2/pim/run/pass/printtypesize.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agod: give dependency files better filenames [PR118477]
Arsen Arsenović [Wed, 29 Jan 2025 20:14:33 +0000 (21:14 +0100)] 
d: give dependency files better filenames [PR118477]

Currently, the dependency files for root-file.o and common-file.o were
both d/.deps/file.Po, which would cause parallel builds to fail
sometimes with:

  make[3]: Leaving directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
  make[3]: Entering directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
  mv: cannot stat 'd/.deps/file.TPo': No such file or directory
  make[3]: *** [/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/gcc-14-20240511/gcc/d/Make-lang.in:421: d/root-file.o] Error 1 shuffle=131581365

Also, this means that dependencies of one of root-file or common-file
are missing when developing.  After this patch, those two files get
assigned dependency files d/.deps/root-file.Po and
d/.deps/common-file.Po respectively, so match the actual object
files in the d/ subdirectory.

There are other files with similar conflicts (mangle-package.o,
visitor-package.o for instance).

2025-01-29  Arsen Arsenović  <arsen@aarsen.me>
    Jakub Jelinek  <jakub@redhat.com>

PR d/118477
* Make-lang.in (DCOMPILE, DPOSTCOMPILE): Use $(basename $(@F))
instead of $(*F).

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
6 months agopair-fusion: A couple of fixes for sp updates [PR118429]
Richard Sandiford [Wed, 29 Jan 2025 17:44:53 +0000 (17:44 +0000)] 
pair-fusion: A couple of fixes for sp updates [PR118429]

The PR showed two issues with pair-fusion.  The first is that the pass
treated stack pointer deallocations as ordinary register updates, and so
might move them earlier than another stack access (through a different
base register) that doesn't alias the pair candidate.

The simplest fix for that seems to be to prevent the stack deallocation
from being moved.  This part might (or might not) be a latent source of
wrong code and so worth backporting in some form.  (The patch as-is
won't work for GCC 14.)

The second issue only started with r15-6551, which added a memory
write to stack allocations and deallocations.  We should use the
existing tombstone mechanism to preserve the associated memory
definition.  (Deleting definitions immediately would have quadratic
complexity in the worst case.)

gcc/
PR rtl-optimization/118429
* pair-fusion.cc (latest_hazard_before): Add an extra parameter
to say whether the instruction is a load or a store.  If the
instruction is not a load or store and has memory side effects,
prevent it from being moved earlier.
(pair_fusion::find_trailing_add): Update call accordingly.
(pair_fusion_bb_info::fuse_pair): If the trailng addition had
a memory side-effect, use a tombstone to preserve it.

gcc/testsuite/
PR rtl-optimization/118429
* gcc.c-torture/compile/pr118429.c: New test.

6 months agoAVR: Allow to share libgcc's __negsi2.
Georg-Johann Lay [Wed, 29 Jan 2025 17:21:07 +0000 (18:21 +0100)] 
AVR: Allow to share libgcc's __negsi2.

libgcc has a module for __negsi2:  REG_22:SI := - REG_22:SI.
This patch adds a pattern that allows to share that function
provided optimize_size.

gcc/
* config/avr/avr.md (*negsi2.libgcc): New insn.

6 months agoc++: add fixed test [PR57533]
Marek Polacek [Wed, 29 Jan 2025 15:37:50 +0000 (10:37 -0500)] 
c++: add fixed test [PR57533]

Fixed by r11-2412.

PR c++/57533

gcc/testsuite/ChangeLog:

* g++.dg/eh/throw5.C: New test.

6 months agotestsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles
Siddhesh Poyarekar [Thu, 19 Dec 2024 13:09:15 +0000 (08:09 -0500)] 
testsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles

Denormal behaviour is well defined for IEEE128 long doubles, so
XFAIL some gfortran tests only for targets with the IBM128 long double
ABI.

gcc/testsuite/ChangeLog:

PR testsuite/118127
* lib/target-supports.exp
(check_effective_target_long_double_is_ibm128): New
procedure.
* gfortran.dg/default_format_2.f90: xfail for
long_double_is_ibm128.
* gfortran.dg/default_format_denormal_2.f90: Likewise.
* gfortran.dg/large_real_kind_form_io_2.f90: Likewise.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
6 months ago[PATCH] RX: Restrict displacement ranges in "Q" constraint
Yoshinori Sato [Wed, 29 Jan 2025 15:07:15 +0000 (08:07 -0700)] 
[PATCH] RX: Restrict displacement ranges in "Q" constraint

When using the "Q" constraint in the inline assembler, the displacement value
could exceed the range specified by the instruction.
To avoid this issue, a displacement range check is added to the "Q" constraint.

gcc/
* config/rx/constraints.md (Q): Also check that the address
passes rx_is_restricted_memory-address.

6 months agolibstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413]
Patrick Palka [Wed, 29 Jan 2025 15:02:28 +0000 (10:02 -0500)] 
libstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413]

The range adaptor perfect forwarding simplification mechanism is currently
only enabled for trivially copyable bound arguments, to prevent undesirable
copies of complex objects.  But "trivially copyable" is the wrong property
to check for here, since a move-only type with a trivial move constructor
is considered trivially copyable, and after P2492R2 we can't assume copy
constructibility of the bound arguments.  This patch makes the mechanism
more specifically check for trivial copy constructibility instead so
that it's properly disabled for move-only bound arguments.

PR libstdc++/118413

libstdc++-v3/ChangeLog:

* include/std/ranges (views::__adaptor::_Partial): Adjust
constraints on the "simple" partial specializations to require
is_trivially_copy_constructible_v instead of
is_trivially_copyable_v.
* testsuite/std/ranges/adaptors/adjacent_transform/1.cc (test04):
Extend P2494R2 test.
* testsuite/std/ranges/adaptors/transform.cc (test09): Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
6 months agosplit-path: Small fix for poor_ifcvt_pred (tsvc s258) [PR118505]
Andrew Pinski [Tue, 28 Jan 2025 20:00:06 +0000 (12:00 -0800)] 
split-path: Small fix for poor_ifcvt_pred (tsvc s258) [PR118505]

After r15-3436-gb2b20b277988ab, poor_ifcvt_pred returns false for
the case where the statement could trap but in this case trapping
instructions cannot be made unconditional so it is a poor ifcvt.

This fixes a small preformance regression with TSVC s258 at
`-O3 -ftrapping-math` on aarch64 where ifcvt would not happen
and we would still have a branch.

On a specific aarch64, we go from 0.145s down to 0.118s.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR tree-optimization/118505
* gimple-ssa-split-paths.cc (poor_ifcvt_pred): Return
true for trapping statements.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
6 months agosplit-path: CALL_EXPR can't show up in gimple_assign
Andrew Pinski [Tue, 28 Jan 2025 20:20:25 +0000 (12:20 -0800)] 
split-path: CALL_EXPR can't show up in gimple_assign

While working on split path, I noticed that poor_ifcvt_candidate_code
would check for CALL_EXPR but that can't show up in gimple_assign
so this removes that check.

This could be a very very small compile time improvement.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* gimple-ssa-split-paths.cc (poor_ifcvt_candidate_code): Remove CALL_EXPR handling.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
6 months agotree-ssa-dce: Avoid creating invalid BBs with no outgoing edge (PR117892)
Martin Jambor [Wed, 29 Jan 2025 09:51:08 +0000 (10:51 +0100)] 
tree-ssa-dce: Avoid creating invalid BBs with no outgoing edge (PR117892)

Zhendong Su and Michal JireÅ¡ found out that our gimple DSE pass can,
under fairly specific conditions, remove a noreturn call which then
leaves behind a "normal" BB with no successor edges which following
passes do not expect.  This patch simply tells the pass to leave such
calls alone even when they otherwise appear to be dead.

Interestingly, our CFG verifier does not report this.  I'll put on my
todo list to add a test for it in the next stage 1.

gcc/ChangeLog:

2025-01-28  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/117892
* tree-ssa-dse.cc (dse_optimize_call): Leave control-altering
noreturn calls alone.

gcc/testsuite/ChangeLog:

2025-01-27  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/117892
* gcc.dg/tree-ssa/pr117892.c: New test.
* gcc.dg/tree-ssa/pr118517.c: Likewise.

co-authored-by: Michal JireÅ¡ <mjires@suse.cz>

6 months agoRISC-V: Fix incorrect code gen for scalar signed SAT_TRUNC [PR117688]
Pan Li [Thu, 23 Jan 2025 06:28:39 +0000 (14:28 +0800)] 
RISC-V: Fix incorrect code gen for scalar signed SAT_TRUNC [PR117688]

This patch would like to fix the wroing code generation for the scalar
signed SAT_TRUNC.  The input can be QI/HI/SI/DI while the alu like sub
can only work on Xmode.  Unfortunately we don't have sub/add for
non-Xmode like QImode in scalar, thus we need to sign extend to Xmode
to ensure we have the correct value before ALU like add.  The gen_lowpart
will generate something like lbu which has all zero for highest bits.

For example, when 0xff7f(-129 for HImode) trunc to QImode, we actually
want compare -129 to -128, but if there is no sign extend like lbu, we will
compare 0xff7f to 0xffffffffffffff80(assum Xmode is DImode).  Thus, we have
to sign extend 0xff(Qmode) to 0xffffffffffffff7f(assume Xmode is DImode)
before compare in Xmode.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

PR target/117688

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_expand_sstrunc): Leverage the helper
riscv_extend_to_xmode_reg with SIGN_EXTEND.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr117688.h: Add test helper macros.
* gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c: New test.
* gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c: New test.
* gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c: New test.
* gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c: New test.
* gcc.target/riscv/pr117688-trunc-run-1-s64-to-s32.c: New test.
* gcc.target/riscv/pr117688-trunc-run-1-s64-to-s8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoRISC-V: Fix incorrect code gen for scalar signed SAT_SUB [PR117688]
Pan Li [Thu, 23 Jan 2025 04:14:43 +0000 (12:14 +0800)] 
RISC-V: Fix incorrect code gen for scalar signed SAT_SUB [PR117688]

This patch would like to fix the wroing code generation for the scalar
signed SAT_SUB.  The input can be QI/HI/SI/DI while the alu like sub
can only work on Xmode.  Unfortunately we don't have sub/add for
non-Xmode like QImode in scalar, thus we need to sign extend to Xmode
to ensure we have the correct value before ALU like sub.  The gen_lowpart
will generate something like lbu which has all zero for highest bits.

For example, when 0xff(-1 for QImode) sub 0x1(1 for QImode), we actually
want to -1 - 1 = -2, but if there is no sign extend like lbu, we will get
0xff - 1 = 0xfe which is incorrect.  Thus, we have to sign extend 0xff(Qmode)
to 0xffffffffffffffff(assume XImode is DImode) before sub in Xmode.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

PR target/117688

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_expand_sssub): Leverage the helper
riscv_extend_to_xmode_reg with SIGN_EXTEND.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr117688.h: Add test helper macro.
* gcc.target/riscv/pr117688-sub-run-1-s16.c: New test.
* gcc.target/riscv/pr117688-sub-run-1-s32.c: New test.
* gcc.target/riscv/pr117688-sub-run-1-s64.c: New test.
* gcc.target/riscv/pr117688-sub-run-1-s8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoRISC-V: Fix incorrect code gen for scalar signed SAT_ADD [PR117688]
Pan Li [Thu, 23 Jan 2025 04:08:17 +0000 (12:08 +0800)] 
RISC-V: Fix incorrect code gen for scalar signed SAT_ADD [PR117688]

This patch would like to fix the wroing code generation for the scalar
signed SAT_ADD.  The input can be QI/HI/SI/DI while the alu like sub
can only work on Xmode.  Unfortunately we don't have sub/add for
non-Xmode like QImode in scalar, thus we need to sign extend to Xmode
to ensure we have the correct value before ALU like add.  The gen_lowpart
will generate something like lbu which has all zero for highest bits.

For example, when 0xff(-1 for QImode) plus 0x2(1 for QImode), we actually
want to -1 + 2 = 1, but if there is no sign extend like lbu, we will get
0xff + 2 = 0x101 which is incorrect.  Thus, we have to sign extend 0xff(Qmode)
to 0xffffffffffffffff(assume XImode is DImode) before plus in Xmode.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

PR target/117688

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_expand_ssadd): Leverage the helper
riscv_extend_to_xmode_reg with SIGN_EXTEND.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr117688-add-run-1-s16.c: New test.
* gcc.target/riscv/pr117688-add-run-1-s32.c: New test.
* gcc.target/riscv/pr117688-add-run-1-s64.c: New test.
* gcc.target/riscv/pr117688-add-run-1-s8.c: New test.
* gcc.target/riscv/pr117688.h: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoRISC-V: Refactor SAT_* operand rtx extend to reg help func [NFC]
Pan Li [Mon, 27 Jan 2025 03:01:08 +0000 (11:01 +0800)] 
RISC-V: Refactor SAT_* operand rtx extend to reg help func [NFC]

This patch would like to refactor the helper function of the SAT_*
scalar.  The helper function will convert the define_pattern ops
to the xmode reg for the underlying code-gen.  This patch add
new parameter for ZERO_EXTEND or SIGN_EXTEND if the input is const_int
or the mode is non-Xmode.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_gen_zero_extend_rtx): Rename from ...
(riscv_extend_to_xmode_reg): Rename to and add rtx_code for
zero/sign extend if non-Xmode.
(riscv_expand_usadd): Leverage the renamed function with ZERO_EXTEND.
(riscv_expand_ussub): Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agomiddle-end/118684 - fix fallout of wrong stack local alignment fix
Richard Biener [Wed, 29 Jan 2025 07:58:39 +0000 (08:58 +0100)] 
middle-end/118684 - fix fallout of wrong stack local alignment fix

When we expand BIT_FIELD_REF <x_2(D), 8, 8> we can end up creating
a stack local, running into the fix.  But get_object_alignment
will return 8 for any SSA_NAME because that's not an "object" we
handle.  Deal with handled components on registers by singling out
SSA_NAME bases, using their type alignment instead of
get_object_alignment (I considered "robustifying" get_object_alignment,
but decided not to at this point).

This fixes an ICE on gcc.dg/pr41123.c on arm as reported by the CI.

PR middle-end/118684
* expr.cc (expand_expr_real_1): When creating a stack local
during expansion of a handled component, when the base is
a SSA_NAME use its type alignment and avoid calling
get_object_alignment.

* gcc.dg/pr118684.c: Require automatic_stack_alignment.

6 months agoc++: Return false from __is_bounded_array for zero-sized arrays [PR118655]
Jakub Jelinek [Wed, 29 Jan 2025 08:32:04 +0000 (09:32 +0100)] 
c++: Return false from __is_bounded_array for zero-sized arrays [PR118655]

This is basically Marek's PR114479 r14-9759 __is_array fix applied to
__is_bounded_array as well.  Similarly to that trait, when not using
the builtin it returned false for zero sized arrays but when using
the builtin it returns true.

2025-01-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/118655
* semantics.cc (trait_expr_value) <case CPTK_IS_BOUNDED_ARRAY>: Return
false for zero-sized arrays.

* g++.dg/ext/is_bounded_array.C: Extend.

6 months agoFortran: fix passing of component ref to assumed-rank dummy [PR118683]
Harald Anlauf [Tue, 28 Jan 2025 20:21:40 +0000 (21:21 +0100)] 
Fortran: fix passing of component ref to assumed-rank dummy [PR118683]

While the fix for pr117774 addressed the passing of an inquiry reference
to an assumed-rank dummy, it missed the similar case of passing a component
reference.  The newer testcase gfortran.dg/pr81978.f90 uncovered this
latent issue with a UBSAN instrumented compiler.

PR fortran/118683

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): The bounds update for
passing to assumed-rank dummies shall also handle component
references besides inquiry references.

6 months agoDaily bump.
GCC Administrator [Wed, 29 Jan 2025 00:17:48 +0000 (00:17 +0000)] 
Daily bump.

6 months agoc++: constexpr VEC_INIT_EXPR [PR118285]
Jason Merrill [Tue, 28 Jan 2025 18:11:50 +0000 (13:11 -0500)] 
c++: constexpr VEC_INIT_EXPR [PR118285]

cxx_eval_vec_init_1 was doing the wrong thing for an array of
self-referential class type; just evaluating the TARGET_EXPR initializer
creates a new object that refers to the TARGET_EXPR_SLOT, if we want it to
refer properly to the initialization target we need to provide it.

PR c++/118285

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_vec_init_1): Build INIT_EXPR for
initializing a class.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-opt7.C: New test.

6 months agoc++: init-list opt and lvalue initializers [PR118673]
Jason Merrill [Mon, 27 Jan 2025 23:30:18 +0000 (18:30 -0500)] 
c++: init-list opt and lvalue initializers [PR118673]

When fn returns {extension}, the ArrayRef in the initializer_list is
constructed to point to 'extension', the variable with static storage
duration.  The optimization was copying extension's value into a temporary
array and constructing the ArrayRef to point to that temporary copy instead,
resulting in a dangling pointer.  So suppress this optimization if the
element constructor takes a reference and the initializer is a non-mergeable
lvalue.

PR c++/118673

gcc/cp/ChangeLog:

* call.cc (maybe_init_list_as_array): Check for lvalue
initializers.
* cp-tree.h (enum cp_lvalue_kind_flags): Add clk_mergeable.
* tree.cc (lvalue_kind): Return it.
(non_mergeable_glvalue_p): New.
(test_lvalue_kind): Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-opt6.C: New test.

6 months agoarm: libgcc: make -spec=sync-*.specs compatible with LTO [PR118642]
Richard Earnshaw [Tue, 28 Jan 2025 16:14:35 +0000 (16:14 +0000)] 
arm: libgcc: make -spec=sync-*.specs compatible with LTO [PR118642]

The arm-none-eabi port provides some alternative implementations of
__sync_synchronize for different implementations of the architecture.
These can be selected using one of -specs=sync-{none,dmb,cp15dmb}.specs.

These specs fragments fail, however, when LTO is used because they
unconditionally add a --defsym=__sync_synchronize=<implementation> to
the linker arguments and that fails if libgcc is not added to the list
of libraries.

Fix this by only adding the defsym if libgcc will be passed to the
linker.

libgcc/

PR target/118642
* config/arm/sync-none.specs (link): Only add the defsym if
libgcc will be used.
* config/arm/sync-dmb.specs: Likewise.
* config/arm/sync-cp15dmb.specs: Likewise.

6 months agomiddle-end/118684 - wrongly aligned stack local during expansion
Richard Biener [Tue, 28 Jan 2025 15:20:30 +0000 (16:20 +0100)] 
middle-end/118684 - wrongly aligned stack local during expansion

The following fixes a not properly aligned stack temporary created
during RTL expansion of a MEM_REF that we handle as a BIT_FIELD_REF
whose base was allocated to a register but which was originally
aligned to allow a larger load not trapping.  While probably UB
in C the vectorizer creates aligned accesses that might overread
a (static) allocation because it is then known not to trap.

PR middle-end/118684
* expr.cc (expand_expr_real_1): When expanding a reference
based on a register and we end up needing a MEM make sure
that's aligned as the original reference required.

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

6 months agoinput.cc: show line record indices in file_cache_slot::dump
David Malcolm [Tue, 28 Jan 2025 15:38:39 +0000 (10:38 -0500)] 
input.cc: show line record indices in file_cache_slot::dump

gcc/ChangeLog:
* input.cc (file_cache_slot::dump): Show indices within
m_line_record when dumping entries.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 months agosarif output: escape braces in messages [PR118675]
David Malcolm [Tue, 28 Jan 2025 15:36:53 +0000 (10:36 -0500)] 
sarif output: escape braces in messages [PR118675]

gcc/ChangeLog:
PR other/118675
* diagnostic-format-sarif.cc: Define INCLUDE_STRING.
(escape_braces): New.
(set_string_property_escaping_braces): New.
(sarif_builder::make_message_object): Escape braces in the "text"
property.
(sarif_builder::make_message_object_for_diagram): Likewise, and
for the "markdown" property.
(sarif_builder::make_multiformat_message_string): Likewise for the
"text" property.
(xelftest::test_message_with_braces): New.
(selftest::diagnostic_format_sarif_cc_tests): Call it.

gcc/testsuite/ChangeLog:
PR other/118675
* gcc.dg/sarif-output/bad-binary-op.py: Update expected output for
escaping of braces in message text.
* gcc.dg/sarif-output/missing-semicolon.py: Likewise.
* gcc.dg/sarif-output/multiple-outputs.py: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 months agovect: Fix permutation counting in VLA-friendly path [PR117270]
Richard Sandiford [Tue, 28 Jan 2025 14:45:11 +0000 (14:45 +0000)] 
vect: Fix permutation counting in VLA-friendly path [PR117270]

vectorizable_slp_permutation_1 has two ways of generating the
permutations: one that looks for repeating patterns and one that
calculates the permutation index for every output element individually.
The former works for VLA and VLS whereas the latter only works for VLS.

There are two justifications for using the repeating code for VLS:
it gives more testing coverage, and it should reduce the analysis
overhead for common cases.  This PR kind-of demonstrates both:
the VLS coverage was showing a bug in the analysis shortcut.

The bug seems to go back to g:ab7e60cec1a6, which added the
repeating_p path.  It generated N copies of the permutation vector
in the repeating case, but didn't multiply the number of permutation
instructions for costing purposes by N.  So we seem to have been
undercounting ncopies>1 permutations all this time...

The problem became more visible with g:8157f3f2d211, which extended
the repeating code to handle more cases.

In the patch, I think noutputs is in practice always a multiple
of unpack_factor, but it seemed more future-proof to handle the
general case.

gcc/
PR tree-optimization/117270
* tree-vect-slp.cc (vectorizable_slp_permutation_1): Make nperms
account for the number of times that each permutation will be used
during transformation.

6 months agoc++: friend vs inherited guide confusion [PR117855]
Patrick Palka [Tue, 28 Jan 2025 14:27:02 +0000 (09:27 -0500)] 
c++: friend vs inherited guide confusion [PR117855]

We recently started using the lang_decl_fn::context field to track
inheritedness of a deduction guide (for C++23 inherited CTAD).  This
new overloading of the field accidentally made DECL_FRIEND_CONTEXT
return non-NULL for inherited guides, which breaks the below testcase
during overload resolution with an inherited guide.

This patch fixes this by refining DECL_FRIEND_CONTEXT appropriately.

PR c++/117855

gcc/cp/ChangeLog:

* cp-tree.h (DECL_FRIEND_CONTEXT): Exclude deduction guides.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/class-deduction-inherited7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
6 months agotree-optimization/112859 - add comment
Richard Biener [Tue, 28 Jan 2025 14:01:25 +0000 (15:01 +0100)] 
tree-optimization/112859 - add comment

This adds a comment before the workaround, indicating flaky
dependence analysis.

PR tree-optimization/112859
* tree-loop-distribution.cc
(loop_distribution::pg_add_dependence_edges): Add comment.

6 months agoarm: libbacktrace: Check if the compiler supports __sync atomics
Richard Earnshaw [Mon, 27 Jan 2025 13:52:05 +0000 (13:52 +0000)] 
arm: libbacktrace: Check if the compiler supports __sync atomics

Older versions of the Arm architecture lack support for __sync
operations directly in hardware and require calls into appropriate
operating-system hooks.  But such hooks obviously don't exist in a
freestanding environment.

Consquently, it is incorrect to assume during configure that such
functions will exist and we need a configure-time check to determine
whether or not these routines will work.

libbacktrace:

* configure.ac: Always check if the compiler supports __sync
operations.
* configure: Regenerated.

6 months ago[PR118663][LRA]: Change secondary memory mode only if there are regs holding the...
Vladimir N. Makarov [Tue, 28 Jan 2025 13:37:33 +0000 (08:37 -0500)] 
[PR118663][LRA]: Change secondary memory mode only if there are regs holding the changed mode

  My recent patch for PR118067 changes the secondary memory mode if
all regs of the pseudo reg class are prohibited in the secondary mode.
But the patch does not check a special case when the
corresponding target hook returns this mode although there are no hard
regs of pseudo class holding value of the mode at all.  This results
in given PR and this patch fixes it.

gcc/ChangeLog:

PR target/118663
* lra-constraints.cc (invalid_mode_reg_p): Check empty
reg_class_contents.

gcc/testsuite/ChangeLog:

PR target/118663
* gcc.target/powerpc/pr118663.c: New.

6 months agotree-optimization/117424 - invalid LIM of trapping ref
Richard Biener [Tue, 28 Jan 2025 11:28:14 +0000 (12:28 +0100)] 
tree-optimization/117424 - invalid LIM of trapping ref

The following addresses a bug in tree_could_trap_p leading to
hoisting of a possibly trapping, because of out-of-bound, access.
We only ensured the first accessed byte is within a decl there,
the patch makes sure the whole base of the reference is within it.
This is pessimistic if a handled component would then subset to
a sub-object within the decl but upcasting of a decl to larger
types should be uncommon, questionable, and wrong without
-fno-strict-aliasing.

The testcase is a bit fragile, but I could not devise a (portable)
way to ensure an out-of-bound access to a decl would fault.

PR tree-optimization/117424
* tree-eh.cc (tree_could_trap_p): Verify the base is
fully contained within a decl.

* gcc.dg/tree-ssa/ssa-lim-25.c: New testcase.

6 months agoClarify 'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P' in 'gcc/tree-pretty-print.cc:dump_omp_clause'
Thomas Schwinge [Tue, 14 Jan 2025 11:58:08 +0000 (12:58 +0100)] 
Clarify 'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P' in 'gcc/tree-pretty-print.cc:dump_omp_clause'

In commit b7e20480630e3eeb9eed8b3941da3b3f0c22c969
"openmp: Relax handling of implicit map vs. existing device mappings",
'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P' was added next to 'OMP_CLAUSE_MAP_IMPLICIT'
with comment: "NOTE: this is different than OMP_CLAUSE_MAP_IMPLICIT".  However,
dumping it as '[implicit]' doesn't exactly help for telling the two apart; make
that '[runtime_implicit]'.  Also, prepend a space character, similar to how
we're doing with other such attributes.

gcc/
* tree-pretty-print.cc (dump_omp_clause): Clarify
'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P'.
gcc/testsuite/
* c-c++-common/gomp/defaultmap-4.c: Adjust.
* c-c++-common/gomp/defaultmap-5.c: Likewise.
* c-c++-common/gomp/target-implicit-map-1.c: Likewise.
* c-c++-common/gomp/target-implicit-map-2.c: Likewise.
* gfortran.dg/gomp/defaultmap-8.f90: Likewise.
* gfortran.dg/gomp/defaultmap-9.f90: Likewise.
* gfortran.dg/gomp/map-subarray.f90: Likewise.
* gfortran.dg/gomp/target-enter-exit-data.f90: Likewise.

6 months agoRemove ChangeLog entry that shouldn't be there.
Jakub Jelinek [Tue, 28 Jan 2025 09:16:06 +0000 (10:16 +0100)] 
Remove ChangeLog entry that shouldn't be there.

6 months agocombine: Fix up make_extraction [PR118638]
Jakub Jelinek [Tue, 28 Jan 2025 09:14:05 +0000 (10:14 +0100)] 
combine: Fix up make_extraction [PR118638]

The following testcase is miscompiled at -Os on x86_64-linux.
The problem is during make_compound_operation of
(ashiftrt:SI (ashift:SI (mult:SI (reg:SI 107 [ a_5 ])
            (const_int 3 [0x3]))
        (const_int 31 [0x1f]))
    (const_int 31 [0x1f]))
where it incorrectly returns
(mult:SI (sign_extract:SI (reg:SI 107 [ a_5 ])
        (const_int 2 [0x2])
        (const_int 0 [0]))
    (const_int 3 [0x3]))
which isn't obviously true, the former returns either 0 or -1 depending
on the least significant bit of the multiplication,
the latter returns either 0 or -3 depending on the second least significant
bit of the multiplication argument.

The bug has been introduced in PR96998 r11-4563, which added handling of x
* (2^N) similar to x << N.  In the above case, pos is 0 and len is 1,
sign extracting a single least significant bit of the multiplication.
As 3 is not a power of 2, shift_amt is -1.
But IN_RANGE (-1, 1, 1 - 1) is still true, because the basic requirement of
IN_RANGE that LOWER is not greater than UPPER is violated.
The intention of using 1 as LOWER is to avoid matching multiplication by 1,
that really shouldn't appear in the IL.  But to avoid violating IN_RANGE
requirement, we need to verify that len is at least 2.

I've added this len > 1 check to the inner if rather than outer because I
think for GCC 16 we should add a further optimization.
In the particular case of 1 least significant bit sign extraction from
multiplication by 3, we could actually say it is equivalent to
(sign_extract:SI (reg:SI 107 [ a_5 ])
        (const_int 1 [0x2])
        (const_int 0 [0]))
That is because 3 is an odd number and multiplication by 2 will yield the
least significant bit 0 (we are sign extracting just one) and so the
multiplication doesn't change anything on the outcome.
More generally, even for larger len, multiplication by C which is
(1 << X) + 1 where X is >= len should be optimizable just to extraction
of the multiplicand's least significant len bits.

2025-01-28  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/118638
* combine.cc (make_extraction): Only optimize (mult x 2^n) if len is
larger than 1.

* gcc.c-torture/execute/pr118638.c: New test.

6 months agoAdd tests for implied copy of variables in reduction clause.
Hafiz Abid Qadeer [Wed, 20 Dec 2023 14:48:29 +0000 (14:48 +0000)] 
Add tests for implied copy of variables in reduction clause.

The OpenACC reduction clause on compute construct implies a copy clause
for each reduction variable [1]. This patch adds tests to check if the
implied copy is being generated. The check covers various types and
operators as described in the specification.

[1] OpenACC 2.7 Specification section 2.5.13

gcc/testsuite/ChangeLog:

* c-c++-common/goacc/implied-copy-1.c: New test.
* c-c++-common/goacc/implied-copy-2.c: New test.
* g++.dg/goacc/implied-copy.C: New test.
* gcc.dg/goacc/implied-copy.c: New test.
* gfortran.dg/goacc/implied-copy-1.f90: New test.
* gfortran.dg/goacc/implied-copy-2.f90: New test.

6 months agovect: Remove extra newline from dump message
Richard Sandiford [Tue, 28 Jan 2025 09:00:08 +0000 (09:00 +0000)] 
vect: Remove extra newline from dump message

Noticed while working PR117270, where it was a distracting
difference for before-after comparisons.

gcc/
* tree-vect-slp.cc (vectorizable_slp_permutation_1): Remove
extra newline from dump message.

6 months agoc: For array element type drop qualifiers but keep other properties of the element...
Jakub Jelinek [Tue, 28 Jan 2025 08:31:27 +0000 (09:31 +0100)] 
c: For array element type drop qualifiers but keep other properties of the element type [PR116357]

In the following testcase we error on the first case because it is
trying to construct an array from overaligned type, but if there are
qualifiers, we accept it silently (unlike in C++ which diagnoses all 3).

The problem is that grokdeclarator if TYPE_QUALS (element_type) is
non-zero just uses TYPE_MAIN_VARIANT; that loses not just the qualifiers
but also attributes, alignment etc.

The following patch uses c_build_qualified_type with TYPE_UNQUALIFIED instead,
which will be in the common case the same as TYPE_MAIN_VARIANT if the
checks are satisfied for it, but if not, will look up different unqualified
type or even create it if there is none.

2025-01-28  Jakub Jelinek  <jakub@redhat.com>

PR c/116357
* c-decl.cc (grokdeclarator): Use c_build_qualified_type with
TYPE_UNQUALIFIED instead of TYPE_MAIN_VARIANT.

* gcc.dg/pr116357.c: New test.

6 months ago[PR target/114085] Fix H8 constraint issue which led to ICE
Jeff Law [Tue, 28 Jan 2025 04:25:39 +0000 (21:25 -0700)] 
[PR target/114085] Fix H8 constraint issue which led to ICE

Nowhere near the top of my list, but a quick looksie Sunday led to an easy to
fix backend bug.  It's not a regression, but given its the H8 backend I think
we've safely got a degree of freedom here.

The H8 has a constraint "U" which allowed both a subset of MEMs and REGs, so it
wasn't marked as a memory constraint.  LRA doesn't really handle this well -- a
pseudo which didn't get a hard reg was replaced by its MEM.  The stack slot
doesn't fit the limited addressing forms available and LRA didn't know it just
needed to reload the address into a reg.

Fixed by removing REG from the "U" constraint, turning "U" into a memory
constraint and adjusting a few patterns to allow "rU" instead of "U".

We don't really support C++ on the H8 and as a result libstdc++ won't build.
Interestingly enough that also keeps the C++ tests from working, even for a
compile-only test.  So no testcase.  Though I did check the reduced and
original test manually and ran it through my tester without any regressions.

PR target/114085
gcc/
* config/h8300/constraints.md (U): No longer accept REGs.
* config/h8300/logical.md (andqi3_2): Use "rU" rather than "U".
(andqi3_2_clobber_flags, andqi3_1, <code>qi3_1): Likewise.
* config/h8300/testcompare.md (tst_extzv_1_n): Likewise.

6 months agoDaily bump.
GCC Administrator [Tue, 28 Jan 2025 00:20:57 +0000 (00:20 +0000)] 
Daily bump.

6 months agoc++: only strip conversions for deduction [PR118632]
Jason Merrill [Mon, 27 Jan 2025 17:04:13 +0000 (12:04 -0500)] 
c++: only strip conversions for deduction [PR118632]

In r15-2761 I changed unify to always strip IMPLICIT_CONV_EXPR from PARM.
In this testcase that leads to comparing nullptr to (int*)0, and failing
because they aren't the same.  Let's only strip conversions if we're
actually going to try to deduce template arguments.

While we're at it, let's move this after the early exits.

And with this adjustment we can remove the workaround for mangle57.C.

PR c++/118632

gcc/cp/ChangeLog:

* pt.cc (unify): Only strip conversion if deducible_expression.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nontype7.C: New test.

6 months agoRISC-V: Add another test for FRM elimination bug [PR118646]
Vineet Gupta [Fri, 24 Jan 2025 21:56:28 +0000 (13:56 -0800)] 
RISC-V: Add another test for FRM elimination bug [PR118646]

The issue is same as PR118103 and fixed by commit 55d288d4ff53
("RISC-V: Make FRM as global register [PR118103]").

Essentially FRM save/restore were getting eliminated because FRM reg
semantics were not being modelled correctly.

In this case it showed up as SPEC2017 527.cam4 runtime aborts in
glibc:round_away() due to non-canonical rounding mode showing up,
"leaking" earlier in the call chain because such rounding mode
save/restore was getting eliminated.

PR target/118646

gcc/testsuite/ChangeLog:
* gfortran.target/riscv/rvv/pr118646.f90 (New Test).

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
6 months agoc++: Don't prune constant capture proxies only used in array dimensions [PR114292]
Simon Martin [Wed, 22 Jan 2025 15:19:47 +0000 (16:19 +0100)] 
c++: Don't prune constant capture proxies only used in array dimensions [PR114292]

We currently ICE upon the following valid (under -Wno-vla) code

=== cut here ===
void f(int c) {
  constexpr int r = 4;
  [&](auto) { int t[r * c]; }(0);
}
=== cut here ===

When parsing the lambda body, and more specifically the multiplication,
we mark the lambda as LAMBDA_EXPR_CAPTURE_OPTIMIZED, which indicates to
prune_lambda_captures that it might be possible to optimize out some
captures.

The problem is that prune_lambda_captures then misses the use of the r
capture (because neither walk_tree_1 nor cp_walk_subtrees walks the
dimensions of array types - here "r * c"), hence believes the capture
can be pruned... and we trip on an assert when instantiating the lambda.

This patch changes cp_walk_subtrees so that (1) when walking a
DECL_EXPR, it also walks the DECL's type, and (2) when walking an
INTEGER_TYPE, it also walks its TYPE_{MIN,MAX}_VALUE. Note that #2 makes
a <case INTEGER_TYPE> redundant in for_each_template_parm_r, and removes
it.

PR c++/114292

gcc/cp/ChangeLog:

* pt.cc (for_each_template_parm_r) <INTEGER_TYPE>: Remove case
now handled by cp_walk_subtrees.
* tree.cc (cp_walk_subtrees): Walk the type of DECL_EXPR
declarations, as well as the TYPE_{MIN,MAX}_VALUE of
INTEGER_TYPEs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-ice4.C: New test.

6 months agoRISC-V: testsuite: Fix reduc-8.c and reduc-9.c
Robin Dapp [Wed, 22 Jan 2025 17:05:44 +0000 (18:05 +0100)] 
RISC-V: testsuite: Fix reduc-8.c and reduc-9.c

In both tests we expect a VEC_SHL_INSERT expression but we now add the
initial value at the end.  Just remove that scan check.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/reduc/reduc-8.c: Remove
VEC_SHL_INSERT check.
* gcc.target/riscv/rvv/autovec/reduc/reduc-9.c: Ditto.

6 months agoRISC-V: testsuite: Fix gather_load_64-12-zvbb.c
Robin Dapp [Wed, 22 Jan 2025 15:19:49 +0000 (16:19 +0100)] 
RISC-V: testsuite: Fix gather_load_64-12-zvbb.c

The test fails with _zvfh because we vectorize more.  Just adjust the
test expectations.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c:
Distinguish between zvfh and !zvfh.

6 months agoRISC-V: Disable two-source permutes for now [PR117173].
Robin Dapp [Thu, 17 Oct 2024 16:39:16 +0000 (18:39 +0200)] 
RISC-V: Disable two-source permutes for now [PR117173].

After testing on the BPI (4.2% improvement for x264 input 1, 4.4% for
input 2) and the discussion in PR117173 I figured it's best to disable
the two-source permutes by default for now.

The patch adds a parameter "riscv-two-source-permutes" which restores
the old behavior.

PR target/117173

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_generic_patterns): Only
support single-source permutes by default.
* config/riscv/riscv.opt: New param "riscv-two-source-permutes".

gcc/testsuite/ChangeLog:

* gcc.dg/fold-perm-2.c: Run with two-source permutes.
* gcc.dg/pr54346.c: Ditto.

6 months agoFortran: fix bogus diagnostics on renamed interface import [PR110993]
Harald Anlauf [Sun, 26 Jan 2025 21:56:57 +0000 (22:56 +0100)] 
Fortran: fix bogus diagnostics on renamed interface import [PR110993]

PR fortran/110993

gcc/fortran/ChangeLog:

* frontend-passes.cc (check_externals_procedure): Do not compare
interfaces of a non-bind(C) procedure against a bind(C) global one.
(check_against_globals): Use local name from rename-on-use in the
search for interfaces.

gcc/testsuite/ChangeLog:

* gfortran.dg/use_rename_14.f90: New test.

6 months agoc++: Use mapped reads and writes when munmap and msync are available
John David Anglin [Mon, 27 Jan 2025 17:39:00 +0000 (12:39 -0500)] 
c++: Use mapped reads and writes when munmap and msync are available

Module support is broken when MAPPED_READING and MAPPED_WRITING
are defined to 0.  This causes internal compiler errors in the
permissive-error-1.C and permissive-error-2.C tests.

HP-UX 11.11 doesn't define _POSIX_MAPPED_FILES but it does have
munmap and msync.  Testing indicates support is sufficient for
c++ modules, so use checks for these functions instead of
_POSIX_MAPPED_FILES check.

2025-01-27  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

PR c++/116524
* configure.ac: Check for munmap and msync.
* configure: Regenerate.
* config.in: Regenerate.

gcc/cp/ChangeLog:
* module.cc: Test HAVE_MUNMAP and HAVE_MSYNC instead of
_POSIX_MAPPED_FILES > 0.

6 months agoRemove mistakenly committed files
Jakub Jelinek [Mon, 27 Jan 2025 16:22:05 +0000 (17:22 +0100)] 
Remove mistakenly committed files

Sorry.

2025-01-27  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/modules/dr2867-1_a.H.jj1: Remove.
* g++.dg/modules/dr2867-1_b.C.jj1: Remove.
* g++.dg/modules/dr2867-2_a.H.jj1: Remove.
* g++.dg/modules/dr2867-2_b.C.jj1: Remove.
* g++.dg/modules/dr2867-3_a.H.jj1: Remove.
* g++.dg/modules/dr2867-3_b.C.jj1: Remove.
* g++.dg/modules/dr2867-4_a.H.jj1: Remove.
* g++.dg/modules/dr2867-4_b.C.jj1: Remove.

6 months agoc++: Handle CWG2867 even in namespace scope structured bindings in header modules...
Jakub Jelinek [Mon, 27 Jan 2025 16:17:17 +0000 (17:17 +0100)] 
c++: Handle CWG2867 even in namespace scope structured bindings in header modules [PR115769]

The following patch implements the module streaming of the new
STATIC_INIT_DECOMP_BASE_P and STATIC_INIT_DECOMP_NONBASE_P flags.  As I think
namespace scope structured bindings in the header modules will be pretty rare,
I've tried to stream something extra only when they actually appear, in that
case it streams extra INTEGER_CSTs which mark end of
STATIC_INIT_DECOMP_*BASE_P (0), start of STATIC_INIT_DECOMP_BASE_P for
static_aggregates (1), start of STATIC_INIT_DECOMP_NONBASE_P for
static_aggregates (2) and ditto for tls_aggregates (3 and 4).
The patch also copies with just small tweaks the testcases from the
namespace scope structured binding CWG2867 patch.

2025-01-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/115769
gcc/cp/
* module.cc (module_state::write_inits): Verify
STATIC_INIT_DECOMP_{,NON}BASE_P flags and stream changes in those
out.
(module_state::read_inits): Stream those flags in.
gcc/testsuite/
* g++.dg/modules/dr2867-1_a.H: New test.
* g++.dg/modules/dr2867-1_b.C: New test.
* g++.dg/modules/dr2867-2_a.H: New test.
* g++.dg/modules/dr2867-2_b.C: New test.
* g++.dg/modules/dr2867-3_a.H: New test.
* g++.dg/modules/dr2867-3_b.C: New test.
* g++.dg/modules/dr2867-4_a.H: New test.
* g++.dg/modules/dr2867-4_b.C: New test.

6 months agoc++: Implement for namespace statics CWG 2867 - Order of initialization for structure...
Jakub Jelinek [Mon, 27 Jan 2025 15:45:56 +0000 (16:45 +0100)] 
c++: Implement for namespace statics CWG 2867 - Order of initialization for structured bindings [PR115769]

The following patch adds CWG 2867 support for namespace locals.

Those vars are just pushed into {static,tls}_aggregates chain, then
pruned from those lists, separated by priority and finally emitted into
the corresponding dynamic initialization functions.
The patch adds two flags used on the TREE_LIST nodes in those lists,
one marks the structured binding base variable and/or associated ref
extended temps, another marks the vars initialized using get methods.
The flags are preserved across the pruning, for splitting into by priority
all associated decls of a structured binding using tuple* are forced
into the same priority as the first one, and finally when actually emitting
code, CLEANUP_POINT_EXPRs are disabled in the base initializer(s) and
code from the bases and non-bases together is wrapped into a single
CLEANUP_POINT_EXPR.

2025-01-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/115769
gcc/cp/
* cp-tree.h (STATIC_INIT_DECOMP_BASE_P): Define.
(STATIC_INIT_DECOMP_NONBASE_P): Define.
* decl.cc (cp_finish_decl): Mark nodes in {static,tls}_aggregates
emitted for namespace scope structured bindings with
STATIC_INIT_DECOMP_{,NON}BASE_P flags when needed.
* decl2.cc (decomp_handle_one_var, decomp_finalize_var_list): New
functions.
(emit_partial_init_fini_fn): Use them.
(prune_vars_needing_no_initialization): Assert
STATIC_INIT_DECOMP_*BASE_P is not set on DECL_EXTERNAL vars to be
pruned out.
(partition_vars_for_init_fini): Use same priority for
consecutive STATIC_INIT_DECOMP_*BASE_P vars and propagate
those flags to new TREE_LISTs when possible.  Formatting fix.
(handle_tls_init): Use decomp_handle_one_var and
decomp_finalize_var_list functions.
gcc/testsuite/
* g++.dg/DRs/dr2867-5.C: New test.
* g++.dg/DRs/dr2867-6.C: New test.
* g++.dg/DRs/dr2867-7.C: New test.
* g++.dg/DRs/dr2867-8.C: New test.

6 months agotree-optimization/118653 - ICE in vectorizable_live_operation
Richard Biener [Mon, 27 Jan 2025 11:53:21 +0000 (12:53 +0100)] 
tree-optimization/118653 - ICE in vectorizable_live_operation

The checking code didn't take into account debug uses.

PR tree-optimization/118653
* tree-vect-loop.cc (vectorizable_live_operation): Also allow
out-of-loop debug uses.

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

6 months agolibstdc++: correct symbol version of typeinfo for bfloat16_t on RISC-V
Andreas Schwab [Tue, 21 Jan 2025 22:50:15 +0000 (23:50 +0100)] 
libstdc++: correct symbol version of typeinfo for bfloat16_t on RISC-V

RISC-V only gained support for bfloat16_t after gcc 14.  Passes
libstdc++/check_abi on {x86_64,aarch64,ppc64le,riscv64,s390x}-suse-linux.

PR libstdc++/118563
* testsuite/util/testsuite_abi.cc (check_version): Add
CXXABI_1.3.16.
* config/abi/pre/gnu.ver (CXXABI_1.3.14) [__riscv]: Exclude
typeinfo for bfloat16_t.
(CXXABI_1.3.16) [__riscv]: Add it here.

6 months agortl-optimization/118662 - wrong combination of vector sign-extends
Richard Biener [Mon, 27 Jan 2025 09:49:51 +0000 (10:49 +0100)] 
rtl-optimization/118662 - wrong combination of vector sign-extends

The following fixes an issue in the RTL combiner where we correctly
combine two vector sign-extends with a vector load

Trying 7, 9 -> 10:
    7: r106:V4QI=[r119:DI]
      REG_DEAD r119:DI
    9: r108:V4HI=sign_extend(vec_select(r106:V4QI#0,parallel))
   10: r109:V4SI=sign_extend(vec_select(r108:V4HI#0,parallel))
      REG_DEAD r108:V4HI

to

modifying insn i2     9: r109:V4SI=sign_extend([r119:DI])

but since r106 is used we wrongly materialize it using a subreg:

modifying insn i3    10: r106:V4QI=r109:V4SI#0

which of course does not work for modes with more than one component,
specifically vector and complex modes.

PR rtl-optimization/118662
* combine.cc (try_combine): When re-materializing a load
from an extended reg by a lowpart subreg make sure we're
not dealing with vector or complex modes.

* gcc.dg/torture/pr118662.c: New testcase.

6 months agomiddle-end/118643 - ICE with out-of-bound decl access
Richard Biener [Mon, 27 Jan 2025 10:28:47 +0000 (11:28 +0100)] 
middle-end/118643 - ICE with out-of-bound decl access

When RTL expansion of an out-of-bound access of a register falls
back to a BIT_FIELD_REF we have to ensure that's valid.  The
following avoids negative offsets by expanding through a stack
temporary.

PR middle-end/118643
* expr.cc (expand_expr_real_1): Avoid falling back to BIT_FIELD_REF
expansion for negative offset.

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

6 months agotree-optimization/112859 - bogus loop distribution
Richard Biener [Thu, 23 Jan 2025 12:10:17 +0000 (13:10 +0100)] 
tree-optimization/112859 - bogus loop distribution

When we get a zero distance vector we still have to check for the
situation of a common inner loop with zero distance.  But we can
still allow a zero distance for the loop we distribute
(gcc.dg/tree-ssa/ldist-33.c is such a case).  This is because
zero distances in non-outermost loops are a misrepresentation
of dependence by dependence analysis.

Note that test coverage of loop distribution of loop nests is
very low.

PR tree-optimization/112859
PR tree-optimization/115347
* tree-loop-distribution.cc
(loop_distribution::pg_add_dependence_edges): For a zero
distance vector still make sure to not have an inner
loop with zero distance.

* gcc.dg/torture/pr112859.c: New testcase.
* gcc.dg/torture/pr115347.c: Likewise.

6 months agoFortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]
Paul Thomas [Mon, 27 Jan 2025 09:55:26 +0000 (09:55 +0000)] 
Fortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]

2025-01-27  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/118640
* resolve.cc (generate_component_assignments): Make sure that
the rhs temporary does not pick up the optional attribute from
the lhs.

gcc/testsuite/
PR fortran/118640
* gfortran.dg/pr118640.f90: New test.

6 months agomatch.pd: Canonicalize unsigned division by power of two into right shift [PR118637]
Jakub Jelinek [Mon, 27 Jan 2025 09:22:28 +0000 (10:22 +0100)] 
match.pd: Canonicalize unsigned division by power of two into right shift [PR118637]

We already do this canonicalization in
simplify_using_ranges::simplify_div_or_mod_using_ranges, but that means
that it is not done at -O1 or when vrp is otherwise disabled, and that
it can be done too late in some cases when e.g. the r8-2064
"X / C1 op C2 into a simple range test." optimization triggers first.
Note, for unsigned modulo we already have
 (simplify
  (mod @0 (convert? (power_of_two_cand@1 @2)))
  (if ((TYPE_UNSIGNED (type) || tree_expr_nonnegative_p (@0))
...
optimization which duplicates what
simplify_using_ranges::simplify_div_or_mod_using_ranges
does in case ranges aren't needed.

For GCC 16 I think we should improve the niters pattern recognition
and handle even what r8-2064 comes with, after all as I've tried to show
in the PR the user could have written it that way.
I've guarded this optimization on #if GIMPLE just in case this would stand
in any way to the various divmult etc. simplification, guess that can be
lifted for GCC 16 too.  In the modulo case we also handle
unsigned % (power_of_two << n), but not really sure if we could do that
for the division, because unsigned / (power_of_two << n) is not simple
unsigned >> (log2 (power_of_two) + n), one can shift the bit out and then
it becomes just 0.

2025-01-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/118637
* match.pd: Canonicalize unsigned division by power of two to
right shift.

* gcc.dg/tree-ssa/pr118637.c: New test.

6 months agomatch.pd: Fix indefinite recursion during exp-log transformations [PR118490]
Soumya AR [Mon, 27 Jan 2025 05:42:33 +0000 (11:12 +0530)] 
match.pd: Fix indefinite recursion during exp-log transformations [PR118490]

This patch fixes the ICE caused when comparing log or exp of a constant with
another constant.

The transform is now restricted to cases where the resultant
log/exp (CST) can be constant folded.

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/ChangeLog:

PR target/118490
* match.pd: Added ! to verify that log/exp (CST) can be constant folded.

gcc/testsuite/ChangeLog:

PR target/118490
* gcc.dg/pr118490.c: New test.

6 months agoDaily bump.
GCC Administrator [Mon, 27 Jan 2025 00:17:43 +0000 (00:17 +0000)] 
Daily bump.

6 months agoFortran: In openmp.cc, uncomment unroll/tile lines of gfc_omp_directives
Tobias Burnus [Sun, 26 Jan 2025 23:35:17 +0000 (00:35 +0100)] 
Fortran: In openmp.cc, uncomment unroll/tile lines of gfc_omp_directives

Enable unroll and tile for assume's contains/absent clauses as both
directives are implemented since r15-1037-g804c0f35a6b1d7.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_omp_directives): Uncomment unroll and tile lines
as the directives are by now implemented.

6 months agomodula2: Tidyup gm2-compiler/M2GenGCC.mod:FoldConstBecomes
Gaius Mulley [Sun, 26 Jan 2025 19:49:55 +0000 (19:49 +0000)] 
modula2: Tidyup gm2-compiler/M2GenGCC.mod:FoldConstBecomes

This patch is cosmetic and removes commented out code.

gcc/m2/ChangeLog:

* gm2-compiler/M2GenGCC.mod (FoldConstBecomes): Remove
commented out code.
Improve early return comment.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoasan: Fix missing FakeStack flag cleanup
Ilya Leoshkevich [Tue, 7 Jan 2025 23:17:07 +0000 (00:17 +0100)] 
asan: Fix missing FakeStack flag cleanup

The FakeStack flag is not zeroed out when can_store_by_pieces()
returns false.  Over time, this causes FakeStack::Allocate() to perform
the maximum number of loop iterations, significantly slowing down the
instrumented program.

Link: https://inbox.sourceware.org/gcc-patches/20250109001702.154685-1-iii@linux.ibm.com/
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
gcc/ChangeLog:

* asan.cc (asan_emit_stack_protection): Always zero the flag
unless it is cleared by the __asan_stack_free_N() libcall.

6 months agoOpenMP: Fix typo in atomic directive error message
Sandra Loosemore [Sun, 26 Jan 2025 16:02:54 +0000 (16:02 +0000)] 
OpenMP: Fix typo in atomic directive error message

gcc/fortran/ChangeLog
* openmp.cc (resolve_omp_atomic): Fix typo in error message.

gcc/testsuite/ChangeLog
* gfortran.dg/gomp/atomic-26.f90: Correct expected output after
fixing typo in error message.

6 months agomodula2: comment tidyup and parameter rename
Gaius Mulley [Sun, 26 Jan 2025 15:57:56 +0000 (15:57 +0000)] 
modula2: comment tidyup and parameter rename

This patch is cosmetic it tidies up some comments, removes commented
code and renames parameters in one procedure.

gcc/m2/ChangeLog:

* gm2-compiler/M2GenGCC.mod (FoldStatementNote): Add header
comment.
(CodeStatementNote): Ditto.
(FoldRange): Tidy comment.
(CodeError): Ditto.
(CodeProcedureScope): Ditto.
(CheckConvertCoerceParameter): Replace op1 with nth.
Replace op2 with callee.
Replace op3 with actual.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoRISC-V: Make FRM as global register [PR118103]
Pan Li [Sat, 25 Jan 2025 07:45:10 +0000 (15:45 +0800)] 
RISC-V: Make FRM as global register [PR118103]

After we enabled the labe-combine pass after the mode-switching pass, it
will try to combine below insn patterns into op.  Aka:

(insn 40 5 41 2 (set (reg:SI 11 a1 [151])
  (reg:SI 69 frm)) "pr118103-simple.c":67:15 2712 {frrmsi}
  (nil))
(insn 41 40 7 2 (set (reg:SI 69 frm)
  (const_int 2 [0x2])) "pr118103-simple.c":69:8 2710 {fsrmsi_restore}
  (nil))
(insn 42 10 11 2 (set (reg:SI 69 frm)
  (reg:SI 11 a1 [151])) "pr118103-simple.c":70:8 2710 {fsrmsi_restore}
    (nil))

trying to combine definition of r11 in:
40: a1:SI=frm:SI
    into:
42: frm:SI=a1:SI
    instruction becomes a no-op:
(set (reg:SI 69 frm)
(reg:SI 69 frm))
original cost = 4 + 4 (weighted: 8.000000), replacement cost =
2147483647; keeping replacement
rescanning insn with uid = 42.
updating insn 42 in-place
verify found no changes in insn with uid = 42.
deleting insn 40

For example we have code as blow:
   9   â”‚ int test_exampe () {
  10   â”‚   test ();
  11   â”‚
  12   â”‚   size_t vl = 4;
  13   â”‚   vfloat16m1_t va = __riscv_vle16_v_f16m1(a, vl);
  14   â”‚   va = __riscv_vfnmadd_vv_f16m1_rm(va, va, va, __RISCV_FRM_RDN, vl);
  15   â”‚   va = __riscv_vfmsac_vv_f16m1(va, va, va, vl);
  16   â”‚
  17   â”‚   __riscv_vse16_v_f16m1(b, va, vl);
  18   â”‚
  19   â”‚   return 0;
  20   â”‚ }

it will be compiled to:
  53   â”‚ main:
  54   â”‚     addi    sp,sp,-16
  55   â”‚     sd  ra,8(sp)
  56   â”‚     call    initialize
  57   â”‚     lui a6,%hi(b)
  58   â”‚     lui a2,%hi(a)
  59   â”‚     addi    a3,a6,%lo(b)
  60   â”‚     addi    a2,a2,%lo(a)
  61   â”‚     li  a4,4
  62   â”‚ .L8:
  63   â”‚     fsrmi   2
  64   â”‚     vsetvli a5,a4,e16,m1,ta,ma
  65   â”‚     vle16.v v1,0(a2)
  66   â”‚     slli    a1,a5,1
  67   â”‚     subw    a4,a4,a5
  68   â”‚     add a2,a2,a1
  69   â”‚     vfnmadd.vv  v1,v1,v1
  >> The fsrm a0 insn is deleted by late-combine <<
  70   â”‚     vfmsub.vv   v1,v1,v1
  71   â”‚     vse16.v v1,0(a3)
  72   â”‚     add a3,a3,a1
  73   â”‚     bgt a4,zero,.L8
  74   â”‚     lh  a4,%lo(b)(a6)
  75   â”‚     li  a5,-20480
  76   â”‚     addi    a5,a5,-1382
  77   â”‚     bne a4,a5,.L14
  78   â”‚     ld  ra,8(sp)
  79   â”‚     li  a0,0
  80   â”‚     addi    sp,sp,16
  81   â”‚     jr  ra

This patch would like to add the FRM register to the global_regs as it
is a cooperatively-managed global register.  And then the fsrm insn will
not be eliminated by late-combine.  The related spec17 cam4 failure may
also caused by this issue too.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

PR target/118103

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_conditional_register_usage): Add
the FRM as the global_regs.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr118103-1.c: New test.
* gcc.target/riscv/rvv/base/pr118103-run-1.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoDaily bump.
GCC Administrator [Sun, 26 Jan 2025 00:16:49 +0000 (00:16 +0000)] 
Daily bump.

6 months ago[PR modula2/118010, modula2/118183] Rebuild bootstrap tools with lseek fix
Gaius Mulley [Sat, 25 Jan 2025 20:30:02 +0000 (20:30 +0000)] 
[PR modula2/118010, modula2/118183] Rebuild bootstrap tools with lseek fix

This patch rebuilds the bootstrap tools mc and pge incorporating the fix to
libc.lseek.  The tool mc is changed to omit INCLUDE_MEMORY from
checkGccConfigSystem.  The pge tool on rebuild now requires
--gcc-config-system to pick up the system.h containing INCLUDE_MEMORY.
After rebuild all local INCLUDE_MEMORY definitions disappear.

gcc/m2/ChangeLog:

PR modula2/117737
PR modula2/118010
* Make-maintainer.in (PGE-MC-OPTIONS): New macro.
(m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o): Use $(PGE-MC-OPTIONS).
(m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)Output.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)pge.o): Ditto.
(m2/gm2-auto/pg.o): Ditto.
(m2/gm2-auto/pge.o): Ditto.
(mc-autogen): Add include directory $(GMPINC) to $(CXX).
* mc/keyc.mod (checkGccConfigSystem): Remove
INCLUDE_MEMORY define.
* mc-boot/GASCII.cc (INCLUDE_MEMORY): Removed during rebuild.
* mc-boot/GASCII.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GArgs.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GArgs.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GAssertion.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GAssertion.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GBreak.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GBreak.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GCOROUTINES.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GCmdArgs.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GCmdArgs.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GDebug.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GDebug.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GDynamicStrings.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GDynamicStrings.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GEnvironment.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GEnvironment.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GFIO.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GFIO.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GFormatStrings.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GFormatStrings.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GFpuIO.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GFpuIO.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GIO.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GIO.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GIndexing.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GIndexing.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GM2Dependent.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GM2Dependent.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GM2EXCEPTION.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GM2EXCEPTION.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GM2RTS.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GM2RTS.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GMemUtils.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GMemUtils.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GNumberIO.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GNumberIO.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GPushBackInput.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GPushBackInput.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GRTExceptions.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GRTExceptions.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GRTco.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GRTentity.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GRTint.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GRTint.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GSArgs.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GSArgs.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GSFIO.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GSFIO.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GSYSTEM.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GSelective.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GStdIO.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GStdIO.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GStorage.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GStorage.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GStrCase.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GStrCase.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GStrIO.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GStrIO.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GStrLib.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GStrLib.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GStringConvert.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GStringConvert.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GSysExceptions.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GSysStorage.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GSysStorage.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GTimeString.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GTimeString.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GUnixArgs.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Galists.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Galists.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gdecl.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gdecl.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gdtoa.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gerrno.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gkeyc.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gkeyc.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gldtoa.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Glibc.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Glibm.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Glists.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Glists.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcComment.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcComment.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcComp.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcComp.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcDebug.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcDebug.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcError.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcError.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcFileName.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcFileName.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcLexBuf.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcLexBuf.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcMetaError.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcMetaError.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcOptions.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcOptions.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcPreprocess.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcPreprocess.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcPretty.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcPretty.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcPrintf.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcPrintf.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcQuiet.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcQuiet.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcReserved.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcReserved.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcSearch.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcSearch.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcStack.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcStack.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcStream.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GmcStream.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcflex.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp1.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp1.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp2.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp2.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp3.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp3.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp4.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp4.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp5.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gmcp5.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GnameKey.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GnameKey.h (INCLUDE_MEMORY): Ditto.
* mc-boot/GsymbolKey.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/GsymbolKey.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gtermios.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gtop.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gvarargs.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gvarargs.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gwlists.cc (INCLUDE_MEMORY): Ditto.
* mc-boot/Gwlists.h (INCLUDE_MEMORY): Ditto.
* mc-boot/Gwrapc.h (INCLUDE_MEMORY): Ditto.
* pge-boot/GIndexing.h (INCLUDE_MEMORY): Ditto.
* pge-boot/GSEnvironment.h (INCLUDE_MEMORY): Ditto.
* pge-boot/GScan.h (INCLUDE_MEMORY): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoFortran: fix issues with variables in BLOCK DATA [PR58857]
Harald Anlauf [Sat, 25 Jan 2025 18:59:56 +0000 (19:59 +0100)] 
Fortran: fix issues with variables in BLOCK DATA [PR58857]

PR fortran/58857

gcc/fortran/ChangeLog:

* class.cc (gfc_find_derived_vtab): Declare some frontend generated
variables and procedures (_vtab, _copy, _deallocate) as artificial.
(find_intrinsic_vtab): Likewise.
* trans-decl.cc (check_block_data_decls): New helper function.
(gfc_generate_block_data): Use it to emit warnings for variables
declared in a BLOCK DATA program unit but not in a COMMON block.

gcc/testsuite/ChangeLog:

* gfortran.dg/uncommon_block_data_2.f90: New test.

6 months agoMove ferror out of hot loop of file cache
Andi Kleen [Thu, 26 Dec 2024 04:21:58 +0000 (20:21 -0800)] 
Move ferror out of hot loop of file cache

glibc ferror is surprisingly expensive. Move it out of the hot loop
of finding lines by setting a flag after the actual IO operations.

gcc/ChangeLog:

PR preprocessor/118168
* input.cc (file_cache_slot::m_error): New field.
(file_cache_slot::create): Clear m_error.
(file_cache_slot::file_cache_slot): Clear m_error.
(file_cache_slot::read_data): Set m_error on error.
(file_cache_slot::get_next_line): Use m_error instead of ferror.

6 months agoPR modula2/118010 libc.def lseek procedure off_t bugfix
Gaius Mulley [Sat, 25 Jan 2025 18:22:35 +0000 (18:22 +0000)] 
PR modula2/118010 libc.def lseek procedure off_t bugfix

This patch fixes calls to lseek from m2 sources.  The new data
type SYSTEM.COFF_T is used instead of SYSTEM.CCSIZE_T.

gcc/m2/ChangeLog:

PR modula2/118010
* gm2-libs-log/FileSystem.mod (doModeChange): Replace
LONGINT with COFF_T.
(SetPos): Use COFF_T for the return value and offset type
when calling lseek.
* gm2-libs/FIO.mod (SetPositionFromBeginning): Convert pos
to COFF_T.
(SetPositionFromEnd): Ditto.
* mc-boot/GFIO.cc: Rebuild.
* mc-boot/Glibc.h: Ditto.
* pge-boot/GFIO.cc: Ditto.
* pge-boot/Glibc.h: Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoc++: Reinstate check for uninitialized bases with c++ <= 17 [PR118239]
Simon Martin [Sat, 25 Jan 2025 17:09:23 +0000 (18:09 +0100)] 
c++: Reinstate check for uninitialized bases with c++ <= 17 [PR118239]

We currently accept this code with c++ <= 17 even though it's invalid
since the base is not initialized (we properly reject it with c++ >= 20)

=== cut here ===
struct NoMut1 { int a, b; };
struct NoMut3 : NoMut1 {
  constexpr NoMut3(int a, int b) {}
};
void mutable_subobjects() {
  constexpr NoMut3 nm3(1, 2);
}
=== cut here ===

This is a fallout of r0-118700-gc2b3ec18a494e3, that ignores all fields
with DECL_ARTIFICIAL in cx_check_missing_mem_inits, including those that
represent base classes, and need to be checked.

This patch makes sure that we only skip fields that have DECL_ARTIFICIAL
if they don't have DECL_FIELD_IS_BASE.

PR c++/118239

gcc/cp/ChangeLog:

* constexpr.cc (cx_check_missing_mem_inits): Don't skip fields
with DECL_FIELD_IS_BASE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-base8.C: New test.

6 months ago[RISC-V][PR target/116256] Improve handling of single bit constants
Jeff Law [Sat, 25 Jan 2025 16:42:19 +0000 (09:42 -0700)] 
[RISC-V][PR target/116256] Improve handling of single bit constants

So under the umbrella of pr116256 (P3 regression) I've been exploring removal
of the mvconst_internal pattern.   Not surprisingly, that's going to cause all
kinds of undesirable fallout.  While I can kind of see a path forward for that
work, it's going to require some combine work that I don't think we want to
tackle in the context of gcc-15.

Essentially without mvconst_internal we'll have fully exposed constant
synthesis prior to combine.  Remember that combine has limits on what
combinations it will perform based on how many instructions are in the source
sequence.  If we need 2+ instructions to synthesize the constant, those eat
into our budget.

In a world without mvconst_internal we'd need to either improve combine to
handle 5 insns cases (which do show up in the testsuite) or we need to
significantly improve how combine handles REG_EQUAL notes.  5 insn combinations
sound like insanity to me.  So I'd tend to lean towards the latter, though
that's going to need some refactoring and diving into note redistribution
(ugh!).

In the mean time we can start limiting mvconst_internal.  For the remaining
case in pr116256 we have this code in combine:

> (insn 8 5 10 2 (set (reg:V2048HF 138 [ _5 ])
>         (vec_duplicate:V2048HF (reg:HF 142 [ x ]))) "j.c":152:11 3712 {*vec_duplicatev2048hf}
>      (expr_list:REG_DEAD (reg:HF 142 [ x ])
>         (nil)))
> (insn 10 8 11 2 (set (reg:DI 139)
>         (const_int 2048 [0x800])) "j.c":152:11 275 {*mvconst_internal}
>      (nil))      (insn 11 10 0 2 (set (mem:V2048HF (reg/f:DI 141 [ in ]) [1 MEM <vector(2048) _Float16> [(_Float16 *)in_7(D)]+0 S4096 A128])
>         (if_then_else:V2048HF (unspec:V2048BI [
>                     (const_vector:V2048BI [
>                             (const_int 1 [0x1]) repeated x2048
>                         ])
>                     (reg:DI 139)
>                     (const_int 2 [0x2]) repeated x3
>                     (reg:SI 66 vl)
>                     (reg:SI 67 vtype)
>                 ] UNSPEC_VPREDICATE)
>             (reg:V2048HF 138 [ _5 ])
>             (unspec:V2048HF [
>                     (reg:DI 0 zero)
>                 ] UNSPEC_VUNDEF))) "j.c":152:11 3843 {*pred_movv2048hf}
>      (expr_list:REG_DEAD (reg/f:DI 141 [ in ])
>         (expr_list:REG_DEAD (reg:DI 0 zero)
>             (expr_list:REG_DEAD (reg:SI 66 vl)
>                 (expr_list:REG_DEAD (reg:SI 67 vtype)
>                     (expr_list:REG_DEAD (reg:V2048HF 138 [ _5 ])
>                         (expr_list:REG_DEAD (reg:DI 139)
>                             (nil))))))))

Note a couple things.  First insn 8 will be split shortly after combine and
will need the constant 2048.  But that's obviously exposed  late. Second (of
course) is the mvconst_internal pattern at insn 10.  After split1 we'll have:

> (insn 16 5 17 2 (set (reg:DI 144)         (const_int 4096 [0x1000])) "j.c":152:11 -1
>      (nil))
> (insn 17 16 18 2 (set (reg:DI 143)
>         (plus:DI (reg:DI 144)
>             (const_int -2048 [0xfffffffffffff800]))) "j.c":152:11 -1
>      (expr_list:REG_EQUAL (const_int 2048 [0x800])
>         (nil)))
> (insn 18 17 19 2 (set (reg:V2048HF 138 [ _5 ])
>         (if_then_else:V2048HF (unspec:V2048BI [                     (const_vector:V2048BI [
>                             (const_int 1 [0x1]) repeated x2048
>                         ])
>                     (reg:DI 143)
>                     (const_int 2 [0x2]) repeated x3
>                     (reg:SI 66 vl)
>                     (reg:SI 67 vtype)
>                 ] UNSPEC_VPREDICATE)
>             (vec_duplicate:V2048HF (reg:HF 142 [ x ]))
>             (unspec:V2048HF [                     (reg:DI 0 zero)
>                 ] UNSPEC_VUNDEF))) "j.c":152:11 -1
>      (nil))
> (insn 19 18 20 2 (set (reg:DI 145)
>         (const_int 4096 [0x1000])) "j.c":152:11 -1
>      (nil))
> (insn 20 19 11 2 (set (reg:DI 139)
>         (plus:DI (reg:DI 145)
>             (const_int -2048 [0xfffffffffffff800]))) "j.c":152:11 -1
>      (expr_list:REG_EQUAL (const_int 2048 [0x800])
>         (nil)))
> (insn 11 20 0 2 (set (mem:V2048HF (reg/f:DI 141 [ in ]) [1 MEM <vector(2048) _Float16> [(_Float16 *)in_7(D)]+0 S4096 A128])
>         (if_then_else:V2048HF (unspec:V2048BI [
>                     (const_vector:V2048BI [
>                             (const_int 1 [0x1]) repeated x2048
>                         ])
>                     (reg:DI 139)                     (const_int 2 [0x2]) repeated x3
>                     (reg:SI 66 vl)
>                     (reg:SI 67 vtype)
>                 ] UNSPEC_VPREDICATE)
>             (reg:V2048HF 138 [ _5 ])
>             (unspec:V2048HF [                     (reg:DI 0 zero)
>                 ] UNSPEC_VUNDEF))) "j.c":152:11 3843 {*pred_movv2048hf}
>      (expr_list:REG_DEAD (reg/f:DI 141 [ in ])
>         (expr_list:REG_DEAD (reg:DI 0 zero)             (expr_list:REG_DEAD (reg:SI 66 vl)
>                 (expr_list:REG_DEAD (reg:SI 67 vtype)
>                     (expr_list:REG_DEAD (reg:V2048HF 138 [ _5 ])
>                         (expr_list:REG_DEAD (reg:DI 139)
>                             (nil))))))))
Note the synthesis of 2048 appears twice.  I seriously considered adding a
local cprop pass at this point.  That could be done with a bit of work.  It
didn't look too bad -- the biggest problem is cprop isn't designed to run once
we've left cfglayout.  But we could probably finesse that by not allowing it to
change jumps if we've left cfglayout or converting it to do the more complex
jump fixups.

You might ask why the post-reload optimizers don't help since this at least
looks like a case where they could.  After LRA the RTL looks like:

> (insn 26 5 25 2 (set (reg:DI 15 a5 [144])
>         (const_int 4096 [0x1000])) "/home/jlaw/test/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/dup-1.c":152:11 277 {*movdi_64bit}      (expr_list:REG_EQUIV (const_int 4096 [0x1000])
>         (nil)))
> (insn 25 26 19 2 (set (reg:DI 15 a5 [143])
>         (plus:DI (reg:DI 15 a5 [144])
>             (const_int -2048 [0xfffffffffffff800]))) "/home/jlaw/test/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/dup-1.c":152:11 5 {adddi3}
>      (expr_list:REG_EQUIV (const_int 2048 [0x800])
>         (nil)))
> (insn 19 25 20 2 (set (reg:V2048QI 100 v4 [orig:138 _11 ] [138])
>         (if_then_else:V2048QI (unspec:V2048BI [
>                     (const_vector:V2048BI [
>                             (const_int 1 [0x1]) repeated x2048
>                         ])
>                     (reg:DI 15 a5 [143])
>                     (const_int 2 [0x2]) repeated x3
>                     (reg:SI 66 vl)
>                     (reg:SI 67 vtype)
>                 ] UNSPEC_VPREDICATE)
>             (vec_duplicate:V2048QI (reg:QI 12 a2 [145]))
>             (unspec:V2048QI [                     (reg:DI 0 zero)
>                 ] UNSPEC_VUNDEF))) "/home/jlaw/test/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/dup-1.c":152:11 4172 {*pred_broadcastv2048qi}
>      (nil)) (insn 20 19 21 2 (set (reg:DI 15 a5 [146])
>         (const_int 4096 [0x1000])) "/home/jlaw/test/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/dup-1.c":152:11 277 {*movdi_64bit}       (expr_list:REG_EQUIV (const_int 4096 [0x1000])
>         (nil)))
> (insn 21 20 11 2 (set (reg:DI 15 a5 [139])
>         (plus:DI (reg:DI 15 a5 [146])
>             (const_int -2048 [0xfffffffffffff800]))) "/home/jlaw/test/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/dup-1.c":152:11 5 {adddi3}
>      (expr_list:REG_EQUIV (const_int 2048 [0x800])
>         (nil)))

Note the re-use of a5 for the constant synthesis steps.  That's going to spoil
any chance of reload_cse saving us.  That re-use also gets in the way of vsetvl
elimination and we ultimately get this code:

> foo10:
>         li      a5,4096
>         addi    a5,a5,-2048
>         vsetvli zero,a5,e16,m8,ta,ma
>         vfmv.v.f        v8,fa0
>         li      a5,4096
>         addi    a5,a5,-2048
>         vsetvli zero,a5,e16,m8,ta,ma
>         vse16.v v8,0(a0)
>         ret
The regression is we have the obviously redundant vsetvl.  The additional copy
of the synthesis is undesirable as well.

If we filter out single bit constants from mvconst_internal we trivially fix
that regression.  The only fallout is a class of saturation tests which want to
test against 0x80000000.   Under the hood this is a minor codegen issue
interacting badly with combine's deliberate rejection of simplification of
extensions of constants.  Rather than constructing the SImode constant, then
zero extending the result we can just generate the constant we actually want
directly in DImode.

The net is we fix the regression, don't introduce any obvious new regressions
and slightly reduce our dependence on mvconst_internal.  All good in my book.
Obviously I'll wait for pre-commit CI to render a verdict.

PR target/116256
gcc/
* config/riscv/riscv.md (mvconst_internal): Reject single bit
constants.
* config/riscv/riscv.cc (riscv_gen_zero_extend_rtx): Improve
handling constants.

6 months agoc: Diagnose ,) at the end of OpenMP clauses [PR118639]
Jakub Jelinek [Sat, 25 Jan 2025 09:28:23 +0000 (10:28 +0100)] 
c: Diagnose ,) at the end of OpenMP clauses [PR118639]

This is something the C++ FE has been diagnosing but C FE only
complained if there wasn't an identifier right after opening (

2025-01-25  Jakub Jelinek  <jakub@redhat.com>

PR c/118639
* c-parser.cc (c_parser_omp_variable_list): Remove first variable
and emit "expected identifier" error regardless of it.

* c-c++-common/gomp/pr118639.c: New test.
* c-c++-common/goacc/cache-2.c: Remove one xfail for c.

6 months agoc++: Only destruct elts of array for new expression if exception is thrown during...
Jakub Jelinek [Sat, 25 Jan 2025 09:15:24 +0000 (10:15 +0100)] 
c++: Only destruct elts of array for new expression if exception is thrown during the initialization [PR117827]

The following testcase r12-6328, because the elements of the array
are destructed twice, once when the callee encounters delete[] p;
and then second time when the exception is thrown.
The array elts should be only destructed if exception is thrown from
one of the constructors during the build_vec_init emitted code in case of
new expressions, but when the new expression completes, it is IMO
responsibility of user code to delete[] it when it is no longer needed.

So, the following patch uses the cleanup_flags argument to build_vec_init
to get notified of the flags that need to be changed when the expression
is complete and build_disable_temp_cleanup to do the changes.

2025-01-25  Jakub Jelinek  <jakub@redhat.com>

PR c++/117827
* init.cc (build_new_1): Pass address of a make_tree_vector ()
initialized gc tree vector to build_vec_init and append
build_disable_temp_cleanup to init_expr from it.

* g++.dg/init/array66.C: New test.

6 months agoPR modula2/118010 m2 libc lseek procedure interface correction
Gaius Mulley [Sat, 25 Jan 2025 02:28:13 +0000 (02:28 +0000)] 
PR modula2/118010 m2 libc lseek procedure interface correction

This patch corrects a typo in the definition of lseek in libc.
The second offset parameter should have been declared as COFF_T.
No errors are seen when bootstrapping using -Werror=odr
-Werror=lto-type-mismatch.

gcc/m2/ChangeLog:

PR modula2/118010
* gm2-compiler/P2SymBuild.mod (Debug): Comment out unused
procedure.
* gm2-libs/libc.def (lseek): Declare second parameter offset
as COFF_T.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoc++/modules: Treat unattached lambdas as TU-local [PR116568]
Nathaniel Shead [Sun, 5 Jan 2025 12:01:44 +0000 (23:01 +1100)] 
c++/modules: Treat unattached lambdas as TU-local [PR116568]

This fixes ICEs where unattached lambdas at class scope (for instance,
in member template instantiations) are streamed.  This is only possible
in header units, as in named modules attempting to stream such lambdas
will be an error.

PR c++/116568

gcc/cp/ChangeLog:

* module.cc (trees_out::get_merge_kind): Treat all lambdas
without a mangling scope as un-mergeable.

gcc/testsuite/ChangeLog:

* g++.dg/modules/lambda-8.h: New test.
* g++.dg/modules/lambda-8_a.H: New test.
* g++.dg/modules/lambda-8_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
6 months agoc++/modules: Diagnose TU-local lambdas, give mangling scope to lambdas in concepts
Nathaniel Shead [Sun, 5 Jan 2025 12:45:05 +0000 (23:45 +1100)] 
c++/modules: Diagnose TU-local lambdas, give mangling scope to lambdas in concepts

This fills in a hole left in r15-6378-g9016c5ac94c557 with regards to
detection of TU-local lambdas.  Now that LAMBDA_EXPR_EXTRA_SCOPE is
properly set for most lambdas we can use it to detect lambdas that are
TU-local.

CWG2988 suggests that lambdas in concept definitions should not be
considered TU-local, since they are always unevaluated and should never
be emitted. This patch gives these lambdas a mangling scope (though it
will never be actually used in name mangling).

PR c++/116568

gcc/cp/ChangeLog:

* cp-tree.h (finish_concept_definition): Adjust parameters.
(start_concept_definition): Declare.
* module.cc (depset::hash::is_tu_local_entity): Use
LAMBDA_EXPR_EXTRA_SCOPE to detect TU-local lambdas.
* parser.cc (cp_parser_concept_definition): Start a lambda scope
for concept definitions.
* pt.cc (tsubst_lambda_expr): Namespace-scope lambdas may now
have extra scope.
(finish_concept_definition): Split into...
(start_concept_definition): ...this new function.

gcc/testsuite/ChangeLog:

* g++.dg/modules/internal-4_b.C: Remove XFAIL, add lambda alias
testcase.
* g++.dg/modules/lambda-9.h: New test.
* g++.dg/modules/lambda-9_a.H: New test.
* g++.dg/modules/lambda-9_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
6 months agoc++: Fix mangling of otherwise unattached class-scope lambdas [PR118245]
Nathaniel Shead [Thu, 23 Jan 2025 08:22:04 +0000 (19:22 +1100)] 
c++: Fix mangling of otherwise unattached class-scope lambdas [PR118245]

This is a step closer to implementing the suggested changes for
https://github.com/itanium-cxx-abi/cxx-abi/pull/85.  Most lambdas
defined within a class should have an extra scope of that class so that
uses across different TUs are properly merged by the linker.  This also
needs to happen during template instantiation.

While I was working on this I found some other cases where the mangling
of lambdas was incorrect and causing issues, notably the testcase
lambda-ctx3.C which currently emits the same mangling for the base class
and member lambdas, causing mysterious assembler errors since r14-9232.

One notable case not handled either here or in the ABI is what is
supposed to happen with such unattached lambdas declared in member
templates; see lambda-uneval22.  I believe that by the C++ standard,
such lambdas should also dedup across TUs, but this isn't currently
implemented, and it's not clear exactly how such lambdas should mangle.

Since this should only affect usage of lambdas in unevaluated contexts
(a C++20 feature) this patch does not add an ABI flag to control this
behaviour.

PR c++/118245

gcc/cp/ChangeLog:

* cp-tree.h (LAMBDA_EXPR_EXTRA_SCOPE): Adjust comment.
* parser.cc (cp_parser_class_head): Start (and do not finish)
lambda scope for all valid types.
(cp_parser_class_specifier): Finish lambda scope after parsing
members instead.
* pt.cc (instantiate_class_template): Add lambda scoping.

gcc/testsuite/ChangeLog:

* g++.dg/abi/lambda-ctx3.C: New test.
* g++.dg/cpp2a/lambda-uneval22.C: New test.
* g++.dg/cpp2a/lambda-uneval23.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
6 months agoDaily bump.
GCC Administrator [Sat, 25 Jan 2025 00:17:46 +0000 (00:17 +0000)] 
Daily bump.

6 months agoPR modula2/118589 Opaque type fields are visible outside implementation module
Gaius Mulley [Sat, 25 Jan 2025 00:05:48 +0000 (00:05 +0000)] 
PR modula2/118589 Opaque type fields are visible outside implementation module

This patch fixes a bug shown when a variable declared as an opaque type is
dereferenced outside the declaration module.  The fix also improves error
recovery.  In the error cases it ensures that an error symbol is created
and the appropriate virtual token is assigned.  Finally there is a new
testsuite directory gm2.dg which contains tests to check against expected
error messages.

gcc/m2/ChangeLog:

PR modula2/118589
* gm2-compiler/M2MetaError.mod (symDesc): Add opaque type
description.
* gm2-compiler/M2Quads.mod (BuildDesignatorPointerError): New
procedure.
(BuildDesignatorPointer): Reimplement.
* gm2-compiler/P3Build.bnf (SubDesignator): Tidy up error message.
Use MetaErrorT2 rather than WriteForma1 and use the token pos from
the quad stack.

gcc/testsuite/ChangeLog:

PR modula2/118589
* lib/gm2-dg.exp (gm2.exp): load_lib.
* gm2.dg/pim/fail/badopaque.mod: New test.
* gm2.dg/pim/fail/badopaque2.mod: New test.
* gm2.dg/pim/fail/dg-pim-fail.exp: New test.
* gm2.dg/pim/fail/opaquedefs.def: New test.
* gm2.dg/pim/fail/opaquedefs.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoaarch64: Add +cpa feature flag
Andrew Carlotti [Fri, 24 Jan 2025 11:00:41 +0000 (11:00 +0000)] 
aarch64: Add +cpa feature flag

This doesn't enable anything within the compiler, but this allows the
flag to be passed the assembler.  There also doesn't appear to be a
kernel cpuinfo name yet.

gcc/ChangeLog:

* config/aarch64/aarch64-arches.def (V9_5A): Add CPA.
* config/aarch64/aarch64-option-extensions.def (CPA): New.
* doc/invoke.texi: Document +cpa.

6 months agodocs: Add +wfxt and +xs to armv9.2-a
Andrew Carlotti [Fri, 10 Jan 2025 19:22:20 +0000 (19:22 +0000)] 
docs: Add +wfxt and +xs to armv9.2-a

I missed that the documentation doesn't include armv8.7-a
within armv9.2-a.

gcc/ChangeLog:

* doc/invoke.texi: Add +wfxt and +xs to armv9.2-a

6 months agoaarch64: Add command line support for armv9.5-a
Andrew Carlotti [Fri, 10 Jan 2025 19:19:19 +0000 (19:19 +0000)] 
aarch64: Add command line support for armv9.5-a

gcc/ChangeLog:

* config/aarch64/aarch64-arches.def (V9_5A): New.
* doc/invoke.texi: Document armv9.5-a option.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/simd/armv9p5.c: New test.

6 months agoaarch64: Make AARCH64_FL_CRYPTO always unset
Andrew Carlotti [Thu, 9 Jan 2025 19:33:25 +0000 (19:33 +0000)] 
aarch64: Make AARCH64_FL_CRYPTO always unset

This feature flag bit only exists to support the +crypto alias.  Outside
of option processing this bit needs to be set or unset consistently.
This patch goes with the latter option.

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc: Assert that CRYPTO
bit is not set.
* config/aarch64/aarch64-feature-deps.h
(info<FEAT>.explicit_on): Unset CRYPTO bit.
(cpu_##CORE_IDENT): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/crypto-alias-1.c: New test.

6 months agoaarch64: Refactor aarch64_rewrite_mcpu
Andrew Carlotti [Thu, 23 Jan 2025 19:07:09 +0000 (19:07 +0000)] 
aarch64: Refactor aarch64_rewrite_mcpu

Use aarch64_validate_cpu instead of the existing duplicate (and worse)
version of the -mcpu parsing code.

The original code used fatal_error; I'm guessing that using error
instead should be ok.

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc
(aarch64_rewrite_selected_cpu): Refactor and inline into...
(aarch64_rewrite_mcpu): this.
* config/aarch64/aarch64-protos.h
(aarch64_rewrite_selected_cpu): Delete.