]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
10 months agoMake store likely in optimize_mask_stores
Jan Hubicka [Thu, 27 Jul 2023 18:14:19 +0000 (20:14 +0200)] 
Make store likely in optimize_mask_stores

gcc/ChangeLog:

* tree-vect-loop.cc (optimize_mask_stores): Make store
likely.

10 months agoFix profile update after RTL unrolling
Jan Hubicka [Thu, 27 Jul 2023 18:06:37 +0000 (20:06 +0200)] 
Fix profile update after RTL unrolling

This patch fixes profile update after RTL unroll, that is now done same way as
in tree one.  We still produce (slightly) corrupted profile for multiple exit
loops I can try to fix incrementally.

I also updated testcases to look for profile mismatches so they do not creep
back in again.

gcc/ChangeLog:

* cfgloop.h (single_dom_exit): Declare.
* cfgloopmanip.h (update_exit_probability_after_unrolling): Declare.
* cfgrtl.cc (struct cfg_hooks): Fix comment.
* loop-unroll.cc (unroll_loop_constant_iterations): Update exit edge.
* tree-ssa-loop-ivopts.h (single_dom_exit): Do not declare it here.
* tree-ssa-loop-manip.cc (update_exit_probability_after_unrolling):
Break out from ...
(tree_transform_and_unroll_loop): ... here;

gcc/testsuite/ChangeLog:

* gcc.dg/tree-prof/peel-1.c: Test for profile mismatches.
* gcc.dg/tree-prof/unroll-1.c: Test for profile mismatches.
* gcc.dg/tree-ssa/peel1.c: Test for profile mismatches.
* gcc.dg/unroll-1.c: Test for profile mismatches.
* gcc.dg/unroll-3.c: Test for profile mismatches.
* gcc.dg/unroll-4.c: Test for profile mismatches.
* gcc.dg/unroll-5.c: Test for profile mismatches.
* gcc.dg/unroll-6.c: Test for profile mismatches.

10 months agoOpenMP/Fortran: Extend reject code between target + teams [PR71065, PR110725]
Tobias Burnus [Thu, 27 Jul 2023 16:14:11 +0000 (18:14 +0200)] 
OpenMP/Fortran: Extend reject code between target + teams [PR71065, PR110725]

The previous version failed to diagnose when the 'teams' was nested
more deeply inside the target region, e.g. inside a DO or some
block or structured block.

            PR fortran/110725
            PR middle-end/71065

gcc/fortran/ChangeLog:

* openmp.cc (resolve_omp_target): Minor cleanup.
* parse.cc (decode_omp_directive): Find TARGET statement
also higher in the stack.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/teams-6.f90: Extend.

10 months agolibstdc++: Fix std::format alternate form for floating-point [PR108046]
Jonathan Wakely [Thu, 27 Jul 2023 13:07:09 +0000 (14:07 +0100)] 
libstdc++: Fix std::format alternate form for floating-point [PR108046]

A decimal point was being added to the end of the string for {:#.0}
because the __expc character was not being set, for the _Pres_none
presentation type, so __s.find(__expc) didn't the 'e' in "1e+01" and so
we created "1e+01." by appending the radix char to the end.

This can be fixed by ensuring that __expc='e' is set for the _Pres_none
case. I realized we can also set __expc='P' and __expc='E' when needed,
to save a call to std::toupper later.

For the {:#.0g} format, __expc='e' was being set and so the 'e' was
found in "1e+10" but then __z = __prec - __sigfigs would wraparound to
SIZE_MAX. That meant we would decide not to add a radix char because the
number of extra characters to insert would be 1+SIZE_MAX i.e. zero.

This can be fixed by using __z == 0 when __prec == 0.

libstdc++-v3/ChangeLog:

PR libstdc++/108046
* include/std/format (__formatter_fp::format): Ensure __expc is
always set for all presentation types. Set __z correctly for
zero precision.
* testsuite/std/format/functions/format.cc: Check problem cases.

10 months agoFix profile update in tree_transform_and_unroll_loop
Jan Hubicka [Thu, 27 Jul 2023 14:17:59 +0000 (16:17 +0200)] 
Fix profile update in tree_transform_and_unroll_loop

Fixe profile update in tree_transform_and_unroll_loop which is used
by predictive comming.  I stared by attempt to fix
gcc.dg/tree-ssa/update-unroll-1.c I xfailed last week, but it turned to be
harder job.

Unrolling was never fixed for changes in duplicate_loop_body_to_header_edge
which is now smarter on getting profile right when some exists are eliminated.
A lot of manual profile can thus now be done using existing infrastructure.

I also noticed that scale_dominated_blocks_in_loop does job identical
to loop I wrote in scale_loop_profile and thus I commonized the implementaiton
and removed recursion.

I also extended duplicate_loop_body_to_header_edge to handle flat profiles same
way as we do in vectorizer. Without it we end up with less then 0 iteration
count in gcc.dg/tree-ssa/update-unroll-1.c (it is unrolled 32times but predicted
to iterated fewer times) and added missing code to update loop_info.

gcc/ChangeLog:

* cfgloopmanip.cc (scale_dominated_blocks_in_loop): Move here from
tree-ssa-loop-manip.cc and avoid recursion.
(scale_loop_profile): Use scale_dominated_blocks_in_loop.
(duplicate_loop_body_to_header_edge): Add DLTHE_FLAG_FLAT_PROFILE
flag.
* cfgloopmanip.h (DLTHE_FLAG_FLAT_PROFILE): Define.
(scale_dominated_blocks_in_loop): Declare.
* predict.cc (dump_prediction): Do not ICE on uninitialized probability.
(change_edge_frequency): Remove.
* predict.h (change_edge_frequency): Remove.
* tree-ssa-loop-manip.cc (scale_dominated_blocks_in_loop): Move to
cfgloopmanip.cc.
(niter_for_unrolled_loop): Remove.
(tree_transform_and_unroll_loop): Fix profile update.

gcc/testsuite/ChangeLog:

* gcc.dg/pr102385.c: Check for no profile mismatches.
* gcc.dg/pr96931.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-1.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-2.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-3.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-4.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-5.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-7.c: Check for one profile mismatch.
* gcc.dg/tree-ssa/predcom-8.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-1.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-10.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-11.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-12.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-2.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-3.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-4.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-5.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-6.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-7.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-8.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-9.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/update-unroll-1.c: Unxfail.

10 months agoFix profile update in tree-ssa-loop-im.cc
Jan Hubicka [Thu, 27 Jul 2023 13:58:52 +0000 (15:58 +0200)] 
Fix profile update in tree-ssa-loop-im.cc

This fixes two bugs in tree-ssa-loop-im.cc.  First is that cap probability is not
reliable, but it is constructed with adjusted quality.  Second is that sometimes
the conditional has wrong joiner BB count.  This is visible on
testsuite/gcc.dg/pr102385.c however the testcase triggers another profile
update bug in pcom, so I will update it in followup patch.

gcc/ChangeLog:

* tree-ssa-loop-im.cc (execute_sm_if_changed): Turn cap probability
to guessed; fix count of new_bb.

10 months agoFix profile_count::apply_probability
Jan Hubicka [Thu, 27 Jul 2023 13:57:54 +0000 (15:57 +0200)] 
Fix profile_count::apply_probability

profile_count::apply_probability misses check for uninitialized probability which leads
to completely random results on applying uninitialized probability to initialized scale.
This can make difference when i.e. inlining -fno-guess-branch-probability function
to -fguess-branch-probability one.

gcc/ChangeLog:

* profile-count.h (profile_count::apply_probability): Fix
handling of uninitialized probabilities, optimize scaling
by probability 1.

10 months agotree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C
Richard Biener [Thu, 27 Jul 2023 11:08:32 +0000 (13:08 +0200)] 
tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C

The following fixes the lack of simplification of a vector shift
by an out-of-bounds shift value.  For scalars this is done both
by CCP and VRP but vectors are not handled there.  This results
in PR91838 differences in outcome dependent on whether a vector
shift ISA is available and thus vector lowering does or does not
expose scalar shifts here.

The following adds a match.pd pattern to catch uniform out-of-bound
shifts, simplifying them to zero when not sanitizing shift amounts.

PR tree-optimization/91838
* gimple-match-head.cc: Include attribs.h and asan.h.
* generic-match-head.cc: Likewise.
* match.pd (([rl]shift @0 out-of-bounds) -> zero): New pattern.

10 months agoc++: constexpr empty subobject elision [PR110197]
Patrick Palka [Thu, 27 Jul 2023 13:10:07 +0000 (09:10 -0400)] 
c++: constexpr empty subobject elision [PR110197]

Now that init_subob_ctx no longer sets new_ctx.ctor for a subobject of
empty type, it seems we need to ensure its callers also consistently
omit entries in the parent ctx->ctor for such subobjects.  We also need
to allow cxx_eval_array_reference to synthesize an empty subobject even
if the array CONSTRUCTOR has CONSTRUCTOR_NO_CLEARING set.

PR c++/110197

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_array_reference): Allow synthesizing an
empty subobject even if CONSTRUCTOR_NO_CLEARING is set.
(cxx_eval_bare_aggregate): Set 'no_slot' to true more generally
whenever new_ctx.ctor is set to NULL_TREE by init_subob_ctx,
i.e. whenever initializing an subobject of empty type.
(cxx_eval_vec_init_1): Define 'no_slot' as above and use it
accordingly.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty18.C: New test.
* g++.dg/cpp0x/constexpr-empty19.C: New test.

10 months agoRISC-V: Enable basic VLS modes support
Juzhe-Zhong [Thu, 27 Jul 2023 11:47:02 +0000 (19:47 +0800)] 
RISC-V: Enable basic VLS modes support

Support && Test VLS modes load/store/reg move as well as LRA spilling

gcc/ChangeLog:

* config/riscv/riscv-modes.def (VECTOR_BOOL_MODE): Add VLS modes.
(ADJUST_ALIGNMENT): Ditto.
(ADJUST_PRECISION): Ditto.
(VLS_MODES): Ditto.
(VECTOR_MODE_WITH_PREFIX): Ditto.
* config/riscv/riscv-opts.h (TARGET_VECTOR_VLS): New macro.
* config/riscv/riscv-protos.h (riscv_v_ext_vls_mode_p): New function.
* config/riscv/riscv-v.cc (INCLUDE_ALGORITHM): Add include.
(legitimize_move): Enable basic VLS modes support.
(get_vlmul): Ditto.
(get_ratio): Ditto.
(get_vector_mode): Ditto.
* config/riscv/riscv-vector-switch.def (VLS_ENTRY): Add vls modes.
* config/riscv/riscv.cc (riscv_v_ext_vls_mode_p): New function.
(VLS_ENTRY): New macro.
(riscv_v_ext_mode_p): Add vls modes.
(riscv_get_v_regno_alignment): New function.
(riscv_print_operand): Add vls modes.
(riscv_hard_regno_nregs): Ditto.
(riscv_hard_regno_mode_ok): Ditto.
(riscv_regmode_natural_size): Ditto.
(riscv_vectorize_preferred_vector_alignment): Ditto.
* config/riscv/riscv.md: Ditto.
* config/riscv/vector-iterators.md: Ditto.
* config/riscv/vector.md: Ditto.
* config/riscv/autovec-vls.md: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/slp-9.c: Add more checks.
* gcc.target/riscv/rvv/rvv.exp: Add VLS modes tests.
* gcc.target/riscv/rvv/autovec/vls/def.h: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-10.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-11.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-12.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-13.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-14.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-15.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-16.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-17.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-8.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-9.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-7.c: New test.

10 months agoRISC-V: Remove unnecessary vread_csr/vwrite_csr intrinsic.
Pan Li [Thu, 27 Jul 2023 02:34:57 +0000 (10:34 +0800)] 
RISC-V: Remove unnecessary vread_csr/vwrite_csr intrinsic.

According to below RVV doc, the related intrinsic is not longer needed.

https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/249

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:

* config/riscv/riscv_vector.h (enum RVV_CSR): Removed.
(vread_csr): Ditto.
(vwrite_csr): Ditto.

10 months agoRISC-V: Fix uninitialized and redundant use of which_alternative
demin.han [Thu, 27 Jul 2023 09:48:59 +0000 (17:48 +0800)] 
RISC-V: Fix uninitialized and redundant use of which_alternative

When pass split2 starts, which_alternative is random depending on
last set of certain pass.

Even initialized, the generated movement is redundant.
The movement can be generated by assembly output template.

Signed-off-by: demin.han <demin.han@starfivetech.com>
gcc/ChangeLog:

* config/riscv/autovec.md: Delete which_alternative use in split

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/madd-split2-1.c: New test.
Signed-off-by: demin.han <demin.han@starfivetech.com>
10 months agoXFAIL parts broken deliberately by r13-1762-gf9d4c3b45c5ed5
Richard Biener [Thu, 27 Jul 2023 10:34:34 +0000 (12:34 +0200)] 
XFAIL parts broken deliberately by r13-1762-gf9d4c3b45c5ed5

The following XFAILs recognizing a complex store as memset.

PR tree-optimization/110829
* gcc.dg/pr56837.c: XFAIL part of the testcase.

10 months agoRemove recursive post-dominator traversal in sinking
Richard Biener [Thu, 27 Jul 2023 08:23:16 +0000 (10:23 +0200)] 
Remove recursive post-dominator traversal in sinking

The following turns the recursive post-dominator traversal in GIMPLE
code sinking to a worklist.

* tree-ssa-sink.cc (sink_code_in_bb): Remove recursion, instead
use a worklist ...
(pass_sink_code::execute): ... in the caller.

10 months agoc++: Fix ICE with parameter pack of decltype(auto) [PR103497]
Nathaniel Shead [Fri, 30 Jun 2023 07:05:24 +0000 (17:05 +1000)] 
c++: Fix ICE with parameter pack of decltype(auto) [PR103497]

This patch ensures 'type_uses_auto' also checks for usages of 'auto' in
parameter packs.

PR c++/103497

gcc/cp/ChangeLog:

* pt.cc (type_uses_auto): Check inside parameter packs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/decltype-auto-103497.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
10 months agovect: Treat VMAT_ELEMENTWISE as scalar load in costing [PR110776]
Kewen Lin [Thu, 27 Jul 2023 02:43:09 +0000 (21:43 -0500)] 
vect: Treat VMAT_ELEMENTWISE as scalar load in costing [PR110776]

PR110776 exposes one issue that we could query unaligned
load for vector type but actually no unaligned vector load
is supported there.  The reason is that the costed load is
with single-lane vector type and its memory access type is
VMAT_ELEMENTWISE, we actually take it as scalar load and
set its alignment_support_scheme as dr_unaligned_supported.

To avoid the ICE as exposed, following Rich's suggestion,
this patch is to make VMAT_ELEMENTWISE be costed as scalar
load.

Co-authored-by: Richard Biener <rguenther@suse.de>
PR tree-optimization/110776

gcc/ChangeLog:

* tree-vect-stmts.cc (vectorizable_load): Always cost VMAT_ELEMENTWISE
as scalar load.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr110776.c: New test.

10 months ago[committed] [RISC-V] Fix expected diagnostic messages in testsuite
Jeff Law [Thu, 27 Jul 2023 01:25:33 +0000 (19:25 -0600)] 
[committed] [RISC-V] Fix expected diagnostic messages in testsuite

Whoops, this should have gone in with the fixes to the RISC-V
diagnostics from earlier this week.

gcc/testsuite
* gcc.target/riscv/arch-23.c: Update expected diagnostic messages.
* gcc.target/riscv/pr102957.c: Likewise.

10 months agoDaily bump.
GCC Administrator [Thu, 27 Jul 2023 00:17:56 +0000 (00:17 +0000)] 
Daily bump.

10 months agoc++: passing partially inst ttp as ttp [PR110566]
Patrick Palka [Wed, 26 Jul 2023 21:21:43 +0000 (17:21 -0400)] 
c++: passing partially inst ttp as ttp [PR110566]

The previous fix doesn't work for partially instantiated ttps mainly
because most_general_template is a no-op for them.  This patch fixes
this by giving such ttps a DECL_TEMPLATE_INFO (extending the
r11-734-g2fb595f8348e16 fix) with which most_general_template can obtain
the original, unlowered ttp.

This patch additionally makes coerce_template_template_parms use the
correct amount of levels from the scope of a ttp argument.

PR c++/110566
PR c++/108179

gcc/cp/ChangeLog:

* pt.cc (reduce_template_parm_level): Set DECL_TEMPLATE_INFO
on the DECL_TEMPLATE_RESULT of the new ttp.
(add_defaults_to_ttp): Make a copy of the original ttp's
DECL_TEMPLATE_RESULT, and update this copy's DECL_TEMPLATE_INFO
as well.
(coerce_template_template_parms): Make sure 'scope_args' has
the right amount of levels for the ttp argument.
(most_general_template): Handle template template parameters.
(rewrite_template_parm): Set DECL_TEMPLATE_RESULT on the
DECL_TEMPLATE_RESULT of the new ttp.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction115.C: New test.
* g++.dg/template/ttp39.C: New test.

10 months agoc++: passing partially inst tmpl as ttp [PR110566]
Patrick Palka [Wed, 26 Jul 2023 21:21:26 +0000 (17:21 -0400)] 
c++: passing partially inst tmpl as ttp [PR110566]

Since the template arguments 'pargs' we pass to coerce_template_parms from
coerce_template_template_parms are always a full set, we need to make sure
we always pass the parameters of the most general template because if the
template is partially instantiated then the levels won't match up.  In the
testcase below during said call to coerce_template_parms the parameters are
{X, Y}, both level 1 rather than 2, and the arguments are {{int}, {N, M}},
which results in a crash during auto deduction for parameters' types.

PR c++/110566
PR c++/108179

gcc/cp/ChangeLog:

* pt.cc (coerce_template_template_parms): Simplify by using
DECL_INNERMOST_TEMPLATE_PARMS and removing redundant asserts.
Always pass the parameters of the most general template to
coerce_template_parms.

gcc/testsuite/ChangeLog:

* g++.dg/template/ttp38.C: New test.

10 months ago[PATCH 2/5] [RISC-V] Generate Zicond instruction for basic semantics
Xiao Zeng [Wed, 26 Jul 2023 17:59:59 +0000 (11:59 -0600)] 
[PATCH 2/5] [RISC-V] Generate Zicond instruction for basic semantics

This patch completes the recognition of the basic semantics
defined in the spec, namely:

Conditional zero, if condition is equal to zero
  rd = (rs2 == 0) ? 0 : rs1
Conditional zero, if condition is non zero
  rd = (rs2 != 0) ? 0 : rs1

gcc/ChangeLog:

* config/riscv/riscv.md: Include zicond.md
* config/riscv/zicond.md: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zicond-primitiveSemantics.c: New test.

Co-authored-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Co-authored-by: Raphael Zinsly <rzinsly@ventanamicro.com>
Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
10 months ago[PATCH 1/5] [RISC-V] Recognize Zicond extension
Xiao Zeng [Wed, 26 Jul 2023 16:07:42 +0000 (10:07 -0600)] 
[PATCH 1/5] [RISC-V] Recognize Zicond extension

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: New extension.
* config/riscv/riscv-opts.h (MASK_ZICOND): New mask.
(TARGET_ZICOND): New target.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/attribute-20.c: New test.
* gcc.target/riscv/attribute-21.c: New test.

Co-authored-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
10 months agoc++: unifying REAL_CSTs [PR110809]
Patrick Palka [Wed, 26 Jul 2023 20:52:13 +0000 (16:52 -0400)] 
c++: unifying REAL_CSTs [PR110809]

This teaches unify how to compare two REAL_CSTs.

PR c++/110809

gcc/cp/ChangeLog:

* pt.cc (unify) <case INTEGER_CST>: Generalize to handle
REAL_CST as well.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-float3.C: New test.

10 months agoFortran: diagnose strings of non-constant length in DATA statements [PR68569]
Harald Anlauf [Wed, 26 Jul 2023 19:12:45 +0000 (21:12 +0200)] 
Fortran: diagnose strings of non-constant length in DATA statements [PR68569]

gcc/fortran/ChangeLog:

PR fortran/68569
* resolve.cc (check_data_variable): Do not accept strings with
deferred length or non-constant length in a DATA statement.
Reject also substrings of string variables of non-constant length.

gcc/testsuite/ChangeLog:

PR fortran/68569
* gfortran.dg/data_char_4.f90: Adjust expected diagnostic.
* gfortran.dg/data_char_5.f90: Likewise.
* gfortran.dg/data_char_6.f90: New test.

10 months agoUpdate gcc uk.po
Joseph Myers [Wed, 26 Jul 2023 19:08:39 +0000 (19:08 +0000)] 
Update gcc uk.po

* uk.po: Update.

10 months agoRegenerate gcc.pot
Joseph Myers [Wed, 26 Jul 2023 18:50:21 +0000 (18:50 +0000)] 
Regenerate gcc.pot

* gcc.pot: Regenerate.

10 months agolibstdc++: Require C++11 for 23_containers/vector/bool/110807.cc [PR110807]
Jonathan Wakely [Wed, 26 Jul 2023 18:08:39 +0000 (19:08 +0100)] 
libstdc++: Require C++11 for 23_containers/vector/bool/110807.cc [PR110807]

This new test uses uniform initialization syntax, so requires C++11 or
later.

libstdc++-v3/ChangeLog:

PR libstdc++/110807
* testsuite/23_containers/vector/bool/110807.cc: Require c++11.

10 months agors6000, add argument to function find_instance
Carl Love [Wed, 26 Jul 2023 17:49:47 +0000 (13:49 -0400)] 
rs6000, add argument to function find_instance

The function find_instance assumes it is called to check a built-in with
only two arguments.  This patch extends the function by adding a parameter
specifying the number of built-in arguments to check.

Note, this patch was supposed to have been applied before commit:

  commit b51795c832cf6e724d61919eb18a383223b76694
  Author: Carl Love <cel@us.ibm.com>
  Date:   Wed Jul 26 11:31:53 2023 -0400

      rs6000, fix vec_replace_unaligned built-in arguments
       ...

gcc/ChangeLog:
* config/rs6000/rs6000-c.cc (find_instance): Add new parameter that
specifies the number of built-in arguments to check.
(altivec_resolve_overloaded_builtin): Update calls to find_instance
to pass the number of built-in arguments to be checked.

10 months agoc++: cp_parser_constant_expression cleanups
Marek Polacek [Tue, 25 Jul 2023 18:03:02 +0000 (14:03 -0400)] 
c++: cp_parser_constant_expression cleanups

It's pointless to call *_rvalue_constant_expression when we're not using
the result.  Also apply some drive-by cleanups.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_constant_expression): Allow non_constant_p to be
nullptr even when allow_non_constant_p is true.  Don't call
_rvalue_constant_expression when not necessary.  Move local variable
declarations closer to their first use.
(cp_parser_static_assert): Don't pass a dummy down to
cp_parser_constant_expression.

10 months agoc++: member vs global template [PR106310]
Jason Merrill [Wed, 26 Jul 2023 14:39:34 +0000 (10:39 -0400)] 
c++: member vs global template [PR106310]

For backward compatibility we still want to allow patterns like
this->A<T>::foo, but the template keyword in a qualified name is
specifically to specify that a dependent name is a template, so don't look
in the enclosing scope at all.

Also fix handling of dependent bases: if member lookup in the current
instantiation fails and we have dependent bases, the lookup is dependent.
We were already handling that for the case where lookup in the enclosing
scope also fails, but we also want it to affect that lookup itself.

PR c++/106310

gcc/cp/ChangeLog:

* parser.cc (cp_parser_template_name): Skip non-member
lookup after the template keyword.
(cp_parser_lookup_name): Pass down template_keyword_p.

gcc/testsuite/ChangeLog:

* g++.dg/template/template-keyword4.C: New test.

10 months agobpf: add v3 atomic instructions
David Faust [Mon, 24 Jul 2023 16:45:17 +0000 (09:45 -0700)] 
bpf: add v3 atomic instructions

This patch adds support for the general atomic operations introduced in
eBPF v3. In addition to the existing atomic add instruction, this adds:
 - Atomic and, or, xor
 - Fetching versions of these operations (including add)
 - Atomic exchange
 - Atomic compare-and-exchange

To control emission of these instructions, a new target option
-m[no-]v3-atomics is added. This option is enabled by -mcpu=v3
and above.

Support for these instructions was recently added in binutils.

gcc/

* config/bpf/bpf.opt (mv3-atomics): New option.
* config/bpf/bpf.cc (bpf_option_override): Handle it here.
* config/bpf/bpf.h (enum_reg_class): Add R0 class.
(REG_CLASS_NAMES): Likewise.
(REG_CLASS_CONTENTS): Likewise.
(REGNO_REG_CLASS): Handle R0.
* config/bpf/bpf.md (UNSPEC_XADD): Rename to UNSPEC_AADD.
(UNSPEC_AAND): New unspec.
(UNSPEC_AOR): Likewise.
(UNSPEC_AXOR): Likewise.
(UNSPEC_AFADD): Likewise.
(UNSPEC_AFAND): Likewise.
(UNSPEC_AFOR): Likewise.
(UNSPEC_AFXOR): Likewise.
(UNSPEC_AXCHG): Likewise.
(UNSPEC_ACMPX): Likewise.
(atomic_add<mode>): Use UNSPEC_AADD and atomic type attribute.
Move to...
* config/bpf/atomic.md: ...Here. New file.
* config/bpf/constraints.md (t): New constraint for R0.
* doc/invoke.texi (eBPF Options): Document -mv3-atomics.

gcc/testsuite/

* gcc.target/bpf/atomic-cmpxchg-1.c: New test.
* gcc.target/bpf/atomic-cmpxchg-2.c: New test.
* gcc.target/bpf/atomic-fetch-op-1.c: New test.
* gcc.target/bpf/atomic-fetch-op-2.c: New test.
* gcc.target/bpf/atomic-fetch-op-3.c: New test.
* gcc.target/bpf/atomic-op-1.c: New test.
* gcc.target/bpf/atomic-op-2.c: New test.
* gcc.target/bpf/atomic-op-3.c: New test.
* gcc.target/bpf/atomic-xchg-1.c: New test.
* gcc.target/bpf/atomic-xchg-2.c: New test.

10 months agolibstdc++: Avoid bogus overflow warnings in std::vector<bool> [PR110807]
Jonathan Wakely [Wed, 26 Jul 2023 13:09:24 +0000 (14:09 +0100)] 
libstdc++: Avoid bogus overflow warnings in std::vector<bool> [PR110807]

GCC thinks the allocation can alter the object being copied if it's
globally reachable, so doesn't realize that [x.begin(), x.end()) after
the allocation is the same as x.size() before it.

This causes a testsuite failure when testing with -D_GLIBCXX_DEBUG:
FAIL: 23_containers/vector/bool/swap.cc (test for excess errors)
A fix is to move the calls to x.begin() and x.end() to before the
allocation.

A similar problem exists in vector<bool>::_M_insert_range where *this is
globally reachable, as reported in PR libstdc++/110807. That can also be
fixed by moving calls to begin() and end() before the allocation.

libstdc++-v3/ChangeLog:

PR libstdc++/110807
* include/bits/stl_bvector.h (vector(const vector&)): Access
iterators before allocating.
* include/bits/vector.tcc (vector<bool>::_M_insert_range):
Likewise.
* testsuite/23_containers/vector/bool/110807.cc: New test.

10 months agolibstdc++: Add deprecated attribute to std::random_shuffle declarations
Jonathan Wakely [Wed, 26 Jul 2023 13:05:58 +0000 (14:05 +0100)] 
libstdc++: Add deprecated attribute to std::random_shuffle declarations

We already have these attributes on the definitions in <bits/stl_algo.h>
but they don't work due to PR c++/84542. Add the attributes to the
declarations in <bits/algorithmfwd.h> as well, and add a test.

libstdc++-v3/ChangeLog:

* include/bits/algorithmfwd.h (random_shuffle): Add deprecated
attribute.
* include/bits/stl_algo.h (random_shuffle): Correct comments.
* testsuite/25_algorithms/random_shuffle/1.cc: Disable
deprecated warnings.
* testsuite/25_algorithms/random_shuffle/59603.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/moveable.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/deprecated.cc: New
test.

10 months ago[committed] Add check_vect in a testcase
Matthew Malcomson [Wed, 26 Jul 2023 15:53:18 +0000 (16:53 +0100)] 
[committed] Add check_vect in a testcase

Also reformat a comment that had too long lines.
Commit c5bd0e5870a introduced both these problems to fix.

Committed as obvious after ensuring that when running the testcase on
AArch64 it still fails before the original c5bd0e5870a commit and passes
after it.

gcc/ChangeLog:

* tree-vect-stmts.cc (get_group_load_store_type): Reformat
comment.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-multi-peel-gaps.c: Add `check_vect` call into
`main` of this testcase.

10 months agors6000, fix vec_replace_unaligned built-in arguments
Carl Love [Wed, 26 Jul 2023 15:31:53 +0000 (11:31 -0400)] 
rs6000, fix vec_replace_unaligned built-in arguments

The first argument of the vec_replace_unaligned built-in should always be
of type vector unsigned char, as specified in gcc/doc/extend.texi.

This patch fixes the builtin definitions and updates the test cases to use
the correct arguments.  The original test file is renamed and a second test
file is added for a new test case.

gcc/ChangeLog:
* config/rs6000/rs6000-builtins.def: Rename
__builtin_altivec_vreplace_un_uv2di as __builtin_altivec_vreplace_un_udi
__builtin_altivec_vreplace_un_uv4si as __builtin_altivec_vreplace_un_usi
__builtin_altivec_vreplace_un_v2df as __builtin_altivec_vreplace_un_df
__builtin_altivec_vreplace_un_v2di as __builtin_altivec_vreplace_un_di
__builtin_altivec_vreplace_un_v4sf as __builtin_altivec_vreplace_un_sf
__builtin_altivec_vreplace_un_v4si as __builtin_altivec_vreplace_un_si.
Rename VREPLACE_UN_UV2DI as VREPLACE_UN_UDI, VREPLACE_UN_UV4SI as
VREPLACE_UN_USI, VREPLACE_UN_V2DF as VREPLACE_UN_DF,
VREPLACE_UN_V2DI as VREPLACE_UN_DI, VREPLACE_UN_V4SF as
VREPLACE_UN_SF, VREPLACE_UN_V4SI as VREPLACE_UN_SI.
Rename vreplace_un_v2di as vreplace_un_di, vreplace_un_v4si as
vreplace_un_si, vreplace_un_v2df as vreplace_un_df,
vreplace_un_v2di as vreplace_un_di, vreplace_un_v4sf as
vreplace_un_sf, vreplace_un_v4si as vreplace_un_si.
* config/rs6000/rs6000-c.cc (find_instance): Add case
RS6000_OVLD_VEC_REPLACE_UN.
* config/rs6000/rs6000-overload.def (__builtin_vec_replace_un):
Fix first argument type.  Rename VREPLACE_UN_UV4SI as
VREPLACE_UN_USI, VREPLACE_UN_V4SI as VREPLACE_UN_SI,
VREPLACE_UN_UV2DI as VREPLACE_UN_UDI, VREPLACE_UN_V2DI as
VREPLACE_UN_DI, VREPLACE_UN_V4SF as VREPLACE_UN_SF,
VREPLACE_UN_V2DF as VREPLACE_UN_DF.
* config/rs6000/vsx.md (REPLACE_ELT): Rename the mode_iterator
REPLACE_ELT_V for vector modes.
(REPLACE_ELT): New scalar mode iterator.
(REPLACE_ELT_char): Add scalar attributes.
(vreplace_un_<mode>): Change iterator and mode attribute.

gcc/testsuite/ChangeLog:
* gcc.target/powerpc/vec-replace-word-runnable.c: Renam
vec-replace-word-runnable_1.c.
* gcc.target/powerpc/vec-replace-word-runnable_1.c
(dg-options): add -flax-vector-conversions.
(vec_replace_unaligned) Fix first argument type.
(vresult_uchar): Fix expected results.
(vec_replace_unaligned): Update for loop to check uchar results.
Remove extra spaces in if statements. Insert missing spaces in
for statements.
* gcc.target/powerpc/vec-replace-word-runnable_2.c: New test file.

10 months agoanalyzer: add symbol base class, moving region id to there [PR104940]
David Malcolm [Wed, 26 Jul 2023 14:29:20 +0000 (10:29 -0400)] 
analyzer: add symbol base class, moving region id to there [PR104940]

This patch introduces a "symbol" base class that region and svalue
both inherit from, generalizing the ID from the region class so it's
also used by svalues.  This gives a way of sorting regions and svalues
into creation order, which I've found useful in my experiments with
adding SMT support (PR analyzer/104940).

gcc/ChangeLog:
PR analyzer/104940
* Makefile.in (ANALYZER_OBJS): Add analyzer/symbol.o.

gcc/analyzer/ChangeLog:
PR analyzer/104940
* region-model-manager.cc
(region_model_manager::region_model_manager): Update for
generalizing region ids to also cover svalues.
(region_model_manager::get_or_create_constant_svalue): Likewise.
(region_model_manager::get_or_create_unknown_svalue): Likewise.
(region_model_manager::create_unique_svalue): Likewise.
(region_model_manager::get_or_create_initial_value): Likewise.
(region_model_manager::get_or_create_setjmp_svalue): Likewise.
(region_model_manager::get_or_create_poisoned_svalue): Likewise.
(region_model_manager::get_ptr_svalue): Likewise.
(region_model_manager::get_or_create_unaryop): Likewise.
(region_model_manager::get_or_create_binop): Likewise.
(region_model_manager::get_or_create_sub_svalue): Likewise.
(region_model_manager::get_or_create_repeated_svalue): Likewise.
(region_model_manager::get_or_create_bits_within): Likewise.
(region_model_manager::get_or_create_unmergeable): Likewise.
(region_model_manager::get_or_create_widening_svalue): Likewise.
(region_model_manager::get_or_create_compound_svalue): Likewise.
(region_model_manager::get_or_create_conjured_svalue): Likewise.
(region_model_manager::get_or_create_asm_output_svalue): Likewise.
(region_model_manager::get_or_create_const_fn_result_svalue):
Likewise.
(region_model_manager::get_region_for_fndecl): Likewise.
(region_model_manager::get_region_for_label): Likewise.
(region_model_manager::get_region_for_global): Likewise.
(region_model_manager::get_field_region): Likewise.
(region_model_manager::get_element_region): Likewise.
(region_model_manager::get_offset_region): Likewise.
(region_model_manager::get_sized_region): Likewise.
(region_model_manager::get_cast_region): Likewise.
(region_model_manager::get_frame_region): Likewise.
(region_model_manager::get_symbolic_region): Likewise.
(region_model_manager::get_region_for_string): Likewise.
(region_model_manager::get_bit_range): Likewise.
(region_model_manager::get_var_arg_region): Likewise.
(region_model_manager::get_region_for_unexpected_tree_code):
Likewise.
(region_model_manager::get_or_create_region_for_heap_alloc):
Likewise.
(region_model_manager::create_region_for_alloca): Likewise.
(region_model_manager::log_stats): Likewise.
* region-model-manager.h (region_model_manager::get_num_regions):
Replace with...
(region_model_manager::get_num_symbols): ...this.
(region_model_manager::alloc_region_id): Replace with...
(region_model_manager::alloc_symbol_id): ...this.
(region_model_manager::m_next_region_id): Replace with...
(region_model_manager::m_next_symbol_id): ...this.
* region-model.cc (selftest::test_get_representative_tree): Update
for generalizing region ids to also cover svalues.
(selftest::test_binop_svalue_folding): Likewise.
(selftest::test_state_merging): Likewise.
* region.cc (region::cmp_ids): Delete, in favor of
symbol::cmp_ids.
(region::region): Update for introduction of symbol base class.
(frame_region::get_region_for_local): Likewise.
(root_region::root_region): Likewise.
(symbolic_region::symbolic_region): Likewise.
* region.h: Replace include of "analyzer/complexity.h" with
"analyzer/symbol.h".
(class region): Make a subclass of symbol.
(region::get_id): Delete in favor of symbol::get_id.
(region::cmp_ids): Delete in favor of symbol::cmp_ids.
(region::get_complexity): Delete in favor of
symbol::get_complexity.
(region::region): Use symbol::id_t for "id" param.
(region::m_complexity): Move field to symbol base class.
(region::m_id): Likewise.
(space_region::space_region): Use symbol::id_t for "id" param.
(frame_region::frame_region): Likewise.
(globals_region::globals_region): Likewise.
(code_region::code_region): Likewise.
(function_region::function_region): Likewise.
(label_region::label_region): Likewise.
(stack_region::stack_region): Likewise.
(heap_region::heap_region): Likewise.
(thread_local_region::thread_local_region): Likewise.
(root_region::root_region): Likewise.
(symbolic_region::symbolic_region): Likewise.
(decl_region::decl_region): Likewise.
(field_region::field_region): Likewise.
(element_region::element_region): Likewise.
(offset_region::offset_region): Likewise.
(sized_region::sized_region): Likewise.
(cast_region::cast_region): Likewise.
(heap_allocated_region::heap_allocated_region): Likewise.
(alloca_region::alloca_region): Likewise.
(string_region::string_region): Likewise.
(bit_range_region::bit_range_region): Likewise.
(var_arg_region::var_arg_region): Likewise.
(errno_region::errno_region): Likewise.
(unknown_region::unknown_region): Likewise.
* svalue.cc (sub_svalue::sub_svalue): Add symbol::id_t param.
(repeated_svalue::repeated_svalue): Likewise.
(bits_within_svalue::bits_within_svalue): Likewise.
(compound_svalue::compound_svalue): Likewise.
* svalue.h: Replace include of "analyzer/complexity.h" with
"analyzer/symbol.h".
(class svalue): Make a subclass of symbol.
(svalue::get_complexity): Delete in favor of
symbol::get_complexity.
(svalue::svalue): Add symbol::id_t param.  Update for new base
class.
(svalue::m_complexity): Delete in favor of
symbol::m_complexity.
(region_svalue::region_svalue): Add symbol::id_t param
(constant_svalue::constant_svalue): Likewise.
(unknown_svalue::unknown_svalue): Likewise.
(poisoned_svalue::poisoned_svalue): Likewise.
(setjmp_svalue::setjmp_svalue): Likewise.
(initial_svalue::initial_svalue): Likewise.
(unaryop_svalue::unaryop_svalue): Likewise.
(binop_svalue::binop_svalue): Likewise.
(sub_svalue::sub_svalue): Likewise.
(repeated_svalue::repeated_svalue): Likewise.
(bits_within_svalue::bits_within_svalue): Likewise.
(unmergeable_svalue::unmergeable_svalue): Likewise.
(placeholder_svalue::placeholder_svalue): Likewise.
(widening_svalue::widening_svalue): Likewise.
(compound_svalue::compound_svalue): Likewise.
(conjured_svalue::conjured_svalue): Likewise.
(asm_output_svalue::asm_output_svalue): Likewise.
(const_fn_result_svalue::const_fn_result_svalue): Likewise.
* symbol.cc: New file.
* symbol.h: New file.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agoOpenMP: Call cuMemcpy2D/cuMemcpy3D for nvptx for omp_target_memcpy_rect
Tobias Burnus [Wed, 26 Jul 2023 14:22:35 +0000 (16:22 +0200)] 
OpenMP: Call cuMemcpy2D/cuMemcpy3D for nvptx for omp_target_memcpy_rect

When copying a 2D or 3D rectangular memmory block, the performance is
better when using CUDA's cuMemcpy2D/cuMemcpy3D instead of copying the
data one by one. That's what this commit does.

Additionally, it permits device-to-device copies, if neccessary using a
temporary variable on the host.

include/ChangeLog:

* cuda/cuda.h (CUlimit): Add CUDA_ERROR_NOT_INITIALIZED,
CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_INVALID_HANDLE.
(CUarray, CUmemorytype, CUDA_MEMCPY2D, CUDA_MEMCPY3D,
CUDA_MEMCPY3D_PEER): New typdefs.
(cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpy3DPeer,
cuMemcpy3DPeerAsync): New prototypes.

libgomp/ChangeLog:

* libgomp-plugin.h (GOMP_OFFLOAD_memcpy2d,
GOMP_OFFLOAD_memcpy3d): New prototypes.
* libgomp.h (struct gomp_device_descr): Add memcpy2d_func
and memcpy3d_func.
* libgomp.texi (nvtpx): Document when cuMemcpy2D/cuMemcpy3D is used.
* oacc-host.c (memcpy2d_func, .memcpy3d_func): Init with NULL.
* plugin/cuda-lib.def (cuMemcpy2D, cuMemcpy2DUnaligned,
cuMemcpy3D): Invoke via CUDA_ONE_CALL.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_memcpy2d,
GOMP_OFFLOAD_memcpy3d): New.
* target.c (omp_target_memcpy_rect_worker):
(omp_target_memcpy_rect_check, omp_target_memcpy_rect_copy):
Permit all device-to-device copyies; invoke new plugins for
2D and 3D copying when available.
(gomp_load_plugin_for_device): DLSYM the new plugin functions.
* testsuite/libgomp.c/target-12.c: Fix dimension bug.
* testsuite/libgomp.fortran/target-12.f90: Likewise.
* testsuite/libgomp.fortran/target-memcpy-rect-1.f90: New test.

10 months agotestsuite: Fix gfortran.dg/ieee/comparisons_3.F90 testsuite failures
Uros Bizjak [Wed, 26 Jul 2023 14:08:25 +0000 (16:08 +0200)] 
testsuite: Fix gfortran.dg/ieee/comparisons_3.F90 testsuite failures

The testcase should use dg-additional-options istead of dg-options to
not overwrite default compile flags that include path for finding
the IEEE modules.

gcc/testsuite/ChangeLog:

* gfortran.dg/ieee/comparisons_3.F90: Use dg-additional-options
instead of dg-options.

10 months agotree-optimization/106081 - elide redundant permute
Richard Biener [Wed, 26 Jul 2023 11:31:16 +0000 (13:31 +0200)] 
tree-optimization/106081 - elide redundant permute

The following patch makes sure to elide a redundant permute that
can be merged with existing splats represented as load permutations
as we now do for non-grouped SLP loads.  This is the last bit
missing to fix this PR where the main fix was already done by
r14-2117-gdd86a5a69cbda4

PR tree-optimization/106081
* tree-vect-slp.cc (vect_optimize_slp_pass::start_choosing_layouts):
Assign layout -1 to splats.

* gcc.dg/vect/pr106081.c: New testcase.

10 months agotestsuite/110763: Ensure zero return from test
Siddhesh Poyarekar [Fri, 21 Jul 2023 15:13:58 +0000 (11:13 -0400)] 
testsuite/110763: Ensure zero return from test

The test deliberately reads beyond bounds to exersize ubsan and the
return value may be anything, based on previous allocations.  The OFF
test caters for it by ANDing the return with 0, do the same for the DYN
test.

gcc/testsuite/ChangeLog:

PR testsuite/110763
* gcc.dg/ubsan/object-size-dyn.c (dyn): New parameter RET.
(main): Use it.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
10 months ago[range-ops] Remove special case for handling bitmasks in casts.
Aldy Hernandez [Wed, 26 Jul 2023 09:00:08 +0000 (11:00 +0200)] 
[range-ops] Remove special case for handling bitmasks in casts.

Now that we can generically handle bitmasks for unary operators,
there's no need to special case them.

gcc/ChangeLog:

* range-op-mixed.h (class operator_cast): Add update_bitmask.
* range-op.cc (operator_cast::update_bitmask): New.
(operator_cast::fold_range): Call update_bitmask.

10 months agoRISC-V: Fix vector tuple intrinsic
Li Xu [Wed, 26 Jul 2023 08:18:36 +0000 (08:18 +0000)] 
RISC-V: Fix vector tuple intrinsic

Consider this following case:
void test_vsoxseg3ei32_v_i32mf2x3(int32_t *base, vuint32mf2_t bindex, vint32mf2x3_t v_tuple, size_t vl) {
  return __riscv_vsoxseg3ei32_v_i32mf2x3(base, bindex, v_tuple, vl);
}

Compiler failed with:
test.c:19:1: internal compiler error: in vl_vtype_info, at config/riscv/riscv-vsetvl.cc:1679
   19 | }
      | ^
0x1439ec2 riscv_vector::vl_vtype_info::vl_vtype_info(riscv_vector::avl_info, unsigned char, riscv_vector::vlmul_type, unsigned char, bool, bool)
        ../.././riscv-gcc/gcc/config/riscv/riscv-vsetvl.cc:1679
0x143f788 get_vl_vtype_info
        ../.././riscv-gcc/gcc/config/riscv/riscv-vsetvl.cc:807
0x143f788 riscv_vector::vector_insn_info::parse_insn(rtl_ssa::insn_info*)
        ../.././riscv-gcc/gcc/config/riscv/riscv-vsetvl.cc:1843
0x1440371 riscv_vector::vector_infos_manager::vector_infos_manager()
        ../.././riscv-gcc/gcc/config/riscv/riscv-vsetvl.cc:2350
0x14407ee pass_vsetvl::init()
        ../.././riscv-gcc/gcc/config/riscv/riscv-vsetvl.cc:4581
0x14471cf pass_vsetvl::execute(function*)
        ../.././riscv-gcc/gcc/config/riscv/riscv-vsetvl.cc:4716

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins.def (vfloat16mf4x2_t): Change
scalar type to float16, eliminate warning.
(vfloat16mf4x3_t): Ditto.
(vfloat16mf4x4_t): Ditto.
(vfloat16mf4x5_t): Ditto.
(vfloat16mf4x6_t): Ditto.
(vfloat16mf4x7_t): Ditto.
(vfloat16mf4x8_t): Ditto.
(vfloat16mf2x2_t): Ditto.
(vfloat16mf2x3_t): Ditto.
(vfloat16mf2x4_t): Ditto.
(vfloat16mf2x5_t): Ditto.
(vfloat16mf2x6_t): Ditto.
(vfloat16mf2x7_t): Ditto.
(vfloat16mf2x8_t): Ditto.
(vfloat16m1x2_t): Ditto.
(vfloat16m1x3_t): Ditto.
(vfloat16m1x4_t): Ditto.
(vfloat16m1x5_t): Ditto.
(vfloat16m1x6_t): Ditto.
(vfloat16m1x7_t): Ditto.
(vfloat16m1x8_t): Ditto.
(vfloat16m2x2_t): Ditto.
(vfloat16m2x3_t): Ditto.
(vfloat16m2x4_t): Ditto.
(vfloat16m4x2_t): Ditto.
* config/riscv/vector-iterators.md: add RVVM4x2DF in iterator V4T.
* config/riscv/vector.md: add tuple mode in attr sew.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/tuple-intrinsic.c: New test.

10 months agoi386: Clear upper half of XMM register for V2SFmode operations [PR110762]
Uros Bizjak [Wed, 26 Jul 2023 09:10:46 +0000 (11:10 +0200)] 
i386: Clear upper half of XMM register for V2SFmode operations [PR110762]

Clear the upper half of a V4SFmode operand register in front of all
potentially trapping instructions. The testcase:

--cut here--
typedef float v2sf __attribute__((vector_size(8)));
typedef float v4sf __attribute__((vector_size(16)));

v2sf test(v4sf x, v4sf y)
{
  v2sf x2, y2;

  x2 = __builtin_shufflevector (x, x, 0, 1);
  y2 = __builtin_shufflevector (y, y, 0, 1);

  return x2 + y2;
}
--cut here--

now compiles to:

        movq    %xmm1, %xmm1    # 9     [c=4 l=4]  *vec_concatv4sf_0
        movq    %xmm0, %xmm0    # 10    [c=4 l=4]  *vec_concatv4sf_0
        addps   %xmm1, %xmm0    # 11    [c=12 l=3]  *addv4sf3/0

This approach addresses issues with exceptions, as well as issues with
denormal/invalid values. An obvious exception to the rule is a division,
where the value != 0.0 should be loaded into the upper half of the
denominator to avoid division by zero exception.

The patch effectively tightens the solution from PR95046 by clearing upper
halves of all operand registers before every potentially trapping instruction.
The testcase:

--cut here--
typedef float __attribute__((vector_size(8))) v2sf;

v2sf test (v2sf a, v2sf b, v2sf c)
{
  return a * b - c;
}
--cut here--

compiles to:

        movq    %xmm1, %xmm1    # 8     [c=4 l=4]  *vec_concatv4sf_0
        movq    %xmm0, %xmm0    # 9     [c=4 l=4]  *vec_concatv4sf_0
        movq    %xmm2, %xmm2    # 12    [c=4 l=4]  *vec_concatv4sf_0
        mulps   %xmm1, %xmm0    # 10    [c=16 l=3]  *mulv4sf3/0
        movq    %xmm0, %xmm0    # 13    [c=4 l=4]  *vec_concatv4sf_0
        subps   %xmm2, %xmm0    # 14    [c=12 l=3]  *subv4sf3/0

The implementation emits V4SFmode operation, so we can remove all "emulated"
SSE2 V2SFmode trapping instructions and remove "emulated" SSE2 V2SFmode
alternatives from 3dNOW! insn patterns.

PR target/110762

gcc/ChangeLog:

* config/i386/i386.md (plusminusmult): New code iterator.
* config/i386/mmx.md (mmxdoublevecmode): New mode attribute.
(movq_<mode>_to_sse): New expander.
(<plusminusmult:insn>v2sf3): Macroize expander from addv2sf3,
subv2sf3 and mulv2sf3 using plusminusmult code iterator.  Rewrite
as a wrapper around V4SFmode operation.
(mmx_addv2sf3): Change operand 1 and operand 2 predicates to
nonimmediate_operand.
(*mmx_addv2sf3): Remove SSE alternatives.  Change operand 1 and
operand 2 predicates to nonimmediate_operand.
(mmx_subv2sf3): Change operand 2 predicate to nonimmediate_operand.
(mmx_subrv2sf3): Change operand 1 predicate to nonimmediate_operand.
(*mmx_subv2sf3): Remove SSE alternatives.  Change operand 1 and
operand 2 predicates to nonimmediate_operand.
(mmx_mulv2sf3): Change operand 1 and operand 2 predicates to
nonimmediate_operand.
(*mmx_mulv2sf3): Remove SSE alternatives.  Change operand 1 and
operand 2 predicates to nonimmediate_operand.
(divv2sf3): Rewrite as a wrapper around V4SFmode operation.
(<smaxmin:code>v2sf3): Ditto.
(mmx_<smaxmin:code>v2sf3): Change operand 1 and operand 2
predicates to nonimmediate_operand.
(*mmx_<smaxmin:code>v2sf3): Remove SSE alternatives.  Change
operand 1 and operand 2 predicates to nonimmediate_operand.
(mmx_ieee_<ieee_maxmin>v2sf3): Ditto.
(sqrtv2sf2): Rewrite as a wrapper around V4SFmode operation.
(*mmx_haddv2sf3_low): Ditto.
(*mmx_hsubv2sf3_low): Ditto.
(vec_addsubv2sf3): Ditto.
(*mmx_maskcmpv2sf3_comm): Remove.
(*mmx_maskcmpv2sf3): Remove.
(vec_cmpv2sfv2si): Rewrite as a wrapper around V4SFmode operation.
(vcond<V2FI:mode>v2sf): Ditto.
(fmav2sf4): Ditto.
(fmsv2sf4): Ditto.
(fnmav2sf4): Ditto.
(fnmsv2sf4): Ditto.
(fix_truncv2sfv2si2): Ditto.
(fixuns_truncv2sfv2si2): Ditto.
(mmx_fix_truncv2sfv2si2): Remove SSE alternatives.
Change operand 1 predicate to nonimmediate_operand.
(floatv2siv2sf2): Rewrite as a wrapper around V4SFmode operation.
(floatunsv2siv2sf2): Ditto.
(mmx_floatv2siv2sf2): Remove SSE alternatives.
Change operand 1 predicate to nonimmediate_operand.
(nearbyintv2sf2): Rewrite as a wrapper around V4SFmode operation.
(rintv2sf2): Ditto.
(lrintv2sfv2si2): Ditto.
(ceilv2sf2): Ditto.
(lceilv2sfv2si2): Ditto.
(floorv2sf2): Ditto.
(lfloorv2sfv2si2): Ditto.
(btruncv2sf2): Ditto.
(roundv2sf2): Ditto.
(lroundv2sfv2si2): Ditto.
(*mmx_roundv2sf2): Remove.

gcc/testsuite/ChangeLog:

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

10 months agobpf: fix generation of neg and neg32 BPF instructions
Jose E. Marchesi [Wed, 26 Jul 2023 10:07:30 +0000 (12:07 +0200)] 
bpf: fix generation of neg and neg32 BPF instructions

This patch fixes GCC to generate correct neg and neg32 instructions,
which do not take a source register operand.  A couple of new tests
are added.

Tested in bpf-unknown-none.

gcc/ChangeLog

2023-07-26  Jose E. Marchesi  <jose.marchesi@oracle.com>

* config/bpf/bpf.md: Fix neg{SI,DI}2 insn.

gcc/testsuite/ChangeLog

2023-07-26  Jose E. Marchesi  <jose.marchesi@oracle.com>

* gcc.target/bpf/neg-1.c: New test.
* gcc.target/bpf/neg-pseudoc-1.c: Likewise.

10 months agolibgomp.texi: Add status item, @ref and document omp_in_explicit_task
Tobias Burnus [Wed, 26 Jul 2023 09:52:20 +0000 (11:52 +0200)] 
libgomp.texi: Add status item, @ref and document omp_in_explicit_task

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.2 features): Add 'all' for 'defaultmap' as 'N'.
(Tasking Routines): Document omp_in_explicit_task.
(Implementation-defined ICV Initialization): Use @ref not @code.

10 months agotree-optimization/110799 - fix bug in code hoisting
Richard Biener [Wed, 26 Jul 2023 07:28:10 +0000 (09:28 +0200)] 
tree-optimization/110799 - fix bug in code hoisting

Code hoisting part of GIMPLE PRE failed to adjust the TBAA behavior
of common loads in the case the alias set of the ref was the same
but the base alias set was not.  It also failed to adjust the
base behavior, assuming it would match.  The following plugs this
hole.

PR tree-optimization/110799
* tree-ssa-pre.cc (compute_avail): More thoroughly match
up TBAA behavior of redundant loads.

* gcc.dg/torture/pr110799.c: New testcase.

10 months agorange-op-float: Fix up -frounding-math frange_arithmetic +- handling [PR110755]
Jakub Jelinek [Wed, 26 Jul 2023 08:50:50 +0000 (10:50 +0200)] 
range-op-float: Fix up -frounding-math frange_arithmetic +- handling [PR110755]

IEEE754 says that x + (-x) and x - x result in +0 in all rounding modes
but rounding towards negative infinity, in which case the result is -0
for all finite x.  x + x and x - (-x) if it is zero retain sign of x.
Now, range_arithmetic implements the normal rounds to even rounding,
and as the addition or subtraction in those cases is exact, we don't do any
further rounding etc. and e.g. on the testcase below distilled from glibc
compute a range [+0, +INF], which is fine for -fno-rounding-math or
if we'd have a guarantee that those statements aren't executed with rounding
towards negative infinity.

I believe it is only +- which has this problematic behavior and I think
it is best to deal with it in frange_arithmetic; if we know -frounding-math
is on, it is x + (-x) or x - x and we are asked to round to negative
infinity (i.e. want low bound rather than high bound), change +0 result to
-0.

2023-07-26  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/110755
* range-op-float.cc (frange_arithmetic): Change +0 result to -0
for PLUS_EXPR or MINUS_EXPR if -frounding-math, inf is negative and
it is exact op1 + (-op1) or op1 - op1.

* gcc.dg/pr110755.c: New test.

10 months agors6000: Correct vsx operands output for xxeval [PR110741]
Kewen Lin [Wed, 26 Jul 2023 08:42:29 +0000 (03:42 -0500)] 
rs6000: Correct vsx operands output for xxeval [PR110741]

PR110741 exposes one issue that we didn't use the correct
character for vsx operands in output operand substitution,
consequently it can map to the wrong registers which hold
some unexpected values.

PR target/110741

gcc/ChangeLog:

* config/rs6000/vsx.md (define_insn xxeval): Correct vsx
operands output with "x".

gcc/testsuite/ChangeLog:

* g++.target/powerpc/pr110741.C: New test.

10 months ago[range-ops] Handle bitmasks for ABSU_EXPR.
Aldy Hernandez [Tue, 25 Jul 2023 16:35:23 +0000 (12:35 -0400)] 
[range-ops] Handle bitmasks for ABSU_EXPR.

gcc/ChangeLog:

* range-op.cc (class operator_absu): Add update_bitmask.
(operator_absu::update_bitmask): New.

10 months ago[range-ops] Handle bitmasks for ABS_EXPR.
Aldy Hernandez [Tue, 25 Jul 2023 16:35:08 +0000 (12:35 -0400)] 
[range-ops] Handle bitmasks for ABS_EXPR.

gcc/ChangeLog:

* range-op-mixed.h (class operator_abs): Add update_bitmask.
* range-op.cc (operator_abs::update_bitmask): New.

10 months ago[range-ops] Handle bitmasks for BIT_NOT_EXPR.
Aldy Hernandez [Tue, 25 Jul 2023 16:34:21 +0000 (12:34 -0400)] 
[range-ops] Handle bitmasks for BIT_NOT_EXPR.

gcc/ChangeLog:

* range-op-mixed.h (class operator_bitwise_not): Add update_bitmask.
* range-op.cc (operator_bitwise_not::update_bitmask): New.

10 months ago[range-ops] Handle bitmasks for unary operators.
Aldy Hernandez [Tue, 25 Jul 2023 16:30:42 +0000 (12:30 -0400)] 
[range-ops] Handle bitmasks for unary operators.

It looks like we missed out on bitmasks for unary operators because we
were using bit_value_binop exclusively.  This patch hands off to
bit_value_unop when appropriate, thus allowing us to handle ABS and
BIT_NOT_EXPR, and others.  Follow-up patches will add the tweaks for the
range-ops entries themselves.

gcc/ChangeLog:

* range-op.cc (update_known_bitmask): Handle unary operators.

10 months agoInitialize value in bit_value_unop.
Aldy Hernandez [Tue, 25 Jul 2023 16:25:30 +0000 (12:25 -0400)] 
Initialize value in bit_value_unop.

bit_value_binop initializes VAL regardless of the final mask.  It even
has a comment to that effect:

  /* Ensure that VAL is initialized (to any value).  */

However, bit_value_unop, which in theory shares the same API, does not.
This causes range-ops to choke on uninitialized VALs for some inputs to
ABS.

Instead of fixing the callers, it's cleaner to make bit_value_unop and
bit_value_binop consistent.

gcc/ChangeLog:

* tree-ssa-ccp.cc (bit_value_unop): Initialize val when appropriate.

10 months agoRISC-V: Fixbug for fsflags instruction error using immediate.
Jin Ma [Wed, 26 Jul 2023 05:41:04 +0000 (13:41 +0800)] 
RISC-V: Fixbug for fsflags instruction error using immediate.

The pattern mistakenly believes that fsflags can use immediate numbers,
but in fact it does not support it. Immediate numbers should use fsflagsi.

For example:
__builtin_riscv_fsflags(4);

The following error occurred.
/tmp/ccoWdWqT.s: Assembler messages:
/tmp/ccoWdWqT.s:14: Error: illegal operands `fsflags 4'

gcc/ChangeLog:

* config/riscv/riscv.md: Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/fsflags.c: New test.

10 months agoFix profile_count::to_sreal_scale
Jan Hubicka [Wed, 26 Jul 2023 06:59:23 +0000 (08:59 +0200)] 
Fix profile_count::to_sreal_scale

gcc/ChangeLog:

* profile-count.cc (profile_count::to_sreal_scale): Value is not know
if we divide by zero.

10 months agoc++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675]
Nathaniel Shead [Sat, 22 Jul 2023 15:15:14 +0000 (01:15 +1000)] 
c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675]

This adds rudimentary lifetime tracking in C++ constexpr contexts,
allowing the compiler to report errors with using values after their
backing has gone out of scope. We don't yet handle other ways of
accessing values outside their lifetime (e.g. following explicit
destructor calls).

PR c++/96630
PR c++/98675
PR c++/70331

gcc/cp/ChangeLog:

* constexpr.cc (constexpr_global_ctx::is_outside_lifetime): New
function.
(constexpr_global_ctx::get_value): Don't return expired values.
(constexpr_global_ctx::get_value_ptr): Likewise.
(constexpr_global_ctx::remove_value): Mark value outside
lifetime.
(outside_lifetime_error): New function.
(cxx_eval_call_expression): No longer track save_exprs.
(cxx_eval_loop_expr): Likewise.
(cxx_eval_constant_expression): Add checks for outside lifetime
values. Remove local variables at end of bind exprs, and
temporaries after cleanup points.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/constexpr-lifetime1.C: New test.
* g++.dg/cpp1y/constexpr-lifetime2.C: New test.
* g++.dg/cpp1y/constexpr-lifetime3.C: New test.
* g++.dg/cpp1y/constexpr-lifetime4.C: New test.
* g++.dg/cpp1y/constexpr-lifetime5.C: New test.
* g++.dg/cpp1y/constexpr-lifetime6.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
10 months agoc++: Prevent dangling pointers from becoming nullptr in constexpr [PR110619]
Nathaniel Shead [Sat, 22 Jul 2023 15:14:37 +0000 (01:14 +1000)] 
c++: Prevent dangling pointers from becoming nullptr in constexpr [PR110619]

Currently, when typeck discovers that a return statement will refer to a
local variable it rewrites to return a null pointer. This causes the
error messages for using the return value in a constant expression to be
unhelpful, especially for reference return values, and is also a visible
change to otherwise valid code (as in the linked PR).

The transformation is nonetheless important, however, both as a safety
guard against attackers being able to gain a handle to other data on the
stack, and to prevent duplicate warnings from later null-dereference
warning passes.

As such, this patch just delays the transformation until cp_genericize,
after constexpr function definitions have been generated.

PR c++/110619

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_genericize_r): Transform RETURN_EXPRs to
not return dangling pointers.
* cp-tree.h (RETURN_EXPR_LOCAL_ADDR_P): New flag.
(check_return_expr): Add a new parameter.
* semantics.cc (finish_return_stmt): Set flag on RETURN_EXPR
when referring to dangling pointer.
* typeck.cc (check_return_expr): Disable transformation of
dangling pointers, instead pass this information to caller.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/constexpr-110619.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
10 months agoc++: Improve location information in constant evaluation
Nathaniel Shead [Sat, 22 Jul 2023 15:13:43 +0000 (01:13 +1000)] 
c++: Improve location information in constant evaluation

This patch updates 'input_location' during constant evaluation to ensure
that errors in subexpressions that lack location information still
provide accurate diagnostics.

By itself this change causes some small regressions in diagnostic
quality for circumstances where errors used 'input_location' but the
location of the parent subexpression doesn't make sense, so this patch
also includes a small diagnostic improvement to fix the most egregious
case.

gcc/cp/ChangeLog:

* constexpr.cc (modifying_const_object_error): Find the source
location of the const object's declaration.
(cxx_eval_constant_expression): Update input_location to the
location of the currently evaluated expression, if possible.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/equal/constexpr_neg.cc: Update diagnostic
locations.
* testsuite/26_numerics/gcd/105844.cc: Likewise.
* testsuite/26_numerics/lcm/105844.cc: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-48089.C: Update diagnostic locations.
* g++.dg/cpp0x/constexpr-70323.C: Likewise.
* g++.dg/cpp0x/constexpr-70323a.C: Likewise.
* g++.dg/cpp0x/constexpr-delete2.C: Likewise.
* g++.dg/cpp0x/constexpr-diag3.C: Likewise.
* g++.dg/cpp0x/constexpr-ice20.C: Likewise.
* g++.dg/cpp0x/constexpr-mutable3.C: Likewise.
* g++.dg/cpp0x/constexpr-recursion.C: Likewise.
* g++.dg/cpp0x/overflow1.C: Likewise.
* g++.dg/cpp1y/constexpr-89285.C: Likewise.
* g++.dg/cpp1y/constexpr-89481.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const14.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const16.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const18.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const19.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const21.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const22.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const3.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const4.C: Likewise.
* g++.dg/cpp1y/constexpr-tracking-const7.C: Likewise.
* g++.dg/cpp1y/constexpr-union5.C: Likewise.
* g++.dg/cpp1y/pr68180.C: Likewise.
* g++.dg/cpp1z/constexpr-lambda6.C: Likewise.
* g++.dg/cpp1z/constexpr-lambda8.C: Likewise.
* g++.dg/cpp2a/bit-cast11.C: Likewise.
* g++.dg/cpp2a/bit-cast12.C: Likewise.
* g++.dg/cpp2a/bit-cast14.C: Likewise.
* g++.dg/cpp2a/constexpr-98122.C: Likewise.
* g++.dg/cpp2a/constexpr-dynamic17.C: Likewise.
* g++.dg/cpp2a/constexpr-init1.C: Likewise.
* g++.dg/cpp2a/constexpr-new12.C: Likewise.
* g++.dg/cpp2a/constexpr-new3.C: Likewise.
* g++.dg/cpp2a/constinit10.C: Likewise.
* g++.dg/cpp2a/is-corresponding-member4.C: Likewise.
* g++.dg/ext/constexpr-vla2.C: Likewise.
* g++.dg/ext/constexpr-vla3.C: Likewise.
* g++.dg/ubsan/pr63956.C: Likewise.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
10 months agotestsuite: run C++11 tests in C++11 mode
Jason Merrill [Tue, 25 Jul 2023 19:39:31 +0000 (15:39 -0400)] 
testsuite: run C++11 tests in C++11 mode

A recent change missed updating constexpr-mutable3.C because it wasn't run
in C++11 mode even though it checks the behavior for { target c++11_only }.

gcc/testsuite/ChangeLog:

* lib/g++-dg.exp (g++-dg-runtest): Check for c++11_only.

10 months agoDaily bump.
GCC Administrator [Wed, 26 Jul 2023 00:17:44 +0000 (00:17 +0000)] 
Daily bump.

10 months agobpf: don't print () in bpf_print_operand_address
David Faust [Tue, 25 Jul 2023 18:50:38 +0000 (11:50 -0700)] 
bpf: don't print () in bpf_print_operand_address

Unfortunately, the pseudo-C dialect syntax used for some of the v3
atomic instructions clashes with unconditionally printing the
surrounding parentheses in bpf_print_operand_address.

Instead, place the parentheses in the output templates where needed.

gcc/

* config/bpf/bpf.cc (bpf_print_operand_address): Don't print
enclosing parentheses for pseudo-C dialect.
* config/bpf/bpf.md (zero_exdendhidi2): Add parentheses around
operands of pseudo-C dialect output templates where needed.
(zero_extendqidi2): Likewise.
(zero_extendsidi2): Likewise.
(*mov<MM:mode>): Likewise.

10 months agoFix 110803: use of plain char instead of signed char
Andrew Pinski [Tue, 25 Jul 2023 21:50:33 +0000 (21:50 +0000)] 
Fix 110803: use of plain char instead of signed char

So the problem here is that plain char can either be signed
or unsigned depending on the target (powerpc and aarch64 are
unsigned while most other targets are signed). So the testcase
gcc.c-torture/execute/pr109986.c was assuming plain char was signed
char which is wrong so it is better to just change the `char` to be
`signed char`.
Note gcc.c-torture/execute/pr109986.c includes gcc.dg/tree-ssa/pr109986.c
where the plain char was being used.

Committed as obvious after a quick test to make sure gcc.c-torture/execute/pr109986.c
now passes and gcc.dg/tree-ssa/pr109986.c still passes.

gcc/testsuite/ChangeLog:

PR testsuite/110803
* gcc.dg/tree-ssa/pr109986.c: Change plain char to be
`signed char`.

10 months agoUpdate gcc uk.po
Joseph Myers [Tue, 25 Jul 2023 20:41:41 +0000 (20:41 +0000)] 
Update gcc uk.po

* uk.po: Update.

10 months agoc++: clear tf_partial et al in instantiate_template [PR108960]
Marek Polacek [Tue, 25 Jul 2023 18:36:47 +0000 (14:36 -0400)] 
c++: clear tf_partial et al in instantiate_template [PR108960]

In <https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612929.html>
we concluded that we might clear all flags except tf_warning_or_error
when performing instantiate_template.

PR c++/108960

gcc/cp/ChangeLog:

* pt.cc (lookup_and_finish_template_variable): Don't clear tf_partial
here.
(instantiate_template): Reset all complain flags except
tf_warning_or_error.

10 months agoList myself as "nvptx port" maintainer
Thomas Schwinge [Tue, 25 Jul 2023 19:17:52 +0000 (21:17 +0200)] 
List myself as "nvptx port" maintainer

* MAINTAINERS: List myself as "nvptx port" maintainer.

10 months agoMake some functions in CCP static.
Aldy Hernandez [Tue, 25 Jul 2023 15:51:28 +0000 (11:51 -0400)] 
Make some functions in CCP static.

gcc/ChangeLog:

* tree-ssa-ccp.cc (value_mask_to_min_max): Make static.
(bit_value_mult_const): Same.
(get_individual_bits): Same.

10 months agoc++: fix ICE with constexpr ARRAY_REF [PR110382]
Marek Polacek [Fri, 21 Jul 2023 21:48:37 +0000 (17:48 -0400)] 
c++: fix ICE with constexpr ARRAY_REF [PR110382]

This code in cxx_eval_array_reference has been hard to get right.
In r12-2304 I added some code; in r13-5693 I removed some of it.

Here the problematic line is "S s = arr[0];" which causes a crash
on the assert in verify_ctor_sanity:

  gcc_assert (!ctx->object || !DECL_P (ctx->object)
              || ctx->global->get_value (ctx->object) == ctx->ctor);

ctx->object is the VAR_DECL 's', which is correct here.  The second
line points to the problem: we replaced ctx->ctor in
cxx_eval_array_reference:

  new_ctx.ctor = build_constructor (elem_type, NULL); // #1

which I think we shouldn't have; the CONSTRUCTOR we created in
cxx_eval_constant_expression/DECL_EXPR

  new_ctx.ctor = build_constructor (TREE_TYPE (r), NULL);

had the right type.

We still need #1 though.  E.g., in constexpr-96241.C, we never
set ctx.ctor/object before calling cxx_eval_array_reference, so
we have to build a CONSTRUCTOR there.  And in constexpr-101371-2.C
we have a ctx.ctor, but it has the wrong type, so we need a new one.

We can fix the problem by always clearing the object, and, as an
optimization, only create/free a new ctor when actually needed.

PR c++/110382

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_array_reference): Create a new constructor
only when we don't already have a matching one.  Clear the object
when the type is non-scalar.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/constexpr-110382.C: New test.

10 months agoOpenMP/Fortran: Reject declarations between target + teams
Tobias Burnus [Tue, 25 Jul 2023 13:43:58 +0000 (15:43 +0200)] 
OpenMP/Fortran: Reject declarations between target + teams

While commit r14-2754-g2e31fe431b08b0302e1fa8a1c18ee51adafd41df
detected executable statements, declarations do not show up as
executable statements.  Hence, we now check whether the first
statement after TARGET is TEAMS - such that we can detect data
statements like type or variable declarations.  Fortran semantics
ensures that only executable directives/statemens can come after
'!$omp end teams' such that those can be detected with the
previous check.

Note that statements returning ST_NONE such as 'omp nothing' or
'omp error at(compilation)' will still slip through.

PR fortran/110725
PR middle-end/71065

gcc/fortran/ChangeLog:

* gfortran.h (gfc_omp_clauses): Add target_first_st_is_teams.
* parse.cc (parse_omp_structured_block): Set it if the first
statement in the structured block of a TARGET is TEAMS or
a combined/composite starting with TEAMS.
* openmp.cc (resolve_omp_target): Also show an error for
contains_teams_construct without target_first_st_is_teams.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/teams-6.f90: New test.

10 months agoAdjust one Ada test
Marc Poulhiès [Tue, 25 Jul 2023 12:11:54 +0000 (14:11 +0200)] 
Adjust one Ada test

Recent change modified how the loops are created, with the first
iteration being extracted out of the loops in the 2 test cases.
Adjust the text to match from the unroll dump.

gcc/testsuite/ChangeLog:

* gnat.dg/unroll3.adb: Adjust.

10 months agogfortran.dg/gomp/pr99226.f90: Add missing dg-error
Tobias Burnus [Tue, 25 Jul 2023 07:28:43 +0000 (09:28 +0200)] 
gfortran.dg/gomp/pr99226.f90: Add missing dg-error

Follow up to r14-2754-g2e31fe431b08b0302e1fa8a1c18ee51adafd41df
which added a check that a target region with teams does not
have anything anything else strictly nested in the target.

When changing the dg-error for this PR, somehow the addition of a
dg-error in a second line was lost (the message uses (1) and (2) as
location, showing two lines, both need a dg-error with the same message).

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr99226.f90: Update dg-error.

10 months agors6000: Implemented f[min/max]_optab by xs[min/max]dp
Haochen Gui [Tue, 25 Jul 2023 02:40:37 +0000 (10:40 +0800)] 
rs6000: Implemented f[min/max]_optab by xs[min/max]dp

gcc/
PR target/103605
* config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_builtin): Gimple
fold RS6000_BIF_XSMINDP and RS6000_BIF_XSMAXDP when fast-math is set.
* config/rs6000/rs6000.md (FMINMAX): New int iterator.
(minmax_op): New int attribute.
(UNSPEC_FMAX, UNSPEC_FMIN): New unspecs.
(f<minmax_op><mode>3): New pattern by UNSPEC_FMAX and UNSPEC_FMIN.
* config/rs6000/rs6000-builtins.def (__builtin_vsx_xsmaxdp): Set
pattern to fmaxdf3.
(__builtin_vsx_xsmindp): Set pattern to fmindf3.

gcc/testsuite/
PR target/103605
* gcc.target/powerpc/pr103605.h: New.
* gcc.target/powerpc/pr103605-1.c: New.
* gcc.target/powerpc/pr103605-2.c: New.

10 months agoPR modula2/110174 Bugfixes to M2GenGCC.mod:CodeInline preventing an ICE
Gaius Mulley [Tue, 25 Jul 2023 02:21:12 +0000 (03:21 +0100)] 
PR modula2/110174 Bugfixes to M2GenGCC.mod:CodeInline preventing an ICE

This patch calls skip_const_decl before chaining parameter values and
ensures that all strings passed to build_stmt (..., ASM_EXPR, ...) are
nul terminated.  It also improves the accuracy of locations in
function calls and asm statements.

gcc/m2/

PR modula2/110174
* gm2-compiler/M2GCCDeclare.def (PromoteToCString): New procedure
function.
* gm2-compiler/M2GCCDeclare.mod (PromoteToCString): New procedure
function.
* gm2-compiler/M2GenGCC.mod (BuildTreeFromInterface): Call
skip_const_decl before chaining the parameter value.
Use PromoteToCString to ensure the string is nul terminated.
(CodeInline): Remove all parameters and replace with quad.
Use GetQuadOtok to get operand token numbers.
Remove call to DeclareConstant and replace it with PromoteToCString.
* gm2-compiler/M2Quads.def (BuildInline): Rename into ...
(BuildAsm): ... this.
* gm2-compiler/M2Quads.mod: (BuildInline): Rename into ...
(BuildAsm): ... this.
(BuildAsmElement): Add debugging.
* gm2-compiler/P1Build.bnf: Remove import of BuildInline.
* gm2-compiler/P2Build.bnf: Remove import of BuildInline.
* gm2-compiler/P3Build.bnf: Remove import of BuildInline and
import BuildAsm.
* gm2-compiler/PHBuild.bnf: Remove import of BuildInline.
* gm2-libs-iso/SysClock.mod (foo): Remove.
* gm2-libs/FIO.mod (BufferedRead): Rename parameter a to dest.
Rename variable t to src.
* m2pp.cc (pf): Correct block comment.
(pe): Correct block comment.
(m2pp_asm_expr): New function.
(m2pp_statement): Call m2pp_asm_expr.

gcc/testsuite/

PR modula2/110174
* gm2/pim/pass/program2.mod: Remove import of BuildInline.
* gm2/extensions/asm/fail/extensions-asm-fail.exp: New test.
* gm2/extensions/asm/fail/stressreturn.mod: New test.
* gm2/extensions/asm/pass/extensions-asm-pass.exp: New test.
* gm2/extensions/asm/pass/fooasm.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
10 months agoDaily bump.
GCC Administrator [Tue, 25 Jul 2023 00:18:54 +0000 (00:18 +0000)] 
Daily bump.

10 months agolibstdc++: Add missing constexpr specifiers in <format>
Deev Patel [Mon, 24 Jul 2023 20:10:52 +0000 (21:10 +0100)] 
libstdc++: Add missing constexpr specifiers in <format>

A couple of virtual functions in the libstdc++ format header are marked
constexpr in the base class, but not in the derived class. This was
causing build failures when trying to compile latest gcc libstdc++ with
clang 16 using c++20. Adding the constexpr specifier resolves the issue.

libstdc++-v3/ChangeLog:

* include/std/format (_Formatting_scanner::_M_on_chars): Add
missing constexpr specifier.
(_Formatting_scanner::_M_format_arg): Likewise.

10 months agoOpenMP/Fortran: Reject not strictly nested target -> teams [PR110725, PR71065]
Tobias Burnus [Mon, 24 Jul 2023 20:57:07 +0000 (22:57 +0200)] 
OpenMP/Fortran: Reject not strictly nested target -> teams [PR110725, PR71065]

OpenMP requires: "If a teams region is nested inside a target region, the
corresponding target construct must not contain any statements, declarations
or directives outside of the corresponding teams construct."

This commit checks now for this restriction.

PR fortran/110725
PR middle-end/71065

gcc/fortran/ChangeLog:

* gfortran.h (gfc_omp_clauses): Add contains_teams_construct.
* openmp.cc (resolve_omp_target): New; check for teams nesting.
(gfc_resolve_omp_directive): Call it.
* parse.cc (decode_omp_directive): Set contains_teams_construct
on enclosing ST_OMP_TARGET.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr99226.f90: Update dg-error.
* gfortran.dg/gomp/teams-5.f90: New test.

10 months agolibstdc++; Do not use strtold for hppa-hpux [PR110653]
Jonathan Wakely [Mon, 24 Jul 2023 10:45:43 +0000 (11:45 +0100)] 
libstdc++; Do not use strtold for hppa-hpux [PR110653]

When I switched std::stold to depend on HAVE_STRTOLD that enabled it for
hppa-hpux which defines HAVE_BROKEN_STRTOLD. Add a check for that macro
so that we don't use strtold, and fall through to the check for double
and long double having the same representation. That should mean we
define a conforming std::stold in terms of std::stod, instead of trying
to use the broken strtold.

Also fix a logic error in the fallback definition of std::stod, which
should not treat zero as a subnormal number.

libstdc++-v3/ChangeLog:

PR libstdc++/110653
* include/bits/basic_string.h [!HAVE_STOF] (stof): Do not
throw an exception for zero result.
[HAVE_BROKEN_STRTOLD] (stold): Do not use strtold.

10 months agobpf: add pseudo-c asm dialect for "nop"
David Faust [Mon, 24 Jul 2023 18:40:57 +0000 (11:40 -0700)] 
bpf: add pseudo-c asm dialect for "nop"

The define_insn "nop" was missing a template for the pseudo-c dialect,
so the normal syntax was unconditionally emitted.

gcc/

* config/bpf/bpf.md (nop): Add pseudo-c asm dialect template.

10 months agomatch.pd: Implement missed optimization (~X | Y) ^ X -> ~(X & Y) [PR109986]
Drew Ross [Mon, 24 Jul 2023 15:51:28 +0000 (17:51 +0200)] 
match.pd: Implement missed optimization (~X | Y) ^ X -> ~(X & Y) [PR109986]

Adds a simplification for (~X | Y) ^ X to be folded into ~(X & Y).
Also adds the macro bitwise_equal_p for generic and gimple which
returns true iff EXPR1 and EXPR2 have the same value. This helps
to reduce the number of nop_converts necessary to match the pattern.

PR middle-end/109986

gcc/ChangeLog:

* generic-match-head.cc (bitwise_equal_p): New macro.
* gimple-match-head.cc (bitwise_equal_p): New macro.
(gimple_nop_convert): Declare.
(gimple_bitwise_equal_p): Helper for bitwise_equal_p.
* match.pd ((~X | Y) ^ X -> ~(X & Y)): New simplification.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/pr109986.c: New test.
* gcc.dg/tree-ssa/pr109986.c: New test.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
10 months ago[committed] Use single quote rather than backquote in RISC-V diagnostic
Jeff Law [Mon, 24 Jul 2023 14:10:21 +0000 (08:10 -0600)] 
[committed] Use single quote rather than backquote in RISC-V diagnostic

Similar to the other patch this morning, this fixes a warning that was causing
the RISC-V bootstrap to fail.

In this case the diagnostic used a backquote.  This changes it to a simple
single quote which the diagnostic framework won't complain about.

Committed to the trunk.

gcc/
* common/config/riscv/riscv-common.cc (riscv_subset_list::add): Use
single quote rather than backquote in diagnostic.

10 months agobpf: sdiv/smod are now part of BPF V4
Jose E. Marchesi [Mon, 24 Jul 2023 13:57:05 +0000 (15:57 +0200)] 
bpf: sdiv/smod are now part of BPF V4

We used to support signed division and signed modulus instructions in
the XBPF GCC-specific extensions to BPF.  However, BPF catched up by
adding these instructions in the V4 of the ISA.

This patch changes GCC in order to use sdiv/smod instructions when
-mcpu=v4 or higher.  The testsuite and the manual have been updated
accordingly.

Tested in bpf-unknown-none.

gcc/ChangeLog

PR target/110783
* config/bpf/bpf.opt: New command-line option -msdiv.
* config/bpf/bpf.md: Conditionalize sdiv/smod on bpf_has_sdiv.
* config/bpf/bpf.cc (bpf_option_override): Initialize
bpf_has_sdiv.
* doc/invoke.texi (eBPF Options): Document -msdiv.

gcc/testsuite/ChangeLog

PR target/110783
* gcc.target/bpf/xbpf-sdiv-1.c: Renamed to sdiv-1.c
* gcc.target/bpf/xbpf-smod-1.c: Renamed to smod-1.c
* gcc.target/bpf/sdiv-1.c: Renamed from xbpf-sdiv-1.c, use -mcpu=v4.
* gcc.target/bpf/smod-1.c: Renamed from xbpf-smod-1.c, use -mcpu=v4.
* gcc.target/bpf/diag-sdiv.c: Use -mcpu=v3.
* gcc.target/bpf/diag-smod.c: Likewise.

10 months ago[committed][RISC-V] Fix minor issues in diagnostic message
Jeff Law [Mon, 24 Jul 2023 13:56:36 +0000 (07:56 -0600)] 
[committed][RISC-V] Fix minor issues in diagnostic message

This fixes two minor issues with the recently adding warning about too large
VLEN in the RISC-V backend.  These prevent the RISC-V port from bootstrapping
as both Andreas and I have found.

Specifically we'll get warnings for the use of '>' in the recently added
 message as well as using "can not" vs "cannot".  While these warnings may
seem annoying, they're in place to make it easier for the translators.

This patch fixes the message in the fairly obvious way.  Spells out the
greater than and uses cannot.  There's a similar issue in another recently
added diagnostic that I'll push momentarily.

gcc/
* config/riscv/riscv.cc (riscv_option_override): Spell out
greater than and use cannot in diagnostic string.

10 months agoRemove SLP_TREE_VEC_STMTS in favor of SLP_TREE_VEC_DEFS
Richard Biener [Mon, 24 Jul 2023 10:14:26 +0000 (12:14 +0200)] 
Remove SLP_TREE_VEC_STMTS in favor of SLP_TREE_VEC_DEFS

The following unifies SLP_TREE_VEC_STMTS into SLP_TREE_VEC_DEFS
which can handle all cases we need.

* tree-vectorizer.h (_slp_tree::push_vec_def): Add.
(_slp_tree::vec_stmts): Remove.
(SLP_TREE_VEC_STMTS): Remove.
* tree-vect-slp.cc (_slp_tree::push_vec_def): Define.
(_slp_tree::_slp_tree): Adjust.
(_slp_tree::~_slp_tree): Likewise.
(vect_get_slp_vect_def): Simplify.
(vect_get_slp_defs): Likewise.
(vect_transform_slp_perm_load_1): Adjust.
(vect_add_slp_permutation): Likewise.
(vect_schedule_slp_node): Likewise.
(vectorize_slp_instance_root_stmt): Likewise.
(vect_schedule_scc): Likewise.
* tree-vect-stmts.cc (vectorizable_bswap): Use push_vec_def.
(vectorizable_call): Likewise.
(vectorizable_call): Likewise.
(vect_create_vectorized_demotion_stmts): Likewise.
(vectorizable_conversion): Likewise.
(vectorizable_assignment): Likewise.
(vectorizable_shift): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_load): Likewise.
(vectorizable_condition): Likewise.
(vectorizable_comparison): Likewise.
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Adjust.
(vectorize_fold_left_reduction): Use push_vec_def.
(vect_transform_reduction): Likewise.
(vect_transform_cycle_phi): Likewise.
(vectorizable_lc_phi): Likewise.
(vectorizable_phi): Likewise.
(vectorizable_recurr): Likewise.
(vectorizable_induction): Likewise.
(vectorizable_live_operation): Likewise.

10 months agoRemove unused tree-vectorizer.h include
Richard Biener [Mon, 24 Jul 2023 10:13:35 +0000 (12:13 +0200)] 
Remove unused tree-vectorizer.h include

* tree-ssa-loop.cc: Remove unused tree-vectorizer.h include.

10 months ago[i386] remove unused tree-vectorizer.h includes
Richard Biener [Mon, 24 Jul 2023 10:12:00 +0000 (12:12 +0200)] 
[i386] remove unused tree-vectorizer.h includes

* config/i386/i386-builtins.cc: Remove tree-vectorizer.h include.
* config/i386/i386-expand.cc: Likewise.
* config/i386/i386-features.cc: Likewise.
* config/i386/i386-options.cc: Likewise.

10 months agovect: Handle demoting FLOAT and promoting FIX_TRUNC.
Robin Dapp [Thu, 13 Jul 2023 07:10:06 +0000 (09:10 +0200)] 
vect: Handle demoting FLOAT and promoting FIX_TRUNC.

The recent changes that allowed multi-step conversions for
"non-packing/unpacking", i.e. modifier == NONE targets included
promoting to-float and demoting to-int variants.  This patch
adds the missing demoting to-float and promoting to-int handling.

gcc/ChangeLog:

* tree-vect-stmts.cc (vectorizable_conversion): Handle
more demotion/promotion for modifier == NONE.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/conversions/vec-narrow-int64-float16.c: New test.
* gcc.target/riscv/rvv/autovec/conversions/vec-widen-float16-int64.c: New test.

10 months ago[Committed] PR target/110787: Revert QImode offsets in {zero,sign}_extract.
Roger Sayle [Mon, 24 Jul 2023 11:34:23 +0000 (12:34 +0100)] 
[Committed] PR target/110787: Revert QImode offsets in {zero,sign}_extract.

My recent patch to use QImode for bit offsets in ZERO_EXTRACTs and
SIGN_EXTRACTs in the i386 backend shouldn't have resulted in any change
behaviour, but as reported by Rainer it produces a bootstrap failure in
gm2.  This reverts the problematic patch whilst we investigate the
underlying cause.

Committed as obvious.

2023-07-23  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/110787
PR target/110790
Revert patch.
* config/i386/i386.md (extv<mode>): Use QImode for offsets.
(extzv<mode>): Likewise.
(insv<mode>): Likewise.
(*testqi_ext_3): Likewise.
(*btr<mode>_2): Likewise.
(define_split): Likewise.
(*btsq_imm): Likewise.
(*btrq_imm): Likewise.
(*btcq_imm): Likewise.
(define_peephole2 x3): Likewise.
(*bt<mode>): Likewise
(*bt<mode>_mask): New define_insn_and_split.
(*jcc_bt<mode>): Use QImode for offsets.
(*jcc_bt<mode>_1): Delete obsolete pattern.
(*jcc_bt<mode>_mask): Use QImode offsets.
(*jcc_bt<mode>_mask_1): Likewise.
(define_split): Likewise.
(*bt<mode>_setcqi): Likewise.
(*bt<mode>_setncqi): Likewise.
(*bt<mode>_setnc<mode>): Likewise.
(*bt<mode>_setncqi_2): Likewise.
(*bt<mode>_setc<mode>_mask): New define_insn_and_split.
(bmi2_bzhi_<mode>3): Use QImode offsets.
(*bmi2_bzhi_<mode>3): Likewise.
(*bmi2_bzhi_<mode>3_1): Likewise.
(*bmi2_bzhi_<mode>3_1_ccz): Likewise.
(@tbm_bextri_<mode>): Likewise.

10 months agobpf: remove -mkernel option and BPF_KERNEL_VERSION_CODE
Jose E. Marchesi [Mon, 24 Jul 2023 09:52:30 +0000 (11:52 +0200)] 
bpf: remove -mkernel option and BPF_KERNEL_VERSION_CODE

Having the ability of specifying a target kernel version when building
a BPF program is one of these things that sound pretty good in theory,
but simply don't work in practice: kernels in practice contain
backports, etc.  Also, the addition of CO-RE to BPF has made this
uneccessary.

This patch removes the -mkernel command line option and also the
associated BPF_KERNEL_VERSION_CODE pre-processor constant.

Tested in bpf-unknown-none.

gcc/ChangeLog

* config/bpf/bpf-opts.h (enum bpf_kernel_version): Remove enum.
* config/bpf/bpf.opt (mkernel): Remove option.
* config/bpf/bpf.cc (bpf_target_macros): Do not define
BPF_KERNEL_VERSION_CODE.

10 months agobpf: make use of the bswap{16,32,64} V4 BPF instruction
Jose E. Marchesi [Mon, 24 Jul 2023 08:56:27 +0000 (10:56 +0200)] 
bpf: make use of the bswap{16,32,64} V4 BPF instruction

This patch makes the BPF backend to use the new V4 bswap{16,32,64}
instructions in order to implement the __builtin_bswap{16,32,64}
built-ins.  It also adds support for -mcpu=v4 and -m[no]bswap
command-line options.  Tests and doc updates are includes.

Tested in bpf-unknown-none.

gcc/ChangeLog

PR target/110786
* config/bpf/bpf.opt (mcpu): Add ISA_V4 and make it the default.
(mbswap): New option.
* config/bpf/bpf-opts.h (enum bpf_isa_version): New value ISA_V4.
* config/bpf/bpf.cc (bpf_option_override): Set bpf_has_bswap.
* config/bpf/bpf.md: Use bswap instructions if available for
bswap* insn, and fix constraint.
* doc/invoke.texi (eBPF Options): Document -mcpu=v4 and -mbswap.

gcc/testsuite/ChangeLog

PR target/110786
* gcc.target/bpf/bswap-1.c: Pass -mcpu=v3 to build test.
* gcc.target/bpf/bswap-2.c: New test.

10 months agoRISC-V: Support in-order floating-point reduction
Juzhe-Zhong [Thu, 20 Jul 2023 08:51:03 +0000 (16:51 +0800)] 
RISC-V: Support in-order floating-point reduction

This patch is depending on:
https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624995.html

Consider this following case:
float foo (float *__restrict a, int n)
{
  float result = 1.0;
  for (int i = 0; i < n; i++)
   result += a[i];
  return result;
}

Compile with **NO** -ffast-math:

Before this patch:
<source>:4:21: missed: couldn't vectorize loop
<source>:1:7: missed: not vectorized: relevant phi not supported: result_14 = PHI <result_11(6), 1.0e+0(5)>

After this patch:
foo:
lui a5,%hi(.LC0)
flw fa0,%lo(.LC0)(a5)
ble a1,zero,.L4
.L3:
vsetvli a5,a1,e32,m1,ta,ma
vle32.v v1,0(a0)
slli a4,a5,2
sub a1,a1,a5
vfmv.s.f v2,fa0
add a0,a0,a4
vfredosum.vs v1,v1,v2     ----------> FOLD_LEFT_PLUS
vfmv.f.s fa0,v1
bne a1,zero,.L3
ret
.L4:
ret

gcc/ChangeLog:

* config/riscv/autovec.md (fold_left_plus_<mode>): New pattern.
(mask_len_fold_left_plus_<mode>): Ditto.
* config/riscv/riscv-protos.h (enum insn_type): New enum.
(enum reduction_type): Ditto.
(expand_reduction): Add in-order reduction.
* config/riscv/riscv-v.cc (emit_nonvlmax_fp_reduction_insn): New function.
(expand_reduction): Add in-order reduction.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/reduc/reduc_strict-1.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict-2.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict-3.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict-4.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict-5.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict-6.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict-7.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-2.c: New test.

10 months agoVECT: Support floating-point in-order reduction for length loop control
Ju-Zhe Zhong [Sun, 23 Jul 2023 04:23:33 +0000 (12:23 +0800)] 
VECT: Support floating-point in-order reduction for length loop control

Hi, Richard and Richi.

This patch support floating-point in-order reduction for loop length control.

Consider this following case:

float foo (float *__restrict a, int n)
{
  float result = 1.0;
  for (int i = 0; i < n; i++)
   result += a[i];
  return result;
}

When compile with **NO** -ffast-math on ARM SVE, we will end up with:

loop_mask = WHILE_ULT
result = MASK_FOLD_LEFT_PLUS (...loop_mask...)

For RVV, we don't use length loop control instead of mask:

So, with this patch, we expect to see:

loop_len = SELECT_VL
result = MASK_LEN_FOLD_LEFT_PLUS (...loop_len...)

gcc/ChangeLog:

* tree-vect-loop.cc (get_masked_reduction_fn): Add mask_len_fold_left_plus.
(vectorize_fold_left_reduction): Ditto.
(vectorizable_reduction): Ditto.
(vect_transform_reduction): Ditto.

10 months agotree-optimization/110777 - abnormals and recent PRE optimization
Richard Biener [Mon, 24 Jul 2023 06:55:11 +0000 (08:55 +0200)] 
tree-optimization/110777 - abnormals and recent PRE optimization

The following avoids propagating abnormals with the recent tweak
to look through PRE introduced copies between equal values.

PR tree-optimization/110777
* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_avail):
Avoid propagating abnormals.

* gcc.dg/pr110777.c: New testcase.

10 months agotree-optimization/110766 - missing PHI location check
Richard Biener [Mon, 24 Jul 2023 06:40:19 +0000 (08:40 +0200)] 
tree-optimization/110766 - missing PHI location check

The following adds a missing PHI location check before querying
the loop latch PHI arg from it.

PR tree-optimization/110766
* tree-scalar-evolution.cc
(analyze_and_compute_bitwise_induction_effect): Check the PHI
is defined in the loop header.

* gcc.dg/torture/pr110766.c: New testcase.

10 months agovect: Don't vectorize a single scalar iteration loop [PR110740]
Kewen Lin [Mon, 24 Jul 2023 06:20:30 +0000 (01:20 -0500)] 
vect: Don't vectorize a single scalar iteration loop [PR110740]

The function vect_update_epilogue_niters which has been
removed by r14-2281 has some code taking care of that if
there is only one scalar iteration left for epilogue then
we won't try to vectorize it any more.

Although costing should be able to care about it eventually,
I think we still want this special casing without costing
enabled, so this patch is to add it back in function
vect_analyze_loop_costing, and make it more general for
both main and epilogue loops as Richi suggested, it can fix
some exposed failures on Power10:

 - gcc.target/powerpc/p9-vec-length-epil-{1,8}.c
 - gcc.dg/vect/slp-perm-{1,5,6,7}.c

PR tree-optimization/110740

gcc/ChangeLog:

* tree-vect-loop.cc (vect_analyze_loop_costing): Do not vectorize a
loop with a single scalar iteration.

10 months agoRISC-V: Bugfix for allowing incorrect dyn for static rounding
Pan Li [Fri, 21 Jul 2023 08:50:08 +0000 (16:50 +0800)] 
RISC-V: Bugfix for allowing incorrect dyn for static rounding

According to the spec, dyn rounding mode is invalid for RVV
floating-point, this patch would like to fix this.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-shapes.cc
(struct alu_frm_def): Take range check.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/float-point-frm-error.c: Update cases.
* gcc.target/riscv/rvv/base/float-point-frm-insert-6.c: Removed.

10 months agoDaily bump.
GCC Administrator [Mon, 24 Jul 2023 00:16:51 +0000 (00:16 +0000)] 
Daily bump.

10 months agoFix PR 110066: crash with -pg -static on riscv
Andrew Pinski [Sat, 22 Jul 2023 15:52:42 +0000 (08:52 -0700)] 
Fix PR 110066: crash with -pg -static on riscv

The problem -fasynchronous-unwind-tables is on by default for riscv linux
We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
to .eh_frame data from crtbeginT.o instead of the user-defined object
during static linking.

This turns it off.

OK?

libgcc/ChangeLog:

* config.host (riscv*-*-linux*): Add t-crtstuff to tmake_file.
(riscv*-*-freebsd*): Likewise.
* config/riscv/t-crtstuff: New file.

10 months agoDaily bump.
GCC Administrator [Sun, 23 Jul 2023 00:17:30 +0000 (00:17 +0000)] 
Daily bump.

10 months agoRISC-V: optim const DF +0.0 store to mem [PR/110748]
Vineet Gupta [Thu, 20 Jul 2023 18:15:37 +0000 (11:15 -0700)] 
RISC-V: optim const DF +0.0 store to mem [PR/110748]

Fixes: ef85d150b5963 ("RISC-V: Enable TARGET_SUPPORTS_WIDE_INT")
DF +0.0 is bitwise all zeros so int x0 store to mem can be used to optimize it.

void zd(double *) { *d = 0.0; }

currently:

| fmv.d.x fa5,zero
| fsd     fa5,0(a0)
| ret

With patch

| sd      zero,0(a0)
| ret

The fix updates predicate const_0_operand() so reg_or_0_operand () now
includes const_double, enabling movdf expander -> riscv_legitimize_move ()
to generate below vs. an intermediate set (reg:DF) const_double:DF

| (insn 6 3 0 2 (set (mem:DF (reg/v/f:DI 134 [ d ])
|        (const_double:DF 0.0 [0x0.0p+0]))

This change also enables such insns to be recog() by later passes.
The md pattern "*movdf_hardfloat_rv64" despite already supporting the
needed constraints {"m","G"} mem/const 0.0 was failing to match because
the additional condition check reg_or_0_operand() was failing due to
missing const_double.

This failure to recog() was triggering an ICE when testing the in-flight
f-m-o patches and is how all of this started, but then was deemed to be
an independent optimization of it's own [1].

[1] https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624857.html

Its worthwhile to note all the set peices were already there and working
up until my own commit mentioned at top regressed the whole thing.

Ran thru full multilib testsuite and no surprises. There was 1 false
failure due to random string "lw" appearing in lto build assembler output,
which is also fixed here.

gcc/ChangeLog:

PR target/110748
* config/riscv/predicates.md (const_0_operand): Add back
const_double.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr110748-1.c: New Test.
* gcc.target/riscv/xtheadfmv-fmv.c: Add '\t' around test
patterns to avoid random string matches.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
10 months agoi386: Don't use insvti_{high,low}part with -O0 (for compile-time).
Roger Sayle [Sat, 22 Jul 2023 20:52:55 +0000 (21:52 +0100)] 
i386: Don't use insvti_{high,low}part with -O0 (for compile-time).

This patch attempts to help with PR rtl-optimization/110587, a regression
of -O0 compile time for the pathological pr28071.c.  My recent patch helps
a bit, but hasn't returned -O0 compile-time to where it was before my
ix86_expand_move changes.  The obvious solution/workaround is to guard
these new TImode parameter passing optimizations with "&& optimize", so
they don't trigger when compiling with -O0.  The very minor complication
is that "&& optimize" alone leads to the regression of pr110533.c, where
our improved TImode parameter passing fixes a wrong-code issue with naked
functions, importantly, when compiling with -O0.  This should explain
the one line fix below "&& (optimize || ix86_function_naked (cfun))".

I've an additional fix/tweak or two for this compile-time issue, but
this change eliminates the part of the regression that I've caused.

2023-07-22  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386-expand.cc (ix86_expand_move): Disable the
64-bit insertions into TImode optimizations with -O0, unless
the function has the "naked" attribute (for PR target/110533).

10 months agoFix alpha building
Andrew Pinski [Sat, 22 Jul 2023 20:34:41 +0000 (20:34 +0000)] 
Fix alpha building

The problem is after r14-2587-gd8105b10fff951, the definition of
extended_count now takes a bool as its last argument but we only
have a declaration for the version which takes an int as the last
argument. This fixes the problem by changing the declaration to be
a bool too.

Committed as obvious after building a cross to alpha-linux-gnu.

gcc/ChangeLog:

PR target/110778
* rtl.h (extended_count): Change last argument type
to bool.