Gaius Mulley [Mon, 5 May 2025 17:16:20 +0000 (18:16 +0100)]
PR modula2/120117: ICE when attempting to obtain the MAX of an aliased set type
The ICE occurred because of a bug in M2GenGCC.mod:FoldBecomes which
attempted to remove the same quadruple twice. Thereafter cc1gm2
generated an erroneous error type error as PCSymBuild did not skip
an aliased set type. The type of the const was set incorrectly
(as a set type) rather than the type of the set element.
gcc/m2/ChangeLog:
PR modula2/120117
* gm2-compiler/M2GenGCC.mod (FoldBecomes): Remove the call to
RemoveQuad since this is performed by TypeCheckBecomes.
* gm2-compiler/PCSymBuild.mod (buildConstFunction): Rewrite
header comment.
Check for a set or a type aliased set and appropriately
skip type equivalences and obtain the element type.
* gm2-compiler/SymbolTable.mod (PutConst): Add call to
CheckBreak.
gcc/testsuite/ChangeLog:
PR modula2/120117
* gm2/pim/pass/highbit.mod: New test.
* gm2/pim/pass/highbit2.mod: New test.
Andrew MacLeod [Fri, 2 May 2025 19:48:08 +0000 (15:48 -0400)]
Allow IPA_CP to handle UNDEFINED as VARYING.
When applying a bitmask to reflect ranges, it is sometimes deferred and
this can result in an UNDEFINED result. IPA is not expecting this, and
add a check for it, and convert to VARYING if encountered.
PR tree-optimization/120048
gcc/
* ipa-cp.cc (ipcp_store_vr_results): Check for UNDEFINED.
Kyle Huey [Fri, 2 May 2025 00:13:47 +0000 (17:13 -0700)]
dwarf2out: Propagate dtprel into the .debug_addr table in resolve_addr_in_expr
For a debugger to display statically-allocated[0] TLS variables the compiler
must communicate information[1] that can be used in conjunction with knowledge
of the runtime enviroment[2] to calculate a location for the variable for
each thread. That need gives rise to dw_loc_dtprel in dwarf2out, a flag tracking
whether the location description is dtprel, or relative to the
"dynamic thread pointer". Location descriptions in the .debug_info section for
TLS variables need to be relocated by the static linker accordingly, and
dw_loc_dtprel controls emission of the needed relocations.
This is further complicated by -gsplit-dwarf. -gsplit-dwarf is designed to allow
as much debugging information as possible to bypass the static linker to improve
linking performance. One of the ways that is done is by introducing a layer of
indirection for relocatable values[3]. That gives rise to addr_index_table which
ultimately results in the .debug_addr section.
While the code handling addr_index_table clearly contemplates the existence of
dtprel entries[4] resolve_addr_in_expr does not, and the result is that when
using -gsplit-dwarf the DWARF for TLS variables contains an address[5] rather
than an offset, and debuggers can't work with that.
This is visible on a trivial example. Compile
```
static __thread int tls_var;
int main(void) {
tls_var = 42;
return 0;
}
```
with -g and -g -gsplit-dwarf. Run the program under gdb. When examining the
value of tls_var before and after the assignment, -g behaves as one would
expect but -g -gsplit-dwarf does not. If the user is lucky and the miscalculated
address is not mapped, gdb will print "Cannot access memory at address ...".
If the user is unlucky and the miscalculated address is mapped, gdb will simply
give the wrong value. You can further confirm that the issue is the address
calculation by asking gdb for the address of tls_var and comparing that to what
one would expect.[6]
Thankfully this is trivial to fix by modifying resolve_addr_in_expr to propagate
the dtprel character of the location where necessary. gdb begins working as
expected and the diff in the generated assembly is clear.
[0] Referring to e.g. __thread as statically-allocated vs. e.g. a
dynamically-allocated pthread_key_create() call.
[1] Generally an offset in a TLS block.
[2] With glibc, provided by libthread_db.so.
[3] Relocatable values are moved to a table in the .debug_addr section, those
values in .debug_info are replaced with special values that look up indexes
in that table, and then the static linker elsewhere assigns a single per-CU
starting index in the .debug_addr section, allowing those special values to
remain permanently fixed and the resulting data to be ignored by the linker.
[4] ate_kind_rtx_dtprel exists, after all, and new_addr_loc_descr does produce
it where appropriate.
[5] e.g. an address in the .tbss/.tdata section.
[6] e.g. on x86-64 by examining %fsbase and the offset in the assembly
2025-05-01 Kyle Huey <khuey@kylehuey.com>
* dwarf2out.cc (resolve_addr_in_expr): Propagate dtprel into the address
table when appropriate.
Eric Botcazou [Mon, 5 May 2025 10:58:58 +0000 (12:58 +0200)]
Ada: Fix assertion failure on Finalizable aspect for tagged record type
This is a (benign) assertion failure on the mainline for the new Finalizable
aspect put on a tagged record type when not all the primitives are declared.
This compiles and runs on the 15 branch because assertions are disabled.
gcc/ada/
PR ada/120104
* exp_ch3.adb (Expand_Freeze_Record_Type): For a controlled tagged
type, freeze only the controlled primitives that are present.
gcc/testsuite/
* gnat.dg/specs/finalizable1.ads: New test.
Simon Martin [Mon, 5 May 2025 08:37:52 +0000 (10:37 +0200)]
c++: Remove obsolete prototype
I noticed while investigating PR c++/119437 that r8-2724-g88b811bd290630
removed parsing_default_capturing_generic_lambda_in_template but not its
prototype in cp-tree.h.
Thomas Schwinge [Mon, 5 May 2025 08:21:35 +0000 (10:21 +0200)]
vect-simd-clone-1[6-8][cd].c: Expect in-branch clones for x86: Fix target selector syntax
Fix-up for commit f9f81d5017adc5d860b24f67aeb89b4e79c7ebdb
"vect-simd-clone-1[6-8][cd].c: Expect in-branch clones for x86", where we lost
the relevant testing, for example, for x86_64, or GCN:
Thomas Schwinge [Mon, 5 May 2025 08:19:30 +0000 (10:19 +0200)]
'libgomp.c/interop-hsa.c': GCN offloading only
Fix-up for commit 8d84ea28510054fbbb8a2b7441916bd75e29163f
"OpenMP, GCN: Add interop-hsa testcase", which added 'libgomp.c/interop-hsa.c'.
If nvptx offloading compilation is enabled in addition to GCN, the former ICEs:
Simon Martin [Mon, 5 May 2025 08:12:08 +0000 (10:12 +0200)]
c++: Inhibit subsequent warnings/notes in diagnostic_groups with an inhibited warning [PR118163,PR118392]
Those 2 PRs show that even when using a *single* diagnostic_group, it's
possible to end up with a warning being inhibited and its associated
note still emitted, which leads to puzzling user experience. Example
from PR118392:
===
$ gcc/cc1plus inhibit-warn-3.C -w
inhibit-warn-3.C:10:17: note: only here as a ‘friend’
10 | friend void bar();
| ^~~
===
Following a suggestion from ppalka@, this patch keeps track of the
"diagnostic depth" at which a warning in inhibited, and makes sure that
all subsequent notes at that depth or deeper are inhibited as well,
until a subsequent warning or error is accepted at that depth, or the
diagnostic_group or nesting level is popped.
PR c++/118163
PR c++/118392
gcc/ChangeLog:
* diagnostic.cc (diagnostic_context::initialize): Initialize
m_diagnostic_groups.m_inhibiting_notes_from.
(diagnostic_context::inhibit_notes_in_group): New.
(diagnostic_context::notes_inhibited_in_group): New
(diagnostic_context::report_diagnostic): Call
inhibit_notes_in_group and notes_inhibited_in_group.
(diagnostic_context::end_group): Call inhibit_notes_in_group.
(diagnostic_context::pop_nesting_level): Ditto.
* diagnostic.h (diagnostic_context::m_diagnostic_groups): Add
member to track the depth at which a warning has been inhibited.
(diagnostic_context::notes_inhibited_in_group): Declare.
(diagnostic_context::inhibit_notes_in_group): Declare.
* doc/ux.texi: Document diagnostic_group behavior with regards
to inhibited warnings.
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/incomplete-type-2.C: New test.
* g++.dg/diagnostic/incomplete-type-2a.C: New test.
* g++.dg/diagnostic/inhibit-warn-3.C: New test.
Kito Cheng [Mon, 5 May 2025 02:16:14 +0000 (10:16 +0800)]
RISC-V: Apply clang-format to genrvv-type-indexer.cc [NFC]
Tweak the formatting of the genrvv-type-indexer.cc file to conform to
the style used by clang-format. This is a no-functional-change commit
that only modifies the formatting of the code.
gcc/Changelog:
* config/riscv/genrvv-type-indexer.cc: Apply clang-format to the
file.
Robert Dubner [Fri, 2 May 2025 20:56:52 +0000 (16:56 -0400)]
cobol: Rewrite exception handling. Partially refactor subscript/refmod calculations.
This commit includes changes to exception handling, and changes to the
calculations for offsets and lengths when processing subscripted table entries
and variables with (from:length) reference modifications.
Exception handling in COBOL requires significant amounts of information to be
built at compile time and sent to libgcobol.so at run time. The changes here
reduce some problems caused by creating structures by the host that are
processed by the target, mainly by creating arrays of simple integers rather
than by turning a structure into a stream of bytes.
Significant changes to the logic of exception handling brings the run-time
performance more in line with the ISO specification.
The handling of COBOL variables that include tables defined with DEPENDING ON
clauses is subtly different when used as sending variables versus when they are
receiving variables. This commit folds the very similar refer_offset_source
and refer_offset_dest routines into a single refer_offset routine. It also
streamlines the refer_length_source and refer_length_dest routines by moving
common code into a static refer_length() routine, and having
refer_length_source() and refer_length_dest() each call refer_length() with a
a type flag.
Co-Authored by: James K. Lowden <jklowden@cobolworx.com>
Co-Authored by: Robert Dubner <rdubner@symas.com>
gcc/cobol/ChangeLog:
* cdf.y: Exceptions.
* except.cc (cbl_enabled_exception_t::dump): Likewise.
(cbl_enabled_exceptions_t::dump): Likewise.
(cbl_enabled_exceptions_t::status): Likewise.
(cbl_enabled_exceptions_t::encode): Likewise.
(cbl_enabled_exceptions_t::turn_on_off): Likewise.
(cbl_enabled_exceptions_t::match): Likewise.
(declarative_runtime_match): Likewise. Likewise.
* exceptg.h (struct cbl_exception_files_t): Likewise.
(class exception_turn_t): Likewise.
(apply_cdf_turn): Likewise.
* genapi.cc (treeplet_fill_source): Use refer_offset().
(function_handle_from_name): Likewise.
(parser_initialize_programs): Likewise.
(parser_statement_begin): Likewise.
(array_of_long_long): Exceptions.
(parser_compile_ecs): Exceptions.
(parser_compile_dcls): Exceptions.
(store_location_stuff): Exceptions.
(initialize_variable_internal): Use refer_offset().
(compare_binary_binary): Use refer_offset().
(cobol_compare): Use refer_offset().
(paragraph_label): Formatting.
(parser_goto): Use refer_offset().
(parser_perform_times): Likewise.
(internal_perform_through_times): Likewise.
(parser_enter_file): Exceptions.
(psa_FldLiteralN): Add comment.
(parser_accept): Use refer_offset().
(parser_accept_command_line): Likewise.
(parser_accept_command_line_count): Likewise.
(parser_accept_envar): Likewise.
(parser_set_envar): Likewise.
(parser_display_internal): Likewise.
(parser_initialize_table): Likewise.
(parser_sleep): Likewise.
(parser_allocate): Likewise.
(parser_free): Likewise.
(parser_division): Likewise.
(parser_relop_long): Likewise.
(parser_see_stop_run): Likewise.
(parser_classify): Likewise.
(parser_file_add): Include symbol_table_index in __gg__file_init().
(parser_file_open): Use refer_offset().
(parser_file_write): Move forward declaration of store_location_stuff().
(parser_file_start): Use refer_offset().
(parser_inspect_conv): Likewise:
(parser_intrinsic_numval_c): Likewise:
(parser_intrinsic_subst): Likewise:
(parser_intrinsic_call_1): Likewise:
(parser_intrinsic_call_2): Likewise:
(parser_intrinsic_call_3): Likewise:
(parser_intrinsic_call_4): Likewise:
(parser_sort): Likewise:
(parser_return_start): Exceptions.
(parser_unstring): Use refer_offset().
(create_and_call): Likewise.
(parser_set_pointers): Use refer_offset().
(parser_program_hierarchy): Comment.
(parser_set_handled): Exceptions; removed.
(parser_set_file_number): Exceptions; removed.
(stash_exceptions): Exceptions; removed.
(parser_exception_prepare): Exceptions; removed.
(parser_match_exception): Exceptions; eliminate blob.
(parser_check_fatal_exception): Exceptions.
(parser_push_exception): Create.
(parser_pop_exception): Create.
(mh_identical): Use refer_offset().
(mh_source_is_literalN): Likewise.
(mh_dest_is_float): Likewise.
(mh_numeric_display): Likewise.
(mh_little_endian): Likewise.
(mh_source_is_group): Likewise.
(move_helper): Likewise.
(binary_initial_from_float128): Formatting; change error message.
(initial_from_float128): Change name to "initial_from_initial"
(initial_from_initial): Add one byte to allocation for figconsts.
(parser_symbol_add): Use initial_from_initial().
(parser_symbol_add): Eliminate unneeded logic around actually_create...
* genapi.h: Exceptions.
* genmath.cc (fast_add): Use refer_offset().
(fast_subtract): Likewise.
(fast_multiply): Likewise.
(fast_divide): Likewise.
* genutil.cc: Exceptions; various global definitions.
(get_integer_value): Comment.
(get_data_offset_dest): Eliminate.
(get_data_offset_source): Rename to get_data_offset().
(get_data_offset): Use refer_offset().
(get_binary_value): Likewise; eliminate use of literal_decl_node.
(build_array_of_treeplets): Likewise.
(build_array_of_fourplets): Likewise.
(REFER_CHECK): Comment:
(refer_refmod_length): Use get_any_capacity(); use refer_offset;
set reflen to integer_one_node.
(refer_offset_dest): Change name to refer_offset.
(refer_offset): Use get_data_offset().
(refer_size_dest): Change name to refer_size().
(refer_size): Use get_any_capacity().
(refer_offset_source): Use refer_offset().
(refer_size_source): Likewise.
(qualified_data_source): Likewise.
(qualified_data_dest): Likewise.
(qualified_data_location): Likewise.
* genutil.h: Exceptions; changes to global declarations.
* lexio.cc (likely_nist_file): Added to detect NIST file format.
(cdftext::free_form_reference_format): Handle NIST file format.
* parse.y: (strip_trailing_zeroes): Added.
Changes for exceptions.
* parse_ante.h (parse_error_inc): Likewise.
(YYLLOC_DEFAULT): Likewise.
(static_cast): Likewise.
(is_cobol_word): Change to is_cobol_charset.
(is_cobol_charset): Refine allowed characters.
(require_numeric): Change to require integer.
(require_integer): Likewise.
(current_enabled_ecs): Exceptions.
(is_integer_literal): Change interpretation.
(procedure_division_ready): Exceptions.
(statement_epilog): Likewise.
(statement_begin): Likewise.
* show_parse.h: Changes to GCOBOL_SHOW handling.
* structs.cc: Add symbol_index to cblc_file_t structure.
* symbols.cc (field_str): Repair .initial handling in FldLiteralN.
* symbols.h (struct cbl_field_t): Eliminate literal_decl_node.
(current_enabled_ecs): Exceptions.
* util.cc (cbl_message): Add final newline to error message.
(ftoupper): Added.
(iso_cobol_word): Add list of ISO reserved words.
* util.h (ftoupper): Added.
This is a patch from late 2024 (just before stage1 freeze), but I never pushed
hard to the change, and thus never integrated it.
It's mostly unchanged except for updating insn in the hash table after finding
an optimizable case. We were holding the deleted insn in the hash table rather
than the new insn. Just something I noticed recently.
Bootstrapped and regression tested on my BPI and regression tested riscv32-elf
and riscv64-elf configurations. We've used this since November internally, so
it's well exercised on spec as well.
gcc/
* config.gcc (riscv): Add riscv-vect-permcost.o to extra_objs.
* config/riscv/riscv-passes.def (pass_vector_permcost): Add new pass.
* config/riscv/riscv-protos.h (make_pass_vector_permconst): Declare.
* config/riscv/riscv-vect-permconst.cc: New file.
* config/riscv/t-riscv: Add build rule for riscv-vect-permcost.o
Harald Anlauf [Sat, 3 May 2025 18:35:57 +0000 (20:35 +0200)]
Fortran: array subreferences and components of derived types [PR119986]
PR fortran/119986
gcc/fortran/ChangeLog:
* expr.cc (is_subref_array): When searching for array references,
do not terminate early so that inquiry references to complex
components work.
* primary.cc (gfc_variable_attr): A substring reference can refer
to either a scalar or array character variable. Adjust search
accordingly.
Jeff Law [Sun, 4 May 2025 17:05:44 +0000 (11:05 -0600)]
[RISC-V] Adjust rvv tests after recent jump threading change
Richi's jump threading patch is resulting in new jump threading opportunities
triggering in various vsetvl related tests. When those new threading
opportunities are realized on vector code we usually end up with a different
number of vsetvls due to the inherent block copying.
At first I was adjusting cases to work with the new jump threads, then realized
we could easily end up back here if we change the threading heuristics and
such. So I just made these tests disable jump threading. I didn't do it
pervasively, just for those that have been affected.
gcc/testsuite
* gcc.target/riscv/rvv/vsetvl/avl_prop-2.c: Disable jump threading
and adjust number of expected vsetvls as needed.
* gcc.target/riscv/rvv/vsetvl/avl_single-56.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/avl_single-67.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/avl_single-68.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/avl_single-71.c: Likewise.
Jin Ma [Sun, 4 May 2025 14:44:27 +0000 (08:44 -0600)]
[PATCH] RISC-V: Implment H modifier for printing the next register name
For RV32 inline assembly, when handling 64-bit integer data, it is
often necessary to process the lower and upper 32 bits separately.
Unfortunately, we can only output the current register name
(lower 32 bits) but not the next register name (upper 32 bits).
To address this, the modifier 'H' has been added to allow users
to handle the upper 32 bits of the data. While I believe the
modifier 'N' (representing the next register name) might be more
suitable for this functionality, 'N' is already in use.
Therefore, 'H' (representing the high register) was chosen instead.
Jeff Law [Sun, 4 May 2025 14:28:56 +0000 (08:28 -0600)]
[to-be-committed][RISC-V] Adjust testcases and finish register move costing fix
The recent adjustment to more correctly cost register moves tripped a few
testsuite regressions.
I'm pretty torn on the thead test adjustments. But in reality they only worked
because the register move costing was broken. So I've reverted the scan-asm
part of those to a prior state for two of those tests. The other was only
failing at -Og/-Oz which was added to the exclude list.
The other Zfa test is similar, but we can make the test behave with a suitable
-mtune option and thus preserve the test.
While investigating I also noted that vector moves aren't being handled
correctly for subclasses of the integer/fp register files. So I fixed those
while I was in there.
Note this may have an impact on some of your work Pan. I haven't followed the
changes from the last week or so due to illness.
Waiting on pre-commit's verdict, though it did spin through my tester
successfully, though not all of the regressions related to that change are
addressed (there's still one for rv32 I'll look at shortly).
gcc/
* config/riscv/riscv.cc (riscv_register_move_cost): Handle
subclasses with vector registers as well.
gcc/testsuite/
* gcc.target/riscv/xtheadfmemidx-xtheadfmv-medany.c: Adjust expected
output.
* gcc.target/riscv/xtheadfmemidx-zfa-medany.c: Likewise.
* gcc.target/riscv/xtheadfmv-fmv.c: Skip for -Os and -Oz.
* gcc.target/riscv/zfa-fmovh-fmovp.c: Use sifive-p400 tuning.
Jan Hubicka [Sun, 4 May 2025 08:52:35 +0000 (10:52 +0200)]
Improve maybe_hot handling in inliner heuristics
Inliner currently applies different heuristics to hot and cold calls (the
second are inlined only if the code size will shrink). It may happen that the
call itself is hot, but the significant time is spent in callee and inlining
makes it faster. For this reason we want to check if the anticipated speedup
is considered hot which is done by this patch (that is similar ot my earlier
ipa-cp change).
In general I think this is less important compared to ipa-cp change, since large
benefit from inlining happens only when something useful is propagated into the
callee and should be handled earlier by ipa-cp. However the patch improves
SPEC2k17 imagick runtime by about 9% as discussed in PR 11900 though it is
mostly problem of bad train data set which does not train well parts of program
that are hot for ref data set. As discussed in the PR log, the particular call
that needs to be inlined has count that falls very slightly bellow the cutoff
and scaling it up by expected savings enables inlining.
gcc/ChangeLog:
PR target/119900
* cgraph.cc (cgraph_edge::maybe_hot_p): Add
a variant accepting a sreal scale; use reliability of
profile.
* cgraph.h (cgraph_edge::maybe_hot_p): Declare
a varaint accepting a sreal scale.
* ipa-inline.cc (callee_speedup): New function.
(want_inline_small_function_p): add early return
and avoid duplicated lookup of summaries; use scaled
maybe_hot predicate.
After we add the frm register to the global_regs, we may not need to
define_insn that volatile to emit the frm restore insns. The
cooperatively-managed global register will help to handle this, instead
of emit the volatile define_insn explicitly.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_emit_frm_mode_set): Refactor
the frm mode set by removing fsrmsi_restore_volatile.
* config/riscv/vector-iterators.md (unspecv): Remove as
unnecessary.
* config/riscv/vector.md (fsrmsi_restore_volatile): Ditto.
Jason Merrill [Thu, 1 May 2025 13:42:40 +0000 (09:42 -0400)]
c++: let plain -Wabi warn about future changes
c_common_post_options limits flag_abi_version and flag_abi_compat_version to
actual ABI version numbers, but let's not do that for warn_abi_version; we
might want to add a warning relative to a future ABI version that isn't
available in the current release, such backporting the PR120012 warning.
Also allow plain -Wabi to include such a warning without complaining that
it's useless.
Also warn about an unsupported -fabi-version argument.
gcc/c-family/ChangeLog:
* c-opts.cc (c_common_post_options): Let plain -Wabi warn
about changes in a future version.
Jan Hubicka [Fri, 2 May 2025 22:26:29 +0000 (00:26 +0200)]
Improve ix86 VEC_MERGE costs
ix86_rtx_costs VEC_MERGE by special casing AVX512 mask operations and otherwise
returning cost->sse_op completely ignoring costs of the operands. Since
VEC_MERGE is also used to represent scalar variant of SSE/AVX operation, this
means that many instructions (such as SSE converisions) are often costed as
sse_op instead of their real cost.
This patch adds pattern matching for the VEC_MERGE pattern which also forced me
to add special cases for masked versions and vcmp otherwise combine is confused
by the default cost compred to the cost of recognized version of the
instruction.
Since now the important cases should be handled, I also added recursion to the
remaining cases so substituting constants and memory is adequately costed.
gcc/ChangeLog:
* config/i386/i386.cc (unspec_pcmp_p): New function.
(ix86_rtx_costs): Cost VEC_MERGE more realistically.
Andrew Pinski [Fri, 2 May 2025 16:46:24 +0000 (09:46 -0700)]
simplify-rtl: Fix crash due to simplify_with_subreg_not [PR120059]
r16-286-gd84fbc516ea57d added a call to simplify_gen_subreg but didn't
check if the result of simplify_gen_subreg was non-null. simplify_gen_subreg
can return NULL if the subreg would be not valid. In the case below we had
a hard register for the SSE register xmm0 of mode SI and doing a subreg to
QI mode but QImode is not a valid mode for the SSE register so simplify_gen_subreg
would return NULL.
This adds the obvious check.
Pushed as obvious after bootstrap/test on x86_64-linux-gnu.
PR rtl-optimization/120059
gcc/ChangeLog:
* simplify-rtx.cc (simplify_with_subreg_not): Check the result
of simplify_gen_subreg.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr120059-1.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Jakub Jelinek [Fri, 2 May 2025 19:19:05 +0000 (21:19 +0200)]
c: Fix up RAW_DATA_CST handling in check_constexpr_init [PR120057]
The pr120057-1.c testcase is incorrectly rejected since
r15-4377 (and for a while it also ICEd after the error), i.e.
the optimization of large C initializers using RAW_DATA_CST.
Similarly, the embed-18.c testcase is incorrectly rejected since
the embed support has been introduced and RAW_DATA_CST used for that.
The callers of check_constexpr_init (store_init_value and
output_init_element) compute int_const_expr as
int_const_expr = (TREE_CODE (init) == INTEGER_CST
&& !TREE_OVERFLOW (init)
&& INTEGRAL_TYPE_P (TREE_TYPE (init)));
but that is only passed through down to check_constexpr_init.
I think tweaking those 2 callers to also allow RAW_DATA_CST for
int_const_expr when check_constexpr_init needs top special case it
no matter what would be larger, so the patch just changes
check_constexpr_init to deal with RAW_DATA_CST in the initializers.
For TYPE_UNSIGNED char precision integral types RAW_DATA_CST is
always valid, for !TYPE_UNSIGNED we need to check for 128-255 values
being turned into negative ones.
On Mon, Mar 31, 2025 at 11:30:20AM -0400, Andrew MacLeod wrote:
> Infer range processing was adjusted to allow a query to be specified,
> but during VRP folding, ranger w3as not providing a query. This results
> in contextual ranges being missed. Pass the cache in as the query
> which provide a read-only query of the current state.
Now that this patch is in, I've retested my patch and it works fine.
If we can determine a range for the arg2 argument and prove that it
doesn't include zero, we can imply nonzero for the arg1 argument.
2025-05-02 Jakub Jelinek <jakub@redhat.com>
Andrew MacLeod <amacleod@redhat.com>
PR c/117023
* gimple-range-infer.cc (gimple_infer_range::gimple_infer_range):
For nonnull_if_nonzero attribute check also arg2 range if it doesn't
include zero and in that case call add_nonzero too.
Jakub Jelinek [Fri, 2 May 2025 17:10:59 +0000 (19:10 +0200)]
cobol: Fix up exception handling [PR119364]
The following patch on top of the
https://gcc.gnu.org/pipermail/gcc-patches/2025-May/682500.html
fixes most of the remaining make check-cobol FAILs in the
i686-linux -> x86_64-linux cross-compiler.
Using the testing environment detailed in
https://gcc.gnu.org/pipermail/gcc-patches/2025-April/680403.html
with this patch I get just cobol.dg/group1/declarative_1.cob FAILs
in i686-linux -> x86_64-linux cross and no FAILs in x86_64-linux
native one.
The patch isn't needed just for cross-compilation with different
hosts, but also on x86_64-linux/aarch64-linux native, because without
it the FE is hashing padding bits which contain random garbage and making
code generation decisions based on that. That is very much against the
reproduceability requirements.
2025-05-02 Jakub Jelinek <jakub@redhat.com>
PR cobol/119364
* structs.h (cbl_enabled_exception_type_node): New variable
declaration.
* structs.cc (cbl_enabled_exception_type_node): New variable.
(create_cbl_enabled_exception_t): New function.
(create_our_type_nodes): Initialize cbl_enabled_exception_type_node
using it.
* genapi.cc (stash_exceptions): Don't compare padding bits to
determine if the exceptions are the same as last time. Use
cbl_enabled_exception_type_node for target size and field offsets
and native_encode_expr to write each field into byte sequence.
Jakub Jelinek [Fri, 2 May 2025 17:09:34 +0000 (19:09 +0200)]
cobol, v2: Fix up cobol cross-compilation from 32-bit arches [PR119364]
Right now it is not possible to even build cross-compilers from 32-bit
architectures to e.g. x86_64-linux or aarch64-linux, even from little-endian
ones.
The following patch attempts to fix that.
There were various issues seen e.g. trying to build i686-linux ->
x86_64-linux cross-compiler (so still 64-bit libgcobol, but the compiler
is 32-bit).
1) warning about >> 32 shift of size_t, on 32-bit arches size_t is 32-bit
and so the shift is UB; fixed by doing (new_size>>16)>>16 so that
it ors in >> 32 when new_size is 64-bit and 0 when it is 32-bit
2) enum cbl_field_attr_t was using size_t as underlying type, but has
various bitmasks which require full 64-bit type; changed this to uint64_t
underlying type and using unsigned long long in the structure; various
routines which operate with those attributes had to be changed also to
work with uint64_t instead of size_t
3) on i686-linux, config.h can #define _FILE_OFFSET_BITS 64 or similar
macros; as documented, those macros have to be defined before including
first C library header, but some sources included cobol-system.h which
includes config.h only after various other headers; this resulted in
link failures, as ino_t was sometimes unsigned long and sometines
unsigned long long, depending on whether config.h was included first or
not, and e.g. cobol_filename uses ino_t argument
4) lots of places used %ld or %lx *printf format specifers with size_t
arguments; that works only if size_t is unsigned long, but not when it
is unsigned int or unsigned long long or some other type; now while
ISO C99 has %zd or %zx to print size_t and C++14 includes C99 (or C11?),
while for the C++ headers the C++ compilers typically have full control
over it and so support everything in C++14 (e.g. libstdc++ in GCC 5.1+
or libc++ if not too old), for C library we are dependent on the system
C library (note, on the host for the compiler side). And not all hosts
support C99 in their C libraries; so instead of just changing it to
%zd or %zx, I'm changing it to what we use elsewhere in GCC,
HOST_SIZE_T_PRINT_{DEC,UNSIGNED,HEX_PURE} or GCC_PRISZ macros in the
*printf family format string and casts of the size_t arguments to
fmt_size_t. Note, if not using the C library *printf family (e.g. in
dbgmsg, sprintf, snprintf, fprintf, etc.) but the GCC diagnostic code
(e.g. err_msg, error, warning, yywarn, ...), then %zd/%zu is supported
and on the other side HOST_SIZE_T_PRINT_{DEC,UNSIGNED,HEX_PURE} etc.
macros shouldn't be used (for two reasons, because it is unnecessary
when %zd/%zu is guaranteed to be supported there because GCC has
control over that and more importantly because it breaks translations,
both extraction of the to be translated strings and we don't want to
have different messages, once with %lld, once with %ld, once with just %d
or %I64d depending on host, translators couldn't translate it all).
5) see above, there were already tons of %zd/%zu or %3zu etc. format
specifers in *printf format strings, this patch changes those too
6) I've noticed dbgmsg wasn't declared with printf attribute, which resulted
in bugs where format specifiers didn't match actually passed types of
arguments
2025-05-02 Jakub Jelinek <jakub@redhat.com>
PR cobol/119364
libgcobol/
* valconv.cc (__gg__realloc_if_necessary): Use (new_size>>16)>>16;
instead of new_size>>32; to avoid warnings on 32-bit hosts.
* common-defs.h (enum cbl_field_attr_t): Use uint64_t
as underlying type rather than size_t.
* gcobolio.h (cblc_field_t): Change attr member type from size_t
to unsigned long long.
gcc/cobol/
* util.cc (is_numeric_edited): Use HOST_SIZE_T_PRINT_UNSIGNED
instead of "%zu" and cast corresponding argument to fmt_size_t.
(normalize_picture): Use GCC_PRISZ instead of "z" and pass address
of fmt_size_t var to sscanf and copy afterwards.
(cbl_refer_t::str): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" and cast corresponding argument
to fmt_size_t.
(struct move_corresponding_field): Likewise.
(valid_move): Likewise.
(ambiguous_reference): Likewise.
(parent_names): Likewise.
(find_corresponding::find_corresponding): Likewise.
(corresponding_fields): Likewise.
(unique_stack::push): Likewise.
(cobol_filename): Likewise.
* lexio.cc: Include config.h first.
(recognize_replacements): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" and cast corresponding argument
to fmt_size_t.
(check_source_format_directive): Likewise.
(parse_replacing_pair): Use size_t(0) instead of 0UL in span_t
construction.
(parse_replace_pairs): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(parse_copy_directive): Likewise.
(parse_replace_last_off): Likewise.
(parse_replace_text): Likewise.
(bytespan_t::append): Likewise.
(cdftext::map_file): Likewise.
(cdftext::process_file): Likewise.
* symfind.cc (dump_symbol_map2): Likewise.
(dump_symbol_map_value): Likewise.
(build_symbol_map): Likewise.
(is_name::dump_key): Likewise.
(symbol_match2): Likewise.
(symbol_find): Likewise.
(symbol_find_of): Likewise.
* cdf.y: Likewise.
* symbols.cc: Include config.h first.
(cbl_field_t::set_attr): Return uint64_t rather than size_t
and replace size_t(attr) with uint64_t(attr).
(cbl_field_t::clear_attr): Likewise.
(symbol_field_capacity): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(symbol_find_odo_debug): Likewise.
(symbols_dump): Likewise.
(calculate_capacity): Likewise.
(field_str): Likewise.
(symbols_update): Likewise.
(symbol_field_forward): Likewise.
(numeric_group_attrs): Return uint64_t rather than size_t and
change inherit variable to from size_t to uint64_t.
(new_literal_add): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(temporaries_t::dump): Likewise.
(cbl_label_t::str): Likewise.
(symbol_label_add): Likewise.
(symbol_program_add): Likewise.
(symbol_forward_names): Likewise.
(symbol_forward_to): Likewise.
(cbl_file_key_t::deforward): Likewise.
(cbl_file_key_t::str): Likewise.
* gengen.cc (show_type): Use PRId64 instead of "ld".
(gg_unique_in_function): Use HOST_SIZE_T_PRINT_DEC instead of
%ld and cast corresponding argument to fmt_size_t.
* scan.l: Add %top section with #include "config.h".
* genmath.cc (parser_add): Use HOST_SIZE_T_PRINT_DEC instead of
%ld and cast corresponding argument to fmt_size_t.
(parser_subtract): Likewise.
* parse.y: Include "config.h" before <fstream>. Use
HOST_SIZE_T_PRINT_UNSIGNED instead of "%zu" and cast corresponding
argument to fmt_size_t. Change type of sign_attrs, group_sign and
type_implies from size_t to uint64_t.
(perform_t::ec_labels_t::new_label): Use HOST_SIZE_T_PRINT_UNSIGNED
instead of "%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC
instead of "%zd" and cast corresponding argument to fmt_size_t.
(stringify_src_t::dump): Likewise.
(lang_check_failed): Likewise.
(numstr2i): Use GCC_PRISZ instead of "z" and pass address of temporary
with fmt_size_t type to sscanf and then copy it over.
(initialize_statement): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(dump_inspect_oper): Likewise.
(new_literal): Likewise.
(literal_subscripts_valid): Likewise.
(eval_subject_t::label): Likewise.
* genapi.cc (level_88_helper): Likewise.
(parser_call_targets_dump): Likewise.
(combined_name): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(section_label): Likewise.
(paragraph_label): Likewise.
(leave_procedure): Likewise.
(parser_perform): Likewise.
(parser_perform_times): Likewise.
(internal_perform_through): Likewise.
(internal_perform_through_times): Likewise.
(parser_enter_program): Likewise.
(parser_init_list_size): Likewise.
(parser_init_list): Likewise.
(psa_FldLiteralN): Likewise.
(psa_FldBlob): Likewise.
(parser_assign): Likewise.
(parser_free): Pass p->field->name to dbgmsg.
(parser_division): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(perform_outofline_before_until): Likewise.
(perform_outofline_after_until): Likewise.
(perform_outofline_testafter_varying): Likewise.
(perform_outofline_before_varying): Likewise.
(perform_inline_testbefore_varying): Likewise.
(parser_inspect): Change n_operations parameter type from
unsigned long to size_t.
(parser_intrinsic_callv): Use HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(parser_bitop): Use HOST_SIZE_T_PRINT_HEX_PURE instead of
"%lx" and cast corresponding argument to fmt_size_t.
(parser_bitwise_op): Likewise.
(parser_program_hierarchy): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(parser_set_handled): Use HOST_SIZE_T_PRINT_HEX_PURE instead of
"%lx" and cast corresponding argument to fmt_size_t.
(parser_set_numeric): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(psa_new_var_decl): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(parser_symbol_add): Use HOST_SIZE_T_PRINT_DEC instead of "%zd"
or HOST_SIZE_T_PRINT_HEX_PURE instead of "%lx" and cast corresponding
argument to fmt_size_t.
* cdf-copy.cc: Include "config.h" first.
* scan_ante.h (trim_location): Use HOST_SIZE_T_PRINT_UNSIGNED instead
of "%zu" or "%d" and cast corresponding argument to fmt_size_t.
* structs.cc (create_cblc_field_t): Use ULONGLONG instead of SIZE
for "attr".
* cbldiag.h (dbgmsg): Add ATTRIBUTE_PRINTF_1.
* gcobolspec.cc (lang_specific_driver): Use HOST_SIZE_T_PRINT_DEC
instead of "%ld" and cast corresponding argument to fmt_size_t.
* parse_ante.h (literal_of): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(evaluate_elem_t::dump): Likewise.
(arith_t::another_pair): Likewise.
(current_t::end_program): Likewise.
(file_add): Likewise.
(implicit_paragraph): Likewise.
(implicit_section): Likewise.
(data_division_ready): Use HOST_SIZE_T_PRINT_DEC instead of "%d"
and cast corresponding argument to fmt_size_t.
* symbols.h (struct cbl_field_t): Change attr member type from size_t
to uint64_t.
(cbl_field_t::set_attr): Change return type from size_t to uint64_t.
(cbl_field_t::clear_attr): Likewise.
(function_descr_t::init): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(cbl_perform_tgt_t::dump): Likewise.
(numeric_group_attrs): Change return type from size_t to uint64_t.
Jan Hubicka [Fri, 2 May 2025 13:53:35 +0000 (15:53 +0200)]
Make ix86 cost of VEC_SELECT equivalent to SUBREG cost 1
This patch fixes regression of imagick with PGO and AVX512 where correcting size
cost of SSE operations (to be 4 instead of 2 originally cut&pasted from x87)
made late combine to eliminate zero registers introduced by rapd. The problem
is that cost-model mistakely accounts VEC_SELECT as real instruction while it is
optimized to nothing if src==dest (which is the case of these testcases).
This register is used to eliminate false dependency between source and destination
of int->fp conversions.
While ix86_insn_cost hook already contains logic to incrase cost of the zero-extend
the costs was not enough.
gcc/ChangeLog:
PR target/119900
* config/i386/i386.cc (ix86_can_change_mode_class): Add TODO
comment.
(ix86_rtx_costs): Make VEC_SELECT equivalent to SUBREG cost 1.
Jason Merrill [Fri, 2 May 2025 12:35:38 +0000 (08:35 -0400)]
c++: CTAD and constexpr ctor [PR115207]
Here we failed to constant-evaluate the A<int> constructor because DECL_SIZE
wasn't set on 'a' yet, so compare_address thinks we can't be sure it isn't
at the same address as 'i'.
Normally DECL_SIZE is set by build_decl calling layout_decl, but that
doesn't happen here because we don't have a type yet. So we need to
layout_decl again after deduction.
PR c++/115207
gcc/cp/ChangeLog:
* decl.cc (cp_finish_decl): Call layout_decl after CTAD.
Jason Merrill [Fri, 2 May 2025 13:33:39 +0000 (09:33 -0400)]
c++: fix some testcases
After r16-332 these tests started failing. constexpr-89285.C should have
always given this error, and the new nonlit19.C needs to remove the
destructor body to prevent -fimplicit-constexpr from making the testcase
well-formed.
Jason Merrill [Wed, 30 Apr 2025 14:18:46 +0000 (10:18 -0400)]
c++: C++17/20 class layout divergence [PR120012]
C++20 made a class with only explicitly defaulted constructors no longer
aggregate, and this wrongly affected whether the class is considered "POD
for layout purposes" under the ABI.
Conveniently, we already have check_non_pod_aggregate to diagnose cases
where this makes a difference, due to PR103681 around a C++14 aggregate
change.
PR c++/120012
gcc/cp/ChangeLog:
* cp-tree.h (struct lang_type): Add non_aggregate_pod.
(CLASSTYPE_NON_AGGREGATE_POD): New.
* class.cc (check_bases_and_members): Set it.
(check_non_pod_aggregate): Diagnose it.
Jason Merrill [Thu, 1 May 2025 15:40:17 +0000 (11:40 -0400)]
i386: -Wabi false positive with indirect call [PR60336]
This warning relies on the TRANSLATION_UNIT_WARN_EMPTY_P flag (set in
cxx_init_decl_processing) to decide whether we want to warn about the GCC 8
empty class parameter passing fix, but in a call through a function pointer
we don't have a translation unit and so complain for any -Wabi flag, even
now long after this was likely to be relevant.
In that situation, let's check the TU for current_function_decl instead.
And if we still can't come up with a TU, default to not warning.
PR c++/60336
gcc/ChangeLog:
* config/i386/i386.cc (ix86_warn_parameter_passing_abi):
If no target, check the current TU.
Jonathan Wakely [Thu, 1 May 2025 21:41:40 +0000 (22:41 +0100)]
libstdc++: Make __gnu_test::default_init_allocator usable in constexpr
If we make this test allocator usable in constant expressions then we'll
get an error if the 'state' data member isn't initialized. This makes it
a more reliable check that allocators are correctly value-initialized
when they're required to be.
libstdc++-v3/ChangeLog:
* testsuite/23_containers/vector/allocator/default_init.cc:
Add a check using constant evaluation.
* testsuite/23_containers/vector/bool/allocator/default_init.cc:
Likewise.
* testsuite/util/testsuite_allocator.h (default_init_allocator):
Make all member functions and equality ops constexpr.
Jonathan Wakely [Thu, 10 Apr 2025 11:56:43 +0000 (12:56 +0100)]
libstdc++: Add some more makefile dependencies
Add more prerequisites for wchar and dual-abi targets in the src/c++11
directory, and simplify the existing ones (we don't need to add the main
xxx.cc source file as a prerequisite of xxx.o because that's implicit,
we only need to add the ones that Make can't determine on its own).
Also add similar prerequisites for the dual-abi targets in the src/c++17
directory.
libstdc++-v3/ChangeLog:
* src/c++11/Makefile.am: Simplify existing prerequisites for wchar and
dual-abi targets that are built from other sources. Add similar
prerequisites for more wchar and dual-abi files.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.am [ENABLE_DUAL_ABI]: Add prerequisites for
dual-abi targets that are built from other sources.
* src/c++17/Makefile.in: Regenerate.
Filip Kastl [Thu, 1 May 2025 13:32:36 +0000 (15:32 +0200)]
gimple: Switch bit-test lowering testcases for the more powerful alg
This patch adds 2 testcases. One tests that GCC is able to create
bit-test clusters of size 64. The other one contains two switches which
GCC wouldn't completely cover with bit-test clusters before the changes
from this patch set.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/switch-5.c: New test.
* gcc.dg/tree-ssa/switch-6.c: New test.
Filip Kastl [Thu, 1 May 2025 13:31:30 +0000 (15:31 +0200)]
gimple: Make bit-test switch lowering more powerful
A reasonable goal for bit-test lowering is to produce the least amount
of clusters for a given switch (a cluster is basically a group of cases
that can be handled by constantly many operations).
The current algorithm doesn't always give optimal solutions in that
sense. This patch should fix this. The important thing is basically
just to ask if a cluster is_beneficial() more proactively.
The patch also has a fix for a mistake which made bit-test lowering only
create BITS_IN_WORD - 1 big clusters. There are also some new comments
that go into more detail on the dynamic programming algorithm.
gcc/ChangeLog:
* tree-switch-conversion.cc (bit_test_cluster::find_bit_tests):
Modify the dynamic programming algorithm to take is_beneficial()
into account earlier. To do this efficiently, copy some logic
from is_beneficial() here. Add detailed comments about how the
DP algorithm works.
(bit_test_cluster::can_be_handled): Check that the cluster range
is >, not >= BITS_IN_WORD. Remove the
"vec<cluster *> &, unsigned, unsigned" overloaded variant since
we no longer need it.
(bit_test_cluster::is_beneficial): Add a comment that this
function is closely tied to m_max_case_bit_tests. Remove the
"vec<cluster *> &, unsigned, unsigned" overloaded variant since
we no longer need it.
* tree-switch-conversion.h: Remove the vec overloaded variants
of bit_test_cluster::is_beneficial and
bit_test_cluster::can_be_handled.
Filip Kastl [Thu, 1 May 2025 13:30:52 +0000 (15:30 +0200)]
gimple: Merge slow and fast bit-test switch lowering [PR117091]
PR117091 showed that bit-test switch lowering can take a lot of time.
The algorithm was O(n^2). We therefore came up with a faster algorithm
(O(n * BITS_IN_WORD)) and made GCC choose between the slow and the fast
algorithm based on how big the switch is.
Here I combine the algorithms so that we get the results of the slower
algorithm in the faster asymptotic time.
PR middle-end/117091
gcc/ChangeLog:
* tree-switch-conversion.cc (bit_test_cluster::find_bit_tests_fast):
Remove function.
(bit_test_cluster::find_bit_tests_slow): Remove function.
(bit_test_cluster::find_bit_tests): We don't need to decide
between slow and fast so just put the modified (no longer) slow
algorithm here.
Jennifer Schmitz [Wed, 12 Mar 2025 07:37:42 +0000 (00:37 -0700)]
aarch64: Optimize SVE extract last for VLS.
For the test case
int32_t foo (svint32_t x)
{
svbool_t pg = svpfalse ();
return svlastb_s32 (pg, x);
}
compiled with -O3 -mcpu=grace -msve-vector-bits=128, GCC produced:
foo:
pfalse p3.b
lastb w0, p3, z0.s
ret
when it could use a Neon lane extract instead:
foo:
umov w0, v0.s[3]
ret
Similar optimizations can be made for VLS with other vector widths.
We implemented this optimization by guarding the emission of
pfalse+lastb in the pattern vec_extract<mode><Vel> by
!val.is_constant ().
Thus, for last-extract operations with VLS, the patterns
*vec_extract<mode><Vel>_v128, *vec_extract<mode><Vel>_dup, or
*vec_extract<mode><Vel>_ext are used instead.
We added tests for 128-bit VLS and adjusted the tests for the other vector
widths.
The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for mainline?
Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* config/aarch64/aarch64-sve.md (vec_extract<mode><Vel>):
Prevent the emission of pfalse+lastb for VLS.
Jakub Jelinek [Fri, 2 May 2025 07:16:27 +0000 (09:16 +0200)]
++: Small build_vec_init improvement [PR117827]
As discussed in the
https://gcc.gnu.org/pipermail/gcc-patches/2025-January/674492.html
thread, the following patch attempts to improve build_vec_init generated
code. E.g. on g++.dg/eh/aggregate1.C test the patch has differences like:
D.2988 = &D.2950->e1;
D.2989 = D.2988;
D.2990 = 1;
try
{
goto <D.2996>;
<D.2997>:
A::A (D.2989);
D.2990 = D.2990 + -1;
D.2989 = D.2989 + 1;
<D.2996>:
if (D.2990 >= 0) goto <D.2997>; else goto <D.2995>;
<D.2995>:
retval.4 = D.2988;
_13 = &D.2950->e2;
A::A (_13);
- D.2990 = 1;
+ D.2988 = 0B;
D.2951 = D.2951 + -1;
}
catch
{
{
struct A * D.2991;
if (D.2988 != 0B) goto <D.3028>; else goto <D.3029>;
<D.3028>:
_11 = 1 - D.2990;
_12 = (sizetype) _11;
D.2991 = D.2988 + _12;
<D.3030>:
if (D.2991 == D.2988) goto <D.3031>; else goto <D.3032>;
<D.3032>:
D.2991 = D.2991 + 18446744073709551615;
A::~A (D.2991);
goto <D.3030>;
<D.3031>:
goto <D.3033>;
<D.3029>:
<D.3033>:
}
}
in 3 spots. As you can see, both setting D.2990 (i.e. iterator) to
maxindex and setting D.2988 (i.e. rval) to nullptr have the same effect of
not actually destructing anything anymore in the cleanup, the
advantage of clearing rval is that setting something to zero is often less
expensive than potentially huge maxindex and that the cleanup tests that
value first.
2025-05-02 Jakub Jelinek <jakub@redhat.com>
PR c++/117827
* init.cc (build_vec_init): Push to *cleanup_flags clearing of rval
instead of setting of iterator to maxindex.
Andrew Pinski [Thu, 1 May 2025 16:05:47 +0000 (09:05 -0700)]
vect: Use internal storage for converts for call into supportable_indirect_convert_operation [PR118617]
While looking into PR 118616, I noticed that
supportable_indirect_convert_operation only pushes up to 2 into its vec.
And the 2 places which call supportable_indirect_convert_operation,
use an auto_vec but without an internal storage. In this case an internal
storage of 2 elements would save both memory and slight compile time performance.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/118617
gcc/ChangeLog:
* tree-vect-generic.cc (expand_vector_conversion): Have 2 elements
as internal storage for converts.
* tree-vect-stmts.cc (vectorizable_conversion): Likewise.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Andrew Pinski [Thu, 1 May 2025 07:14:27 +0000 (00:14 -0700)]
get_known_nonzero_bits_1 should use wi::bit_and_not [PR118659]
While looking into bitwise optimizations, I noticed that
get_known_nonzero_bits_1 does `bm.value () & ~bm.mask ()` which
is ok except it creates a temporary wide_int. Instead if we
use wi::bit_and_not, we can avoid the temporary and on some
targets use the andn/bic instruction.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
PR tree-optimization/118659
* tree-ssanames.cc (get_known_nonzero_bits_1): Use
wi::bit_and_not instead of `a & ~b`.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Andrew Pinski [Thu, 1 May 2025 15:31:18 +0000 (08:31 -0700)]
expand: Remove unsignedp argument from get_compare_parts [PR118090]
While helping Eikansh with a patch to ccmp, it was noticed that the
result stored in the up pointer that gets passed to get_compare_parts
was unused on all call sites.
It was always unused since get_compare_parts was added in r8-1717-gf580a969d7fbab. It looks it was not noticed it became unused
when rcode was set via get_compare_parts and in RTL, the signedness is
part of the comparison.
PR middle-end/118090
gcc/ChangeLog:
* ccmp.cc (get_compare_parts): Remove the up argument.
(expand_ccmp_next): Update call to get_compare_parts.
(expand_ccmp_expr_1): Likewise.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Named loops (C2y) could not previously be compiled with
-O1 and -ggdb2 or higher because the label preceding
a loop (or switch) could not be found when using such
command lines.
This could be observed by compiling
gcc/gcc/testsuite/gcc.dg/c2y-named-loops-1.c with
the provoking command line (or any minimal example such
as that cited in the bug report).
The fix was simply to ignore the tree nodes inserted
for debugging information.
* c-decl.cc (c_get_loop_names): Do not prematurely
end the search for a label that names a loop or
switch statement upon encountering a DEBUG_BEGIN_STMT.
Instead, ignore any instances of DEBUG_BEGIN_STMT.
Tobias Burnus [Thu, 1 May 2025 15:39:42 +0000 (15:39 +0000)]
OpenMP: Restore lost Fortran testcase for 'omp allocate'
This testcase, which is present on the OG13 and OG14 branches, was
overlooked when the Fortran support for 'omp allocate' was added to
mainline (commit d4b6d147920b93297e621124a99ed01e7e310d92 from
December 2023).
libgomp/ChangeLog
* testsuite/libgomp.fortran/allocate-8a.f90: New test.
Patrick Palka [Thu, 1 May 2025 15:40:44 +0000 (11:40 -0400)]
c++: poor diag w/ non-constexpr dtor called from constexpr ctor
When diagnosing a non-constexpr constructor call during constexpr
evaluation, explain_invalid_constexpr_fn was passing the genericized
body to require_potential_constant_expression rather than the saved
non-genericized one.
This meant for the below testcase (reduced from PR libstdc++/119282)
in which B::B() is deemed non-constexpr due to the local variable having
a non-constexpr destructor we would then issue the cryptic diagnostic:
constexpr-nonlit19.C:17:16: error: non-constant condition for static assertion
17 | static_assert(f());
| ~^~
constexpr-nonlit19.C:17:16: in ‘constexpr’ expansion of ‘f()’
constexpr-nonlit19.C:13:5: error: ‘constexpr B::B()’ called in a constant expression
13 | B b;
| ^
constexpr-nonlit19.C:6:13: note: ‘constexpr B::B()’ is not usable as a ‘constexpr’ function because:
6 | constexpr B() {
| ^
constexpr-nonlit19.C:8:5: error: ‘goto’ is not a constant expression
8 | for (int i = 0; i < 10; i++) { }
| ^~~
This patch makes us pass the non-genericized body to
require_potential_constant_expression, and so we now emit:
...
constexpr-nonlit19.C:6:13: note: ‘constexpr B::B()’ is not usable as a ‘constexpr’ function because:
6 | constexpr B() {
| ^
constexpr-nonlit19.C:9:3: error: call to non-‘constexpr’ function ‘A::~A()’
9 | }
| ^
constexpr-nonlit19.C:3:12: note: ‘A::~A()’ declared here
3 | struct A { ~A() { } };
| ^
gcc/cp/ChangeLog:
* constexpr.cc (explain_invalid_constexpr_fn): In the
DECL_CONSTRUCTOR_P branch pass the non-genericized body to
require_potential_constant_expression.
Andrew Pinski [Wed, 30 Apr 2025 19:56:13 +0000 (12:56 -0700)]
phiopt: Remove special case for a sequence after match and simplify for early phiopt
r16-189-g99aa410f5e0a72 fixed the case where match-and-simplify there was an extra
assignment happening inside the sequence return. phiopt_early_allow had code to
workaround that issue but now can be removed and simplify down to only allowing
the sequence having only one MIN/MAX if the outer code is MIN/MAX also.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-phiopt.cc (phiopt_early_allow): Only allow a sequence
with one statement for MIN/MAX and the op was MIN/MAX.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Patrick Palka [Thu, 1 May 2025 14:58:50 +0000 (10:58 -0400)]
c++: more overeager use of deleted function before ADL [PR119034]
The PR68942 fix used the tf_conv flag to disable mark_used when
substituting a FUNCTION_DECL callee of an ADL-enabled call. In this
slightly more elaborate testcase, we end up prematurely calling
mark_used anyway on the FUNCTION_DECL directly from the CALL_EXPR case
of tsubst_expr during partial instantiation, leading to a bogus "use of
deleted function" error.
This patch fixes the general problem in a more robust way by ensuring
the callee of an ADL-enabled call is wrapped in an OVERLOAD, so that
tsubst_expr leaves it alone.
PR c++/119034
PR c++/68942
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr) <case CALL_EXPR>: Revert PR68942 fix.
* semantics.cc (finish_call_expr): Ensure the callee of an
ADL-enabled call is wrapped in an OVERLOAD.
Paul Thomas [Thu, 1 May 2025 14:22:54 +0000 (15:22 +0100)]
Fortran: Source allocation of pure function result rejected [PR119948]
2025-05-01 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/119948
* resolve.cc (gfc_impure_variable): The result of a module
procedure with an interface declaration is not impure even if
the current namespace is not the same as the symbol's.
gcc/testsuite/
PR fortran/119948
* gfortran.dg/pr119948.f90: New test.
Ayan Shafqat [Thu, 1 May 2025 13:17:30 +0000 (06:17 -0700)]
Aarch64: Add __sqrt and __sqrtf intrinsics and corresponding tests
This patch introduces two new inline functions, __sqrt and __sqrtf, in
arm_acle.h for Aarch64 targets. These functions wrap the new builtins
__builtin_aarch64_sqrtdf and __builtin_aarch64_sqrtsf, respectively,
providing direct access to hardware instructions without relying on the
standard math library or optimization levels.
This patch also introduces acle_sqrt.c in the AArch64 testsuite,
verifying that the new __sqrt and __sqrtf intrinsics emit the expected
fsqrt instructions for double and float arguments.
Coverage for new intrinsics ensures that __sqrt and __sqrtf are
correctly expanded to hardware instructions and do not fall back to
library calls, regardless of optimization levels.
gcc/ChangeLog:
* config/aarch64/arm_acle.h (__sqrt, __sqrtf): New function.
Ayan Shafqat [Thu, 1 May 2025 13:14:44 +0000 (06:14 -0700)]
Aarch64: Use BUILTIN_VHSDF_HSDF for vector and scalar sqrt builtins
This patch changes the `sqrt` builtin definition from `BUILTIN_VHSDF_DF`
to `BUILTIN_VHSDF_HSDF` in `aarch64-simd-builtins.def`, ensuring the
builtin covers half, single, and double precision variants. The redundant
`VAR1 (UNOP, sqrt, 2, FP, hf)` lines are removed, as they are no longer
needed now that `BUILTIN_VHSDF_HSDF` handles those cases.
gcc/ChangeLog:
* config/aarch64/aarch64-simd-builtins.def: Change
BUILTIN_VHSDF_DF to BUILTIN_VHSDF_HSDF.
Signed-off-by: Ayan Shafqat <ayan.x.shafqat@gmail.com> Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Jason Merrill [Tue, 29 Apr 2025 12:32:44 +0000 (08:32 -0400)]
c++: avoid weird #line paths in std-name-hint.h
etags was getting confused by the #line pathnames in std-name-hint.h that
don't match my directory layout; let's avoid encoding information about
a particular developer's $(srcdir) in the generated file.
gcc/cp/ChangeLog:
* Make-lang.in: Don't pass the full path to gperf.
* std-name-hint.h: Regenerate.
Jason Merrill [Tue, 11 Mar 2025 15:17:46 +0000 (11:17 -0400)]
c++: remove TREE_STATIC from constexpr heap vars [PR119162]
While working on PR119162 it occurred to me that it would be simpler to
detect the problem of a value referring to a heap allocation if we stopped
setting TREE_STATIC on them so they naturally are not considered to have a
constant address. With that change we no longer need to specifically avoid
caching a value that refers to a deleted pointer.
But with this change maybe_nonzero_address is not sure whether the variable
could have address zero. I don't understand why it returns 1 only for
variables in the current function, rather than all non-symtab decls; an auto
variable from some other function also won't have address zero. Maybe this
made more sense when it was in tree_single_nonzero_warnv_p before r7-5868?
But assuming there is some reason for the current behavior, this patch only
changes the handling of non-symtab decls when folding_cxx_constexpr.
PR c++/119162
gcc/cp/ChangeLog:
* constexpr.cc (find_deleted_heap_var): Remove.
(cxx_eval_call_expression): Don't call it. Don't set TREE_STATIC on
heap vars.
(cxx_eval_outermost_constant_expr): Don't mess with varpool.
gcc/ChangeLog:
* fold-const.cc (maybe_nonzero_address): Return 1 for non-symtab
vars if folding_cxx_constexpr.
Richard Biener [Wed, 30 Apr 2025 12:57:03 +0000 (14:57 +0200)]
Remove non-SLP path from vectorizable_conversion
This removes the non-SLP paths from vectorizable_conversion and
in the process eliminates uses of 'ncopies' and 'STMT_VINFO_VECTYPE'
from the function.
Jakub Jelinek [Thu, 1 May 2025 06:29:03 +0000 (08:29 +0200)]
combine: Special case set_noop_p in two spots
Here is the incremental patch I was talking about.
For noop sets, we don't need to test much, they can go to i2
unless that would violate i3 JUMP condition.
With this the try_combine on the pr119291.c testcase doesn't fail,
but succeeds and we get
(insn 22 21 23 4 (set (pc)
(pc)) "pr119291.c":27:15 2147483647 {NOOP_MOVE}
(nil))
(insn 23 22 24 4 (set (reg/v:SI 117 [ e ])
(reg/v:SI 116 [ e ])) 96 {*movsi_internal}
(expr_list:REG_DEAD (reg/v:SI 116 [ e ])
(nil)))
(note 24 23 25 4 NOTE_INSN_DELETED)
(insn 25 24 26 4 (set (reg/v:SI 116 [ e ])
(const_int 0 [0])) "pr119291.c":28:13 96 {*movsi_internal}
(nil))
(note 26 25 27 4 NOTE_INSN_DELETED)
(insn 27 26 28 4 (set (reg:DI 128 [ _9 ])
(const_int 0 [0])) "pr119291.c":28:13 95 {*movdi_internal}
(nil))
after it.
2025-05-01 Jakub Jelinek <jakub@redhat.com>
* combine.cc (try_combine): Sets which satisfy set_noop_p can go
to i2 unless i3 is a jump and the other set is not.
c++/modules: Ensure deduction guides for imported types are reachable [PR120023]
In the linked PR, because the deduction guides depend on an imported
type, we never walk the type and so never call add_deduction_guides.
This patch ensures that we make bindings for deduction guides if we saw
any deduction guide at all.
PR c++/120023
gcc/cp/ChangeLog:
* module.cc (depset::hash::find_dependencies): Also call
add_deduction_guides when walking one.
gcc/testsuite/ChangeLog:
* g++.dg/modules/dguide-7_a.C: New test.
* g++.dg/modules/dguide-7_b.C: New test.
* g++.dg/modules/dguide-7_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
c++/modules: Fix imported CNTTPs being considered non-constant [PR119938]
When importing a CNTTP object, since r15-3031-g0b7904e274fbd6 we
shortcut the processing of the generated NTTP so that we don't attempt
to recursively load pendings. However, due to an oversight we do not
properly set TREE_CONSTANT or DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P
on the decl, which confuses later processing. This patch ensures that
this happens correctly.
PR c++/119938
gcc/cp/ChangeLog:
* pt.cc (get_template_parm_object): When !check_init, add assert
that expr really is constant and mark decl as such.
gcc/testsuite/ChangeLog:
* g++.dg/modules/tpl-nttp-2_a.H: New test.
* g++.dg/modules/tpl-nttp-2_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
c++/modules: Catch exposures of TU-local values through inline references [PR119996]
In r15-9136-g0210bedf481a9f we started erroring for inline variables
that exposed TU-local entities in their definition, as such variables
would need to have their definitions emitted in importers but would not
know about the TU-local entities they referenced.
A case we mised was potentially-constant references, which disable
streaming of their definitions in make_dependency so as to comply with
[expr.const] p9.2. This meant that we didn't see the definition
referencing a TU-local entity, leading to nonsensical results.
PR c++/119551
PR c++/119996
gcc/cp/ChangeLog:
* module.cc (depset::hash::make_dependency): Also mark inline
variables referencing TU-local values as exposures here.
(depset::hash::finalize_dependencies): Add error message for
inline variables.
gcc/testsuite/ChangeLog:
* g++.dg/modules/internal-13.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Andrew Pinski [Wed, 30 Apr 2025 22:10:29 +0000 (15:10 -0700)]
vectorizer: Fix riscv build [PR120042]
r15-9859-ga6cfde60d8c added a call to dominated_by_p to tree-vectorizer.h
but dominance.h is not always included; and you get a build failure on riscv building
riscv-vector-costs.cc.
Let's add the include of dominance.h to tree-vectorizer.h
Pushed as obvious after builds for riscv and x86_64.
gcc/ChangeLog:
PR target/120042
* tree-vectorizer.h: Include dominance.h.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
The SARIF 2.1.0 spec says that although a "SARIF log file SHALL contain
a serialization of the SARIF object model into the JSON format ... in the
future, other serializations might be defined." (§3.1)
I've been experimenting with alternative serializations of SARIF (CBOR
and JSON5 for now). To help with these experiments, this patch adds a
new param "serialization" to -fdiagnostics-add-output='s "sarif" scheme.
For now this must have value "json", but will be helpful for any
followup patches.
gcc/ChangeLog:
* diagnostic-format-sarif.cc
(sarif_serialization_format_json::write_to_file): New.
(sarif_builder::m_formatted): Replace field with...
(sarif_builder::m_serialization_format): ...this.
(sarif_builder::sarif_builder): Update for field change.
(sarif_builder::flush_to_file): Call m_serialization_format's
write_to_file vfunc.
(sarif_output_format::sarif_output_format): Replace param
"formatted" with "serialization_format".
(sarif_stream_output_format::sarif_output_format): Likewise.
(sarif_file_output_format::sarif_file_output_format): Likewise.
(diagnostic_output_format_init_sarif_stderr): Make a
sarif_serialization_format_json and pass it to
diagnostic_output_format_init_sarif.
(diagnostic_output_format_open_sarif_file): Split out into...
(diagnostic_output_file::try_to_open): ...this, adding
"serialization_kind" param.
(diagnostic_output_format_init_sarif_file): Update for new param
to diagnostic_output_format_open_sarif_file. Make a
sarif_serialization_format_json and pass it to
diagnostic_output_format_init_sarif.
(diagnostic_output_format_init_sarif_stream): Make a
sarif_serialization_format_json and pass it to
diagnostic_output_format_init_sarif.
(make_sarif_sink): Replace param "formatted" with "serialization".
(selftest::test_make_location_object): Update for changes to
sarif_builder ctor.
* diagnostic-format-sarif.h (enum class sarif_serialization): New.
(diagnostic_output_format_open_sarif_file): Add param
"serialization_kind".
(class sarif_serialization_format): New.
(class sarif_serialization_format_json): New.
(make_sarif_sink): Replace param "formatted" with
"serialization_format".
* diagnostic-output-file.h (diagnostic_output_file::try_to_open):
New decl.
* diagnostic.h (enum diagnostics_output_format): Tweak comments.
* doc/invoke.texi (-fdiagnostics-add-output): Add "serialization"
param to sarif scheme.
* libgdiagnostics.cc (sarif_sink::sarif_sink): Update for change
to make_sarif_sink.
* opts-diagnostic.cc (sarif_scheme_handler::make_sink): Add
"serialization" param and pass it on to make_sarif_sink.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Wed, 30 Apr 2025 20:50:16 +0000 (16:50 -0400)]
analyzer: add more test coverage for sprintf
gcc/testsuite/ChangeLog:
PR analyzer/107017
* c-c++-common/analyzer/sprintf-3.c: New test, covering use of
sprintf with specific format strings. Doesn't yet find problems
as the analyzer doesn't yet understand the format strings.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Wed, 30 Apr 2025 20:50:15 +0000 (16:50 -0400)]
analyzer: avoid saying "'0' is NULL"
gcc/analyzer/ChangeLog:
* sm-malloc.cc (malloc_diagnostic::describe_state_change): Tweak
the "EXPR is NULL" message for the case where EXPR is a null
pointer.
In r15-123 and r14-11434 we unconditionally set processing_template_decl
when substituting the context of an UNBOUND_CLASS_TEMPLATE, in order to
handle instantiation of the dependently scoped friend declaration
template<int N>
template<class T>
friend class A<N>::B;
where the scope A<N> remains dependent after instantiation. But this
turns out to misbehave for the UNBOUND_CLASS_TEMPLATE in the below
testcase representing
g<[]{}>::template fn
since with the flag set substituting the args of test3 into the lambda
causes us to defer the substitution and yield a lambda that still looks
dependent, which in turn makes g<[]{}> still dependent and not suitable
for qualified name lookup.
This patch restricts setting processing_template_decl during
UNBOUND_CLASS_TEMPLATE substitution to the case where there are multiple
levels of introduced template parameters, as in the friend declaration.
(This means we need to substitute the template parameter list(s) first,
which makes sense since they lexically appear first.)
PR c++/119981
PR c++/119378
gcc/cp/ChangeLog:
* pt.cc (tsubst) <case UNBOUND_CLASS_TEMPLATE>: Substitute
into template parameter list first. When substituting the
context, only set processing_template_decl if there's more
than one level of introduced template parameters.
Richard Biener [Tue, 29 Apr 2025 13:08:52 +0000 (15:08 +0200)]
tree-optimization/119960 - add validity checking to SLP scheduling
The following adds checks that when we search for a vector stmt
insert location we arrive at one where all required operand defs
are dominating the insert location. At the moment any such
failure only blows up during SSA verification.
There's the long-standing issue that we do not verify there
exists a valid schedule of the SLP graph from BB vectorization
into the existing CFG. We do not have the ability to insert
vector stmts on the dominance frontier "end", nor to insert
LC PHIs that would be eventually required.
This should be done all differently, computing the schedule
during analysis and failing if we can't schedule.
The following addresses a too conservative sanity check of SLP nodes
we want to promote external. The issue lies in code generation
for such external which relies on get_later_stmt to figure an
insert location. But get_later_stmt relies on the ability to
totally order stmts, specifically implementation-wise that they
are all from the same BB, which is what is verified at the moment.
The patch changes this to require stmts to be orderable by
dominance queries. For simplicity and seemingly enough for the
testcase in PR119960, this handles the case of two distinct BBs.
PR tree-optimization/119960
* tree-vect-slp.cc (vect_slp_can_convert_to_external):
Handle cases where defs from multiple BBs are ordered
by their dominance relation.
Richard Biener [Wed, 30 Apr 2025 08:01:47 +0000 (10:01 +0200)]
ipa/120006 - wrong code with IPA PTA
When PTA gets support for special-handling more builtins in
find_func_aliases the corresponding code in find_func_clobbers
needs updating as well since for unhandled cases it assumes
the former will populate ESCAPED accordingly. The following
fixes a few omissions, the testcase runs into the missing strdup
handling. I believe the more advanced handling using modref
results and fnspecs opened a larger gap, the proper fix is to
merge both functions, gating the clobber/use part on a parameter
to avoid diverging.
Richard Biener [Wed, 30 Apr 2025 09:52:17 +0000 (11:52 +0200)]
tree-optimization/120003 - missed jump threading
The following allows the entry and exit block of a jump thread path
to be equal, which can easily happen when there isn't a forwarder
on the interesting edge for an FSM thread conditional. We just
don't want to enlarge the path from such a block.
PR tree-optimization/120003
* tree-ssa-threadbackward.cc (back_threader::find_paths_to_names):
Allow block re-use but do not enlarge the path beyond such a
re-use.
* gcc.dg/tree-ssa/ssa-thread-23.c: New testcase.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Adjust.
Eric Botcazou [Wed, 30 Apr 2025 10:41:36 +0000 (12:41 +0200)]
Fix GNAT build failure for x86/FreeBSD
gcc/ada/
PR ada/112958
* Makefile.rtl (LIBGNAT_TARGET_PAIRS) [x86 FreeBSD]: Add specific
version of s-dorepr.adb.
* libgnat/s-dorepr__freebsd.adb: New file.
AVR: target/119989 - Add missing clobbers to xload_<mode>_libgcc.
libgcc's __xload_1...4 is clobbering Z (and also R21 is some cases),
but avr.md had clobbers of respective GPRs only up to reload.
Outcome was that code reading from the same __memx address twice
could be wrong. This patch adds respective clobbers.
Forward-port from 2025-04-30 r14-11703
PR target/119989
gcc/
* config/avr/avr.md (xload_<mode>_libgcc): Clobber R21, Z.
gcc/testsuite/
* gcc.target/avr/torture/pr119989.h: New file.
* gcc.target/avr/torture/pr119989-memx-1.c: New test.
* gcc.target/avr/torture/pr119989-memx-2.c: New test.
* gcc.target/avr/torture/pr119989-memx-3.c: New test.
* gcc.target/avr/torture/pr119989-memx-4.c: New test.
* gcc.target/avr/torture/pr119989-flashx-1.c: New test.
* gcc.target/avr/torture/pr119989-flashx-2.c: New test.
* gcc.target/avr/torture/pr119989-flashx-3.c: New test.
* gcc.target/avr/torture/pr119989-flashx-4.c: New test.
Kito Cheng [Tue, 29 Apr 2025 03:35:00 +0000 (11:35 +0800)]
RISC-V: Allow different dynamic floating point mode to be merged [PR119832]
Although we already try to set the mode needed to FRM_DYN after a function call,
there are still some corner cases where both FRM_DYN and FRM_DYN_CALL may appear
on incoming edges.
Therefore, we use TARGET_MODE_CONFLUENCE to tell GCC that FRM_DYN, FRM_DYN_CALL,
and FRM_DYN_EXIT modes are compatible.
The Zve32x extension depends on the Zicsr extension.
Currently, enabling Zve32x alone does not automatically imply Zicsr in GCC.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc: Add Zve32x depends on Zicsr
gcc/testsuite/ChangeLog:
* gcc.target/riscv/predef-19.c: set the march to rv64im_zve32x
instead of rv64gc_zve32x to avoid Zicsr implied by g. Extra m is
added to avoid current 'V' extension requires 'M' extension
Signed-off-by: Jerry Zhang Jian <jerry.zhangjian@sifive.com>
Jennifer Schmitz [Thu, 13 Feb 2025 12:34:30 +0000 (04:34 -0800)]
AArch64: Fold LD1/ST1 with ptrue to LDR/STR for 128-bit VLS
If -msve-vector-bits=128, SVE loads and stores (LD1 and ST1) with a
ptrue predicate can be replaced by neon instructions (LDR and STR),
thus avoiding the predicate altogether. This also enables formation of
LDP/STP pairs.
were previously compiled to
(with -O2 -march=armv8.2-a+sve -msve-vector-bits=128):
ptrue_load:
ptrue p3.b, vl16
ld1d z0.d, p3/z, [x0]
ret
ptrue_store:
ptrue p3.b, vl16
st1d z0.d, p3, [x0]
ret
Now the are compiled to:
ptrue_load:
ldr q0, [x0]
ret
ptrue_store:
str q0, [x0]
ret
The implementation includes the if-statement
if (known_eq (GET_MODE_SIZE (mode), 16)
&& aarch64_classify_vector_mode (mode) == VEC_SVE_DATA)
which checks for 128-bit VLS and excludes partial modes with a
mode size < 128 (e.g. VNx2QI).
The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for mainline?
Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* config/aarch64/aarch64.cc (aarch64_emit_sve_pred_move):
Fold LD1/ST1 with ptrue to LDR/STR for 128-bit VLS.
* gcc.target/riscv/rvv/xsfvector/sf_vc_f.c: New test.
* gcc.target/riscv/rvv/xsfvector/sf_vc_i.c: New test.
* gcc.target/riscv/rvv/xsfvector/sf_vc_v.c: New test.
* gcc.target/riscv/rvv/xsfvector/sf_vc_x.c: New test.
Adapt testsuite v3_target_compile to strip version namespace from compiler
output so that dg-error and dg-warning directives do not need to consider it.
Avoid a aligned_storage check as behavior has been fixed only when using
gnu-versioned-namespace as it is an abi breaking change.
libstdc++-v3/ChangeLog:
* testsuite/lib/libstdc++.exp (v3_target_compile): Strip version namespace
from compiler output.
* testsuite/20_util/aligned_storage/value.cc [_GLIBCXX_INLINE_VERSION]:
Avoid align_msa check.
* testsuite/20_util/function/cons/70692.cc: Remove now useless __8 namespace
pattern.
* testsuite/23_containers/map/48101_neg.cc: Likewise.
* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Tomasz Kamiński [Fri, 25 Apr 2025 18:10:52 +0000 (20:10 +0200)]
libstdc++: Fix _Padding_sink in case when predicted width is between padwidth and maxwidth [PR109162]
The _Padding_sink was behaving incorrectly, when the predicted width (based on
code units count) was higher than _M_maxwidth, but lower than _M_padwidth.
In this case _M_update() returned without calling _M_force_update() and computing
field width for Unicode encoding, because _M_buffering() returned 'true'.
As a consequence we switched to _M_ignoring() mode, while storing a sequence
with more code units but smaller field width than _M_maxwidth.
We now call _M_force_update() if predicted width is greater or equal to either
_M_padwidth or _M_maxwidth.
This happened for existing test case on 32bit architecture.
PR libstdc++/109162
libstdc++-v3/ChangeLog:
* include/std/format (_Padding_sink::_M_update): Fixed condition for
calling _M_force_update.
* testsuite/std/format/debug.cc: Add test that reproduces this issue
on 64bit architecture.
* testsuite/std/format/ranges/sequence.cc: Another edge value test.