]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 days agoFix unsafe stmt modifications in FOR_EACH_IMM_USE_STMT
Richard Biener [Mon, 3 Nov 2025 12:59:36 +0000 (13:59 +0100)] 
Fix unsafe stmt modifications in FOR_EACH_IMM_USE_STMT

The following fixes path isolation changing the immediate use list of
an SSA name that is currently iterated over via FOR_EACH_IMM_USE_STMT.
This happens when it duplicates a BB within this and creates/modifies
stmts that contain SSA uses of the name and calls update_stmt which
re-builds SSA operands, including removal of SSA uses and re-inserting
them.  This is not safe as that might cause missed iterated uses but
more importantly could cause the 'next' use to be removed.

For the case in question the fix is to collect interesting uses in
a vec and do the processing outside of the FOR_EACH_IMM_USE_STMT
iteration.

* gimple-ssa-isolate-paths.cc (check_loadstore): Set
the volatile flag on the stmt manually.
(find_implicit_erroneous_behavior): Move code transform
outside of FOR_EACH_IMM_USE_STMT iteration.

2 days agoAdd debug function for affine_iv
Richard Biener [Tue, 4 Nov 2025 14:48:04 +0000 (15:48 +0100)] 
Add debug function for affine_iv

* tree-ssa-loop-niter.cc (dump_affine_iv): Use file, not
dump_file when printing.
(debug): New overload for affine_iv.

2 days agoLoongArch: testsuite: Adapt widen-mul-rtx-cost-signed.c for r16-4949
Guo Jie [Tue, 4 Nov 2025 12:40:47 +0000 (20:40 +0800)] 
LoongArch: testsuite: Adapt widen-mul-rtx-cost-signed.c for r16-4949

Commit r16-4949 optimize mulw.d.w + srli.d to mulh.w,
so remove the check rule for mulw.d.w.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/widen-mul-rtx-cost-signed.c: Update.

2 days agoLoongArch: Avoid unnecessary zero-initialization using LSX for scalar popcount
Xi Ruoyao [Sat, 22 Feb 2025 07:34:54 +0000 (15:34 +0800)] 
LoongArch: Avoid unnecessary zero-initialization using LSX for scalar popcount

Now for __builtin_popcountl we are getting things like

vrepli.b $vr0,0
vinsgr2vr.d $vr0,$r4,0
vpcnt.d $vr0,$vr0
vpickve2gr.du $r4,$vr0,0
slli.w $r4,$r4,0
jr  $r1

The "vrepli.b" instruction is introduced by the init-regs pass (see
PR61810 and all the issues it references).  To work it around, we can
use post-reload instead of define_expand: the "f" constraint will make
the compiler automatically move the scalar between GPR and FPR, and
reload is much later than init-regs so init-regs won't get in our way.

Now the code looks like:

movgr2fr.d $f0,$r4
vpcnt.d $vr0,$vr0
movfr2gr.d $r4,$f0
jr  $r1

gcc/ChangeLog:

* config/loongarch/loongarch.md (cntmap): Change to uppercase.
(popcount<GPR:mode>2): Modify to a post reload split.

2 days agoDaily bump.
GCC Administrator [Wed, 5 Nov 2025 00:19:42 +0000 (00:19 +0000)] 
Daily bump.

2 days agoAda: Fix explicit raise on subtype of lock-free protected type
Eric Botcazou [Tue, 4 Nov 2025 19:05:25 +0000 (20:05 +0100)] 
Ada: Fix explicit raise on subtype of lock-free protected type

The issue is that the Uses_Lock_Free flag is not propagated to the subtype.

gcc/ada/
* sem_ch3.adb (Analyze_Subtype_Declaration) <Concurrent_Kind>:
Propagate the Uses_Lock_Free flag for protected types.

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

2 days agoAda: Fix incorrect legality check in instantiation of child generic unit
Eric Botcazou [Tue, 4 Nov 2025 18:54:45 +0000 (19:54 +0100)] 
Ada: Fix incorrect legality check in instantiation of child generic unit

The problem arises when the generic unit has a formal access type parameter,
because the manual resolution implemented in Find_Actual_Type does not pick
the correct entity for the designated type.  The fix replaces it with a bona
fide resolution and cleans up the associated code in the callers.

gcc/ada/
PR ada/18453
* sem_ch12.adb (Find_Actual_Type): Add Typ_Ref parameter and
perform a standard resolution on it in the fallback case.
Call Get_Instance_Of if the type is declared in a formal of
the child unit.
(Instantiate_Type.Validate_Access_Type_Instance): Adjust call
to Find_Actual_Type.
(Instantiate_Type.Validate_Array_Type_Instance): Likewise and
streamline the check for matching component subtypes.

gcc/testsuite/
* gnat.dg/specs/generic_inst9.ads: New test.
* gnat.dg/specs/generic_inst9_pkg1.ads: New helper.
* gnat.dg/specs/generic_inst9_pkg2.ads: Likewise.
* gnat.dg/specs/generic_inst9_pkg2-g.ads: Likewise.

2 days agoFortran: fix frontend memleak with DO CONCURRENT [PR122564]
Harald Anlauf [Tue, 4 Nov 2025 19:04:55 +0000 (20:04 +0100)] 
Fortran: fix frontend memleak with DO CONCURRENT [PR122564]

PR fortran/122564

gcc/fortran/ChangeLog:

* resolve.cc (resolve_locality_spec): Delete temporary hash_set.

2 days agoFix typos in comment
Alejandro Colomar [Sun, 2 Nov 2025 18:45:33 +0000 (19:45 +0100)] 
Fix typos in comment

gcc/c-family/ChangeLog:

* c-warn.cc (warn_parms_array_mismatch): Fix typos in comment.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 days agogcc/: Rename warn_parm_array_mismatch() => warn_parms_array_mismatch()
Alejandro Colomar [Sun, 2 Nov 2025 18:45:29 +0000 (19:45 +0100)] 
gcc/: Rename warn_parm_array_mismatch() => warn_parms_array_mismatch()

This function acts on entire parameter declaration lists, and iterates
over them.  Use plural in the name, to clarify that it acts on
parameters, not just on a single parameter.

gcc/c-family/ChangeLog:

* c-common.h (warn_parm_array_mismatch):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.
* c-warn.cc (warn_parm_array_mismatch):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.

gcc/c/ChangeLog:

* c-decl.cc (start_function):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.
* c-parser.cc (c_parser_declaration_or_fndef):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
3 days agoi386: TEST insn should be merged with ADC/SBB insn [PR122390]
Uros Bizjak [Tue, 4 Nov 2025 09:18:03 +0000 (10:18 +0100)] 
i386: TEST insn should be merged with ADC/SBB insn [PR122390]

The attached testcase is currently compiled to:

f1:
        cmpl    %esi, %edi
        adcl    %esi, %edi
        testl   %edi, %edi
        js      .L4
...

TEST insn should be merged with ADC/SBB insn.  The patch provides missing
combined insn patterns.

PR target/122390

gcc/ChangeLog:

* config/i386/i386.md (*add<mode>3_carry_2): New insn pattern.
(*add<mode>3_carry_0_cc): Ditto.
(*add<mode>3_carry_0r_cc): Ditto.
(*sub<mode>3_carry_2): Ditto.
(*sub<mode>3_carry_0_cc): Ditto.
(*sub<mode>3_carry_0r_cc): Ditt.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr122390.c: New test.
* gcc.target/i386/pr122390-1.c: New test.

3 days agoarc: Add const attribute support for mathematical ARC builtins
Kees Cook [Tue, 26 Aug 2025 04:09:41 +0000 (21:09 -0700)] 
arc: Add const attribute support for mathematical ARC builtins

The ARC builtin functions __builtin_arc_ffs and __builtin_arc_fls
perform pure mathematical operations equivalent to the standard
GCC __builtin_ffs function, which is marked with the const attribute.
However, the ARC target-specific versions were not marked as const,
preventing compiler optimizations like common subexpression elimination.

Extend the ARC builtin infrastructure to support function attributes
and mark the appropriate mathematical builtins as const:

- __builtin_arc_ffs: Find first set bit (const)
- __builtin_arc_fls: Find last set bit (const)
- __builtin_arc_norm: Count leading zeros (const)
- __builtin_arc_normw: Count leading zeros for 16-bit (const)
- __builtin_arc_swap: Endian swap (const)

gcc/ChangeLog:

* config/arc/builtins.def: Add ATTRS parameter to DEF_BUILTIN
macro calls.  Mark mathematical builtins (FFS, FLS, NORM, NORMW,
SWAP) with attr_const, leave others as NULL_TREE.
* config/arc/arc.cc: Add support for builtin function attributes.
Create attr_const using tree_cons.  Update DEF_BUILTIN macro to
pass ATTRS parameter to add_builtin_function.

gcc/testsuite/ChangeLog:

* gcc.target/arc/builtin_fls_const.c: New test.  Verify that
const attribute enables CSE optimization for mathematical ARC
builtins by checking that duplicate calls are eliminated and
results are optimized to shift operations.

Signed-off-by: Kees Cook <kees@kernel.org>
3 days agoOpenMP/Fortran: Revamp handling of labels in metadirectives [PR122369,PR122508]
Paul-Antoine Arras [Tue, 28 Oct 2025 16:27:47 +0000 (17:27 +0100)] 
OpenMP/Fortran: Revamp handling of labels in metadirectives [PR122369,PR122508]

When a label is matched in the first statement after the end of a metadirective
body, it is bound to the associated region. However this prevents it from being
referenced elsewhere.
This patch fixes it by rebinding such labels to the outer region. It also
ensures that labels defined in an outer region can be referenced in a
metadirective body.

PR fortran/122369
PR fortran/122508

gcc/fortran/ChangeLog:
* gfortran.h (gfc_rebind_label): Declare new function.
* parse.cc (parse_omp_metadirective_body): Rebind labels to the outer
region. Maintain a vector of metadirective regions.
(gfc_parse_file): Initialise it.
* parse.h (GFC_PARSE_H): Declare it.
* symbol.cc (gfc_get_st_label): Look for existing labels in outer
metadirective regions.
(gfc_rebind_label): Define new function.
(gfc_define_st_label): Accept duplicate labels in metadirective body.
(gfc_reference_st_label): Accept shared DO termination labels in
metadirective body.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr122369-1.f90: New test.
* gfortran.dg/gomp/pr122369-2.f90: New test.
* gfortran.dg/gomp/pr122369-3.f90: New test.
* gfortran.dg/gomp/pr122369-4.f90: New test.
* gfortran.dg/gomp/pr122508-1.f90: New test.
* gfortran.dg/gomp/pr122508-2.f90: New test.

3 days agoMatch: Refactor min based unsigned SAT_MUL pattern by widen mul helper [NFC]
Pan Li [Mon, 3 Nov 2025 11:27:24 +0000 (19:27 +0800)] 
Match: Refactor min based unsigned SAT_MUL pattern by widen mul helper [NFC]

There are 3 kinds of widen_mul during the unsigned SAT_MUL pattern, aka
* widen_mul directly, like _3 w* _4
* convert and the widen_mul, like (uint64_t)_3 *w (uint64_t)_4
* convert and then mul, like (uint64_t)_3 * (uint64_t)_4

All of them will be referenced during different forms of unsigned
SAT_MUL pattern match, but actually we can wrap them into a helper
which present the "widening_mul" sematics.  With this helper, some
unnecessary pattern and duplicated code could be eliminated.

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

gcc/ChangeLog:

* match.pd: Add usmul_widen_mult helper and referenced by
min based unsigned SAT_MUL pattern.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 days agolto/122515: Fix archive offset types for i686
Siddhesh Poyarekar [Mon, 3 Nov 2025 23:02:00 +0000 (17:02 -0600)] 
lto/122515: Fix archive offset types for i686

On i686, offsets into object archives could be 64-bit, but they're
inconsistently treated across the lto, which may sometimes result in
truncation of those offsets for large archives.

Use int64_t/off_t consistently across all uses of archive offsets to
make sure that they're always read and mapped correctly.

gcc/lto/ChangeLog

PR lto/122515
* lto.h (lto_section_slot): Set type of START to off_t.
* lto-common.cc (lto_read_section_data): Adjust.
* lto-object.cc (lto_obj_file_open): Set type of OFFSET to
int64_t.

gcc/ChangeLog

PR lto/122515
* lto-wrapper.cc (debug_objcopy): Set type of INOFF to int64_t.
(run_gcc): Set type of FILE_OFFSET to int64_t.

gcc/testsuite/ChangeLog

PR lto/122515
* lib/lto.exp (lto-build-archive): New procedure.
(lto-execute-1): Use it.
(lto-link-and-maybe-run, lto-get-options-main): Handle ar-link.
* gcc.dg/lto/pr122515_0.c: New test case.
* gcc.dg/lto/pr122515_1.c: New file.
* gcc.dg/lto/pr122515_2.c: Likewise.
* gcc.dg/lto/pr122515_3.c: Likewise.
* gcc.dg/lto/pr122515_4.c: Likewise.
* gcc.dg/lto/pr122515_5.c: Likewise.
* gcc.dg/lto/pr122515_6.c: Likewise.
* gcc.dg/lto/pr122515_7.c: Likewise.
* gcc.dg/lto/pr122515_8.c: Likewise.
* gcc.dg/lto/pr122515_9.c: Likewise.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
3 days agoc++: Don't constrain template visibility using no-linkage variables [PR122253]
Nathaniel Shead [Thu, 16 Oct 2025 11:51:23 +0000 (22:51 +1100)] 
c++: Don't constrain template visibility using no-linkage variables [PR122253]

When finding the minimal visibility of a template, any reference to a
dependent automatic variable will cause the instantiation to be marked
as internal linkage.  However, when processing the template decl we
don't yet know whether that should actually be the case, as a given
instantiation may not require referencing the local decl in its
mangling.

This patch fixes the issue by checking for no-linkage decls first, in
which case we just constrain using the type of the entity.  We can't use
a check for lk_external/lk_internal in the other cases, as
instantiations referring to internal types can still have external
linkage as determined by the language, but should still constrain the
visibility of any declarations that refer to them.

PR c++/122253

gcc/cp/ChangeLog:

* decl2.cc (min_vis_expr_r): Don't mark no-linkage declarations
as VISIBILITY_ANON.

gcc/testsuite/ChangeLog:

* g++.dg/modules/internal-16.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 days agogfortran.dg/pr122513-2.f90: New test [PR122513]
Tobias Burnus [Tue, 4 Nov 2025 09:23:31 +0000 (10:23 +0100)] 
gfortran.dg/pr122513-2.f90: New test [PR122513]

This test is from PR122513; even though the actual error message was
already added in GCC 15, there was no testcase for the diagnostic type
  Index variable 'i' at (1) cannot be specified in a locality-spec

Thus, this commit adds one.

gcc/testsuite/ChangeLog:

PR fortran/122513
* gfortran.dg/pr122513-2.f90: New test.

3 days agosimplify-rtx: Canonicalize SUBREG and LSHIFTRT order for AND operations
Kishan Parmar [Tue, 4 Nov 2025 07:11:28 +0000 (12:41 +0530)] 
simplify-rtx: Canonicalize SUBREG and LSHIFTRT order for AND operations

For a given rtx expression (and (lshiftrt (subreg X) shift) mask)
combine pass tries to simplify the RTL form to

   (and (subreg (lshiftrt X shift)) mask)

where the SUBREG wraps the result of the shift.  This leaves the AND
and the shift in different modes, which complicates recognition.

   (and (lshiftrt (subreg X) shift) mask)

where the SUBREG is inside the shift and both operations share the same
mode.  This form is easier to recognize across targets and enables
cleaner pattern matching.

This patch checks in simplify-rtx to perform this transformation when
safe: the SUBREG must be a lowpart, the shift amount must be valid, and
the precision of the operation must be preserved.

Tested on powerpc64le-linux-gnu, powerpc64-linux-gnu, and
x86_64-pc-linux-gnu with no regressions.  On rs6000, the change reduces
insn counts due to improved matching.

2025-11-04  Kishan Parmar  <kishan@linux.ibm.com>

gcc/ChangeLog:

PR rtl-optimization/93738
* simplify-rtx.cc (simplify_binary_operation_1): Canonicalize
SUBREG(LSHIFTRT) into LSHIFTRT(SUBREG) when valid.

gcc/testsuite/ChangeLog:

PR rtl-optimization/93738
* gcc.target/powerpc/rlwimi-2.c: Update expected rldicl count.

3 days agoanalyzer: add event kinds for special control flow [PR122544]
David Malcolm [Tue, 4 Nov 2025 02:42:59 +0000 (21:42 -0500)] 
analyzer: add event kinds for special control flow [PR122544]

The SARIF 3.38.8 "kinds" property has some verbs for expressing
control flow, but is missing some of the awkward special cases.

The spec says "If none of these values are appropriate, a SARIF
producer MAY use any value."

This patch adds the following new values:

* "throw" for throwing an exception
* "catch" for catching an exception
* "unwind" for unwinding stack frame(s) during exception-handling
* "setjmp" for calls to setjmp
* "longjmp" for calls to longjmp that rewind the program counter/stack
to the location of a previous setjmp call

gcc/analyzer/ChangeLog:
PR analyzer/122544
* checker-event.cc (catch_cfg_edge_event::get_meaning): New.
(setjmp_event::get_meaning): New.
(rewind_event::get_meaning): New.
(throw_event::get_meaning): New.
(unwind_event::get_meaning): New.
* checker-event.h (catch_cfg_edge_event::get_meaning): New decl.
(setjmp_event::get_meaning): New decl.
(rewind_event::get_meaning): New decl.
(throw_event::get_meaning): New decl.
(unwind_event::get_meaning): New decl.

gcc/ChangeLog:
PR analyzer/122544
* diagnostics/paths.cc (event::meaning::maybe_get_verb_str):
Handle the new verbs.
* diagnostics/paths.h (event::meaning::verb): Add new values
for special control flow operations.
(event::meaning::meaning): Add ctor taking just a verb.

gcc/testsuite/ChangeLog:
PR analyzer/122544
* g++.dg/analyzer/exception-path-1-sarif.py: New test script.
* g++.dg/analyzer/exception-path-1.C: Add SARIF output, and use
the above to check it.
* g++.dg/analyzer/exception-path-unwind-multiple-2-sarif.py: New
test script.
* g++.dg/analyzer/exception-path-unwind-multiple-2.C: Add SARIF
output, and use the above to check it.
* gcc.dg/analyzer/setjmp-3-sarif.py: New test script.
* gcc.dg/analyzer/setjmp-3.c: Add SARIF output, and use
the above to check it.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 days agocp: fix typo "an decrement" -> "a decrement"
David Malcolm [Tue, 4 Nov 2025 02:42:58 +0000 (21:42 -0500)] 
cp: fix typo "an decrement" -> "a decrement"

gcc/cp/ChangeLog:
* parser.cc (enum non_integral_constant): Fix typo
"an decrement" -> "a decrement" in comment.
(cp_parser_non_integral_constant_expression): Likewise in error
message.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 days agoDaily bump.
GCC Administrator [Tue, 4 Nov 2025 00:20:26 +0000 (00:20 +0000)] 
Daily bump.

3 days agoAda: Fix segfault for instantiation on function call returning string
Eric Botcazou [Mon, 3 Nov 2025 23:40:39 +0000 (00:40 +0100)] 
Ada: Fix segfault for instantiation on function call returning string

The problem is that a transient scope is created during the analysis of the
actual parameters of the instantiation and this discombobulates the complex
handling of scopes in Sem_Ch12.

gcc/ada/
PR ada/78175
* sem_ch12.adb (Hide_Current_Scope): Deal with a transient scope
as current scope.
(Remove_Parent): Likewise.

gcc/testsuite/
* gnat.dg/generic_inst15.adb: New test.
* gnat.dg/generic_inst15_pkg-g.ads: New helper.
* gnat.dg/generic_inst15_pkg.ads: Likewise.

3 days agoAda: Fix misleading diagnostic about abstract new in type derivation
Eric Botcazou [Mon, 3 Nov 2025 23:10:55 +0000 (00:10 +0100)] 
Ada: Fix misleading diagnostic about abstract new in type derivation

The current error message is:

abstract1.ads:7:13: error: "abstract" not allowed here, ignored

but "abstract" is indeed allowed there if you complete the declaration.

The patch changes it to:

abstract1.ads:7:13: error: "abstract" allowed only for record extension, ...

gcc/ada/
PR ada/55324
* par-ch3.adb (P_Type_Declaration): Give a better error message
for illegal "abstract" in a type derivation.

gcc/testsuite/
* gnat.dg/specs/abstract1.ads: New test.

3 days agoi386: Allow memory op in operand 1 predicate of *test<mode>_1 insn patterns [PR122534]
Uros Bizjak [Mon, 3 Nov 2025 19:22:10 +0000 (20:22 +0100)] 
i386: Allow memory op in operand 1 predicate of *test<mode>_1 insn patterns [PR122534]

Combine tries to combine AND RTX with memory operand:

Trying 12 -> 13:
   12: {r106:DI=r99:DI&[r100:DI*0x8+r103:DI];clobber flags:CC;}
      REG_UNUSED flags:CC
   13: flags:CCZ=cmp(r106:DI,0)
      REG_DEAD r106:DI

but fails to match instruction:

(set (reg:CCZ 17 flags)
    (compare:CCZ (and:DI (reg:DI 99 [ shifttmp_6 ])
            (mem:DI (plus:DI (mult:DI (reg/v:DI 100 [ i ])
                        (const_int 8 [0x8]))
                    (reg/v/f:DI 103 [ p ])) [1 MEM[(long unsigned int *)p_8(D) + i_14 * 8]+0 S8 A64]))
        (const_int 0 [0])))

because corresponding *test<mode>_1 pattern doesn't allow memory operand 1.

Allow memory operand 1 by matching operand predicates of *test<mode>_1 family
of insns with corresponding *and<mode>_2 insn patterns.

The testcase improves from:

movl %esi, %ecx
movl $1, %eax
salq %cl, %rax
movq %rax, %rcx
xorl %eax, %eax
.L4:
movq %rcx, %rdx
andq (%rdi,%rax,8), %rdx
jne .L1
...

to:
movl $1, %edx
movl %esi, %ecx
xorl %eax, %eax
salq %cl, %rdx
.L4:
testq %rdx, (%rdi,%rax,8)
jne .L1
...

Also improve pentium pairing in *testqi_1_maybe_si insn pattern.

PR target/122534

gcc/ChangeLog:

* config/i386/i386.md (@test<mode>_ccno_1):
Use <general_szext_operand> as operand 1 predicate.
(testqi_ccz_1): Use general_operand as operand 1 predicate.
(*testdi_1): Use x86_64_szext_general_operand as operand 1 predicate.
(*testqi_1_maybe_si): Use general_operand as operand 1 predicate.
Add (n,*a) alternative to allow UV pairing for pentium processor.
(*test<mode>_1): Use <general_operand> as operand 1 predicate.

gcc/testsuite/ChangeLog:

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

3 days agoRISC-V: testsuite: Fix pr119115.c.
Robin Dapp [Mon, 3 Nov 2025 20:36:09 +0000 (13:36 -0700)] 
RISC-V: testsuite: Fix pr119115.c.

pr119115.c is broken (since it was added?) but because we only
attempt to compile/run it on a 256b target I never noticed it.

This patch adds -std=gnu99 to make it compile.

Regtested on rv64gcv_zvl512b.  Going to push after the CI run.

Regards
 Robin

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr119115.c: Add -std=gnu99.

3 days agoFortran: Fix check on locality spec DO CONCURRENT
Steve Kargl [Mon, 3 Nov 2025 19:47:54 +0000 (11:47 -0800)] 
Fortran: Fix check on locality spec DO CONCURRENT

PR fortran/122513

gcc/fortran/ChangeLog:

* resolve.cc (check_default_none_expr): Do not allow an
iterator in a locality spec. Allow a named constant to be
used within the loop.

gcc/testsuite/ChangeLog:

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

3 days agogcc: sync top-level with binutils-gdb
Sam James [Mon, 3 Nov 2025 09:48:00 +0000 (09:48 +0000)] 
gcc: sync top-level with binutils-gdb

This just pulls in Alan's:

commit 87b6078fc212ccba5f043399c6370ee20f6b355a
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Mon Nov 3 10:59:50 2025 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Mon Nov 3 10:59:50 2025 +1030

    tidy m4 plugin config support

    ...

It tidies up the configure test output.

config/ChangeLog:

* clang-plugin.m4: Sync with binutils.
* gcc-plugin.m4: Ditto.

ChangeLog:

* configure: Regenerate.

gcc/ChangeLog:

* configure: Regenerate.

libatomic/ChangeLog:

* configure: Regenerate.

libbacktrace/ChangeLog:

* configure: Regenerate.

libcc1/ChangeLog:

* configure: Regenerate.

libffi/ChangeLog:

* configure: Regenerate.

libgcobol/ChangeLog:

* configure: Regenerate.

libgfortran/ChangeLog:

* configure: Regenerate.

libgm2/ChangeLog:

* configure: Regenerate.

libgomp/ChangeLog:

* configure: Regenerate.

libgrust/ChangeLog:

* configure: Regenerate.

libiberty/ChangeLog:

* configure: Regenerate.

libitm/ChangeLog:

* configure: Regenerate.

libobjc/ChangeLog:

* configure: Regenerate.

libphobos/ChangeLog:

* configure: Regenerate.

libquadmath/ChangeLog:

* configure: Regenerate.

libsanitizer/ChangeLog:

* configure: Regenerate.

libssp/ChangeLog:

* configure: Regenerate.

libstdc++-v3/ChangeLog:

* configure: Regenerate.

libvtv/ChangeLog:

* configure: Regenerate.

lto-plugin/ChangeLog:

* configure: Regenerate.

zlib/ChangeLog:

* configure: Regenerate.

3 days ago[PR rtl-optimization/122536] Fix guard against variable bit extracts in RTL simplifier
Jeff Law [Mon, 3 Nov 2025 19:46:23 +0000 (12:46 -0700)] 
[PR rtl-optimization/122536] Fix guard against variable bit extracts in RTL simplifier

While I haven't been able to reproduce the failure Sam reported, based on the
RTL checking failure point and the code in question it was pretty clear the
code that was supposed to guard against a variable bit extract was just
checking the wrong argument to verify it was a constant integer -- it missed a
level of XEXP object extraction.

I passed this patch along to Sam and he verified it fixes his kernel build.
I've bootstrapped and regression tested on x86_64.  Pushing to the trunk.

Pushing to the trunk.

PR rtl-optimization/122536
gcc/
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Fix
guard against variable bit extracts in recent change.

3 days agoc++: ADL finds all friends (P1787)
Jason Merrill [Sat, 1 Nov 2025 18:56:26 +0000 (21:56 +0300)] 
c++: ADL finds all friends (P1787)

Some libstdc++ tests were failing with import std because ADL didn't find
rethrow_exception, even though it's a friend.  The problem turned out to be
because it's not in the same namespace, and in C++17 ADL only makes hidden
friends visible.  But in C++20 P1787 changed [basic.lookup.argdep]/4.2 to
directly include all friends in the lookup.

Note that my change still excludes class members, even though the standard
doesn't specify that; including implicit object member functions would just
break, and even foreign static/xobj member functions seem like they would be
strange to include.

gcc/cp/ChangeLog:

* name-lookup.cc (name_lookup::adl_class_fns): Include all
namespace-scope friends.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/koenig16.C: New test.

3 days agoc++/modules: import confict with builtin
Jason Merrill [Sun, 2 Nov 2025 06:44:10 +0000 (09:44 +0300)] 
c++/modules: import confict with builtin

27_io/headers/iostream/synopsis.cc was failing with modules because pushdecl
called update_binding for a redeclared import while passing the built-in
clog as "old".  This could also be fixed by discarding the builtin in
e.g. import_module_binding, but this seems straightforward.

gcc/cp/ChangeLog:

* name-lookup.cc (pushdecl): Discard built-in sooner.

gcc/testsuite/ChangeLog:

* g++.dg/modules/builtin-9_a.C: New test.
* g++.dg/modules/builtin-9_b.C: New test.

3 days agolibstdc++: add ADL friends
Jason Merrill [Sat, 1 Nov 2025 13:07:18 +0000 (16:07 +0300)] 
libstdc++: add ADL friends

Since the implementation namespaces __detail and __exception_ptr aren't
exported from std, ADL can't find these functions there.  Adding friend
declarations makes it work.

libstdc++-v3/ChangeLog:

* include/bits/quoted_string.h: Add ADL friends.
* libsupc++/exception_ptr.h: Add ADL friend.

4 days agolibgomp.fortran/omp_target_memset.f90 - Avoid implicit mapping by an uninit size...
Tobias Burnus [Mon, 3 Nov 2025 17:30:07 +0000 (18:30 +0100)] 
libgomp.fortran/omp_target_memset.f90 - Avoid implicit mapping by an uninit size [PR122543]

In OpenMP, pointers are implicitly mapped - which means for Fortran that
their pointer target is also mapped. However, for uninitialized memory,
this means that some random pointee with some random amount of memory is
copied - in the good case, size == 0, but if not, odd things can happen.

Solution: Use 'fptr => null()' before the target mapping or - as done here -
declare the pointer inside the region.

libgomp/ChangeLog:

PR libgomp/122543
* testsuite/libgomp.fortran/omp_target_memset.f90: Move fptr inside
the target to avoid implicit mapping of its uninit pointee.
* testsuite/libgomp.fortran/omp_target_memset-2.f90: Likewise.

4 days agolibstdc++: adjust std module TBB workaround
Jason Merrill [Mon, 3 Nov 2025 15:55:06 +0000 (18:55 +0300)] 
libstdc++: adjust std module TBB workaround

Messing with macros before possibly importing the stdc++.h header unit is
bad form; better to mess with (other) macros afterward.

libstdc++-v3/ChangeLog:

* src/c++23/std.cc.in: Move TBB macro shenanigans after
bits/stdc++.h.

4 days agolibstdc++: remove cassert from stdc++.h
Jason Merrill [Mon, 3 Nov 2025 15:55:06 +0000 (18:55 +0300)] 
libstdc++: remove cassert from stdc++.h

<cassert> isn't suitable for a header unit, because by design it depends on
the user NDEBUG macro.  So let's not include it in <bits/stdc++.h>.

libstdc++-v3/ChangeLog:

* include/precompiled/stdc++.h: Remove <cassert>.
* testsuite/util/exception/safety.h: Add <cassert>.
* testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc:
Don't define _GLIBCXX_NO_ASSERT.

4 days agolibstdc++: add attributes to more ios_base types
Jason Merrill [Mon, 3 Nov 2025 15:55:06 +0000 (18:55 +0300)] 
libstdc++: add attributes to more ios_base types

In r15-3499 I added attributes to _Ios_Openmode to avoid -Wswitch false
positives; let's do the same for the other enums in ios_base.

It also seems to me that with these attributes, the tests don't need to
include the end/max/min cases.

libstdc++-v3/ChangeLog:

* include/bits/ios_base.h: Add attribs to _Ios_Fmtflags,
_Ios_Iostate, _ios_seekdir.
* testsuite/27_io/ios_base/types/fmtflags/case_label.cc: Remove
unneeded cases.
* testsuite/27_io/ios_base/types/iostate/case_label.cc: Likewise.
* testsuite/27_io/ios_base/types/openmode/case_label.cc: Likewise.
* testsuite/27_io/ios_base/types/seekdir/case_label.cc: Likewise.

4 days agoc++: modules, clones, and overload resolution
Jason Merrill [Mon, 3 Nov 2025 14:51:38 +0000 (17:51 +0300)] 
c++: modules, clones, and overload resolution

21_strings/basic_string_view/cons/wchar_t/3.cc was failing with import std
because as in the reduced testcase, the module includes an instantiation of
the template constructor for <const char *, const char *>, and importing the
module was wrongly adding that instantiation to CLASSTYPE_MEMBER_VEC, so it
became part of the overload set independent of its template.
tsubst_function_decl doesn't add to CLASSTYPE_MEMBER_VEC, and importing
should work the same.

gcc/cp/ChangeLog:

* module.cc (trees_in::decl_value): Don't add an instantiation to
CLASSTYPE_MEMBER_VEC.

gcc/testsuite/ChangeLog:

* g++.dg/modules/clone-5_a.C: New test.
* g++.dg/modules/clone-5_b.C: New test.

4 days agoc++: modules and deprecated namespaces
Jason Merrill [Mon, 3 Nov 2025 14:51:38 +0000 (17:51 +0300)] 
c++: modules and deprecated namespaces

20_util/rel_ops.cc was failing because the gcm didn't represent
[[deprecated]] on a namespace.  Are there any other attributes we're
missing?

gcc/cp/ChangeLog:

* module.cc (module_state::write_namespaces): Handle
TREE_DEPRECATED.
(module_state::read_namespaces): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/namespace-15_a.C: New test.
* g++.dg/modules/namespace-15_b.C: New test.

4 days agoFix 'libgomp.c/pr122281.c' for non-USM offloading execution [PR122281]
Thomas Schwinge [Mon, 3 Nov 2025 14:24:28 +0000 (15:24 +0100)] 
Fix 'libgomp.c/pr122281.c' for non-USM offloading execution [PR122281]

... where it currently runs into:

    libgomp: cuCtxSynchronize error: an illegal memory access was encountered

... for nvptx, or similarly for GCN:

    Memory access fault by GPU node-1 (Agent handle: 0x34d77290) on address 0x7fff3c553000. Reason: Page not present or supervisor privilege.

Fix-up for commit r16-4961-ge2cbcd1b27c0da92bdcd96664064d3d0c1d44e6f
"Fix gimple_copy for OpenMP atomic load/store [PR122281, PR105001]".

PR libgomp/122281
libgomp/
* testsuite/libgomp.c/pr122281.c: Fix for non-USM offloading
execution.

4 days agoada: Guard compile-time evaluator against rewritten if-expressions
Piotr Trojanek [Wed, 22 Oct 2025 15:38:04 +0000 (17:38 +0200)] 
ada: Guard compile-time evaluator against rewritten if-expressions

A hopefully temporary fix for if-expression that has been rewritten into an
if-statement, where a object reference has the if-statement as its parent,
but is not part of the condition, then statements or else statements.

gcc/ada/ChangeLog:

* exp_util.adb (Get_Current_Value_Condition): Guard against orphaned
references in rewritten if-expressions.

4 days agoada: Restore alignment check for address clause given with alignment clause
Eric Botcazou [Tue, 21 Oct 2025 21:33:01 +0000 (23:33 +0200)] 
ada: Restore alignment check for address clause given with alignment clause

The alignment check for address clauses had historically been performed
universally by GNAT, until a decade ago when it was disabled by default
on non-strict-alignment platforms.

This seems questionable when an alignment clause is also given for the
entity since the intent is clear, so the change restores it as well as
its associated warning.

Moreover, this alignment check had historically been subsumed into the
language-defined Range_Check, until two decades ago when it became the
implementation-defined Alignment_Check, while still being part of the
Range_Check to ease the transition.  Now is probably a good time to cut
the apron strings and make Alignment_Check standalone.

gcc/ada/ChangeLog:

* doc/gnat_rm/representation_clauses_and_pragmas.rst (Address
Clauses): Adjust description of alignment checks.
* sem_ch13.adb (Address_Clause_Check_Record): Remove now unused
Alignment_Checks_Suppressed component.
(Alignment_Checks_Suppressed): Delete.
(Analyze_Attribute_Definition_Clause) <Attribute_Alignment>: Do not
consider the status of range checks to decide whether to generate an
alignment check.  Always generate it if an alignment clause is also
given for the entity.
<Attribute_Alignment>: Generate an alignment check if an address
clause is also given for the entity.
(Register_Address_Clause_Check): Adjust for above removal.
(Validate_Address_Clauses): Test the Check_Address_Alignment flag
on the clause to decide whether to give the warning.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

4 days agoada: Adjust outdated reference in comment
Eric Botcazou [Tue, 21 Oct 2025 10:24:44 +0000 (12:24 +0200)] 
ada: Adjust outdated reference in comment

The Apply_Alignment_Check procedure no longer exists.

gcc/ada/ChangeLog:

* checks.adb (Apply_Address_Clause_Check): Adjust self-reference in
the opening comment.

4 days agoada: Decouple compile-time evaluation from while loop source locations
Piotr Trojanek [Mon, 20 Oct 2025 10:09:07 +0000 (12:09 +0200)] 
ada: Decouple compile-time evaluation from while loop source locations

The compile-time evaluation relied on source locations to decide whether a
variable reference occurs within a WHILE loop where the evaluation can
assume the loop condition. Now this relies exclusively on the AST structure.

gcc/ada/ChangeLog:

* exp_util.adb (Find_In_Enclosing_Context): Refactor from handling of
IF statements.
(Get_Current_Value_Condition): Reuse IF code for WHILE statements.

4 days agoada: Decouple compile-time evaluation from if_statement source locations
Piotr Trojanek [Fri, 17 Oct 2025 09:25:00 +0000 (11:25 +0200)] 
ada: Decouple compile-time evaluation from if_statement source locations

The compile-time evaluation relied on source locations to decide whether a
variable reference occurs within an IF statement where the evaluation can
assume the IF condition. This was unreliable, especially for rewritten and
internally generated IF statements, whose End_Span is typically left as zero.

This patch makes the evaluation exclusively dependent on the AST structure
itself, while the source location and the span of an if statement is only used
in assertion.

gcc/ada/ChangeLog:

* exp_util.adb (Get_Current_Value_Condition): Rewrite to not rely on
Sloc and End_Span of an if statement.

4 days agoada: Preserve AST structure when copying tree with discrete types
Piotr Trojanek [Fri, 17 Oct 2025 08:47:41 +0000 (10:47 +0200)] 
ada: Preserve AST structure when copying tree with discrete types

When copying AST we created an orphaned copy of a scalar range. This was
confusing the compile-time evaluator, because we couldn't determine location of
a scalar range within an IF statement by looking at its parenthood chain.

gcc/ada/ChangeLog:

* sem_util.adb (Update_Semantic_Fields): Preserve tree structure when
copying scalar range of a discrete type.

4 days agoada: Keep source locations for inlined subprograms from predefined units
Piotr Trojanek [Fri, 17 Oct 2025 08:33:44 +0000 (10:33 +0200)] 
ada: Keep source locations for inlined subprograms from predefined units

Frontend inlining, which is now deprecated and only enabled with switch -gnatN
is used, used to reset source locations for subprograms from predefined units.
This was a workaround to prevent the debugger from visiting internal code in
Ada.Tags, but this problem no longer occurs (even when switch -gnatN is used)
and is no longer needed. This patch removes it, because it confused
compile-time evaluation, which makes use of source locations to recognize code
within IF statements.

gcc/ada/ChangeLog:

* inline.adb (Process_Sloc): Remove.

4 days agoada: Fix box accepted as second association of a generic formal package
Eric Botcazou [Mon, 20 Oct 2025 20:33:34 +0000 (22:33 +0200)] 
ada: Fix box accepted as second association of a generic formal package

The syntax is plain invalid because a box can be accepted as a positional
parameter only in the first place.

gcc/ada/ChangeLog:

PR ada/61127
* sem_ch12.adb (Associations.Match_Positional): Remove the always
false condition that guards the error on a positional box.

4 days agoada: Crash on call to a dispatching op with if_expr and tag-indeterminate calls
Gary Dismukes [Thu, 16 Oct 2025 21:38:38 +0000 (21:38 +0000)] 
ada: Crash on call to a dispatching op with if_expr and tag-indeterminate calls

The compiler can crash with a Storage_Error for a failed precondition
when compiling a call to a dispatching subprogram where an actual for a
controlling formal is given by an if_expression whose dependent expressions
are tag-indeterminate calls.  This problem showed up on a build of Alire
(on the compilation of alire-roots.adb) done during a build_gnat_world
mailserver (as well as having been noticed and reported separately by
another engineering team).

The code in Sem_Disp.Check_Dispatching_Call for checking nondispatching
procedure calls for actuals that are calls to abstract tag-indeterminate
functions did not account for conditional expressions, and attempted to
retrieve the (nonexistent) Expression field from an N_If_Expression node,
failing the precondition for Expression.  It was discovered that none of
the code checking for illegal calls to abstract tag-indeterminate functions
in procedure calls is needed, and the whole related "elsif" part is removed
by this change.  (Note that there is separate checking done separately
within Check_Dispatching_Call that will catch nondispatching calls to
abstract functions.)

gcc/ada/ChangeLog:

* sem_disp.adb (Check_Dispatching_Call): Remove "elsif" that does error
checking for abstract tag-indeterminate calls (seems to be no longer
needed).

4 days agoada: Fix another incorrectly nested procedure
Marc Poulhiès [Fri, 10 Oct 2025 08:52:47 +0000 (10:52 +0200)] 
ada: Fix another incorrectly nested procedure

When unnesting a loop, its body is moved inside a procedure, and inner
entities have their scope adjusted. The current GNAT Tree at this stage
is incoherent wrt scope information, and some nested entities are
incorrectly scoped, possibly leading to a crash of the unnester.

The existing Fixup_Inner_Scopes procedure has been added to adjust the
incoherences after the fact because fixing them earlier has proven to be
more complex than expected. This change adds one more adjustment by this
procedure for TSS (Type Support Subprogram) that may be embedded within
N_Freeze_Entity nodes.

gcc/ada/ChangeLog:

* exp_ch7.adb (Fixup_Inner_Scopes): Adjust to handle N_Freeze_Entity nodes.
* exp_unst.adb (Get_Level): Assert when the function didn't find the
nested level (indicates that inner sub has scope pointing higher in
the stack)

4 days agoada: Tweak Is_Predefined_File_Name
Ronan Desplanques [Thu, 16 Oct 2025 08:07:04 +0000 (10:07 +0200)] 
ada: Tweak Is_Predefined_File_Name

This patch extends the set of names recognized by
Is_Predefined_File_Name so that names that start with "a-" and are longer
than 12 characters are considered predefined.

This is motivated by the need to make gprname work with the in-tree
a-strunb__shared.ads file that uses GNAT syntax extensions but whose name
wasn't considered predefined before this patch.

gcc/ada/ChangeLog:

* fname.adb (Is_Predefined_File_Name): Tweak.

4 days agoada: Get rid of Sy/Sm mixing (Expression)
Bob Duff [Wed, 15 Oct 2025 10:43:32 +0000 (06:43 -0400)] 
ada: Get rid of Sy/Sm mixing (Expression)

We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

The Expression field was both syntactic (in N_Exception_Declaration) and
semantic (in all other node kinds). This patch makes it always
syntactic.

Expression is the last such field, so we remove all code and comments
that allowed for such mixing.

The Expression field in N_Exception_Declaration was never properly
documented; fix that.

No change in overall compiler behavior.

An alternative would be to change the name of this Expression
field to be something else (Exception_Declaration_Expression?),
and keep it as "semantic". That would cause an earthquake in gigi,
because gigi wants to treat exception declarations more-or-less
like normal object declarations, with the Expression field being
the initialization expression. So we don't do that.

gcc/ada/ChangeLog:

* gen_il-gen-gen_nodes.adb (N_Exception_Declaration):
Change Expression from Sm to Sy, to match other Expression fields.
* gen_il-gen.adb (Setter_Needs_Parent):
Expression no longer needs to be a special case.
(Check_For_Syntactic_Field_Mismatch):
Do not exempt Expression from the Sy/Sm mixing rule.
This was the last such case, so remove all the exemption code.
* gen_il-gen.ads: Update comments to match new code.
* sinfo.ads (N_Exception_Declaration):
Document the meaning of the Expression field, because it
doesn't follow from the RM syntax of exception_declaration.
* exp_ch11.adb: Minor comment fixes.

4 days agoada: Reject nonconfirming size clauses on objects of floating-point types
Eric Botcazou [Wed, 15 Oct 2025 14:23:26 +0000 (16:23 +0200)] 
ada: Reject nonconfirming size clauses on objects of floating-point types

The RM 13.1(7/5) subclause contains the following sentences: "If the size
of an object is greater than that of its subtype, the additional bits are
padding bits. For an elementary object, these padding bits are normally
read and updated along with the others."

GNAT implements it only for objects of integer and fixed-point types.
For objects of floating-point types, the padding bits are ignored (and
therefore not initialized) with a warning:

  warning: 32 bits of "F" unused [enabled by default]

Implementing it for objects of floating-point types does not seem worth the
hassle, so rejecting nonconfirming size clauses is probably the cleanest
approach (clauses giving the object a size lower than that of its subtype
are already rejected for objects of floating-point types).

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_Attribute_Definition_Clause)
<Attribute_Size>: Tweak wording of existing error message for the
size of all elementary objects.  Move error handling for aliased
objects into the block for objects and give a similar error for
(nonaliased) floating-point objects.

4 days agoada: Fix spurious check on 'Put_Image for an array of characters
Piotr Trojanek [Tue, 28 Jan 2025 11:23:33 +0000 (12:23 +0100)] 
ada: Fix spurious check on 'Put_Image for an array of characters

gcc/ada/ChangeLog:

* exp_attr.adb (Rewrite_Attribute_Proc_Call)<Attribute_Put_Image>:
Fix call to Analyze.

4 days agoada: Remove workaround for a freezing issue with address of a slice
Piotr Trojanek [Tue, 14 Oct 2025 14:15:46 +0000 (16:15 +0200)] 
ada: Remove workaround for a freezing issue with address of a slice

Rewriting of an address of a slice, e.g. "X (Low .. High)'Address" into an
address of an indexed component, e.g. "X (Low)'Address", was only done as a
workaround for some freezing issue. Apparently this freezing issue is now
solved and the rewriting is causing problems for GNATprove. (This rewriting,
if needed, should be rather done in expansion and not resolution.)

gcc/ada/ChangeLog:

* sem_attr.adb (Resolve_Attribute): Remove rewriting of a slice
address expression.

4 days agoada: Fix Put_Image for Multiway_Trees
Viljar Indus [Tue, 14 Oct 2025 09:02:13 +0000 (12:02 +0300)] 
ada: Fix Put_Image for Multiway_Trees

Put_Image should start printing the tree from the Root instead
of the First_Child.

gcc/ada/ChangeLog:

* libgnat/a-cbmutr.adb (Put_Image): Fix the condition and starting point
for printing the tree.
* libgnat/a-cimutr.adb (Put_Image): Likewise.
* libgnat/a-comutr.adb (Put_Image): Likewise.

4 days agoada: Avoid Ignored ghost code behavior in Codepeer_Mode
Viljar Indus [Fri, 10 Oct 2025 09:47:07 +0000 (12:47 +0300)] 
ada: Avoid Ignored ghost code behavior in Codepeer_Mode

When the frontend is called by it should treat all ghost
code as checked. Avoid removing expansion in ignored ghost code regions
when Codepeer_Mode is active.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Avoid disabling
the expander for ignored ghost regions if Codepeer_Mode is active.
* sem_ch7.adb (Analyze_Package_Body_Helper): Likewise.
* freeze.adb (Freeze_Entity): Avoid triggering special freezing
action for entities within ignored ghost regions in Codepeer_Mode.

4 days agoada: Avoid triggering ghost context errors on prefixed names
Viljar Indus [Tue, 7 Oct 2025 09:59:28 +0000 (12:59 +0300)] 
ada: Avoid triggering ghost context errors on prefixed names

Errors for ghost incompatibilities of qualified names should not
be applied to prefixes but rather only the final selector.

gcc/ada/ChangeLog:

* ghost.adb (Is_Ok_Context): consider ghost prefix to always
be a valid ghost context.

4 days agoada: Direct attribute definition for constructors
Denis Mazzucato [Thu, 25 Sep 2025 09:31:46 +0000 (11:31 +0200)] 
ada: Direct attribute definition for constructors

This patch introduces the 'Constructor attribute and implements its direct
attribute definition syntax within subprogram specification. This new shorthand
avoids having to come up with an arbitrary subprogram name and to type out the
constructor aspect. Before, constructors where defined through the aspect
Constructor, which has been removed.

Furthermore, this patch prepares for the expansion of direct attribute
definitions to other attributes.

gcc/ada/ChangeLog:

* errout.adb (Set_Msg_Node): Support N_Attribute_Reference and
nodes that denotes direct attribute definitions.
* exp_dbug.ads: Description for the encoding of direct attribute
definitions as tick are hard to deal in entity names.
* erroutc.adb
(Set_Msg_Insertion_Name): Replace underscore between prefix and
attribute name in direct attribute definitions; at this point we
lost the semantic information of node type and we resort to match
the string name as described in exp_dbug.adb.
* exp_aggr.adb (Convert_To_Positional): Use Needs_Construction and
Has_Default_Constructor.
* exp_ch3.adb (Build_Record_Init_Proc)
(Expand_N_Object_Declaration): Likewise.
* exp_attr.adb (Expand_N_Attribute_Reference): Likewise.
* exp_ch4.adb (Expand_N_Allocator): Likewise.
* exp_ch6.adb
(Prepend_Constructor_Procedure_Prologue): Use
Is_Constructor_Procedure.
(Make_Parent_Constructor_Call): Use
Direct_Attribute_Definition_Name.
* gen_il-fields.ads: Remove Constructor_List and Constructor_Name.
* gen_il-gen-gen_entities.adb: Likewise.
* einfo.ads (Needs_Construction): Add description.
(Has_Delayed_Aspects): Adjust indentation.
* par-ch13.adb (P_Attribute_Designators): Parse attribute
designators.
(P_Representation_Clause): Use P_Attribute_Designators.
* par-ch6.adb (P_Subprogram): Support attribute designators in
subprogram name.
(Rewrites_Entity_If_Direct_Attribute_Def): Fix the specification
node in case of direct attribute definitions.
* par-endh.adb (Check_End, Same_Label): Likewise.
* par.adb (P_Attribute_Designators): Specification.
* sem_attr.adb (Analyze_Attribute): Error when using 'Constructor
outside procedure specification.
(Analyze_Attribute): Add error handling code.
* sem_ch3.adb (Analyze_Aspect_Specifications): Likewise.
* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Handle direct
attribute definitions. Add error handling code for the
'Construction attribute and set constructor flags when necessary.
(Analyze_Subprogram_Specification): Use
Analyze_Direct_Attribute_Definition.
* sem_util.adb (Direct_Attribute_Definition_Name): Name of
entities created for direct attribute definitions. We emit an
error if multiple attributes.
(Is_Direct_Attribute_Subp_Spec): Helper to check whether a
subprogram specification is a direct attribute definition.
(Is_Constructor_Procedure): Helper to check whether a subprogram
is a constructor procedure.
(Has_Default_Constructor): Check whether the default constructor
exists.
(Default_Constructor): Not used anymore.
(Parameter_Count): Likewise.
(Process_End_Label): Get_Attribute_Reference_Name_String encodes
also direct attribute definition end labels.
* sem_util.ads: Likewise.
* snames.ads-tmpl: Support for 'Constructor attribute.
* snames.adb-tmpl (Is_Direct_Attribute_Definition_Name): Helper to
check attributes allowed in direct attribute definitions.
* aspects.ads: Remove constructor aspect.
* sem_ch13.adb: Likewise.

4 days agoada: Tidy up code dealing with visibility in instances of formal packages
Eric Botcazou [Thu, 9 Oct 2025 07:41:54 +0000 (09:41 +0200)] 
ada: Tidy up code dealing with visibility in instances of formal packages

The actuals for parameters of formal packages are visible in the instance
if the formal packages either are declared with a box or contain defaulted
parameters.  This is essentially implemented in Check_Generic_Actuals and
Restore_Private_Views, with the help of the Is_Visible_Formal flag.

This documents more prominently the processing and streamlines it, as well
as removes a couple of questionable calls to Set_Is_Hidden, thus plugging
a couple more loopholes in the implementation.

gcc/ada/ChangeLog:

PR ada/122161
* sem_ch12.adb: Improve the description of Check_Generic_Actuals,
Restore_Private_Views and Switch_View, and alphabetize them.
(Check_Generic_Actuals): Make actuals visible only if needed.
(Install_Formal_Packages): Pass exact Is_Formal_Box parameter and
remove call to Set_Is_Hidden.
(Instantiate_Formal_Package): Use Next_Non_Pragma consistently in
the loop computing the visibility of actuals.
(Analyze_Package_Instantiation): Use named second parameter in the
call to Restore_Private_Views.
(Analyze_Subprogram_Instantiation): Likewise.
(Instantiate_Package_Body): Likewise and for Check_Generic_Actuals.
(Instantiate_Subprogram_Body): Likewise.
(Restore_Env): Replace call to Restore_Private_Views.
(Restore_Private_Views): Remove default value for second parameter
and test of presence for first parameter.  Consistently clear the
Is_Potentially_Use_Visible flag when setting the Is_Hidden flag.
Remove call to Set_Is_Hidden for a formal package of the enclosing
generic unit, if any.

4 days agoada: Get rid of Sy/Sm mixing (Actions)
Bob Duff [Fri, 10 Oct 2025 16:40:42 +0000 (12:40 -0400)] 
ada: Get rid of Sy/Sm mixing (Actions)

We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

The Actions field is both syntactic and semantic. This patch
makes it always syntactic.

No change in overall compiler behavior.

gcc/ada/ChangeLog:

* gen_il-gen.adb (N_Short_Circuit):
Make Actions syntactic.
(N_Case_Expression_Alternative): Likewise.
* gen_il-gen-gen_nodes.adb (Create_Type):
No longer exempt Actions from the syntactic/semantic ordering rule.
(Check_For_Syntactic_Field_Mismatch):
No longer exempt Actions from the syntactic/semantic mixing rule.
* sinfo.ads (N_Compound_Statement):
Add comment.

4 days agoada: Remove outdated comment
Marc Poulhiès [Fri, 10 Oct 2025 09:08:34 +0000 (11:08 +0200)] 
ada: Remove outdated comment

The comment has been documenting a 'Present(S)' that has been long
gone (>17y).

gcc/ada/ChangeLog:

* sem_aux.adb (Enclosing_Dynamic_Scope): Remove comment.

4 days agoada: Get rid of unused node/entity fields (neither set nor get)
Bob Duff [Thu, 9 Oct 2025 14:12:24 +0000 (10:12 -0400)] 
ada: Get rid of unused node/entity fields (neither set nor get)

The following fields are not used in GNAT nor in any of its clients.
Neither the setters nor the getters are called.

    Node fields:
        Do_Storage_Check
        Enclosing_Variant
        Handler_List_Entry
        Is_Subprogram_Descriptor
        Renaming_Exception
        Default_Expression

    Entity fields:
        Is_Unimplemented

This patch removes all of them.

gcc/ada/ChangeLog:

* einfo.ads: Remove unused fields.
* gen_il-fields.ads: Likewise.
* gen_il-gen-gen_entities.adb: Likewise.
* gen_il-gen-gen_nodes.adb: Likewise.
* sinfo.ads: Likewise.
* gen_il-gen.adb (Compile): Remove obsolete comment.

4 days agoada: Add missing runtime procedure for CHERI
Ronan Desplanques [Thu, 9 Oct 2025 08:11:43 +0000 (10:11 +0200)] 
ada: Add missing runtime procedure for CHERI

A recent patch added a procedure in the spec of System.Stream_Attributes
but failed to add the corresponding body in the CHERI-specific body of
this package. This patch fixes this.

gcc/ada/ChangeLog:

* libgnat/s-stratt__cheri.adb (W_80IEEE): New procedure.

4 days agoada: Move constant declaration
Ronan Desplanques [Thu, 9 Oct 2025 08:08:50 +0000 (10:08 +0200)] 
ada: Move constant declaration

This patch reduces the scope of a recently introduced variable because
it was much larger than it needed to be.

gcc/ada/ChangeLog:

* libgnat/s-stratt.adb (W_80IEEE): Make constant local.

4 days agoada: Get rid of unused node/entity fields (Set_ only)
Bob Duff [Wed, 8 Oct 2025 16:29:35 +0000 (12:29 -0400)] 
ada: Get rid of unused node/entity fields (Set_ only)

The following fields are Set_ but not used in GNAT. We get rid of them
or document them as follows:

    - Has_Pragma_Controlled
Remove.
    - Corresponding_Entry_Body
Document that it is used by codepeer.
    - Is_Activation_Record
Document that it is used by llvm.
    - Is_Discriminant_Check_Function
Document that it is used by codepeer.
    - Original_Access_Type
No change (already documented that it is used by codepeer).

gcc/ada/ChangeLog:

* einfo.ads (Has_Pragma_Controlled): Remove.
(Is_Activation_Record): Document usage by llvm.
* gen_il-fields.ads (Opt_Field_Enum):
Remove Has_Pragma_Controlled.
* gen_il-gen-gen_entities.adb (Access_Kind):
Remove Has_Pragma_Controlled.
* sem_prag.adb:
Remove setting of Has_Pragma_Controlled.
* sinfo.ads (Corresponding_Entry_Body):
Document usage by codepeer.

4 days agoada: Add ctor call after address clause
Alexandre Oliva [Wed, 1 Oct 2025 14:59:18 +0000 (11:59 -0300)] 
ada: Add ctor call after address clause

An object initialized by a C++-imported constructor call has the
constructor function call transformed into a procedure call, and the
call is inserted after the object declaration.

If the object has say an address clause, that transformation separates
the declaration from the address clause, causing the translation of
the call to fail.

Keep such clauses next to the declaration by inserting the constructor
procedure call after them.

gcc/ada/ChangeLog:

* exp_ch3.adb (Expand_N_Object_Declaration): Insert ctor call
after representation clauses.

4 days agoada: Remove exception handler in Check_Vanishing_Fields
Bob Duff [Tue, 7 Oct 2025 14:45:20 +0000 (10:45 -0400)] 
ada: Remove exception handler in Check_Vanishing_Fields

Check_Vanishing_Fields calls Same_Node_To_Fetch_From, which was calling
Node_To_Fetch_From, which will raise an exception (as it should) on
..._Type_Only fields if called early (when the Base_Type,
Implementation_Base_Type, or Root_Type has not yet been set).
Other exceptions can also be raised when Check_Vanishing_Fields
is called early.

An exception handler was used to ignore any such exceptions. That was
correct, but it is annoying in gdb with "catch exception". (Note that
efficiency doesn't matter much, because Check_Vanishing_Fields is not
done in production mode.)

We now call Node_To_Fetch_From_If_Set, remove other potential raises,
and remove the now-unnecessary exception handler.

Note that other calls to Node_To_Fetch_From will still raise an
exception (as they should) for such "early" calls.

gcc/ada/ChangeLog:

* atree.adb (Same_Node_To_Fetch_From):
Use Node_To_Fetch_From_If_Set, and remove handler.
* einfo-utils.adb (Root_Type_If_Set):
Return Empty if Base_Type_If_Set returns Empty.
Return Empty if we find Etype (T) = Empty.
(Underlying_Type): Use "Has_Non_Limited_View..." instead
of "Present (Non_Limited_View...)", because the latter raises
an exception when given the wrong Ekind.

4 days agoada: Make Long_Long_Float'Write deterministic
Ronan Desplanques [Tue, 7 Oct 2025 13:04:46 +0000 (15:04 +0200)] 
ada: Make Long_Long_Float'Write deterministic

On some platforms, Long_Long_Float'Size (and Long_Long_Float'Stream_Size)
is 128 but only 80 bits are effectively used. This pack makes it so
'Write in this case write zeros for the padding bits instead of
unspecified values.

gcc/ada/ChangeLog:

* gen_il-fields.ads (Is_IEEE_Extended_Precision): New flag.
* gen_il-gen-gen_entities.adb: Likewise.
* gen_il-internals.adb (Image): Likewise.
* treepr.adb (Image): Likewise.
* einfo.ads: Document new flag.
* cstand.adb (Copy_Float_Type, Register_Float_Type): Use new flag.
* libgnat/s-stratt.ads (W_80IEEE): New procedure.
* libgnat/s-stratt.adb (W_80IEEE): Likewise.
* exp_strm.adb (Get_Primitives): Select new procedure when
appropriate.
* rtsfind.ads: Register new runtime procedure.
* sem_ch3.adb (Build_Derived_Numeric_Type,
Analyze_Subtype_Declaration): Propagate new flag.

4 days agoada: Fix incorrect static string concatenation with null left string
Eric Botcazou [Tue, 7 Oct 2025 20:57:02 +0000 (22:57 +0200)] 
ada: Fix incorrect static string concatenation with null left string

It comes from the implementation of an optimization for static concatenation
in Resolve_String_Literal, which causes the original subtype of the literal
to be lost.  Now this subtype must be preserved in the case where the left
operand of the concatenation may be null, per the 4.5.3(5) subclause.

gcc/ada/ChangeLog:

PR ada/122160
* sem_res.adb (Resolve_Op_Concat_Rest): Do not build the subtype of
the second operand again if it has already been built.
(Resolve_String_Literal): Do not defer the creation of the subtype
for the right operand of a concatenation whose left operand may be
the null string.

4 days agoada: Remove dependence on secondary stack for type with controlled component
Gary Dismukes [Mon, 6 Oct 2025 19:23:34 +0000 (19:23 +0000)] 
ada: Remove dependence on secondary stack for type with controlled component

There are cases where GNAT introduces a dependence on the secondary stack
in a build-in-place function with a result subtype that is definite, when
this dependence could be avoided.  In particular this is done for record
types that requires finalization due to having a controlled component.

At one time such functions required the secondary stack in order to
properly handle cases where the function might raise an exception
(to avoid improper finalization in the caller), but that is no longer
necessary.  We remove the dependence of these functions on the SS,
along with the BIPalloc formal and the generation of the big if_statement
that uses that formal.

An additional small change is to revise the condition for determining when
to generate SS mark/release within functions.

gcc/ada/ChangeLog:

* exp_ch6.ads (Make_Build_In_Place_Call_In_Allocator): Simplify comment.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Remove obsolete
comment about not being able to allocate fixed-size controlled results
on the caller side, and replace another obsolete comment with a simpler
comment. Call Build_Allocate_Deallocate_Proc when the function doesn't
need a BIPalloc formal to ensure that function results with controlled
parts allocated on the caller side will be chained for finalization.
(Make_Build_In_Place_Call_In_Object_Declaration): Call Needs_BIP_Collection
on the function's Entity_Id rather than the function call.
(Needs_BIP_Collection): If a BIP function doesn't need a BIPalloc formal
then it doesn't need a BIP collection either; return False in that case.
(Needs_BIP_Alloc_Form): Remove test of Needs_BIP_Collection.
* exp_ch7.adb (Expand_Cleanup_Actions): Move test of Uses_Sec_Stack
to be the first conjunct in setting of Needs_Sec_Stack_Mark, and put
the other tests in a disjunction subsidiary to that. Improve preceding
comment.

4 days agoada: Get rid of Sy/Sm mixing (Default_Expression)
Bob Duff [Tue, 7 Oct 2025 14:35:03 +0000 (10:35 -0400)] 
ada: Get rid of Sy/Sm mixing (Default_Expression)

We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

Change the name of Default_Expression (a syntactic field) on
N_Formal_Object_Declaration to be Expression. This avoids
the conflict with the name-named semantic field of
N_Parameter_Specification.

It is also more uniform with other syntactic categories that
use default_expression in the syntax rules.  See, for example,
COMPONENT_DECLARATION in sinfo.ads, which is presumably intended
to be uniform with OBJECT_DECLARATION.

Fix the comment on N_Formal_Object_Declaration to refer
to the new field name Expression.

gcc/ada/ChangeLog:

* gen_il-gen-gen_nodes.adb: Rename Default_Expression to be
Expression.
* gen_il-gen.adb (Check_For_Syntactic_Field_Mismatch): Do not
exempt Default_Expression from the rule.
* par-ch12.adb (P_Formal_Object_Declarations): Use renamed setter.
* sem_ch12.adb (Default): Use renamed getter.
(Analyze_Formal_Object_Declaration): Likewise.
* sprint.adb (Sprint_Node_Actual): Use renamed getter.
* sinfo.ads: Fix comments.

4 days agoada: Incorrect warning redundant parens on in
Bob Duff [Mon, 6 Oct 2025 10:56:34 +0000 (06:56 -0400)] 
ada: Incorrect warning redundant parens on in

This patch fixes a bug where GNAT gives a warning
about redundant parentheses on expressions like "(X in S) = B".
In fact, the parentheses are required in this case.

The bug is caused by constant-folding the expression into
an expression that does not require parentheses, but in
a way that retains the parentheses. The fix is to look
at Original_Node.

gcc/ada/ChangeLog:

* style.adb (Check_Xtra_Parens_Precedence):
Give warning based on Original_Node.

4 days agoada: Fix visibility issue in nested instance with use clause for formal package
Eric Botcazou [Mon, 6 Oct 2025 19:36:56 +0000 (21:36 +0200)] 
ada: Fix visibility issue in nested instance with use clause for formal package

The compiler gives a spurious visibility error for a formal object parameter
of a formal package with a use clause, present in a parent instance, when an
instance of a child generic unit is compiled, while this does not happen in
the same circumstances for a formal type parameter.

The discrepancy comes from the Check_Generic_Actuals procedure, which clears
the Is_Hidden flag on all the actuals of a generic instance, but only sets
the Is_Potentially_Use_Visible flag on the actuals for formal types.

The change also contains a fix for a pasto in Restore_Private_Views, which
is responsible for undoing the changes made by Check_Generic_Actuals.

gcc/ada/ChangeLog:

PR ada/122161
* sem_ch12.adb (Check_Generic_Actuals): Consistently set the
Is_Potentially_Use_Visible flag on actuals whenever the Is_Hidden
flag is cleared.
(Restore_Private_Views): Clear the Is_Potentially_Use_Visible flag
explicitly on the entities of an actual package.

4 days agoada: Add System.Traceback.Symbolic.Calling_Entity
Ronan Desplanques [Mon, 6 Oct 2025 15:01:32 +0000 (17:01 +0200)] 
ada: Add System.Traceback.Symbolic.Calling_Entity

This patch adds a new convenience function to the runtime library,
intended to help with logging.

gcc/ada/ChangeLog:

* libgnat/s-trasym.ads (Calling_Entity): New function.
* libgnat/s-trasym.adb (Calling_Entity): Add dummy body.
* libgnat/s-trasym__dwarf.adb (Calling_Entity): New function.
(Symbolic_Traceback, Symbolic_Traceback_No_Lock,
Module_Symbolic_Traceback, Multi_Module_Symbolic_Traceback): Add
Subprg_Name_Only parameter and corresponding functionality.
(Symbolic_Traceback_No_Lock): Fix typo in documentation comment.
* libgnat/s-dwalin.ads (Symbolic_Traceback): Likewise.
* libgnat/s-dwalin.adb (Symbolic_Traceback): Likewise.

4 days agoada: Get rid of Sy/Sm mixing (Chars)
Bob Duff [Mon, 6 Oct 2025 18:20:00 +0000 (14:20 -0400)] 
ada: Get rid of Sy/Sm mixing (Chars)

We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

The Chars field is both syntactic and semantic. This patch
makes it always syntactic, and does some other Chars-related
cleanups.

An attempt was made to instead rename the semantic field
to be Op_Chars, but that complicates things, because there
is a fair amount of code that fetches the Chars field
without knowing the node kind. Notably, Errout does this.

No change in overall compiler behavior.

gcc/ada/ChangeLog:

* gen_il-gen-gen_nodes.adb (N_Op):
Make Chars syntactic, and move it down into subclasses
N_Binary_Op and N_Unary_Op.
* gen_il-gen.adb (Create_Type):
Do not exempt Chars from the ordering rule.
(Exception_To_Inheritance_Rule): Exempt Chars from the
inheritance rule.
(Check_For_Syntactic_Field_Mismatch):
Do not exempt Chars from the syntactic mismatch rule.
This is the main point of this change.
(Put_Make_Bodies): The Nmake functions for types in N_Op
will now take a Chars parameter, which should always
default to No_Name. This will be overwritten by the
special-case Set_Chars call. Assert that it is in
fact defaulted.
* exp_ch4.adb (Expand_Array_Comparison):
Use the Nkind instead of the Chars, which seems cleaner.
Use a case instead of an elsif chain.
* sem_attr.adb (Proper_Op): Minor cleanup.
* sem_ch8.adb: Minor reformatting.
* sem_res.adb (Operator_Kind): Tighten up the result subtype.

4 days agoada: Catch Constraint_Errors on non-scalar streaming attributes
Viljar Indus [Tue, 23 Sep 2025 09:40:26 +0000 (12:40 +0300)] 
ada: Catch Constraint_Errors on non-scalar streaming attributes

The specs for the streaming methods should use the first
subtype of the prefix attribute for the Item argument if the
prefix has a non-scalar type instead of the underlying type.

This will catch size errors for is smaller size are used for
the Item argument that has a constrained derived
type.

Additionally remove additional casts applied for the Input
attribute that convert the result to the prefix type.
This cast is only necessary for converting the result if
the Input attribute is used on a classwide type.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): Use the
First_Subtype when creating the procedure for stream
attributes.
(Get_Array_Stream_Item_Type): New method for calculating
the type for the Item argument for streaming methods.

4 days agoipa: Fix pritting of symtab_node type: Fix 'static_assert' [PR122512]
Thomas Schwinge [Mon, 3 Nov 2025 12:19:06 +0000 (13:19 +0100)] 
ipa: Fix pritting of symtab_node type: Fix 'static_assert' [PR122512]

Fix-up for commit r16-4914-ga3ee90fd3dc5d5c98f63a16f9cdd788c5d5c3335
"ipa: Fix pritting of symtab_node type [PR122512]":

    ../../source-gcc/gcc/symtab.cc:885:61: error: expected â€˜,’ before â€˜)’ token
     static_assert (ARRAY_SIZE(toplevel_type_names)==TOPLEVEL_MAX);
                                                                 ^
    ../../source-gcc/gcc/symtab.cc:885:61: error: expected string-literal before â€˜)’ token
    make[2]: *** [Makefile:1215: symtab.o] Error 1

PR ipa/122512
gcc/
* symtab.cc: Fix 'static_assert'.

4 days agoAVR: Fix gcc.target/avr/torture/pr92606.c that failed without LPMx.
Georg-Johann Lay [Mon, 3 Nov 2025 11:44:46 +0000 (12:44 +0100)] 
AVR: Fix gcc.target/avr/torture/pr92606.c that failed without LPMx.

gcc/testsuite/
* gcc.target/avr/torture/pr92606.c: Use LPM even if LPMx
is available.

4 days agoarc: Fix wrong vector ordering on big-endian architecture
Loeka Rogge [Wed, 29 Oct 2025 13:57:55 +0000 (06:57 -0700)] 
arc: Fix wrong vector ordering on big-endian architecture

V2HI vectors, explicitly or auto-generated, could be stored in memory wrongly
due to endianness. For example in the following c code stores to the struct
are SLP vectorized, causing them to be stored in the wrong order:

struct S {short a; short b;};
s.a = 520;
s.b = -1;

in the split2 pass the following register set:

(const_vector:V2HI [
        (const_int 520 [0x208])
        (const_int -1 [0xffffffffffffffff])
    ])) "smallTest.c":16:9 484 {*movv2hi_insn}

is converted to:

(const_int -65016 [0xffffffffffff0208])) "smallTest.c":16:9 3 {*movsi_insn}

and is then loaded into the struct. For big-endian this is wrong because
the most significant bytes are written first in memory, storing -1 instead of
520 in s.a .
This patch swaps the 2 values in this step if the target is big-endian.
The added test creates a vector of 2 shorts and verifies the order when
it is passed in a register or in memory.

Regtested for arc and big-endian arc.

gcc/ChangeLog:

* config/arc/simdext.md(movv2hi_insn): Change order for movv2hi
for big-endian.

gcc/testsuite/ChangeLog:

* gcc.target/arc/movv2hi-be.c: New test.

Signed-off-by: Loeka Rogge <loeka@synopsys.com>
4 days agoFix gimple_copy for OpenMP atomic load/store [PR122281, PR105001]
Tobias Burnus [Mon, 3 Nov 2025 11:21:30 +0000 (12:21 +0100)] 
Fix gimple_copy for OpenMP atomic load/store [PR122281, PR105001]

PR libgomp/122281
PR middle-end/105001

gcc/ChangeLog:

* gimple.cc (gimple_copy): Add missing unshare_expr for
GIMPLE_OMP_ATOMIC_LOAD and GIMPLE_OMP_ATOMIC_STORE.

4 days agodocs: fmv: Update Function multi-versioning documentation [PR c/122202]
Alfie Richards [Tue, 14 Oct 2025 15:08:18 +0000 (15:08 +0000)] 
docs: fmv:  Update Function multi-versioning documentation [PR c/122202]

This updates the FMV documentation to the current state of things, including
the addition of "target_version" based FMV.

Left as much of the x86 target based FMV documentation unchanged as
the behaviour change there should be unchanged. Though highlights some of
the differences between it and target_version FMV to try avoid confusion there.

PR c/122202

gcc/ChangeLog:

* doc/extend.texi (target function attribute): Update to describe FMV
behaviour.
(target_version function attribute): New section.
(target_clones attribute): Update to descrbe new behaviour with
target_version.
(Function Multiversioning): Update to discuss both target_version and
target based FMV.

4 days agoRISC-V: Fix the ABI of empty unions and zero length array in struct
Kito Cheng [Wed, 22 Oct 2025 09:06:03 +0000 (17:06 +0800)] 
RISC-V: Fix the ABI of empty unions and zero length array in struct

The RISC-V ABI currently defines that empty unions and zero length array
in struct should be ignored, but the implementation in GCC is not
correct.

e.g. for the following code:
```
struct S2eu_2f {
    union{} e1;
    float f;
    float g;
};
```

The RISC-V ABI defines that the layout of S2eu_2f should be equivalent
to:
```
struct S2eu_2f {
float f;
float g;
};
```

However, the current GCC implementation passes S2eu_2f in a0 (lp64d)
rather than fa0 and fa1 (lp64d).

Also for the following code:
```
struct S0ae_2f {
    struct{} e1[0];
    float f;
    float g;
};
```
The RISC-V ABI defines that the layout of S0ae_2f should be equivalent
to:
```
struct S0ae_2f {
float f;
float g;
};
```

And again, the current GCC implementation passes S0ae_2f in a0 (lp64d)
rather than fa0 and fa1 (lp64d).

This patch fixes the issue by updating the relevant functions to correctly
handle empty unions, also we have implemented the ABI change warning to
notify user that the ABI of empty unions and zero length array in struct
has been changed/fixed.

Generally ABI should not be changed, but the psABI is defined there for
long time and clang/LLVM has already implemented it correctly, so we
decide to fix it in GCC as well to maintain compatibility, and another
reason to fix that in GCC is zero length array and empty union in struct
should be rarely used in practice, so the impact should be limited.

References:
[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/464

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_flatten_aggregate_field): Skip
empty unions and zero-length arrays when flattening aggregate
fields for ABI classification.
(riscv_pass_aggregate_in_fpr_pair_p): Refactor to use separate
field parsing and emit ABI change warning for affected types.
(riscv_pass_aggregate_in_fpr_and_gpr_p): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/abi/param2.C: Add -Wno-psabi option for RISC-V.
* g++.target/riscv/abi/empty-struct+union-1.cc: New test.
* g++.target/riscv/abi/empty-struct+union-2.cc: New test.
* g++.target/riscv/abi/empty-struct+union-3.cc: New test.
* g++.target/riscv/abi/empty-struct+union-4.cc: New test.
* g++.target/riscv/abi/empty-struct-1.cc: New test.
* g++.target/riscv/abi/empty-struct-2.cc: New test.
* g++.target/riscv/abi/empty-struct-3.cc: New test.
* g++.target/riscv/abi/empty-struct-4.cc: New test.
* g++.target/riscv/abi/empty-struct-5.cc: New test.
* g++.target/riscv/abi/empty-struct-6.cc: New test.
* g++.target/riscv/abi/empty-struct-7.cc: New test.
* g++.target/riscv/abi/empty-struct-8.cc: New test.
* g++.target/riscv/abi/empty-struct-9.cc: New test.
* g++.target/riscv/abi/empty-struct-10.cc: New test.
* g++.target/riscv/abi/empty-struct-11.cc: New test.
* g++.target/riscv/abi/empty-struct-12.cc: New test.
* g++.target/riscv/abi/empty-union-1.cc: New test.
* g++.target/riscv/abi/empty-union-2.cc: New test.
* g++.target/riscv/abi/empty-union-3.cc: New test.
* g++.target/riscv/abi/empty-union-4.cc: New test.
* g++.target/riscv/riscv.exp: Add abi subdirectory.
* gcc.dg/compat/pr83487-1_x.c: Add -Wno-psabi option for RISC-V.
* gcc.dg/compat/pr83487-1_y.c: Likewise.
* gcc.dg/compat/pr83487-2_x.c: Likewise.
* gcc.dg/compat/pr83487-2_y.c: Likewise.
* gcc.dg/torture/pr28814.c: Likewise.
* gcc.target/riscv/abi/empty-struct+union-1.c: New test.
* gcc.target/riscv/abi/empty-struct+union-2.c: New test.
* gcc.target/riscv/abi/empty-struct+union-3.c: New test.
* gcc.target/riscv/abi/empty-struct+union-4.c: New test.
* gcc.target/riscv/abi/empty-struct-1.c: New test.
* gcc.target/riscv/abi/empty-struct-2.c: New test.
* gcc.target/riscv/abi/empty-struct-3.c: New test.
* gcc.target/riscv/abi/empty-struct-4.c: New test.
* gcc.target/riscv/abi/empty-struct-5.c: New test.
* gcc.target/riscv/abi/empty-struct-6.c: New test.
* gcc.target/riscv/abi/empty-struct-7.c: New test.
* gcc.target/riscv/abi/empty-struct-8.c: New test.
* gcc.target/riscv/abi/empty-struct-9.c: New test.
* gcc.target/riscv/abi/empty-struct-10.c: New test.
* gcc.target/riscv/abi/empty-struct-11.c: New test.
* gcc.target/riscv/abi/empty-struct-12.c: New test.
* gcc.target/riscv/abi/empty-union-1.c: New test.
* gcc.target/riscv/abi/empty-union-2.c: New test.
* gcc.target/riscv/abi/empty-union-3.c: New test.
* gcc.target/riscv/abi/empty-union-4.c: New test.
* gcc.target/riscv/riscv.exp: Add abi subdirectory.

4 days agoAArch64: Fix mv-cmpu-features.C test that fails on older glibc's [PR 122405]
Alfie Richards [Mon, 27 Oct 2025 17:49:07 +0000 (17:49 +0000)] 
AArch64: Fix mv-cmpu-features.C test that fails on older glibc's [PR 122405]

Adds a definition of HWCAP_ATOMICS and HWCAP2_RNG in the test file for the
case that the glibc is old enough to not include them.

PR target/122405

gcc/testsuite/ChangeLog:

* g++.target/aarch64/mv-cpu-features.C: Add HWCAP_ATOMICS and
HWCAP2_RNG defines.

4 days agoaarch64: Add missing fmv features.
Alfie Richards [Mon, 20 Oct 2025 12:01:13 +0000 (12:01 +0000)] 
aarch64: Add missing fmv features.

Add all the missing FMV features from the ACLE.

gcc/ChangeLog:

* config/aarch64/aarch64-option-extensions.def (dit): New fmv feature.
(dpb): New fmv feature.
(dpb2): New fmv feature.
(memtag): Change to also define an FMV feature.
(ssbs): Change to also define an FMV feature.
(bti): New fmv feature.
* config/aarch64/aarch64.cc (FEAT_SSBS): Add macro.
(FEAT_MEMTAG): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/fmv_priority.in: Update for new features.
* gcc.target/aarch64/fmv_priority1.c: Ditto.
* gcc.target/aarch64/fmv_priority2.c: Ditto.

4 days agoAda: Add testcase for missed loop vectorization on x86-64/Windows
Eric Botcazou [Mon, 3 Nov 2025 09:00:22 +0000 (10:00 +0100)] 
Ada: Add testcase for missed loop vectorization on x86-64/Windows

It has been fixed by swapping operands during SLP discovery.

gcc/testsuite/
* gnat.dg/vect19.ads, gnat.dg/vect19.adb: New test.
* gnat.dg/vect19_pkg.ads, gnat.dg/vect19_pkg.adb: New helper.

4 days agoxtensa: Revise implementation of hardware FP rounding instructions
Takayuki 'January June' Suwa [Sun, 2 Nov 2025 20:39:56 +0000 (05:39 +0900)] 
xtensa: Revise implementation of hardware FP rounding instructions

Since each element in an MD iterator can have its own condition that is
true by default, it is simpler to specify the precondition for the ROUND.S
machine instruction such way.

There are no functional changes with this patch.

gcc/ChangeLog:

* config/xtensa/xtensa.md (int_iterator ANY_ROUND):
Specify "flag_unsafe_math_optimizations" in the condition of the
UNSPEC_ROUND element.
(int_attr c_round): Remove.
(l<m_round>sfsi2, *l<m_round>sfsi2_2x, *l<m_round>sfsi2_scaled):
Remove " && <c_round>" from the conditions.

4 days agoLoongArch: Improve TARGET_MODES_TIEABLE_P implementation
Guo Jie [Sun, 2 Nov 2025 03:32:44 +0000 (11:32 +0800)] 
LoongArch: Improve TARGET_MODES_TIEABLE_P implementation

Make scalar int mode and scalar fp mode tieable, so movgr2fr and
movfr2gr can be used instead of memory access.

For example, in pattern '*movsi_internal', when matching gr->fr,
due to the constraint '*' in alt4, it will match alt5, resulting
in memory access instead of movgr2fr.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_modes_tieable_p):
Make MODE_FLOAT and MODE_INT tieable.
* config/loongarch/loongarch.md: Adjust constraints.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/mode-tieable-opt.c: New test.

4 days agoLoongArch: Make full use of load insns with unsigned extension
Guo Jie [Sun, 2 Nov 2025 03:32:07 +0000 (11:32 +0800)] 
LoongArch: Make full use of load insns with unsigned extension

gcc/ChangeLog:

* config/loongarch/loongarch.md
(and_load_zero_extend<mode>): New combiner.
* config/loongarch/predicates.md
(mask_operand): New predicate.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/mem-and-mask-opt.c: New test.

4 days agoLoongArch: Eliminate unnecessary dependencies introduced by xvpermi.q
Guo Jie [Sun, 2 Nov 2025 03:31:32 +0000 (11:31 +0800)] 
LoongArch: Eliminate unnecessary dependencies introduced by xvpermi.q

1. When the selector is 0x0, 0x1, 0x10, or 0x11, the result of
xvpermi.q does not depend on the output operand, thus eliminating
the dependency chain of the output operand as input, which can
reduce the number of instructions.

2. When the selector is 0x22, 0x23, 0x32, or 0x33, the result of
xvpermi.q does not depend on the second input operand, thus
eliminating the dependency chain of the second input operand,
which can also reduce the number of instructions.

gcc/ChangeLog:

* config/loongarch/lasx.md (lasx_xvpermi_q_<LASX:mode>):
Add new splitter for optimization.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vec_pack_unpack_256.c: Adjust to changed
lasx_xvpermi_q_<LASX:mode> template.
* gcc.target/loongarch/vector/lasx/lasx-builtin.c: Ditto.
* gcc.target/loongarch/lasx-xvpermi_q-opt.c: New test.

4 days agoLoongArch: Optimize AND large immediate operation
Guo Jie [Sun, 2 Nov 2025 03:30:57 +0000 (11:30 +0800)] 
LoongArch: Optimize AND large immediate operation

For large immediate values in variable AND operations:
if their bit representation has two consecutive 0 sequences,
one starting from the MSB can use the bstrpick.d instruction,
and the bstrins.d instruction for the other.

For example, in the case 'var & 0x3fffffffefffffff':

Before:
    lu12i.w $r12,-65537
    ori     $r12,$r12,4095
    lu52i.d $r12,$r12,0x3ff
    and     $r4,$r4,$r12

After:
    bstrpick.d $r4,$r4,61,0
    bstrins.d $r4,$r0,28,28

gcc/ChangeLog:

* config/loongarch/loongarch-protos.h
(loongarch_use_bstrins_bstrpick_for_and): New proto.
* config/loongarch/loongarch.cc
(loongarch_use_bstrins_bstrpick_for_and): Decide whether
to optimize.
(loongarch_rtx_costs): Adjust the cost of AND operation.
* config/loongarch/loongarch.md
(bstrins_bstrpick_for_and_imm<mode>): New insn_and_split.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/and-large-immediate-opt.c: New test.

4 days agoLoongArch: Improve TARGET_CAN_CHANGE_MODE_CLASS implementation
Guo Jie [Sun, 2 Nov 2025 02:01:06 +0000 (10:01 +0800)] 
LoongArch: Improve TARGET_CAN_CHANGE_MODE_CLASS implementation

Support for conversion between scalar INT and scalar FP.

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_can_change_mode_class): Support for conversion
between scalar INT and scalar FP.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/extendsidi2-combine.c: New test.
* gcc.target/loongarch/spill-less.c: New test.

4 days agoLoongArch: Correct the cost of mulh.{w[u]/d[u]}
Guo Jie [Sat, 1 Nov 2025 07:33:06 +0000 (15:33 +0800)] 
LoongArch: Correct the cost of mulh.{w[u]/d[u]}

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_rtx_costs):
Correct the cost of mulh.{w[u]|d[u]}.

gcc/testsuite/ChangeLog:

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

4 days agovect: Fix null dereference in boolean reductions [PR122475]
Tamar Christina [Mon, 3 Nov 2025 08:07:13 +0000 (08:07 +0000)] 
vect: Fix null dereference in boolean reductions [PR122475]

neutral_op can be null, so guard against that.

gcc/ChangeLog:

PR tree-optimization/122475
* tree-vect-loop.cc (vectorizable_reduction): Check for neutral_op.

gcc/testsuite/ChangeLog:

PR tree-optimization/122475
* gcc.dg/vect/pr122475.c: New test.
* gcc.target/aarch64/sve/vect-reduc-bool-19.c: New test.
* gcc.target/aarch64/sve/vect-reduc-bool-20.c: New test.

4 days agox86-64: Inline memmove with overlapping unaligned loads and stores
H.J. Lu [Mon, 20 Oct 2025 08:14:34 +0000 (16:14 +0800)] 
x86-64: Inline memmove with overlapping unaligned loads and stores

Inline memmove in 64-bit since there are much less registers available
in 32-bit:

1. Load all sources into registers and store them together to avoid
   possible address overlap between source and destination.
2. For known size, first try to fully unroll with 8 registers.
3. For size <= 2 * MOVE_MAX, load all sources into 2 registers first
   and then store them together.
4. For size > 2 * MOVE_MAX and size <= 4 * MOVE_MAX, load all sources
   into 4 registers first and then store them together.
5. For size > 4 * MOVE_MAX and size <= 8 * MOVE_MAX, load all sources
   into 8 registers first and then store them together.
6. For size > 8 * MOVE_MAX,
   a. If address of destination > address of source, copy backward
      with a 4 * MOVE_MAX loop with unaligned loads and stores.  Load
      the first 4 * MOVE_MAX into 4 registers before the loop and
      store them after the loop to support overlapping addresses.
   b. Otherwise, copy forward with a 4 * MOVE_MAX loop with unaligned
      loads and stores.  Load the last 4 * MOVE_MAX into 4 registers
      before the loop and store them after the loop to support
      overlapping addresses.

Verified and benchmarked memmove implementations inlined with GPR, SSE2,
AVX2 and AVX512 using glibc memmove tests.  It is available at

https://gitlab.com/x86-glibc/glibc/-/commits/users/hjl/test/memmove

Their performances are comparable with optimized memmove implementations
in glibc on Intel Core i7-1195G7.

gcc/

PR target/90262
* config/i386/i386-expand.cc (ix86_expand_unroll_movmem): New.
(ix86_expand_n_move_movmem): Likewise.
(ix86_expand_load_movmem): Likewise.
(ix86_expand_store_movmem): Likewise.
(ix86_expand_n_overlapping_move_movmem): Likewise.
(ix86_expand_less_move_movmem): Likewise.
(ix86_expand_movmem): Likewise.
* config/i386/i386-protos.h (ix86_expand_movmem): Likewise.
* config/i386/i386.md (movmem<mode>): Likewise.

gcc/testsuite/

* gcc.target/i386/builtin-memmove-1a.c: New test.
* gcc.target/i386/builtin-memmove-1b.c: Likewise.
* gcc.target/i386/builtin-memmove-1c.c: Likewise.
* gcc.target/i386/builtin-memmove-1d.c: Likewise.
* gcc.target/i386/builtin-memmove-2a.c: Likewise.
* gcc.target/i386/builtin-memmove-2b.c: Likewise.
* gcc.target/i386/builtin-memmove-2c.c: Likewise.
* gcc.target/i386/builtin-memmove-2d.c: Likewise.
* gcc.target/i386/builtin-memmove-3a.c: Likewise.
* gcc.target/i386/builtin-memmove-3b.c: Likewise.
* gcc.target/i386/builtin-memmove-3c.c: Likewise.
* gcc.target/i386/builtin-memmove-4a.c: Likewise.
* gcc.target/i386/builtin-memmove-4b.c: Likewise.
* gcc.target/i386/builtin-memmove-4c.c: Likewise.
* gcc.target/i386/builtin-memmove-5a.c: Likewise.
* gcc.target/i386/builtin-memmove-5b.c: Likewise.
* gcc.target/i386/builtin-memmove-5c.c: Likewise.
* gcc.target/i386/builtin-memmove-6.c: Likewise.
* gcc.target/i386/builtin-memmove-7.c: Likewise.
* gcc.target/i386/builtin-memmove-8.c: Likewise.
* gcc.target/i386/builtin-memmove-9.c: Likewise.
* gcc.target/i386/builtin-memmove-10.c: Likewise.
* gcc.target/i386/builtin-memmove-11a.c: Likewise.
* gcc.target/i386/builtin-memmove-11b.c: Likewise.
* gcc.target/i386/builtin-memmove-11c.c: Likewise.
* gcc.target/i386/builtin-memmove-12.c: Likewise.
* gcc.target/i386/builtin-memmove-13.c: Likewise.
* gcc.target/i386/builtin-memmove-14.c: Likewise.
* gcc.target/i386/builtin-memmove-15.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 days ago[RISC-V][PR tree-optimization/52345] Optimize testing multiple booleans
Shreya Munnangi [Mon, 3 Nov 2025 02:21:53 +0000 (19:21 -0700)] 
[RISC-V][PR tree-optimization/52345] Optimize testing multiple booleans

This is Shreya's work, my contribution was primarily covering the testing.
Bootstrapped and regression tested on x86 and riscv64.  It's also been tested
on all the embedded targets in my tester without regression.

While this improves code generation to optimal on riscv-64, I'm electing to
keep the BZ open because we probably should have the same kind of
simplification in match.pd.  Shreya is just starting to write some match.pd
patterns and I expect we'll return to write a match.pd pattern for this issue
relatively soon.

Obviously waiting for pre-commit CI to chime in before moving forward.

Jeff

--

In PR52345, we have this testcase:

int f(int a, int b)
{
  int c = a != 0;
  int d = (c!=0|b!=0);
  return d;
}

Basically, "d" will either be 0 or 1. Depending on "a", "c" will also
either be 0 or 1. So if "a" is 0 and "b" is 0, then "d" will also be 0. Otherwise, it will be 1.

When the testcase is compiled, we get this generated assembly code:

        snez    a0,a0
        or      a0,a1,a0
        snez    a0,a0

RISC-V has a missed optimization here, as this can simply be done by first
computing a|b and checking if the result is equal to 0. If "a" is 0 and "b" is
0, we will get 0. Otherwise, we will get 1. Doing this removes the unnecessary
first snez instruction.

When we looked at the combine pass, it was trying:

Failed to match this instruction:
(set (reg/i:DI 10 a0)
    (ne:DI (ior:DI (ne:DI (reg:DI 151 [ a ])
                (const_int 0 [0]))
            (reg:DI 152 [ b ]))
        (const_int 0 [0])))

In simplify_relational_operation_1 of simplify-rtx.cc, we added a condition.
For cases where the outer code is a "not equal to" (NE) and the operands match
the pattern above, we simply emit an NE of an IOR of the two registers, giving
us:

        or      a0,a0,a1
        snez    a0,a0

We then generalized this to include the case where the outer code is an "equal
to" (EQ). With the logic working in the same way, we simply adjust the
recognition code to check that the outer code is either an NE or EQ and
generalize the NE we emit to match the outer code.

--

PR target/52345
gcc/

* simplify-rtx.cc (simplify_relational_operation_1): Optimize boolean
IOR equality tests.

gcc/testsuite/

* gcc.target/riscv/pr52345.c: Add new test cases.

4 days agoLoongArch: Add builtin interfaces for 128 and 256 vector conversions.
chenxiaolong [Wed, 29 Oct 2025 10:49:34 +0000 (18:49 +0800)] 
LoongArch: Add builtin interfaces for 128 and 256 vector conversions.

gcc/ChangeLog:

* config/loongarch/lasx.md (vec_cast<mode>): New template
implemention.
(vec_insert_lo_<mode>): Dito.
(vec_insert_hi_<mode>): Dito.
* config/loongarch/lasxintrin.h (defined): Test for adding
the builtin function.
(__lasx_cast_128_s): Dito.
(__lasx_cast_128_d): Dito.
(__lasx_cast_128): Dito.
(__lasx_concat_128_s): Dito.
(__lasx_concat_128_d): Dito.
(__lasx_concat_128): Dito.
(__lasx_extract_128_lo_s): Dito.
(__lasx_extract_128_hi_s): Dito.
(__lasx_extract_128_lo_d): Dito.
(__lasx_extract_128_hi_d): Dito.
(__lasx_extract_128_lo): Dito.
(__lasx_extract_128_hi): Dito.
(__lasx_insert_128_lo_s): Dito.
(__lasx_insert_128_hi_s): Dito.
(__lasx_insert_128_lo_d): Dito.
(__lasx_insert_128_hi_d): Dito.
(__lasx_insert_128_lo): Dito.
(__lasx_insert_128_hi): Dito.
* config/loongarch/loongarch-builtins.cc
(CODE_FOR_lasx_extract_128_lo_s): Add builtins and register
icode.
(CODE_FOR_lasx_extract_128_hi_s): Dito.
(CODE_FOR_lasx_extract_128_lo_d): Dito.
(CODE_FOR_lasx_extract_128_hi_d): Dito.
(CODE_FOR_lasx_extract_128_lo): Dito.
(CODE_FOR_lasx_extract_128_hi): Dito.
(CODE_FOR_lasx_insert_128_lo_s): Dito.
(CODE_FOR_lasx_insert_128_hi_s): Dito.
(CODE_FOR_lasx_insert_128_lo_d): Dito.
(CODE_FOR_lasx_insert_128_hi_d): Dito.
(CODE_FOR_lasx_insert_128_lo): Dito.
(CODE_FOR_lasx_insert_128_hi): Dito.
(CODE_FOR_lasx_concat_128_s): Dito.
(CODE_FOR_lasx_concat_128_d): Dito.
(CODE_FOR_lasx_concat_128): Dito.
(CODE_FOR_lasx_cast_128_s): Dito.
(CODE_FOR_lasx_cast_128_d): Dito.
(CODE_FOR_lasx_cast_128): Dito.
(loongarch_expand_builtin_direct): For the newly added
insertion or extraction, construct the parallel parameter
corresponding to the operand.
* config/loongarch/loongarch-c.cc
(loongarch_update_cpp_builtins): Define
__loongarch_asx_sx_conv.
* config/loongarch/loongarch-ftypes.def: Declare the type
of the builtin function.
* doc/extend.texi: Add document description.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vector/lasx/vect-concat-128-256-result.c: New test.
* gcc.target/loongarch/vector/lasx/vect-concat-128-256.c: New test.
* gcc.target/loongarch/vector/lasx/vect-extract-256-128-result.c: New test.
* gcc.target/loongarch/vector/lasx/vect-extract-256-128.c: New test.
* gcc.target/loongarch/vector/lasx/vect-insert-128-256-result.c: New test.
* gcc.target/loongarch/vector/lasx/vect-insert-128-256.c: New test.

4 days agoLoongArch: Optimize normal immediate data loading.
Lulu Cheng [Sun, 25 May 2025 03:15:07 +0000 (11:15 +0800)] 
LoongArch: Optimize normal immediate data loading.

Ensure that only one register is used when loading immediate values.
The original immediate value load is handled through virtual
registers, resulting in the following load operation
(0x1234567890abcdef):
        lu12i.w $r4,-456004                     # 0xfffffffffff90abc
        or      $r12,$r0,$r0
        ori     $r4,$r4,3567
        lu32i.d $r12,0x45678
        lu32i.d $r4,0
        or      $r4,$r4,$r12
        lu52i.d $r4,$r4,0x123

The optimized sequence is as follows:
lu12i.w $r4,-456004 # 0xfffffffffff90abc
ori $r4,$r4,3567
lu32i.d $r4,0x45678
lu52i.d $r4,$r4,0x123

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_move_integer):
No new virtual register is allocated during immediate load.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/imm-load.c: Modify.

4 days agoLoongArch: Fix ICE caused by loongarch_split_reduction [PR122477].
Lulu Cheng [Wed, 29 Oct 2025 01:21:58 +0000 (09:21 +0800)] 
LoongArch: Fix ICE caused by loongarch_split_reduction [PR122477].

In r16-4619, the scalar mode is not handled, which causes the
compilation of test cases such as pr111414-1.c to fail in ICE.

PR target/122477

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_split_reduction): Added handling of scalar mode.

4 days agoDaily bump.
GCC Administrator [Mon, 3 Nov 2025 00:18:56 +0000 (00:18 +0000)] 
Daily bump.

4 days agoPR modula2/122499: misspelt procedure in import list causes clutter
Gaius Mulley [Sun, 2 Nov 2025 21:44:03 +0000 (21:44 +0000)] 
PR modula2/122499: misspelt procedure in import list causes clutter

A misspelt ident in an import list causes a sequence of clutted errors.
This bug fix filters unknowns built during import lists.  It also
checks for spelling mistakes against the modules exported identifiers.

gcc/m2/ChangeLog:

PR modula2/122499
* gm2-compiler/M2StackSpell.mod (PushName): Add comment.
(GetSpellHint): Rewrite.
(GetExportedSpellHint): New procedure function.
(GetScopeSpellHint): New procedure function.
* gm2-compiler/P1Build.bnf (IdentScope): Rewrite.
(PossiblyExportIdent): Ditto.
* gm2-compiler/P1SymBuild.mod (BuildImportInnerModule): Add
parameter to AddNameToImportList.
* gm2-compiler/SymbolTable.def (GetUnknownOnImport): New
procedure function.
(GetUnknownDeclScope): Ditto.
(AddNameToScope): Add tok parameter.
(AddNameToImportList): Ditto.
* gm2-compiler/SymbolTable.mod (SymUndefined): New field
declScope.
New field onImport.
(MakeObject): Add tok parameter.
(FillInUnknownFields): Initialize declScope.
Initialize onImport.
(GetUnknownOnImport): New procedure function.
(GetUnknownDeclScope): Ditto.
(AddNameToScope): Pass tok to MakeObject.
(AddNameToImportList): Add tok parameter.
Pass tok to MakeObject.
(GetDeclaredSym): Add parameters to FillInUnknownFields.
(RequestSym): Ditto.
(FetchUnknownFromModule): Ditto.
(FetchUnknownFromDefImp): Ditto.
(FetchUnknownFrom): Ditto.

gcc/testsuite/ChangeLog:

PR modula2/122499
* gm2.dg/spell/iso/fail/badimport2.mod: New test.
* gm2.dg/spell/iso/fail/badimport3.mod: New test.
* gm2.dg/spell/iso/fail/badimport4.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
4 days agoSPARC: Make target-specific test more robust
Eric Botcazou [Sun, 2 Nov 2025 21:21:49 +0000 (22:21 +0100)] 
SPARC: Make target-specific test more robust

The test is expected to pass on Solaris only.

gcc/testsuite/
* gcc.target/sparc/small-struct-1.c: Run only on Solaris.