Skip to content

Sync with upstream (2026-11-26): 462db733c853ed199c05f164ca95232505921d83 - #5128

Merged
dkm merged 225 commits into
masterfrom
gerris/rebase/2026-11-26
Nov 26, 2026
Merged

dkm merged 225 commits into
masterfrom
gerris/rebase/2026-11-26

Conversation

@dkm

@dkm dkm commented Nov 26, 2026

Copy link
Copy Markdown
Member

This is a sync with upstream GCC:

-- gerris 🦀

jakubjelinek and others added 30 commits November 21, 2026 10:01
r17-4656 side_effects_p should be on op0 for
testcase to produce correct code.

2026-11-21  Kael Andrew Franco  <kaelfandrew@gmail.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/128119
	* simplify-rtx.cc (simplify_binary_operation_1) <UMUL_HIGHPART>:
	Fix side_effects_p argument for x h* 1 to 0 simplification.

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

Signed-off-by: Kael Andrew Franco <kaelfandrew@gmail.com>
Reviewed-by: Richard Biener <rguenth@suse.de>
…sequence to begin octal-literals

The following patch partially implements the C++29
P0085R5 - Oo... adding a coherent character sequence to begin octal-literals
paper.  The partial word is there because it doesn't add any deprecation
for the 000 and 042 etc. literals, only adds support for the new 0o42 and
0O42 literals.  Deprecation will be done in a separate patch.
Yes, this is a new feature for C++, but as the patch shows, except for
the testcase it is just a few lines, because all the support is already
there, just restricted to C until now.

2026-11-21  Jakub Jelinek  <jakub@redhat.com>

	P0085R5
gcc/c-family/
	* c-cppbuiltin.cc (c_cpp_builtins): Predefine __cpp_0o_octals
	for C++29.
gcc/testsuite/
	* g++.dg/DRs/dr2581-1.C: Add __cpp_0o_octals test.
	* g++.dg/DRs/dr2581-2.C: Likewise.
	* g++.dg/cpp29/feat-cxx29.C: Likewise.
	* g++.dg/cpp29/octal1.C: New test.
	* g++.dg/cpp29/octal2.C: New test.
	* g++.dg/cpp29/octal3.C: New test.
	* g++.dg/cpp29/octal4.C: New test.
libcpp/
	* init.cc (lang_defaults): Set octal_constants for C++29.
	* expr.cc (cpp_classify_number): Parse 0o and 0O prefixes even for
	C++.  Emit different diagnostics for C++ if octal_constants is
	false.

Reviewed-by: Jason Merrill <jason@redhat.com>
I've committed the clmul patch some days ago with the FTM intentionally
lowered just in case the paper undergoes substantial changes.
For simd part that would be even useful but we don't have that
implemented yet.

This patch just updates it to the final one.

2026-11-21  Jakub Jelinek  <jakub@redhat.com>

	* include/bits/version.def (clmul): Bump FTM to 202611.
	* include/bits/version.h: Regenerate.
	* include/std/numeric: Use #ifdef __glibcxx_clmul rather than
	#if __glibcxx_clmul > 202610L.
	* testsuite/26_numerics/clmul/1.cc: Expect __cpp_lib_clmul 202611.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
…S with different promotion state

Wow, this one was fun.  I fully expected this to be a RISC-V target problem,
but in the end it's generic and very old.  It's just been latent for decades!

The core problem is exp_equiv_p (used by CSE and GCSE) returns true for SUBREG
expressions with different promotion states.

A RISC-V backend change in this cycle stopped pretending we always had zero
extension insns during expansion.  Instead the port now emits the shift pair
when the appropriate extensions are not available.

That caused the testcase from the PR to use expanded shift pairs for zero
extension.  We had an underlying SUBREG object in those newly exposed shifts.
In one context that SUBREG object had promoted state and in another context it
did not.  GCSE (incorrectly) determined the SUBREGs were equivalent and created
the dominating definition allowing the two instances to be removed.  The
representative instance GCSE inserted had the promotion state markers, but was
inserted into a point where the promoted state did not hold.  combine then came
along saw we had a shift pair implementing zero extension on a value that was
marked as already extended, so combine removed the zero extension.  Boom,
incorrect code.

Bootstrapped and regression tested on x86 and aarch64.  Also tested on
riscv32-elf and riscv64-elf.  Pushing to the trunk.

Assisted-By: Claude for dumpfile analysis

	PR rtl-optimization/128910
gcc/
	* cse.cc (exp_equiv_p): Return false for SUBREGs that have different
	promotion states.

gcc/testsuite
	* gcc.dg/torture/pr128910.c: New test.
…type [PR125221]

If the value range of a popcount argument shows that it fits in a
narrower unsigned type, convert the argument to that type and call the
popcount function for it.  This lets the target use a cheaper popcount,
for example a 32-bit one for a 64-bit value that is known to be below
2^32.

The function is chosen from the narrowed type: IFN_POPCOUNT if the
target supports it for that type, otherwise __builtin_popcount
(32 bits) or __builtin_popcountll (64 bits).  The builtins are used
only when the original type is wider than a word and has no popcount of
its own, since libgcc has no popcount routine narrower than a word on
most targets.  Wide arguments such as __int128 and _BitInt are
narrowed to 32, 64 or 128 bits, up to MAX_FIXED_MODE_SIZE.

Changes since v2:
* Restrict the __builtin_popcount / __builtin_popcountll fallback to
  types wider than a word that have no popcount of their own, as in
  popcount (zext (X)) (addressed sashiko LLM review comment -
  20261115121407.2749144-1-Shivam98.tkg%40gmail.com)
* Limit popcountll-narrow.c to targets with a popcount optab (aarch64,
  and x86 with -mpopcnt), and scan only for .POPCOUNT.
* Limit popcountg-narrow-bitint.c to 64-bit aarch64 and x86_64.

Changes since v1:
* Fix the narrowed call.  v1 reused the matched variant, so
  __builtin_popcountll could receive an unsigned int.  v2 picks
  IFN_POPCOUNT, __builtin_popcount or __builtin_popcountll from the
  narrowed type, as popcount (zext (X)) does.
* Also narrow to 64 and 128 bits where the target has an
  IFN_POPCOUNT for that type, covering __int128 and _BitInt.
* Tests: accept both __builtin_popcount and .POPCOUNT, and add
  a scan that no narrowed value reaches __builtin_popcountll. Add
  _BitInt and aarch64 128-bit tests.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/125221

gcc/ChangeLog:

	* gimple-match-head.cc: Include vr-values.h.
	* match.pd (POPCOUNT): Narrow the argument when its value range
	fits in a narrower unsigned type.

gcc/testsuite/ChangeLog:

	* gcc.dg/popcountll-narrow.c: New test.
	* gcc.dg/popcountg-narrow-bitint.c: New test.
	* gcc.target/aarch64/popcountg-narrow-128.c: New test.

Signed-off-by: Shivam Gupta <Shivam98.tkg@gmail.com>
…PR115392]

If A is known to lie in [0, 2^m-1], then X | A and X ^ A leave the bits
of X at and above position m unchanged, so the comparison with C is
decided by the high parts alone when the low m bits of C are:

        all ones: fold (X op A) <= C and (X op A) > C to X <= C and X > C,
        all zeros: fold (X op A) < C and (X op A) >= C to X < C and X >= C.

A may be a constant or a range limited value, for example a bool,
a masked value or a value with a known range.
The fold is not done when A may touch the sign bit.

	PR tree-optimization/115392

gcc/ChangeLog:

	* match.pd: Fold (X | A) cmp C and (X ^ A) cmp C into X cmp C
	when A is known to be in [0, 2^m-1] and the low m bits of C are
	all ones (le, gt) or all zeros (lt, ge).

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr115392-1.c: New test.
	* gcc.dg/tree-ssa/pr115392-2.c: New test.
	* gcc.dg/tree-ssa/pr115392-3.c: New test.
	* gcc.dg/tree-ssa/pr115392-4.c: New test.
	* gcc.dg/tree-ssa/pr115392-5.c: New test.
	* gcc.dg/ipa/pr91088.c: Use a constant that the new fold does not
	simplify, so that the XOR is still visible to ipa-cp.
ISO doesn't allow a refmodded string as a target; IBM, MF, and GnuCOBOL
do.  -Wrefmod was added to handle that.

The lexer and parser wasn't handling missing closing parentheses, or
missing closing double quotes, or missing closing single quotes.  These
changes repair that.

ADD CORRESPONDING and SUBTRACT CORRESPONDING now reject senders and
receivers that are not groups.

gcc/cobol/ChangeLog:

	* cbldiag.h (enum cbl_diag_id_t): -Wrefmod.
	* cobol1.cc (cobol_langhook_handle_option): Likewise.
	* gcobol.1: Likewise.
	* lang-specs.h: Likewise.
	* lang.opt: Likewise.
	* lexio.cc (cobol_filename): Handle missing closing characters.
	(mapped_file): Likewise.
	(lexer_input_close): Likewise.
	(lexer_input): Likewise.
	* lexio.h (lexer_input_close): Likewise.
	* messages.cc: -Wrefmod.
	* parse.y: Fix ADD/SUBTRACT CORRESPONDING; handle IF <object class>
	properly.
	* parse_ante.h (struct arith_t): handle IF <object class>.
	(struct ast_op_t): Likewise.
	(class eval_subject_t): Likewise.
	(valid_sign_condition): Likewise.
	(valid_class_condition): Likewise.
	* scan.l:  Handle missing closing characters.
	* scan_ante.h (skip_string): Handle missing closing characters.
	(is_refmod): -Wrefmod.
	* symbols.h (struct cbl_refer_t): handle IF <object class>.
	* util.cc (parse_file): Handle missing closing characters.

gcc/testsuite/ChangeLog:

	* cobol.dg/group2/COMPUTE_multiplication_to_FIX4.cob: Use NUMVAL
	to convert a numeric-edited value to a numeric value.
Analyze and generate broadcast for uniform gather offsets

Implement analysis using SCEV information and formal proof to detect when
gather offset expressions evaluate to the same value for all lanes of
each vector of N lanes. For example, if N=8, iterations
0-7 of "i >> 6" all evaluate to 0, enabling optimization to broadcast.

Example: For "M[i >> 6]" with N=8:
- Iterations 0-7: i >> 6 = 0 (uniform)
- Iterations 64-71: i >> 6 = 1 (uniform)
Here we can optimize each vector iteration to load once + broadcast

Then transform uniform gather operations into optimized scalar load + broadcast
instead of emulated gather with N individual scalar loads.

 BEFORE (Emulated Gather - 8 loads for N=8):
     for each lane i in 0..7:
         offset[i] = BIT_FIELD_REF<offset_vector, i>
         addr[i] = base + offset[i] * scale
         result[i] = MEM[addr[i]]
       result_vector = {result[0], ..., result[7]}

 AFTER (Broadcast - 1 load):
         offset = BIT_FIELD_REF<offset_vector, 0>
         addr = base + offset * scale
         scalar_val = MEM[addr]
         result_vector = {scalar_val, scalar_val,...}

gcc/ChangeLog:

	* tree-vect-data-refs.cc (vect_check_gather_load_offset_uniform): New.
	Return whether the gather offset is the same for all lanes of
	each vector of N = CONST_NUNITS lanes in LOOP.
	* tree-vect-stmts.cc (get_load_store_type): Initialize
	gs_offset_uniform_p. Call vect_check_gather_load_offset_uniform
	and set gs_offset_uniform_p.
	(vectorizable_load): Generate broadcast for uniform gather offsets.
	* tree-vectorizer.h (struct vect_load_store_data): New field gs_offset_
	uniform_p for flagging uniformity.

gcc/testsuite/ChangeLog:

	* g++.dg/vect/vect-uniform-broadcast-neg.cc: New test.
	* g++.dg/vect/vect-uniform-broadcast-op2-var.cc: New test.
	* g++.dg/vect/vect-uniform-broadcast.cc: New test.
	* gcc.dg/vect/vect-gather-uniform-and.c: New test.
	* gcc.dg/vect/vect-gather-uniform-epil-1.c: New test.
	* gcc.dg/vect/vect-gather-uniform-mpeel-1.c: New test.
	* gcc.dg/vect/vect-gather-uniform-neg-and.c: New test.
	* gcc.dg/vect/vect-gather-uniform-peel-1.c: New test.
	* gcc.dg/vect/vect-gather-uniform-peel-2.c: New test.
	* gcc.dg/vect/vect-gather-uniform-peel-3.c: New test.
	* gcc.dg/vect/vect-gather-uniform-run-1.c: New test.
	* gcc.dg/vect/vect-gather-uniform-run-2.c: New test.
	* gcc.dg/vect/vect-gather-uniform-run-3.c: New test.
	* gcc.dg/vect/vect-gather-uniform-slp-1.c: New test.
	* gcc.dg/vect/vect-gather-uniform-slp-2.c: New test.
A parenthesized scalar CLASS variable passed as an actual argument was
not copied, so the dummy aliased the variable, and passing it to a TYPE
dummy with allocatable components segfaulted, because the components of
the CLASS container were copied and freed as if it were the derived
type.  Make the value of a parenthesized scalar CLASS variable a copy in
gfc_conv_expr_op, made through the vtable and finalized after its use,
keep the free of the copy until after the call, and leave its
components to the copy's own finalization.

Assisted-by: Claude Opus 5.5

	PR fortran/128478

gcc/fortran/ChangeLog:

	* trans-expr.cc (conv_class_value_copy): New function.
	(gfc_conv_expr_op): Use it to copy a parenthesized scalar CLASS
	variable.
	(gfc_conv_procedure_call): Do not copy or free the allocatable
	components of the copy of a parenthesized scalar CLASS variable.
	(gfc_conv_expr_reference): Keep the free of that copy in se->post.

gcc/testsuite/ChangeLog:

	* gfortran.dg/asan/paren_class_copy_1.f90: New test.
… [PR128611]

instantiate_new_reg replaced virtual_cfa_rtx with the argument pointer
plus cfa_offset.  In a frame realigned with a dynamic realign argument
pointer (DRAP) the argument pointer is at no fixed offset from SP or the
hard frame pointer.  On x86 it is eliminated to a fake location, the copy
of the return address pushed after realignment, so __builtin_dwarf_cfa
returns the wrong address.  On a target that doesn't push such a copy it
can't be eliminated at all.

virtual_incoming_args_rtx already uses crtl->args.internal_arg_pointer,
the DRAP pseudo, in this case: the DRAP holds arg_pointer_rtx +
in_arg_offset.  Do the same for virtual_cfa_rtx, at offset
cfa_offset - in_arg_offset.  On x86, the only target that currently
reaches this path, in_arg_offset is 0; subtracting it keeps the
instantiation correct for a target where FIRST_PARM_OFFSET is not 0.

The FRAME_POINTER_CFA_OFFSET branch is left alone.  Of the targets that
define it, only nvptx also provides a DRAP (TARGET_GET_DRAP_RTX), and
there is no CFA-based unwinding on PTX to check it against.

dwarf-cfa-1.c compares the CFA seen by a realigned and a plain function
called from the same frame.  Without this change it aborts on x86_64
and i686 whenever the frame is realigned with a DRAP: in the
-mforce-drap variants of stackalign.exp, and with -m32 unless
-maccumulate-outgoing-args is given.

Assisted-by: Claude Opus 5.5
Acked-by: Uros Bizjak <ubizjak@gmail.com>

gcc/ChangeLog:

	PR middle-end/128611
	* function.cc (instantiate_new_reg): Instantiate virtual_cfa_rtx
	from the DRAP pseudo in a realigned frame.

gcc/testsuite/ChangeLog:

	PR middle-end/128611
	* gcc.dg/torture/stackalign/dwarf-cfa-1.c: New test.

Signed-off-by: Igor Shevlyakov <igor.shevlyakov@gmail.com>
When a component has a defined assignment whose first argument is
INTENT(INOUT), or INTENT(OUT) and finalizable,
generate_component_assignments first copies the lhs to a temporary.
With a scalar pointer lhs the temporary became a pointer too, which
nothing allocated, so the copy wrote through a null pointer.  Do not
give a scalar temporary the POINTER attribute.

Assisted-by: Claude Opus 5.5

	PR fortran/128833

gcc/fortran/ChangeLog:

	* resolve.cc (generate_component_assignments): Do not give a scalar
	temporary for the lhs the POINTER attribute.

gcc/testsuite/ChangeLog:

	* gfortran.dg/defined_assignment_pointer_lhs_1.f90: New test.
IS_CONTIGUOUS returned .true. for an array section with a vector
subscript, such as A([1,3]), because the run-time test inspected the
contiguous temporary that is built for such a section.  F2023 8.5.7
does not make a section with a vector subscript contiguous, so
simplify the result to .false.

Assisted-by: Claude Opus 5.5

gcc/fortran/ChangeLog:

	* simplify.cc (gfc_simplify_is_contiguous): Return .false. for an
	array section with a vector subscript.

gcc/testsuite/ChangeLog:

	* gfortran.dg/is_contiguous_8.f90: New test.
gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_compute_frame_info): Do not compute the saved
	registers masks for naked functions.
	(loongarch_naked_function_p): New function.
	(loongarch_expand_prologue): Do not emit a prologue for
	naked functions and report a zero static stack size.
	(loongarch_expand_epilogue): Do not emit an epilogue for
	naked functions.
	(loongarch_function_ok_for_sibcall): Return false for naked
	functions.
	(loongarch_allocate_stack_slots_for_args): New function.
	(loongarch_warn_func_return): New function.
	(loongarch_set_current_function): Record whether the current
	function is naked in machine_function.
	(loongarch_handle_fndecl_attribute): New function.
	(TARGET_GNU_ATTRIBUTES): Add naked attribute.
	(TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS): Define.
	(TARGET_WARN_FUNC_RETURN): Define.
	* config/loongarch/loongarch.h (machine_function):
	Add naked_p field.
	* config/loongarch/loongarch.md (*<optab>): Emit no assembly
	for the	return instruction of a naked function.
	* doc/extend.texi (Common Attributes): Document LoongArch
	support for the naked attribute.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/naked-1.c: New test.
	* gcc.target/loongarch/naked-2.c: New test.
A nonpointer function result passed as an actual argument was not
finalized when the call was an operand or in a condition, and never
when its type had a component with a defined assignment, although
F2023 7.5.6.3 requires it.

gfc_conv_procedure_call collects the finalization of such results in
the finalblock of the enclosing call, but only assignments, subroutine
calls and I/O emit that block; operators, intrinsic functions and
conditions drop it.  gfc_finalize_tree_expr also skips every function
result of a type with a defined-assignment component, although
generate_component_assignments handles only a result that is the
right-hand side of an intrinsic assignment.

For a function result not returned by reference, move the
finalization of the arguments to the front of the post block, which
every enclosing expression keeps.  Count the nesting of actual
argument evaluation in actual_arg_level and apply the skip only
outside it.  move_alloc_20.f03 counted only the finalization in the
assignment inside GET_U; it now also counts that of its result.

Assisted-by: Claude Opus 5.5

	PR fortran/128856

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Increment
	actual_arg_level while evaluating the arguments.  For a function
	result not returned by reference, move the finalization of the
	arguments to the post block.
	* trans.cc (actual_arg_level): New.
	(gfc_finalize_tree_expr): Do not skip a type with a
	defined-assignment component for an actual argument.
	* trans.h (actual_arg_level): Declare.

gcc/testsuite/ChangeLog:

	* gfortran.dg/move_alloc_20.f03: Count the finalization of the
	result of GET_U.
	* gfortran.dg/finalize_65.f90: New test.
The lsx_vbitrevi_<lsxfmt> described its immediate with
const_lsx_branch_operand, the predicate used for the branch offsets
(-1024 .. 1023), instead of const_<bitimm>_operand.  The immediate of
vbitrevi is a bit index, so it must fit in the element: 3 bits for
byte, 4 bits for halfword, 5 bits for word and 6 bits for doubleword
elements.

Because the predicate was too permissive, out of range immediates were
not diagnosed by the compiler; they were emitted as-is and the
assembler then failed with Fatal error: Immediate overflow.

gcc/ChangeLog:

	* config/loongarch/lasx.md (bitimm256): Remove.  Update all
	instruction templates to use bitimm.
	* config/loongarch/lsx.md (lsx_vbitrevi_<lsxfmt>): Use
	const_<bitimm>_operand instead of const_lsx_branch_operand.
	* config/loongarch/predicates.md (const_lsx_branch_operand):
	Remove.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vector/lsx/vbit-imm-range.c: New test.
The workarounds for the lost FDIV or FSQRT result, for the AT697F and
for the UT699 used next_active_insn() to walk their instruction windows.
A zero-length insn, such as the frame blockage or an empty asm
statement, emits no instruction, but it took a place in the window.  A
problematic sequence which spanned such an insn got no NOP.

Use next_active_non_empty_insn() in these walks, like the workarounds
for the branch target, the UT700 and the back-to-back stores.

Assisted-by: Claude Opus 5.5
Co-authored-by: Matteo Concas <matteo.concas@gaisler.com>

gcc/ChangeLog:

	* config/sparc/sparc.cc (sparc_do_work_around_errata): Use
	next_active_non_empty_insn to walk the instruction windows of the
	lost divide/square root, the AT697F and the UT699 workarounds.

gcc/testsuite/ChangeLog:

	* gcc.target/sparc/fix-gr712rc-1.c: Add lost divide tests.
	* gcc.target/sparc/fix-at697f-1.c: New test.
	* gcc.target/sparc/fix-ut699-1.c: New test.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The default mode for tests contained in vect.exp is configured in
check_vect_support_and_set_flags.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/pr128689-2.c: Remove explict "dg-do run".

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
The heterogeneous even/odd widening templates combine a zero-extended
operand with a sign-extended operand and produce a <WVEC_HALF> result.
The zero-extended operand correctly uses <WVEC_HALF>, but the
sign-extended operand in simd_<optab>w_evod_<mode>_hetero incorrectly
uses <WVEC>, i.e. the mode of the un-widened source vector.

For a 64-bit element input such as V2DI, the malformed RTL is:

  (plus:V1TI
    (zero_extend:V1TI (vec_select:V2DI ...))
    (sign_extend:V2TI (vec_select:V2DI ...)))

or the corresponding minus or mult expression.  The sign extension must
produce V1TI, not V2TI.  The malformed RTL can assert in CSE while
folding constant operands, or later in combine's simplify_subreg.

gcc/ChangeLog:

	* config/loongarch/simd.md
	(simd_<optab>w_evod_<mode>_hetero): Use <WVEC_HALF> instead of
	<WVEC> for the result of the sign extension.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vector/lasx/hetero-widen-const.c: New test.
	* gcc.target/loongarch/vector/lsx/hetero-widen-const.c: New test.
This is a temporary measure to fix PR target/128734 until the support
for C++ named address spaces is merged.  By leaving this function as
default, we don't reach the assert that checks for address space
qualification that we can't handle.  The named address space patches
allow us to use cp_type_quals as LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
again.

Note that the presence of this address space qualification can lead to
ICEs in the compiler, as shown in the comments on that PR, on
specific (but rare) cases.

gcc/cp/ChangeLog:

	PR target/128734
	* cp-objcp-common.cc (cp_type_quals_as_set): Remove.
	* cp-objcp-common.h (cp_type_quals_as_set): Remove.
	(LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN): Leave as default.
-mrecord-mcount emits __mcount_loc without an alignment directive, so
the section has an alignment of 1.  GNU ld and LLD only use packed
relative relocations (-z pack-relative-relocs) for input sections that
are at least 2-byte aligned, so in position independent output, each
entry needs a 24 byte RELA relocation instead.  For a PIE build of the
x86_64 Linux kernel, that is 50111 relocations (1.2 MB) instead of
about 6 KB of RELR.

Align the entries to their size, like the generic code already does
for __patchable_function_entries.

gcc/ChangeLog:

	* config/i386/i386.cc (x86_function_profiler): Align the
	__mcount_loc entries to their size.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/record-mcount-2.c: New test.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This patch removes the Front-Cover Text definitions from the two GNAT
manuals.  This eliminates the obligation on publishers to print the
titles of the manuals on their covers and allows Debian to continue
with its current packaging.

gcc/ada/
	PR ada/128510
	* doc/gnat_rm.rst: Remove FDL Front-Cover Text.
	* doc/gnat_ugn.rst: Likewise.
	* gnat_rm.texi: Regenerate.
	* gnat_ugn.texi: Likewise.
libiberty.h includes redeclarations of a bunch of possibly-system-
provided functions (mkstemps, etc); but it doesn't properly handle the
case where the system defines these as macros, and has already defined
them when libiberty.h is #included.  This has a tendency to cause build
faulures on such systems (glibc is usually explicitly ruled out, which
is a bit of a code smell in itself).

Redeclare in parentheses, avoiding any macro definition.

include/
	PR bootstrap/127914
	* libiberty.h: Wrap POSIX-specified function redeclarations in
	parens to protect against prior declaration as macros.
A VALUE dummy is associated with a copy of the actual argument (F2023
15.5.2.4).  gfortran passed a derived type with allocatable components
by value, sharing its component data with the actual argument, and gave
a scalar CLASS dummy the actual's own container or, for a
non-polymorphic or intrinsic actual, the address of a container where
the callee expected the container.

Pass a derived type with allocatable components by reference, like an
array or a CHARACTER of non-constant length, because the caller frees
the components of the copy and must see a DEALLOCATE done by the
callee.  This changes the calling convention for such dummies, which
gfc_value_dummy_passed_byref decides for both gfc_sym_type and
gfc_maybe_dereference_var.  Pass a scalar CLASS dummy a container whose
data is copied through the vtable.  Copy only an actual argument that
can share storage with a variable; a function result or a constructor
is already an anonymous object, and the cleanup after the call frees
it.

This patch depends on the PR128478 patch, which adds
conv_class_value_copy.

Assisted-by: Claude Opus 5.5

	PR fortran/51284

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_maybe_dereference_var): Dereference a VALUE
	dummy that gfc_value_dummy_passed_byref passes by reference.
	(value_actual_shares_storage): New function.
	(conv_class_value_arg): New function.
	(conv_dummy_value): Pass a derived type with allocatable components
	by reference to a copy of a variable, or to the temporary.  Pass the
	copy of a PDT by reference when the dummy is.  Pass a null pointer
	for an absent argument to a dummy passed by reference.
	(gfc_conv_procedure_call): Use conv_class_value_arg for a scalar
	CLASS dummy with VALUE, repackaging an element of a class array as a
	class container.  Copy an intrinsic actual argument for a CLASS(*)
	dummy with VALUE.
	* trans-types.cc (gfc_value_dummy_passed_byref): New function.
	(gfc_sym_type): Use it.
	* trans-types.h (gfc_value_dummy_passed_byref): Declare.

gcc/testsuite/ChangeLog:

	* gfortran.dg/asan/value_dummy_copy_1.f90: New test.
	* gfortran.dg/value_19.f90: New test.
	* gfortran.dg/value_21.f90: New test.
	* gfortran.dg/value_22.f90: New test.
Modify the mov<mode>cc expander to support conditional floating-point move
based on integer comparison results. The testcase:

double foo (double a, double b, int c) { return c > 0 ? a : b; }

compiles (-O2) to:

foo:
	addi.d  $r3,$r3,-16
        slti    $r12,$r4,1
        st.d    $r12,$r3,8
        ld.b    $r12,$r3,8
        movgr2fr.w      $f2,$r12
        movfr2cf        $fcc0,$f2
        fsel    $f0,$f0,$f1,$fcc0
        addi.d  $r3,$r3,16
        jr      $r1

Setting the cost of moving GR_REGS to FCC_REGS as the true cost can avoid
unnecessary spill code:

	slti    $r4,$r4,1
	movgr2fr.w      $f2,$r4
	movfr2cf        $fcc0,$f2
	fsel    $f0,$f0,$f1,$fcc0
	jr      $r1

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_expand_conditional_move):
	Allow conditional move FP via integer condition codes.
	(loongarch_move_to_gpr_cost): Use actual FCC->GPR move cost.
	(loongarch_move_from_gpr_cost): Use actual GPR->FCC move cost.
	(loongarch_secondary_reload): Adjust.
	* config/loongarch/loongarch.md (mov<mode>cc): Adjust.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/la64/ifcvt-double-1.c: New test.
	* gcc.target/loongarch/la64/ifcvt-double-2.c: New test.
If there is no cost information from the backend, the middle end
estimates the cost of if_then_else, which has three operands, as
3 instructions (i.e. 12 units). Define its cost as a single machine
cycle, ignoring the cost of actually taking the branch, to enable
more if-conversion optimizations.

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_rtx_costs):
	<IF_THEN_ELSE>: New case.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/ifcvt-1.c: New test.
The PR118935 fix accesses the 64-bit file_dev and file_ino fields of
gfc_unit with __atomic builtins whenever HAVE_ATOMIC_FETCH_ADD is
defined, but that configure check tests only an int.  On 32-bit
targets without inline 64-bit atomics the accesses become calls into
libatomic, which libgfortran does not link.  r17-6152 made the check
test a 64-bit type instead, but on those targets that also turns off
the atomics for the unit waiting count and stream pointer, and the
waiting count is then incremented under a read lock without them.
Revert r17-6152 and use atomic accesses for the file id only where
64-bit atomics are lock-free.

Assisted-by: Claude Opus 5.5

	PR libfortran/128618

libgfortran/ChangeLog:

	* acinclude.m4 (LIBGFOR_CHECK_ATOMIC_FETCH_ADD): Revert
	r17-6152; test int again.  Note that 64-bit atomics are not
	covered.
	* configure: Regenerate.
	* io/io.h (GFC_ATOMIC_FILE_ID): Define if 64-bit atomics are
	lock-free.
	(set_unit_file_id, unit_file_id_matches): Use it instead of
	HAVE_ATOMIC_FETCH_ADD.
Support the sdot_prod optab for BF16 and FP16 inputs with a float
accumulator through the existing AVX512BF16 vdpbf16ps and AVX10.2
vdpphps insns, so the vectorizer can use them for floating point dot
products.

vdpbf16ps treats denormal inputs as zero and flushes denormal results,
so its expander requires flag_unsafe_math_optimizations.

gcc/ChangeLog:

	* config/i386/sse.md (ssePSmode, ssePSmodelower): Add BF modes.
	(sdot_prod<ssePSmodelower><mode>): New expanders.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx10_2-fp16-dotprod-1.c: New test.
	* gcc.target/i386/avx10_2-fp16-dotprod-2.c: Ditto.
	* gcc.target/i386/avx10_2-fp16-dotprod-3.c: Ditto.
	* gcc.target/i386/avx10_2-fp16-dotprod-4.c: Ditto.
	* gcc.target/i386/avx512bf16-dotprod-1.c: Ditto.
	* gcc.target/i386/avx512bf16-dotprod-2.c: Ditto.
	* gcc.target/i386/avx512bf16-dotprod-3.c: Ditto.
	* gcc.target/i386/avx512bf16-dotprod-4.c: Ditto.
	* gcc.target/i386/avx512bf16-dotprod-5.c: Ditto.
…28911]

The @ccmp<mode> leaf compared (minus a b) against zero, which only matches
the flags of cmp a, b for EQ/NE, so simplify-rtx could fold ordered and
unsigned conditions wrongly. Also the condition was hard-coded on
(reg:CC FLAGS_REG), losing the CC mode of the previous compare and the
scc output was incorrect. Compare operands 2 and 3 directly and make the
flags register an operand to inhert previous CCmode.

gcc/ChangeLog:

	PR target/128911
	* config/i386/i386.md (@ccmp<mode>): Compare operands 2 and 3
	directly.  Use operand 5 for the flags register in operand 1.
	* config/i386/i386-expand.cc (ix86_gen_ccmp_next): Keep the CC
	mode of the previous compare and pass it as operand 5.

gcc/testsuite/ChangeLog:

	PR target/128911
	* gcc.target/i386/pr128911-1.c: New test.
	* gcc.target/i386/pr128911-2.c: Likewise.
	* gcc.target/i386/pr128911-3.c: Likewise.
P-E-P and others added 26 commits November 26, 2026 18:39
ChangeLog:

	* .github/ISSUE_TEMPLATE/bug_report.yml: New file.
	* .github/ISSUE_TEMPLATE/bug_report.md: Deleted old template.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
ChangeLog:

	* README.md: Add fedora deps.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@iki.fi>
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Co-authored-by: Sam James <sam@gentoo.org>
Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
Co-authored-by: Philip Herron <herron.philip@googlemail.com>
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
This new workflow is used to send emails to the gcc-patches@ mailing list
after every merged PR.

For each merged PR:
- remove commits touching files not to-be-upstreamed (e.g. github
workflow, README.md, ...)
- send a mail series

Each mail contains explanation + links to commits/PR on the github
project.

Authors of commits will be put in Cc: of emails.

Configure it by setting the following secrets in github:
- SMTP_PASSWORD
And the following variables:
- PATCH_TO: the "To:" field for the emails
- PATCH_CC: optional "Cc:"
- SMTP_FROM, SMTP_PASSWORD, SMTP_PORT, SMTP_SERVER, STMP_USERNAME: self explanatory

ChangeLog:

        * .github/workflows/send-emails.yml: New file.

Co-authored-by: Andrew V. Teylu <andrew.teylu@vector.com>
Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Since f1982cc, we are using
clang-format-16 instead of clang-format-10. This commit updates the
clang-format version documented in CONTRIBUTING.md so that new
contributors don't get tripped.

ChangeLog:

	* CONTRIBUTING.md: Update clang-format version

Signed-off-by: Ryo Yoshida <low.ryoshida@gmail.com>
ChangeLog:

	* .github/workflows/commit-format.yml: adjust grep.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Use dtolnay/rust-toolchain action to install rustc toolchain.
Use a composite action for the various build/check on ubuntu.

More cleanup possible (the 32/64bits builds could be simplified and only
build 1 compiler and split the checks)

ChangeLog:

	* .github/workflows/ccpp.yml: Refactor.
	* .github/actions/build-gcc/action.yml: New file.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
ChangeLog:

	* README.md: Add Fedora WSL deps.

Signed-off-by: Osama Albahrani <osalbahr@gmail.com>
We've had at least one case of mails not being sent because the commit
log was so big that the $GH_EVENT var couldn't be expanded by the shell.
Using envsubst avoids having the shell do the expansion.

ChangeLog:
	* .github/workflows/send-emails.yml: use envsubst.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Look for Rust-GCC/gccrs#XXXXXX issue references (and only that) and
expand them as github URLs in the email body.

See #4529

ChangeLog:
	* .github/workflows/send-emails.yml: Expand github's issues
	references in sent emails.
grep returned an error when there was no reference, causing the workflow
to stop.

ChangeLog:
        .github/workflows/send-emails.yml: fix issue ref scrapping.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
github allows contribution without disclosing author's email. It uses a
"@noreply DOT github DOT com" in the commit log, which is not OK for
upstream contribution.

Refs: #4568

ChangeLog:
	* .github/workflows/commit-format.yml (check-valid-email): New
	job to reject bad emails.
A full reference to a github issue is: Rust-GCC/gccrs#XXX
This will help with the email script that scraps refs.

ChangeLog/
	* .github/workflows/commit-format.yml: Adjust regex for matching
	github ref.
ChangeLog:

	* .github/workflows/send-emails.yml: Check if we have a
	configured SMTP server before running send_patches.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
ChangeLog:

	* .github/workflows/ccpp32alpine.yml: Add `linux-headers` to package list.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
If the Rust version we're targeting is equal or higher than 1.82, then allow &raw {const,mut}
syntax without feature gating it.

gcc/rust/ChangeLog:

	* checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit): Don't gate the feature if
	we are in compatibility mode higher or equal to 1.82.

gcc/testsuite/ChangeLog:

	* rust/compile/raw-borrow-compat-mode.rs: New test.
A trait can declare and associated type and a method with the same
identifier, since they live in different namespaces. Several lookups
matched trait items by name alone and picked whichever came first, which
caused an ICE in resolve_method_address.

Filter impl probe candidates to functions before falling back to the
trait's default methods, and makeup lookup_hir_trait_item and the
TraitItemReference overload of lookup_associated_item match on the item
itself instead of it's name.

Fixes #4986

gcc/rust/ChangeLog:
	* backend/rust-compile-base.cc
	(HirCompileBase::resolve_method_address): Filter probe candidate
	first before checking for an empty set.
	* typecheck/rust-hir-trait-reference.cc
	(TraitReference::lookup_hir_trait_item): Match on HirId instead
	of identifier.
	* typecheck/rust-tyty-bounds.cc
	(TypeBoundPredicate::lookup_associated_item): Match by identity.

gcc/testsuite/ChangeLog:
	* rust/compile/method-assoc-type-same-name.rs: New test.
	* rust/execute/torture/issue-4986.rs: New test.

Signed-off-by: Wesley Lewis <lewis.wes.23@gmail.com>
* This patch improves the as_string API for the PathProbe with detailed
log about the Candidate. The log resolves the candidate type with
available APIs, and resolves the type string from the ty class as_string
and builds the stringstream to return.

Fixes #5078

gcc/rust/ChangeLog:

	* typecheck/rust-hir-path-probe.cc: (PathProbeCandidate::as_string): Implement.

Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
This error is triggering on valid code from `core 1.49`, so turn it into a warning for now
and add extra info for when the fix happens.

gcc/rust/ChangeLog:

	* typecheck/rust-hir-trait-reference.cc (TraitReference::is_object_safe): Turn the error
	into a warning.

gcc/testsuite/ChangeLog:

	* rust/compile/traits10.rs: Change error into a warning.
	* rust/compile/traits11.rs: Likewise.
	* rust/compile/invalid-non-object-safe-warning.rs: New test.
	* rust/core/core-1.49.expected: Regenerate
The guard only popped the resolver for functions, so every impl block
resolved on demand left its lifetime resolver on the stack and later
lookups hit the wrong one. This is the unresolved lifetime core runs
into in str/pattern.rs.

Fixes #4980

Assisted-by: Claude Opus (Anthropic)

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check.h
	(TypeCheckContext::LifetimeResolverGuard::~LifetimeResolverGuard):
	Also pop impl block resolvers.

gcc/testsuite/ChangeLog:

	* rust/compile/issues/issue-4980.rs: New test.

Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
In a const fn, a continue inside loop, or a labeled break or continue,
was either rejected as a goto or ran into the loop iteration limit.
Treat loop labels as compiler labels even when the loop is named, put
the continue label of loop at the start of its body like for while,
and let a loop pass on jumps to labels outside of it.

Fixes #5014

Assisted-by: Claude Opus 5.5 (Anthropic)

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit (LoopExpr)): Put
	the continue label at the start of the loop body.
	(CompileExpr::construct_loop_labels): Mark the labels artificial.
	* backend/rust-constexpr.cc (find_label_expr_r): New function.
	(eval_loop_expr): Leave the loop on a jump to a label outside of it.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/const-fn-loop-jumps.rs: New test.

Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
A `where Self: Bound` on a trait method was added to the trait's shared
Self, so every method of the trait then required it. That is why none
of Iterator's default methods resolve once `rev` is around. Put the
bound on the item's own Self substitution instead.

Fixes #4917

Assisted-by: Claude Opus (Anthropic)

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-type.h (ResolveWhereClauseItem): Take
	the trait item's own Self.
	* typecheck/rust-hir-type-check-type.cc
	(ResolveWhereClauseItem::Resolve): Pass it along.
	(ResolveWhereClauseItem::visit (TypeBoundWhereClauseItem)): Apply
	bounds on the implicit Self to it.
	* typecheck/rust-hir-type-check.cc
	(TraitItemReference::get_type_from_fn): Hand the item's Self to the
	where clause resolver.

gcc/testsuite/ChangeLog:

	* rust/compile/issues/issue-4917.rs: New test.
	* rust/compile/issues/issue-4917-2.rs: New test.
	* rust/compile/issues/issue-4917-3.rs: New test.

Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
Currently gccrs didn't evaluate const expressions in the discriminant
when the enum is declared. It was evaluated when the enum was used in
a program. These changes evaluate const expressions for discriminant
of an enum. Also provided caching, so that during the evaluation during constructor
expression lookup we use the cached value.

Fixes #4966

Assisted by: Claude

gcc/rust/ChangeLog:
	* backend/rust-compile-base.h
	(HIRCompileBase::compile_enum_discriminant): Declaration.
	* backend/rust-compile-base.cc
	(HIRCompileBase::compile_enum_discriminant): Implementation.
	* backend/rust-compile-item.cc
	(CompileItem::visit (HIR::Enum &enum_decl)): Call compile_enum_discriminant.
	* backend/rust-compile-resolve-path.cc
	(ResolvePathRef::attempt_constructor_expression_lookup): Likewise.

gcc/testsuite/ChangeLog:
	* rust/compile/enum_discriminant4.rs: Added test.

Signed-off-by: Wesley Lewis <lewis.wes.23@gmail.com>
A let with a wildcard, tuple or struct pattern in a const fn used a
temporary that isn't in any block, so const eval lost track of it and
silently left the constant uninitialized.  Declare it in the enclosing
block instead.

Fixes #5009

Assisted-by: Claude Opus 5.5 (Anthropic)

gcc/rust/ChangeLog:

	* rust-backend.h (temporary_variable): Say that a bind_tree scopes
	the variable.
	* rust-gcc.cc (temporary_variable): Declare the variable in
	bind_tree whenever one is given.
	(array_initializer): Keep the array temporary function-wide, it is
	read after the block.
	* backend/rust-compile-pattern.cc
	(CompilePatternLet::visit (WildcardPattern)): Pass the enclosing
	scope.
	(CompilePatternLet::visit (TuplePattern)): Likewise.
	(CompilePatternLet::visit (StructPattern)): Likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/const-fn-let-pattern.rs: New test.

Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
…se/2026-11-26

This branch has a no-op merge as the last commit:
 - one arm is the "current" development branch from github
 - the other arm is a rebased version of the "current" master branch onto a recent GCC's master

The merge is obtained with "git merge --strategy=ours" to only keep the changes from second arm.
@dkm

dkm commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

                === rust Summary ===

# of expected passes            12253
# of expected failures          85
# of unsupported tests          10
 ../contrib/dg-cmp-results.sh  -v -v unix gcc/testsuite/rust/rust.sum /home/barryallen/dkm/git/gccrs-master/build/gcc/testsuite/rust/rust.sum
dg-cmp-results.sh: Verbosity is 2, Variant is "unix"

Older log file: gcc/testsuite/rust/rust.sum
Test run by dkm on Thu Nov 26 19:50:25 2026
Native configuration is x86_64-pc-linux-gnu

Newer log file: /home/barryallen/dkm/git/gccrs-master/build/gcc/testsuite/rust/rust.sum
Test run by dkm on Thu Nov 26 18:52:53 2026
Native configuration is x86_64-pc-linux-gnu

But gcc-5 fails because of gmp/mpfr missing ?!

@dkm

dkm commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

build ongoing, no issue with gmp/mpfr this time...

@dkm
dkm merged commit 7627d86 into master Nov 26, 2026
14 of 18 checks passed
@dkm
dkm deleted the gerris/rebase/2026-11-26 branch November 26, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.