Remove %I from the spec string because gcobol does not use the C
preprocessor library and does not search include/ or include-fixed/
directories. Instead, system copybooks (as they're called) follow the
runtime library and are installed into the LIBSUBDIR, similarly to
Modula-2's .def files.
For compilations relying on non-standard paths (i.e., outside the
installation prefix), -B is already handled by the cobol1 compiler.
Georg-Johann Lay [Mon, 22 Jun 2026 16:36:36 +0000 (18:36 +0200)]
Remove -*- C++ -*- tags for Emacs from .cc files.
There are still some -*- C++ -*- markers in .cc files.
They were needed after GCC transitioned to C++ but still
used .c extensions for C++ files.
These tags are no more needed, and this patch removes these
tags from some .cc files that still have them.
The preferred way of letting Emacs chose a major mode is by
means of file-name based rules. Such tags can be annoying
when you have a different rule for .cc files, for example
when .cc files are bound to GNU style but default C++ style isn't.
Kanishka Solanki [Mon, 22 Jun 2026 12:28:40 +0000 (17:58 +0530)]
a68: return alias set 0 for Algol 68
Hi,
Following review feedback, this version adds the requested commit
subject prefix and an explanatory comment before the return statement
in a68_get_alias_set.
The frontend builds successfully and make check-algol68 passes with this
change.
Thanks,
Kanishka Solanki
[4. text/x-patch; 0001-a68-return-alias-set-0-for-Algol-68.patch]...
From daf6fde806010dcff462d4078992621646d841ae Mon Sep 17 00:00:00 2001
From: Kanishka Solanki <kanishkasolanki456s@gmail.com>
Date: Sun, 21 Jun 2026 21:34:40 +0530
Subject: [PATCH] a68: return alias set 0 for Algol 68
The default LANG_HOOKS_GET_ALIAS_SET implementation returns -1,
causing GCC to use its default alias set machinery.
Override LANG_HOOKS_GET_ALIAS_SET in the Algol 68 frontend and
return 0 so all objects are treated as potentially aliasing.
gcc/algol68/ChangeLog
* a68-lang.cc (a68_get_alias_set): New function.
(LANG_HOOKS_GET_ALIAS_SET): Define to a68_get_alias_set.
Tobias Burnus [Mon, 22 Jun 2026 13:16:19 +0000 (15:16 +0200)]
Fortran/OpenMP: Split-off resolve_omp_clauses_aff_dep_map_cache from resolve_omp_clauses
In order to simplify resolve_omp_clauses but also because re-resolving is
required (in a later patch) for 'declare mapper', the code to resolve
MAP, TO and FROM clauses needs to be separately callable.
As AFFINITY, DEPEND and CACHE share the same code, those have been moved
as well.
The new function integrates the body of two loops. This means that
'n->sym->attr.referenced' is set when walking the walking the symbol for
the first time; however, that should not have any effect. Besides merging
the loop bodies and replacing an outer 'continue' by a 'return', there
has been a lot of reindenting, that shortend the code a bit as more
code fits now into a single line. Otherwise, the code should be identical.
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses_aff_dep_map_cache): Split off
from ...
(resolve_omp_clauses): ... here. Call it.
Suggested-by: Julian Brown <julian@codesourcery.com>
Tobias Burnus [Mon, 22 Jun 2026 11:35:41 +0000 (13:35 +0200)]
libgomp: Add stubs for OpenMP's multidim routines
This commit adds OpenMP 6.1's multidimensional support routines. 'stub' is
slightly misleading as they are fully functional; however, as GCC currently
only supports a single active spatial dimension for both teams and target,
the non-'omp_supported' functions act as their unidimensional counter part
for dimension 0. And the supported-active-dims functions just return one.
However, the functions omp_get_supported_teams_dim and
omp_get_supported_threads_dim actually return (for dim == 0) an upper bound
for the number of teams and threads, respectively, that can be useful to
know for unidimensional use as well.
gcc/ChangeLog:
* omp-general.cc (omp_runtime_api_procname): Update for added
functions and older additions.
* omp-low.cc (scan_omp_1_stmt): Update for added _dim function.
libgomp/ChangeLog:
* config/gcn/teams.c (omp_get_num_teams_dim,
omp_get_team_num_dim): New functions.
* config/nvptx/teams.c (omp_get_num_teams_dim,
omp_get_team_num_dim): Likewise.
* fortran.c (omp_get_supported_active_team_dims_,
omp_get_supported_active_league_dims_): Likewise.
* icv.c (omp_get_thread_limit_dim): Likewise.
* libgomp-plugin.h (GOMP_OFFLOAD_get_numa_node): Remove spurious
const of 'const int' function return type.
(GOMP_OFFLOAD_supported_teams_dim,
GOMP_OFFLOAD_supported_threads_dim): Declare.
* libgomp.h (struct gomp_device_descr): Add supported_teams_dim_func
and supported_threads_dim_func members.
* libgomp.map (OMP_6.1): Add new OpenMP routines.
* libgomp.texi (Multidimensional Support Routines): Add new section.
(omp_get_device_distances): Fix chapter of spec reference.
* omp.h.in (omp_get_num_threads_dim, omp_get_thread_num_dim,
omp_get_thread_limit_dim, omp_get_supported_active_team_dims,
omp_get_supported_active_league_dims, omp_get_supported_teams_dim,
omp_get_supported_threads_dim, omp_get_num_teams_dim,
omp_get_team_num_dim, omp_get_device_distances): Declare.
* omp_lib.f90.in: Likewise.
* omp_lib.h.in: Likewise.
* parallel.c (omp_get_num_threads_dim,
omp_get_thread_num_dim): New functions.
* plugin/plugin-gcn.c (limit_worker_threads): Add comment.
(GOMP_OFFLOAD_supported_teams_dim,
GOMP_OFFLOAD_supported_threads_dim): New functions.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_supported_teams_dim,
GOMP_OFFLOAD_supported_threads_dim): New functions.
(nvptx_adjust_launch_bounds): Add comment.
* target.c (omp_get_supported_active_team_dims,
omp_get_supported_active_league_dims,
omp_get_supported_teams_dim,
omp_get_supported_threads_dim): New functions.
(gomp_load_plugin_for_device): dlsym added functions.
* teams.c (omp_get_num_teams_dim,
omp_get_team_num_dim): New functions.
* testsuite/libgomp.c/multi-dim-routines.c: New test.
* testsuite/libgomp.fortran/multi-dim-routines-2.F90: New test.
* testsuite/libgomp.fortran/multi-dim-routines.F90: New test.
Declare mapper with strided is not yet supported and is reject at parse
time. For non-contiguous memory, Fortran gave an ICE, which this commit
fixes.
Additionally, once implemented, the strided use needs to be diagosed
when used in 'target {,{enter,exit}}' but is fine for 'target update';
the added testcases should make it easier not to forgot to check this,
once strided is added.
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses): Avoid ICE when called
by gfc_resolve_omp_udm.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/declare-mapper-2.c: New test.
* gfortran.dg/gomp/declare-mapper-8.f90: New test.
Zhongjie Guo [Mon, 22 Jun 2026 10:55:21 +0000 (10:55 +0000)]
i386: Use comparison operand mode for compare costs
AVX512 vector comparisons produce mask results, but the instructions
operate on vector operands. The instruction cost should therefore be
based on the operand vector mode rather than the mask result mode.
The mismatch is especially visible on AVX512 split-regs targets, where
ix86_vec_cost scales 512-bit vector operations. Using the mask result
type misses that scaling and can make 512-bit vectorization look too
cheap.
As Richi suggested, this can be extended to cover scalar as well.
So this patch is to obtain the mode of comparison operand first, then
continue with the existing comparison cost logic. It also adjusts
truth_value_p with tcc_comparison check.
gcc/ChangeLog:
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Cost
comparisons using the comparison operand mode.
gcc/testsuite/ChangeLog:
* gcc.target/i386/vect-compare-cost.c: New test.
Signed-off-by: Zhongjie Guo <guozhongjie@hygon.cn> Co-Authored-By: Richard Biener <rguenther@suse.de>
Javier Miranda [Sat, 6 Jun 2026 16:09:41 +0000 (16:09 +0000)]
ada: Add support for abstract constructors
A constructor may be defined abstract in the public part of a package
to hide it, but it must be defined in the private part of the package.
gcc/ada/ChangeLog:
* par-ch6.adb (P_Subprogram): Add missing support for direct
attribute definition in abstract subprogram declarations.
* sem_attr.adb (Check_Hidden_Abstract_Constructor_Call): New
local subprogram of Analyze_Attribute.
(Analyze_Attribute) <Attribute_Make>: Add calls to the new local
subprogram to detect and report wrong calls to abstract constructors;
minor code restructure.
* sem_ch3.adb (Process_Full_View): Propagate Needs_Construction from
the partial view to the full view.
* sem_ch4.adb (Extended_Primitive_Ops): Add callable constructors to
the extended primitive operations when available; otherwise, add
abstract constructors so that we can diagnose wrong calls to them.
* sem_ch6.adb (Analyze_Direct_Attribute_Definition) <Name_Constructor>:
add missing support for abstract constructors. Report an error on
abstract constructors not declared in the visible part of a package.
(New_Overloaded_Entity): Add support for a private constructor to
complete a public abstract constructor and link them with the
Overridden_Operation attribute.
* sem_ch7.adb (Inspect_Abstract_Constructors_Completion): New subprogram
that checks if every abstract constructor in the visible part of the
package has a matching counterpart constructor in its private part.
(Analyze_Package_Specification): After analysing private declarations,
call Inspect_Abstract_Constructors_Completion.
* sem_util.ads (Collect_Constructors): New subprogram that collects
all non-hidden constructors into two lists: Callable (non-abstract)
constructors, and abstract constructors.
* sem_util.adb (Collect_Constructors): Ditto.
Eric Botcazou [Fri, 12 Jun 2026 15:35:11 +0000 (17:35 +0200)]
ada: Fix couple of issues with membership tests for tagged types
The first issue is that the special case for tagged types mentioned in the
RM 4.5.2(3.1) rule is not implemented, leading to legal code being rejected.
The second issue is that the RM 4.5.2(30-30.3) dynamic semantic rules are
not correctly implemented when both tested expression and tested type are
of a specific tagged type, leading to a wrong run-time outcome of the test.
The changes are mostly straightforward, except for the unexpected fallout
for the implementation of the RM 6.5(8.2) rule prescribing a tag check for
an anonymous access return designating a specific tagged type, which was
implemented using a direct membership test on tagged types, and now needs
to be changed to use an indirect membership test on tagged types, which is
not affected by the adjusted implementation of dynamic semantic rules.
gcc/ada/ChangeLog:
* accessibility.adb (Accessibility_Level): Deal with the associated
entity created during expansion for 'Old attribute references.
* exp_ch4.ads (Tagged_Membership): New declaration from...
* exp_ch4.adb (Tagged_Membership): ...here. Retrieve the designated
types first, if any. Do not retrieve the root type of a CW type for
the left operand, instead compute a full type for this operand. Do
not generate a tag equality test in the direct case if both left and
right operands are of specific tagged type.
(Expand_N_In): In the anonymous access type case, pass the left
operand directly to the Accessibility_Level routine.
* exp_ch6.adb: Add clauses for SCIL_LL package.
(Expand_Simple_Function_Return): Use an indirect membership test to
implement the tag check for an anonymous access return designating
a specific tagged type.
* sem_ch4.adb (Analyze_Membership_Op): Deal specifically with a
right operand that denotes a tagged type.
* sem_res.ads (Valid_Tagged_Conversion): New declaration from...
* sem_res.adb (Valid_Tagged_Conversion): ...here.
(Resolve_Membership_Op): Deal specifically with a right operand that
denotes a tagged type and remove obsolete special case.
(Valid_Conversion): Adjust calls to Valid_Tagged_Conversion.
* sem_type.adb (Intersect_Types): Minor tweaks.
Tobias Burnus [Mon, 22 Jun 2026 09:04:41 +0000 (11:04 +0200)]
OpenMP/Fortran: Split-off check_omp_clauses_dupl_syms from resolve_omp_clauses
Move all duplicate checks from resolve_omp_clauses to an extra function
and call it; note that the check is based on n->sym such that the
n->expr does not need to be resolved.
gcc/fortran/ChangeLog:
* openmp.cc (check_omp_clauses_dupl_syms): New; moved code from ...
(resolve_omp_clauses): ... here. Call new function.
Suggested-by: Julian Brown <julian@codesourcery.com>
This patch removes the const keyword from the second parameter of
extract_quoted_files. The function actually does modify the string
passed through that parameter. Moreover, clang currently produces a
warning when compiling this file since in C23, strrchr of a const char *
returns const char *. This patch gets rid of that warning.
I've also stumbled upon some trailing whitespace so I removed that too.
Bootstrapped and regtested on x86_64 linux. I would push this as
trivial, but this is the first time I'm modifying fixincludes, so I'm
trying to be careful.
Georg-Johann Lay [Sat, 20 Jun 2026 12:25:54 +0000 (14:25 +0200)]
AVR: Support to print nodes brief and recursive.
This patch adds a new format %N to the avr_xdump functions.
The purpose is to print a tree node, usually a DECL_P or
a TYPE_P in a recursive form that's not too verbose.
For example:
typedef int (* const __flash fun_t)(long, int);
int foo (fun_t (*f[][4]), int x, int y)
{
return (*f[x][y]) (x, y);
}
will print with -mlog=insert_attributes, amongst others:
Avinash Jayakar [Mon, 22 Jun 2026 05:20:41 +0000 (10:50 +0530)]
testsuite: Split spaceship_mixed_variants tests containing long long as input arg
The test spaceship_mixed_variants.c failed on ilp32 targets since the
targets will not have a DI mode spaceship optab, and thus the spaceship
optimization would not happen.
Separated out the tests that contain long long as input argument to the
spaceship optab to a different test file with appropriate target checks
done for the test.
2026-06-22 Avinash Jayakar <avinashd@ibm.com>
gcc/testsuite/ChangeLog:
* gcc.dg/spaceship_mixed_variants.c: Split long long arg tests
in a different file.
* gcc.dg/spaceship_mixed_variants_ll.c: New test.
Move the code for ALLOCATE clause checking out of resolve_omp_clauses into
a new function. Additionally, the all-enclosing if condition block is
replaced by an early return; likewise, an inner if condition block that
stretched to the end of the outer one is replaced by a second early
return. Hence, a lot of code could be shifted 4 or 8 columns to the left.
Except for the re-indentation, the early exit changes to the two if
conditions and to two variable declarations, the code is identical.
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_allocate_clauses): New function for
resolving 'allocate' clauses, splitt-off from ...
(resolve_omp_clauses): ... here. Call the new function.
Suggested-by: Julian Brown <julian@codesourcery.com>
The problem was that the optimization done for PR 57073 uses powi and
friends, so it only applied to default integer exponent. The test
case has an integer(kind=8) exponent, which is is calculated by
calling a gfortran library function.
There are two possible approaches: One would be to convert all
integer types to default integer (because only the lowest-value
bit matters to the result) and call the right __builtin_powi function.
However, the generated code is suboptimal, see PR 125919. I therefore
chose the variant which currently generates the best code.
This requires the change to the power_6.f90 test case.
Pan Li [Tue, 16 Jun 2026 05:42:42 +0000 (13:42 +0800)]
RISC-V: Add testcase for unsigned scalar SAT_MUL form 13
The form 12 of unsigned scalar SAT_MUL has supported from
the previous change. Thus, add the test cases to make sure
it works well.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_arith.h: Add test helper macros
* gcc.target/riscv/sat/sat_u_mul-14-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u16-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u16-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u32-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u32-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u8-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-14-u8-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-14-u8-from-u64.c: New test.
Jerry DeLisle [Mon, 15 Jun 2026 18:58:31 +0000 (11:58 -0700)]
libfortran: [PR114618] Format produces incorrect output when contains 1x
When tabbing left or right it is possible to land in the format buffer
where some text is over written or skipped improperly. The bad formatting
depended on whether stream I/O is used or regular I/O. The max position
has to be calculated correctly in these situations.
One existing test case is renamed to align with other format T/TL/TR
test cases.
PR libfortran/114618
libgfortran/ChangeLog:
* io/transfer.c (formatted_transfer_scalar_write): Determine
possible new max_pos based on file I/O method and adjust
accordingly
Jason Merrill [Fri, 19 Jun 2026 21:43:44 +0000 (17:43 -0400)]
c++: capture folding and lvalueness checking [PR125408]
Here after the recursive mark_rvalue_use we end up with a VAR_DECL in r, so
the assert fails. But in that case r is still an lvalue, so we don't need
to do any adjustment.
Fixed by adjusting the condition to detect the case we actually need to fix
up, i.e. when ref is an lvalue and r is not. The previous !rvalue_p
condition doesn't make much sense; rvalue_p indicates whether we want to do
an lvalue-rvalue conversion on expr, not whether expr was already an rvalue.
PR c++/125408
gcc/cp/ChangeLog:
* expr.cc (mark_use): Fix condition for changing rvalue to lvalue.
Jason Merrill [Sat, 20 Jun 2026 22:23:09 +0000 (18:23 -0400)]
c++: typedef in lambda in pack expansion
In trying to reduce the testcase for PR125408, I came across an older
regression, dating back to r14-9938, though the problem wasn't in that
commit.
cp_walk_subtrees avoids walking into uses of typedefs because it wants to
look at what's actually written. But here we were also skipping over the
definition of the typedef, so extract_locals_r never got to see the use of
't', so later substitution failed.
Fixed by specifically handling typedef DECL_EXPR.
PR c++/125408
gcc/cp/ChangeLog:
* tree.cc (cp_walk_subtrees): Walk into the DECL_ORIGINAL_TYPE of a
typedef DECL_EXPR.
Iain Sandoe [Tue, 9 Jun 2026 06:27:12 +0000 (07:27 +0100)]
aarch64: Use LLONG_MAX instead of LONG_LONG_MAX
A recent change to aarch64-builtins.cc broke the build on Darwin.
This is because it expects LONG_LONG_MAX to be defined. However, from the
inclusion of limits.h, we can really only expect LLONG_MAX to be defined
as per the descriptions for limits.h in the language standards.
So this swaps LLONG_MAX for LONG_LONG_MAX.
gcc/ChangeLog:
* config/aarch64/aarch64-builtins.cc
(aarch64_expand_prefetch_range_builtin): Use LLONG_MAX instead
of LONG_LONG_MAX.
Jerry DeLisle [Sat, 20 Jun 2026 01:37:52 +0000 (18:37 -0700)]
fortran: namelist read with repeat count fails when member of array
When processing a namelist with a repeat count and the object is a
component of a derived type, we need to go through the components
and update each one.
PR fortran/82086
libgfortran/ChangeLog:
* io/list_read.c (nml_read_obj): Add is_component parameter
to correctly distribute repeat count across derived-type array
elements.
Iain Sandoe [Sun, 5 May 2024 23:01:36 +0000 (00:01 +0100)]
testsuite, darwin: Handle Darwin LTO section names.
This recognises the .section __GNU_LTO, segment prefix used by Darwin
to skip LTO sections there and splits this into a separate function
since it is used several times.
Roger Sayle [Sat, 20 Jun 2026 09:02:34 +0000 (10:02 +0100)]
i386: Avoid calling gen_lowpart for V2DImode on DDmode register.
Hongtao did warn me there might be corner cases in STV when
converting DImode SUBREGs to use V2DImode vector registers.
https://gcc.gnu.org/pipermail/gcc-patches/2026-May/718615.html
is exactly such a case, where with -m32 -O2 -march=cascadelake
we attempt to convert a comparison containing (subreg:DI (reg:DD) 0)
where the resulting call to gen_lowpart (V2DImode, ...) triggers
an ICE. It's the lack of transitivity: DDmode may be SUBREGed to
DImode, and DImode may be SUBREGed to V2DImode, but DDmode can't
(directly) be SUBREGed to V2DImode.
Alas my attempts to reduce a testcase (simpler than the one
already in the testsuite) haven't be successful... The example
below contains the problematic SUBREG in a comparison, but in
this case, STV doesn't consider converting the chain profitable.
void foo()
{
__decfloat64 t = ext();
if (__builtin_memcmp((void*)&t,(void*)&x,sizeof(__decfloat64)) != 0
&& __builtin_memcmp((void*)&t,(void*)&y,sizeof(__decfloat64)) != 0
&& __builtin_memcmp((void*)&t,(void*)&z,sizeof(__decfloat64)) != 0) {
x = t;
y = t;
z = t;
}
}
Fortunately, the proposed fix is relatively straight forward, using
modes_tieable_p and validate_subreg to check that the source pseudo is
representable in an SSE register. When originally written, this code
was expecting V1TImode, V2DImode or V4SImode. If this isn't a simple
SUBREG, STV can emit a move instruction (to preserve it), then operate
on the resulting pseudo (as usual).
2026-06-20 Roger Sayle <roger@nextmovesoftware.com>
Hongtao Liu <hongtao.liu@intel.com>
gcc/ChangeLog
* config/i386/i386-features.cc (scalar_chain::convert_op): Check
if the (DImode) SUBREG being converted by STV has an original mode
that's tieable to the vector mode (V2DImode), if not (e.g. DDmode)
emit this "conversion" as a separate move for reload to handle.
Tamar Christina [Sat, 20 Jun 2026 08:42:59 +0000 (09:42 +0100)]
testsuite: fix UB in vect-early-break_144-pr125804.c [PR125871]
The PR reports a failure on -m32 that I can't seem to
reproduce on my x86_64 machine..
However cvise (I gave the compiler as many flags I
could think of to prevent this) did give me a
reproducer that has some UB in it wrt to signed
shifts on 32-bit systems.
So this fixed the UBs and hopefully that fixes
the reported failure.
gcc/testsuite/ChangeLog:
PR testsuite/125871
* gcc.dg/vect/vect-early-break_144-pr125804.c: New test.
Robert Dubner [Sat, 20 Jun 2026 01:21:48 +0000 (21:21 -0400)]
cobol: Improve binary conversion from packed-decimal and numeric-display.
There are routines that create GENERIC conversion routines that convert
packed-decimal and numeric-display variables to binary. Some are in
libgcobol, and some have direct GENERIC implementations. All have been
updated to use faster divide-and-conquer algorithms.
The new routines are ten to twenty times faster than the prior versions.
gcc/cobol/ChangeLog:
* genapi.cc (parser_enter_file): Establish a var_decl for the
common packed-decimal to binary conversion table.
* genutil.cc (digit): Divide-and conquer numeric-display converter.
(num_disp_dive): Likewise.
(pd_dive): Divide-and-conqure packed-decimal converter.
(get_pd_value): Likewise.
(get_binary_value_tree): Use the new routines.
(binary_from_FldNumericBinary): Divide-and conquer numeric-display
converter.
* genutil.h: Declaration for var_decl_dp2bin.
* move.cc (mh_little_endian): Allow FldPacked as a source.
libgcobol/ChangeLog:
* charmaps.cc: Eliminate rt_encoding_t.
* libgcobol.cc (console_init): Change how __gg__console_encoding is
established.
(initialize_program_state): Likewise.
(get_binary_value_local): Use new conversion algorithms.
(__gg__move): Likewise.
* stringbin.cc (__gg__numeric_display_to_binary): Likewise.
(digit_rt): Likewise.
(num_disp_dive_rt): Likewise.
(pd_dive_rt): Likewise.
(__gg__packed_to_binary): Likewise.
* stringbin.h (STRINGBIN_H_): Declaration for __gg__dp2bin.
(__gg__numeric_display_to_binary): Use new algorithms.
(__gg__packed_to_binary): Likewise.
Kees Cook [Thu, 18 Jun 2026 19:56:51 +0000 (12:56 -0700)]
c: handle .ACCESS_WITH_SIZE in build_unary_op for !/+/- [PR125604]
PR123569 fixed wrong code with the counted_by attribute on a pointer
member by suppressing creation of the .ACCESS_WITH_SIZE wrapper in the
parser's pre/post-increment paths, and added a checking assertion in
build_unary_op to ensure no .ACCESS_WITH_SIZE call reaches it.
The other rvalue-consuming unary operators (!, -, +) still
rvalue-convert their operand via convert_lvalue_to_rvalue, which
produces the .ACCESS_WITH_SIZE wrapper as before. They then reach
parser_build_unary_op then build_unary_op carrying the wrapper and
trip the assertion. A minimal reproducer:
struct s {
int n;
char *p __attribute__((__counted_by__(n)));
};
int f (struct s *o) { return !o->p; }
Unwrap the .ACCESS_WITH_SIZE call at the top of build_unary_op via
get_ref_from_access_with_size. These unary operators consume the
pointer rvalue rather than the pointed-to data, so the bounds-checking
wrapper is not load-bearing here. The assertion is retained: after
the unwrap it documents the post-condition the rest of the function
relies on.
PR c/125604
gcc/c/ChangeLog:
* c-typeck.cc (build_unary_op): Unwrap .ACCESS_WITH_SIZE
from the operand before further processing.
Andrew Pinski [Thu, 18 Jun 2026 21:16:04 +0000 (14:16 -0700)]
ipa: Don't record return value ranges for pranges with non ipa-invariant [PR125857]
Now that pranges can have invariants in it, we need to make sure the
return value range does not record non-ipa invariants; otherwise we
might prop the address of a local variable from one function to
another.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/125857
gcc/ChangeLog:
* ipa-prop.cc (ipa_record_return_value_range_1): Don't record
pranges which have non ipa-invariants in it.
gcc/testsuite/ChangeLog:
* gcc.dg/pr125857-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Iain Sandoe [Fri, 19 Jun 2026 18:54:53 +0000 (19:54 +0100)]
aarch64: Handle vec_deconstruct in vector_costs code.
r17-1655-g7d351b07e5b85c introduces 'vec_deconstruct' which needs to
be handled in the aarch64_vector_costs::count_ops code, leading to a
bootstrap fail.
gcc/ChangeLog:
* config/aarch64/aarch64.cc
(aarch64_vector_costs::count_ops): Treat vec_deconstruct in the
same way as vec_construct.
Peter Bergner [Thu, 18 Jun 2026 04:33:03 +0000 (04:33 +0000)]
riscv: Change tt-ascalon-d8 to tt-ascalon-x
The Ascalon cpu's official marketing name is Ascalon X. Change the -mcpu=
and -mtune= options to accept tt-ascalon-x as the cpu's canonical name.
Create an alias name so the old option names are still accepted.
2026-06-17 Peter Bergner <bergner@tenstorrent.com>
gcc/
* config/riscv/riscv-cores.def (RISCV_TUNE)<tt-ascalon-d8>: Rename from
this...
(RISCV_TUNE)<tt-ascalon-x>: ...to this.
(RISCV_CORE)<tt-ascalon-d8>: Likewise.
(RISCV_CORE)<tt-ascalon-x>: Likewise.
(RISCV_CORE_ALIAS): Add tt-ascalon-d8 alias for tt-ascalon-x.
* doc/riscv-mcpu.texi: Document the name change.
* doc/riscv-mtune.texi: Likewise.
Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
Peter Bergner [Thu, 18 Jun 2026 04:11:09 +0000 (04:11 +0000)]
riscv: Add support for alias names for cpus
Some cpus are known by multiple names or have their name changed after
support has already been added to GCC. Add support to the riscv port
that allows setting up alternate names or aliases for a cpu's canonical
name.
2026-06-17 Peter Bergner <bergner@tenstorrent.com>
gcc/
* common/config/riscv/riscv-common.cc (struct riscv_cpu_alias_info):
New struct.
(riscv_cpu_alias_table): New.
(riscv_find_cpu): Add support for cpu alias names.
(riscv_get_valid_option_values): Likewise.
Add an early loop exit if we found a duplicate name.
* config/riscv/riscv-cores.def (RISCV_CORE_ALIAS): New macro.
Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
Kanishka Solanki [Fri, 19 Jun 2026 16:25:51 +0000 (21:55 +0530)]
a68: remove redundant HAS_ROWS check from caller side of a68_low_dup
This patch removes redundant caller-side HAS_ROWS checks before calls to
a68_low_dup.
a68_low_dup originally always performed a deep copy, so callers avoided
invoking it for values without rows by checking HAS_ROWS beforehand.
a68_low_dup now performs its own HAS_ROWS check and returns the original
expression unchanged when a deep copy is not required. Remove the
remaining caller-side HAS_ROWS checks, as they are redundant.
gcc/algol68/ChangeLog
* a68-low-clauses.cc (a68_lower_collateral_clause): Do not check
for rows before calling a68_low_dup.
* a68-low-units.cc (collect_call_arguments): Likewise.
Andrew Pinski [Wed, 17 Jun 2026 23:09:40 +0000 (16:09 -0700)]
phiopt: Add support for non-zero offsets for load factoring [PR122193]
This extends the factor_out_conditional_load to support non-zero offsets
for the MEM_REF. And fixes PR 122193.
It tries not to create gimple statements that don't need to be created.
E.g. If the base is the same then it creates the pointer plus in the join
bb rather than the in the middle bbs. Also uses gimple_build for the pointer
plus so that the if one of the offsets was 0, a new statement is not created.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122193
gcc/ChangeLog:
* tree-ssa-phiopt.cc (factor_out_conditional_load): Support non-zero
offsets.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/factor_op_phi-load-offsets-1.c: New test.
* gcc.dg/tree-ssa/factor_op_phi-load-offsets-2.c: New test.
* gcc.dg/tree-ssa/factor_op_phi-load-offsets-3.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Mon, 15 Jun 2026 05:23:00 +0000 (22:23 -0700)]
phiopt: Allow factoring out loads even if there are stores
This is a small improvement to the code where we allow factoring
out loads even with stores (or calls) before hand, this will allow
for store elimination (store factoring) to happen too.
factor_op_phi-load-stores-1.c is one such example.
Also adds the cost model to factoring out loads.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-phiopt.cc (is_factor_profitable): Change arg_op
to operands and opcount.
(factor_out_conditional_operation): Update call to
is_factor_profitable.
(factor_out_conditional_load): Support when merge has
a virtual phi. The load's vuse needs to be the arguments
to the virtual phi. Call is_factor_profitable on the new phi
arguments. Update the vuse on the new load to the virtual phi.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/factor_op_phi-load-stores-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Fri, 12 Jun 2026 19:52:18 +0000 (12:52 -0700)]
phiopt: Simplified factoring of loads [PR125557]
This is a simplified version that I was mentioning.
It is based on https://gcc.gnu.org/pipermail/gcc-patches/2026-June/720170.html
but only handing in phi-opt. It is able to optimize
what is requested and will not have the regression dealing
with vectorization. There are some more tweaks we can do
to handle some more stuff.
Like before vectorization, if the two pointers are the same we should do
the factoring. Or handling stores before the load which will allow
us to iterate better with cs-elim limited. We can also tweak the
before vectorization cost to be rather based on if it just inside
a loop into what was done in the full patch. For the benchmark improvement
that was not needed.
Changes since v1:
* v2: the factoring needs to be done on a diamond only, and the loads need to
come from the middle bbs.
PR tree-optimization/125557
gcc/ChangeLog:
* tree-ssa-phiopt.cc (factor_out_conditional_load): New function.
(factor_out_all): Call factor_out_conditional_load.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/scc-diamond-1.c: New test.
* gcc.dg/tree-ssa/scc-diamond-3.c: New test.
* gcc.dg/tree-ssa/scc-diamond-4.c: New test.
* gcc.target/aarch64/scc-diamond-2.c: New test.
Eric Botcazou [Tue, 9 Jun 2026 09:11:54 +0000 (11:11 +0200)]
ada: Fix spurious error on Ada 2022 declare expression of limited type
The underlying problem is that declare expressions are implemented by means
of a temporary in most cases and that's incompatible with limited types.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Expression_With_Actions): Create a temporary
only for types that can be copied, and replace the EWA node by its
expression for other types.
* exp_ch6.adb (Expand_Ctrl_Function_Call): Bail out when the parent
is an EWA node.
* sem_ch3.adb (OK_For_Limited_Init_In_05): Recurse on the expression
of an EWA node.
The Build_And_Insert_Type_Attr_Subp procedure sometimes uses the
declaration list of a subprogram body ancestor even when the point of
reference is inside the statement list. Before this patch, this caused
an assertion failure (and a failure to hoist with assertions disabled)
when the declaration list of the body was empty. This patch fixes this.
gcc/ada/ChangeLog:
* exp_attr.adb (Spot, Spot_Kind): New types.
(Build_And_Insert_Type_Attr_Subp, Skip_Non_Source_Subps,
Find_Insertion_Point_For_Ancestor): Handle case of empty body
declaration list.
Eric Botcazou [Fri, 5 Jun 2026 21:24:59 +0000 (23:24 +0200)]
ada: Fix long-standing issue in static accessibility check for allocators
This has been exposed by the latest change made to Resolve_Allocator: the
constraints of a subtype indication are not necessarily given in the same
order as the discriminants of the base type in the source code.
gcc/ada/ChangeLog:
* sem_res.adb (Check_Discriminant_Use): Rename PN local variable as
Par and apply minor formatting tweaks.
(Resolve_Allocator): For the subtype indication form, make sure to
take the constraints of a subtype into account instead of those of
the indication in order to implement the static accessibility check.
Olivier Hainque [Thu, 4 Jun 2026 12:02:23 +0000 (12:02 +0000)]
ada: Straigthen Call_Chain and __gnat_backtrace processing
Work on cross-testsuite/ta20_015__exc_traceback exposed
that calls to GNAT.Traceback.Call_Chain, in some configurations,
yield a first entry within Call_Chain rather than at the
call point.
This is supposed to be controlled by a careful computation
of a number of frames to skip, passed down as the SKIP_FRAMES
parameter to __gnat_backtrace in tracebak.c.
Roughly:
```
subprogramA
calls subprogramB
calls GNAT.TB.Call_Chain (Skip_Frames => 1)
calls System.TB.Chain (Skip_Frames => 2)
calls __gnat_backtrace (skip_frames => 3)
Actual backtrace at this point is
1 __gnat_backtrace
2 System.TB.Call_Chain
3 GNAT.TB.Call_Chain
4 spB
5 spA
Skip the first 3 frames -> return
[spB, spA]
```
Within tracebak.c, the skip operation is influenced
by micro details of the semantics of a BASE_SKIP macro,
which was imprecisely documented.
I first thought the fault was in the value for this macro
in a couple of configurations, while it was entirely elswehere.
There were two issues aside from the BASE_SKIP documentation
(in)accuracy:
1 GNAT.Traceback exposes a Call_Chain procedure and a Call_Chain
function.
The function has a Skip_Frames parameter, with a default value,
and a description of how it operates wrt that parameter.
The procedure doesn't accept a parameter, the spec was imprecise
and the behavior was different from that of the function with
the default parameter value.
2 The way Skip_Frames values propagate down to __gnat_backtrace
require the internal calls within the runtime to materialze as actual
calls (and call frames) at run-time. This requires preventing
inlining and sibling call optimization, which was achieved with
dedicated compilation switches for s-traceb.adb and overlooked
for g-traceb.adb.
This patch addresses these combined points together:
gcc/ada/ChangeLog:
* tracebak.c: Improve documentation of BASE_SKIP.
* libgnat/g-traceb.ads (Call_Chain procedure): Clarify the
expected behavior wrt Call_Chain itself.
* libgnat/g-traceb.adb (Call_Chain procedure): Propagate
a Skip_Frames value to System.TB.Call_Chain accordingly.
* libgnat/libgnat.gpr: Use the same special switches for
g-traceb.adb as for s-traceb.adb.
* Makefile.rtl: Likewise.
* libgnat/s-traceb.adb: Reword top comment on the need
to prevent optimizations. No need to specify how to do it
here.
Eric Botcazou [Sun, 7 Jun 2026 20:30:56 +0000 (22:30 +0200)]
ada: Fix missing names for 'Image of enumeration type
This is a freezing issue introduced by the recent coupling of assertions and
Ghost mode, which are supposed to use different paths in the freezing code.
In light of this, it appears to be wise to undo the coupling and restore the
clear separation between the two different mechanisms. The price to pay is
the loss of the "assertion would fail at run time" warning for non-static
assertions that are disabled (it is still present for static assertions),
which seems to be an acceptable trade-off to avoid nasty freezing issues.
gcc/ada/ChangeLog:
* expander.adb (Expand): Revert latest change.
* ghost.adb (Set_Ghost_Mode): Likewise.
* sem_ch3.adb (Analyze_Subtype_Declaration): Also copy the RM size
for floating-point types.
* sem_prag.adb (Analyze_Pragma) <Pragma_Check>: Do not mark the
pragma as Ghost when expander is active and the pragma is ignored.
Preanalyze it instead of analyzing it, and rewrite it as a null
statement at the end of the processing.
Init_Or_Norm_Scalars was a global variable used to store the boolean
disjunction of two other global variables. This patch replaces it with
an expression function to make things simpler.
Restructure mem_ref_hasher::equal so the non-decomposed fallback
and the decomposed comparison path are explicit. The non-decomposed
lookup still compares the original refs with operand_equal_p, while
the decomposed path keeps the same base, offset, size, max_size,
volatile, alias-set, and type checks as before. This matches the split
in gather_mem_refs_stmt, where non-decomposed references are marked
with an unknown max_size and decomposed references are hashed from
base, offset, and size.
* tree-ssa-loop-im.cc (mem_ref_hasher::equal): Refactor
for clarity.
Arsen Arsenović [Fri, 19 Jun 2026 09:13:21 +0000 (11:13 +0200)]
gcc/doc: Move @anchor-s referring to top of node after their @node
Previously, the anchors would end up generating redirects to the end of
unrelated nodes, rather than to the start of nodes we intended to
target. This fixes that.
gcc/ChangeLog:
* doc/extend.texi: Move @anchor-s referring to tops of nodes
after their corresponding @node lines.
* doc/invoke.texi: Ditto.
Reported-by: Alexander Monakov <amonakov@ispras.ru>
Eric Botcazou [Thu, 18 Jun 2026 09:08:39 +0000 (11:08 +0200)]
Adjust configure machinery to abi32 targets
The machinery would still consider them as 64-bit targets in a few cases.
gcc/
* acinclude.m4 (gcc_GAS_FLAGS): Set to --32 for abi32 targets.
* configure.ac (TLS support): Use 32-bit sequence for abi32 targets.
* configure: Regenerate.
Eric Botcazou [Wed, 17 Jun 2026 08:07:41 +0000 (10:07 +0200)]
Fix wrong optimization of array manipulation at -O2 or above
This occurs when the array is declared in a subprogram and manipulated from
within a second subprogram nested in the first: in this case, the array is
allocated in the special frame structure of the first subprogram as a field
with the DECL_NONADDRESSABLE_P flag set if the TREE_ADDRESSABLE flag is not
set for the original array variable. But the array may contain addressable
(sub)components whose address can be taken, thus fooling the computation of
alias sets when strict aliasing is enabled.
The fix is in keeping with the usage of DECL_NONADDRESSABLE_P on fields of
record types by the Ada compiler, which is the main user of both the flag
and the machinery implemented in the tree-nested.cc file.
gcc/
* tree-nested.cc (lookup_field_for_decl): In the non-pointer case,
clear DECL_NONADDRESSABLE_P if the DECL is of an aggregate type.
gcc/testsuite/
* gnat.dg/opt108.adb: New test.
* gnat.dg/opt108_pkg.ads, gnat.dg/opt108_pkg.adb: New helper.
[PATCH] match: Optimize bit_ior/bit_and {bit_not} rshift to min/max [PR125641]
Fold x | (x >> (TYPE_PRECISION (type) - 1)) to max (x, -1)
Fold x | (~ (x >> (TYPE_PRECISION (type) - 1))) to min (x, -1)
Fold x & (x >> (TYPE_PRECISION (type) - 1)) to min (x, 0)
Fold x & (~ (x >> (TYPE_PRECISION (type) - 1))) to max (x, 0)
Bootstrapped and tested on x86_64-pc-linux-gnu
PR tree-optimization/125641
gcc/ChangeLog:
PR tree-optimization/125641
* match.pd: Add bit_ior/bit_and {bit_not} rshift to min/max.
gcc/testsuite/ChangeLog:
PR tree-optimization/125641
* gcc.dg/pr125641.c: New test.
clean: Removed orphaned comments from deleted imports.
Hello!
This patch removes comments that used to refer to imports, which
were deleted in some import clean-ups that happened years ago.
I did a brief tour of the code and did not notice any other such
orphaned comment.
For convenience of reviewing, here are the links to the mentioned
commits. Notice that these diffs created the orphaned comments.
- For ddg.h:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=60393bbc
- For sel-sched-ir.h:
gcc.gnu.org/git/?p=gcc.git;a=commit;h=c7131fb
- For trans-intrinsic, objc-act, objc-encoding:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=69f293c
As for testing, I don't think comments could affect the target
binary, but I have nevertheless successfully bootstrapped gcc
with these changes applied.
gcc/ChangeLog:
* ddg.h (GCC_DDG_H): Removed orphaned comment from 60393bbc
* sel-sched-ir.h (GCC_SEL_SCHED_IR_H): Removed orphaned comment from c7131fb
gcc/fortran/ChangeLog:
* trans-intrinsic.cc: Removed orphaned comment from 69f293c
gcc/objc/ChangeLog:
* objc-act.cc: Removed orphaned comment from 69f293c
* objc-encoding.cc: Removed orphaned comment from 69f293c
Milan Tripkovic [Thu, 18 Jun 2026 23:51:59 +0000 (17:51 -0600)]
[PATCH] PR tree-optimization/125405: Missed optimization: mask/sub sign-extension idiom not canonicalized to sign extension
This patch implement new pattern for match.pd that recognize the
sign-extension idiom (x & low_bits) - (x & sign_bit) and tests that covers it.
Pattern is based on conversation from bug report.
TRUNK riscv output:
sext8_hd:
andi a5,a0,127
andi a0,a0,128
sub a0,a5,a0
ret
sext16_hd:
slli a5,a0,49
li a4,32768
srli a5,a5,49
and a0,a0,a4
sub a0,a5,a0
ret
NEW riscv output:
sext8_hd:
slliw a0,a0,24
sraiw a0,a0,24
ret
sext16_hd:
slliw a0,a0,16
sraiw a0,a0,16
ret
TRUNK x86 output:
"sext8_hd":
mov rax, rdi
and edi, 128
and eax, 127
sub rax, rdi
ret
"sext16_hd":
mov rax, rdi
and edi, 32768
and eax, 32767
sub rax, rdi
ret
new x86 output:
sext8_hd:
movsbq %dil, %rax
ret
sext16_hd:
movswq %di, %rax
ret
PR target/125405
gcc/ChangeLog:
* match.pd: New pattern added.
gcc/testsuite/ChangeLog:
* gcc.dg/pr125405-bitint.c: New test.
* gcc.dg/tree-ssa/pr125405.c: New test.
* gcc.target/riscv/pr125405.c: New test.
Jeff Law [Thu, 18 Jun 2026 22:56:31 +0000 (16:56 -0600)]
[RISC-V] Split X eq/ne C where -C is a small constant
This was something I found while analyzing paths forward for a patch from
Daniel.
Amazingly, RISC-V does not have anything like a setCC style insn that compares
a register against a constant. Instead we negate the constant and add it to
the source value. That gives us zero (equal) or nonzero (not equal). We
follow that with a snez/seqz to give us 0/1 like other setCC style
instructions.
If we have a 3 or more insns that ultimately combine into something like:
(set (dest) (eq (srcreg) (const_int))
We can use a define_split to rewrite that into a two instruction sequence which
is a small win. I'd suspected there was some value in this kind of splitter
for a while, but never had a testcase that could actually be improved. I wrote
the splitter and tested with Daniel's code, but more importantly, once I had
the basic splitter working, I could do a before/after comparison and look for
differences which I was able to find.
While the testcase came from 502.gcc, it's not hot at all. But it does clearly
show how the splitter can improve code.
Tested on riscv32-elf and riscv64-elf. Bootstraps on the K3 and c920 are in
flight. I'll wait for the bootstrap/regression tests as well as the pre-commit
CI testing before moving forward.
gcc/
* config/riscv/riscv.md (splitter for equality test): New splitter.
gcc/testsuite/
* gcc.target/riscv/test-equal.c: New test.
Thomas Schwinge [Mon, 11 May 2026 20:07:13 +0000 (22:07 +0200)]
libgomp: Prototype "accel" 'GOMP_INDIRECT_ADDR_MAP', 'GOMP_INDIRECT_ADDR_HMAP' in 'target-indirect.h'
..., instead of repeating 'extern' prototypes in all "accel" 'team.c' files
for 'GOMP_INDIRECT_ADDR_MAP' vs. no prototype for 'GOMP_INDIRECT_ADDR_HMAP',
as done in commit da5803c794d16deb461c93588461856fbf6e54ac
"libgomp: Init hash table for 'indirect'-clause of 'declare target' on the host [PR114445, PR119857]".
Thomas Schwinge [Mon, 11 May 2026 19:58:30 +0000 (21:58 +0200)]
libgomp: Prototype "accel" 'build_indirect_map' in new 'target-indirect.h'
..., instead of repeating 'extern' prototypes in all "accel" 'team.c'
files, as done in commit a49c7d3193bb0fd5589e12e725f5a130725ae171
"openmp: Add support for the 'indirect' clause in C/C++".
Thomas Schwinge [Mon, 11 May 2026 19:42:11 +0000 (21:42 +0200)]
libgomp: '#include "libgomp.h"' in 'libgomp/target-indirect.c'
..., as libgomp implementation files generally do. This gets us
'#include "libgomp_g.h"', which contains the prototype for
'GOMP_target_map_indirect_ptr'. Minor fix-up for
commit a49c7d3193bb0fd5589e12e725f5a130725ae171
"openmp: Add support for the 'indirect' clause in C/C++".
Thomas Schwinge [Mon, 11 May 2026 14:07:43 +0000 (16:07 +0200)]
libgomp: Drop unused 'ialias'es from 'libgomp/oacc-init.c'
They've always been unused, and, curiously, no 'ialias'es had ever gotten
added for any other 'libgomp/oacc-[...].c' files. Minor fix-up for
Subversion r219682 (Git commit 41dbbb3789850dfea98dd8984f69806284f87b6e)
"Merge current set of OpenACC changes from gomp-4_0-branch".
For no good reason, libgomp/GCN currently compiles the "full" (host)
'oacc-parallel.c', instead of the empty "accel" one. Minor fix-up for
Subversion r278132 (Git commit b3d14b3aa343eb7fc656e7f4d3c9b2dc04be63be)
"Move generic libgomp files from nvptx to accel", which moved other files
from 'libgomp/config/nvptx/' to 'libgomp/config/accel/'.
Paul Iannetta [Thu, 6 Oct 2022 14:34:00 +0000 (16:34 +0200)]
Make 'gcc/tree.h:ENCODE_QUAL_ADDR_SPACE' safer to use
As pointed out by Paul Iannetta in his
"[RFC] c++: parser - Support for target address spaces in C++". Fix-up for
Subversion r153572 (Git commit 09e881c9e21a9209b2092e400ea4c38948614f78)
"Named address spaces: core middle-end support".
Jerry DeLisle [Fri, 12 Jun 2026 01:50:37 +0000 (18:50 -0700)]
fortran: [PR125535] Plug remaining leak in implied-do array constructor with allocatable components
Follow-up to the PR fortran/125535 wrong-code fix (commit 1b8421e9d5b,
already pushed): that fix corrected the *values* produced by an
implied-do array constructor of derived-type function results with
allocatable components, but left a separate memory leak in the same
code path.
An array constructor whose implied-do produces function results of a
derived type with allocatable components moves each result into the
constructor temporary, so the temporary owns those components. The
per-element finalization in gfc_trans_array_ctor_element only freed
the single slot referenced by the final loop offset, leaking the
allocatable components of every other element the loop produced.
A whole-array sweep is the only way to free every slot written by an
implied-do, but it may be used only when every element is an owned
function result: a variable element is shallow-copied into the
temporary and its components are aliased rather than owned, so freeing
them would double free. Add gfc_constructor_is_owned_alloc_comp to
detect the all-owned case and, when it holds, suppress the per-element
finalization and emit a single gfc_deallocate_alloc_comp_no_caf over
the whole temporary.
PR fortran/125535
gcc/fortran/ChangeLog:
* trans-array.cc (gfc_constructor_is_owned_alloc_comp): New function.
(gfc_trans_array_constructor_value): Add OWNED_SWEEP parameter and,
when set, suppress the per-element finalization. Pass it through the
recursive call.
(trans_array_constructor): Compute OWNED_SWEEP and, when set,
deallocate the allocatable components of the whole temporary in one
sweep.
gcc/testsuite/ChangeLog:
* gfortran.dg/asan/implied_do_alloc_comp_leak_1.f90: New test.
Thomas Koenig [Sun, 14 Jun 2026 06:43:00 +0000 (08:43 +0200)]
Mark variables in references for variable definition context as used.
Code like "a(i) = 42" would not mark i as used, leading to false
positives for warnings with -Wunused-but-set-variable. This is fixed
in the attached patch. It also removes some default arguments to
make sure that the caller side provides correct information.
Robert Dubner [Thu, 18 Jun 2026 15:25:57 +0000 (11:25 -0400)]
cobol: Improved MOVE routines.
Faster routine for converting numeric-display numerical strings to
binary values. Improved conversion of binary values to big-endian
COMP-4 values.
gcc/cobol/ChangeLog:
* cbldiag.h (current_program_index): Suppress cppcheck warning.
(struct cbl_loc_t): Likewise.
* genutil.cc (get_depending_on_value_from_odo): Check subscript
against occurs-depending-on value.
(get_data_offset): Likewise.
(digit): Fast string-to-binary routine.
(num_disp_dive): Likewise.
(get_binary_value_tree): Likewise.
(copy_little_endian_into_place): Move the function to move.cc.
(get_location): Normalize use of "data" pointer versus using the
address of a known variable.
* genutil.h (copy_little_endian_into_place): Remove declarations.
* move.cc (get_reference_to_data): Eliminate function.
(mh_identical): Simplify the logic that uses get_location.
(copy_little_endian_into_place): Use the routine for both little-
and big-endian targets. Take absolute value of signed inputs when
the target is unsigned.
(mh_little_endian): Handle both little- and big-endian targets.
* symbols.cc (cbl_alphabet_t::cbl_alphabet_t): Suppress
cppcheck warning.
backprop: Don't try to delete default defs [PR125872]
In this PR, -fno-tree-dce meant that backprop was presented with code
that was completely dead. The pass's internal DCE then tried to delete
the function parameter's definition.
Andrew MacLeod [Wed, 17 Jun 2026 20:51:15 +0000 (16:51 -0400)]
Do not invoke a different range query from within fold_stmt.
fold_using_range works on a specified range_query object. IF this
object is not the current_range_query (cfun) object, do not invoke
the general gimple fold routines as they may call into the current
query.
PR tree-optimization/125854
gcc/
* gimple-range-fold.cc (fold_using_range::fold_stmt): Check if the
range_query matches the current one before invoking fold.
Marek Polacek [Wed, 17 Jun 2026 18:20:53 +0000 (14:20 -0400)]
c++: simplify condition in check_initializer
This condition has become unwieldy and hard to read.
In <https://gcc.gnu.org/pipermail/gcc-patches/2026-June/720712.html>
I tried to factor it out into a separate function but it works to
just drop the complicated inner disjunction. I ran the testsuite
checking if we exercise the case where the new and old conditions
evaluate to different values and many tests triggered that.
gcc/cp/ChangeLog:
* decl.cc (check_initializer): Don't call
build_aggr_init_full_exprs for {} of an aggregate.
Martin Jambor [Thu, 18 Jun 2026 12:55:33 +0000 (14:55 +0200)]
ipa-cp: Fix ipa-vr intersection in wrong type (PR124128)
Function ipa_vr_intersect_with_arith_jfunc in ipa-cp.cc contains a
check
if (src_type == dst_type)
which should have been
if (operation_type == dst_type)
which lead to an ICE in the ranger machinery as it tried to intersect
a signed and an unsigned integer when compiling the testcases from
PR124128.
The condition itself is basically an early exit to avoid calling yet
another ipa_vr_operation_and_type_effects to type-convert the value
range when we already can simply compare the types and see we already
have the righ thing. A better place for it is however just before
that conversion, where it can also avoid the call when dealing with
the most simple of pass-through jump functions (and where it generally
"makes more sense") so this is what the patch does.
gcc/ChangeLog:
2026-06-04 Martin Jambor <mjambor@suse.cz>
PR ipa/124128
* ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Move the check if
the final type conversion needs to happen before the conversion.
Martin Jambor [Thu, 18 Jun 2026 12:17:14 +0000 (14:17 +0200)]
fortran: Fix UBSAN error member access within null pointer (PR125860)
With UBSAN instrumented compiler, compiling the testcase
gfortran.dg/altreturn_5.f90 at -O3 fails with:
/home/worker/buildworker/ubsan/build/gcc/fortran/interface.cc:4717:27: runtime error: member access within null pointer of type 'struct gfc_expr'
This patch adds the necessary guard to avoid passing an invalid LOC to
gfc_value_set_and_used even when the EXPR parameter is NULL and the
function will just return. I have left the NULL-check in
gfc_value_set_and_used intact so that the behavior of the function is
consistent with gfc_value_used_expr (and possibly other functions).
gcc/fortran/ChangeLog:
2026-06-16 Martin Jambor <mjambor@suse.cz>
PR fortran/125860
* interface.cc (gfc_procedure_use): Check a->expr is not NULL before
calling gfc_value_set_and_used.
Richard Biener [Tue, 12 May 2026 12:48:41 +0000 (14:48 +0200)]
use recorded vector composition type for costing
We're making vector construction extra costly but too much
because we up to now do not know the actual vector composition
type used. This makes use of this now available information.
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Use vector construction scaling also for mult-lane
VMAT_STRIDED_SLP but use vector composition type recorded
to avoid excessive over-costing.
Richard Biener [Wed, 13 May 2026 12:14:19 +0000 (14:14 +0200)]
Split out ix86_vector_cd_cost
This implements costing of vector construction and decomposition
to a custom (possibly vector) element type to be used for vectorizer
costing of the corresponding operations when dealing with
VMAT_STRIDED_SLP loads and stores.
* config/i386/i386.cc (ix86_vector_cd_cost): New function,
enhanced and split out from ...
(ix86_default_vector_cost): ... here.
Richard Biener [Wed, 17 Jun 2026 11:19:56 +0000 (13:19 +0200)]
Add vec_deconstruct costing kind
The following adds vec_decostruct to replace nunits * vec_to_scalar
which allows for more precise costing whenever vectorization
needs to decompose a vector to pieces, like for emulated gather/scatter
but also for strided [SLP] loads/stores.
This requires changes across targets, both for the different kind
but also for the difference in expected count. For now this adjusts
them all to handle vec_deconstruct like vec_construct to avoid ICEing.
Richard Biener [Wed, 13 May 2026 12:22:01 +0000 (14:22 +0200)]
Also record ls element type for costing
I've realized that on x86 we get vector types as vector composition
element types, so just recording the ls_type isn't enough to
realize we're constructing a V4SI from V2SI elements. The following
adds such a field.
* tree-vectorizer.h (vect_load_store_data::ls_eltype): New field.
* tree-vect-stmts.cc (vectorizable_load): Record ltype
as ls_eltype for VMAT_STRIDED_SLP.
(vectorizable_store): Likewise.
Eric Botcazou [Fri, 5 Jun 2026 19:55:29 +0000 (21:55 +0200)]
ada: Fix missing accessibility check for allocator with access discriminant
This implements the last part of the RM 4.8(10.1) rule about allocators
for types with access discriminants. The implementation is modeled on
that of returns for types with access discriminants, given that the set
of rules applying to them is the same (RM 3.10.2(12-12.4)).
The change also streamlines the latter by applying the RM 3.10.2(12.4)
rule in Apply_Accessibility_Check_For_Discriminated_Return.