]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agoc++: base-specifier name lookup is type-only [PR122192]
Patrick Palka [Fri, 10 Oct 2025 14:25:25 +0000 (10:25 -0400)] 
c++: base-specifier name lookup is type-only [PR122192]

The r13-6098 change to make TYPENAME_TYPE no longer always ignore
non-type bindings needs another exception: base-specifiers that are
represented as TYPENAME_TYPE, for which lookup must be type-only (by
[class.derived.general]/2).  This patch fixes this by giving such
TYPENAME_TYPEs a tag type of class_type rather than typename_type so
that we treat them like elaborated-type-specifiers (another type-only
lookup situation).

PR c++/122192

gcc/cp/ChangeLog:

* decl.cc (make_typename_type): Document base-specifier as
another type-only lookup case.
* parser.cc (cp_parser_class_name): Propagate tag_type to
make_typename_type instead of hardcoding typename_type.
(cp_parser_base_specifier): Pass class_type instead of
typename_type as tag_type to cp_parser_class_name.

gcc/testsuite/ChangeLog:

* g++.dg/template/dependent-base6.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agox86: Fixes for AMD znver5 enablement
Umesh Kalvakuntla [Wed, 8 Oct 2025 16:50:37 +0000 (18:50 +0200)] 
x86: Fixes for AMD znver5 enablement

This patch fixes cpu family model numbers for znver5 and uses the
correct cpuid bit for prefetchi which is different from Intel
(https://docs.amd.com/v/u/en-US/24594_3.37).

2025-09-29  Umesh Kalvakuntla <Umesh.Kalvakuntla@amd.com>

* common/config/i386/cpuinfo.h (get_amd_cpu): Fix znver5 family
model numbers.
(get_available_features): Set FEATURE_PREFETCHI for bit_AMD_PREFETCHI.
* config/i386/cpuid.h (bit_AMD_PREFETCHI): New Macro.

2 months agoRISC-V: Add test for vec_duplicate + vwsubu.wv combine with GR2VR cost 0, 1 and 15
Pan Li [Wed, 8 Oct 2025 14:15:56 +0000 (22:15 +0800)] 
RISC-V: Add test for vec_duplicate + vwsubu.wv combine with GR2VR cost 0, 1 and 15

Add asm dump check and run test for vec_duplicate + vwsubu.wv
combine to vwsubu.wx, with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check
for vwsubu.wx.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_widen.h: Add test helper
macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_widen_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/wx_vwsubu-run-1-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoRISC-V: Combine vec_duplicate + vwsubu.wv to vwsubu.wx on GR2VR cost
Pan Li [Wed, 8 Oct 2025 14:12:38 +0000 (22:12 +0800)] 
RISC-V: Combine vec_duplicate + vwsubu.wv to vwsubu.wx on GR2VR cost

This patch would like to combine the vec_duplicate + vwsubu.wv to the
vwsubu.wx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have asm code like below, GR2VR cost is 0.

Before this patch:
  11       beq a3,zero,.L8
  12       vsetvli a5,zero,e32,m1,ta,ma
  13       vmv.v.x v2,a2
  ...
  16   .L3:
  17       vsetvli a5,a3,e32,m1,ta,ma
  ...
  22       vwsubu.wv v1,v2,v3
  ...
  25       bne a3,zero,.L3

After this patch:
  11       beq a3,zero,.L8
  ...
  14    .L3:
  15       vsetvli a5,a3,e32,m1,ta,ma
  ...
  20       vwsubu.wx v1,a2,v3
  ...
  23       bne a3,zero,.L3

Unfortunately, and similar as vwaddu.vv, only widening from uint32_t to
uint64_t has the necessary zero-extend during combine, we loss the
extend op after expand for any other types.

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*widen_wsubu_wx_<mode>): Add new
pattern to match vwsubu.wx.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agos390x: Fix fmin/fmax patterns
Juergen Christ [Mon, 15 Sep 2025 10:13:22 +0000 (12:13 +0200)] 
s390x: Fix fmin/fmax patterns

s390x floating point minimum and maximum functions unfortunately do
not canonicalize NaNs.  Hence, test pr105414.c fails since
c476f554e3f.  Fix this by only allowing fmin/fmax pattern if signaling
NaNs are disabled.

gcc/ChangeLog:

* config/s390/vector.md (fmax<mode>3): Restrict to no trapping
math.
(fmin<mode>3): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/s390/fminmax-1.c: Disable for signaling NaNs.
* gcc.target/s390/fminmax-2.c: Ditto.
* gcc.target/s390/vector/reduc-minmax-1.c: Ditto.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
2 months agotestsuite: Fix vector-subscript-4.c [PR116421]
Stefan Schulze Frielinghaus [Fri, 10 Oct 2025 13:02:09 +0000 (15:02 +0200)] 
testsuite: Fix vector-subscript-4.c [PR116421]

Verify we don't have any vector temporaries in the IL at least until
ISEL which may introduce VEC_EXTRACTs on targets which support
non-constant indices (see PR116421).

As a pass I chose NRV for no particular reason except that it is
literally the last pass prior ISEL.  At least at time of writing this.

gcc/testsuite/ChangeLog:
PR testsuite/116421
* c-c++-common/vector-subscript-4.c: Check for vectors prior
ISEL.

2 months agors6000: Add CCFP and CCEQ to CCANY
Segher Boessenkool [Fri, 10 Oct 2025 12:08:45 +0000 (12:08 +0000)] 
rs6000: Add CCFP and CCEQ to CCANY

This allows those modes to be used in more setbc and similar
constructions.

2025-10-10  Segher Boessenkool  <segher@kernel.crashing.org>

* config/rs6000/rs6000.md (mode_iterator CCANY): Add CCFP and CCEQ.

2 months agolibstdc++: Remove misleading TODO comments to add parsing tests.
Tomasz Kamiński [Fri, 10 Oct 2025 12:03:11 +0000 (14:03 +0200)] 
libstdc++: Remove misleading TODO comments to add parsing tests.

Standard does not define form_stream overloads for these types,
so there is nothing to tests.

libstdc++-v3/ChangeLog:

* testsuite/std/time/month_day_last/io.cc: Remove TODO comments
for test_parse().
* testsuite/std/time/month_weekday/io.cc: Likewise.
* testsuite/std/time/month_weekday_last/io.cc: Likewise.
* testsuite/std/time/weekday_indexed/io.cc: Likewise.
* testsuite/std/time/weekday_last/io.cc: Likewise.
* testsuite/std/time/year_month_day_last/io.cc: Likewise.
* testsuite/std/time/year_month_weekday/io.cc: Likewise.
* testsuite/std/time/year_month_weekday_last/io.cc: Likewise.

2 months agotestsuite: Adjust vect-reduc-chain-1.c for SLP permute transform
Christophe Lyon [Fri, 10 Oct 2025 11:26:38 +0000 (11:26 +0000)] 
testsuite: Adjust vect-reduc-chain-1.c for SLP permute transform

Since r16-3847-g21d1bb1922f (Integrate SLP permute transform into
vect_transform_stmt), vect-reduc-chain-1.c was failing on aarch64
because the dump message changed.

Apply the same change as r16-3847-g21d1bb1922f applied to
vect-reduc-chain-2.c and vect-reduc-chain-3.c

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-reduc-chain-1.c: Adjust expected
dump.

2 months agoarm: [MVE] Fix operands order in vbicq_f [PR122223]
Christophe Lyon [Thu, 9 Oct 2025 14:09:26 +0000 (14:09 +0000)] 
arm: [MVE] Fix operands order in vbicq_f [PR122223]

The operands of the floating-point version of vbicq were swapped, this
patch fixes this.

gcc/ChangeLog:
PR target/122223
* config/arm/mve.md (@mve_vbicq_f<mode>): Fix operands order.

gcc/testsuite/ChangeLog:
PR target/122223
* gcc.target/arm/mve/intrinsics/pr122223.c: New test.

2 months agovect: Fix out-of-date VEC_STMT comments
Andrew Stubbs [Thu, 9 Oct 2025 12:52:29 +0000 (12:52 +0000)] 
vect: Fix out-of-date VEC_STMT comments

The vec_stmt parameter was removed from these functions by Richi in July
(commit 5865c0b81, some were removed earlier), but the comments still talked
about it.

gcc/ChangeLog:

* tree-vect-stmts.cc: Fix VEC_STMT parameter comments throughout.

2 months agoaarch64, Darwin: Improve Apple M3 cores, add M4
Francois-Xavier Coudert [Thu, 9 Oct 2025 08:11:38 +0000 (10:11 +0200)] 
aarch64, Darwin: Improve Apple M3 cores, add M4

Complete the list of M3 cores (Ibiza, Palma and Lobos) and add the M4
cores (Donan and two types of Brava).

The values for chip IDs and the LITTLE.big variants have been taken from
lists in the XNU sources (xnu/osfmk/arm/cpuid.h) in xnu-11417.101.15.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (AARCH64_CORE): Improve Apple
M3 and add Apple M4 cores.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Add apple-m4 core to the ones listed
for arch and tune selections.

2 months agoUse gimple_build to perform conversion simplification
Richard Biener [Fri, 10 Oct 2025 08:05:46 +0000 (10:05 +0200)] 
Use gimple_build to perform conversion simplification

The following uses gimple_build to do the conversion simplification
in build_and_insert_cast instead of duplicating it there.  Conveniently
when building directly into the IL all stmts are taken into account
for the simplification.

PR tree-optimization/122111
* tree-ssa-math-opts.cc (build_and_insert_cast): Remove
conversion simplification, instead use gimple_convert.

* gcc.target/arm/pr122111.c: New test.

2 months agoarm: Fix support_vector_misalignment.
Robin Dapp [Thu, 9 Oct 2025 20:47:26 +0000 (22:47 +0200)] 
arm: Fix support_vector_misalignment.

In gcc-16-4314-g5e9eecc6686 I meant to remove all uses of TYPE
in support_vector_misalignment but apparently forgot this one.
Fixing by using the inner mode's size.

gcc/ChangeLog:

* config/arm/arm.cc (arm_builtin_support_vector_misalignment):
Remove use of type.

2 months agolibgomp: Add is_integrated_apu function to plugin/plugin-{gcn,nvptx}.c
Tobias Burnus [Fri, 10 Oct 2025 07:48:37 +0000 (09:48 +0200)] 
libgomp: Add is_integrated_apu function to plugin/plugin-{gcn,nvptx}.c

The added function is currently '#if 0' but is planned to be used to enable
self mapping automatically. Prerequisite for auto self maps is still mapping
'declare target' variables (if any, in libgomp) or converting all
'declare target' variables to 'declare target link' in the compiler
(as required for 'omp requires self_maps').

include/ChangeLog:

* hsa_ext_amd.h (enum hsa_amd_agent_info_s): Add
HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES.
(enum): Add HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (is_integrated_apu): New; currently '#if 0'.
* plugin/plugin-nvptx.c (is_integrated_apu): Likewise.

2 months agotree-optimization/122225 - fix return stmt verification
Richard Biener [Fri, 10 Oct 2025 06:20:22 +0000 (08:20 +0200)] 
tree-optimization/122225 - fix return stmt verification

The following fixes return stmt type verification by properly looking
at DECL_RESULT to decide whether that's by reference, not trying to
figure that from the actual argument.

PR tree-optimization/122225
* tree-cfg.cc (verify_gimple_return): Look at DECL_RESULT
for DECL_BY_REFERENCE.

2 months agolibstdc++: Adjust enable_nonlocking_formatter_optimization specializations [PR121790]
Tomasz Kamiński [Fri, 3 Oct 2025 07:01:21 +0000 (09:01 +0200)] 
libstdc++: Adjust enable_nonlocking_formatter_optimization specializations [PR121790]

This patch addresses several issues related to the additional specializations
for enable_nonlocking_formatter_optimization fomr P3235R3 proposal:

* LWG4399 [1]: Apply remove_cvref_t to tuple and pair elements when checking if
the direct printing optimization is enabled.
* LWG4398 [2]: Disable the direct printing optimization for the standard library
 container adaptors: queue, priority_queue, and stack.
* LWG4400 [3]: Enable the direct printing optimization only for durations that
 use standard arithmetic types. Conditionally enable it for hh_mm_ss
 and time_points based on their underlying Duration template argument.

[1] https://cplusplus.github.io/LWG/issue4399
[2] https://cplusplus.github.io/LWG/issue4398
[3] https://cplusplus.github.io/LWG/issue4400

PR libstdc++/121790

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (enable_nonlocking_formatter_optimization):
Adjust specializations for duration, hh_mm_ss and time_points.
* include/std/format (enable_nonlocking_formatter_optimization):
Apply remove_cvref_t on pair and tuple elements.
* include/std/queue (enable_nonlocking_formatter_optimization):
Change specialization value to false.
* include/std/stack (enable_nonlocking_formatter_optimization):
Change specialization value to false.
* testsuite/std/format/ranges/adaptors.cc: Adjusted tests.
* testsuite/std/format/tuple.cc: Adjusted tests.
* testsuite/std/time/format/nonlocking.cc: Adjusted tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agolibstdc++: Implement P3235R3 optimizations for std::print [PR121790]
Tomasz Kamiński [Thu, 2 Oct 2025 14:17:05 +0000 (16:17 +0200)] 
libstdc++: Implement P3235R3 optimizations for std::print [PR121790]

This patch implements additional enable_nonlocking_formatter_optimization
specializations listed in P3235R3.

PR libstdc++/121790

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h
(enable_nonlocking_formatter_optimization): Define specializations
for chrono types.
* include/bits/version.def (print): Bump.
* include/bits/version.h: Regenerate.
* include/std/format (enable_nonlocking_formatter_optimization):
Define specializations for pair, tuple and ranges.
* include/std/queue (enable_nonlocking_formatter_optimization):
Define specializations for queue and priority_queue.
* include/std/stack (enable_nonlocking_formatter_optimization):
Define specialization for stack.
* include/std/stacktrace (enable_nonlocking_formatter_optimization):
Define specialization for basic_stacktrace and stacktrace_entry.
* include/std/thread (enable_nonlocking_formatter_optimization):
Define specialization for thread::id.
* include/std/vector (enable_nonlocking_formatter_optimization):
Define specialization for vector<bool>::reference.
* testsuite/23_containers/vector/bool/format.cc: Test value of
enable_nonlocking_formatter_optimization.
* testsuite/30_threads/thread/id/output.cc: Likewise.
* testsuite/std/format/ranges/adaptors.cc: Likewise.
* testsuite/std/format/ranges/formatter.cc: Likewise.
* testsuite/std/format/tuple.cc: Likewise.
* testsuite/std/time/format/empty_spec.cc: Extract Rep class
to custom_rep.h.
* testsuite/std/time/format/custom_rep.h: Extracted from
empty_spec.cc.
* testsuite/std/time/format/nonlocking.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agolibstdc++: Implement P3107R5 optimizations for std::print [PR121790]
Jonathan Wakely [Wed, 21 Feb 2024 16:11:53 +0000 (16:11 +0000)] 
libstdc++: Implement P3107R5 optimizations for std::print [PR121790]

The names of the vprint functions follow the convention from P3235R3.

This takes advantage of the additional permission proposed by P3107R5 so
that std::print can write directly to a FILE stream, rather than
formatting to an intermediate std::string temporary and then writing
that to the stream. The change is to write to a new _File_sink type
instead of a _Str_sink that populates a std::string. There are three
implementations of _File_sink.

For non-Glibc targets that support POSIX flockfile and putc_unlocked,
the stream will be locked and then formatted characters will be buffered
on the stack (instead of allocating a std::string) and copied to the
stream when the buffer fills up.

For Glibc, _File_sink will lock the stream but then if the file is
line-buffered or fully buffered, characters will be written directly
into the file's output buffer. This avoids two levels of buffering and
copying the characters from one to the other. For an unbuffered stream
(like stderr) the _File_sink buffer will still be used, to avoid the
overhead of lots of small writes to the stream.  Because this version of
_File_sink accesses the stream's buffer directly it relies on
glibc-specific implementation details that are exposed in public
headers.

A fallback definition of _File_sink just wraps a _Str_sink so is
equivalent to the original code, and is used when flockfile isn't
available.

Both forms of std::println (taking a FILE* and a std::ostream) can be
implemented more efficiently by appending a newline to the format
string, to avoid formatting twice.

PR libstdc++/121790

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CHECK_STDIO_LOCKING): New macro to check
for std::print dependencies.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Use GLIBCXX_CHECK_STDIO_LOCKING.
* include/bits/formatfwd.h (enable_nonlocking_formatter_optimization):
Define new variable template.
* include/bits/version.def (print): Bump value.
* include/bits/version.h: Regenerate.
* include/std/format (enable_nonlocking_formatter_optimization):
Define specializations for variable template.
* include/std/ostream (print) [!_WIN32]: Do not use
vprint_unicode at all.
(println): Append newline to format string instead of formatting
twice.
* include/std/print (_File_sink): New class.
(vprint_nonunicode_locking): New function.
(vprint_unicode_locking): New function reusing previous code
from vprint_unicode.
(vprintf_unicode): Defer to vprint_nonunicode for Windows or to
vprint_unicode_locking otherwise.
(print): [!_WIN32]: Do no use vprint_unicode at all.
Check enable_nonlocking_formatter_optimization and defer to
either vprint_nonunicode_locking or vprint_nonunicode.
(println): Use vprint_unicode or format directly to a _File_sink
instead of formatting twice.
* testsuite/27_io/print/1.cc: Updated and added new tests.
* testsuite/std/format/formatter/nonlocking.cc: New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Handle cv-qualified types in atomic and atomic_ref [PR115402]
Giuseppe D'Angelo [Mon, 9 Dec 2024 00:32:27 +0000 (01:32 +0100)] 
libstdc++: Handle cv-qualified types in atomic and atomic_ref [PR115402]

Implements P3233R1 (DR for C++20/C++11, fixes LWG 4069 and 3508).

This commit implements std::atomic_ref<cv T> support (LWG3508) as DR for
C++20, by  extractingparts of the __atomic_ref class (that atomic_ref inherits
from) into a further base class (__atomic_ref_base):

* __atomic_ref_base<const T> implements non-mutating (const) atomic API.
  Single base class is used, and the difference in is_always_lock_free and
  required_aligment values between types are handled by _S_is_always_lock_free,
  _S_required_aligment helper functions.
* __atomic_ref_base<T> implements the common atomic APIs. The non-mutating
  operations are handled by inherting from __atomic_ref_base<const T> partial
  partial specialization. Tu support that __atomic_ref_base<const T> stores
  mutable pointer to T, and performs const_cast in constructor.
* __atomic_ref<T, ....> inherits from __atomic_ref_base<T>, and implement
  type-specific mutable APIs (fetch_add, -=, ...) and difference_type member
  type.
* __atomic_ref<const T, ...> inherits from __atomic_ref_base<const T>
  and adds different_type member, whose presence and denoted type depends
  on T.

The __atomic_ref specialization selection is adjusted to handle cv-qualified
bool (add remove_cv_t) and pointer types. To handle the later, additional
constant template parameter is introduced.

The atomic wait and notify operations are currently not supported for volatile
types, to signal that static assert is added to corresponding methods of
atomic_ref.

At the same time,  disable support for cv-qualified types in std::atomic
(for instance, std::atomic<volatile T> isn't meaningful; one should use
volatile std::atomic<T>), again as per the paper, resolving LWG4069 as DR
for C++11. This only affects atomic<volatile T>, as specialization
atomic with const-qualifed types was already producing an compile-time
error.

PR libstdc++/115402

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (__atomic_ref_base<const _Tp>)
(__atomic_ref_base<_Tp>): Define by extracting common methods
from atomic_ref specializations.
(__atomic_ref<_Tp, In, Fp, Pt>): Inherit from __atomic_ref_base
and remove extracted method.
(__atomic_ref<const _Tp, In, Fp, Pt>): Define.
* include/std/atomic (std::atomic): Added an
* testsuite/29_atomics/atomic/requirements/types_neg.cc:
Add test for volatile qualified types.
* testsuite/29_atomics/atomic_ref/bool.cc: Move the content
to op_support.cc, add test for bool.
* testsuite/29_atomics/atomic_ref/op_support.cc: New test
expanded from atomic_ref/bool.cc.
* testsuite/29_atomics/atomic_ref/cv_qual.cc: New test.
* testsuite/29_atomics/atomic_ref/requirements_neg.cc: New test.
* testsuite/29_atomics/atomic_ref/deduction.cc: Add tests for
cv-qualified types.
* testsuite/29_atomics/atomic_ref/float.cc: Likewise.
* testsuite/29_atomics/atomic_ref/generic.cc: Likewise.
* testsuite/29_atomics/atomic_ref/integral.cc: Likewise.
* testsuite/29_atomics/atomic_ref/pointer.cc: Likewise.
* testsuite/29_atomics/atomic_ref/requirements.cc: Likewise.
* testsuite/29_atomics/atomic_ref/wait_notify.cc: Add tests for
const qualified types.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Improve handling of !ok() weekday index in formatting [PR121929]
Tomasz Kamiński [Thu, 9 Oct 2025 12:38:54 +0000 (14:38 +0200)] 
libstdc++: Improve handling of !ok() weekday index in formatting [PR121929]

Previously, formatting a year_month_weekday with the weekday index equal to
0, 6, or 7 (which are !ok() values in the supported range) produced a
seemingly correct day output. For example %Y-%m-%d produced:
 * 2024-09-06 for 2024y/September/Sunday[6] (2024-10-06)
 * 2024-09-25 for 2024y/September/Sunday[0] (2023-08-25)

This patch changes how the internal _M_day value is computed for
year_month_weekday. Instead of converting to local_days then to year_month_day,
_M_day is now set as the number of days since ymd.year()/ymd.month()/0. If this
difference is negative (which occurs when index() is 0), _M_day is set to 0 to
avoid handling negative days of the month.

This change yields identical results for all ok() values. However, for !ok() dates,
it now consistently produces invalid dates, ensuring the formatted output clearly
reflects the !ok input state:
 * 2024-09-36 for 2024y/September/Sunday[6]
 * 2024-09-00 for 2024y/September/Sunday[0]

For consistency, _M_day is computed in the same manner for year_month_weekday_last.

Finally, for year_month_day_last, we fill _M_day directly with ymd.day().
This provides a more efficient implementation and avoids the need to compute
local_days for %Y-%m-%d, %F and similar specifiers.

PR libstdc++/121929

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (_ChronoData::_M_fill_aux)
(_ChronoData::_M_fill_aux): Add comment documenting precondition.
(formatter<chrono::year_month_day, _CharT>::format): Compute
local_days inline.
(formatter<chrono::year_month_day_last, _CharT>::format)
(formatter<chrono::year_month_weekday, _CharT>::format)
(formatter<chrono::year_month_weekday_last, _CharT>::format):
Change how the _M_day field is computed.
* testsuite/std/time/year_month_weekday/io.cc: Adjust tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoDaily bump.
GCC Administrator [Fri, 10 Oct 2025 00:21:51 +0000 (00:21 +0000)] 
Daily bump.

2 months agoRevert "MIPS: Add conditions for use of the -mmips16e2 and -mips16 option."
YunQiang Su [Fri, 10 Oct 2025 00:16:38 +0000 (08:16 +0800)] 
Revert "MIPS: Add conditions for use of the -mmips16e2 and -mips16 option."

This reverts commit f731fa580156d07f6347cb87931ce7b9cf2acbb4.

2 months agoRevert "MIPS/testsuite: Use isa_rev=2 instead of >=2"
YunQiang Su [Fri, 10 Oct 2025 00:16:32 +0000 (08:16 +0800)] 
Revert "MIPS/testsuite: Use isa_rev=2 instead of >=2"

This reverts commit 10bb371eee6357cd32ffc8cfddcd62bd8b182c4b.

2 months agobpf: add tests for CO-RE and BTF tag interaction
David Faust [Mon, 28 Apr 2025 19:17:24 +0000 (12:17 -0700)] 
bpf: add tests for CO-RE and BTF tag interaction

Add a couple of tests to ensure that BTF type/decl tags do not interfere
with generation of BPF CO-RE relocations.

gcc/testsuite/
* gcc.target/bpf/core-btf-tag-1.c: New test.
* gcc.target/bpf/core-btf-tag-2.c: New test.

2 months agodoc: document btf_type_tag and btf_decl_tag attributes
David Faust [Wed, 5 Feb 2025 18:42:25 +0000 (10:42 -0800)] 
doc: document btf_type_tag and btf_decl_tag attributes

gcc/
* doc/extend.texi (Common Function Attributes)
(Common Variable Attributes): Document btf_decl_tag attribute.
(Common Type Attributes): Document btf_type_tag attribute.

2 months agobtf: generate and output DECL_TAG and TYPE_TAG records
David Faust [Wed, 5 Feb 2025 18:41:23 +0000 (10:41 -0800)] 
btf: generate and output DECL_TAG and TYPE_TAG records

Support the btf_decl_tag and btf_type_tag attributes in BTF by creating
and emitting BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records,
respectively, for them.

Some care is required when -gprune-btf is in effect to avoid emitting
decl or type tags for declarations or types which have been pruned and
will not be emitted in BTF.

gcc/
* btfout.cc (get_btf_kind): Handle DECL_TAG and TYPE_TAG kinds.
(btf_calc_num_vbytes): Likewise.
(btf_asm_type): Likewise.
(output_asm_btf_vlen_bytes): Likewise.
(output_btf_tags): New.
(btf_output): Call it here.
(btf_add_used_type): Replace with simple wrapper around...
(btf_add_used_type_1): ...the implementation.  Handle
BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG.
(btf_add_vars): Update btf_add_used_type call.
(btf_assign_tag_ids): New.
(btf_mark_type_used): Update btf_add_used_type call.
(btf_collect_pruned_types): Likewise.  Handle type and decl tags.
(btf_finish): Call btf_assign_tag_ids.

gcc/testsuite/
* gcc.dg/debug/btf/btf-decl-tag-1.c: New test.
* gcc.dg/debug/btf/btf-decl-tag-2.c: New test.
* gcc.dg/debug/btf/btf-decl-tag-3.c: New test.
* gcc.dg/debug/btf/btf-decl-tag-4.c: New test.
* gcc.dg/debug/btf/btf-type-tag-1.c: New test.
* gcc.dg/debug/btf/btf-type-tag-2.c: New test.
* gcc.dg/debug/btf/btf-type-tag-3.c: New test.
* gcc.dg/debug/btf/btf-type-tag-4.c: New test.
* gcc.dg/debug/btf/btf-type-tag-c2x-1.c: New test.

include/
* btf.h (BTF_KIND_DECL_TAG, BTF_KIND_TYPE_TAG) New defines.
(struct btf_decl_tag): New.

2 months agoctf: translate annotation DIEs to internal ctf
David Faust [Wed, 5 Feb 2025 18:40:12 +0000 (10:40 -0800)] 
ctf: translate annotation DIEs to internal ctf

Translate DW_TAG_GNU_annotation DIEs created for C attributes
btf_decl_tag and btf_type_tag into an in-memory representation in the
CTF/BTF container.  They will be output in BTF as BTF_KIND_DECL_TAG and
BTF_KIND_TYPE_TAG records.

The new CTF kinds used to represent these annotations, CTF_K_DECL_TAG
and CTF_K_TYPE_TAG, are expected to be formalized in the next version of
the CTF specification.  For now they only exist in memory as a
translation step to BTF, and are not emitted when generating CTF
information.

gcc/
* ctfc.cc (ctf_dtu_d_union_selector): Handle CTF_K_DECL_TAG and
CTF_K_TYPE_TAG.
(ctf_add_type_tag, ctf_add_decl_tag): New.
(ctf_add_variable): Return the new ctf_dvdef_ref rather than zero.
(new_ctf_container): Initialize new members.
(ctfc_delete_container): Deallocate new members.
* ctfc.h (ctf_dvdef, ctf_dvdef_t, ctf_dvdef_ref): Move forward
declarations earlier in file.
(ctf_decl_tag_t): New typedef.
(ctf_dtdef): Add ctf_decl_tag_t member to dtd_u union.
(ctf_dtu_d_union_enum): Add new CTF_DTU_D_TAG enumerator.
(ctf_container): Add ctfc_tags vector and ctfc_type_tags_map hash_map
members.
(ctf_add_type_tag, ctf_add_decl_tag): New function protos.
(ctf_add_variable): Change prototype return type to ctf_dvdef_ref.
* dwarf2ctf.cc (gen_ctf_type_tags, gen_ctf_decl_tags)
(gen_ctf_decl_tags_for_var): New static functions.
(gen_ctf_pointer_type): Handle type tags.
(gen_ctf_sou_type): Handle decl tags.
(gen_ctf_function_type): Likewise.
(gen_ctf_variable): Likewise.
(gen_ctf_function): Likewise.
(gen_ctf_type): Handle TAG_GNU_annotation DIEs.

gcc/testsuite/
* gcc.dg/debug/ctf/ctf-decl-tag-1.c: New test.
* gcc.dg/debug/ctf/ctf-type-tag-1.c: New test.

include/
* ctf.h (CTF_K_DECL_TAG, CTF_K_TYPE_TAG): New defines.

2 months agodwarf: create annotation DIEs for btf tags
David Faust [Wed, 5 Feb 2025 18:37:47 +0000 (10:37 -0800)] 
dwarf: create annotation DIEs for btf tags

The btf_decl_tag and btf_type_tag attributes provide a means to annotate
declarations and types respectively with arbitrary user provided
strings.  These strings are recorded in debug information for
post-compilation uses, and despite the name they are meant to be
recorded in DWARF as well as BTF.  New DWARF extensions
DW_TAG_GNU_annotation and DW_AT_GNU_annotation are used to represent
these user annotations in DWARF.

This patch introduces the new DWARF extension DIE and attribute, and
generates them as necessary to represent user annotations from
btf_decl_tag and btf_type_tag.

The format of the new DIE is as follows:

    DW_TAG_GNU_annotation
        DW_AT_name: "btf_decl_tag" or "btf_type_tag"
        DW_AT_const_value: <arbitrary user-supplied string>
        DW_AT_GNU_annotation: <reference to another TAG_GNU_annotation DIE>

DW_AT_GNU_annotation is a new attribute extension used to refer to these
new annotation DIEs.  If non-null in any given declaration or type DIE,
it is a reference to a DW_TAG_GNU_annotation DIE holding an annotation
for that declaration or type.  In addition, the DW_TAG_GNU_annotation
DIEs may also have a non-null DW_AT_GNU_annotation, referring to another
annotation DIE.  This allows chains of annotation DIEs to be formed,
such as in the case where a single declaration has multiple instances of
btf_decl_tag with different string annotations.

gcc/
* dwarf2out.cc (struct annotation_node, struct annotation_node_hasher)
(btf_tag_htab): New ancillary structures and hash table.
(annotation_node_hasher::hash, annotation_node_hasher::equal): New.
(hash_btf_tag, gen_btf_tag_dies, maybe_gen_btf_type_tag_dies)
(maybe_gen_btf_decl_tag_dies): New functions.
(modified_type_die): Add new argument to pass type attributes.
Handle btf_type_tag, and update recursive calls.
(base_type_for_mode): Add new arg for modified_type_die call.
(add_type_attribute): Likewise.
(gen_array_type_die): Call maybe_gen_btf_type_tag_dies for the type.
(gen_formal_parameter_die): Call maybe_gen_btf_decl_tag_dies for the
parameter.
(override_type_for_decl_p): Add new arg for modified_type_die call.
(force_type_die): Likewise.
(gen_tagged_type_die): Call maybe_gen_btf_type_tag_dies for the type.
(gen_decl_die): Call maybe_gen_btf_decl_tag_dies for the decl.
(dwarf2out_finish): Empty btf_tag_htab.
(dwarf2out_cc_finalize): Delete btf_tag_htab hash table.

include/
* dwarf2.def (DW_TAG_GNU_annotation): New DWARF extension.
(DW_AT_GNU_annotation): Likewise.

gcc/testsuite/
* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-1.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-2.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-3.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-1.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-2.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-3.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-4.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-5.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-6.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-7.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-8.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-9.c: New test.
* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-10.c: New test.

2 months agoc-family: add btf_type_tag and btf_decl_tag attributes
David Faust [Wed, 5 Feb 2025 18:35:13 +0000 (10:35 -0800)] 
c-family: add btf_type_tag and btf_decl_tag attributes

Add two new c-family attributes, "btf_type_tag" and "btf_decl_tag"
along with attribute handlers for them.  These attributes may be
used to annotate types or declarations respectively with arbitrary
strings, which will be recorded in DWARF and/or BTF information.
Both attributes accept exactly one string argument.  Wide strings
are not supported.

gcc/c-family/
* c-attribs.cc (c_common_attribute_table): Add btf_decl_tag and
btf_type_tag attributes.
(handle_btf_decl_tag_attribute): New handler for btf_decl_tag.
(hanlde_btf_type_tag_attribute): New handler for btf_type_tag.
(btf_tag_args_ok): Helper for new attribute handlers.

gcc/testsuite/
* gcc.dg/attr-btf-decl-tag-1.c: New test.
* gcc.dg/attr-btf-decl-tag-2.c: New test.
* gcc.dg/attr-btf-type-tag-1.c: New test.
* gcc.dg/attr-btf-type-tag-2.c: New test.
* gcc.dg/attr-btf-type-tag-3.c: New test.

2 months agoc++: C++26 va_start - part of P3348R4 - C++26 should refer to C23 not C17
Jakub Jelinek [Thu, 9 Oct 2025 20:41:30 +0000 (22:41 +0200)] 
c++: C++26 va_start - part of P3348R4 - C++26 should refer to C23 not C17

The C++26 https://wg21.link/P3348R4 C++26 should refer to C23 not C17
paper among other things changes va_start macro in the similar way
how C23 has changed it.  Now, unlike C17 and older, C++ has since forever
allowed int (...) but just one wasn't able to use va_start/va_arg/va_end
in such functions.
With the current C++26 draft wording, we'd have to
  #define va_start(V, ...) __builtin_va_start (V, 0)
like we've used for C23 before the PR107980 change.
But Jonathan has kindly filed
https://cplusplus.github.io/LWG/issue4388
which similarly to C23 will if accepted allow to define it as
  #define va_start(...) __builtin_c23_va_start(__VA_ARGS__)
and let the compiler diagnose undesirable cases (see stdarg6.C
testcase in the patch for what it can diagnose, basically anything
that isn't either va_start (ap) or va_start (ap, i) where i is the
last argument's identifier).  This patch implements what assumes
LWG4388 will pass.

It also defines
  #define __STDC_VERSION_STDARG_H__ 202311L
also for C++26.

The hardest part is actually something different.
C23 had to differentiate between C99 void foo (); i.e. unspecified
arguments (but not stdarg) and the new C23 void bar (...); which
is stdarg, but in both cases TYPE_ARG_TYPES (fntype) is NULL.
This has been implemented through the new TYPE_NO_NAMED_ARGS_STDARG_P
flag, fntypes with that flag set are considered stdarg_p and allow
va_start in those, while fntypes with NULL TYPE_ARG_TYPES but the
flag cleared are not stdarg_p, can accept any number of arguments
but can't use va_start.
So, I had to change various places in the C++ FE to pass true
as the third argument to build_function_type for calls which are
meant to be (...) so that one can actually use va_start in those.
Done only for C++26 in order not to disturb older versions too much.
And there is a problem with some of the builtins and #pragma weak
which are using (...) declarations more in the sense of C17
unspecified arguments rather than this call has variable arguments.

So, structural_comptypes now considers the non-C++26 (...) used
for selected builtins and #pragma weak incompatible with C++26 (...)
to avoid ICEs.

2025-10-09  Jakub Jelinek  <jakub@redhat.com>

gcc/
* ginclude/stdarg.h (va_start): Use __builtin_c23_va_start
also for C++26.
(__STDC_VERSION_STDARG_H__): Also define for C++26.
gcc/c-family/
* c-common.h (D_CXX26): Define.
* c-common.cc (c_common_resword): Add D_CXX26 to
__builtin_c23_va_start flags, mention D_CXX26 in comment.
gcc/cp/
* cp-tree.h (cp_build_function_type): Declare.
* lex.cc: Implement va_start changes from P3348R4 - C++26 should
refer to C23 not C17 paper.
(init_reswords): Set D_CXX26 in mask for C++23 and older.
* parser.cc (cp_parser_primary_expression): Handle RID_C23_VA_START.
(cp_parser_builtin_c23_va_start): New function.
* cp-objcp-common.cc (names_builtin_p): Likewise.
* decl.cc (grokfndecl, check_function_type): Pass
TYPE_NO_NAMED_ARGS_STDARG_P as last arg to build_function_type.
(grokdeclarator, static_fn_type): Use cp_build_function_type instead
of build_function_type.
* typeck.cc (merge_types): Likewise.
(structural_comptypes): Return false for TYPE_NO_NAMED_ARGS_STDARG_P
differences.
* lambda.cc (maybe_add_lambda_conv_op): Use cp_build_function_type
instead of build_function_type.
* tree.cc (cp_build_function_type): New function.
(strip_typedefs): Pass TYPE_NO_NAMED_ARGS_STDARG_P as last arg to
build_function_type.
* name-lookup.cc (push_local_extern_decl_alias): Likewise.
* module.cc (trees_in::tree_node): Use cp_build_function_type instead
of build_function_type.
* pt.cc (copy_default_args_to_explicit_spec,
rebuild_function_or_method_type, build_deduction_guide): Likewise.
(alias_ctad_tweaks): Pass TYPE_NO_NAMED_ARGS_STDARG_P as last arg to
build_function_type.
* decl2.cc (change_return_type, cp_reconstruct_complex_type):
Likewise.
gcc/testsuite/
* c-c++-common/cpp/has-builtin-4.c: Expect
__has_builtin (__builtin_c23_va_start) == 1 also for C++26.
* c-c++-common/Wvarargs.c (foo3): Don't expect undefined behavior
warning for C++26.
* g++.dg/cpp26/stdarg1.C: New test.
* g++.dg/cpp26/stdarg2.C: New test.
* g++.dg/cpp26/stdarg3.C: New test.
* g++.dg/cpp26/stdarg4.C: New test.
* g++.dg/cpp26/stdarg5.C: New test.
* g++.dg/cpp26/stdarg6.C: New test.
* g++.dg/cpp26/stdarg7.C: New test.
* g++.dg/cpp26/stdarg8.C: New test.
* g++.dg/cpp26/stdarg9.C: New test.
* g++.dg/opt/pr60849.C (foo): Add explicit cast.

2 months agoc++: Fix ICE with concept used as function [PR116477]
Egas Ribeiro [Tue, 7 Oct 2025 21:48:56 +0000 (22:48 +0100)] 
c++: Fix ICE with concept used as function [PR116477]

As suggested by Patrick Palka in the bug report, the diagnostic check
for concept_check_p(fn) was being done too late in finish_call_expr(),
which led to an early return inside if (processing_template_decl), which
meant that the error wouldn't be triggered when we are in a type
dependence early exit. This fix makes sure that this error is handled in
the semantic analysis phase, and avoids the failed assertion later in
tsubst_expr().

PR c++/116477

gcc/cp/ChangeLog:

* semantics.cc (finish_call_expr): Move concept_check_p diagnostic
before processing_template_decl check to catch errors earlier.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
2 months agoAVR: target/122222 - Add modules for __floatsidf, __floatunsidf.
Georg-Johann Lay [Thu, 9 Oct 2025 16:35:34 +0000 (18:35 +0200)] 
AVR: target/122222 - Add modules for __floatsidf, __floatunsidf.

PR target/122222
libgcc/config/avr/libf7/
* libf7-asm.sx (D_floatsidf, D_floatunsidf): New modules.
* libf7-common.mk (F7_ASM_PARTS): Add D_floatsidf, D_floatunsidf.
(F7F, g_dx): Remove floatunsidf, floatsidf.
* libf7.c (f7_set_s32): Don't alias to f7_floatsidf.
(f7_set_u32): Don't alias to f7_floatunsidf.
* f7-renames.h: Rebuild
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/pr122222-sitod.c: New test.

2 months agoAVR: target/122220 - Let (int32_t) -0x1p31L return INT32_MIN.
Georg-Johann Lay [Thu, 9 Oct 2025 13:27:16 +0000 (15:27 +0200)] 
AVR: target/122220 - Let (int32_t) -0x1p31L return INT32_MIN.

PR target/122220
libgcc/config/avr/libf7/
* libf7-asm.sx (to_integer): Return 0x80... on negative overflow.

gcc/testsuite/
* gcc.target/avr/pr122220.c: New test.

2 months agoanalyzer: reimplement binding_map using a "spatial" representation
David Malcolm [Thu, 9 Oct 2025 18:41:28 +0000 (14:41 -0400)] 
analyzer: reimplement binding_map using a "spatial" representation

Previously, ana::binding_map was a
  hash_map <const binding_key *, const svalue *>
combining both concrete and symbolic keys into the same map, with no
meaningful ordering.

This patch reimplements it as:
  concrete_bindings_t m_concrete;
  symbolic_bindings_t m_symbolic;
where concrete_bindings_t is:
  std::map<bit_range, const svalue *>
thus organizing them into order, and symbolic_bindings_t is:
  std::vector<symbolic_binding>
where a symbolic_binding is a (region, svalue pair) and the vector for
now has at most one symbolic binding.

In particular, this means that iterating over the bindings in a map or
cluster yields them in ascending memory order of concrete bindings,
followed by the symbolic binding (if present).

This should allow various optimizations, make it easier to detect
overlapping bindings, and to eventually better support analyzing code
that builds up a string via concatenations (perhaps with multiple
symbolic bindings "hanging off the end").

gcc/analyzer/ChangeLog:
* access-diagram.cc: Update for renaming of fields of binding_key.
* ana-state-to-diagnostic-state.cc: Likewise.
* bounds-checking.cc: Likewise.  Add store_manager param.
* call-summary.cc: Likewise.
* diagnostic-manager.cc: Drop includes of "basic-block.h" and
"gimple.h".
* engine.cc: Likewise.
* infinite-recursion.cc: Update for renaming of fields of
binding_key.
* kf.cc: Pass store_manager to mark_as_escaped.
* program-state.cc: Update for renaming of fields of binding_key.
* region-model-asm.cc: Pass store manager to
get_or_create_cluster.
* region-model-reachability.cc: Likewise.  Update for renaming of
fields of binding_key.
* region-model.cc: Likewise.
(struct bad_pointer_finder): Drop.
(region_model::poison_any_pointers_to_descendents): Implement
iteration directly, rather than using store::for_each_binding.
Drop return value.
(selftest::test_struct): Set field in order y then x.  Verify
that iteration yields bindings in order x then y.
* region-model.h
(region_model::poison_any_pointers_to_descendents): Drop return
value.
* region.cc: Pass store manager to get_or_create_cluster.
* store.cc (binding_map::const_iterator::operator==): New.
(binding_map::const_iterator::operator++): New.
(binding_map::const_iterator::operator*): New.
(binding_map::iterator::operator==): New.
(binding_map::iterator::operator++): New.
(binding_map::iterator::operator*): New.
(binding_map::binding_map): Reimplement.
(binding_map::operator=): Reimplement.
(binding_map::operator==): Reimplement.
(binding_map::hash): Reimplement.
(binding_map::get): Reimplement.
(binding_map::put): Reimplement.
(binding_map::overwrite): New.
(binding_map::remove): New.
(binding_map::begin): New.
(binding_map::end): New.
(binding_map::elements): New.
(binding_map::dump_to_pp): Reimplement.
(binding_map::to_json): Iterate over *this directly; drop sort.
(binding_map::add_to_tree_widget): Likewise.
(binding_map::cmp): Reimplement.
(binding_map::get_overlapping_bindings): Update for field
renamings.
(binding_cluster::binding_cluster): Add store_mgr param.
(binding_cluster::validate): Update for field renamings.
(binding_cluster::bind_compound_sval): Likewise.
(binding_cluster::purge_state_involving): Likewise.
(binding_cluster::maybe_get_compound_binding): Likewise.  Add
store_mgr param.
(binding_cluster::can_merge_p): Likewise.  Update for new
implementation.
(binding_cluster::make_unknown_relative_to): Likewise.
(binding_cluster::on_unknown_fncall): Likewise.
(binding_cluster::on_asm): Likewise.
(binding_cluster::get_representative_path_vars): Likewise.
(store::set_value): Likewise.
(store::on_maybe_live_values): Pass around store_manager.
(store::fill_region): Likewise.
(store::mark_region_as_unknown): Likewise.
(store::get_or_create_cluster): Likewise.
(store::can_merge_p): Likewise.
(store::mark_as_escaped): Likewise.
(store::canonicalize): Update for field renamings.
(store::loop_replay_fixup): Likewise.  Pass around store_manager.
(store::replay_call_summary_cluster): Likewise.
(selftest::test_binding_map_ops): New.
(selftest::analyzer_store_cc_tests): Call it.
* store.h (class binding_map): Reimplement.
(binding_map::map_t): Drop.
(struct binding_map::symbolic_binding): New.
(binding_map::concrete_bindings_t): New.
(binding_map::symbolic_bindings_t): New.
(struct binding_map::bindings_pair): New.
(class binding_map::const_iterator): New.
(class binding_map::iterator): New.
(binding_map::get): Reimplement.
(binding_map::overwrite): New decl.
(binding_map::remove): Reimplement.
(binding_map::clear): Reimplement.
(binding_map::put): Reimplement.
(binding_map::empty_p): Reimplement.
(binding_map::begin): Reimplement.
(binding_map::end): Reimplement.
(binding_map::elements): Reimplement.
(binding_map::m_map): Drop field.
(binding_map::m_store_mgr): New field.
(binding_map::m_concrete): New field.
(binding_map::m_symbolic): New field.
(BindingVisitor): Drop.
(binding_cluster::map_t): Drop.
(binding_cluster::iterator_t): Reimplement.
(binding_cluster::const_iterator_t): New.
(binding_cluster::binding_cluster): Add store_mgr param.
(binding_cluster::for_each_value): Reimplement.
(binding_cluster::empty_p): Reimplement.
(binding_cluster::for_each_binding): Drop.
(binding_cluster::begin): Split into const/non-const overloads.
(binding_cluster::get_map): Add non-const overload.
(store::get_or_create_cluster): Add store_mgr param.
(store::mark_as_escaped): Likewise.
(store::for_each_binding): Drop.
(store::on_maybe_live_values): Add store_mgr param.
* svalue.cc (compound_svalue::compound_svalue): Reimplement.
(compound_svalue::accept): Likewise.
(compound_svalue::calc_complexity): Likewise.
(compound_svalue::maybe_fold_bits_within): Likewise.
* svalue.h (compound_svalue::const_iterator_t): New.
(compound_svalue::begin): Split into const/non-const overloads.
(compound_svalue::end): Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Replace INCLUDE_
defines with include of include "analyzer/common.h".  Update
for changes to binding_pair.
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agotestsuite: Explicitly enable cselim pass for cselim-2.c
Dimitar Dimitrov [Wed, 8 Oct 2025 18:45:09 +0000 (21:45 +0300)] 
testsuite: Explicitly enable cselim pass for cselim-2.c

The cselim pass is enabled only for targets that have conditional move
instructions.  Since pru-unknown-elf doesn't have such instructions, the
pass is not executed, and the test fails with:

  gcc.dg/tree-ssa/cselim-2.c: dump file does not exist
  UNRESOLVED: gcc.dg/tree-ssa/cselim-2.c scan-tree-dump cselim "if-then-else store replacement: 3"

Fix by explicitly enabling the cselim pass for this test.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/cselim-2.c: Pass -ftree-cselim option.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 months agoFortran: fix "unstable" interfaces of external procedures [PR122206]
Harald Anlauf [Thu, 9 Oct 2025 16:43:22 +0000 (18:43 +0200)] 
Fortran: fix "unstable" interfaces of external procedures [PR122206]

In the testcase repeated invocations of a function showed an apparently
unstable interface.  This was caused by trying to guess an (inappropriate)
interface of the external procedure after processing of the procedure
arguments in gfc_conv_procedure_call.  The mis-guessed interface showed up
in subsequent uses of the procedure symbol in gfc_conv_procedure_call.  The
solution is to check for an existing interface of an external procedure
before trying to wildly guess based on just the actual arguments.

PR fortran/122206

gcc/fortran/ChangeLog:

* trans-types.cc (gfc_get_function_type): Do not clobber an
existing procedure interface.

gcc/testsuite/ChangeLog:

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

2 months agogimplify: Fix up side-effect handling in 2nd __builtin_c[lt]zg argument [PR122188]
Jakub Jelinek [Thu, 9 Oct 2025 16:06:39 +0000 (18:06 +0200)] 
gimplify: Fix up side-effect handling in 2nd __builtin_c[lt]zg argument [PR122188]

The patch from yesterday made me think about side-effects in the second
argument of __builtin_c[lt]zg.  When we change
__builtin_c[lt]zg (x, y)
when y is not INTEGER_CST into
x ? __builtin_c[lt]zg (x) : y
with evaluating x only once, we omit the side-effects in y unless x is not
0.  That looks undesirable, we should evaluate side-effects in y
unconditionally.

2025-10-09  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Also gimplify the second operand
before the COND_EXPR and use in COND_EXPR result of gimplification.

* gcc.dg/torture/pr122188.c: New test.

2 months agodiagnostics: add class sink::extension
David Malcolm [Thu, 9 Oct 2025 15:38:50 +0000 (11:38 -0400)] 
diagnostics: add class sink::extension

This patch provides a way for plugins to add extra information
to a diagnostic sink, potentially capturing more information via
a "finalizer" hook.

gcc/c-family/ChangeLog:
* c-opts.cc: Define INCLUDE_VECTOR.

gcc/cp/ChangeLog:
* error.cc: Define INCLUDE_VECTOR.

gcc/ChangeLog:
* diagnostic-global-context.cc: Define INCLUDE_VECTOR.
* diagnostics/buffering.cc: Likewise.
* diagnostics/context.cc (context::finish): Call
finalize_extensions on each sink.
(sink::dump): Dump any extensions.
(sink::finalize_extensions): New.
* diagnostics/macro-unwinding.cc: Define INCLUDE_VECTOR.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/sink.h (class sink::extension): New.
(sink::add_extension): New.
(sink::finalize_extensions): New decl.
(sink::m_extensions): New member.
* gcc.cc: Define INCLUDE_VECTOR.
* langhooks.cc: Likewise.
* opts.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.

gcc/fortran/ChangeLog:
* error.cc: Define INCLUDE_VECTOR.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_group_plugin.cc: Define INCLUDE_VECTOR.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

libcc1/ChangeLog:
* context.cc: Define INCLUDE_VECTOR.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agolibstdc++: Extend constexpr if to C++14 in _Hashtable::_S_nothrow_move()
Jonathan Wakely [Wed, 8 Oct 2025 14:26:54 +0000 (15:26 +0100)] 
libstdc++: Extend constexpr if to C++14 in _Hashtable::_S_nothrow_move()

We can use diagnostic pragmas to allow the constexpr if version of this
function to be used for C++14 as well. We still need the __and_ version
for C++11 because we can't use 'if' in constexpr functions at all before
C++14.

Also use the integral_constant::value static data member instead of
invoking integral_constant::operator(), as it's a tiny bit cheaper to
compiler.

libstdc++-v3/ChangeLog:

* include/bits/hashtable.h (_Hashtable::_S_nothrow_move): Use
diagnostic pragmas to allow constexpr if in C++14. Use value
member instead of operator().

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Tweak comment on generated #endif lines in bits/version.h
Jonathan Wakely [Wed, 8 Oct 2025 11:42:41 +0000 (12:42 +0100)] 
libstdc++: Tweak comment on generated #endif lines in bits/version.h

Make the #endif comment match the #if condition in the generated code.

Also adjust a comment in the Scheme code which describes the logic. The
__glibcxx_NAME macro is not defined _unconditionally_, as it still
depends on the conditions in cxxmin, extra_cond etca,. and the
__cpp_lib_NAME macro now depends on no_stdname too.

libstdc++-v3/ChangeLog:

* include/bits/version.tpl: Fix comment on #endif. Tweak
description of when macros are defined.
* include/bits/version.h: Regenerate.

Reviewed-by: Arsen Arsenović <arsen@aarsen.me>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agotree-ssa-structalias: Put constraint building into its own file
Filip Kastl [Thu, 9 Oct 2025 11:45:17 +0000 (13:45 +0200)] 
tree-ssa-structalias: Put constraint building into its own file

This patch cuts out points-to constraint building from
tree-ssa-structalias.cc and places it into a new file
gimple-ssa-pta-constraints.cc.

The diff of tree-ssa-structalias.cc ended up being messy, so here is a
summary of changes I made that may not be apparent at first glance.
I didn't do any functional changes.  Everything is just shifting
functions and declarations around and giving external linkage to some
things.

- These functions now have external linkage and got shifted to the
  beginning of the file:
determine_global_memory_access
fndecl_maybe_in_other_partition
new_var_info
- The using namespace pointer_analysis directive got shifted to the
  beginning of the file
- Declarations of these global variables got shifted to the beginning of
  the file:
variable_info_pool
final_solutions
final_solutions_obstack
- These global variables got external linkage:
use_field_sensitive
in_ipa_mode

gcc/ChangeLog:

* Makefile.in: Add gimple-ssa-pta-constraints.cc.
* tree-ssa-structalias.cc (determine_global_memory_access):
External linkage, move to namespace pointer_analysis.
(fndecl_maybe_in_other_partition): External linkage, move to
namespace pointer_analysis.
(new_var_info): External linkage, move to namespace
pointer_analysis.
(create_variable_info_for): Move to
gimple-ssa-pta-constraints.cc.
(lookup_vi_for_tree): External linkage, move to namespace
pointer_analysis, move to gimple-ssa-pta-constraints.cc.
(type_can_have_subvars): Move to gimple-ssa-pta-constraints.cc.
(make_param_constraints): Move to gimple-ssa-pta-constraints.cc.
(get_call_vi): Move to gimple-ssa-pta-constraints.cc.
(lookup_call_use_vi): External linkage, move to namespace
pointer_analysis, move to gimple-ssa-pta-constraints.cc.
(lookup_call_clobber_vi): External linkage, move to namespace
pointer_analysis, move to gimple-ssa-pta-constraints.cc.
(get_call_use_vi): Move to gimple-ssa-pta-constraints.cc.
(get_call_clobber_vi): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for_1): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for_rhs): Move to gimple-ssa-pta-constraints.cc.
(do_deref): Move to gimple-ssa-pta-constraints.cc.
(constraint_pool): Move to gimple-ssa-pta-constraints.cc.
(new_constraint): Move to gimple-ssa-pta-constraints.cc.
(insert_vi_for_tree): Move to gimple-ssa-pta-constraints.cc.
(alias_get_name): Move to gimple-ssa-pta-constraints.cc.
(get_vi_for_tree): Move to gimple-ssa-pta-constraints.cc.
(new_scalar_tmp_constraint_exp): Move to
gimple-ssa-pta-constraints.cc.
(get_constraint_for_ssa_var): Move to
gimple-ssa-pta-constraints.cc.
(process_constraint): Move to gimple-ssa-pta-constraints.cc.
(bitpos_of_field): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for_ptr_offset): Move to
gimple-ssa-pta-constraints.cc.
(get_constraint_for_component_ref): Move to
gimple-ssa-pta-constraints.cc.
(get_constraint_for_address_of): Move to
gimple-ssa-pta-constraints.cc.
(process_all_all_constraints): Move to
gimple-ssa-pta-constraints.cc.
(do_structure_copy): Move to gimple-ssa-pta-constraints.cc.
(make_constraints_to): Move to gimple-ssa-pta-constraints.cc.
(make_constraint_to): Move to gimple-ssa-pta-constraints.cc.
(make_constraint_from): Move to gimple-ssa-pta-constraints.cc.
(make_copy_constraint): Move to gimple-ssa-pta-constraints.cc.
(make_escape_constraint): Move to gimple-ssa-pta-constraints.cc.
(make_indirect_escape_constraint): Move to
gimple-ssa-pta-constraints.cc.
(make_transitive_closure_constraints): Move to
gimple-ssa-pta-constraints.cc.
(make_any_offset_constraints): Move to
gimple-ssa-pta-constraints.cc.
(struct obstack fake_var_decl_obstack): Move to
gimple-ssa-pta-constraints.cc.
(build_fake_var_decl): Move to gimple-ssa-pta-constraints.cc.
(make_heapvar): Move to gimple-ssa-pta-constraints.cc.
(make_constraint_from_restrict): Move to
gimple-ssa-pta-constraints.cc.
(make_constraint_from_global_restrict): Move to
gimple-ssa-pta-constraints.cc.
(get_function_part_constraint): Move to
gimple-ssa-pta-constraints.cc.
(handle_call_arg): Move to gimple-ssa-pta-constraints.cc.
(handle_rhs_call): Move to gimple-ssa-pta-constraints.cc.
(handle_lhs_call): Move to gimple-ssa-pta-constraints.cc.
(get_fi_for_callee): Move to gimple-ssa-pta-constraints.cc.
(find_func_aliases_for_call_arg): Move to
gimple-ssa-pta-constraints.cc.
(find_func_aliases_for_builtin_call): Move to
gimple-ssa-pta-constraints.cc.
(find_func_aliases_for_call): Move to
gimple-ssa-pta-constraints.cc.
(find_func_aliases): Move to gimple-ssa-pta-constraints.cc.
(process_ipa_clobber): Move to gimple-ssa-pta-constraints.cc.
(find_func_clobbers): Move to gimple-ssa-pta-constraints.cc.
(struct fieldoff): Move to gimple-ssa-pta-constraints.cc.
(fieldoff_compare): Move to gimple-ssa-pta-constraints.cc.
(sort_fieldstack): Move to gimple-ssa-pta-constraints.cc.
(var_can_have_subvars): Move to gimple-ssa-pta-constraints.cc.
(type_must_have_pointers): Move to
gimple-ssa-pta-constraints.cc.
(field_must_have_pointers): Move to
gimple-ssa-pta-constraints.cc.
(push_fields_onto_fieldstack): Move to
gimple-ssa-pta-constraints.cc.
(count_num_arguments): Move to gimple-ssa-pta-constraints.cc.
(create_function_info_for): Move to
gimple-ssa-pta-constraints.cc.
(check_for_overlaps): Move to gimple-ssa-pta-constraints.cc.
(create_variable_info_for_1): Move to
gimple-ssa-pta-constraints.cc.
(intra_create_variable_infos): Move to
gimple-ssa-pta-constraints.cc.
(init_base_vars): Move to gimple-ssa-pta-constraints.cc.
(init_constraint_builder): Move to
gimple-ssa-pta-constraints.cc.
(delete_constraint_builder): Move to
gimple-ssa-pta-constraints.cc.
(intra_build_constraints): Move to
gimple-ssa-pta-constraints.cc.
(delete_points_to_sets): Move to gimple-ssa-pta-constraints.cc.
(associate_varinfo_to_alias): Move to
gimple-ssa-pta-constraints.cc
(refered_from_nonlocal_fn): Move to
gimple-ssa-pta-constraints.cc
(refered_from_nonlocal_var): Move to
gimple-ssa-pta-constraints.cc
(ipa_create_function_infos): Move to
gimple-ssa-pta-constraints.cc
(ipa_create_global_variable_infos): Move to
gimple-ssa-pta-constraints.cc
(ipa_build_constraints): Move to gimple-ssa-pta-constraints.cc
* tree-ssa-structalias.h (struct constraint_stats):
(determine_global_memory_access): External linkage, move to
namespace pointer_analysis.
(fndecl_maybe_in_other_partition): External linkage, move to
namespace pointer_analysis.
(new_var_info): External linkage, move to namespace
pointer_analysis.
* gimple-ssa-pta-constraints.cc: New file.
* gimple-ssa-pta-constraints.h: New file.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 months agotree-ssa-structalias: Put constraint building into separate functions
Filip Kastl [Thu, 9 Oct 2025 11:42:52 +0000 (13:42 +0200)] 
tree-ssa-structalias: Put constraint building into separate functions

Preparation for splitting out constraint building into a separate source
file.  This patch splits out constraint building from
compute_points_to_sets and ipa_pta_execute into separate functions.
It also moves initializing and cleaning up constraint building stuff
into separate functions.

gcc/ChangeLog:

* tree-ssa-structalias.cc (init_constraint_builder): New
function.
(delete_constraint_builder): New function.
(compute_points_to_sets): Put constraint building into
intra_build_constraints and call it.
(intra_build_constraints): New function.
(delete_points_to_sets): Put cleanup of constraint builder
global vars into delete_constraint_builder and call it.
(ipa_pta_execute): Put constraint building into
ipa_build_constraints and call it.
(ipa_create_function_infos): New function.
(ipa_create_global_variable_infos): New function.
(ipa_build_constraints): New function.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 months agolibstdc++: Formatting tests for std::chrono date types.
Tomasz Kamiński [Thu, 9 Oct 2025 09:12:15 +0000 (11:12 +0200)] 
libstdc++: Formatting tests for std::chrono date types.

This covers year_month_day_last, year_month_weekday, year_month_weekday_last.

libstdc++-v3/ChangeLog:

* testsuite/std/time/year_month_day_last/io.cc: New formatting tests.
* testsuite/std/time/year_month_weekday/io.cc: Likewise.
* testsuite/std/time/year_month_weekday_last/io.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoxtensa: constantsynth: Update to version 2
Takayuki 'January June' Suwa [Wed, 8 Oct 2025 01:31:37 +0000 (10:31 +0900)] 
xtensa: constantsynth: Update to version 2

This patch completely replaces the existing "constantsynth" with a new
implementation, which has become unsightly due to the extension.

This new version offers the following benefits:

  - Independence from the insn splitting mechanism.  No define_split
    descriptions are required
  - Resource saving as internally required information storage no longer
    persists across passes
  - The replacement of insns is based on the actual costs (for both size
    and speed) of the insns before and after the conversion, rather than
    on some arbitrary pre-determined ones
  - The replacing insn sequence is verified by formally evaluating the
    RTL expressions to see if it correctly computes the original constant
    value
  - Easy-to-understand/-add interface for constant synthesis methods

The built-in synthesis methods are (supposedly) very effective, with 2
instructions for certain values and up to 5 instructions to cover all
32-bit values.

     /* example */
     _Complex double test(int a[], float b[]) {
       a[0] = 2045 * 2045;
       a[1] = 0xDEADBEEF;
       a[2] = 0xDEADBEEF - 15;
       a[3] = 4182000;
       a[4] = 131071;
       a[5] = 293805;
       a[6] = 700972933;
       a[7] = -372738139;
       b[0] = 3.14159265359f;
       b[1] *= 0.12005615234375f;
       return 1-1i;
     }

     ;; result (-O2 -mextra-l32r-costs=5)
     test:
      entry sp, 32
      movi a8, 0x7af
      float.s f1, a8, 14
      movi a8, 0x7fd
      mull a8, a8, a8
      lsi f0, a3, 4
      s32i.n a8, a2, 0
      movi.n a8, 0x57
      addmi a8, a8, -0x1100
      slli a8, a8, 17
      addmi a8, a8, -0x4100
      addi a8, a8, -17
      s32i.n a8, a2, 4
      addi a8, a8, -15
      s32i.n a8, a2, 8
      movi a8, 0x3fd
      slli a8, a8, 12
      addi a8, a8, -16
      s32i.n a8, a2, 12
      movi.n a8, -1
      srli a8, a8, 15
      s32i.n a8, a2, 16
      movi a8, 0x85
      addmi a8, a8, 0x7f00
      addx8 a8, a8, a8
      s32i.n a8, a2, 20
      movi a8, 0x539
      slli a8, a8, 19
      addi a8, a8, -123
      s32i.n a8, a2, 24
      movi a8, -0x2c7
      slli a8, a8, 19
      addmi a8, a8, 0x7800
      addi a8, a8, -91
      s32i.n a8, a2, 28
      movi.n a8, 0x49
      mul.s f0, f0, f1
      addmi a8, a8, 0x4000
      slli a8, a8, 16
      addmi a8, a8, 0x1000
      addi a8, a8, -37
      s32i.n a8, a3, 0
      ssi f0, a3, 4
      movi a5, -0x401
      movi a3, 0x3ff
      movi.n a2, 0
      slli a3, a3, 20
      movi.n a4, 0
      slli a5, a5, 20
      retw.n

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h (xtensa_constantsynth): Remove.
* config/xtensa/xtensa.cc
(#include): Remove "context.h" and "pass_manager.h".
(machine_function): Remove "litpool_usage" member.
(xtensa_constantsynth_2insn, xtensa_constantsynth_rtx_SLLI,
xtensa_constantsynth_rtx_ADDSUBX, xtensa_constantsynth): Remove.
(constantsynth_method_lshr_m1, split_hwi_to_MOVI_ADDMI,
constantsynth_method_16bits, constantsynth_method_32bits,
constantsynth_method_square): New worker function related to
constant synthesis methods.
(constantsynth_method_info, constantsynth_methods):
New structure representing the list of all constant synthesis
methods.
(constantsynth_info): New structure that stores internal
information for "constantsynth".
(constantsynth_pass1, verify_synth_seq, constantsynth_pass2):
New functions that are the core of "constantsynth".
(do_largeconst): Add a call to constantsynth_pass1() to the insn
enumeration loop, and add a call to constantsynth_pass2() to the
end of this function.
* config/xtensa/xtensa.md (SHI): Remove.
(The two auxiliary define_splits for mov[sh]i_internal): Remove.
(The two auxiliary define_splits for movsf_internal): Remove.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/constsynth_2insns.c,
gcc.target/xtensa/constsynth_3insns.c,
gcc.target/xtensa/constsynth_double.c: Remove due to outdated.
* gcc.target/xtensa/constsynthV2_O2_costs0.c,
gcc.target/xtensa/constsynthV2_O2_costs5.c,
gcc.target/xtensa/constsynthV2_Os.c: New.

2 months agoxtensa: Change the splitting of D[IF]mode constant assignments to be implemented...
Takayuki 'January June' Suwa [Wed, 8 Oct 2025 01:27:48 +0000 (10:27 +0900)] 
xtensa: Change the splitting of D[IF]mode constant assignments to be implemented in xt_largeconst instead of define_split

This patch moves the process of splitting D[IF]mode constant assignments
into SImode ones from the define_split implementation after reloading to
processing within the "xt_largeconst" target-specific pass.  It also
converts SFmode constant assignments into bit-equivalent SImode ones.

This allows these assignments to be processed by the "constantsynth"
optimization, which will be reimplemented later.

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h
(xtensa_split_DI_reg_imm): Remove.
* config/xtensa/xtensa.cc (xtensa_split_DI_reg_imm): Remove.
(split_DI_SF_DF_const): New worker function.
(do_largeconst): Add a call to split_DI_SF_DF_const() to the insn
enumeration loop.
* config/xtensa/xtensa.md (movdi): Remove split code when the
source is constant.
(movdi_internal): Add a new constraint pair (a, Y) to the second
of the existing constraint alternatives.
(The auxiliary define_split for movdi_internal): Remove.

2 months agoxtensa: Optimize assignment of certain constants to hardware FP registers
Takayuki 'January June' Suwa [Fri, 19 Sep 2025 12:25:10 +0000 (21:25 +0900)] 
xtensa: Optimize assignment of certain constants to hardware FP registers

This patch introduces an optimization that replaces assignments of signed
12-bit integer values divided by 0th through 15th power of two to hardware
FP registers with assignments of that integer values to address (GP)
registers followed by negatively-scaled floating-point conversion
instructions.

For example, 0.12005615234375f is exactly equal to (1967.f / (1 << 14)), so
we can emit such as:

movi a9, 1967
float.s f0, a9, 14

if such conversion reduces costs.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xt_full_rtx_costs):
New struct, derived from full_rtx_costs.
(FPreg_neg_scaled_simm12b_1, FPreg_neg_scaled_simm12b):
New worker functions.
(do_largeconst): Add a call to FPreg_neg_scaled_simm12b() to the
insn enumeration loop.

2 months agoxtensa: Make large CONST_INT legitimate until the postreload pass
Takayuki 'January June' Suwa [Fri, 19 Sep 2025 12:24:27 +0000 (21:24 +0900)] 
xtensa: Make large CONST_INT legitimate until the postreload pass

Generally, RISC machines only have a limited bit width for integer constant
immediate values, and it is common to implement
TARGET_LEGITIMATE_CONSTANT_P() for their representation.  However, by
making bare CONST_INTs less visible in RTL, some optimizers may miss out
on opportunities.

  - Operands with the nonmemory/immediate_operand() predicates never accept
    constants that TARGET_LEGITIMATE_CONSTANT_P() rejects, so templates
    containing their predicates may unintentionally not be used for insns
    containing such constants during the RTL generation or instruction
    combination passes

  - Some optimizers only accept bare CONST_INTs and may not consider their
    equivalents (such as literal pool entry references) at all
    (Unrelated to this patch, but perhaps even worse, some optimizers such
    as RTL ifcvt, assume that not only the constant format but also the insn
    format is CISC-like)

As a clear example, the effect of constant-anchored optimization during
the postreload pass can be seen by compiling the following with and without
-mconst16 or -mauto-litpools:

     /* example */
     void test(int a[4]) {
       a[0] = 0xDEADFACE;
       a[1] = 0xDEADFACE - 1;
       a[2] = 0xDEADFACE - 2;
       a[3] = 0xDEADFACE + 254;
     }

     ;; without -mauto-litpools
      .literal_position
      .literal .LC0, -559023410
      .literal .LC1, -559023411
      .literal .LC2, -559023412
      .literal .LC3, -559023156
     test:
      entry sp, 32
      l32r a8, .LC0
      s32i.n a8, a2, 0
      l32r a8, .LC1
      s32i.n a8, a2, 4
      l32r a8, .LC2
      s32i.n a8, a2, 8
      l32r a8, .LC3
      s32i.n a8, a2, 12
      retw.n

     ;; with -mauto-litpools
     test:
      entry sp, 32
      movi a8, -559023410
      s32i.n a8, a2, 0
      addi.n a8, a8, -1 ;; const-anchored
      s32i.n a8, a2, 4
      addi.n a8, a8, -1 ;; const-anchored
      s32i.n a8, a2, 8
      addmi a8, a8, 0x100 :: const-anchored
      s32i.n a8, a2, 12
      retw.n

Therefore, we aim to overcome the above obstacles by introducing a tweak
that legitimates a full-bitwidth CONST_INT regardless of other conditions
until a specific RTL path is reached.  Then, the most appropriate point
to switch the behavior of TARGET_LEGITIMATE_CONSTANT_P() would probably
be just before reload/LRA, but as mentioned earlier, there is an optimizer
that should be utilized in postreload, so the switchover point will be
just after that.

This patch introduces a new target-specific pass called "xt_largeconst"
to implement all of the above, which will also serves as a host for other
future optimizers related to large constants, such as "constantsynth".
As a result, this patch also resolves some of the issues mentioned in the
previous patch notes:

  - B[GE/LT]U branch instructions with immediate values of 32768 or 65536
    cannot be emitted
  - Insn combination templates matching the CLAMPS instruction cannot be
    matched against large upper and lower bounds

gcc/ChangeLog:

* config/xtensa/constraints.md (Y):
Change to reference xtensa_postreload_completed_p() instead of
xtensa_split1_finished_p().
* config/xtensa/predicates.md (move_operand): Ditto.
* config/xtensa/t-xtensa (PASSES_EXTRA):
Add xtensa-passes.def as target-specific pass description.
* config/xtensa/xtensa-passes.def:
New definition file that inserts pass_xtensa_largeconst after
pass_postreload_cse.
* config/xtensa/xtensa-protos.h (xtensa_split1_finished_p): Remove.
(xtensa_postreload_completed_p, make_pass_xtensa_largeconst):
New function prototypes.
* config/xtensa/xtensa.cc (machine_function):
Add a new member "postreload_completed".
(xtensa_emit_move_sequence):
Change to reference xtensa_postreload_completed_p() instead of
can_create_pseudo_p().
(xtensa_split1_finished_p): Remove.
(xtensa_postreload_completed_p): New function.
(xtensa_legitimate_constant_p): Change to also consider
xtensa_postreload_completed_p().
(litpool_set_src_1, litpool_set_src, do_largeconst,
rest_of_handle_largeconst):
New sub-functions for pass_xtensa_largeconst.
(pass_data_xtensa_largeconst, pass_xtensa_largeconst):
New target-specific pass definition.
(make_pass_xtensa_largeconst):
New function called by the pass manager.
* config/xtensa/xtensa.md
(The auxiliary define_split for movdi_internal):
Change to reference xtensa_postreload_completed_p() instead of
xtensa_split1_finished_p().
(The first of three auxiliary define_splits for mov[sh]i_internal):
Remove.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/BGEUI-BLTUI-32k-64k.c:
Disable optimizations and modify to also verify RTL dump in the
"expand" pass.

2 months agoxtensa: Implement TARGET_MD_ASM_ADJUST
Takayuki 'January June' Suwa [Fri, 19 Sep 2025 12:23:51 +0000 (21:23 +0900)] 
xtensa: Implement TARGET_MD_ASM_ADJUST

The behavior of the 'g'-constraint on asm statement operands does not
strictly match that described in the GCC User Manual:

   "'g'  Any register, memory, or immediate integer operand is allowed,
    except for registers that are not general registers."

   -- 6.12.3.1 Simple Constraints, Using the GCC (the latest)

Contrary to the quote above, the following example will produce different
results depending on whether TARGET_CONST16 or TARGET_AUTO_LITPOOLS is
enabled:

     /* example */
     void test(void) {
       asm volatile ("# %0"::"g"(65536));
     }

     ;; TARGET_CONST16 || TARGET_AUTO_LITPOOLS
     test:
      entry sp, 32
      # 65536
      retw.n

     ;; !TARGET_CONST16 && !TARGET_AUTO_LITPOOLS
      .literal_position
      .literal .LC0, 65536
     test:
      entry sp, 32
      # .LC0
      retw.n

Indeed, both of the above results satisfy the constraint, but the latter
is not an "any" constant as stated in the manual, and is therefore incon-
sistent with the former.

This is because the behavior of the 'g'-constraint on constants depends
on the general_operand() predicate, and essentially on
TARGET_LEGITIMATE_CONSTANT_P().

This patch resolves that inconsistency by adding an 'n'-constraint imme-
diately before every occurrence of 'g' in each constraint string during
the RTL generation pass, to prioritize being an integer constant for the
alternative to which 'g' belongs.

gcc/ChangeLog:

* config/xtensa/xtensa.cc
(TARGET_MD_ASM_ADJUST): New macro definition.
(xtensa_md_asm_adjust): New function prototype and definition, that
prepends all 'g'-constraints in the "constraints" vector with 'n',
if neither TARGET_CONST16 nor TARGET_AUTO_LITPOOLS is enabled.

2 months agotree-optimization/122212 - fix CLZ detection
Richard Biener [Thu, 9 Oct 2025 07:06:27 +0000 (09:06 +0200)] 
tree-optimization/122212 - fix CLZ detection

The following corrects a mistake with the zero value handling which
was broken because the bits bias was applied first which works
for the special-case using a bit-and but not when using a conditional
move.  Apply this after the fact instead where it also more easily
folds with an existing bias we compensate.

PR tree-optimization/122212
* tree-ssa-forwprop.cc (simplify_count_zeroes): Apply
bias for CLZ after dealing with the zero special value.

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

2 months agoAVR: target/122210 - Add double -> fixed-point conversions.
Georg-Johann Lay [Wed, 8 Oct 2025 18:02:53 +0000 (20:02 +0200)] 
AVR: target/122210 - Add double -> fixed-point conversions.

PR target/122210
libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add D2<fx> modules.
* libf7-asm.sx: Implement the D2<fx> modules.

gcc/testsuite/
* gcc.target/avr/dtofx.c: New test.

2 months agoAVR: target/122210 - Add fixed-point -> double conversions.
Georg-Johann Lay [Wed, 8 Oct 2025 18:02:53 +0000 (20:02 +0200)] 
AVR: target/122210 - Add fixed-point -> double conversions.

PR target/122210
libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add <fx>2D modules.
* libf7-asm.sx: Implement the <fx>2D modules.

gcc/testsuite/
* gcc.target/avr/fxtod.c: New test.

2 months agoRISC-V: Allow VLS types using up to LMUL 8
Kito Cheng [Mon, 1 Sep 2025 10:29:53 +0000 (18:29 +0800)] 
RISC-V: Allow VLS types using up to LMUL 8

We used to apply -mrvv-max-lmul= to limit VLS code gen, auto vectorizer,
and builtin string function expansion. But I think the VLS code gen part doesn't
need this limit, since it only happens when the user explicitly writes vector
types.

For example, int32x8_t under -mrvv-max-lmul=m1 with VLEN=128 would be split into
two int32x4_t, which generate more instructions and runs slower.

In this patch, I changed -mrvv-max-lmul= to only affect auto vectorization and
builtin string function expansion. Actually, the option's help text already
says it only controls the LMUL used by auto-vectorization, so I believe this
change is makes sense :)

Changes since v1:
- Add testase to make sure auto vectorizer is still constrained by
  -mrvv-max-lmul=.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (vls_mode_valid_p): New argument
allow_up_to_lmul_8.
* config/riscv/riscv-v.cc (autovectorize_vector_modes): Set
allow_up_to_lmul_8 to false.
(vls_mode_valid_p): Add new argument allow_up_to_lmul_8, and use
it to determine whether to allow LMUL 8.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vls-type-rvv-max-lmul.c: New test.
* gcc.target/riscv/rvv/vls-type-rvv-max-lmul-autovec.c: New
test.

2 months agoPR81358: Enable automatic linking of libatomic.
Prathamesh Kulkarni [Thu, 9 Oct 2025 07:07:24 +0000 (07:07 +0000)] 
PR81358: Enable automatic linking of libatomic.

ChangeLog:
PR driver/81358
* Makefile.def: Add no_atomic=true for libraries that don't depend on
libatomic.
* Makefile.tpl: Export TARGET_CONFIGDIRS and create rule to
add dependencies for libatomic.
* configure.ac: Add libatomic to bootstrap_target_libs.
* Makefile.in: Regenerate.
* configure: Regenerate.

gcc/ChangeLog:
PR driver/81358
* common.opt: New option -flink-libatomic.
* gcc.cc (LINK_LIBATOMIC_SPEC): New macro.
* config/alpha/linux.h (LINK_GCC_C_SEQUENCE_SPEC): Use LINK_LIBATOMIC_SPEC.
* config/arm/uclinux-elf.h: Likewise.
* config/arm/unknown-elf.h: Likewise.
* config/avr/avrlibc.h: Likewise.
* config/bfin/linux.h: Likewise.
* config/darwin.h: Likewise.
* config/gnu-user.h: Likewise.
* config/lm32/uclinux-elf.h: Likewise.
* config/rs6000/linux64.h: Likewise.
* config/rs6000/rtems.h: Likewise.
* config/sparc/sparc.h: Likewise.
* doc/invoke.texi: Document -flink-libatomic.
* configure.ac: Define TARGET_PROVIDES_LIBATOMIC.
* configure: Regenerate.
* config.in: Regenerate.
* common.opt.urls: Regenerate.

libatomic/ChangeLog:
PR driver/81358
* Makefile.am: Pass -fno-link-libatomic.
New rule all-local.
* configure.ac: Assert that CFLAGS is set and pass -fno-link-libatomic.
Use __libatomic_save_CFLAGS__ instead of save_CFLAGS.
* Makefile.in: Regenerate.
* configure: Regenerate.

Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
Co-authored-by: Matthew Malcolmson <mmalcolmson@nvidia.com>
2 months agovect: Remove type from misalignment hook.
Robin Dapp [Thu, 11 Sep 2025 13:20:36 +0000 (15:20 +0200)] 
vect: Remove type from misalignment hook.

This patch removes the type argument from the vector_misalignment hook.
Ever since we switched from element to byte misalignment its
semantics haven't been particularly clear and nowadays it should be
redundant.

Also, in case of gather/scatter, the patch sets misalignment to the
misalignment of one unit of the vector mode so targets can
distinguish between element size alignment and element mode alignment.

is_packed is now always set, regardless of misalignment.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_builtin_support_vector_misalignment):
Remove type.
* config/arm/arm.cc (arm_builtin_support_vector_misalignment):
Ditto.
* config/epiphany/epiphany.cc (epiphany_support_vector_misalignment):
Ditto.
* config/gcn/gcn.cc (gcn_vectorize_support_vector_misalignment):
Ditto.
* config/loongarch/loongarch.cc (loongarch_builtin_support_vector_misalignment):
Ditto.
* config/riscv/riscv.cc (riscv_support_vector_misalignment):
Ditto.
* config/rs6000/rs6000.cc (rs6000_builtin_support_vector_misalignment):
Ditto.
* config/s390/s390.cc (s390_support_vector_misalignment):
Ditto.
* doc/tm.texi: Adjust vector misalignment docs.
* target.def: Ditto.
* targhooks.cc (default_builtin_support_vector_misalignment):
Remove type.
* targhooks.h (default_builtin_support_vector_misalignment):
Ditto.
* tree-vect-data-refs.cc (vect_can_force_dr_alignment_p):
Set misalignment for gather/scatter and remove type.
(vect_supportable_dr_alignment): Ditto.

2 months agodoc: type-punning through a union is a GNU extension for C++
Sam James [Thu, 9 Oct 2025 02:40:58 +0000 (03:40 +0100)] 
doc: type-punning through a union is a GNU extension for C++

We didn't explicitly say that type-punning through a union is undefined
behavior in C++. Mention that, and that we support it as a GNU extension.

This was reported on LLVM's Discourse (forums) [0].

[0] https://discourse.llvm.org/t/ub-when-type-punning-through-unions/88527/6

gcc/ChangeLog:
PR c++/117219

* doc/invoke.texi (-fstrict-aliasing): Explain that type-punning
through a union in C++ is supported as a GNU extension.

2 months agodoc: fix grammar nit
Sam James [Thu, 9 Oct 2025 02:38:06 +0000 (03:38 +0100)] 
doc: fix grammar nit

gcc/ChangeLog:

* doc/invoke.texi: Add missing full stop.

2 months agodoc: mention -Wmaybe-uninitialized vs CCP
Sam James [Tue, 7 Oct 2025 00:51:55 +0000 (01:51 +0100)] 
doc: mention -Wmaybe-uninitialized vs CCP

CCP interacts poorly with -Wmaybe-uninitialized in some cases by assuming a value
which stops us warning about it (false negatives). Inform users about this
infamous interaction.

gcc/ChangeLog:
PR tree-optimization/18501

* doc/invoke.texi (-Wmaybe-uninitialized): Mention interaction with
CCP.

2 months agoDaily bump.
GCC Administrator [Thu, 9 Oct 2025 00:21:21 +0000 (00:21 +0000)] 
Daily bump.

2 months agoc: Implement C23 rules for undefined static functions in _Generic
Joseph Myers [Wed, 8 Oct 2025 23:12:11 +0000 (23:12 +0000)] 
c: Implement C23 rules for undefined static functions in _Generic

A fairly late change in C23, the resolution of CD2 ballot comments
US-077 and US-078, added certain locations in _Generic to the
obviously unevaluated locations where it is permitted to have a
reference to a static function that is never defined.

Implement this feature in GCC.  The main complication is that, unlike
previous cases where it's known at the end of an operand to a
construct such as sizeof whether that operand is obviously unevaluated
and so an appropriate argument can be passed to pop_maybe_used, in the
case of a default generic association in _Generic it may not be known
until the end of that _Generic expression whether that case is
evaluated or not.  Thus, we arrange for the state of the
maybe_used_decls stack to be saved in this case and later restored
once the correct argument to pop_maybe_used is known.

There may well be further changes in this area in C2y (if the
"discarded" proposal is adopted, further locations will be OK for such
references to undefined static functions).  For now, only expressions
and not type names in _Generic have this special treatment.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
* c-typeck.cc (in_generic, save_maybe_used, restore_maybe_used):
New.
(mark_decl_used, record_maybe_used_decl, pop_maybe_used): Use
in_generic.
(struct maybe_used_decl): Move to c-tree.h.
* c-tree.h (struct maybe_used_decl): Move from c-typeck.cc.
(in_generic, save_maybe_used, restore_maybe_used): Declare.
* c-parser.cc (c_parser_generic_selection): Increment and
decrement in_generic.  Use pop_maybe_used, save_maybe_used and
restore_maybe_used.

gcc/testsuite/
* gcc.dg/c11-generic-4.c, gcc.dg/c23-generic-5.c,
gcc.dg/c2y-generic-5.c: New tests.

2 months agoFortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]
Harald Anlauf [Tue, 7 Oct 2025 19:54:45 +0000 (21:54 +0200)] 
Fortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]

The Fortran standard does not prohibit restricting the accessibility of a
symbol by use of the PRIVATE attribute and exposing it via a C binding
label.  Instead of unconditionally generating a warning, only warn if the
binding label is surprisingly identical to the privatized Fortran symbol
and when -Wsurprising is specified.

PR fortran/49111

gcc/fortran/ChangeLog:

* decl.cc (verify_bind_c_sym): Modify condition for generation of
accessibility warning, and adjust warning message.

gcc/testsuite/ChangeLog:

* gfortran.dg/binding_label_tests_9.f03: Adjust test.
* gfortran.dg/module_private_2.f90: Likewise.
* gfortran.dg/public_private_module_2.f90: Likewise.
* gfortran.dg/binding_label_tests_35.f90: New test.

2 months agoc: Allow variably-modified types in generic associations for C2Y
Martin Uecker [Sat, 30 Aug 2025 17:05:05 +0000 (19:05 +0200)] 
c: Allow variably-modified types in generic associations for C2Y

This implements part of N3348 to allow variably-modified types in
generic associations in C2Y and making it a pedantic warning before.
Allowing star * is not yet implemented.

gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Change
error_at to pedwarn_c23.

gcc/testsuite/ChangeLog:
* gcc.dg/c11-generic-2.c: Adapt error message.
* gcc.dg/c2y-generic-3.c: Adapt test.
* gcc.dg/c2y-generic-4.c: New test.

2 months agolibstdc++: Update dead links to PSTL upstream in docs
Jonathan Wakely [Wed, 8 Oct 2025 11:41:16 +0000 (12:41 +0100)] 
libstdc++: Update dead links to PSTL upstream in docs

The pstl code has been removed from the llvm repo so point to the Intel
upstream project where it really originates from.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2017.xml: Replace broken link to PSTL
upstream.
* doc/xml/manual/status_cxx2020.xml: Likewise.
* doc/html/manual/status.html: Regenerate.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Remove unused config/cpu/i486/atomicity.h file
Jonathan Wakely [Tue, 7 Oct 2025 14:06:43 +0000 (15:06 +0100)] 
libstdc++: Remove unused config/cpu/i486/atomicity.h file

This file is no longer used, because we always use the definitions in
config/cpu/generic/atomicity_builtins/atomicity.h now.

libstdc++-v3/ChangeLog:

* config/cpu/i486/atomicity.h: Removed.

Reviewed-by: Uros Bizjak <ubizjak@gmail.com>
2 months agolibstdc++: Remove unused config/cpu/cris/atomicity.h file [PR122172]
Jonathan Wakely [Tue, 7 Oct 2025 14:06:43 +0000 (15:06 +0100)] 
libstdc++: Remove unused config/cpu/cris/atomicity.h file [PR122172]

This file is no longer used, because we always use the definitions in
config/cpu/generic/atomicity_builtins/atomicity.h now.

H-P confirmed that the code generated by __atomic_fetch_add is fine and
we don't need the handwritten assembly.

libstdc++-v3/ChangeLog:

PR libstdc++/122172
* config/cpu/cris/atomicity.h: Removed.

Reviewed-by: Hans-Peter Nilsson <hp@axis.com>
2 months agolibstdc++: Fix allocator propagation and tests for std::indirect and std::polymorphic
Jonathan Wakely [Wed, 1 Oct 2025 11:45:17 +0000 (12:45 +0100)] 
libstdc++: Fix allocator propagation and tests for std::indirect and std::polymorphic

I noticed that several tests were doing:

static_assert([] { /* ... */; return true; });

i.e. just testing a lambda, not invoking it and testing the result. This
change fixes that, so that all the lambdas are invoked.

After fixing that, most of the tests failed because they were using
__gnu_test::tracker_allocator or std::scoped_allocator_adaptor in
constexpr functions. The tracker_allocator modifies global state, so can
never be constexpr, and none of std::scoped_allocator_adaptor's members
are marked constexpr.

This change makes __gnu_test::uneq_allocator and
__gnu_test::propagating_allocator usable in constant expressions, which
allows some of the tests which can't be constexpr to be duplicated to
new functions which use uneq_allocator or propagating_allocator instead
of tracker_allocator. This new functions can be tested with the
static_assert calling a lambda.

In some cases none of the tests could be adapted to be constexpr, so the
static_assert and lambda were just removed.

Two changes were also needed for the actual library code, because the
move assignment operators for std::indirect and std::polymorphic were
using copy-assignment on the allocator. Although the semantics of
move-assignment for allocators should be equivalent to copy-assignment,
an allocator isn't actually required to support copy-assignment unless
propagate_on_container_copy_assignment is true. So we have to use
move-assignment for propagate_on_container_move_assignment cases.

libstdc++-v3/ChangeLog:

* include/bits/indirect.h (indirect::operator=(indirect&&)):
Move assign allocator when POCMA is true.
(polymorphic::operator=(polymorphic&&)): Likewise.
* testsuite/std/memory/indirect/copy.cc: Remove constexpr from
functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/indirect/copy_alloc.cc: Remove constexpr
from all functions and remove static_assert.
* testsuite/std/memory/indirect/ctor.cc: Do not use
scoped_allocator_adaptor during constant evaluation.
* testsuite/std/memory/indirect/move.cc: Remove constexpr from
functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/indirect/move_alloc.cc: Remove constexpr
from all functions and remove static_assert.
* testsuite/std/memory/indirect/relops.cc: Invoke lambda in
static_assert.
* testsuite/std/memory/polymorphic/copy.cc: Remove constexpr
from functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/polymorphic/copy_alloc.cc: Remove
constexpr from all functions and remove static_assert.
* testsuite/std/memory/polymorphic/ctor.cc: Do not use
scoped_allocator_adaptor during constant evaluation.
* testsuite/std/memory/polymorphic/ctor_poly.cc: Likewise.
* testsuite/std/memory/polymorphic/move.cc: Remove constexpr
from functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/polymorphic/move_alloc.cc: Remove
constexpr from all functions and remove static_assert.
* testsuite/util/testsuite_allocator.h (tracker_allocator):
Remove redundant 'inline' from friend.
(uneq_allocator): Make all functions constexpr.
(uneq_allocator::base, uneq_allocator::swap_base): Remove.
(uneq_allocator::~uneq_allocator): Remove.
(uneq_allocator::allocate, uneq_allocator::deallocate): Do not
use map of allocations during constant evaluation.
(propagating_allocator): Make all functions constexpr.
(propagating_allocator::base): Remove.
(propagating_allocator::swap_base): Simplify.
(ExplicitConsAlloc, CustomPointerAlloc, NullablePointer): Add
constexpr to all functions.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoUpdate to Unicode 17.0.0
Jakub Jelinek [Wed, 8 Oct 2025 15:54:11 +0000 (17:54 +0200)] 
Update to Unicode 17.0.0

The following patch updates GCC from Unicode 16.0.0 to 17.0.0.

I've followed what the README says and updated also one script from
glibc, but that needed another Unicode file - HangulSyllableType.txt -
around as well, so I'm adding it.
I've added one new test to named-universal-char-escape-1.c for
randomly chosen character from new CJK block.
Note, Unicode 17.0.0 authors forgot to adjust the 4-8 table, I've filed
bugreports about that but the UnicodeData.txt changes for the range ends
and the new range seems to match e.g. what is in the glyph tables, so
the patch follows UnicodeData.txt and not 4-8 table here.

Another thing was that makeuname2c.cc didn't handle correctly when
the size of the generated string table modulo 77 was 76 or 77, in which
case it forgot to emit a semicolon after the string literal and so failed
to compile.

And as can be seen in the emoji-data.txt diff, some properties like
Extended_Pictographic have been removed from certain characters, e.g.
from the Mahjong cards characters except U+1F004, and one libstdc++
test was testing that property exactly on U+1F000.  Dunno why that was
changed, but U+1F004 is the only colored one among tons of black and white
ones.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

contrib/
* unicode/README: Add HangulSyllableType.txt file to the
list as newest utf8_gen.py from glibc now needs it.  Adjust
git commit hash and change unicode 16 version to 17.
* unicode/from_glibc/utf8_gen.py: Updated from glibc.
* unicode/DerivedCoreProperties.txt: Updated from Unicode 17.0.0.
* unicode/emoji-data.txt: Likewise.
* unicode/PropList.txt: Likewise.
* unicode/GraphemeBreakProperty.txt: Likewise.
* unicode/DerivedNormalizationProps.txt: Likewise.
* unicode/NameAliases.txt: Likewise.
* unicode/UnicodeData.txt: Likewise.
* unicode/EastAsianWidth.txt: Likewise.
* unicode/DerivedGeneralCategory.txt: Likewise.
* unicode/HangulSyllableType.txt: New file.
gcc/testsuite/
* c-c++-common/cpp/named-universal-char-escape-1.c: Add test for
\N{CJK UNIFIED IDEOGRAPH-3340E}.
libcpp/
* makeucnid.cc (write_copyright): Adjust copyright year.
* makeuname2c.cc (generated_ranges): Adjust end points for a couple
of ranges based on UnicodeData.txt Last changes and add a whole new
CJK UNIFIED IDEOGRAPH- entry.  None of these changes are in the 4-8
table, but clearly it has just been forgotten.
(write_copyright): Adjust copyright year.
(write_dict): Fix up condition when to print semicolon.
* generated_cpp_wcwidth.h: Regenerate.
* ucnid.h: Regenerate.
* uname2c.h: Regenerate.
libstdc++-v3/
* include/bits/unicode-data.h: Regenerate.
* testsuite/ext/unicode/properties.cc: Test __is_extended_pictographic
on U+1F004 rather than U+1F000.

2 months agoc++: clobber non-placement new
Jason Merrill [Wed, 8 Oct 2025 15:09:49 +0000 (16:09 +0100)] 
c++: clobber non-placement new

And also add the clobber for non-placement new.

For now let's limit the clobber of an array with non-constant bound to
placement new in constant evaluation, where we need it to set the active
member of a union.

And catch some additional cases of there being no actual data to clobber.

This changes the diagnostics in a couple of analyzer tests, but the new
diagnostics are also valid.

It also adds some -Wuninitialized warnings which seem like an improvement;
the lines that now warn about an uninitialized vptr are correct, since
trying to assign to a member of a virtual base reads the vptr of an object
that was never created.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Also clobber for non-placement new.
Only loop clobber in constexpr.
* expr.cc (wrap_with_if_consteval): New.
* cp-tree.h (wrap_with_if_consteval): Declare.

gcc/testsuite/ChangeLog:

* g++.dg/analyzer/new-2.C: Adjust diags.
* g++.dg/analyzer/noexcept-new.C: Adjust diags.
* g++.dg/warn/Warray-bounds-23.C: Add warnings.
* g++.dg/warn/Warray-bounds-24.C: Add warnings.
* g++.dg/cpp26/constexpr-new4a.C: New test.

2 months agoRegenerate gcc/configure
Antoni Boucher [Wed, 8 Oct 2025 13:49:13 +0000 (09:49 -0400)] 
Regenerate gcc/configure

Use autoconf 2.69 to regenerate gcc/configure

gcc/ChangeLog:

* configure: Regenerate.

2 months agolibstdc++: Fix type in computation of _M_weekday_index.
Tomasz Kamiński [Wed, 8 Oct 2025 13:14:04 +0000 (15:14 +0200)] 
libstdc++: Fix type in computation of _M_weekday_index.

The value should use divide instead of modulo, as given 1st of month
being weekday X (Mon, Tue, ...), 01 is always X[1], 08 is X[2], e.t.c.

This values is currently not observable, as there is no user-accessible
format specifier that will print it, however it may be exposed in future.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (_ChronoData::_M_fill_day): Replace
'%' by '/'.

2 months agox86-64: mingw: Pass and return _Float16 in vector registers [PR115054]
Trevor Gross [Sun, 14 Sep 2025 00:50:21 +0000 (19:50 -0500)] 
x86-64: mingw: Pass and return _Float16 in vector registers [PR115054]

For MinGW on x86-64, GCC currently passes and returns `_Float16` in
GPRs. Microsoft does not specify an ABI for the type so this is purely
an extension; however, there are a few reasons the current ABI is not
ideal:

1. `float` and `double` are both passed and returned in xmm registers
   under the MSVC ABI, there isn't any reason for `_Float16` to deviate.
2. `_Float16` is returned in xmm0 on Windows x86-32 by both GCC and
   Clang.
3. There is a platform-natural ABI with AVX512-FP16, which requires
   half-precision operands to be in vector registers.
4. System V uses vector registers for `_Float16`.

Thus, update the `HFmode` ABI to both pass and return in vector
registers, meaning its ABI is now identical to `float` and `double`.
This is already Clang's behavior on both its x64 MSVC and MinGW targets,
so the change here also resolves an ABI incompatibility (originally
reported in linked issue).

The results can be verified by evaluating the change in assembly output
with this source:

    void pass_f16(_Float16 x, _Float16 *dst) {
        *dst = x;
    }

    void callee_f16(_Float16);
    void call_f16() {
        callee_f16(1.0);
    }

    _Float16 ret_f16(_Float16 *x) {
        return *x;
    }

    /* Check libcall ABI */

    void extend_f16(_Float16 *x, _Float32 *dst) {
        *dst = (_Float32)*x;
    }

    void trunc_f16(_Float32 *x, _Float16 *dst) {
        *dst = (_Float16)*x;
    }

    /* Float varargs should be in vregs with a zeroed shadow GPR */

    void va(_Float16, ...);
    void va_f16() {
        va(1.0f16, 2.0f16, 3.0f16, 4.0f16, 5.0f16);
    }

While modifying the `function_value_ms_64` `switch` statement, a
redundant condition and trailing whitespace in the 16-byte case is
cleaned up.

2025-09-13  Trevor Gross  <tmgross@umich.edu>

gcc:
PR target/115054
* config/i386/i386.cc (function_arg_ms_64,
function_value_ms_64): Pass and return _Float16 in vector
registers on Windows.

Signed-off-by: Trevor Gross <tmgross@umich.edu>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
2 months agolibstdc++: Add missing include to std/time/format/format.cc
Jonathan Wakely [Wed, 8 Oct 2025 09:14:27 +0000 (10:14 +0100)] 
libstdc++: Add missing include to std/time/format/format.cc

libstdc++-v3/ChangeLog:

* testsuite/std/time/format/format.cc: Include <vector>.

2 months agoAdd boolean pattern for bitwise ops
Richard Biener [Tue, 7 Oct 2025 13:38:57 +0000 (15:38 +0200)] 
Add boolean pattern for bitwise ops

As we consider bitwise operations possible mask operations we have
to consider the case of only one operand arriving as mask.  The
following compensates for this by creating mask from the other operand
and insert possibly required mask conversions.

PR tree-optimization/110223
PR tree-optimization/122128
* tree-vect-patterns.cc (vect_recog_bool_pattern): Add
compensation for mixed mask/data bitwise operations.

* gcc.dg/vect/vect-bool-2.c: New testcase.
* gcc.dg/vect/vect-bool-cmp-3.c: Likewise.
* gcc.dg/vect/vect-bool-cmp-4.c: Likewise.

2 months agoCheck non-strictly vect_internal_def internal defs in integer_type_for_mask
Richard Biener [Wed, 8 Oct 2025 07:19:50 +0000 (09:19 +0200)] 
Check non-strictly vect_internal_def internal defs in integer_type_for_mask

We are missing masks produced by inductions or reductions otherwise.

* tree-vect-patterns.cc (integer_type_for_mask): Only
reject vect_external_defs.

2 months agoAdjust g++.dg/vect/pr64410.cc scan
Richard Biener [Wed, 8 Oct 2025 09:50:14 +0000 (11:50 +0200)] 
Adjust g++.dg/vect/pr64410.cc scan

We are now vectorizing more loops in standard library functions.
Restrict the dump scan to the loop we're interested in.

PR testsuite/120100
* g++.dg/vect/pr64410.cc: Adjust.

2 months agolibstdc++: Implement submdspan_mapping_result. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:16 +0000 (11:27 +0200)] 
libstdc++: Implement submdspan_mapping_result. [PR110352]

Implement the class submdspan_mapping_result and add it to the std
module.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (submdspan_mapping_result): New class.
* src/c++23/std.cc.in (submdspan_mapping_result): Add.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Implement full_extent_t. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:15 +0000 (11:27 +0200)] 
libstdc++: Implement full_extent_t. [PR110352]

Add the class and updates the std module.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (full_extent_t): New class.
* src/c++23/std.cc.in (full_extent_t): Add.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Implement strided_slice from <mdspan>. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:14 +0000 (11:27 +0200)] 
libstdc++: Implement strided_slice from <mdspan>. [PR110352]

Adds strided_slice as standardized in N5014. Also creates
the internal feature testing macro for submdspan.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/bits/version.def (submdspan): New internal macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan (strided_slice): New class.
* src/c++23/std.cc.in (strided_slice): Add.
* testsuite/23_containers/mdspan/submdspan/strided_slice.cc: New test.
* testsuite/23_containers/mdspan/submdspan/strided_slice_neg.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Improve and cleanup mdspan related code.
Luc Grosheintz [Tue, 30 Sep 2025 10:55:18 +0000 (12:55 +0200)] 
libstdc++: Improve and cleanup mdspan related code.

The improvement is that in __index_type_cast, we don't need to check at
runtime if we know that _IndexType is smaller than _OIndexType.

The cleanup is whitespace (overlength lines) in <mdspan>, grouping is_always_foo
and is_foo together, and de-uglifying a variable in test code.

libstdc++-v3/ChangeLog:

* include/std/mdspan (__mdspan::__index_type_cast): Optimize by
skipping a __glibcxx_assert if it's know at compile-time.
(std::layout_left_padded, std::layout_righ_padded): Reorder
is_always_strided and is_unique member functions.
* testsuite/23_containers/mdspan/int_like.h: Rename _M_i to
value.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agoDo not expect 8 byte vectorization with ia32
Richard Biener [Wed, 8 Oct 2025 09:38:12 +0000 (11:38 +0200)] 
Do not expect 8 byte vectorization with ia32

We are not considering ia32 to be TARGET_MMX_WITH_SSE so the testcase
cannot work there.

PR target/120091
gcc/testsuite/
* gcc.target/i386/pr119919.c: Only check for vectorization
when !ia32.

2 months agolibstdc++: Implement std::layout_right_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:19 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_right_padded [PR110352].

This commit adds the right padded layout as described in N5014, with
LWG4372 (dynamic padding value) and LWG4314 (move in operator()).

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (_RightPaddedIndices): Traits for right
padded layouts.
(layout_right::mapping::mapping) New overload for right padded
layouts.
(layout_right_padded): Add implementation.
* src/c++23/std.cc.in (layout_right_padded): Add.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Update
test for right padded layouts.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: Ditto.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Implement std::layout_left_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:18 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_left_padded [PR110352].

This commit adds a new layout layout_left_padded as standardized in
N5014. It adds a purely internal feature testing macro padded_layouts
and registers layout_left_padded in the std module.

This commit implements LWG4372, because without it's not possible
to properly test padded layouts with a dynamic padding value. It also
implements LWG4314, for consistency with prior layouts.

The implementation uses a _PaddedStorage to deduplicate most of the code
shared between left- and right-padded layouts. It's implemented through
aggregation rather than inheritence, because of a bug related to
inheriting conditionally explicit ctors.

The tests are written such that the canonical version works for
layout_left_padded. A version for layout_right_padded is derived
essentially by reversing the order of the extents.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/bits/version.def (padded_layouts): Add new internal
feature testing macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan (__fwd_prod): New overload.
(layout_left_padded): Add declaration and implementation.
(layout_right_padded): Add declaration only.
(layout_left::mapping::mapping): New overload for left
padded mappings.
(__index_type_cast): New function that performs a checked cast
to index_type.
(__is_left_padded_mapping): New concept.
(__is_right_padded_mapping): Ditto.
(__standardized_mapping): Recognize left and right padded
mappings.
(_LeftPaddedIndices): Traits for left padded details.
(_PaddedStorage): New class for implementing padded layouts.
* src/c++23/std.cc.in (layout_left_padded): Add.
* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc:
Refactor and add tests for layout_left_padded.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: New
traits.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agoAdd missing menu item for JIT Language and ABI
Richard Biener [Wed, 8 Oct 2025 09:13:15 +0000 (11:13 +0200)] 
Add missing menu item for JIT Language and ABI

Build of gccint.texi is currently broken, the following fixes it.

* doc/tm.texi.in (JIT Language and ABI): Add menu item.
* doc/tm.texi: Re-generate.

2 months agoc: Fix i386 target attribute regression [PR 122180]
Alfie Richards [Tue, 7 Oct 2025 09:34:48 +0000 (09:34 +0000)] 
c: Fix i386 target attribute regression [PR 122180]

My patch (r16-4182-g73888cefe6da65) broke another target (i386), which this
patch fixes.

The issue was the target_version code was incorrectly being triggered on
targets that do not support target_version semantics (i386).

PR target/122180

gcc/c/ChangeLog:

* c-decl.cc (pushdecl): Add TARGET_HAS_FMV_TARGET_ATTRIBUTE check.

gcc/testsuite/ChangeLog:

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

2 months agogimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]
Jakub Jelinek [Wed, 8 Oct 2025 07:58:41 +0000 (09:58 +0200)] 
gimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]

The following testcase ICEs during gimplification.
The problem is that save_expr sometimes doesn't create a SAVE_EXPR but
returns the original complex tree (COND_EXPR) and the code then uses that
tree in 2 different spots without unsharing.  As this is done during
gimplification it wasn't unshared when whole body is unshared and because
gimplification is destructive, the first time we gimplify it we destruct it
and second time we try to gimplify it we ICE on it.
Now, we could replace one a use with unshare_expr (a), but because this
is a gimplification hook, I think easier than trying to create a save_expr
is just gimplify the argument, then we know it is is_gimple_val and so
something without side-effects and can safely use it twice.  That argument
would be the first thing to gimplify after return GS_OK anyway, so it
doesn't change argument sequencing etc.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Gimplify CALL_EXPR_ARG (*expr_p, 0)
instead of calling save_expr on it.

* c-c++-common/pr122188.c: New test.

2 months agotestsuite: Fix up pr121987.c testcase for ilp32 [PR121206]
Jakub Jelinek [Wed, 8 Oct 2025 07:49:25 +0000 (09:49 +0200)] 
testsuite: Fix up pr121987.c testcase for ilp32 [PR121206]

The test FAILs on ilp32 targets with
pr121987.c:5:21: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '10000000000' to '1410065408' [-Woverflow]
excess error.  Fixed by using unsigned long long instead of unsigned and
using a suffix on the constant.
Tested on x86_64-linux with -m32/-m64, additionally tested with older cc1
where it ICEd in both cases in upper_bound.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/121206
* gcc.dg/pr121987.c (main): Use unsigned long long type for e instead
of unsigned long and use ULL suffix on the initializer.

2 months agoFortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]
Paul Thomas [Wed, 8 Oct 2025 07:17:10 +0000 (08:17 +0100)] 
Fortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]

2025-10-08  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/93175
PR fortran/102240
PR fortran/102686
* array.cc (match_array_element_spec): For pdt templates, call
gfc_correct_parm_expr to elimante extraneous symbols from the
bound expressions.
* decl.cc (correct_parm_expr, gfc_correct_parm_expr): New fcns
that remove symbols that are not PDT parameters from the type
specification expressions.
(insert_parameter_exprs): Process function symbols as if they
are variables in the substitution with parameter expressions.
(gfc_get_pdt_instance): Make sure that the parameter list of
PDT components is updated as the instance is built. Move the
construction of pdt_strings down a bit in the function and
remove the tie up with pdt_arrays.
* gfortran.h: Add prototype for gfc_correct_parm_expr.
* resolve.cc (resolve_component): Skip testing for constant
specification expressions in pdt_template component string
lengths and pdt_strings.
* trans-array.cc (structure_alloc_comps): Remove testing for
deferred parameters and instead make sure that components of
PDT type have parameters substituted with the parameter exprs
of the enclosing PDT.

gcc/testsuite/
PR fortran/93175
PR fortran/102240
PR fortran/102686
* gfortran.dg/pdt_55.f03: New test.

2 months agoFixup store bool pattern
Richard Biener [Tue, 7 Oct 2025 13:32:45 +0000 (15:32 +0200)] 
Fixup store bool pattern

I think the bool pattern recognition for a store from a bool we
decided to represent with a mask type is a bit confused.  The
following streamlines it by using the mask to create a data 0/1
and first possibly converting the mask according to the vector
data type we produce (that was missing and is noticable in PR110223).

This alone doesn't fix the 2nd testcase from the PR, but is required.

PR tree-optimization/110223
* tree-vect-patterns.cc (vect_recog_bool_pattern): Fix
mistakes in the store-from-mask bool pattern.  Add
required mask conversions.

2 months agotree-optimization/105490 - improve COND_EXPR bool pattern
Richard Biener [Tue, 7 Oct 2025 12:31:18 +0000 (14:31 +0200)] 
tree-optimization/105490 - improve COND_EXPR bool pattern

We miss to add a mask conversion from the mask producer to the
appropriate mask for the condition operation.  The following moves
required helpers and adds the missing part of the pattern.  That's
required both for the case we have different mask element sizes
and for the case we have a different number of elements because
cond expression vectorization doesn't handle the mask having
different nunits than the data vector.

PR tree-optimization/105490
* tree-vect-patterns.cc (build_mask_conversion): Move earlier.
(vect_convert_mask_for_vectype): Likewise.
(vect_recog_bool_pattern): Remove redundant truth type
construction.  Add missing possibly required mask conversion.

* gcc.dg/vect/vect-cond-14.c: New testcase.

2 months agolibgccjit: Add ability to get CPU features
Antoni Boucher [Fri, 21 Mar 2025 17:13:41 +0000 (13:13 -0400)] 
libgccjit: Add ability to get CPU features

gcc/ChangeLog:
PR jit/112466
* Makefile.in (tm_jit_file_list, tm_jit_include_list, TM_JIT_H,
JIT_TARGET_DEF, JIT_TARGET_H, JIT_TARGET_OBJS): New variables.
(tm_jit.h, cs-tm_jit.h, jit/jit-target-hooks-def.h,
s-jit-target-hooks-def-h, default-jit.o): New rules.
(s-tm-texi): Also check timestamp on jit-target.def.
(generated_files): Add TM_JIT_H and jit/jit-target-hooks-def.h.
(build/genhooks.o): Also depend on JIT_TARGET_DEF.
* config.gcc (tm_jit_file, jit_target_objs, target_has_targetjitm):
New variables.
* config/i386/t-i386 (i386-jit.o): New rule.
* configure: Regenerate.
* configure.ac (tm_jit_file_list, tm_jit_include_list,
jit_target_objs): Add substitutes.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (targetjitm): Document.
(target_has_targetjitm): Document.
* genhooks.cc: Include jit/jit-target.def.
* config/default-jit.cc: New file.
* config/i386/i386-jit.cc: New file.
* config/i386/i386-jit.h: New file.

gcc/jit/ChangeLog:
PR jit/112466
* Make-lang.in (JIT_OBJS): New variable.
* jit-playback.cc (replay): Include jit-target.h and initialize
target.
* jit-playback.h (class populate_target_info): New class.
* jit-recording.cc (recording::context::populate_target_info): New
method.
* jit-recording.h (recording::context::populate_target_info): New
method.
(recording::context::m_populated_target_info): New field.
* libgccjit.cc: Include jit-target.h.
(struct gcc_jit_target_info): New struct.
(gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type): New functions.
* libgccjit.h (gcc_jit_context_get_target_info,
gcc_jit_target_info_release, gcc_jit_target_info_cpu_supports,
gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type):
New functions.
* libgccjit.map (LIBGCCJIT_ABI_35): New ABI tag.
* docs/topics/compilation.rst: Add documentation for the
functions gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_35): New ABI tag.
* jit-target-def.h: New file.
* jit-target.cc: New file.
* jit-target.def: New file.
* jit-target.h: New file.

gcc/testsuite/ChangeLog:
PR jit/112466
* jit.dg/all-non-failing-tests.h: Mention
test-target-info.c.
* jit.dg/test-target-info.c: New test.
* jit.dg/test-error-target-info.c: New test.

2 months agoDaily bump.
GCC Administrator [Wed, 8 Oct 2025 00:20:55 +0000 (00:20 +0000)] 
Daily bump.

2 months agoc: Implement C2y handling of incomplete tentative definitions [PR26581]
Joseph Myers [Tue, 7 Oct 2025 23:04:54 +0000 (23:04 +0000)] 
c: Implement C2y handling of incomplete tentative definitions [PR26581]

Before C2y, a tentative definition (file-scope, not extern, no
initializer) with internal linkage and incomplete type was undefined
behavior ("shall" outside Constraints violated).  In C2y, this has
changed to a constraint violation if the type has not been completed
by the end of the translation unit, and is valid if the type has been
completed by the end of the translation unit.  This change originates
from N3347 but the wording accepted into C2y was that from reflector
message 26758.

In GCC, the case of incomplete array types was a hard error with
-pedantic, rather than a pedwarn, contrary to how -pedantic is
supposed to behave; bug 26581 requested a change to allow this case
with -pedantic (i.e. the change made in C2y).  For incomplete structs
and unions, GCC only diagnoses them if the type remains incomplete at
the end of the translation unit; bug 88727 (*not* fixed here) requests
the case where the type gets completed should also be diagnosed as a
quality of implementation matter (and that bug is still applicable for
pre-C2y langauge versions and -Wc23-c2y-compat).

Change the handling of arrays following C2y; the previous error
becomes a pedwarn_c23 while there is a new error at the end of the
translation unit if the type remains incomplete there in C2y mode.

There is an ambiguity in the wording in C2y for the case where the
type gets completed only in an inner scope; I've raised that in
reflector message 34118.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR c/26581

gcc/c/
* c-decl.cc (c_finish_incomplete_decl): Give error for tentative
definition of incomplete array for C2y with internal linkage.
(finish_decl): Do not set DO_DEFAULT based on -pedantic.  Use
pedwarn_c23 for missing array sizes for internal linkage.

gcc/testsuite/
* gcc.dg/c23-incomplete-2.c, gcc.dg/c23-incomplete-3.c,
gcc.dg/c23-incomplete-4.c, gcc.dg/c2y-incomplete-4.c,
gcc.dg/c2y-incomplete-5.c: New tests.
* gcc.dg/c23-thread-local-2.c, gcc.dg/c2y-incomplete-1.c: Update
expected errors.

2 months agolibbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic
H.J. Lu [Sat, 30 Aug 2025 18:46:31 +0000 (11:46 -0700)] 
libbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic

Since _Decimal128 arithmetic requires the round-to-nearest rounding
mode, define DFP_INIT_ROUNDMODE and DFP_RESTORE_ROUNDMODE, similar to
FP_INIT_ROUNDMODE in sfp-machine.h, to set the rounding mode to
round-to-nearest at _Decimal128 related arithmetic function entrances
and restores it upon return.  This doesn't require linking with libm
when libgcc is used.

libgcc/

PR target/120691
* Makefile.in (DECNUMINC): Add -I$(srcdir)/config/$(cpu_type).
* config/i386/dfp-machine.h: New file.
* config/i386/32/dfp-machine.h: Likewise.
* config/i386/64/dfp-machine.h: Likewise.

libgcc/config/libbid/

PR target/120691
* bid128_div.c: Run DFP_INIT_ROUNDMODE at function entrace and
DFP_RESTORE_ROUNDMODE at function exit.
* bid128_rem.c: Likewise.
* bid128_sqrt.c: Likewise.
* bid64_div.c (bid64_div): Likewise.
* bid64_sqrt.c (bid64_sqrt): Likewise.
* bid_conf.h: Include <dfp-machine.h>.
* dfp-machine.h: New file.

gcc/testsuite/

PR target/120691
* gcc.target/i386/pr120691.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoc++: new-expr clobber of constant-size array
Jason Merrill [Sat, 4 Oct 2025 08:24:29 +0000 (09:24 +0100)] 
c++: new-expr clobber of constant-size array

I previously tried to clobber an array as a whole, but fell back on a loop
due to issues with std::construct_at following the resolution of LWG3436.
But the loop seems to make life hard for the optimizers and it occurs to me
that for a one-element array we can just clobber the element type.

This also fixes some xfails in Warray-bounds-20.C.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Clobber a constant-bound array as a whole.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Warray-bounds-20.C: Remove xfails, add diags.

2 months agodocs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro
Alfie Richards [Wed, 13 Aug 2025 20:13:28 +0000 (20:13 +0000)] 
docs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro

Adds documentation for the TARGET_HAS_FMV_TARGET_ATTRIBUTE macro hook.

gcc/ChangeLog:

* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE.

2 months agoAVR: target/122187 - Don't clobber recog_data.operand[] in insn out.
Georg-Johann Lay [Tue, 7 Oct 2025 15:50:34 +0000 (17:50 +0200)] 
AVR: target/122187 - Don't clobber recog_data.operand[] in insn out.

avr.cc::avr_out_extr() and avr.cc::avr_out_extr_not()
changed xop for output, which spoiled the operand for
the next invokation, running into an assertion.

This patch makes a local copy of the operands.

PR target/122187
gcc/
* config/avr/avr.cc (avr_out_extr, avr_out_extr_not):
Make a local copy of the passed rtx[] operands.

gcc/testsuite/
* gcc.target/avr/torture/pr122187.c: New test.

2 months agoall: Fix "specifc", "costant" and "constat" typos in comments
Jonathan Wakely [Tue, 7 Oct 2025 14:00:24 +0000 (15:00 +0100)] 
all: Fix "specifc", "costant" and "constat" typos in comments

gcc/ChangeLog:

* config/i386/i386-features.cc
(general_scalar_chain::vector_const_cost): Fix spelling in
comment.
* ipa-prop.h (enum jump_func_type): Likewise.
* tree-vectorizer.cc (try_vectorize_loop_1): Likewise.

gcc/cp/ChangeLog:

* module.cc (trees_out::lang_vals): Fix spelling in comment.

gcc/jit/ChangeLog:

* docs/_build/texinfo/libgccjit.texi: Fix spelling.
* docs/internals/index.rst: Likewise.

libgm2/ChangeLog:

* configure.host: Fix spelling in comment.

libstdc++-v3/ChangeLog:

* configure.host: Fix spelling in comment.

gcc/testsuite/ChangeLog:

* gfortran.dg/dynamic_dispatch_9.f03: Fix spelling in comment.
* gfortran.dg/use_only_3.inc: Likewise

2 months ago[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].
Robin Dapp [Tue, 7 Oct 2025 13:18:27 +0000 (07:18 -0600)] 
[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].

Hi,

In shuffle_series_pattern we use series_p to determine if the permute
mask is a simple series.  This didn't take into account that series_p
also returns true for e.g. {0, 3, 2, 1} where the step is 3 and the
indices form a series modulo 4.

We emit
 vid + vmul
in order to synthesize a series.  In order to be always correct we would
need a vrem afterwards still which does not seem worth it.

This patch adds the modulo for VLA permutes and punts if we wrap around
for VLS permutes.  I'm not really certain whether we'll really see a wrapping
VLA series (certainly we haven't so far in the test suite) but as we observed
a VLS one here now it appears conservatively correct to module the indices.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

PR target/121845

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_series_patterns):
Modulo indices for VLA and punt when wrapping for VLS.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121845.c: New test.

2 months ago[PATCH] RISC-V: Fix slide pattern recognition [PR122124]
Raphael Moreira Zinsly [Tue, 7 Oct 2025 13:14:01 +0000 (07:14 -0600)] 
[PATCH] RISC-V: Fix slide pattern recognition [PR122124]

Ensure the second pivot is really a pivot and it's not in OP1.

PR target/122124
gcc/ChangeLog:
* config/riscv/riscv-v.cc (shuffle_slide_patterns): Check if
the second pivot is in OP1 and improve comments.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr122124.c: New test.

2 months agoFortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]
Paul Thomas [Tue, 7 Oct 2025 12:30:43 +0000 (13:30 +0100)] 
Fortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]

2025-10-07  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/102901
* trans-array.cc (structure_alloc_comps): Do not use
gfc_check_pdt_dummy with pointer or allocatable components.

gcc/testsuite/
PR fortran/102901
* gfortran.dg/pdt_56.f03: Copy of pdt_13.f03 compiled with
-fcheck=all.