Andrea Pinski [Mon, 13 Jul 2026 22:20:09 +0000 (15:20 -0700)]
phiopt: New comparison combine part of phiopt [PR126138]
Since phiopt rejects trapping statements, this has to be done
seperately but it does reuse most of the infastructure to handle
this.
This is designed to handle foating point comparisons mergining
with another one.
An example is:
```
c = false;
if (a > b) c = a >= b;
```
This should merge into just `c = a > b;`.
Which we do already if it was written as `a > b && a >= b`.
In this case this is already handled by DOM/VRP/ranger.
The case I am more interesting in is:
```
bool f1(double a, double b)
{
if (a == b)
return 1;
return a > b;
}
```
Which can/should optimize to `a >= b`.
This comes from `(a <=> b) >= 0` without spaceship_replacement and/or
with a patch that forwprops the phi values into the `>= 0`; replacing
the phi.
That is this is prerequisite to
https://inbox.sourceware.org/gcc-patches/20260625233902.2605630-1-andrew.pinski@oss.qualcomm.com/.
and to remove spaceship_replacement in phiopt.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/126138
gcc/ChangeLog:
* tree-ssa-phiopt.cc (one_feeding_comparison_into_p): New function.
(comparison_combine): New function.
(pass_phiopt::execute): Call comparison_combine.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/fp-trapping-cmp-4.c: New test.
* gcc.dg/tree-ssa/fp-trapping-cmp-5.c: New test.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
We can sometimes combine comparisons that are trapping.
This adds that optimization to ifcombine; using combine_comparison
from fold-const to do most of the work.
This does not handle all cases though; mostly dealing with where we need an
inversion of the outer comparison and it does not invert is not currently handled.
This will be handled later on as it needs some extra code added to combine_comparisons.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/126138
gcc/ChangeLog:
* tree-ssa-ifcombine.cc (bb_no_side_effects_p): Don't reject GIMPLE_COND
that can trap.
(ifcombine_ifandif): Handle trapping inner conditional specially.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/fp-trapping-cmp-2.c: New test.
* gcc.dg/tree-ssa/fp-trapping-cmp-3.c: New test.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
Andrea Pinski [Sun, 12 Jul 2026 05:56:40 +0000 (22:56 -0700)]
fold: Allow combining eq/ne with a trapping to get a trapping [PR126138]
For `(i == j) || (i < j)` this can be combined to just `i <= j` without
worrying about removal of a trap as a NaN would cause the the equal to be
false which will cause not to short circuit and the trapping instruction
will always be executed.
`(i != j) && (i < j)` has the same reasoning.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/126138
gcc/ChangeLog:
* fold-const.cc (combine_comparisons): Allow eq to combine
with || and ne combine with && if the original rcode was trapping
and the new code is trapping.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/fp-trapping-cmp-1.c: New test.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
Patrick Palka [Sat, 25 Jul 2026 20:12:19 +0000 (16:12 -0400)]
c++: function NTTP argument in pack considered unused [PR126280]
This is just the pack version of PR c++/105848, in which our non-dependent
call pruning may cause us to not mark an otherwise unused function pointer
template argument within a pack as used.
PR c++/126280
gcc/cp/ChangeLog:
* pt.cc (mark_template_arguments_used): Split out loop into ...
(mark_template_arguments_used_1): ... here. Recurse into
argument packs.
Patrick Palka [Sat, 25 Jul 2026 20:12:13 +0000 (16:12 -0400)]
libstdc++: Optimize flat_map range insertion for pair-like elements
When inserting a range of pair-like elements we can avoid constructing a
value_type (i.e. pair) temporary and instead obtain the corresponding key
and value directly from *__first.
This came up when looking at LWG 4499 for flat_set::insert_range (which
I think we already optimally implement) but it prompted me to look at
flat_map::insert_range during which I noticed this extra std::move.
libstdc++-v3/ChangeLog:
* include/std/flat_map (flat_map::_M_insert): Avoid constructing
value_type temporary when the iterator already has pair-like
elements.
* testsuite/23_containers/flat_map/1.cc (test14): New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Jakub Jelinek [Sat, 25 Jul 2026 19:56:48 +0000 (21:56 +0200)]
Use HOST_SIZE_T_PRINT_UNSIGNED in a few other spots
On Thu, Jul 23, 2026 at 12:06 PM John David Anglin <dave.anglin@bell.net> wrote:
> Not all hosts support the "z" format length modifier. Noticed
> by inspection.
That is not the only spot that does this though.
I've grepped for printf.*%z and found this.
2026-07-25 Jakub Jelinek <jakub@redhat.com>
gcc/
* sym-exec/sym-exec-expression.cc (symbolic_bit::print): Use
HOST_SIZE_T_PRINT_UNSIGNED instead of "%zu" and add cast to
fmt_size_t.
* genoutput.cc (main): Likewise.
gcc/cobol/
* symbols.cc (symbols_dump): Use HOST_SIZE_T_PRINT_UNSIGNED instead
of "%zu" and add cast to fmt_size_t.
Reviewed-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
This patch introduces __negdi2_r10 to lib1funcs.S and tidies
some 64-bit negations.
libgcc/
* config/avr/t-avr (FUNCS_notiny): Add _negdi2_r10.
* config/avr/lib1funcs.S (__negdi2_r10): New function.
(__divdi3_moddi3): Use it.
* config/avr/lib1funcs-fixed.S (__mulQ64_work): Use it.
ifcvt: Keep only reaching definitions when rewiring sets [PR126184]
init_noce_multiple_sets_info records earlier SET destinations that are
mentioned by a later SET source. When a pseudo is set more than once, only
its most recent prior definition reaches that source.
Recording every definition is unsafe in the second
noce_convert_multiple_sets_1 attempt. The newest definition can be emitted
directly into its target pseudo, making its replacement a no-op. A later
replacement using an older definition then substitutes a stale value.
PR126184 contains the following dependency chain:
c = x + 1;
x = c * y;
c = z + 3;
y = c * x;
The unfixed conversion computes the last multiply with the temporary that
holds `x + 1`, rather than the reaching `z + 3` value.
The unfixed final sequence forms `x + 1` in x0 and later uses x0 as the
multiply operand:
add x0, x1, 1
csel x1, x1, x3, eq
mul x0, x1, x0
With the fix, x3 retains z until `z + 3` is formed and used by the multiply:
add x3, x3, 3
csel x0, x0, x1, ne
mul x3, x0, x3
Walk definitions from newest to oldest and record only the first match for
each pseudo. Add an AArch64 execution test for the reported dependency.
Bootstrapped and tested on aarch64-none-linux-gnu and
x86_64-pc-linux-gnu.
gcc/ChangeLog:
PR rtl-optimization/126184
* ifcvt.cc (init_noce_multiple_sets_info): Record only the most
recent prior definition of each pseudo register.
gcc/testsuite/ChangeLog:
PR rtl-optimization/126184
* gcc.target/aarch64/pr126184.c: New test.
ifcvt: Reject hard-register destinations in multiple sets [PR126184]
noce_convert_multiple_sets keys its dependency information by destination
register number. Hard registers can have overlapping definitions in
different modes. An exact RTL replacement cannot represent the value from a
partial or mode-changing definition.
Reject hard-register destinations in the block eligibility check. Assert
the resulting pseudo-only invariant when dependency information is
initialized.
Add an RTL execution test with mixed-mode hard-register definitions. It
verifies that the block remains unconverted.
Bootstrapped and regtested on aarch64-none-linux-gnu and
x86_64-pc-linux-gnu.
gcc/ChangeLog:
PR rtl-optimization/126184
* ifcvt.cc (init_noce_multiple_sets_info): Assert that destinations
are pseudos.
(bb_ok_for_noce_convert_multiple_sets): Reject hard-register
destinations.
gcc/testsuite/ChangeLog:
PR rtl-optimization/126184
* gcc.target/aarch64/pr126184-2.c: New test.
Robert Dubner [Sat, 25 Jul 2026 04:57:49 +0000 (00:57 -0400)]
cobol: ACCEPT <DATE> into subscripted and reference-modified variables.
The principal changes here are so that ACCEPT X(N) FROM <date-funcs> and
ACCEPT Y(A:B) FROM <date-funcs> work.
Another set of changes modifies SELECT ASSIGN to handle certain IBM
requirements about TO DEVICE syntax.
There are also changes here that improve the execution time of certain types
of MOVE statements.
gcc/cobol/ChangeLog:
* cbldiag.h (struct cbl_loc_t): Mollify cppcheck.
* gcobol.1: Documentation.
* genapi.cc (parser_accept_date_yymmdd): Changes to ACCEPT.
(parser_accept_date_yyyymmdd): Likewise.
(parser_accept_date_yyddd): Likewise.
(parser_accept_date_yyyyddd): Likewise.
(parser_accept_date_dow): Likewise.
(parser_accept_date_hhmmssff): Likewise.
(walk_initialization): Propagate based_e attribute to child variables.
(parser_file_open): SELECT ASSIGN TO DEVICE changes.
(parser_call): Include function name in error message when the
function name cannot be found.
* genapi.h (parser_accept_date_yymmdd): Changes to ACCEPT.
(parser_accept_date_yyyymmdd): Likewise.
(parser_accept_date_yyddd): Likewise.
(parser_accept_date_yyyyddd): Likewise.
(parser_accept_date_dow): Likewise.
(parser_accept_date_hhmmssff): Likewise.
* genutil.cc (FIXED_WIDE_INT): Potential improvement to MOVE
statements involving intermediate_e variables.
(get_power_of_two): Likewise.
* genutil.h (FIXED_WIDE_INT): Likewise.
* lexio.h (struct filespan_t): Mollify cppcheck.
* move.cc (mh_identical): Improve MOVE execution speed.
(copy_native_into_place): Likewise.
(copy_intermediate_into_place): Likewise.
(mh_to_binary): Likewise.
(move_helper): Likewise.
* parse.y: Changes to ACCEPT.
* symbols.cc (symbol_table_init): Add external_e attribute to
DEBUG-ITEM and children.
(new_temporary_impl): Mollify cppcheck.
* symfind.cc (struct funcname): Likewise.
* util.cc (determine_intermediate_type): Set output.data.digits to
zero.
libgcobol/ChangeLog:
* constants.cc (struct cblc_field_t): Add external_e attribute to
DEBUG-ITEM and children.
* libgcobol.cc (field_from_ascii): Changes to ACCEPT.
(__gg__get_date_yymmdd): Likewise.
(__gg__get_date_yyyymmdd): Likewise.
(__gg__get_date_yyddd): Likewise.
(__gg__get_yyyyddd): Likewise.
(__gg__get_date_dow): Likewise.
(__gg__get_date_hhmmssff): Likewise.
(format_for_display_internal): Initialize an automatic variable.
(default_exception_handler): Include function name in "missing
function" run-time error.
(__gg__set_exception_code): Likewise.
(__gg__set_exception_call): Likewise.
gcc/testsuite/ChangeLog:
* cobol.dg/group2/ACCEPT_FROM__date__with_subscripts_and_refmods.cob: New test.
* cobol.dg/group2/ACCEPT_FROM__date__with_subscripts_and_refmods.out: New test.
* cobol.dg/group2/MOVE__identical__operations.cob: New test.
* cobol.dg/group2/MOVE__identical__operations.out: New test.
* cobol.dg/group2/RT3574_PR__40-_Repository_section_intrinsic_funcs.cob: New test.
[PATCH v2] tree-optimization: Fix strlen(s) != 0 not folded into *s [PR92408]
Checks for strlen(s) == 0 could be rewritten as *s == 0 in the simple
case, but in complex cases (such as those involving variable
assignment), the optimization wouldn't be implemented. Fix this
by moving it over to forwprop from fold-const. Although, since
this currently only runs when PROP_last_full_fold is set, the
original code is kept in as well.
Bootstrapped and tested on x86_64-pc-linux-gnu
PR tree-optimization/92408
gcc/ChangeLog:
* tree-ssa-forwprop.cc (optimize_strlen_comp): Rewrite
strlen(s) == 0 as *s == 0 and strlen(s) != 0 as *s != 0.
(simplify_builtin_call): Added call to optimize_strlen_comp.
gcc/testsuite/ChangeLog:
* gcc.dg/pr92408.c: New test.
testsuite: Split rs6000 mma related PR test cases to dmf and nodmf
Hi Michael,
The same changes as done for 1/2 patch is done for this as well. Kindly
review and approve for trunk and gcc-16.
Thanks,
Avinash
Changes from v1:
* Use dmf, nodmf instead of p10 and future in updated test file names.
* Use powerpc_future_compile_ok for dmf tests.
* Use -mno-dense-math for nodmf tests.
All the remaining test cases which use mma functionality have been
split into power10 and future.
gcc/testsuite/ChangeLog:
PR target/100777
PR target/101849
PR target/102976
PR target/103127
PR target/104923
PR target/106016
PR target/106017
PR target/106833
PR target/110411
PR target/96446
PR target/96530
PR target/96808
PR target/97360
PR target/98872
* gcc.target/powerpc/pr100777.c: Move to...
* gcc.target/powerpc/pr100777.h: ...here.
* gcc.target/powerpc/pr101849.c: Move to...
* gcc.target/powerpc/pr101849.h: ...here.
* gcc.target/powerpc/pr103127.c: Move to...
* gcc.target/powerpc/pr103127.h: ...here.
* gcc.target/powerpc/pr104923.c: Move to...
* gcc.target/powerpc/pr104923.h: ...here.
* gcc.target/powerpc/pr106016.c: Move to...
* gcc.target/powerpc/pr106016.h: ...here.
* gcc.target/powerpc/pr106017.c: Move to...
* gcc.target/powerpc/pr106017.h: ...here.
* gcc.target/powerpc/pr110411-2.c: Move to...
* gcc.target/powerpc/pr110411-2.h: ...here.
* gcc.target/powerpc/pr96446.c: Move to...
* gcc.target/powerpc/pr96446.h: ...here.
* gcc.target/powerpc/pr96530.c: Move to...
* gcc.target/powerpc/pr96530.h: ...here.
* gcc.target/powerpc/pr96808.c: Move to...
* gcc.target/powerpc/pr96808.h: ...here.
* gcc.target/powerpc/pr97360.c: Move to...
* gcc.target/powerpc/pr97360.h: ...here.
* gcc.target/powerpc/pr98872.c: Move to...
* gcc.target/powerpc/pr98872.h: ...here.
* gcc.target/powerpc/pr102976.c: Removed.
* gcc.target/powerpc/pr103627-1.c: Removed.
* gcc.target/powerpc/pr106833.c: Removed.
* gcc.target/powerpc/pr100777.dmf.c: New test.
* gcc.target/powerpc/pr100777.nodmf.c: New test.
* gcc.target/powerpc/pr101849.dmf.c: New test.
* gcc.target/powerpc/pr101849.nodmf.c: New test.
* gcc.target/powerpc/pr102976.dmf.c: New test.
* gcc.target/powerpc/pr102976.h: New test.
* gcc.target/powerpc/pr102976.nodmf.c: New test.
* gcc.target/powerpc/pr103127.dmf.c: New test.
* gcc.target/powerpc/pr103127.nodmf.c: New test.
* gcc.target/powerpc/pr104923.dmf.c: New test.
* gcc.target/powerpc/pr104923.nodmf.c: New test.
* gcc.target/powerpc/pr106016.dmf.c: New test.
* gcc.target/powerpc/pr106016.nodmf.c: New test.
* gcc.target/powerpc/pr106017.dmf.c: New test.
* gcc.target/powerpc/pr106017.nodmf.c: New test.
* gcc.target/powerpc/pr106833.dmf.c: New test.
* gcc.target/powerpc/pr106833.h: New test.
* gcc.target/powerpc/pr106833.nodmf.c: New test.
* gcc.target/powerpc/pr110411-2.dmf.c: New test.
* gcc.target/powerpc/pr110411-2.nodmf.c: New test.
* gcc.target/powerpc/pr96446.dmf.c: New test.
* gcc.target/powerpc/pr96446.nodmf.c: New test.
* gcc.target/powerpc/pr96530.dmf.c: New test.
* gcc.target/powerpc/pr96530.nodmf.c: New test.
* gcc.target/powerpc/pr96808.dmf.c: New test.
* gcc.target/powerpc/pr96808.nodmf.c: New test.
* gcc.target/powerpc/pr97360.dmf.c: New test.
* gcc.target/powerpc/pr97360.nodmf.c: New test.
* gcc.target/powerpc/pr98872.dmf.c: New test.
* gcc.target/powerpc/pr98872.nodmf.c: New test.
Jeff Law [Fri, 24 Jul 2026 22:19:57 +0000 (16:19 -0600)]
Fix m68k bootstrap due to -Wempty-body warning
Ah the jobs of conditional compilation...
A recent change is breaking m68k bootstrap as it doesn't have any
UNSPECV_VALUES and as a result we end up with
if (cond)
;
[ With no else clauses. ]
Which triggers:
> /home/jlaw/test/gcc/gcc/print-rtl.cc: In function ‘void print_exp(pretty_printer*, const_rtx, int)’:
> /home/jlaw/test/gcc/gcc/print-rtl.cc:1622:11: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
Rather than using ";" we can use a "{}" pair with proper formatting as the
warning suggests.
Committing as obvious and hopefully restoring m68k bootstrap.
Andrea Pinski [Fri, 24 Jul 2026 20:47:02 +0000 (13:47 -0700)]
testsuite/aarch64: Update bitint-args.c for w vs x reg usage
bitint-args.c was failing due to the code produced by gcc,
now using the w form of register for f19. This code is
correct and expected form now after prefering the w form
over the x form.
Pushed as obvious after testing to make sure it works now.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/bitint-args.c (f19): Fix
expected form of sbfx to use the w form.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
Adjust check for addressable misaligned stack argument
ignores arguments passed on stack since caller is responsible to align
the outgoing stack for arguments passed on stack. However, callee may
spill a register argument:
Update ix86_argument_passed_on_stack_p to check spill of register argument
by callee.
gcc/
PR target/126320
* config/i386/i386.cc (ix86_spill_register_argument_p): New
function.
(ix86_argument_passed_on_stack_p): Add a pattern argument. Call
ix86_spill_register_argument_p to check spill of register argument
by callee.
(ix86_update_stack_alignment): Pass pat to
ix86_argument_passed_on_stack_p.
gcc/testsuite/
PR target/126320
* gcc.target/i386/pr126320.c: New test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Co-Authored-By: Uros Bizjak <ubizjak@gmail.com>
gcn: mkoffload - pass -L<dir> on to the amdgcn-amdhsa linker
Add a way to specify a linker-search path to the amdgcn-amdhsa/collect2
linker call, which is in particular useful as '.' (current directory) is
not in the search path.
Note that the -L specified to the host compiler are not passed to mkoffload,
i.e. only using a flag like --offload-options="-L." will affect the linker
search path.
gcc/ChangeLog:
* config/gcn/mkoffload.cc (main): Pass -L<dir> on to the
device compiler.
Pengfei Li [Fri, 17 Jul 2026 11:45:33 +0000 (11:45 +0000)]
AArch64: Update Neoverse V2 cost model for SVE structure loads/stores
The current Neoverse V2 cost model underestimates the costs of SVE
structure loads and stores. This can cause the vectorizer to make a
suboptimal choice between AdvSIMD and SVE.
This patch brings the cost model in line with the latest Neoverse V2
Software Optimization Guide, which indicates that SVE structure loads
and stores are generally more expensive than the AdvSIMD versions.
Performance testing shows this change improves SPEC CPU 2026 735.ocio_r
by ~10.8% on Neoverse V2.
Bootstrapped and tested on aarch64-linux-gnu.
gcc/ChangeLog:
* config/aarch64/tuning_models/neoversev2.h: Update the costs
of SVE structure loads and stores.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/cost_model_20.c: New test.
Richard Biener [Tue, 21 Jul 2026 13:10:24 +0000 (15:10 +0200)]
target/126328 - [x86] insn_cost of *sse3_h{add,sub}v2df3[_low]
I run into issues with gcc.target/i386/pr54400.c when SLP vectorizing
a horizontal reduction of a V2DF vector. The following plugs the
remaining hole in costing which prevents combine from doing its work
to recover the single hadd instruction for { p[0] + p[1], q[0] + q[1] }
The patch avoids the pattern cost special-casing of vec_concat
by costing the insn based on a new cost_special attribute which I placed
on all of the haddsub patterns.
PR target/126328
PR target/126383
* config/i386/i386.md (cost_special): New attribute.
* config/i386/sse.md (avx_h<insn>v4df3): Add cost_special
attribute with value haddsub.
(*sse3_haddv2df3): Likewise.
(sse3_hsubv2df3): Likewise.
(*sse3_haddv2df3_low): Likewise.
(*sse3_hsubv2df3_low): Likewise.
(avx_h<insn>v8sf3): Likewise.
(sse3_h<insn>v4sf3): Likewise.
* config/i386/i386.cc (ix86_insn_cost): Cost insns with
the cost_special attribute value of haddsub like an add.
Richard Biener [Fri, 24 Jul 2026 07:21:50 +0000 (09:21 +0200)]
Remove shift vectorization check from vect_build_slp_tree_1
The following removes the SLP discovery failure caused by not
vectorizable shifts. This does not belong here. I have kept
the heuristic that forces uniform shift operands when vector-vector
shifts are not supported.
* tree-vect-slp.cc (vect_build_slp_tree_1): Remove failure
on unvectorizable shifts.
Richard Biener [Tue, 21 Jul 2026 14:24:23 +0000 (16:24 +0200)]
Set INSN_CODE to recognized insn before calling insn_cost in combine
The following makes the recognized INSN_CODEs available to the
backends for costing via insn_cost.
PR target/126328
* combine.cc (combine_validate_cost): New arguments for
the insn codes. Set INSN_CODE to recognized values
before calling insn_cost.
(try_combine): Adjust.
Roger Sayle [Fri, 24 Jul 2026 06:21:48 +0000 (07:21 +0100)]
x86 SSE: Use insertps to zero V4SI/V4SF elements in a single instruction.
This patch teaches the x86 backend that the SSE4.1 insertps instruction
can be used/abused to clear one or more elements of a V4SI or V4SF vector
in a single instruction (i.e. without requiring pxor to clear a second
register).
foo: xorl %eax, %eax
vpinsrd $2, %eax, %xmm0, %xmm0
ret
with this patch we now generate:
foo: vinsertps $4, %xmm0, %xmm0, %xmm0
ret
For the more complicated example:
v4si bar(v4si x) { x[1]=0; x[3]=0; return x; }
previously, we'd generate:
bar: xorl %eax, %eax
vpinsrd $1, %eax, %xmm0, %xmm0
vpinsrd $3, %eax, %xmm0, %xmm0
ret
with this patch we now generate:
bar: vinsertps $10, %xmm0, %xmm0, %xmm0
ret
One improvement that I'll leave to an i386/SSE expert, is that setting
elements 1, 2 and 3 [i.e. zero extending element 0] still falls back
to the existing patterns (and tests for this are commented out in the
new test cases). Tweaking sse_movss_v4si to consider using insertps
requires expertise in register preferencing and instruction attributes
that I'm happy to leave to someone else.
2026-07-24 Roger Sayle <roger@nextmovesoftware.com>
Hongtao Liu <hongtao.liu@intel.com>
gcc/ChangeLog
* config/i386/i386-expand.cc (ix86_expand_vec_set_builtin): Don't
force op1 to a register when it is CONST0_RTX (mode1).
(ix86_expand_vector_set_var): For now, force VAL to a register.
(ix86_expand_vector_set): If val is CONST0_RTX, expand using
the new sse4_1_insertps_v4s[if]_zero patterns on TARGET_SSE4_1.
Otherwise, force val to a register (restoring previous behaviour).
* config/i386/sse.md (sse4_1_insertps_<mode>_zero): New insn
using vec_merge to select which elements to clear/preserve.
(vec_set<mode>): Tweak operand 1 to allow both REGs and CONST0_RTX.
gcc/testsuite/ChangeLog
* gcc.target/i386/sse4_1-insertps-6.c: New test case.
* gcc.target/i386/sse4_1-insertps-7.c: Likewise.
Philipp Tomsich [Thu, 23 Jul 2026 17:09:21 +0000 (19:09 +0200)]
ifcvt: drop redundant reversibility pre-checks in store-flag callers
The PR126347 fix (commit dcb8c8d3e733) made noce_emit_store_flag return
NULL_RTX whenever the requested (reversed) comparison code is UNKNOWN, so
every caller already copes with an unreversible condition through the
existing NULL_RTX return.
Remove the redundant guards and document the invariant on
noce_emit_store_flag, matching noce_try_store_flag_logical, which already
relies on the NULL_RTX return with no pre-check. The noce_reversed_cond_code
guards in noce_try_addcc and noce_try_cmove_arith protect a different
consumer and are left in place.
Bootstrapped and regression tested on x86_64-pc-linux-gnu with no
regressions.
gcc/
* ifcvt.cc (noce_emit_store_flag): Document that a NULL_RTX
return signals an unreversible condition.
(noce_try_store_flag): Drop redundant noce_reversed_cond_code
pre-check.
(noce_try_shifted_store_flag): Likewise.
(noce_try_store_flag_constants): Drop redundant can_reverse
guards on the reversed 2^n and -1 cases.
(noce_try_store_flag_mask): Set reversep unconditionally; the
store-flag emission now handles an unreversible condition.
libgfortran: Add additional long double math support for hppa64-hpux*
On hppa-hpux, we lack support for C99 math routines but the long
double type conforms to the standard 16-byte IEEE (IEC 60559)
specification. This allows us to use the quad routines from
libquadmath.
2026-07-22 John David Anglin <danglin@gcc.gnu.org>
testsuite: use arm_neon as xfail condition [PR118407]
Before r17-2558-g383854a7016ad2, the test predcom-8.c test was only
failing for -march=armv7ve+neon and -march=armv7ve+simd. After, there
are xpass for Cortex-M targets. Correct xfail condition to arm_neon to
rectify my mistake.
gcc/testsuite/ChangeLog:
PR testsuite/118407
* gcc.dg/tree-ssa/predcom-8.c: Use arm_neon as xfail condition.
rs6000: Builtins for MMA+ float16 outer product instructions
This patch adds builtins for the Matrix Multiply Assist Plus (MMA+)
float16 GER instructions. These instructions may or may not be
supported in a future Power processor. Specifically, builtins have been
added for the following instructions:
Float16 GER operations:
- dmxvf16gerx2 and its variants (pp, pn, np, nn)
- pmdmxvf16gerx2 and its variants (pp, pn, np, nn)
Note, the names of the builtins may change in the future.
Philipp Tomsich [Tue, 21 Jul 2026 19:19:53 +0000 (21:19 +0200)]
ifcvt: do not emit a store flag for an irreversible condition [PR126347]
noce_emit_store_flag feeds the possibly-reversed comparison code to a
store-flag insn, and to emit_store_flag, without checking that the
reversal succeeded. reversed_comparison_code returns UNKNOWN for
UNLT/UNLE/UNGT/UNGE, and for a MODE_CC comparison it cannot trace back
to its COMPARE -- common for a floating-point condition on targets that
compare into a condition-code register. emit_store_flag then reaches
its floating-point path and calls swap_condition (UNKNOWN), which aborts.
This was latent until r17-2519-ga33f26607eb4f3 made
noce_try_shifted_store_flag the first caller to reach
noce_emit_store_flag with REVERSEP set for such a condition.
Bail out early when the reversal failed.
Bootstrapped and regression tested on aarch64-unknown-linux-gnu with no
regressions.
PR rtl-optimization/126347
gcc/
* ifcvt.cc (noce_emit_store_flag): Return NULL_RTX when the
comparison code is UNKNOWN.
rs6000: Builtins for MMA+ bfloat16 and int8 instructions [RFC02658]
This patch adds builtins for the Matrix Multiply Assist Plus (MMA+)
instructions defined in RFC02658. These instructions may or may not be
supported in a future Power processor. Specifically, builtins have been
added for the following instructions:
1. Bfloat16 GER operations:
- dmxvbf16gerx2 and its variants (pp, pn, np, nn)
- pmdmxvbf16gerx2 and its variants (pp, pn, np, nn)
2. Signed accumulate variant for 8-bit integer GER operations:
- dmxvi8gerx4spp
- pmdmxvi8gerx4spp
Note, the names of the builtins may change in the future.
rs6000: Add DMR extract builtins for Dense Math support
Add two new builtins for extracting data from 1024-bit Dense Math
Registers (DMRs):
- __builtin_dmr_extract512 (void *, dmr1024 *, const int<2>):
extracts one 512-bit half of a DMR into four 128-bit vectors.
- __builtin_disassemble_dmr (void *, dmr1024 *):
extracts both 512-bit halves of a DMR into eight 128-bit vectors.
gcc:
* config/rs6000/rs6000-builtins.def (__builtin_dmr_extract512): New
built-in.
(__builtin_disassemble_dmr): Likewise.
(__builtin_dmr_extract512_internal): New internal built-in.
* config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_mma_builtin):
Exempt RS6000_BIF_DISASSEMBLE_DMR from the early-return guard.
Generate appropriate gimple code for the extract builtins.
gcc/testsuite:
* gcc.target/powerpc/dmf-extract512.c: New test.
* gcc.target/powerpc/dmf-disassemble-dmr.c: New test.
This is an attempt to implement <https://cplusplus.github.io/LWG/issue3819>.
My understanding of this issue is that previously, ref_xes_from_temporary
was defined by using is_constructible, which is implemented by seeing
if
T t(declval<Args>()...);
is well-formed. But declval always yields an xvalue, never a prvalue.
In practice this means that for
struct U {
U();
U(U&&) = delete;
};
struct T {
T(U);
};
reference_constructs_from_temporary_v<const T&, U> is false due
to the deleted move ctor. But if we have a prvalue, then the
call to the move ctor should be elided and so it doesn't matter
that it's deleted. So the result should be 'true'.
Our ref_xes_from_temporary already doesn't check is_constructible<T, U>
as the comment says, but we always use build_trait_object which
gives us an xvalue. What we need is to implement [meta.unary.prop]/5.2:
Otherwise [not a reference or function type], VAL<T> is a prvalue that
initially has type T. For this I've added build_prvalue_trait_object.
The finish_trait_expr change is so that get_target_expr doesn't crash
on an incomplete type. This change should be correct since
https://cplusplus.github.io/LWG/issue2939 didn't adjust
reference_xes_from_temporary the same way as is_convertible/constructible.
PR c++/112908
gcc/cp/ChangeLog:
* method.cc (build_prvalue_trait_object): New.
(ref_xes_from_temporary): Use build_prvalue_trait_object.
Use deferring_access_check_sentinel and cp_unevaluated. Don't
call force_rvalue or rvalue.
* semantics.cc (finish_trait_expr)
<case CPTK_REF_CONSTRUCTS_FROM_TEMPORARY>: Actually check
completeness.
gcc/testsuite/ChangeLog:
* g++.dg/ext/is_constructible8.C: Move
__reference_*_from_temporary testing to a new test.
* g++.dg/ext/reference_xes_from_temporary2.C: New test.
* g++.dg/ext/reference_xes_from_temporary3.C: New test.
Jakub Jelinek [Thu, 23 Jul 2026 13:42:10 +0000 (15:42 +0200)]
c++: Diagnose return from [[noreturn]] function during constant evaluation [PR126354]
This PR complains about g++ not diagnosing return from [[noreturn]]
function (which is UB) during constant evaluation.
This patch diagnoses that.
I haven't included the [[noreturn]] function name in the diagnostics
as it is printed in the context:
/home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp1y/pr126354.C:18:24: in 'constexpr' expansion of 'bar()'
/home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp1y/pr126354.C:15:7: in 'constexpr' expansion of 'foo(false)'
/home/jakub/src/gcc/gcc/testsuite/g++.dg/cpp1y/pr126354.C:15:7: error: '[[noreturn]]' call returns
But if you think it is better to emit
error ("%<[[noreturn]]%> %qD call returns", fun);
instead, I can certainly do that.
2026-07-23 Jakub Jelinek <jakub@redhat.com>
PR c++/126354
* constexpr.cc (cxx_eval_call_expression): Diagnose return from
[[noreturn]] function.
* g++.dg/cpp1y/pr126354.C: New test.
* g++.dg/cpp26/pr126354.C: New test.
and we replace '<retval>' with 'names', but we only call
recompute_tree_invariant_expr for the first ADDR_EXPR, not the latter.
For the second ADDR_EXPR d->changed will be false: the first replacement
changed the shared tree <retval>.D.3013. In replace_placeholders_r we
unshare_expr when replacing a PLACEHOLDER_EXPR, but we also replace
PLACEHOLDER_EXPRs in lookup_placeholder which didn't have this
unsharing.
PR c++/126215
gcc/cp/ChangeLog:
* constexpr.cc (lookup_placeholder): Do unshare_expr.
Anlai Lu [Tue, 30 Jun 2026 12:49:03 +0000 (12:49 +0000)]
libstdc++: Use __chrono_write via _S_empty_fs for chrono ostream insertion
Add __detail::__chrono_write which formats a chrono object into a
stack buffer via std::format_to_n with _S_empty_fs(), then writes
through __ostream_insert. A non-type template parameter _BufSize
allows per-type buffer tuning. Each _BufSize is the smallest power
of two that accommodates the longest possible formatted output for
that type, including error cases. All chrono operator<< overloads
that previously used std::format, std::vformat, or basic_stringstream
now use this helper.
libstdc++-v3/ChangeLog:
* include/bits/chrono_io.h (__formatter_chrono::_S_empty_fs):
Make public.
(__detail::__chrono_write): New function template.
(operator<<): Use __chrono_write consistently for all chrono
types.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com> Signed-off-by: Anlai Lu <agicy@qq.com>
libstdc++: Remove noexcept from basic_string instantiations [PR126327]
The explicit instantiations of basic_string's default constructor used
an unconditional noexcept specification. For the fully-dynamic COW
string, those default constructors are noexcept(false).
Remove noexcept from both the char and wchar_t instantiations.
Yan Churkin [Fri, 26 Jun 2026 19:45:31 +0000 (22:45 +0300)]
libstdc++: Don't dereference past-the-end iterator with overloaded operator&& [PR125981]
std::__find_if, std::__mismatch and std::__push_heap drove their loops
with a condition of the form
while (__first != __last && PREDICATE_CALL(...))
If the predicate/comparator result type has an ADL-reachable
operator&&(bool, T), overload resolution selects that user-defined
operator&& for the loop condition. It does not short-circuit, so the
operand that dereferences *__first is evaluated even when
__first == __last, dereferencing the past-the-end iterator.
Such a result type does not model boolean-testable, so this is undefined
behaviour and not a conformance issue. Handle it anyway as a QoI
extension, consistent with std::equal, std::binary_search and
std::__partition, by forcing the predicate result to bool so the
built-in && is used. This has no effect on well-behaved predicates; the
ranges:: versions are unaffected because their wrappers already return
bool.
PR libstdc++/125981
libstdc++-v3/ChangeLog:
* include/bits/stl_algobase.h (__find_if): Force the predicate
result to bool so that non-boolean_testable predicates cannot
cause a past-the-end iterator to be dereferenced.
(__mismatch): Likewise for both overloads.
* include/bits/stl_heap.h (__push_heap): Likewise for the
comparator result.
* testsuite/25_algorithms/find_if/overloaded_logical_ops.cc: New
test.
* testsuite/25_algorithms/mismatch/overloaded_logical_ops.cc:
New test.
Automake normally builds subdirectories sequentially, which makes the
libsanitizer builds effectively sequential as there is little parallelism per
subdirectory. This patch replaces the all-recursive loop with an explicit
dependency graph: asan and hwasan depend on lsan, while others just need
sanitizer_common.
Exposing this DAG to make raises the CPU load from 2.3 to 3.7, yielding a
roughly 30% reduction in build time on multi-core machines.
libsanitizer/ChangeLog:
* Makefile.am: Override all-recursive and define explicit
DAG dependencies for all-* targets to enable parallel builds.
* Makefile.in: Regenerate.
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl> Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Jakub Jelinek [Thu, 23 Jul 2026 09:14:21 +0000 (11:14 +0200)]
c++: Diagnose declaration of objects with anonymous union or struct types [CWG3130]
https://wg21.link/CWG3130 added
"All objects of such an unnamed type shall be such an unnamed object."
sentence which should prevent reusing anonymous union types (and by
extension anonymous struct types too) as types of some other declarations,
which in some cases ICEs, in other cases is just really weird and could
misbehave when trying to look things up etc.
That wording is IMHO bad, because creation of objects is what happens
at runtime, so it is something that really can't be diagnosed by the compiler
because it doesn't know if a variable, function parameter, temporary etc.
will be actually encountered during runtime or not.
This patch assumes this sentence is changed to something reasonable that
would disallow anything that can create such objects at compile time,
so, declaration of variables, function parameters, class members,
constructs that need temporaries of this type, or all of those with
a type (perhaps multidimensional) array of anonmous union/struct.
In addition to that, I've added an error trying to make derived types from
anonymous struct types (one can't make derived types from union types, so
that case isn't a problem).
2026-07-23 Jakub Jelinek <jakub@redhat.com>
gcc/cp/
* typeck2.cc: Implement part of CWG3130 - Naming function members of
anonymous unions.
(abstract_virtuals_error): Diagnose trying to create
an object with anonymous union or struct type.
* semantics.cc (finish_compound_literal): Call abstract_virtuals_error.
(finish_member_declaration): Diagnose named members with anonymous
union or struct type.
* decl.cc (xref_basetypes): Diagnose anonymous structs as bases.
gcc/testsuite/
* g++.dg/cpp0x/anon-union4.C: New test.
* g++.dg/reflect/anon6.C: New test.
* g++.dg/reflect/anon7.C: New test.
* g++.dg/reflect/anon8.C: New test.
* g++.dg/reflect/anon9.C: New test.
* g++.dg/template/anonunion3.C: Expect an error.
testsuite: Provide shf_link_order effective target
Like R_flag_in_section, the o_flag_in_section effective target is a
misnomer. It actually signifies support for the SHF_LINK_ORDER section
flag. Therefore this patch uses the et-static framework to determine it
from HAVE_GAS_SECTION_LINK_ORDER in auto-host.h, adapting the existing
uses.
Bootstrapped without regressions on i386-pc-solaris2.11 and
x86_64-pc-linux-gnu.
Richard Biener [Wed, 15 Jul 2026 08:37:57 +0000 (10:37 +0200)]
Support two-lane vector BB reductions without target support
The following implements BB reduction epilog handling for two-lane
vectors with lane extracts. This allows targets to omit defining
reduc_*_scal optabs for two lane vector modes and enables trivial
handling of in-order reductions with two lanes. The former is
one issue we run into with PR126028 on x86_64.
This causes some no-op vectorization since we now accept vector
costs equal to scalar costs.
For gcc.target/i386/pr54400.c this shows that after SLP vectorizing
a two lane reduction we are no longer able to match up the x86 haddpd
instruction I have sent a partial x86 backend fix.
For g++.target/i386/pr114187.C it shows the usual
argument/return costing difficulties but also a too broad testcase
and inadverted coverage of -m32 - I have adjusted the testcase.
PR tree-optimization/126028
* tree-vect-slp.cc (vect_slp_check_for_roots): Move
fold-left reduction check ...
(vectorizable_bb_reduc_epilogue): ... here and allow
two reduction lanes to be unaffected. Handle the two
vector lane without target support for the reduction.
(vectorize_slp_instance_root_stmt): Implement manual two-lane
reduction.
* gcc.dg/vect/bb-slp-reduc-1.c: New testcase for a two-lane
in-order reduction.
* c-c++-common/vector-subscript-4.c: Use -fno-vectorize.
* g++.target/i386/pr114187.C: Narrow pattern to better
only catch the reported issue.
The existing R_flag_in_section effective target is badly named: the name
carries no mnemonic value and is actually an implementation detail of a
specific assembler section flag syntax.
This patch uses the et-static framework to replace it by a new
gnu_retain keyword. Given that the existing R_flag_in_section
implementation checks for both HAVE_GAS_SHF_GNU_RETAIN and
HAVE_INITFINI_ARRAY_SUPPORT, this patch starts with matching
shf_gnu_retain and sht_init_array keywords and combines them into
gnu_retain proper.
The existing tests are adaptated accordingly.
Bootstrapped without regressions on i386-pc-solaris2.11 and
x86_64-pc-linux-gnu.
gcc/testsuite:
* lib/et-static.def (shf_gnu_retain, sht_init_array): New
effective targets.
* lib/target-supports.exp
(check_effective_target_R_flag_in_section): Remove.
(check_effective_target_gnu_retain): New proc.
testsuite: Don't use auto-host.h in target-supports.exp
Several effective targets use a complicated dance to determine their
values from auto-host.h. This prompted the et-static framework, which
is now used to replace their implementations.
Bootstrapped without regressions on i386-pc-solaris2.11 and
x86_64-pc-linux-gnu.
Like the gas/solaris_as case, a testcase actually checks if Solaris ld
is in use. This patch uses the et-static framework to introduce a
solaris_ld effective target for this.
Other uses of the existing gld effective target are about GNU ld
features and remain untouched.
Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11 (as/ld and gas/gld), and x86_64-pc-linux-gnu.
Several uses of the gas effective target in the testsuite are actually
about if Solaris as is in use. This patch uses the new framework to
generate effective targets from auto-host.h to introduce a solaris_as
effective target and adjusts affected tests accordingly.
The existing gas effective target remains, however, because other uses
are about using gas features in particular.
Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and
sparc64-unknown-linux-gnu.
i386: Update Suffix for AVX10.2 SAT CVT scalar Intrinsics
The previous _ep[i|u]{32,64} suffix for scalar SAT CVT intrinsics does
not match the intrinsic naming convention: scalar convert intrinsics
have used _[i|u]{32,64} (with _si{32,64} aliases for signed variants)
since AVX-512F, so the AVX10.2 scalar SAT CVT names need to follow the
same convention.
This patch renames the scalar SAT CVT intrinsics to use _[i|u]{32,64}
suffix and provides _si{32,64} aliases for the signed intrinsics.
gcc/ChangeLog:
* config/i386/avx10_2satcvtintrin.h
(_mm_cvtts_sd_i32): Renamed from _mm_cvtts_sd_epi32.
(_mm_cvtts_sd_si32): New alias of _mm_cvtts_sd_i32.
(_mm_cvtts_sd_u32): Renamed from _mm_cvtts_sd_epu32.
(_mm_cvtts_ss_i32): Renamed from _mm_cvtts_ss_epi32.
(_mm_cvtts_ss_si32): New alias of _mm_cvtts_ss_i32.
(_mm_cvtts_ss_u32): Renamed from _mm_cvtts_ss_epu32.
(_mm_cvtts_roundsd_i32): Renamed from _mm_cvtts_roundsd_epi32.
(_mm_cvtts_roundsd_si32): New alias of _mm_cvtts_roundsd_i32.
(_mm_cvtts_roundsd_u32): Renamed from _mm_cvtts_roundsd_epu32.
(_mm_cvtts_roundss_i32): Renamed from _mm_cvtts_roundss_epi32.
(_mm_cvtts_roundss_si32): New alias of _mm_cvtts_roundss_i32.
(_mm_cvtts_roundss_u32): Renamed from _mm_cvtts_roundss_epu32.
(_mm_cvtts_sd_i64): Renamed from _mm_cvtts_sd_epi64.
(_mm_cvtts_sd_si64): New alias of _mm_cvtts_sd_i64.
(_mm_cvtts_sd_u64): Renamed from _mm_cvtts_sd_epu64.
(_mm_cvtts_ss_i64): Renamed from _mm_cvtts_ss_epi64.
(_mm_cvtts_ss_si64): New alias of _mm_cvtts_ss_i64.
(_mm_cvtts_ss_u64): Renamed from _mm_cvtts_ss_epu64.
(_mm_cvtts_roundsd_i64): Renamed from _mm_cvtts_roundsd_epi64.
(_mm_cvtts_roundsd_si64): New alias of _mm_cvtts_roundsd_i64.
(_mm_cvtts_roundsd_u64): Renamed from _mm_cvtts_roundsd_epu64.
(_mm_cvtts_roundss_i64): Renamed from _mm_cvtts_roundss_epi64.
(_mm_cvtts_roundss_si64): New alias of _mm_cvtts_roundss_i64.
(_mm_cvtts_roundss_u64): Renamed from _mm_cvtts_roundss_epu64.
Expose existing vector conversion instructions through lrint optabs so
the vectorizer can use vcvtps2qq and vcvtpd2dq instead of scalar
conversion sequences.
gcc/ChangeLog:
PR target/126160
* config/i386/sse.md (lrint<ssePSmode2lower><mode>2): New expander.
(lrintv2sfv2di2): Likewise.
(ssedfsimode): New mode attribute.
(ssedfsimodelower): Likewise.
(lrint<mode><ssedfsimodelower>2): New expander.
gcc/testsuite/ChangeLog:
PR target/126160
* gcc.target/i386/pr126160.c: New test.
* gcc.target/i386/pr126160-2.c: New test.
rs6000: Update existing mma insns to use wD constraint and update %A printer
This patch replaces the 'd' constraint that was used for accumulators
previously since they overlapped with the FPRs, to use 'wD' constraint
and the new accumulator_operand in the existing mma define_insns. The
behaviour without dense-math option will be same as before, only if
dense-math option is used will the DMR registers be used.
It also updates the %A operand printer to print the DMR register numbers
instead of FPR if dense-math option is enabled
frange: Add a comparison function for range endpoints
IEEE calls -0.0 and +0.0 equal, but in frange they are distinct:
[+0.0, x] excludes -0.0 and [-0.0, x] includes it. We have been
fixing things on the fly at each modification site, either manually or
by calling combine_zeros to fix up the signs. This was hacky at best.
This patch removes the signed zero special casing by providing
frange_cmp(), a comparison function that orders -0.0 strictly below +0.0.
The ranges themselves are unchanged. The only difference is that we
are now more exact about whether we actually modified a range
containing a zero. Previously combine_zeros flagged a change whenever
the two ranges disagreed on the sign of a zero endpoint, even when the
canonical result was the sign we already had. This made union_ and
intersect return a changed range pessimistically. We are now more
accurate, so in theory the ranger cache should be happier.
With these cleanups we can start implementing multi-ranges for frange
without any special casing for signed zeros.
Tested on x86-64 and ppc64le Linux. No changes to assembly for a
corpus of preprocessed files from LAPACK. Also, LAPACK and GCC tests
pass as usual.
gcc/ChangeLog:
* value-range.cc (frange_cmp): New.
(frange::combine_zeros): Remove.
(frange::union_): Use frange_cmp to merge endpoints.
(frange::intersect): Likewise.
(frange::contains_p): Use frange_cmp.
(frange::verify_range): Use frange_cmp.
* value-range.h (class frange): Remove combine_zeros.
rs6000: Add Dense Math (DMF/MMA+) built-in/instruction support
Add support for the DMF (Dense Math Facility) and MMA+
(Matrix-Multiply Assist Plus) builtins and instructions which may be
available on a future Power processor.
This patch extends the existing MMA infrastructure to support Dense
Math Registers (DMRs).
Key changes:
1. Extended MMA operand support from 7 to 9 operands (MAX_MMA_OPERANDS)
2. Added new DMF-specific unspecs:
* UNSPEC_DMF_DMXOR for DMR XOR operations
* UNSPEC_DMF_DMXVI8GERX4* for DMR GER (outer product) operations
* UNSPEC_DMF_PMDMXVI8GERX4* for prefixed DMR GER operations
* UNSPEC_DMF_DMSETDMRZ for zeroing a DMR register
3. Implemented new instruction patterns in mma.md:
* dmf_build_dmr: Build a DMR from eight vector operands
* dmf_dmsetdmrz: Zero a DMR register
* dmf_dmxor: XOR operation on DMR registers
* dmf_dmxvi8gerx4/dmxvi8gerx4pp: DMR outer product operations
* dmf_pmdmxvi8gerx4/pmdmxvi8gerx4pp: Prefixed DMR outer product
operations
4. Added new DMF builtins and updated GIMPLE folding:
* Added DMF and MMA+ builtins
* Updated GIMPLE folding to handle DMR pass-by-reference semantics
* Extended builtin expansion to support up to 9 operand instructions
5. Added documentation for the new DMF and MMA+ builtins.
The implementation follows the existing MMA pattern where user-facing
builtins use pass-by-reference for DMR arguments, while internal
builtins use pass-by-value for optimization.
testsuite: prevent packing enum in vect-early-break_65.c [PR124112]
GCC might be compiled with -fshort-enum enabled by default.
For those targets, it is important that the enum type is not packed into
something smaller than int, or vectorization will not match.
gcc/testsuite/ChangeLog:
PR testsuite/124112
* gcc.dg/vect/vect-early-break_65.c: Prevent packing enum to a
smaller object.
The changes have been bootstrapped and regression tested on
powerpc64le-linux.
Register __dmr1024 as a new 1024-bit opaque built-in type, following
the same pattern as the existing __vector_pair (OOmode) and
__vector_quad (XOmode) opaque types. __dmr1024 uses TDOmode, which
was already added in a previous commit ("rs6000: Add TDOmode
support"), and is intended to hold the contents of a Dense Math
Register (DMR) when the Dense Math Facility (-mdense-math) is
enabled.
2026-07-22 Manjunath Matti <mmatti@linux.ibm.com>
gcc/
* config/rs6000/rs6000.h (RS6000_BTI_dmr1024): New enumerator.
(RS6000_BTI_ptr_dmr1024): New enumerator.
(dmr1024_type_node): New macro.
(ptr_dmr1024_type_node): New macro.
* config/rs6000/rs6000-builtin.cc (rs6000_type_string): Handle
dmr1024_type_node.
(rs6000_init_builtins): Register the __dmr1024 opaque type and
its pointer-to-const variant, with 512-bit alignment.
* config/rs6000/rs6000.cc (rs6000_mangle_type): Handle
dmr1024_type_node.
(rs6000_invalid_conversion): Reject conversions to/from TDOmode.
(rs6000_opaque_type_invalid_use_p): Gate __vector_quad and
__vector_pair on TARGET_MMA and __dmr1024 on TARGET_DMF
independently, and require -mdense-math for __dmr1024.
gcc/testsuite/
* gcc.target/powerpc/dmr1024-alignment.c: New test case.
* gcc.target/powerpc/dmr1024-compile.c: Likewise.
* gcc.target/powerpc/dmr1024-invalid-use-1.c: Likewise.
* gcc.target/powerpc/dmr1024-invalid-use-2.c: Likewise.
* gcc.target/powerpc/dmf-no-mma.c: Likewise.
Pan Li [Wed, 22 Jul 2026 01:33:45 +0000 (09:33 +0800)]
RISC-V: Add test cases for vfwcvt.rtz.xu.f.v reg overlap
Add test cases for register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_xu-f32-mf2.c: New test.
Pan Li [Wed, 22 Jul 2026 01:32:21 +0000 (09:32 +0800)]
RISC-V: Add test cases for vfwcvt.rtz.x.f.v reg overlap
Add test cases for register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_rtz_x-f32-mf2.c: New test.
Andrew Pinski [Mon, 22 Jun 2026 23:54:27 +0000 (16:54 -0700)]
phiopt: for non-diamond case, invoke a limited conditional store elimination
After adding a limited store elimination function which is always valid even
without non-trapping code, we can call this from phiopt to optimize earlier
some ifconversion. This should allow for earlier optimizations of say perlbmk.
Also since the _limited version does not depend on store sinking, to happen,
some cases in loops might be better optimized.
Changes since v1:
* v2: Add false argument to cond_store_replacement_limited. And add/fixup
testcases.
Andrew Pinski [Sun, 21 Jun 2026 06:01:07 +0000 (23:01 -0700)]
cselim: reduced cs-elim without non-trapping
This adds a reduced cs-elim functionality which will be used
from phiopt. The design is similar to cond_store_replacement except
we are looking for a similar store right beore the condition or a
non-trapping (no data races or local variable) load right before
the conditional. This allows for 2 things, the reuse of the same
aliasing set and second is allows for use in phiopt in a secondary patch.
It supports the inserting on the edge for the case where there is
no load/stores before the condition if the store is a non-trapping memory
with no data races; this is a similar to what is done in cond_store_replacement
already. Thia part is not going to be used with phiopt though as it is too
complex to support there and it adds a conditional load for no benifit for
phiopt.
Note pr99473-1.c of a case where can be optimized even without
-fallow-store-data-races now. The store happens before the conditional
and inside the conditional, so afterwards there is only one store rather
than 2. The code was also handling it in sink in GCC 12 the same way too
but now handling it in cselim before sink1.
Changes since v1:
* v2: Add support for loads before the conditional and support
for doing the load on the edge. Fix formating and comments.
* v3: Move and rename can_trap_as_a_store to tree-eh.cc (lhs_could_trap_p).
Rename may_alias_mem to copy_mem_with_alias_set_zero.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-eh.cc (lhs_could_trap_p): New function.
* tree-eh.h (lhs_could_trap_p): New decl.
* tree-ssa-phiopt.cc (copy_mem_with_alias_set_zero): New function.
(cond_store_replacement_limited): New function.
(pass_cselim::execute): Call cond_store_replacement_limited before
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr99473-1.c: Remove -fallow-store-data-races as it is not
needed with cond_store_replacement_limited.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
James K. Lowden [Wed, 22 Jul 2026 22:16:43 +0000 (18:16 -0400)]
cobol: Restrict CDF reserved words to CDF parsing.
Among others PARAMETER was captured as a reserved word during normal
parsing, which it is not. Move that and some other obvious CDF tokens
to the cdf_state start condition.
gcc/cobol/ChangeLog:
* scan.l: Make PARAMETER and friends unspecial outside CDF.
James K. Lowden [Wed, 22 Jul 2026 21:50:47 +0000 (17:50 -0400)]
cobol: Improve "sameness" test when deciding whether a CDF token was used.
In establishing whether or not the CDF parser discarded a lookahead
token, compare not just the last scanned token's type, but also its
location.
gcc/cobol/ChangeLog:
* cdf.y (cdf::location): New function.
* scan_post.h (same_end): New function to match token ending
locations.
(same_token): New function to match two tokens.
[frange] Consolidate signed-zero canonicalization of endpoints
The methods frange::set() and frange::flush_denormals_to_zero() canonicalize
ranges containing floating point zero endpoints differently. Whereas set()
includes both +0.0 and -0.0 in the range, so contains_p([+-]0.0) works, even
under -ffast-math, flush_denormals_to_zero() always sets the lower bound of a
positive denormal as +0.0, regardless of HONOR_SIGNED_ZEROS. This means that
contains_p(-0.0) would theoretically fail under -ffast-math.
In reality this last scenario doesn't happen because all users of zero endpoints
in the code are special casing signed zeros. Also, building a range with -0.0
would cause the set() canonicalization to kick in, and set the range to
[-0.0, +0.0] anyhow. Not only is this fragile at best, but in follow-up patches
I'd like to do some cleanup in this area, and one representation across the
board is in the spirit of what we've always tried to do with irange: a given
range should be representable in only one way (ok, not exactly cause we have
irange_bitmask's which complicate things, but we try ;-)).
Ultimately I'd like to implement sub-ranges for frange so we can represent
inequality with a constant, and tackle a couple of the signed zero PRs in this
area. But initially I just want to provide an frange_cmp() comparison
function that respects signed zeros, and lets users not have to worry about
special casing anything when dealing with endpoints.
For example, frange_cmp() will order -0.0 strictly below +0.0, so a membership
test becomes just two endpoint comparisons: -0.0 lands outside [+0.0, x] but
inside [-0.0, x], and nobody has to first ask "is this a zero, and if so which
one?". But that only works if a range always spells its zero endpoints the same
way. Today set() spells the lower zero of [0.0, 5.0] as -0.0 under -ffast-math,
while flush_denormals_to_zero() spells it +0.0, so one range ends up with two
bit patterns, and frange_cmp() would tell you [+0.0, 5.0] is a strict subset of
[-0.0, 5.0] even though they are the same range. Once both producers run
through canonicalize_zeros() the order is well defined, and when frange_cmp()
gets implemented, contains_p(), and the eventual sub-range union/intersect code
can just call it and drop their signed-zero special cases entirely.
This patch moves the canonicalization into one function that both set() and
flush_denormals_to_zero() can share. With it flush_denormals_to_zero() moves
the denormal endpoint to the zero on its side and lets canonicalize_zeros()
settle the sign, exactly as set() does.
I've included a selftest to test this: under -ffast-math, flushing
[+DENORM, 5.0] used to yield [+0.0, 5.0], while set() on the same range yields
[-0.0, 5.0]. With this patch, flushing also yields [-0.0, 5.0], matching set().
There's no observable change with this patch-- every consumer that reads the
sign of a zero endpoint already special-cases !HONOR_SIGNED_ZEROS, so nothing
today can tell the two representations apart.
Tested on x86-64 Linux with a full bootstrap and regtests. I also tested the
LAPACK suite for regressions, and I ran f951 over all the preprocessed Fortran
files in LAPACK and made sure there are no changes in the assembly with and
without this patch. Also, tested on ppc64le Linux, including LAPACK,
and making sure there are no changes in assembly with the preprocessed Fortran
files.
This is an internal-consistency fix and a prerequisite for upcoming patches
which will make the sign of a zero endpoint load-bearing.
gcc/ChangeLog:
* value-range.cc (frange::flush_denormals_to_zero): Collapse a
denormal endpoint to the zero of the same sign and defer the sign
to canonicalize_zeros.
(frange::canonicalize_zeros): New.
(frange::set): Use it.
(range_tests_flush_denormals): New.
(range_tests_floats): Call it.
* value-range.h (class frange): Declare canonicalize_zeros.
James K. Lowden [Wed, 22 Jul 2026 20:19:14 +0000 (16:19 -0400)]
cobol: Enable suppression of unimplemented exception conditions.
For each warning, provide both Wx and Wno-x in the specs string, so
that the driver passes both forms to the driver. This enables, in
addition to being able to defeat a default, to override the warning
status implied by a dialect.
gcc/cobol/ChangeLog:
* cobol1.cc (enable_exceptions): Remove redundant message.
* lang-specs.h: Provide both forms of every warning.
* parse.y: Remove deleterious comment.
Jerry DeLisle [Sat, 11 Jul 2026 04:47:59 +0000 (21:47 -0700)]
fortran: [PR78718] ICE in gfc_get_symbol_decl, at fortran/trans-decl.c
PR fortran/78718
gcc/fortran/ChangeLog:
* resolve.cc (was_declared): Recognize the RESULT attribute so a
function's result variable is not mistaken for a host-associated
symbol of the same name.
I noticed that as of commit 7cb252f60c1f600066300ede2781a2c9e3808adb
"libgomp: Add by-device capabilities for OpenMP 'omp requires' handling",
'libgomp.fortran/reverse-offload-5.f90' no longer XFAILs NVIDIA GPU offloading
execution, no matter whether non-USM or USM single-GPU system. That was
suspicious, given that this commit shouldn't cause any such difference in
behavior, per my understanding. Well, turns out, this commit indeed didn't
magically fix the failure, but it's just another case of non-existing static
type checking of flag values...
James K. Lowden [Wed, 22 Jul 2026 17:43:46 +0000 (13:43 -0400)]
cobol: Accept ASSIGN TO DEVICE.
For SELECT fd-name ASSIGN TO dev, "dev" may name either a runtime
environment variable (as previously) or, as now, an
implementation-defined device. New warnings govern dialect
variations. Fixes RT 3617.
gcc/cobol/ChangeLog:
* cbldiag.h (enum cbl_diag_id_t): New warnings.
* cobol1.cc (cobol_langhook_handle_option): Process warnings.
* gcobol.1: Document warnings and devices.
* lang-specs.h: Accept warngings.
* lang.opt: Define warnings.
* messages.cc: Associate warnings with dialects.
* parse.y: Parse new syntax.
Jerry DeLisle [Tue, 21 Jul 2026 16:15:50 +0000 (09:15 -0700)]
fortran: [PR53296] Fix character array-ctor function called twice
Avoid the redundant generated call to the pre chain when
no_function_call is set.
Also fix a related stack-buffer-overflow: gfc_conv_array_parameter
wrote over the array constructor's. The specified length was to short.
Use the explicit character type-spec length instead.
PR fortran/53296
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_conv_procedure_call): Skip the redundant
function call added to the pre chain when no_function_call is
set and the character result length was already determined
without running the callee.
* trans-array.cc (gfc_conv_array_parameter): Convert an array
constructor's explicit character type-spec length directly
instead of using the first elements length.
Andrea Pinski [Tue, 21 Jul 2026 18:25:34 +0000 (11:25 -0700)]
Fix maintainer_utils.py for older jsonscheme [PR126162]
Some semi-older distros don't have a new enough jsonscheme
installed. So this moves the scheme to the older json scheme
rather than using the 2020 one.
PR testsuite/126162
contrib/ChangeLog:
* maintainer_utils.py: Move to the older scheme which
is valid for MAINTAINERS.yml.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com> Co-authored-by: Arsen Arsenović <aarsenovic@baylibre.com>
Split the movxo pattern into DMF and non-DMF variants.
Use DMF move instructions (dmxxinstdmr512, dmmr, and dmxxextfdmr512)
for accumulator/DMR moves while retaining the existing split for
non-DMR operands.
2026-07-15 Vijay Shankar <vijay@linux.ibm.com>
gcc/ChangeLog:
* config/rs6000/mma.md (*movxo): renamed to movxo_nodmf
(*movxo_nodmf): updated contraint to use wD and add !TARGET_DMF
(*movxo_dmf): New pattern to handle dmf insert/extract from vsx
rs6000: Add TDOmode reload patterns for DMR registers
Add define_insn_and_split patterns for reloading TDOmode values between
Dense Math Registers (DMRs) and memory when TARGET_DMF is enabled.
2026-07-15 Surya Kumari Jangala <jskumari@linux.ibm.com>
Peter Bergner <bergner@linux.ibm.com>
gcc:
* config/rs6000/mma.md (UNSPEC_DMR_RELOAD_FROM_MEMORY): New unspec.
(UNSPEC_DMR_RELOAD_TO_MEMORY): Likewise.
(reload_tdo_load): New define_insn_and_split.
(reload_tdo_store): Likewise.
* config/rs6000/rs6000.cc (rs6000_init_hard_regno_mode_ok): Set
reload_load and reload_store for TDOmode when TARGET_DMF.
This patch
- Tweaks the signed overflow handling in __mulQ64_work.
- Rename misnomed fx24-mul.c to fx64-mul-1.c.
- Adds more test cases in fx64-mul-2.c.
libgcc/
* config/avr/lib1funcs-fixed.S (__mulQ64_work): Tweak
overflow handling. Use __negsi2 (non-saturating negation)
to negate.
gcc/testsuite/
* gcc.target/avr/fx24-mul.c: Renamed to...
* gcc.target/avr/fx64-mul-1.c: ...this.
* gcc.target/avr/fx64-mul-2.c: New test.
* gcc.target/avr/fx64-mul.h: New file.
testsuite: require cortex-a53 in reg_equal_test.c test
The original purpose of the test is to verify that, when the backend
emits a mov-pair sequence, the sequence carries a REG_EQUAL note for the
final constant value. Make that precondition explicit instead of
depending on target-specific tuning behavior, by forcing the test to
a CPU with the required properties.
gcc/testsuite/ChangeLog:
* gcc.target/arm/reg_equal_test.c: Add require effective target
cortex-a53 for test.
Jakub Jelinek [Wed, 22 Jul 2026 09:56:48 +0000 (11:56 +0200)]
libstdc++: Update Linux baselines for GCC 17.0
The following patch applies the powerpc64le-linux-gnu/baseline_symbols.txt
and x86_64-linux-gnu/baseline_symbols.txt r17-2579 changes to all
other linux arches which have recently updated baseline_symbols.txt
(i.e. those which have GLIBCXX_3.4.35 symbol version in it).
Those 3 symbols are architecture independent, they don't have any
size_t etc. argument that depends on the architecture, j (unsigned int) for
the last one is unsigned int on all arches.
On most the patch applied cleanly, on some (powerpc*/s390x*) I had to
manually resolve fuzz, as
FUNC:_ZNKSt16bad_array_length4whatEv@@CXXABI_1.3.8
there wasn't followed by
FUNC:_ZNKSt17bad_function_call4whatEv@@GLIBCXX_3.4.18
but some @@GLIBCXX_LDBL_3.4 symbols (which are _ZNKSt17* though, so the
two new comes alphabetically sorted before those).
libgomp: Add by-device capabilities for OpenMP 'omp requires' handling
Before the capabilities of a device were statically set to a generic
by-device-type value. This has been modified to additionally set them
to a value for a specific device.
On the plugin side, this permits to set the unified-shared memory
capability for only a subset of devices and to mark devices that are
integrated GPUs (APU) and support USM, which in turn permitted to move
the handling of OpenMP requirements from the plugin back to target.c
and permits in future to automatically enable unified-shared memory
for integrated GPUs/APUs.
The check for whether host memory can be accessed is for Nvidia GPUs
whether pageableMemoryAccess is supported (unchanged) and for AMD GPUs
whether SVM_ACCESSIBLE_BY_DEFAULT is supported (unchanged, global
property) and, if not, now also whether the device is an APU and
either XNACK is enabled or not supported by the hardware. For systems
with a single GPU, the result should be identical.
Note: The resulting capability is currently only used with
omp requires unified_shared_memory / self_maps
such that this flag is only set if the user code has this requirement
and all devices not supporting the host-memory access are filtered out.
Co-authored-by: Andrew Stubbs <ams@baylibre.com> Co-authored-by: supers1ngular <supers1ngular@baylibre.com>
include/ChangeLog: