]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
5 weeks agotestsuite: Remove debugging puts from check_profiling_available
Uros Bizjak [Thu, 14 May 2026 20:55:13 +0000 (22:55 +0200)] 
testsuite: Remove debugging puts from check_profiling_available

Remove a stray debugging puts and an unused global declaration from
check_profiling_available. Neither affects the AutoFDO availability
check, as the wrapper path is already computed by profopt-perf-wrapper.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_profiling_available): Remove
unused global declaration and debugging output.

5 weeks agoc++/reflection: undeduced auto, deferred noexcept [PR124628]
Patrick Palka [Thu, 14 May 2026 18:53:06 +0000 (14:53 -0400)] 
c++/reflection: undeduced auto, deferred noexcept [PR124628]

Various reflection queries reject functions (or variables) with an
undeduced return type.  But this assumes return type deduction has
already been attempted which is not the case if the function is a
specialization that has not yet been ODR-used or otherwise instantiated,
which we must do now.  Similarly a function can also have an deferred
noexcept-specification which we should also instantiate at this point.

Rather an inventing a new way to resolve the type of such a function
or variable for reflection purposes, I think we can just silently call
mark_used in an unevaluated context, which will behave similarly to
requires { &decl; }.  Since diagnostics (in the immediate context) get
suppressed, we'll gracefully handle deleted functions or those with
unsatisfied constraints, leaving it up to the caller to handle them.

PR c++/124628

gcc/cp/ChangeLog:

* reflect.cc (resolve_type_of_reflected_decl): New.
(get_reflection): Call resolve_type_of_reflected_decl instead
of mark_used.
(has_type): Call resolve_type_of_reflected_decl before
checking for an undeduced auto.
(eval_can_substitute): Likewise.  Also look through BASELINK.
(members_of_representable): Call resolve_type_of_reflected_decl
before checking for an undeduced auto.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/can_substitute2.C: New test.
* g++.dg/reflect/members_of14.C: New test.
* g++.dg/reflect/substitute3.C: Adjust test so that f<int>'s
return type fails to get deduced.
* g++.dg/reflect/type_of3.C: Also test type_of of a templated
member function with deduced return type.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Marek Polacek <polacek@redhat.com>
5 weeks agoPR124316: Fix ptwrite assembler mode
Andi Kleen [Wed, 13 May 2026 23:40:16 +0000 (16:40 -0700)] 
PR124316: Fix ptwrite assembler mode

Add explicit assembler mode for cases when the argument is not
unambigious. This avoids cases where a user specified 64bit ptwrite
ends up being 32bit due to an ambigious argument.

PR target/124316

gcc/ChangeLog:

* config/i386/i386.md (ptwrite): Add explicit mode to
instruction.

gcc/testsuite/ChangeLog:

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

5 weeks agoOpenMP: mapper [C/C++] reject w/o map usage, reject C++98, fix map decay
Tobias Burnus [Thu, 14 May 2026 16:23:57 +0000 (18:23 +0200)] 
OpenMP: mapper [C/C++] reject w/o map usage, reject C++98, fix map decay

This commit adds a check for the following 'declare mapper restriction:
"At least one map clause that maps var or at least one element of var is
 required."

It additionally fixes a bug in the map-decay code, which did not handle
map modifiers like 'always' when specified in the declare mapper's map
clause.

For C++, some checks are now also run when templates are involved.
Additionally, it turned out that the internal use of constexpr caused
bogus errors when compiled with -std=c++98; therefore, a sorry is now
shown. Solution is to use -std=c++11 or higher.

gcc/c-family/ChangeLog:

* c-omp.cc (omp_map_decayed_kind): Handle map modifiers
also for declare-mapper's map clauses.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_declare_mapper): Check that the
struct var is actually used by at least one map clause.

gcc/cp/ChangeLog:

* semantics.cc (cp_check_omp_declare_mapper): Change what
argument is expected; check that the struct var is used by at
least one map war. Print sorry when compiling with -std=c++98.
* pt.cc (tsubst_stmt, tsubst_expr): Call it.
* parser.cc (cp_parser_omp_declare_mapper): Update call.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/declare-mapper-10.c: Exclude C++98.
* c-c++-common/gomp/declare-mapper-15.c: Likewise.
* c-c++-common/gomp/declare-mapper-16.c: Likewise.
* c-c++-common/gomp/declare-mapper-3.c: Likewise.
* c-c++-common/gomp/declare-mapper-4.c: Likewise.
* c-c++-common/gomp/declare-mapper-5.c: Likewise.
* c-c++-common/gomp/declare-mapper-6.c: Likewise.
* c-c++-common/gomp/declare-mapper-7.c: Likewise.
* c-c++-common/gomp/declare-mapper-8.c: Likewise.
* c-c++-common/gomp/declare-mapper-9.c: Likewise.
* g++.dg/gomp/declare-mapper-1.C: Likewise.
* g++.dg/gomp/declare-mapper-2.C: Likewise.
* c-c++-common/gomp/pr122866.c: Expect sorry with C++98.
* c-c++-common/gomp/declare-mapper-11.c: Likewise.
Add dg-error for missing var-in-map-clause use.
* g++.dg/gomp/declare-mapper-3.C: Likewise.
* c-c++-common/gomp/declare-mapper-17.c: New test.
* c-c++-common/gomp/declare-mapper-18.c: New test.
* g++.dg/gomp/declare-mapper-4.C: New test.
* g++.dg/gomp/declare-mapper-5.C: New test.

5 weeks agoPR fortran/125092 - implement for binding label argument mismatch.
Thomas Koenig [Thu, 14 May 2026 14:59:11 +0000 (16:59 +0200)] 
PR fortran/125092 - implement for binding label argument mismatch.

This patch implements some checks on different interfaces to the same
C binding functions. It contains a few policy changes, and is somewhat
more permissive than the standard, but there are no constraint
violations (to my knowledge) that it misses.

Apart from checking for standards conformance, this should also
help proof code against (now or future) type-based aliasing mishaps.

Checks for global identifiers are performed on a case-insensitive
basis by default, and only sensitive when -pedantic is in force.
This makes sense if Fortran code wants to interface to "FOO" and
"foo".  The restriction to case-insensitive labels comes from a time
when relevant systems had linkers which were case-insensitive, and
it is not possible to implement C (especially the C versions referenced
in the standard) with such a linker.

Return types of functions, ranks, number, type and rank of arguments
are checked. In non-pedantic mode, arguments which have the same
prototype on the C side are permitted, for example passing a scalar
or an array by reference, or arrays of different rank (both for pass
by reference and pass by descriptors). Assumed types are also
assumed to bee OK. This functionality was checked in a few test
cases, so it would make little sense to remove it.

C_PTR is *not* compatible with a random argument passed by reference.
For example, a TYPE(C_PTR), VALUE argument is not compatible
with an INTEGER argument (without VALUE); C_LOC has to be used.

The one-liner in decl.cc may fix some ENTRY problems, I didn't check.

gcc/fortran/ChangeLog:

PR fortran/125092
* decl.cc (add_global_entry): Use string from the heap instead
of a pointer to stack-allocated memory.
* frontend-passes.cc (check_against_globals): If there is an error
already, return early.
* gfortran.h (gfc_symbol_rank): New prototype.
* interface.cc (symbol_rank): Rename to
(gfc_symbol_rank): this.
(gfc_check_dummy_characteristics): Use new function name.
(gfc_check_result_characteristics): Likewise.
(gfc_compare_interfaces): Likewise.
(compare_parameter): Likewise.
(get_sym_storage_size): Likewise.
(gfc_procedure_use): Likewise.
* resolve.cc (decays_to_pointer): New function.
(c_types_conform): New function.
(compare_c_binding_arglists): New function.
(gfc_verify_binding_labels): Check return types and rank
plus argument lists if there is a pre-exisiting global
symbol.

gcc/testsuite/ChangeLog:

PR fortran/125092
* gfortran.dg/PR100906.f90: Add -Wno-pedantic to options.
* gfortran.dg/PR100911.f90: Likewise.
* gfortran.dg/PR100915.f90: Likewise.
* gfortran.dg/PR94327.f90: Likewise.
* gfortran.dg/PR94331.f90: Likewise.
* gfortran.dg/bind_c_procs_4.f90: Add error messages, remove
warning.
* gfortran.dg/binding_label_tests_25.f90: Add error messages.
* gfortran.dg/binding_label_tests_3.f03: Add error messages.
* gfortran.dg/binding_label_tests_34.f90: Add -Wno-pedantic to
options.
* gfortran.dg/c_char_tests_4.f90: Likewise.
* gfortran.dg/c_char_tests_5.f90: Likewise.
* gfortran.dg/binding_label_tests_36.f90: New test.
* gfortran.dg/binding_label_tests_37.f90: New test.

5 weeks agoLoongArch: Improve xor+xor+ior sequence when possible [PR 96692]
Xi Ruoyao [Fri, 1 May 2026 19:58:04 +0000 (03:58 +0800)] 
LoongArch: Improve xor+xor+ior sequence when possible [PR 96692]

Copy the a ^ b ^ (a | c) => (c & ~a) ^ b optimization from RISC-V zbb
(r17-241) as we have the andn instruction in LA64 and LA32S.

PR rtl-optimization/96692

gcc/

* config/loongarch/loongarch.md (define_split): New splitters
turning a ^ b ^ (a | c) => (c &~ a) ^ b.

gcc/testsuite/

* gcc.target/loongarch/pr96692.c: New test.

5 weeks agolibstdc++: Merge __type_identity and type_identity for C+20.
Tomasz Kamiński [Thu, 14 May 2026 10:48:19 +0000 (12:48 +0200)] 
libstdc++: Merge __type_identity and type_identity for C+20.

The components that used __type_identity in C++20 mode (due source
compatibility with older standard) lead to instantiation of separate
class template from std::type_identity for each used type. This
patch makes __type_identity an alias to type_identity if the latter is
available.

libstdc++-v3/ChangeLog:

* include/std/type_traits (__type_identity, __type_identity_t)
[__cpp_lib_type_identity]: Define as alias to type_identity
and its nested type respectively.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks ago[RISC-V] Drop unused parameters to restore bootstrap
Jeff Law [Thu, 14 May 2026 13:19:52 +0000 (07:19 -0600)] 
[RISC-V] Drop unused parameters to restore bootstrap

Bootstraps on RISC-V recently started failing due to an unused parameter.  I've
only lightly tested this, but it should restore bootstrapping.  Pushing to the
trunk.

gcc/
* config/riscv/riscv-v.cc (expand_const_vector_stepped): Drop unused
SRC parameter. All callers changed.
(expand_const_vector_interleaved_stepped_npatterns): Likewise.
(expand_const_vector): Corresponding changes.

5 weeks agodoc: Fix description of GET_MODE_MASK
Alex Coplan [Tue, 12 May 2026 09:22:09 +0000 (10:22 +0100)] 
doc: Fix description of GET_MODE_MASK

This updates the description of GET_MODE_MASK in the GCC internals
manual.  Currently it says that the macro can only be used for modes
whose bitsize is less than or equal to HOST_BITS_PER_INT.  That may have
once been correct, but these days it seems to work for modes up to
HOST_BITS_PER_WIDE_INT in size.  The code in genmodes.cc:emit_mode_mask
seems to support this.  It has:

  print_maybe_const_decl ("%sunsigned HOST_WIDE_INT", "mode_mask_array",
                          "NUM_MACHINE_MODES", adj_nunits);
  puts ("\
  ((m) >= HOST_BITS_PER_WIDE_INT)             \\\n\
   ? HOST_WIDE_INT_M1U                        \\\n\
   : (HOST_WIDE_INT_1U << (m)) - 1\n");

gcc/ChangeLog:

* doc/rtl.texi (Machine Modes): Update description of
GET_MODE_MASK to use HOST_BITS_PER_WIDE_INT instead of
HOST_BITS_PER_INT as the upper limit of the input mode's bitsize.

5 weeks agolibstdc++: Fix reserve of size_t(-1) elements in piecewise_constant_distribution...
Tomasz Kamiński [Wed, 13 May 2026 15:05:05 +0000 (17:05 +0200)] 
libstdc++: Fix reserve of size_t(-1) elements in piecewise_constant_distribution. [PR113761]

The piecewise_constant_distribution constructor from std::initializer_list il,
unconditionally reserve _M_den for il.size()-1 elements. In case when the il.size()
was zero, this led to unsigned overflow, and attempt to allocate size_t(-1)
elements.

This patch addresses above, by refactoring the constructors of param_type for
both piecewise_constant_distribution and piecewise_linear_distribution, to
exit early (and do not populate internal vectors) if number of intervals range is
smaller than two. For the constructor accepting pair of iterators, this is done
by checking result of __detail::__load_first2, that extracts up to two elements,
and returns false, if less than two is found.

Furthermore, we if the number of intervals is equal to two (for iterator __bbegin
is at __bend after __load_first2), we store densities value on stack, and call
newly introduced an _M_initialize2 helper, that does not populate internal vector
if __ints and __dens values correspond to default configuration.

With both of above changes, we no longer populate _M_int and _M_den with default
values, and corresponding code that clears them in _M_initialize is not necessary.
This avoids any unnecessary memory allocators.

For constructor accepting two iterators, we reserve required space in _M_int vector,
if the iterators are forward (or model sized_sentinel in C++20). The _M_den
initialization is performed afterwards, so _M_int size is already determined
(even for input iterators) and it can be used for call to reserve.

Finally, the _M_initialize members are renamed to _M_configure, so the new
implementation that skips the check, is not used by TU compiler will other
that would invoke it with empty vector, and thus retrigger the issue.

PR libstdc++/113761

libstdc++-v3/ChangeLog:

* include/bits/random.h
(piecewise_constant_distribution::param_type::_M_initialize)
(piecewise_linear_distribution::param_type::_M_initialize): Remove.
(piecewise_constant_distribution::param_type::_M_configure)
(piecewise_linear_distribution::param_type::_M_configure): Define.
(piecewise_constant_distribution::param_type::_M_initialize2)
(piecewise_linear_distribution::param_type::_M_initialize2): Declare.
* include/bits/random.tcc (__detail::__load_first2): Define.
(piecewise_constant_distribution::param_type::_M_initialize)
(piecewise_linear_distribution::param_type::_M_initialize):
Rename to...
(piecewise_constant_distribution::param_type::_M_configure)
(piecewise_linear_distribution::param_type::_M_configure):
Renamed implementation of _M_initialize, that removes checks for
default values.
(piecewise_constant_distribution::param_type::_M_initialize2)
(piecewise_linear_distribution::param_type::_M_initialize2): Define.
(piecewise_constant_distribution::param_type::param_type)
(piecewise_linear_distribution::param_type::param_type):
Exit early for less that two intervals. Use _M_initialize2 to handle
two intervals case. Reserve _M_int for iterators case.
* testsuite/26_numerics/random/piecewise_constant_distribution/cons/range.cc:
Test input and forward iterators, in addition to random_access ones.
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/range.cc:
Likewise.
* testsuite/26_numerics/random/piecewise_constant_distribution/cons/fallback.cc:
New test.
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/fallback.cc:
New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoOpenMP: Improve interface comment for the omp_deep_mapping lang hooks
Tobias Burnus [Thu, 14 May 2026 09:41:22 +0000 (11:41 +0200)] 
OpenMP: Improve interface comment for the omp_deep_mapping lang hooks

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_cnt,
gfc_omp_deep_mapping): Improve interface comment.

gcc/ChangeLog:

* langhooks.cc (lhd_omp_deep_mapping_p, lhd_omp_deep_mapping_cnt,
lhd_omp_deep_mapping): Improve interface comment.
* langhooks.h (lhd_omp_deep_mapping_p, lhd_omp_deep_mapping_cnt,
lhd_omp_deep_mapping): Likewise

5 weeks agolibstdc++: Mark gencanon_eng_neg test as unsupported if __float128 is not available.
Tomasz Kamiński [Thu, 14 May 2026 07:46:14 +0000 (09:46 +0200)] 
libstdc++: Mark gencanon_eng_neg test as unsupported if __float128 is not available.

As DejaGnu reads all lines, the { dg-error } still expected error,
even if the code was removed by preprocessor checks.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon_eng_neg.cc:
Removed preprocessor checks, add dg-require-effective-target.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoAVR: target/125194 - Make -mno-call-main work with -flto.
Georg-Johann Lay [Thu, 14 May 2026 08:21:28 +0000 (10:21 +0200)] 
AVR: target/125194 - Make -mno-call-main work with -flto.

Instead of emitting  .global __call_main + __call_main=0  in some
module, it uses a %{mno-call-main: --defsym __call_main=0} spec.

The problem with the old implementation is that avr_no_call_main_p
was set by cc1[plus] (in avr_insert_attributes) but used by lto1
(in avr_file_end).  The new approach uses  --defsym __call_main=0
in order to avoid link fails due to multiple definitions of __call_main
in *.o and lib<mcu>.a.

PR target/125194
gcc/
* config/avr/avr.cc (avr_no_call_main_p): Remove variable...
(avr_file_end): ...and code that uses it.
(avr_insert_attributes): Same.  Add "used" to main attributes
when -mno-call-main.
* config/avr/gen-avr-mmcu-specs.cc (print_mcu): Emit code
for link_no_call_main specs.
* config/avr/specs.h (LINK_SPEC): Add %(link_no_call_main).

5 weeks agoDaily bump.
GCC Administrator [Thu, 14 May 2026 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agolibstdc++: Remove trailing whitespace in shared_ptr_atomic.h
Jonathan Wakely [Wed, 13 May 2026 23:39:43 +0000 (00:39 +0100)] 
libstdc++: Remove trailing whitespace in shared_ptr_atomic.h

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h: Remove trailing whitespace.

5 weeks agolibstdc++: Add call to test_format in std/time/clock/local/io.cc
Jonathan Wakely [Wed, 13 May 2026 19:48:42 +0000 (20:48 +0100)] 
libstdc++: Add call to test_format in std/time/clock/local/io.cc

This function was defined but not being called at runtime.

libstdc++-v3/ChangeLog:

* testsuite/std/time/clock/local/io.cc: Call test_format.

5 weeks agolibstdc++: Fix -Wsign-compare warning in new test
Jonathan Wakely [Tue, 12 May 2026 16:14:26 +0000 (17:14 +0100)] 
libstdc++: Fix -Wsign-compare warning in new test

libstdc++-v3/ChangeLog:

* testsuite/std/time/clock/utc/leap_second_info-2.cc: Fix sign
compare warning. Tweak comment.

5 weeks agolibstdc++: rebuild configure
Alexandre Oliva [Wed, 13 May 2026 15:50:34 +0000 (12:50 -0300)] 
libstdc++: rebuild configure

An earlier configury patch made originally in gcc-15, where no line
number changes came up during configure rebuild, needed an explicit
rebuild after porting to trunk.

for  libstdc++-v3/ChangeLog

* configure: Rebuild.

5 weeks agoRISC-V: Remove interleaved vector synthesis optimization [PR125215]
Zhongyao Chen [Fri, 8 May 2026 11:02:06 +0000 (19:02 +0800)] 
RISC-V: Remove interleaved vector synthesis optimization [PR125215]

This patch removes the "hi/lo" optimization path in interleaved
stepped constant vector synthesis. This optimization was found
to be not really better than the fallback merge version. Once the
overflow issue is fixed, the extra masking makes the code generation
"even worse". So remove it instead of fixing.

Obsolete tests slp-interleave-[1-5].c are also removed as they were
specifically designed to verify this now-removed path.

My local test shows no regression.

PR target/125215

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector_interleaved_stepped_npatterns):
Remove hi/lo optimization and always use the merge fallback.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr125215.c: New test.
* gcc.target/riscv/rvv/autovec/slp-interleave-1.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-2.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-3.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-4.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-5.c: Remove.

Signed-off-by: Zhongyao Chen <chen.zhongyao@zte.com.cn>
5 weeks agolibstdc++: Use type_identity_t for operator<=> parameter [PR114400]
Tomasz Kamiński [Wed, 13 May 2026 09:51:25 +0000 (11:51 +0200)] 
libstdc++: Use type_identity_t for operator<=> parameter [PR114400]

This matches change to operator== from r14-9642-gf4605c53ea2eeaf,
and implements exact resolution of LWG3950, "std::basic_string_view comparison
operators are overspecified". The difference between __type_identity and
type_identity is observable as illustrated by PR.

libstdc++-v3/ChangeLog:

PR libstdc++/114400
* include/std/string_view (operator<=>): Use type_identity_t
instead of __type_identity_t.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoc++/reflection: overzealous complete_type in consteval_only_p [PR125280]
Marek Polacek [Tue, 12 May 2026 21:01:29 +0000 (17:01 -0400)] 
c++/reflection: overzealous complete_type in consteval_only_p [PR125280]

This bug report shows that we generate a bogus "has incomplete type"
error for Element::mData in type12.C with -freflection: consteval_only_p
attempts to complete Array when finishing mData, but mData uses Element
which is currently being defined, so we can't complete it yet.  We could
fix this bogus error by checking can_complete_type_without_circularity
before calling complete_type in consteval_only_p, but I'm no longer so
sure that we must call complete_type at all.  This patch removes that
call.  One consequence of that is that we don't produce the "outside
a constant-evaluated context" error for C::mData (only when mData is
defined outside the class as with A::mData above).  This behavior
matches clang++ though so I'm not too worried about it.

type13.C shows that even without the complete_type we can still get
to consteval_only_p_walker::walk with a member with erroneous type
which currently crashes.

PR c++/125280

gcc/cp/ChangeLog:

* reflect.cc (consteval_only_p): Don't complete_type.
(consteval_only_p_walker::walk): Return false for
error_mark_node.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/init19.C: New test.
* g++.dg/reflect/type12.C: New test.
* g++.dg/reflect/type13.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
5 weeks agoMAINTAINERS: Add myself to write after approval and DCO.
Zhongyao Chen [Wed, 13 May 2026 02:05:38 +0000 (10:05 +0800)] 
MAINTAINERS: Add myself to write after approval and DCO.

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.
(Contributing under the DCO): Add myself.

Signed-off-by: Zhongyao Chen <chen.zhongyao@zte.com.cn>
5 weeks agolibstdc++: Test for unsupported engine range for 128bits floating points [PR119739]
Tomasz Kamiński [Wed, 13 May 2026 12:51:02 +0000 (14:51 +0200)] 
libstdc++: Test for unsupported engine range for 128bits floating points [PR119739]

This patch add test illustrating, that after implementing P0952 "A new specification for
std::generate_canonical",  generators, that emit range of non-power-of-two size, that
span over B bits, are not supported in combination with 128bits integer are not
support for B in ranges: [22, 23), [26, 29), [33, 38), [43, 57). This is because, the
lowest multiply of B that is larger of equal than 113 (size of mantisa of float128)
is greater than 128, and thus they will require 256 bits integers support.

This does not impact any generate defined in standard (see gencanon_eng.cc tests),
nor generate emitting power of 2 sized ranges.

PR libstdc++/119739

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon_eng_neg.cc:
New test.

Reviewed-by: Nathan Myers <nmyers@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoscev: maintain affine CHRECs in the presence of type conversions
Tamar Christina [Wed, 13 May 2026 11:36:07 +0000 (12:36 +0100)] 
scev: maintain affine CHRECs in the presence of type conversions

The example

float *e;
void f (float *f, float *g, char *h, int n,
        int b, int c, int d)
{
  float a = 0;
  for (int i = 0; i < n; ++i) {
    int j = b + i, k = c + i * d;
    float l = g[j], m = h[i] ? g[k] : l;
    a += f[i] * m;
  }
  *e = a;
}

gets vectorized using gathers for the access to g:

.L5:
        ld1b    z4.s, p7/z, [x2, x6]
        cmpne   p6.b, p7/z, z4.b, #0
        ld1w    z2.s, p7/z, [x0, x6, lsl 2]
        add     z7.s, z30.s, z16.s
        add     z6.s, z16.s, z18.s
        add     x6, x6, x7
        ld1w    z5.s, p7/z, [x1, z6.s, sxtw 2]
        ld1w    z3.s, p6/z, [x1, z7.s, sxtw 2]
        incw    z16.s
        sel     z3.s, p6, z3.s, z5.s
        fmla    z17.s, p7/m, z2.s, z3.s
        whilelo p7.s, w6, w3
        b.any   .L5

however the first g is g[b+i] and second is g[c + i*d];

since b is loop invariant the access to g[b+i] is actually linear and since c
is loop invariant, then the base of the second access g[c + i *d] can be
simplified by recognizing the base as g + c.

Today however SCEV fails to analyze these accesses as affine and as a
consequence we end up with gathers:

: missed:  failed: evolution of base is not affine.
        base_address:
        offset from base address:
        constant offset from base address:
        step:
        base alignment: 0
        base misalignment: 0
        offset alignment: 0
        step alignment: 0
        base_object: *_63

Looking at SCEV this is because of an outer cast around the CHREC:

)
(set_scalar_evolution
  instantiated_below = 25
  (scalar = _65)
  (scalar_evolution = (long unsigned int) {b_22(D), +, 1}_2))
)
(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = (long unsigned int) {b_22(D), +, 1}_2)

(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = g_27(D))
  (res = g_27(D)))

  which corresponds to

  j_66 = b_22(D) + i_67;
  _65 = (long unsigned int) j_66;
  _64 = _65 * 4;
  _63 = g_27(D) + _64;
  l_62 = *_63;

and the _64 is deemed to not be affine:

(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = _64)
(analyze_scalar_evolution
  (loop_nb = 2)
  (scalar = _64)
(get_scalar_evolution
  (scalar = _64)
  (scalar_evolution = _64))
)
  (res = scev_not_known))

This patch fixes it by (very carefully) folding a multiply on an unsigned affine
CHREC into the CHREC itself.

which results in

(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = 4)
  (res = 4))
(set_scalar_evolution
  instantiated_below = 25
  (scalar = _64)
  (scalar_evolution = {(long unsigned int) b_22(D) * 4, +, 4}_2))
)
(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = g_27(D))
  (res = g_27(D)))
(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = {(long unsigned int) b_22(D) * 4, +, 4}_2)
  (res = {(long unsigned int) b_22(D) * 4, +, 4}_2))
(set_scalar_evolution
  instantiated_below = 25
  (scalar = _63)
  (scalar_evolution = {g_27(D) + (long unsigned int) b_22(D) * 4, +, 4}_2))
)

and dataref now correctly analyzes the base

        base_address: g_27(D) + (sizetype) b_22(D) * 4
        offset from base address: 0
        constant offset from base address: 0
        step: 4
        base alignment: 4
        base misalignment: 0
        offset alignment: 128
        step alignment: 4
        base_object: *g_27(D) + (sizetype) b_22(D) * 4
        Access function 0: {0B, +, 4}_2

producing the final codegen:

.L7:
        ld1b    z4.s, p7/z, [x2, x6]
        cmpne   p6.b, p7/z, z4.b, #0
        ld1w    z29.s, p7/z, [x4, x6, lsl 2]
        ld1w    z2.s, p7/z, [x0, x6, lsl 2]
        ld1w    z3.s, p6/z, [x5]
        add     x6, x6, x7
        sel     z3.s, p6, z3.s, z29.s
        add     x5, x5, x1
        fmla    z30.s, p7/m, z2.s, z3.s
        whilelo p7.s, w6, w3
        b.any   .L7
        faddv   s31, p5, z30.s

gcc/ChangeLog:

* tree-chrec.cc (chrec_convert_1): Fold unsigned CHREC converts.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-scev-affine_1.c: New test.

5 weeks agox86: Shorter load immediate constants with -Oz
Roger Sayle [Wed, 13 May 2026 11:31:12 +0000 (12:31 +0100)] 
x86: Shorter load immediate constants with -Oz

This patch adds two peephole2 patterns to i386.md to decrease the size
of some integer loads.  These replace "movl $const, %eax" (5 bytes)
with "xorl %eax, %eax" followed by either "movb $const,%al" or
"movb $const,%ah" (together 4 bytes), for suitable constants and
suitable general registers, when the flags register is dead.

Ideally modern Intel and AMD prcoessors can recognize these sequences
during instruction decode (avoiding any partial register stall in
the same way they avoid the false dependence for the xorl), and
internally generate a single uop, treating these bytes like an
alternate instruction encoding.

2026-05-13  Roger Sayle  <roger@nextmovesoftware.com>
    Uros Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
PR target/32803
* config/i386/i386.md (peephole2): Don't transform xorl;movb into
movzb with -Oz.
(peephole2): Convert movl into xorl;movb (strict_low_part) with -Oz.
(peephole2): Likewise, convert movl into xorl;movb [abcd]h with -Oz.

gcc/testsuite/ChangeLog
PR target/32803
* gcc.target/i386/pr32803-2.c: New test case.
* gcc.target/i386/pr32803-3.c: Likewise.

5 weeks agotestsuite: Skip new test case gcc.target/arm/muldi-1.c with -mthumb
Roger Sayle [Wed, 13 May 2026 11:23:41 +0000 (12:23 +0100)] 
testsuite: Skip new test case gcc.target/arm/muldi-1.c with -mthumb

The recent test to confirm PR middle-end/122871 is resolved on ARM,
wasn't expecting -mthumb.  This adds a requires-effective-target.
Committed as obvious.

2026-05-13  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Earnshaw  <rearnsha@arm.com>

gcc/testsuite/ChangeLog
PR middle-end/122871
* gcc.target/arm/muldi-1.c: Skip test if compiled with -mthumb.

5 weeks agoRecord (de-)composition type in ls_type for VMAT_STRIDED_SLP accesses
Richard Biener [Wed, 13 May 2026 06:47:43 +0000 (08:47 +0200)] 
Record (de-)composition type in ls_type for VMAT_STRIDED_SLP accesses

The following arranges the vector (de-)composition type for VMAT_STRIDED_SLP
loads and stores to be available in the ls_type field of the load/store data
for target costing.

* tree-vect-stmts.cc (vectorizable_store): Record ls_type
for VMAT_STRIDED_SLP.
(vectorizable_load): Likewise.

5 weeks agoDelay setting of slp_node->data in vectorizable_{load,store}
Richard Biener [Tue, 12 May 2026 12:44:30 +0000 (14:44 +0200)] 
Delay setting of slp_node->data in vectorizable_{load,store}

We move 'ls' to slp_node->data early, inhibiting late adjustments
like setting of ls_type.  We also have failure cases after, which
we should not.  The following moves one such failure check earlier
and moves setting slp_node->data and SLP_TREE_TYPE
down, duplicating it to various "success" returns.

* tree-vect-stmts.cc (vectorizable_store): Set slp_node->data
and SLP_TREE_TYPE only on success.
(vectorizable_load): Likewise.  Move one validity check early.

5 weeks agors6000: Fix [su]mul<mode>3_highpart patterns to use RTL codes [PR122665]
Jeevitha [Wed, 13 May 2026 08:36:10 +0000 (03:36 -0500)] 
rs6000: Fix [su]mul<mode>3_highpart patterns to use RTL codes [PR122665]

The existing smul<mode>3_highpart and umul<mode>3_highpart patterns
incorrectly defined the high-part multiply by shifting both operands
right by 32 before multiplication. This does not match the semantics
of the instructions vmulhs<wd> and vmulhu<wd>, which perform a widened
multiplication and return the high part of the result.

This patch replaces the incorrect shift-based patterns with the proper
smul_highpart and umul_highpart RTL codes, and updates the operand
predicate from vsx_register_operand to altivec_register_operand, since
these instructions only accept Altivec registers.

2026-05-13  Jeevitha Palanisamy  <jeevitha@linux.ibm.com>

gcc/
PR target/122665
* config/rs6000/vsx.md (smul<mode>3_highpart, umul<mode>3_highpart):
Replace shift-based patterns with smul_highpart and umul_highpart RTL
codes and use altivec_register_operand.

5 weeks agoEnabling POPCNT generation for 32-bit patterns.
Reshma Roy [Thu, 11 Dec 2025 05:27:53 +0000 (10:57 +0530)] 
Enabling POPCNT generation for 32-bit patterns.

Enabling POPCNT generation for 32-bit pattern from Hacker's Delight

Pattern 1:
int Gia_WordCountOnes32c( uint32_t uword )
{
  uword = (uword & 0x55555555) + ((uword>>1) & 0x55555555);
  uword = (uword & 0x33333333) + ((uword>>2) & 0x33333333);
  uword = (uword & 0x0f0f0f0f) + ((uword>>4) & 0x0f0f0f0f);
  uword = (uword & 0x00ff00ff) + ((uword>>8) & 0x00ff00ff);
  return  (uword & 0x0000ffff) + (uword>>16);
  or
  return (uword & 0x0000FFFF) + ((uword >> 16) & 0x0000FFFF);
}

Pattern 2:
int pop(unsigned x) {
  x = x - ((x >> 1) & 0x55555555);
  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  x = (x + (x >> 4)) & 0x0F0F0F0F;
  x = x + (x >> 8);
  x = x + (x >> 16);
  return x & 0x0000003F;
}

Pattern 3:
int pop(unsigned x) {
  x = x - ((x >> 1) & 0x55555555);
  x = x - 3*((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0F0F0F0F;
  x = x + (x >> 8);
  x = x + (x >> 16);
  return x & 0x0000003F;
}

gcc/ChangeLog:

* match.pd: Add new popcount pattern variants from Hacker's Delight.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/popcount7.c: New test.
* gcc.dg/tree-ssa/popcount7_2.c: New test.
* gcc.dg/tree-ssa/popcount8.c: New test.
* gcc.dg/tree-ssa/popcount9.c: New test.

5 weeks agolibgomp.texi: Add the missing closing brace
H.J. Lu [Wed, 13 May 2026 07:42:37 +0000 (15:42 +0800)] 
libgomp.texi: Add the missing closing brace

Fix GCC build error:

libgomp.texi:647: @code missing closing brace
make[4]: *** [Makefile:1434: stamp-build-info] Error 1

from

commit a94fc2737d4c3916cdab15e2f2e28f74b6c39e65
Author: Tobias Burnus <tburnus@baylibre.com>
Date:   Wed May 13 08:21:53 2026 +0200

    libgomp: Add stub omp_control_tool for OMPT

-@item New @code{omp_pause_stop_tool} constant for omp_pause_resource @tab N @tab
+@item New @code{omp_pause_stop_tool} constant for @code{omp_pause_resource
+      @tab Y @tab

* libgomp.texi: the Add missing closing brace.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agox86-64: Use R11 for DRAP register in preserve_none functions
H.J. Lu [Sun, 10 May 2026 10:36:26 +0000 (18:36 +0800)] 
x86-64: Use R11 for DRAP register in preserve_none functions

In 64-bit mode, for preserve_none functions, DRAP may use any register
except AX, R12–R15, DI, SI (argument registers), SP, and BP. Use R11.
In non-callee-saved functions, R10 and R13 are also available since they
are not used for parameter passing.  In 32-bit mode, preserve_none does
not affect parameter passing, so the current approach remains valid.

DRAP register is used to restore stack pointer in epilogue for stack
realignment.  Always save and restore DRAP register between prologue
and epilogue so that stack pointer can be restored.

Tested with CPython 3.14.4 on Linux/x86-64.

gcc/

PR target/120870
* config/i386/i386.cc (ix86_save_reg): Return true for DRAP
register early at entry.
(find_drap_reg): Use R11_REG in preserve_none functions in
64-bit mode.

gcc/testsuite/

PR target/120870
* gcc.target/i386/pr120870-1.c: New test.
* gcc.target/i386/pr120870-2.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Uros Bizjak <ubizjak@gmail.com>
5 weeks agolibstdc++: Support ON-format DAY in Zone UNTIL field [PR124852]
Álvaro Begué [Tue, 12 May 2026 12:55:01 +0000 (14:55 +0200)] 
libstdc++: Support ON-format DAY in Zone UNTIL field [PR124852]

The Zone-line UNTIL parser only accepted a plain day-of-month integer
for the DAY field, while the tzdata.zi grammar accepts the same ON-style
forms as Rule lines: lastSun, Sun>=8, Sat<=20, etc. Real zones use these
forms in their UNTIL DAY: Europe/Simferopol's `3 - MSK 1997 Mar lastSu
1u`, for instance, became `Mar 1` (silently misparsed) instead of `Mar
30`, leaving Simferopol an extra 29 days in MSK.

The previous parser's `int d = 1; in >> m >> d >> t;` chain silently
left d == 1 when the day token wasn't a digit, then went on to parse the
remainder as the TIME field.

Renames on_day to on_month_day, and factor out the day-component parser
parser from operator>>(istream&, on_day&) as operator>> for newly added
on_day_t tag type, and reuse it for the UNTIL DAY field. The operator
handles all three on_day forms (DayOfMonth, LastWeekday, LessEq /
GreaterEq).  The MONTH-only and YEAR-only short forms are still accepted
because the DAY/TIME fields are optional and default to day 1, time 00:00.
The on_day struct's pin() method handles the year/month-relative
resolution.

The DAY field is unambiguously distinguishable from a TIME field that
could otherwise follow the MONTH directly: per zic's grammar, MONTH
must be followed by DAY before any TIME is allowed.  So we always
attempt to parse a DAY if any non-whitespace remains after the MONTH.

libstdc++-v3/ChangeLog:

PR libstdc++/124852
* src/c++20/tzdb.cc (on_day): Rename to...
(on_day_month): Rename from on_day.
(on_day_month::on_day_t, on_day_month::on_day): Define.
(operator>>(istream&, on_day_t&&)): Factored out of
operator>>(istream&, on_day&).
(operator>>(istream&, on_day&)): Use on_day_t parser.
(operator>>(istream&, ZoneInfo&)): Replace the integer DAY
parser with on_day_t for the UNTIL field.
* testsuite/std/time/time_zone/until_day_on.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Álvaro Begué <alvaro.begue@gmail.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agolibgomp: Add stub omp_control_tool for OMPT
Tobias Burnus [Wed, 13 May 2026 06:21:53 +0000 (08:21 +0200)] 
libgomp: Add stub omp_control_tool for OMPT

Add the omp_control_tool routine (always returning omp_control_tool_notool);
add it and omp_control_tool/omp_control_tool_result enums/parameters to omp.h
and omp_lib.{h,mod}. Plus add OpenMP 6.0's omp_pause_stop_tool named constant.

Note that omp_control_tool uses the OpenMP 6.0 C/C++ prototype that uses an
enum omp_control_tool_t as first argument instead of an 'int'.

gcc/fortran/ChangeLog:

* intrinsic.texi (OpenMP Modules): Add named parameters for
omp_control_tool and omp_control_tool_result.

gcc/ChangeLog:

* omp-general.cc (omp_runtime_api_procname): Add omp_control_tool.

libgomp/ChangeLog:

* env.c (omp_control_tool): Stub implementation for omp_control_tool.
* fortran.c (omp_control_tool_, omp_control_tool_8_): Add.
* libgomp.map (OMP_6.0): Add for omp_control_tool*.
* libgomp.texi (Tool Control Routine): Add for omp_control_tool.
(OpenMP 6.0): Mark omp_pause_stop_tool as implemented.
* omp.h.in (omp_pause_resource_t): Add omp_pause_stop_tool.
(omp_control_tool_result_t): Add.
(omp_control_tool_t): Add.
* omp_lib.f90.in (omp_lib_kinds): Add omp_pause_stop_tool and
omp_control_tool/omp_control_tool_result parameters.
(omp_lib): Add omp_control_tool interface.
* omp_lib.h.in: Add omp_pause_stop_tool and
omp_control_tool/omp_control_tool_result parameters; add
omp_control_tool interface.
* testsuite/libgomp.c/omp-control-tools-1.c: New test.
* testsuite/libgomp.fortran/omp-control-tools-1.f: New test.
* testsuite/libgomp.fortran/omp-control-tools-1.f90: New test.

5 weeks agolibstdc++: Fix numeric save offset on Zone lines [PR124851]
Álvaro Begué [Sun, 26 Apr 2026 23:51:17 +0000 (19:51 -0400)] 
libstdc++: Fix numeric save offset on Zone lines [PR124851]

When a Zone line specifies a numeric value as its RULES field (the
constant DST save value for that zone line, e.g. Africa/Gaborone's
"2 1 CAST" line), the parser stored the standard offset alone in
ZoneInfo::m_offset. ZoneInfo::to() then returned that as
sys_info::offset, dropping the numeric save and reporting a total
offset that was wrong by the save amount.

This was inconsistent with the two ZoneInfo constructors that take a
sys_info, which previously stored the *total* offset (stdoff + save) in
m_offset. As a result m_offset's semantics depended on which code path
created the ZoneInfo, and only the parser path's lines with non-zero
numeric save were observably broken.

Fix by giving m_offset a single semantics: always the standard offset
only. The two sys_info-taking constructors now subtract the save before
storing, and to(0 adds it back when reconstructing the sys_info.

The remaining .offset() callers inside _M_get_sys_info already expect
the standard offset (they are computing rule firing times, where the
save component is added separately from the active rule's save value),
so no other call sites need adjustment.

libstdc++-v3/ChangeLog:

PR libstdc++/124851
* src/c++20/tzdb.cc (ZoneInfo::ZoneInfo(sys_info&&)): Store
stdoff only in m_offset (subtract info.save).
(ZoneInfo::ZoneInfo(const pair<sys_info, string_view>&)):
Likewise.
(ZoneInfo::offset()): Document new semantics.
(ZoneInfo::to(sys_info&)): Add m_save back to offset() when
populating sys_info::offset.
* testsuite/std/time/time_zone/numeric_save.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Álvaro Begué <alvaro.begue@gmail.com>
5 weeks agoc: avoid false positive for useless casts and generic [PR125261]
Martin Uecker [Tue, 12 May 2026 05:11:38 +0000 (07:11 +0200)] 
c: avoid false positive for useless casts and generic [PR125261]

To reduce the number of false positives, we guard -Wuseless-cast by
c_inhibit_evaluation_warnings and also increment it for a generic
association if we have seen a prior match for a (non-default)
association.  This covers the common case where the default association
comes last.  If there is another association selected after we have
seen a default, we still have false positives.

PR c/125261

gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Modify logic for
c_inhibit_evaluation_warnings.
* c-typeck.cc (build_c_cast): Use c_inhibit_evaluation_warnings.

gcc/testsuite/ChangeLog:
* gcc.dg/pr125261.c: New test.

5 weeks agoc++/reflection: reject invalid annotation on class [PR123609]
chzn@mail.ustc.edu.cn [Wed, 13 May 2026 04:48:45 +0000 (00:48 -0400)] 
c++/reflection: reject invalid annotation on class [PR123609]

Some errors while parsing attributes on class are ignored due to tentative
parsing, this patch redo parsing to reject it.

PR c++/123609

gcc/cp/ChangeLog:

* parser.cc (cp_parser_class_head): Re-parse attributes
that caused a tentative parsing failure.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/attr-nodiscard1.C: Adjust expected errors.
* g++.dg/reflect/annotations19.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
5 weeks agotestsuite: Move pr123286.c to gcc.target/aarch64/
Naveen [Wed, 13 May 2026 03:30:01 +0000 (20:30 -0700)] 
testsuite: Move pr123286.c to gcc.target/aarch64/

The test for PR middle-end/123286 unconditionally includes <arm_neon.h>
which is only available on AArch64 targets. Hence, move the testcase to
gcc.target/aarch64/ where the target context is implicit.

gcc/testsuite/ChangeLog:
* gcc.dg/pr123286.c: Move to...
* gcc.target/aarch64/pr123286.c: ...here.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
5 weeks agogfortran.dg/coarray: Require target sleep where calls were recently added, PR125005
Hans-Peter Nilsson [Thu, 23 Apr 2026 16:22:02 +0000 (18:22 +0200)] 
gfortran.dg/coarray: Require target sleep where calls were recently added, PR125005

I added this attribute only to those tests requiring linking and
runtime use, i.e. those failing as per the PR.

PR libfortran/125005
* gfortran.dg/coarray/failed_images_2.f08,
gfortran.dg/coarray/image_status_2.f08,
gfortran.dg/coarray/stopped_images_2.f08: Require sleep effective
target.

5 weeks agoDaily bump.
GCC Administrator [Wed, 13 May 2026 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agocobol: Improved GENERIC for conditionals and comparisons.
Robert Dubner [Tue, 12 May 2026 17:52:28 +0000 (13:52 -0400)] 
cobol: Improved GENERIC for conditionals and comparisons.

After several years, I am finally developing some understanding of
GENERIC and how the middle-end processes it.  These wide-ranging changes
improve the execution speed of conditional logic and numeric-numeric,
numeric-alpha, and alpha-alpha comparisons.

I started with refining the way GENERIC for "IF <conditional statement>"
is created, and then I moved on to numerous individual cases.  Some
all-purpose routines in libgcobol.so have been broken out into special-
purpose routines implemented in GENERIC.

gcc/cobol/ChangeLog:

* Make-lang.in: Incorporate new gcc/cobol/compare.cc file.
* cobol1.cc (ATTR_CONST_NOTHROW_LEAF): Incorporate __builtin_swap16,
__builtin_swap32, __builtin_swap64, and __builtin_swap128.
(cobol_langhook_init): Likewise.
* genapi.cc (treeplet_fill_source): Improve speed.
(get_binary_value_from_float): Spelling.
(normal_normal_compare): Eliminate.
(compare_binary_binary): Eliminate.
(DEBUG_COMPARE): Eliminate.
(cobol_compare): Eliminate.
(parser_enter_file): Eliminate obsolete variables.
(data_decl_type_for): New function.
(parser_alphabet_use): Flag altered alphabets for speed.
(parser_display): Environment switch for putting comments into
the assembly language.
(program_end_stuff): Change "hijack" to "hijack_h".
(parser_division): Repair RETURN-CODE logic.
(parser_logop): Improve GENERIC for logical operations.
(parser_relop): Use new cobol_compare_relop() routine.
(parser_relop_long): Elminate unnecessary static variable.
(inspect_tally): Improve parameter passing to library routine.
(inspect_replacing): Likewise.
(parser_intrinsic_subst): Likewise.
(parser_intrinsic_callv): Likewise.
(parser_intrinsic_call_1): Likewise.
(parser_bsearch_start): Likewise.
(parser_bsearch_when): Use new comparison routine; simplify logic.
(parser_unstring): Improve parameter passing to library routine.
(parser_string): Likewise.
(create_and_call): Repair RETURN-CODE logic.
(parser_call): Adjust exception processing when the target cannot be
found.
(build_temporaryN): Constructor for cblc_field_t::data.
(hijack_for_development): Change hijacking name to "dubner_h".
(hijacker): Change hijacking name to "hijack_h".
(get_reference_to_data): New function.
(mh_identical): Improve speed when sender and receiver have the same
structure.
(mh_source_is_literalN): Eliminate leading plus/minus when moving a
numeric to an alphanumeric.
(move_helper): Adjust logic for mh_identical and mh_source_is_group.
(actually_create_the_static_field): Use constructor for data member.
(psa_new_var_decl): Typo in comment.
(parser_symbol_add): Make the generated data type more consistent
with the COBOL variable type.
* genapi.h (parser_bsearch_when): Change declaration.
(parser_bsearch_start): Formatting.
(parser_sort): Formatting.
* gengen.cc (gg_show_type): Expand for ARRAY_TYPE and ARRAY_REF.
(gg_define_from_declaration): Use void type for DECL_EXPR.
(gg_define_volatile_variable): New function.
(gg_get_address): New function.
(gg_array_value): Use fold_convert().
(gg_bswap): New function.
(gg_memcmp): New function.
* gengen.h (SCHAR_P): New and changed declarations.
(struct gg_function_t): Add alphabet_in_use flag.
(gg_define_volatile_variable): New declaration.
(gg_get_address_of): Comment.
(gg_pointer_to_array): Comment.
(gg_get_address): New declaration.
(gg_bswap): New declaration.
(gg_memcmp):  New declaration.
(gg_insert_into_assemblerf): Formatting.
* genmath.cc (arithmetic_operation): Improved handling of
parameters.
(fast_add): Improved handling of locations.
(parser_add): Formatting.
* genutil.cc (tree_type_from_digits): Correct parameter.
(get_data_offset): Correct exception handling.
(get_binary_value_tree): Improve location handling.
(tree_type_from_field): Correct logic.
(tree_type_from_size): Correct signs for returned type.
(build_array_of_treeplets): Eliminated.
(build_array_of_referlets): New function.
(build_array_of_fourplets): Eliminated.
(build_array_of_refers): New function.
(refer_is_clean): Improved logic.
(refer_is_super_clean): New function.
(refer_is_working_storage): New function.
(refer_offset): Formatting.
(binary_from_FldNumericBin5): New function.
(binary_from_FldNumericBinary): New function.
(d_and_q_num_disp): New function.
(binary_from_FldNumericDisplay): New function.
(make_dp2bin_decl): New function.
(d_and_q_packed): New function.
(binary_from_comp_3): New function.
(binary_from_comp_6): New function.
(binary_from_FldPacked): New function.
(binary_from_FldFloat): New function.
(get_binary_value): New function.
(get_location): New function.
(get_length): New function.
* genutil.h (tree_type_from_digits): New declaration.
(tree_type_from_size): Changed declaration.
(refer_is_super_clean): New declaration.
(refer_is_working_storage): New declaration.
(refer_offset): Changed declaration.
(build_array_of_treeplets): Remove declaration.
(build_array_of_referlets): New declaration.
(build_array_of_fourplets): Remove declaration.
(build_array_of_refers): New declaration.
(tree_type_from_field): New declaration.
(get_binary_value): New declaration.
(get_location): New declaration.
(get_length): New declaration.
* parse.y: Mysterious changes. All changes to YACC rules are
mysterious.
* parse_ante.h (class log_expr_t): Changes to logop() invocation.
* scan_post.h (yylex): Remove unnecessary trailing semicolon.
* structs.cc (create_cblc_file_t): Change cblc_file_t declaration.
(create_referlet_t): New function.
(create_refer_t): New function.
(create_our_type_nodes): Add cblc_referlet_type_node and
cblc_refer_type_node.
* structs.h (member2): New declaration.
(GTY): Type for cblc_referlet_type_node and cblc_refer_type_node.
* symbols.cc (temporaries_t::add): Remove unnecessary trailing
semicolon.
* symbols.h (struct cbl_bsearch_t): Remove obsolete member.
(ENABLE_HIJACKING): Compilation switch for enabling dubner_h and
hijack_h code-generation hijacking.
* util.cc (symbol_field_type_update): Comment.
* compare.cc: New file.
* compare.h: New file.

libgcobol/ChangeLog:

* charmaps.h (class charmap_t): Remove an abort().
* common-defs.h (SUPERTYPE): Pairs integers for complex switch().
(cbl_file_mode_str): Remove unnecessary trailing semicolon.
* gcobolio.h: New cblc_referlet_t and cblc_refer_t structures;
eliminate obsolete structures.
* gmath.cc (__gg__pow): Improved parameter handling.
(__gg__add_fixed_phase1): Likewise.
(__gg__addf1_fixed_phase2): Likewise.
(__gg__fixed_phase2_assign_to_c): Likewise.
(__gg__add_float_phase1): Likewise.
(__gg__addf1_float_phase2): Likewise.
(__gg__float_phase2_assign_to_c): Likewise.
(__gg__addf3): Likewise.
(__gg__subtractf1_fixed_phase2): Likewise.
(__gg__subtractf2_fixed_phase1): Likewise.
(__gg__subtractf1_float_phase2): Likewise.
(__gg__subtractf2_float_phase1): Likewise.
(__gg__subtractf3): Likewise.
(__gg__multiplyf1_phase1): Likewise.
(__gg__multiplyf1_phase2): Likewise.
(__gg__multiplyf2): Likewise.
(__gg__dividef1_phase2): Likewise.
(__gg__dividef23): Likewise.
(__gg__dividef45): Likewise.
* inspect.cc (inspect_backward_format_1): Likewise.
(__gg__inspect_format_1): Likewise.
(inspect_backward_format_2): Likewise.
(__gg__inspect_format_2): Likewise.
(__gg__inspect_format_1_sbc): Likewise.
* intrinsic.cc (kahan_summation): Likewise.
(variance): Likewise.
(__gg__concat): Likewise.
(__gg__max): Likewise.
(__gg__mean): Likewise.
(__gg__median): Likewise.
(__gg__midrange): Likewise.
(__gg__min): Likewise.
(__gg__ord_min): Likewise.
(__gg__ord_max): Likewise.
(__gg__present_value): Likewise.
(__gg__range): Likewise.
(__gg__standard_deviation): Likewise.
(__gg__sum): Likewise.
(__gg__variance): Likewise.
(__gg__substitute): Likewise.
* libgcobol.cc (__gg__resize_int_p): Eliminate.
(__gg__resize_treeplet): Eliminate.
(initialize_program_state): Eliminate the use of obsolete variables.
(format_for_display_internal): Handle FldLiteralN; display up to
38 digits for __int128.
(compare_field_class): Rename to __gg__compare_field_class.
(__gg__compare_field_class): Likewise.
(interconvert): Correct codeset correction logic.
(__gg__compare_2): Use __gg__compare_field_class.
(__gg__move): Handle FldNumericBin5 correction.
(__gg__string): Improved parameter handling.
(display_both): Cope with missing codeset parameter.
(__gg__literaln_alpha_compare): Eliminate.
(__gg__unstring): Improved parameter handling.
(__gg__just_mangle_name): Improved codeset handling.
(__gg__convert): Formatting.
(__gg__set_data_member): Eliminate.
(__gg__show_int128): New function.
(__gg__compare_string_all): New function.
(__gg__compare_string_1): New function.
(ASCII_16): Abuse of the preprocessor to create a 1024-byte string
of ASCII spaces.
(ASCII_64): Likewise.
(ASCII_256): Likewise.
(ASCII_1024): Likewise.
(EBCDIC_16): Abuse of the preprocessor to create a 1024-byte string
of EBCDIC spaces.
(EBCDIC_64): Likewise.
(EBCDIC_256): Likewise.
(EBCDIC_1024): Likewise.
(__gg__compare_string_1a): New function.
(__gg__compare_string_1e): New function.
(__gg__compare_string_2): New function.
(__gg__compare_string_2a): New function.
(__gg__compare_string_4): New function.
(__gg__compare_string_4a): New function.
(__gg_compare_string_different): New function.
(__gg__compare_numeric_all): New function.
(__gg__compare_binary_to_string): New function.
* stringbin.cc (__gg__binary_to_string_ascii): Improved algorithm.

gcc/testsuite/ChangeLog:

* cobol.dg/group2/Check_for_equality_of_COMP-1___COMP-2.cob:
Corrected logic.
* cobol.dg/group2/ENTRY_statement.cob: Expanded test.
* cobol.dg/group2/ENTRY_statement.out: Likewise.
* cobol.dg/group2/FUNCTION_DATE___TIME_OMNIBUS.cob: Automated
generation of run-time environment variable.
* cobol.dg/group2/Intrinsic_Function_ABS.cob: Corrected.
* cobol.dg/group2/RETURN-CODE_moving.cob: Requires "dialect ibm".
* cobol.dg/group2/FUNCTION_TRIM_with_NATIONAL_characters.cob: New test.
* cobol.dg/group2/FUNCTION_TRIM_with_NATIONAL_characters.out: New test.
* cobol.dg/group2/Large_PIC_10000000_.cob: New test.
* cobol.dg/group2/Large_PIC_10000000_.out: New test.
* cobol.dg/group2/Nested_PERFORM.cob: New test.
* cobol.dg/group2/Nested_PERFORM.out: New test.
* cobol.dg/group2/Overlapping_MOVE.cob: New test.
* cobol.dg/group2/Overlapping_MOVE.out: New test.
* cobol.dg/group2/PERFORM_TIMES_subscripted.cob: New test.
* cobol.dg/group2/PERFORM_TIMES_subscripted.out: New test.
* cobol.dg/group2/PERFORM_VARYING_BY_-0.2.cob: New test.
* cobol.dg/group2/PERFORM_VARYING_BY_-0.2.out: New test.
* cobol.dg/group2/REDEFINES__chained.cob: New test.
* cobol.dg/group2/REDEFINES__chained.out: New test.
* cobol.dg/group2/RETURN-CODE_with_INITIAL_and_RECURSIVE.cob: New test.
* cobol.dg/group2/RETURN-CODE_with_INITIAL_and_RECURSIVE.out: New test.
* cobol.dg/group2/Sanity_check_for_ENTRY.cob: New test.
* cobol.dg/group2/Sanity_check_for_ENTRY.out: New test.
* cobol.dg/group2/Simple_COMP-X.cob: New test.
* cobol.dg/group2/Simple_COMP-X.out: New test.
* cobol.dg/group2/compare_alpha_to_all__literal_.cob: New test.
* cobol.dg/group2/compare_alpha_to_all__literal_.out: New test.
* cobol.dg/group2/compare_national_to_display.cob: New test.
* cobol.dg/group2/compare_national_to_display.out: New test.
* cobol.dg/group2/comprensive_compare_comp-1_comp-5.cob: New test.
* cobol.dg/group2/comprensive_compare_comp-1_comp-5.out: New test.
* cobol.dg/group2/refmod_with_nested_parentheses.cob: New test.
* cobol.dg/group2/refmod_with_nested_parentheses.out: New test.
* cobol.dg/group2/signed_unsigned_compare.cob: New test.
* cobol.dg/group2/signed_unsigned_compare.out: New test.

5 weeks agoICE with -Winfinite-recursion due to recursive rather than work queue/list [PR124651]
Heiko Eißfeldt [Tue, 7 Apr 2026 18:28:16 +0000 (20:28 +0200)] 
ICE with -Winfinite-recursion due to recursive rather than work queue/list [PR124651]

As suggested the control flow in
pass_warn_recursion::find_function_exit() was changed
from a recursive to an iterative form. The logic for detecting infinite
recursion is left unchanged.

This avoids stack overflows while handling very large functions
as could be seen with the generated code attached to the PR.

Reg tested OK.

2026-04-07 Heiko Eißfeldt <heiko@hexco.de>

PR middle-end/124651
* gimple-warn-recursion.cc (find_function_exit):
replace recursive calls with iteration for lower stack usage

5 weeks agodoc: Remove unused reference to @gol macro.
Léo Hardt [Tue, 12 May 2026 22:09:28 +0000 (19:09 -0300)] 
doc: Remove unused reference to @gol macro.

The @gol texinfo macro appears to have been used as a workaround for
achieving line breaks in gccoptlists, and has been removed on commit
43b72ed. The texi2pod rule to ignore it was not cleaned up at the time.

I did not find any references to @gol in the documentation, and building
man pages with and without the deleted rule produced identical files.

contrib/ChangeLog:

* texi2pod.pl: Remove rule to parse the defunct @gol macro.

Signed-off-by: Léo Hardt <leom.hardt@inf.ufrgs.br>
5 weeks agohppa64: Don't define MD_EXEC_PREFIX to "/usr/ccs/bin" on hpux
John David Anglin [Tue, 12 May 2026 19:58:26 +0000 (15:58 -0400)] 
hppa64: Don't define MD_EXEC_PREFIX to "/usr/ccs/bin" on hpux

In testing with GNU ld, I found defining MD_EXEC_PREFIX to "/usr/ccs/bin"
sometimes causes HP ld to be selected when we want GNU ld.

2026-05-12  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa64-hpux.h (MD_EXEC_PREFIX): Define to empty
string.

5 weeks agoAdd warnings of potentially-uninitialized padding bits
Christopher Bazley [Tue, 10 Feb 2026 15:33:07 +0000 (15:33 +0000)] 
Add warnings of potentially-uninitialized padding bits

    Commit 0547dbb725b reduced the number of cases in which
    union padding bits are zeroed when the relevant language
    standard does not strictly require it, unless gcc was
    invoked with -fzero-init-padding-bits=unions or
    -fzero-init-padding-bits=all in order to explicitly
    request zeroing of padding bits.

    This commit adds a closely related warning,
    -Wzero-init-padding-bits=, which is intended to help
    programmers to find code that might now need to be
    rewritten or recompiled with
    -fzero-init-padding-bits=unions or
    -fzero-init-padding-bits=all in order to replicate
    the behaviour that it had when compiled by older
    versions of GCC. It can also be used to find struct
    padding that was never previously guaranteed to be
    zero initialized and still isn't unless GCC is
    invoked with -fzero-init-padding-bits=all.

    The new warning can be set to the same three states
    as -fzero-init-padding-bits ('standard', 'unions'
    or 'all') and has the same default value ('standard').

    The two options interact as follows:

             f: standard  f: unions   f: all
    w: standard     X         X         X
    w: unions       U         X         X
    w: all          A         S         X

    X = No warnings about padding
    U = Warnings about padding of unions.
    S = Warnings about padding of structs.
    A = Warnings about padding of structs and unions.

    The level of optimisation and whether or not the
    entire initializer is dropped to memory can both
    affect whether warnings are produced when compiling
    a given program. This is intentional, since tying
    the warnings more closely to the relevant language
    standard would require a very different approach
    that would still be target-dependent, might impose
    an unacceptable burden on programmers, and would
    risk not satisfying the intended use-case (which
    is closely tied to a specific optimisation).

gcc/ChangeLog:

* common.opt: Add Wzero-init-padding-bits=.
* common.opt.urls: Regenerated.
* doc/invoke.texi: Document Wzero-init-padding-bits=.
* expr.cc (categorize_ctor_elements_1): Update new struct type
ctor_completeness instead of an integer to indicate presence of
padding or missing fields in a constructor. Instead of setting -1
upon discovery of padding bits in both structs and unions,
set separate flags to indicate the type of padding bits.
(categorize_ctor_elements): Update the type and documentation of
the p_complete parameter.
(mostly_zeros_p): Use new struct type ctor_completeness when
calling categorize_ctor_elements.
(all_zeros_p): Use new struct type ctor_completeness when
calling categorize_ctor_elements.
* expr.h (struct ctor_completeness): New struct type to replace an
an integer that could take the value -1 ('all fields are
initialized, but there's padding'), 0 ('fields are missing') or
1 ('all fields are initialized, and there's no padding'). Named
bool members make the code easier to understand and make room to
disambiguate struct padding bits from union padding bits.
(categorize_ctor_elements): Update the function declaration to use
the new struct type in the last parameter declaration.
* gimplify.cc (gimplify_init_constructor): Replace use of
complete_p != 0 ('all fields are initialized') with !sparse,
replace use of complete == 0 ('fields are missing') with sparse, and
replace use of complete <= 0 ('fields are missing' or 'all fields are
initialized, but there's padding') with sparse || padded_union or
padded_non_union. Trigger new warnings if storage for the object
is not zeroed but padded_union or padded_non_union is set
(because this combination implies possible non-zero padding bits).

gcc/testsuite/ChangeLog:

* gcc.dg/c23-empty-init-warn-1.c: New test.
* gcc.dg/c23-empty-init-warn-10.c: New test.
* gcc.dg/c23-empty-init-warn-11.c: New test.
* gcc.dg/c23-empty-init-warn-12.c: New test.
* gcc.dg/c23-empty-init-warn-13.c: New test.
* gcc.dg/c23-empty-init-warn-14.c: New test.
* gcc.dg/c23-empty-init-warn-15.c: New test.
* gcc.dg/c23-empty-init-warn-16.c: New test.
* gcc.dg/c23-empty-init-warn-17.c: New test.
* gcc.dg/c23-empty-init-warn-2.c: New test.
* gcc.dg/c23-empty-init-warn-3.c: New test.
* gcc.dg/c23-empty-init-warn-4.c: New test.
* gcc.dg/c23-empty-init-warn-5.c: New test.
* gcc.dg/c23-empty-init-warn-6.c: New test.
* gcc.dg/c23-empty-init-warn-7.c: New test.
* gcc.dg/c23-empty-init-warn-8.c: New test.
* gcc.dg/c23-empty-init-warn-9.c: New test.
* gcc.dg/gnu11-empty-init-warn-1.c: New test.
* gcc.dg/gnu11-empty-init-warn-10.c: New test.
* gcc.dg/gnu11-empty-init-warn-11.c: New test.
* gcc.dg/gnu11-empty-init-warn-12.c: New test.
* gcc.dg/gnu11-empty-init-warn-13.c: New test.
* gcc.dg/gnu11-empty-init-warn-14.c: New test.
* gcc.dg/gnu11-empty-init-warn-15.c: New test.
* gcc.dg/gnu11-empty-init-warn-16.c: New test.
* gcc.dg/gnu11-empty-init-warn-17.c: New test.
* gcc.dg/gnu11-empty-init-warn-2.c: New test.
* gcc.dg/gnu11-empty-init-warn-3.c: New test.
* gcc.dg/gnu11-empty-init-warn-4.c: New test.
* gcc.dg/gnu11-empty-init-warn-5.c: New test.
* gcc.dg/gnu11-empty-init-warn-6.c: New test.
* gcc.dg/gnu11-empty-init-warn-7.c: New test.
* gcc.dg/gnu11-empty-init-warn-8.c: New test.
* gcc.dg/gnu11-empty-init-warn-9.c: New test.

5 weeks agoc++: -Wzero-as-null-pointer-constant and <=> [PR100903]
Jason Merrill [Tue, 12 May 2026 15:27:29 +0000 (11:27 -0400)] 
c++: -Wzero-as-null-pointer-constant and <=> [PR100903]

(x <=> y) < 0 is the pattern suggested by the standard, we shouldn't warn
about it because of our implementation strategy.

We already disable the warning in <compare> to avoid warnings on the uses of
this pattern within the header, so no library changes are needed.

PR c++/100903

gcc/cp/ChangeLog:

* call.cc (build_over_call): Avoid -Wzero-as-null-pointer-constant
if the warning is disabled around the called function.

gcc/testsuite/ChangeLog:

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

5 weeks agoc++: deferred parsing of default arguments [PR50479]
Marek Polacek [Mon, 11 May 2026 21:19:42 +0000 (17:19 -0400)] 
c++: deferred parsing of default arguments [PR50479]

In

  void fn (int i = sizeof (i)) {}

the i in sizeof should refer to the parameter ([basic.scope.pdecl]) and
since the second i is not evaluated, the code is valid per
[dcl.fct.default]/9: A parameter shall not appear as a potentially
evaluated expression in a default argument.

This patch fixes this by moving the grokdeclarator call from
_parameter_declaration_list to _parameter_declaration and maybe calling
pushdecl before parsing the default argument.

PR c++/50479
PR c++/62244

gcc/cp/ChangeLog:

* parser.cc (cp_parser_parameter_declaration_list): Move the
grokdeclarator call and setting DECL_SOURCE_LOCATION to...
(cp_parser_parameter_declaration): ...here.  New tree parameter.
Set it.  Call pushdecl for a named decl with a default argument.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/parm1.C: Uncomment code.
* g++.dg/parse/defarg22.C: New test.
* g++.dg/parse/defarg23.C: New test.
* g++.dg/parse/defarg24.C: New test.
* g++.dg/parse/defarg25.C: New test.
* g++.dg/parse/defarg26.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
5 weeks agolibstdc++: Improve handling of leap second expiry time [PR123165]
Jonathan Wakely [Tue, 28 Apr 2026 12:15:22 +0000 (13:15 +0100)] 
libstdc++: Improve handling of leap second expiry time [PR123165]

This change allows the hardcoded list of leap seconds in <chrono> to be
used even when the program is executing after the hardcoded expiry date
in that header.

For times after the hardcoded expiry, the inline __get_leap_second_info
function calls a new library function which compares the number of
hardcoded leap seconds in the header with the number of leap seconds
defined in the tzdata leapseconds file (usually provided by the OS).

There are three leap second lists that are relevant here. The first is
the hardcoded list (and its expiry time) in the <chrono> header. That is
fixed when the user code is compiled, and might be out of date by the
time the application runs. The second list (and its expiry time) is
hardcoded in tzdb.cc in the libstdc++.so library. If the application
uses a newer libstdc++.so at runtime than the <chrono> header used at
compile time, we can still avoid going to the filesystem for dates
within the expiry time of the list in libstdc++.so. The third list is
the most up-to-date one which is read from the leapseconds file.

The code added by this commit tries to avoid reading the file when
possible (because that's slower than using the in-memory lists), and if
it does have to go to the file system, it tries to avoid doing so again
next time the leap seconds are needed.

libstdc++-v3/ChangeLog:

PR libstdc++/123165
* acinclude.m4 (libtool_VERSION): Bump version.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.36): Add new symbol
version and export new symbol.
* configure: Regenerate.
* include/std/chrono (__detail::__recent_leap_second_info):
Declare new function and make it a friend of varous classes.
(leap_second): Make private constructor constexpr. Remove friend
declaration for get_leap_second_info.
(__detail::__get_leap_second_info): Use new function for times
past the hardcoded expiry.
* src/c++20/tzdb.cc (tzdb_list::_Node::fixed_leaps): Move array
of leap seconds here from _S_read_leap_seconds.
(fixed_expiry, num_leap_seconds): New globals.
(__detail::__recent_leap_second_info): Define new function.
(tzdb_list::_Node::_S_read_leap_seconds): Populate vector from
_Node::fixed_leaps. Rename bool variable to clarify meaning.
(tzdb_list::_Node::_S_replace_head): Update num_leap_seconds
when updating the tzdb_list.
* testsuite/util/testsuite_abi.cc: Update known_versions and
latestp.
* testsuite/std/time/clock/utc/leap_second_info-2.cc: New test.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agotestsuite: fix reflect/bases_of5.C for -m32
Marek Polacek [Tue, 12 May 2026 13:19:21 +0000 (09:19 -0400)] 
testsuite: fix reflect/bases_of5.C for -m32

gcc/testsuite/ChangeLog:

* g++.dg/reflect/bases_of5.C: Use decltype (sizeof 0) instead of
unsigned long.

5 weeks agosra: Fix build_user_friendly_ref_for_offset for bit-fields (PR124151)
Martin Jambor [Tue, 12 May 2026 12:59:13 +0000 (14:59 +0200)] 
sra: Fix build_user_friendly_ref_for_offset for bit-fields (PR124151)

When SRA propagates bit-field propagations across assignments, it
first attempts to use build_user_friendly_ref_for_offset to represent
the expression of the new accesses and a possible scalar replacement
so that if there are any warnings generated for it, they are as nice
as we can make them.

However, this can lead to situations where, despite that the new
access has exactly the same type as the new old one, it accesses a
(record or union): field which is just big enough for its precision,
whereas the one we want to match has size rounded up to bytes.  This
causes discrepancy between the recorded size of the new access and the
size get_ref_base_and_extent reports for its expr, which trips the
verifier.

Unlike the previous approach which avoided propagation in the case of
bit fields, this patch fixes build_user_friendly_ref_for_offset by
making it also track the size it is looking at and the size it is
looking for so that it can declare success only if these two also
match.  Additionally, it reverts the simple bail-out fix for PR 117217
because it is no longer necessary.  (I have verified the bug is still
fixed though by applying the new fix on top of the last problematic
commit.)

gcc/ChangeLog:

2026-04-29  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/124151
* tree-sra.cc (build_user_friendly_ref_for_offset): Added parameters
CUR_SIZE and EXP_SIZE.  Added code passing the correct CUR_SIZE and
checking it against EXP_SIZE.  Removed unused code for the case when
EXP_TYPE was NULL_TREE.
(create_artificial_child_access): Adjusted the call to
build_user_friendly_ref_for_offset.
(propagate_subaccesses_from_rhs): Likewise.
(propagate_subaccesses_from_rhs): Removed a check that the size of
lchild is a multiple of BITS_PER_UNIT.
(propagate_subaccesses_from_lhs): Likewise.

gcc/testsuite/ChangeLog:

2026-04-29  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/124151
* gcc.dg/tree-ssa/pr124151.c: New test.

5 weeks agoRX: Fix infinite-loop on LRA [PR113948]
Yoshinori Sato [Tue, 12 May 2026 11:39:07 +0000 (12:39 +0100)] 
RX: Fix infinite-loop on LRA [PR113948]

The LRA was confused and looping due to the definition of the register class.
The LRA yielded incorrect results because the manipulation of stack frames
and the movement of double words relied heavily on existing reloads.
These changes ensure that the correct code is generated even when the "-mlra"
option is specified.

gcc/ChangeLog:
PR target/113948

* config/rx/rx-protos.h (rx_split_double_move): New helper prototype.
(rx_relax_double_operands): Likewise.
* config/rx/rx.cc (rx_legitimize_address): Add expand complex case.
(rx_is_legitimate_address): Add double word case.
(rx_gen_move_template): Fix operation size in unsigned extend.
(rx_gen_move_template): Remove DImode and DFmode.
(rx_get_stack_layout): Fix for frame size calculation.
(rx_initial_elimination_offset): The calculation method has been
changed to one that supports LRA.
(rx_hard_regno_nregs): Use CEIL.
(rx_hard_regno_mode_ok): Add ATTRIBUTE_UNUSED.
(rx_get_subword): New. Double word move helper.
(rx_split_double_move): Likewise.
(rx_relax_double_operands): Likewise.
* config/rx/rx.h (reg_class): Add CC for all regsisters.
(CLASS_MAX_NREGS): Remove.
* config/rx/rx.md (mov<register_modes:mode>):
Replace copy_to_mode_reg to force_reg.
(movdi): Limit the arguments to make register allocation easier.
(movdf): Likewise.
(movdi_internal): New.
(movdf_internal): New.
(addsi3_pid): New. Handling UNSPEC_PID_ADDR.
(addsi3_lra): New. alternative addptrsi3.
(ashlsi3_lra): Likewise.

Signed-off-by: Yoshinori Sato <yoshinori.sato@nifty.com>
5 weeks ago[PATCH 2/2] tree-optimization/vect: Allow single-lane SLP fallback when limit is...
Lili Cui [Tue, 12 May 2026 17:01:00 +0000 (10:01 -0700)] 
[PATCH 2/2] tree-optimization/vect: Allow single-lane SLP fallback when limit is exhausted

In vect_analyze_slp_reduction, the early bail "if (*limit == 0) return
false" blocked all SLP discovery including the single-lane fallback path.
However, single-lane SLP trees (group_size == 1) do not consume the
discovery limit as they cannot cause exponential tree growth.

This causes vectorization failures in loops with many independent
conditional reductions: multi-lane grouping attempts exhaust the limit,
then the single-lane fallback that would have succeeded is incorrectly
rejected.

The fix moves the limit check to only guard chain analysis (which builds
multi-lane trees and does consume limit), allowing the single-lane
fallback to always proceed.

This improves 731.astcenc_r (-Ofast) by 3.8% on EMR and 1.4% on Znver5 with single-copy.

gcc/ChangeLog:

* tree-vect-slp.cc (vect_analyze_slp_reduction): Don't bail out
early when SLP discovery limit is exhausted; only guard the chain
analysis which may build multi-lane trees.  Single-lane fallback
does not consume limit and should always be attempted.

Co-authored-by: Hongtao Liu <hongtao.liu@intel.com>
5 weeks ago[PATCH 1/2] tree-optimization/vect: Allow commutative operand swap for IFN in SLP...
Lili Cui [Tue, 12 May 2026 17:00:00 +0000 (10:00 -0700)] 
[PATCH 1/2] tree-optimization/vect: Allow commutative operand swap for IFN in SLP reduction

In vect_build_slp_tree_1, when checking whether reduction operands at
different positions can be swapped, only tree_code operations (e.g.
PLUS_EXPR) were recognized as commutative.  Internal functions produced
by if-conversion (e.g. .COND_ADD, .COND_MUL) were not handled, causing
"different reduc_idx" failures when the reduction operand appeared at
different commutative positions across SLP lanes.

This patch extends the commutative swap recognition to internal
functions using the unified first_commutative_argument(code_helper, tree)
interface to identify the swappable operand pair for both tree codes and
internal functions.

This improves 731.astcenc_r (-Ofast) by 7.1% on EMR and 2.48% on Znver5.

gcc/ChangeLog:

* tree-vect-slp.cc (vect_build_slp_tree_1): Use unified
first_commutative_argument interface to allow commutative
operand swap for both tree codes and internal functions
(e.g. .COND_ADD) in SLP reduction matching.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/slp-reduc-15.c: New test.

Co-authored-by: Hongtao Liu <hongtao.liu@intel.com>
5 weeks agoAvoid setting ls_type when unused
Richard Biener [Tue, 12 May 2026 08:40:56 +0000 (10:40 +0200)] 
Avoid setting ls_type when unused

The following avoids setting the ls_type on loads/stores when that
type isn't used.

* tree-vect-stmts.cc (get_load_store_type): Pass
temporary to vect_use_grouped_gather, only set ls_type
when that succeeded.

5 weeks agomatch.pd: rearrange (VCE (BFR)) simplification conditions [PR125259]
Artemiy Volkov [Mon, 11 May 2026 09:06:12 +0000 (09:06 +0000)] 
match.pd: rearrange (VCE (BFR)) simplification conditions [PR125259]

The precondition for (view_convert (BIT_FIELD_REF)) simplification at
match.pd:5881 last fixed in r16-4735-g44c27171c36a91 is still wrong,
as it allows a vector type to be converted to/from _BitInt types (for
which precision can be smaller than size).  Address this by always
checking type_has_mode_precision_p () for all integer types.  (This fix
was posted by Richard B. at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125259#c5.)

Add a testcase as reduced in the PR as tree-ssa/pr125259.c.

Bootstrapped and regtested on aarch64, arm, and x86_64.

OK for trunk and 16?

PR middle-end/125259

gcc/ChangeLog:

* match.pd: Fix the view_convert (BIT_FIELD_REF) pattern.

gcc/testsuite/ChangeLog:

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

5 weeks agovxworks: support aarch64 errata
Alexandre Oliva [Mon, 11 May 2026 06:47:03 +0000 (03:47 -0300)] 
vxworks: support aarch64 errata

I noticed that aarch64 errata required specs tweaks that were missing
on vxworks.  To my surprise, adding those specs enabled even the
linker tests to pass, despite using vxlink and not always performing
final links.  Ok, then, reverting the skip directives added not too
long ago.

for  gcc/ChangeLog

* config.gcc [aarch64*-wrs-vxworks*] (tm_file): Add
aarch64/aarch64-errata.h.
* config/aarch64/aarch64-vxworks.h (LINK_SPEC): Add
AARCH64_ERRATA_LINK_SPEC.
(CC1_SPEC, CC1PLUS_SPEC): Add AARCH64_ERRATA_COMPILE_SPEC.

for  gcc/testsuite/ChangeLog

* gcc.target/aarch64/erratas_opt_0.c: Revert skip on VxWorks.
* gcc.target/aarch64/erratas_opt_1.c: Likewise.
* gcc.target/aarch64/erratas_opt_2.c: Likewise.
* gcc.target/aarch64/erratas_opt_3.c: Likewise.
* gcc.target/aarch64/erratas_opt_4.c: Likewise.
* gcc.target/aarch64/erratas_opt_5.c: Likewise.
* gcc.target/aarch64/erratas_opt_6.c: Likewise.
* gcc.target/aarch64/erratas_opt_7.c: Likewise.
* gcc.target/aarch64/erratas_opt_8.c: Likewise.
* gcc.target/aarch64/erratas_opt_9.c: Likewise.
* gcc.target/aarch64/erratas_opt_10.c: Likewise.
* gcc.target/aarch64/erratas_opt_11.c: Likewise.
* gcc.target/aarch64/erratas_opt_12.c: Likewise.
* gcc.target/aarch64/erratas_opt_13.c: Likewise.
* gcc.target/aarch64/erratas_opt_14.c: Likewise.
* gcc.target/aarch64/erratas_opt_15.c: Likewise.

5 weeks agolibstdc++: vxworks: enable clock_gettime
Alexandre Oliva [Mon, 11 May 2026 06:46:46 +0000 (03:46 -0300)] 
libstdc++: vxworks: enable clock_gettime

We've been using gettimeofday() on VxWorks, because configury didn't
state clock_gettime was available.  It has been since at least
vxworks6.9, possibly earlier.  Indeed, it's been available for longer
than gettimeofday(), so this enables libstdc++'s chrono.cc to work
with earlier 6.9 releases.

We've used clock_gettime unconditionally in __gthread_cond_timedwait
for a very long time, so it's not like this brings in a new
dependency, but it allows clocks and deadlines to work with the same
precision.  Before this change, we'd use gettimeofday's coarser
clocks, and finer timed waits, which makes room for imprecisions.

for  libstdc++-v3/ChangeLog

* acinclude.m4 (GLIBXX_ENABLE_LIBSTDCXX_TIME) [vxworks*]:
Enable monotonic and realtime clocks.
* configure: Rebuilt.

5 weeks agotestsuite: pr94994: include stddef.h for size_t
Alexandre Oliva [Tue, 12 May 2026 06:29:29 +0000 (03:29 -0300)] 
testsuite: pr94994: include stddef.h for size_t

The testcase refers to size_t without including stddef.h.

for  gcc/testsuite/ChangeLog

* gcc.dg/vect/pr94994.c: Include stddef.h.

5 weeks agotestsuite: riscv: reset -march for tests with -mcpu
Alexandre Oliva [Tue, 12 May 2026 06:29:10 +0000 (03:29 -0300)] 
testsuite: riscv: reset -march for tests with -mcpu

The tests fail when --target_board sets -march to a 32-bit
architecture.  Override that -march by resetting it, so that the arch
implied by -mcpu prevails.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/pr114139.c: Reset arch.
* gcc.target/riscv/pr118170.c: Likewise.

5 weeks agotree-optimization: Fold SAT_ADD at gimple level
Naveen [Tue, 12 May 2026 04:08:11 +0000 (21:08 -0700)] 
tree-optimization: Fold SAT_ADD at gimple level

Extend scalar SAT_ADD constant folding to recognize cases where one operand is
zero. It allows SAT_ADD expressions with constant operands to fold away early.
The change improves optimization opportunities and avoids emitting unnecessary
SAT_ADD operations.
Bootstrapped and tested on aarch64-linux-gnu.

PR middle-end/123286

gcc/ChangeLog:
* fold-const-call.cc (fold_internal_fn_sat_add): New function.
(fold_const_call): Handle CFN_SAT_ADD.
* match.pd: Add simplifications for x SAT_ADD 0 == x.
* genmatch.cc (commutative_op): Add CFN_SAT_ADD.

gcc/testsuite/ChangeLog:
* gcc.dg/pr123286.c: New test.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
5 weeks ago[Aarch64]: Make aarch64_output_simd_mov_imm_low return const char *
Naveen [Tue, 12 May 2026 04:04:38 +0000 (21:04 -0700)] 
[Aarch64]: Make aarch64_output_simd_mov_imm_low return const char *

aarch64_output_simd_mov_imm_low emits the instruction directly using
output_asm_insn and returns an empty string to indicate that no further
template needs to be emitted.  Since the returned empty string is a string
literal, the function should return const char * rather than char *.

This fixes a bootstrap failure with -Werror=write-strings.

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h (aarch64_output_simd_mov_imm_low):
Change return type to const char *.
* config/aarch64/aarch64.cc (aarch64_output_simd_mov_imm_low): Likewise.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
5 weeks agoc++/reflection: fixes for comparing reflections [PR125208]
Marek Polacek [Thu, 7 May 2026 20:38:34 +0000 (16:38 -0400)] 
c++/reflection: fixes for comparing reflections [PR125208]

This fixes two bugs:

1) crash in cp_tree_equal when comparing reflections with binfos;
cp_tree_equal doesn't handle those.  We're coming from
lookup_template_class -> spec_hasher::equal -> comp_template_args
-> cp_tree_equal.  We should use compare_reflections in cp_tree_equal.

2) the fix for 1) revealed that compare_reflections is buggy when
comparing two aliases: we shouldn't fall back to same_type_p
because given

   using A = int;
   using B = int;

^^A != ^^B should hold.

PR c++/125208

gcc/cp/ChangeLog:

* reflect.cc (compare_reflections): Use == when comparing two
aliases.
* tree.cc (cp_tree_equal) <case REFLECT_EXPR>: Use
compare_reflections.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/alias3.C: New test.
* g++.dg/reflect/bases_of5.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
5 weeks agoDaily bump.
GCC Administrator [Tue, 12 May 2026 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agocontrib: Fix check_GNU_style.py for some .opt issues [PR125275]
Andrew Pinski [Mon, 11 May 2026 21:34:58 +0000 (14:34 -0700)] 
contrib: Fix check_GNU_style.py for some .opt issues [PR125275]

I noticed while reviewing a patch check_GNU_style.py would fail
for the .opt files in a few ways. First greater than 80 columns
is expected. Second is the space after the "function".
Both of these are not useful for .opt so let's ignore then here.

PR other/125275
contrib/ChangeLog:

* check_GNU_style_lib.py (LineLengthCheck.check): Ignore
filenames that end with .opt.
(FunctionParenthesisCheck.check): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agoc++/reflection: add null_reflection_p
Jason Merrill [Sat, 9 May 2026 09:15:01 +0000 (05:15 -0400)] 
c++/reflection: add null_reflection_p

I wanted to improve %E of info{}, and it seemed desirable to have a
shorter way to spell this test.

gcc/cp/ChangeLog:

* reflect.cc (null_reflection_p): New.
(splice): Use it.
* error.cc (dump_expr): Use it.
* cp-tree.h (null_reflection_p): Declare.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/pr125007.C: Add info{} test.

5 weeks agohppa64: Fix linking of libgcc on HP-UX with GNU ld
John David Anglin [Mon, 11 May 2026 20:04:24 +0000 (16:04 -0400)] 
hppa64: Fix linking of libgcc on HP-UX with GNU ld

2026-05-11  John David Anglin  <danglin@gcc.gnu.org>

libgcc/ChangeLog:

* config.host (hppa*64*-hp-hpux11*): Handle linking with GNU ld.
* config/pa/libgcc-hpux.ver: New file.
* config/pa/t-slibgcc-gld: New file.
* config/pa/t-slibgcc-hpux (SHLIB_LDFLAGS, INSTALL_SHLIB,
SHLIB_MKMAP, SHLIB_MAPFILES): Define.

5 weeks agolm32: enable LRA after testing showed minimal regressions.
William D. Jones [Mon, 11 May 2026 19:35:37 +0000 (13:35 -0600)] 
lm32: enable LRA after testing showed minimal regressions.

PR target/120077
gcc/ChangeLog:
* config/lm32/lm32.cc: Enable LRA after diff testing showed minimal issues.

5 weeks agoc-family: look through non-user-facing typedef [PR124621]
Jason Merrill [Mon, 11 May 2026 15:55:06 +0000 (11:55 -0400)] 
c-family: look through non-user-facing typedef [PR124621]

'aka' printing shouldn't differ between in-tree and installed compilers due
to difference in whether libstdc++ headers are considered to be system
headers.  The problem was that if we encounter a non-user-facing typedef
like __iter_type<T>, we stopped there instead of continuing to look through
typedefs to find the underlying user type.

PR c++/124621

gcc/c-family/ChangeLog:

* c-common.cc (user_facing_original_type_p): Recurse.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/reflect_constant_array2.C: Add -D_GLIBCXX_SYSHDR.

5 weeks agoc++: refine decl_defined_p
Marek Polacek [Thu, 7 May 2026 19:39:09 +0000 (15:39 -0400)] 
c++: refine decl_defined_p

As discussed in the 124770 patch.  This makes decl_defined_p correct
for more cases.

gcc/cp/ChangeLog:

* decl2.cc (decl_defined_p): Also return true if DECL_INITIAL
and !DECL_IN_AGGR_P is true for a VAR_DECL.

Reviewed-by: Jason Merrill <jason@redhat.com>
5 weeks agofortran: Add -fcoarray=shared option to auto-link -lcaf_shmem
Jerry DeLisle [Sat, 9 May 2026 18:49:21 +0000 (11:49 -0700)] 
fortran: Add -fcoarray=shared option to auto-link -lcaf_shmem

The new -fcoarray=shared option provides a convenient shorthand for
the common invocation -fcoarray=lib -lcaf_shmem.  The driver transforms
-fcoarray=shared into -fcoarray=lib for the frontend and automatically
appends -lcaf_shmem to the link command.  Existing uses of -fcoarray=lib
are unaffected.

Assisted by: Claude Sonnet 4.6

gcc/:

* flag-types.h (gfc_fcoarray): Add GFC_FCOARRAY_SHARED.

gcc/fortran/:

* lang.opt (fcoarray=): Add shared enum value; update help text.
* gfortranspec.cc (CAF_SHMEM_LIBRARY): New macro.
(lang_specific_driver): Detect -fcoarray=shared in first pass and
set need_caf_shmem flag.  In second pass, transform -fcoarray=shared
to -fcoarray=lib for cc1.  Append -lcaf_shmem when need_caf_shmem
is set and linking is active.

gcc/testsuite/:

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

5 weeks agoxtensa: Assert the results of several validate_change() calls
Takayuki 'January June' Suwa [Sun, 10 May 2026 06:25:01 +0000 (15:25 +0900)] 
xtensa: Assert the results of several validate_change() calls

I regret that I've been using validate_change() thoughtlessly until now,
and should at least verify whether the RTX changes were successful.

I hope this patch doesn't cause any problems, but if not, I will take some
kind of new action.

gcc/ChangeLog:

* config/xtensa/xtensa.cc
(FPreg_neg_scaled_simm12b, convert_SF_const, constantsynth_pass1,
litpool_set_src_1, litpool_set_src):
Change each call to validate_change() and apply_change_group() to
trigger an ICE if the result is not true.

5 weeks agoxtensa: Revise xtensa_expand_prologue()
Takayuki 'January June' Suwa [Sun, 10 May 2026 05:54:36 +0000 (14:54 +0900)] 
xtensa: Revise xtensa_expand_prologue()

No functional changes.

gcc/ChangeLog:

* config/xtensa/xtensa.cc
(xtensa_can_eliminate_callee_saved_reg_p):
Change the arguments that return values from being passed by pointer
to C++ reference.
(xtensa_expand_prologue):
Adjust the call to xtensa_can_eliminate_callee_saved_reg_p() to
match the above changes.

5 weeks agoxtensa: Define HONOR_REG_ALLOC_ORDER as 1
Takayuki 'January June' Suwa [Fri, 8 May 2026 21:04:48 +0000 (06:04 +0900)] 
xtensa: Define HONOR_REG_ALLOC_ORDER as 1

Since the commit of the preceding patch for IRA, "ira: Scale save/restore
costs of callee save registers with block frequency" (3b9b8d6cfdf59337f4b7ce10ce92a98044b2657b),
the Xtensa ISA has shown a tendency to allocate slightly more function stack
frames, especially when using the CALL0 ABI.

     /* example */
     extern void foo(void);
     int test(int a) {
       int array[252];
       foo();
       asm volatile (""::"m"(array));
       return a;
     }

     ;; before (-O2 -mabi=call0)
     test:
      addi sp, sp, -16
      s32i.n a0, sp, 12
      addmi sp, sp, -0x400
      s32i a2, sp, 1008
      call0 foo
      l32i a2, sp, 1008
      addmi sp, sp, 0x400
      l32i.n a0, sp, 12
      addi sp, sp, 16
      ret.n

This patch disables the incorrect register save cost estimation in function
prologues/epilogues by defining the HONOR_REG_ALLOC_ORDER macro as 1.

     ;; after (-O2 -mabi=call0)
     test:
      addmi sp, sp, -0x400
      s32i a0, sp, 1020
      s32i a2, sp, 1016
      call0 foo
      l32i a2, sp, 1016
      l32i a0, sp, 1020
      addmi sp, sp, 0x400
      ret.n

gcc/ChangeLog:

* config/xtensa/xtensa.h (HONOR_REG_ALLOC_ORDER):
New macro definition.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/elim_callee_saved.c:
Revise the test item for the number of mov instructions in the
assembler output.

5 weeks agoAArch64: Turn on GPR narrowing pass by default
Tamar Christina [Mon, 11 May 2026 14:58:52 +0000 (15:58 +0100)] 
AArch64: Turn on GPR narrowing pass by default

This turns on the GPR narrowing pass for all AArch64 targets.

gcc/ChangeLog:

* config/aarch64/aarch64-tuning-flags.def
(AARCH64_EXTRA_TUNE_BASE): Add AARCH64_EXTRA_TUNE_NARROW_GP_WRITES.

5 weeks agoMatch: Move saturation alu patterns into match-sat-alu.pd [NFC]
Pan Li [Fri, 8 May 2026 01:41:01 +0000 (09:41 +0800)] 
Match: Move saturation alu patterns into match-sat-alu.pd [NFC]

Given there are lots of sat alu patterns in match.pd, and
there will more in short future.  Move all of them into
a separated file for better org.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

gcc/ChangeLog:

* Makefile.in: Add match-sat-alu.pd as dependency.
* match.pd: Remove saturation alu related patterns.
* match-sat-alu.pd: Add new file for saturation alu patterns.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 weeks agoi386: Keep SEH enabled for Win64 sysv_abi functions
Oleg Tolmatcev [Wed, 6 May 2026 17:20:31 +0000 (19:20 +0200)] 
i386: Keep SEH enabled for Win64 sysv_abi functions

TARGET_SEH currently depends on TARGET_64BIT_MS_ABI.  For Win64
functions compiled with SysV ABI, that makes the SEH hooks drop out
even though exception handling still emits .seh_handlerdata.  The
result is assembly with .seh_handlerdata outside any .seh_proc block.

Keep TARGET_SEH enabled for all 64-bit Windows functions when unwind
tables are requested so SEH prologue and handler state remains
consistent across ABI variants.

Add a regression test covering a SysV ABI wrapper trampoline that
references a throwing callee on x86_64 mingw.

gcc/ChangeLog:

* config/i386/cygming.h (TARGET_SEH): Keep SEH enabled for all
64-bit Windows functions when unwind tables are requested.

gcc/testsuite/ChangeLog:
* g++.target/i386/seh-sysvabi-wrap1.C: New test.

Signed-off-by: oltolm <oleg.tolmatcev@gmail.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
5 weeks agotree-optimization/125250 - LIM speculating not noop load/store
Richard Biener [Mon, 11 May 2026 08:25:57 +0000 (10:25 +0200)] 
tree-optimization/125250 - LIM speculating not noop load/store

The following avoids speculating a load/store pair for modes
that cannot transfer bits or, as for the testcase, bitfield
loads that are either value changing or invoke UB when out-of-bound
(and that we'd rewrite to be defined with explicit truncation).

PR tree-optimization/125250
* tree-ssa-loop-im.cc (execute_sm): For modes that cannot
transfer bits, _Bool and bitfield accesses force the
multi-threaded model.

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

5 weeks agomingw: Ensure symbols are quoted in Intel syntax
LIU Hao [Fri, 8 May 2026 13:02:23 +0000 (21:02 +0800)] 
mingw: Ensure symbols are quoted in Intel syntax

Previously, this code

   extern int shl;
   int get_shl(void) { return shl; }

gave errors like

   $ x86_64-w64-mingw32-gcc -masm=intel test.c
   ccUSyr0f.s: Assembler messages:
   ccUSyr0f.s:24: Error: invalid use of operator "shl"

because it contained

   .refptr.shl:
       .quad   shl

This `shl` should have referenced the symbol, but it appeared in an expression
context, where, in Intel syntax, it got interpreted as the shift-left operator.

This commit fixes the issue by emitting the target symbol with
`ASM_OUTPUT_LABELREF`, which will quote it properly with regard to the output
assembler syntax.

PR target/53929

gcc/ChangeLog:

* config/mingw/winnt.cc (mingw_pe_file_end): Use `ASM_OUTPUT_LABELREF`
to emit `name`.

Signed-off-by: LIU Hao <lh_mouse@126.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
5 weeks agolibstdc++: Reorder compile-time checks for __formatter_str::_M_format_range.
Tomasz Kamiński [Wed, 6 May 2026 13:22:06 +0000 (15:22 +0200)] 
libstdc++: Reorder compile-time checks for __formatter_str::_M_format_range.

If _M_format_range was called with prvalue of span S (or any contiguous_range),
the previous chain of if-contexpr will call _M_format_range<S&>, then
_M_format_range<const S&> and then format(string_view). By checking for
contiguous_range first, it calls format(string_view) direclty, removing
unnecessary instantiations and symbols.

Similary, for all prvalues of type R, that meet __simply_formattable_range R,
we were instantiating _M_format_range<R&> and then _M_format_range<const R&>.
By moving the if for __simply_formattable_range before is_lvalue_reference_v,
we call _M_format_range<const R&> direclty.

libstdc++-v3/ChangeLog:

* include/std/format (__formatter_str::_M_format_range):
Reorder constexpr checks, to reduce number of instantiations.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoadjust OMP SIMD call cost
Richard Biener [Wed, 6 May 2026 11:43:27 +0000 (13:43 +0200)] 
adjust OMP SIMD call cost

The following adds special handling to OMP SIMD vector call costs
which were not costed at all and for which a single simple vector
stmt isn't appropriate.  PR125174 shows that even when AVX imposes
more overhead (from also slightly bogus costing) than SSE, when
there's two OMP SIMD calls involved doing less of those should trump
that.

PR target/125174
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Cost calls as 10 times FMA.

5 weeks agocombine: Reject any resulting insns using hard reg constraints [PR121426]
Stefan Schulze Frielinghaus [Mon, 11 May 2026 06:37:58 +0000 (08:37 +0200)] 
combine: Reject any resulting insns using hard reg constraints [PR121426]

This fixes

t.c:6:1: error: unable to find a register to spill
    6 | }
      | ^

for target avr.  In the PR we are given a patch which makes use of hard
register constraints in the machine description for divmodhi4.  Prior
combine we have for the test from the PR

(insn 7 6 8 2 (parallel [
            (set (reg:HI 46 [ _1 ])
                (div:HI (reg/v:HI 44 [ k ])
                    (reg:HI 48)))
            (set (reg:HI 47)
                (mod:HI (reg/v:HI 44 [ k ])
                    (reg:HI 48)))
            (clobber (scratch:HI))
            (clobber (scratch:QI))
        ]) "t.c":5:5 602 {divmodhi4}
     (expr_list:REG_DEAD (reg:HI 48)
        (expr_list:REG_DEAD (reg/v:HI 44 [ k ])
            (expr_list:REG_UNUSED (reg:HI 47)
                (nil)))))
(insn 8 7 9 2 (set (reg:HI 22 r22)
        (symbol_ref/f:HI ("*.LC0") [flags 0x2]  <var_decl 0x3fff7950d10 *.LC0>)) "t.c":5:5 128 {*movhi_split}
     (nil))
(insn 9 8 10 2 (set (reg:HI 24 r24)
        (reg:HI 46 [ _1 ])) "t.c":5:5 128 {*movhi_split}
     (expr_list:REG_DEAD (reg:HI 46 [ _1 ])
        (nil)))

The patched instruction divmodhi4 constraints operand 2 (here pseudo
48) to hard register 22.  Combine merges insn 7 into 9 by crossing a
hard register assignment of register 22.

(note 7 6 8 2 NOTE_INSN_DELETED)
(insn 8 7 9 2 (set (reg:HI 22 r22)
        (symbol_ref/f:HI ("*.LC0") [flags 0x2]  <var_decl 0x3fff7950d10 *.LC0>)) "t.c":5:5 128 {*movhi_split}
     (nil))
(insn 9 8 10 2 (parallel [
            (set (reg:HI 24 r24)
                (div:HI (reg:HI 49 [ k ])
                    (reg:HI 48)))
            (set (reg:HI 47)
                (mod:HI (reg:HI 49 [ k ])
                    (reg:HI 48)))
            (clobber (scratch:HI))
            (clobber (scratch:QI))
        ]) "t.c":5:5 602 {divmodhi4}
     (expr_list:REG_DEAD (reg:HI 48)
        (expr_list:REG_DEAD (reg:HI 49 [ k ])
            (nil))))

This leaves us with a conflict for pseudo 48 in the updated insn 9 since
register 22 is live here.

Fixed by pulling the sledge hammer and rejecting any resulting insn
which makes use of hard register constraints.  Ideally we would skip
based on the fact whether a combination crosses a hard register
assignment and the corresponding hard register is also referred by a
single register constraint of the resulting insn.

PR rtl-optimization/121426

gcc/ChangeLog:

* combine.cc (recog_for_combine_1): Reject insns which make use
of hard register constraints.

5 weeks ago[PATCH] [Aarch64]: Use fmov for some low-lane FP SIMD constant vectors
Naveen [Mon, 11 May 2026 05:45:41 +0000 (22:45 -0700)] 
[PATCH] [Aarch64]: Use fmov for some low-lane FP SIMD constant vectors

Extend AdvSIMD constant materialization to recognize vectors where only
the low element is a representable floating-point constant and all other
elements are zero.
Bootstrapped and tested on aarch64-linux-gnu.

PR target/113856

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h
(aarch64_output_simd_mov_imm_low): New.
(aarch64_const_vec_fmov_p): New.
* config/aarch64/aarch64-simd.md (mov<mode>): Do not expand constant
vectors handled by aarch64_const_vec_fmov_p into VDUP.
(*aarch64_simd_mov<VDMOV:mode>): Add Dc alternatives for FMOV based
SIMD constant moves.
(*aarch64_simd_mov<VQMOV:mode>): Likewise.
* config/aarch64/aarch64.cc (aarch64_const_vec_fmov_p): New function.
(aarch64_output_simd_mov_imm_low): New function.
* config/aarch64/constraints.md (Dc): New constraint.

gcc/testsuite/ChangeLog:
* gcc.target/aarch64/pr113856.c: New test.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
5 weeks agoUpdate Email in MAINTAINERS
Naveen [Mon, 11 May 2026 05:16:13 +0000 (22:16 -0700)] 
Update Email in MAINTAINERS

ChangeLog:

* MAINTAINERS: Update my email and add myself to the DCO
section.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
5 weeks ago[PATCH] combine: Check against CLOBBER in make_compound_operation_int [PR125209]
Boudewijn van der Heide [Mon, 11 May 2026 03:46:48 +0000 (21:46 -0600)] 
[PATCH] combine: Check against CLOBBER in make_compound_operation_int [PR125209]

In combine_simplify_rtx, CLOBBER can be returned, which is propagated to
make_compound_operation.  When make_compound_operation_int then calls
simplify_subreg, it triggers a gcc_assert, because the mode is neither inner,
nor void. This results in an ICE.

We fix this by checking if we got CLOBBER before calling simplify_subreg from
make_compound_operation and bail out; we return NULL_RTX.

Testcase from the bug report by Zhendong Su.

Bootstrapped and tested on x86_64-linux-gnu.

PR rtl-optimization/125209

gcc/
* combine.cc (make_compound_operation_int): Return NULL_RTX if we got CLOBBER.

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

Signed-off-by: Boudewijn van der Heide <boudewijn@delta-utec.com>
5 weeks ago[RISC-V][PR rtl-optimization/80770] Simplify bit flipping operations down to xor
Shreya Munnangi [Mon, 11 May 2026 03:37:29 +0000 (21:37 -0600)] 
[RISC-V][PR rtl-optimization/80770] Simplify bit flipping operations down to xor

So this is the target independent work to finish resolving pr80770.  It's a
combination of Shreya's efforts and my own.

To recap, the basic idea is we want to simplify RTL blobs which ultimately are
just flipping a bit.  Consider:

> (set (reg:DI 153)
>      (ior:DI (and:DI (reg:DI 140 [ *s_4(D) ])
>              (const_int 254 [0xfe]))
>          (and:DI (not:DI (reg:DI 140 [ *s_4(D) ]))
>              (const_int 1 [0x1]))))

The first operand of the IOR clears the low bit of the source register leaving
everything else unchanged.  The second operand of the IOR clears everything but
the low bit and flips the low bit. When we IOR those together we get the
original value with the lowest bit flipped.  The key is to realize we have the
same pseudo in both arms and there are no bits in common for the constants. So
this works for an arbitrary bit(s) as long as the constants have the right
form.

That gets us good code on riscv and almost certainly helps other targets.
There is another form which shows up on the H8 and possibly other targets
sub-word arithmetic.  op0 and op1 are respectively:

> (gdb) p debug_rtx (op0)
> (and:QI (reg:QI 24 [ *s_4(D) ])
>     (const_int 127 [0x7f]))
> $1 = void
> (gdb) p debug_rtx (op1)
> (plus:QI (and:QI (reg:QI 24 [ *s_4(D) ])
>         (const_int -128 [0xffffffffffffff80]))
>     (const_int -128 [0xffffffffffffff80]))
> $2 = void

Note we're in QImode.  op1 just flips the highest QImode bit.  If there are
carry-outs, we don't really care about them.  The net is we can capture that
case on the H8 by verifying this form flips the highest bit for the given mode.
Otherwise the carry-outs are relevant and our transformation is incorrect.

Plan is to commit Friday.  While it has been tested with the usual bootstraps
as well as testing on various cross platforms, I'm more comfortable giving
folks time to take a looksie to see if Shreya or I missed anything critical.

For the testcase in question before/afters look like this:

x86:
        movzbl  (%rdi), %eax
        movl    %eax, %edx
        andl    $-2, %eax
        andl    $1, %edx
        xorl    $1, %edx
        orl     %edx, %eax
        movb    %al, (%rdi)

  Turns into:

        xorb    $1, (%rdi)

RISC-V:

        lbu     a5,0(a0)
        andi    a4,a5,1
        xori    a4,a4,1
        andi    a5,a5,-2
        or      a5,a5,a4
        sb      a5,0(a0)

  Turns into:

        lbu     a5,0(a0)
        xori    a5,a5,1
        sb      a5,0(a0)

PR rtl-optimization/80770
gcc/
* rtl.h (simplify_context::simplify_ior_with_common_term): Add
new method.
(simplify_context::simplify_binary_operation_1): Use new method.
* simplify-rtx.cc (simplify_context::simplify_ior_with_common_term):
New method.

gcc/testsuite/

* gcc.target/riscv/pr80770.c: New test.
* gcc.target/riscv/pr80770-2.c: New test.
* gcc.target/h8300/pr80770.c: New test.
* gcc.target/h8300/pr80770-2.c: New test.

Co-authored-by: Jeff Law <jeffrey.law@oss.qualcomm.com>
5 weeks agoDaily bump.
GCC Administrator [Mon, 11 May 2026 00:16:22 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agogcov: Read the right arc flag in json output
Jørgen Kvalsvik [Sun, 10 May 2026 11:26:59 +0000 (13:26 +0200)] 
gcov: Read the right arc flag in json output

It is quite dishonest to check the false_value and output "true", and we
should strive to be honest.

gcc/ChangeLog:

* gcov.cc (json_set_prime_path_coverage): Read arc.true_value.

5 weeks agoAda: Fix Image for derived enumeration type with representation clause
Eric Botcazou [Sun, 10 May 2026 10:51:44 +0000 (12:51 +0200)] 
Ada: Fix Image for derived enumeration type with representation clause

The problem is that Expand_Image_Attribute incorrectly fetches the root type
for enumeration types, thus bypassing a clause present on the derived type.

The fix is to change the two fields Lit_Indexes and Lit_Strings defined for
enumeration types and subtypes to be formally present on root types only, as
well as to make Expand_Image_Attribute stick to base types.

gcc/ada/
PR ada/125240
* gen_il-gen-gen_entities.adb (Enumeration_Kind): Make
Lit_Indexes and Lit_Strings be defined for root types only.
* einfo.ads (Lit_Hash): Adjust description.
(Lit_Indexes): Likewise.
(Lit_Strings): Likewise.
(E_Enumeration_Type): Likewise.
* exp_imgv.adb (Expand_Image_Attribute): Do not fetch the root type
for enumeration types, except for character types, and adjust.

gcc/testsuite/
* gnat.dg/enum6.adb: New test.

5 weeks agoAda: Set LDFLAGS to configure setting in gnattools
Eric Botcazou [Sun, 10 May 2026 09:39:54 +0000 (11:39 +0200)] 
Ada: Set LDFLAGS to configure setting in gnattools

This just aligns gnattools with both c++tools and gotools.

gnattools/
PR ada/125232
* Makefile.in (ADA_FOR_BUILD): Delete.
(ADA_FOR_TARGET): Likewise.
(LDFLAGS): Set to @LDFLAGS@.

5 weeks agoa68: remove unimplemented math functions from is_mappable_routine
Jose E. Marchesi [Sun, 10 May 2026 10:16:24 +0000 (12:16 +0200)] 
a68: remove unimplemented math functions from is_mappable_routine

The is_mappable_routine function has to identify all routines that are
lengthety-mapped.  This includes math functions like sin and cos.

This patch removes the handling of several math routines that we are
not implementing as compiler builtins:

arccosdg   cbrt     curt       gammaincgf
arccotdg   cosdg     erf       sindg
arcsindg   cospi     erfc       sinpi
arctandg   cot     gamma       tandg
beta   cotdg     gammainc       tanpi
betainc   cotpi     gammaincg

If these routines ever get added to the extended standard prelude, it
will be as regular procedures rather than compiler builtins.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
Reported-by: "Nelson H. F. Beebe" <beebe@math.utah.edu>
gcc/algol68/ChangeLog

* a68-parser-taxes.cc (is_mappable_routine): Remove handling of
non-implemented math functions.

5 weeks agox86_cse: Convert vector load to constant integer load
H.J. Lu [Sat, 9 May 2026 12:58:11 +0000 (20:58 +0800)] 
x86_cse: Convert vector load to constant integer load

Convert vector load:

(insn 14 465 412 3 (set (reg:SI 507 [ j_lsm.26 ])
        (const_int 2 [0x2])) "foo.c":10:12 discrim 2 100 {*movsi_internal}
     (nil))
...
(insn 518 507 434 16 (set (reg:V2SI 493)
        (reg:V2SI 517)) 2066 {*movv2si_internal}
     (nil))

to constant integer load:

(insn 566 55 56 6 (set (subreg:DI (reg:V2SI 517) 0)
        (const_int 8589934594 [0x200000002])) -1
     (nil))
...
(insn 518 507 434 16 (set (reg:V2SI 493)
        (reg:V2SI 517)) 2066 {*movv2si_internal}
     (nil))

Tested on Linux/x86-64.

gcc/

PR target/125238
* config/i386/i386-features.cc (ix86_broadcast_inner): Set kind
to X86_CSE_CONST_VECTOR if the vector load can be converted to
constant integer load.

gcc/testsuite/

PR target/125238
* gcc.target/i386/pr125238.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agoFortran: Allow access to coarray elements within modules. [PR125051]
Paul Thomas [Fri, 8 May 2026 05:34:21 +0000 (06:34 +0100)] 
Fortran: Allow access to coarray elements within modules. [PR125051]

The parts of this patch is fix the problem are chunks 2 and 3. Chunk3 prevents
gfc_conv_intrinsic_caf_get from working in the module namespace, when the array
symbol is in a module. Equally, though, gfc_current_ns is not necessarily in
the referencing procedure namespace. The second chunk makes sure that this is
the case. As an aside, it seems to us that it makes considerably more sense that
gfc_current_ns be that of the current procedure. The first chunk makes sure that
result symbol initialization does not occur outside the function.

Passes regtesting with FC44/x86_64.

2026-05-10  Andre Vehreschild  <vehre@gcc.gnu.org>
    Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/125051
* trans-decl.cc (gfc_get_symbol_decl): gfc_defer_symbol_init
must not be called for PDT types, classes or types with PDT
(gfc_generate_function_code): If gfc_current_ns is not the same
as the function namespace, stash it,change it to the function
namespace and restore after translation of the code.
* trans-intrinsic.cc (gfc_conv_intrinsic_caf_get): If the array
is in a module, use the symbol namespace.
* trans-openmp.cc (gfc_trans_omp_array_reduction_or_udr): If the
current namespace is not that of the procedure, change to the
procedure namspace and revert on leaving this function.

gcc/testsuite/
PR fortran/125051
* gfortran.dg/coarray/pr125051.f90: New test.

5 weeks agoDaily bump.
GCC Administrator [Sun, 10 May 2026 00:16:23 +0000 (00:16 +0000)] 
Daily bump.

5 weeks ago[PATCH] RISC-V: Don't emit cm.popret when zcmp + zicfiss is enabled [PR125217]
Michiel Derhaeg [Sat, 9 May 2026 17:22:07 +0000 (11:22 -0600)] 
[PATCH] RISC-V: Don't emit cm.popret when zcmp + zicfiss is enabled [PR125217]

Currently when -fcf-protection=return and zcmp are enabled this code is
generated:

sspush ra
cm.push {ra, s0-s1}, -32
..
cm.popret {ra, s0-s1}, 32

riscv_expand_epilogue will skip emitting sspopchk when cm.popret is
emitted. After this patch we will no longer emit cm.popret and instead
use cm.pop + sspopchk + a regular return:

sspush  ra
cm.push {ra, s0-s1}, -32
..
cm.pop {ra, s0-s1}, 32
sspopchk ra
jr ra

Regtested for rv32g & rv64g.

PR target/125217

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_gen_multi_pop_insn): Rename variable.
(riscv_expand_epilogue): Don't emit cm.popret with shadow stack.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/ssp-zcmp.c: New test.

5 weeks agox86_cse: Add a test for PR target/125245
H.J. Lu [Sat, 9 May 2026 14:28:05 +0000 (22:28 +0800)] 
x86_cse: Add a test for PR target/125245

Add a test for

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125245

which has been fixed by

commit 7d84a357cfaa3d9ff2cc600a3c145780d37b6aed
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat May 9 05:58:09 2026 +0800

    x86_cse: Check CONST0_RTX and CONSTM1_RTX

PR target/125245
* gcc.target/i386/pr125245.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
6 weeks agocfghooks: constifify cfg_hooks [PR117871]
Andrew Pinski [Sat, 9 May 2026 01:32:50 +0000 (18:32 -0700)] 
cfghooks: constifify cfg_hooks [PR117871]

This constifies the hooks so the structs can't be changed at runtime.
The only odd place where we need to handle special is sel-sched.
This is because we make a copy of the current cfghooks and then
use its own.  This changes things slightly there, there is still a
copy used but instead of copying back into the current cfghooks, we
just change the pointer back to the original one. This code is only
enabled by ia64 backend by default so I doubt it will change.

Boostrapped and tested on x86_64-linux-gnu.

PR middle-end/117871
gcc/ChangeLog:

* cfghooks.cc (cfg_hooks): Change the type
to be a pointer to a const struct cfg_hooks.
(get_cfg_hooks): Return the current pointer
rather the struct.
(set_cfg_hooks): Change the argument type and
set the cfg_hooks directly to it.
* cfghooks.h (gimple_cfg_hooks): Constify.
(rtl_cfg_hooks): Likewise.
(cfg_layout_rtl_cfg_hooks): Likewise.
(get_cfg_hooks): Update declration.
(set_cfg_hooks): Likewise.
* cfgrtl.cc (rtl_cfg_hooks): Constify.
(cfg_layout_rtl_cfg_hooks): Likewise.
* sel-sched-ir.cc (orig_cfg_hooks): Change to a pointer.
(sel_create_basic_block): Update
for orig_cfg_hooks being a pointer.
(sel_register_cfg_hooks): Update for the constification
of cfg_hooks.
* tree-cfg.cc (gimple_cfg_hooks): Constify.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
6 weeks agocfghooks: Remove name field
Andrew Pinski [Sat, 9 May 2026 00:51:54 +0000 (17:51 -0700)] 
cfghooks: Remove name field

Now we have an IR field, we can remove the name field. The
only time the name is used was for internal errors so having
this field outside of the hooks is better anyways.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* cfghooks.cc (current_ir_name): New function.
(dump_bb_for_graph): Use current_ir_name
instead of accessing the name field.
(dump_bb_as_sarif_properties): Likewise.
(redirect_edge_and_branch): Likewise.
(can_remove_branch_p): Likewise.
(redirect_edge_and_branch_force): Likewise.
(split_block_1): Likewise.
(move_block_after): Likewise.
(delete_basic_block): Likewise.
(split_edge): Likewise.
(create_basic_block_1): Likewise.
(can_merge_blocks_p): Likewise.
(predict_edge): Likewise.
(predicted_by_p): Likewise.
(merge_blocks): Likewise.
(make_forwarder_block): Likewise.
(force_nonfallthru): Likewise.
(can_duplicate_block_p): Likewise.
(duplicate_block): Likewise.
(block_ends_with_call_p): Likewise.
(block_ends_with_condjump_p): Likewise.
(flow_call_edges_add): Likewise.
* cfghooks.h (struct cfg_hooks): Remove the name
field.
* cfgrtl.cc (rtl_cfg_hooks): Update for the removal
of the name field.
(cfg_layout_rtl_cfg_hooks): Likewise.
* tree-cfg.cc (struct cfg_hooks): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
6 weeks agocfghooks: Move ir_type inside cfghooks
Andrew Pinski [Sat, 9 May 2026 00:16:10 +0000 (17:16 -0700)] 
cfghooks: Move ir_type inside cfghooks

This is the first step in constification (and/or C++ification)
of the cfghooks. Currently we compare variables to figure out
what the current IR type is. Rather let's move the ir_type
into the cfghooks.  This will help with constification due
to sel-sched overloading one of the hooks.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* cfghooks.cc (current_ir_type): Return cfghooks' ir field.
* cfghooks.h (struct cfg_hooks): Add ir field.
* cfgrtl.cc (rtl_cfg_hooks): Update for new ir field.
(cfg_layout_rtl_cfg_hooks): Likewise.
* tree-cfg.cc (gimple_cfg_hooks): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
6 weeks agox86_cse: Check CONST0_RTX and CONSTM1_RTX
H.J. Lu [Fri, 8 May 2026 21:58:09 +0000 (05:58 +0800)] 
x86_cse: Check CONST0_RTX and CONSTM1_RTX

For CONST_VECTOR source, check CONST0_RTX and CONSTM1_RTX with
X86_CSE_CONSTM1_VECTOR when placing

(insn 32 2 7 2 (set (reg:V2DI 114)
        (const_vector:V2DI [
                (const_int 0 [0]) repeated x2
            ])) -1
     (nil))

after

(note 2 3 32 2 NOTE_INSN_FUNCTION_BEG)

for X86_CSE_VEC_DUP, not X86_CSE_CONST0_VECTOR or X86_CSE_CONSTM1_VECTOR,
after replacing redundant vector loads:

(insn 31 15 16 2 (set (reg/v/f:DI 99 [ d ])
        (const_int 0 [0])) "x.c":5:16 -1
     (nil))
...
(insn 18 17 19 2 (set (reg:V2DI 111 [ _22 ])
        (vec_duplicate:V2DI (reg/v/f:DI 99 [ d ]))) "x.c":5:16 9345 {*vec_dupv2di}
     (nil))

...
(insn 29 12 15 2 (set (reg/v/f:DI 98 [ c ])
        (const_int 0 [0])) "x.c":5:16 -1
     (nil))
...
(insn 20 19 21 2 (set (reg:V2DI 112 [ _20 ])
        (vec_duplicate:V2DI (reg/v/f:DI 98 [ c ]))) "x.c":5:16 9345 {*vec_dupv2di}
     (nil))

with

(insn 18 17 19 2 (set (reg:V2DI 111 [ _22 ])
        (reg:V2DI 114)) "x.c":5:16 2454 {movv2di_internal}
     (nil))

and

(insn 20 19 21 2 (set (reg:V2DI 112 [ _20 ])
        (reg:V2DI 114)) "x.c":5:16 2454 {movv2di_internal}
     (nil))

Adjust gcc.target/i386/pr124407-1.c for the expected x86_cse dump:

(insn 35 8 9 2 (set (reg:V16QI 125)
        (const_vector:V16QI [
                (const_int 0 [0]) repeated x16
            ])) -1
     (nil))

instead of

(insn 36 8 35 2 (set (reg:SF 126)
        (const_double:SF 0.0 [0x0.0p+0])) -1
     (nil))
(insn 35 36 9 2 (set (reg:V4SF 125)
        (vec_duplicate:V4SF (reg:SF 126))) -1
     (nil))

gcc/

PR target/125239
* config/i386/i386-features.cc (ix86_place_single_vector_set):
For CONST_VECTOR source, check CONST0_RTX with
X86_CSE_CONST0_VECTOR and CONSTM1_RTX with X86_CSE_CONSTM1_VECTOR.
(ix86_broadcast_inner): Set x86_cse kind to X86_CSE_CONST0_VECTOR
for CONST0_RTX and X86_CSE_CONSTM1_VECTOR for CONSTM1_RTX.

gcc/testsuite/

PR target/125239
* gcc.target/i386/pr124407-1.c: Adjusted.
* gcc.target/i386/pr125239.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
6 weeks agoc++: always walk DECL_VALUE_EXPR in cp_genericize_r [PR121500]
Patrick Palka [Sat, 9 May 2026 13:01:11 +0000 (09:01 -0400)] 
c++: always walk DECL_VALUE_EXPR in cp_genericize_r [PR121500]

This patch makes cp_genericize_r unconditionally walk DECL_VALUE_EXPR
as per the TODO from r16-7523.

PR c++/121500

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_genericize_r): Unconditionally walk
DECL_VALUE_EXPR.

Reviewed-by: Jason Merrill <jason@redhat.com>