]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
10 months agolibstdc++: Refactor experimental::filesystem::path string conversions
Jonathan Wakely [Fri, 27 Sep 2024 14:53:04 +0000 (15:53 +0100)] 
libstdc++: Refactor experimental::filesystem::path string conversions

I noticed a -Wc++17-extensions warning due to use of if-constexpr in
std::experimental::filesystem::path, which was not protected by
diagnostic pragmas to disable the warning.

While adding the pragmas I noticed that other places in the same file
use tag dispatching and multiple overloads instead of if-constexpr.
Since we're already using it in that file, we might as well just use it
everywhere.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_path.h (path::_Cvt): Refactor to
use if-constexpr.
(path::string(const Allocator&)): Likewise.

10 months agolibstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite
Jonathan Wakely [Fri, 27 Sep 2024 14:51:56 +0000 (15:51 +0100)] 
libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite

libstdc++-v3/ChangeLog:

* include/bits/basic_string.tcc (resize_for_overwrite): Fix
-Wsign-compare warning.
* include/bits/cow_string.h (resize_for_overwrite): Likewise.

10 months agoc++: ICE with structured bindings and m-d array [PR102594]
Marek Polacek [Thu, 5 Sep 2024 20:45:32 +0000 (16:45 -0400)] 
c++: ICE with structured bindings and m-d array [PR102594]

We ICE in decay_conversion with this test:

  struct S {
    S() {}
  };
  S arr[1][1];
  auto [m](arr3);

But not when the last line is:

  auto [n] = arr3;

Therefore the difference is between copy- and direct-init.  In
particular, in build_vec_init we have:

  if (direct_init)
    from = build_tree_list (NULL_TREE, from);

and then we call build_vec_init again with init==from.  Then
decay_conversion gets the TREE_LIST and it crashes.

build_aggr_init has:

              /* Wrap the initializer in a CONSTRUCTOR so that build_vec_init
                 recognizes it as direct-initialization.  */
              init = build_constructor_single (init_list_type_node,
                                               NULL_TREE, init);
              CONSTRUCTOR_IS_DIRECT_INIT (init) = true;

so I propose to do the same in build_vec_init.

PR c++/102594

gcc/cp/ChangeLog:

* init.cc (build_vec_init): Build up a CONSTRUCTOR to signal
direct-initialization rather than a TREE_LIST.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/decomp61.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agolibstdc++: Fix test FAILs due to -Wreturn-local-addr
Jonathan Wakely [Thu, 26 Sep 2024 22:43:20 +0000 (23:43 +0100)] 
libstdc++: Fix test FAILs due to -Wreturn-local-addr

This fixes two FAILs due to -Wpointer-arith warnings when testing with
c++11 or c++14 dialects.

libstdc++-v3/ChangeLog:

* testsuite/20_util/bind/dangling_ref.cc: Add an additional
dg-warning for -Wreturn-local-addr warning.
* testsuite/30_threads/packaged_task/cons/dangling_ref.cc:
Likewise.

10 months agolibstdc++: Fix test FAIL due to -Wpointer-arith
Jonathan Wakely [Thu, 26 Sep 2024 22:38:41 +0000 (23:38 +0100)] 
libstdc++: Fix test FAIL due to -Wpointer-arith

This fixes a FAIL due to a -Wpointer-arith warning when testing with
c++11 or c++14 dialects. As an extension our std::atomic<void*> supports
pointer arithmetic in C++11 and C++14, but due to the system header
changes there is now a warning about it. The warning seems reasonable,
so rather than suppress it we should make the test expect it.

While looking into this I decided to simplify some of the code related
to atomic<T*> arithmetic.

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (__atomic_base<T*>::_M_type_size):
Replace overloaded functions with static _S_type_size.
* include/std/atomic (atomic<T*>): Use is_object_v instead of
is_object.
* testsuite/29_atomics/atomic/operators/pointer_partial_void.cc:
Add dg-warning for -Wpointer-arith warning.

10 months agoaarch64: fix build failure on aarch64-none-elf
Matthieu Longo [Thu, 26 Sep 2024 17:14:23 +0000 (18:14 +0100)] 
aarch64: fix build failure on aarch64-none-elf

A previous patch ([1]) introduced a build regression on aarch64-none-elf
target. The changes were primarilly tested on aarch64-unknown-linux-gnu,
so the issue was missed during development.
The includes are slighly different between the two targets, and due to some
include rules ([2]), "aarch64-unwind-def.h" was not found.

[1]: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=bdf41d627c13bc5f0dc676991f4513daa9d9ae36

[2]: https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
> include "file"
> ...  It searches for a file named file first in the directory
> containing the current file, ...

libgcc/ChangeLog:

* config/aarch64/aarch64-unwind.h: Fix header path.

10 months agodiagnostic: Save/restore diagnostic context history and push/pop state for PCH [PR116847]
Jakub Jelinek [Fri, 27 Sep 2024 14:07:40 +0000 (16:07 +0200)] 
diagnostic: Save/restore diagnostic context history and push/pop state for PCH [PR116847]

The following patch on top of the just posted cleanup patch
saves/restores the m_classification_history and m_push_list
vectors for PCH.  Without that as the testcase shows during parsing
of the templates we don't report ignored diagnostics, but after loading
PCH header when instantiating those templates those warnings can be
emitted.  This doesn't show up on x86_64-linux build because configure
injects there -fcf-protection -mshstk flags during library build (and so
also during PCH header creation), but make check doesn't use those flags
and so the PCH header is ignored.

2024-09-26  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/116847
gcc/
* diagnostic.h (diagnostic_option_classifier): Add pch_save and
pch_restore method declarations.
(diagnostic_context): Add pch_save and pch_restore inline method
definitions.
* diagnostic.cc (diagnostic_option_classifier::pch_save): New method.
(diagnostic_option_classifier::pch_restore): Likewise.
gcc/c-family/
* c-pch.cc: Include diagnostic.h.
(c_common_write_pch): Call global_dc->pch_save.
(c_common_read_pch): Call global_dc->pch_restore.
gcc/testsuite/
* g++.dg/pch/pr116847.C: New test.
* g++.dg/pch/pr116847.Hs: New test.

10 months agodiagnostic: Use vec instead of custom array reallocations for m_classification_histor...
Jakub Jelinek [Fri, 27 Sep 2024 14:06:29 +0000 (16:06 +0200)] 
diagnostic: Use vec instead of custom array reallocations for m_classification_history/m_push_list [PR116847]

diagnostic.h already relies on vec.h, it uses auto_vec in one spot.

The following patch converts m_classification_history and m_push_list
hand-managed arrays to vec templates.
The main advantage is exponential rather than linear reallocation,
e.g. with current libstdc++ headers if one includes all the standard
headers there could be ~ 300 reallocations of the m_classification_history
array (sure, not all of them will result in actually copying the data, but
still).
In addition to that it fixes some formatting issues in the code.

2024-09-26  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/116847
* diagnostic.h (diagnostic_option_classifier): Change type
of m_classification_history from diagnostic_classification_change_t *
to vec<diagnostic_classification_change_t>.  Change type of
m_push_list from int * to vec<int>.  Remove m_n_classification_history
and m_n_push members.
* diagnostic.cc (diagnostic_option_classifier::init): Set m_push_list
to vNULL rather than nullptr.  Don't initialize m_n_push.  Initialize
m_classification_history to vNULL.
(diagnostic_option_classifier::fini): Call release () method on
m_push_list instead of free on it.  Call release () on
m_classification_history.  Don't clear m_n_push.
(diagnostic_option_classifier::push): Adjust for m_push_list and
m_classification_history being vectors rather than custom allocated
arrays with counter.
(diagnostic_option_classifier::pop): Likewise.
(classify_diagnostic): Adjust for m_classification_history being
vector rather than custom allocated array with counter.
(update_effective_level_from_pragmas): Likewise.

10 months agoi386: Modernize AMD processor types
Uros Bizjak [Fri, 27 Sep 2024 13:58:17 +0000 (15:58 +0200)] 
i386: Modernize AMD processor types

Use iterative PTA definitions for members of the same AMD processor family.

Also, fix a couple of related M_CPU_TYPE/M_CPU_SUBTYPE inconsistencies.

No functional changes intended.

gcc/ChangeLog:

* config/i386/i386.h: Add PTA_BDVER1, PTA_BDVER2, PTA_BDVER3,
PTA_BDVER4, PTA_BTVER1 and PTA_BTVER2.
* common/config/i386/i386-common.cc (processor_alias_table)
<"bdver1">: Use PTA_BDVER1.
<"bdver2">: Use PTA_BDVER2.
<"bdver3">: Use PTA_BDVER3.
<"bdver4">: Use PTA_BDVER4.
<"btver1">: Use PTA_BTVER1.  Use M_CPU_TYPE (AMD_BTVER1).
<"btver2">: Use PTA_BTVER2.
<"shanghai>: Use M_CPU_SUBTYPE (AMDFAM10H_SHANGHAI).
<"istanbul>: Use M_CPU_SUBTYPE (AMDFAM10H_ISTANBUL).

10 months agoWidening-Mul: Fix one ICE when iterate on phi node
Pan Li [Fri, 27 Sep 2024 03:03:51 +0000 (11:03 +0800)] 
Widening-Mul: Fix one ICE when iterate on phi node

We iterate all phi node of bb to try to match the SAT_* pattern
for scalar integer.  We also remove the phi mode when the relevant
pattern matched.

Unfortunately the iterator may have no idea the phi node is removed
and continue leverage the free data and then ICE similar as below.

[0] psi ptr 0x75216340c000
[0] psi ptr 0x75216340c400
[1] psi ptr 0xa5a5a5a5a5a5a5a5 <=== GC freed pointer.

during GIMPLE pass: widening_mul
tmp.c: In function ‘f’:
tmp.c:45:6: internal compiler error: Segmentation fault
   45 | void f(int rows, int cols) {
      |      ^
0x36e2788 internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:517
0x18005f0 crash_signal
        ../../gcc/toplev.cc:321
0x752163c4531f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x103ae0e bool is_a_helper<gphi*>::test<gimple>(gimple*)
../../gcc/gimple.h:1256
0x103f9a5 bool is_a<gphi*, gimple>(gimple*)
        ../../gcc/is-a.h:232
0x103dc78 gphi* as_a<gphi*, gimple>(gimple*)
../../gcc/is-a.h:255
0x104f12e gphi_iterator::phi() const
        ../../gcc/gimple-iterator.h:47
0x1a57bef after_dom_children
        ../../gcc/tree-ssa-math-opts.cc:6140
0x3344482 dom_walker::walk(basic_block_def*)
        ../../gcc/domwalk.cc:354
0x1a58601 execute
        ../../gcc/tree-ssa-math-opts.cc:6312

This patch would like to fix the iterate on modified collection problem
by backup the next phi in advance.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

PR middle-end/116861

gcc/ChangeLog:

* tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Backup
the next psi iterator before remove the phi node.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116861-1.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoFix sorting in Contributors.html
Richard Biener [Fri, 27 Sep 2024 12:54:07 +0000 (14:54 +0200)] 
Fix sorting in Contributors.html

The following moves my entry to where it belongs alphabetically
(it wasn't moved when s/Guenther/Biener/).

* doc/contrib.texi (Richard Biener): Move entry.

10 months agolibgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14 [PR116809]
Mark Mentovai [Tue, 24 Sep 2024 20:11:14 +0000 (16:11 -0400)] 
libgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14 [PR116809]

d9cafa0c4f0a stopped building libgcc_s.1 on macOS >= 15, in part because
that is required to bootstrap the compiler using the macOS 15 SDK. The
macOS 15 SDK ships in Xcode 16, which also runs on macOS 14. libgcc_s.1
can no longer be built on macOS 14 using Xcode 16 by the same logic that
the previous change disabled it for macOS 15.

PR target/116809

libgcc/ChangeLog:

* config.host: Don't build legacy libgcc_s.1 on macOS 14.

Signed-off-by: Mark Mentovai <mark@mentovai.com>
10 months agoc++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793]
Arsen Arsenović [Tue, 24 Sep 2024 16:16:01 +0000 (18:16 +0200)] 
c++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793]

If we reach a CLEANUP_POINT_EXPR while trying to walk statements, we
actually care about the statement or statement list contained within it.

Indeed, such a construction started happening with
r15-3513-g964577c31df206, after temporary promotion.  In the test case
presented in PR116793, the compiler generated:

  <<cleanup_point {
    struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3];
    int T002 [value-expr: frame_ptr->T002_2_3];

      int T002 [value-expr: frame_ptr->T002_2_3];
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (T002 = TARGET_EXPR <D.20994, 3>) >>>>>;
      struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3];
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (Aw0 = TARGET_EXPR <D.20995, func ((int &) &T002)>) >>>>>;
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (D.22450 = <<< Unknown tree: co_await
        TARGET_EXPR <D.20995, func ((int &) &T002)>
        Aw0

        {_cleanup_task::await_ready (&Aw0), _cleanup_task::await_suspend<_task1::promise_type> (&Aw0, TARGET_EXPR <D.21078, _Coro_self_handle>), <<< Unknown tree: aggr_init_expr
          4
          await_resume
          D.22443
          &Aw0 >>>}
        0 >>>) >>>>>;
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (D.20991 = (struct tuple &) &D.22450) >>>>>;
  }
  D.22467 = 1;
  int & i [value-expr: frame_ptr->i_1_2];
  <<cleanup_point <<< Unknown tree: expr_stmt
    (void) (i = std::get<0, int&> (NON_LVALUE_EXPR <D.20991>)) >>>>>;>>;

... i.e. a statement list within a cleanup point.  In such a case, we
don't actually care about the cleanup point, but we do care about the
statement inside, so, we can just walk down into the CLEANUP_POINT_EXPR.

PR c++/116793

gcc/cp/ChangeLog:

* coroutines.cc (await_statement_expander): Just process
subtrees if encountering a CLEANUP_POINT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr116793-1.C: New test.

10 months agoc++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void
Arsen Arsenović [Fri, 20 Sep 2024 11:13:02 +0000 (13:13 +0200)] 
c++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void

convert_to_void has, so far, when converting a co_await expression to
void altered the await_resume expression of a co_await so that it is
also converted to void.  This meant that the type of the await_resume
expression, which is also supposed to be the type of the whole co_await
expression, was not the same as the type of the CO_AWAIT_EXPR tree.

While this has not caused problems so far, it is unexpected, I think.

Also, convert_to_void had a special case when an INDIRECT_REF wrapped a
CALL_EXPR.  In this case, we also diagnosed maybe_warn_nodiscard.  This
was a duplication of logic related to converting call expressions to
void.

Instead, we can generalize a bit, and rather discard the expression that
was implicitly dereferenced instead.

This patch changes the diagnostic of:

  void f(struct S* x) { static_cast<volatile S&>(*x); }

... from:

  warning: indirection will not access object of incomplete type
           'volatile S' in statement

... to:

  warning: implicit dereference will not access object of type
           ‘volatile S’ in statement

... but should have no impact in other cases.

gcc/cp/ChangeLog:

* coroutines.cc (co_await_get_resume_call): Return a tree
directly, rather than a tree pointer.
* cp-tree.h (co_await_get_resume_call): Adjust signature
accordingly.
* cvt.cc (convert_to_void): Do not alter CO_AWAIT_EXPRs when
discarding them.  Simplify handling implicit INDIRECT_REFs.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/nodiscard-1.C: New test.

10 months agoc++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502]
Arsen Arsenović [Wed, 28 Aug 2024 19:59:18 +0000 (21:59 +0200)] 
c++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502]

If such a diagnostic is necessary, it has already been emitted,
otherwise, it is not correct and emitting it here is inactionable by the
user, and bogus.

PR c++/116502

gcc/cp/ChangeLog:

* coroutines.cc (maybe_promote_temps): Convert temporary
initializers to void without complaining.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/maybe-unused-1.C: New test.
* g++.dg/coroutines/pr116502.C: New test.

10 months ago[MAINTAINERS]: Add myself as MVE Reviewer for the AArch32 (arm) port
Christophe Lyon [Fri, 27 Sep 2024 08:37:01 +0000 (10:37 +0200)] 
[MAINTAINERS]: Add myself as MVE Reviewer for the AArch32 (arm) port

ChangeLog:
* MAINTAINERS: Add myself as MVE Reviewer for the AArch32 (arm)
port.

10 months agolibgomp.texi: Remove now duplicate TR13 item
Tobias Burnus [Fri, 27 Sep 2024 10:06:17 +0000 (12:06 +0200)] 
libgomp.texi: Remove now duplicate TR13 item

Remove an item under "Other new TR 13 features" that since the last commit
(r15-3917-g6b7eaec20b046e) to this file is is covered by the added
  "New @code{storage} map-type modifier; context-dependent @code{alloc} and
   @code{release} are aliases"
  "Update of the map-type decay for mapping and @code{declare_mapper}"

libgomp/
* libgomp.texi (TR13 status): Update semi-duplicated, semi-obsoleted
item; remove left-over half-sentence.

10 months agoRISC-V/libgcc: Save/Restore routines for E goes with ABI.
Jim Lin [Fri, 27 Sep 2024 06:44:12 +0000 (14:44 +0800)] 
RISC-V/libgcc: Save/Restore routines for E goes with ABI.

That Save/Restore routines for E can be used for RVI with ILP32E ABI.

libgcc/ChangeLog:

* config/riscv/save-restore.S: Check with __riscv_abi_rve rather than
__riscv_32e.

10 months agolibgomp.texi: fix formatting; add post-TR13 OpenMP impl. status items
Tobias Burnus [Fri, 27 Sep 2024 08:48:09 +0000 (10:48 +0200)] 
libgomp.texi: fix formatting; add post-TR13 OpenMP impl. status items

libgomp/
* libgomp.texi (OpenMP Technical Report 13): Change @emph to @code;
add two post-TR13 OpenMP 6.0 items.

10 months agotree-optimization/116818 - try VMAT_GATHER_SCATTER also for SLP
Richard Biener [Mon, 23 Sep 2024 13:24:01 +0000 (15:24 +0200)] 
tree-optimization/116818 - try VMAT_GATHER_SCATTER also for SLP

When not doing SLP and we end up with VMAT_ELEMENTWISE we consider
using strided loads, aka VMAT_GATHER_SCATTER.  The following moves
this logic down to also apply to SLP where we now can end up
using VMAT_ELEMENTWISE as well.

PR tree-optimization/116818
* tree-vect-stmts.cc (get_group_load_store_type): Consider
VMAT_GATHER_SCATTER instead of VMAT_ELEMENTWISE also for SLP.
(vectorizable_load): For single-lane VMAT_GATHER_SCATTER also
ignore permutations.

10 months agoFix bogus SLP nvector compute in check_load_store_for_partial_vectors
Richard Biener [Tue, 24 Sep 2024 08:42:01 +0000 (10:42 +0200)] 
Fix bogus SLP nvector compute in check_load_store_for_partial_vectors

We have a new overload for vect_get_num_copies that handles both
SLP and non-SLP.  Use it and avoid the division by group_size
for SLP when not using load-store lanes.

* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Use the new vect_get_num_copies overload.  Only divide by
group_size for SLP for load-store lanes.

10 months agounswitch: Replace manual ondemand maybe_undef with ssa_name_maybe_undef_p/mark_ssa_ma...
Andrew Pinski [Thu, 26 Sep 2024 05:55:58 +0000 (05:55 +0000)] 
unswitch: Replace manual ondemand maybe_undef with ssa_name_maybe_undef_p/mark_ssa_maybe_undefs [PR116848]

The ondemand maybe_undef that follows phis was added in r7-6427-g8b670f93ab1136
but then later ssa_name_maybe_undef_p/mark_ssa_maybe_undefs was added in
r13-972-gbe2861fe8c527a. This moves the ondemand one to use
mark_ssa_maybe_undefs/ssa_name_maybe_undef_p instead. Which itself will be
faster since the mark_ssa_maybe_undefs is a walk based on the uses of
undefined names (and only once) rather than a walk based on the def of
ones which are more likely defined (and on demand).

Even though the ondemand maybe_undef had some extra special cases, those won't make
a big difference in most code.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116848

gcc/ChangeLog:

* tree-ssa-loop-unswitch.cc (tree_ssa_unswitch_loops): Call mark_ssa_maybe_undefs.
(is_maybe_undefined): Call ssa_name_maybe_undef_p instead of ondemand undef.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
10 months agoc++/modules: Allow imported references in constant expressions
Nathaniel Shead [Thu, 12 Sep 2024 10:06:39 +0000 (20:06 +1000)] 
c++/modules: Allow imported references in constant expressions

Currently the streaming code uses TREE_CONSTANT to determine whether an
entity will have a definition that is interesting to stream out.  This
is not sufficient, however; we also need to write the definition of
references, since although not TREE_CONSTANT they can still be usable in
constant expressions.

As such this patch uses the existing decl_maybe_constant_var function
which correctly handles this case.

gcc/cp/ChangeLog:

* module.cc (has_definition): Use decl_maybe_constant_var
instead of TREE_CONSTANT.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoc++/modules: Fix linkage checks for exported using-decls
Nathaniel Shead [Tue, 3 Sep 2024 15:18:19 +0000 (01:18 +1000)] 
c++/modules: Fix linkage checks for exported using-decls

This fixes some inconsistencies with what kinds of linkage various
entities are assumed to have.  This also fixes handling of exported
using-decls binding to GM entities and type aliases to better align with
the standard's requirements.

gcc/cp/ChangeLog:

* name-lookup.cc (check_can_export_using_decl): Handle internal
linkage GM entities (but ignore in header units); use linkage
of entity ultimately referred to by aliases.

gcc/testsuite/ChangeLog:

* g++.dg/modules/using-10.C: Add tests for no-linkage, fix
expected linkage of aliases.
* g++.dg/modules/using-12.C: Likewise.
* g++.dg/modules/using-27.C: New test.
* g++.dg/modules/using-28_a.C: New test.
* g++.dg/modules/using-28_b.C: New test.
* g++.dg/modules/using-29.H: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoc++/modules: Use decl_linkage in maybe_record_mergeable_decl
Nathaniel Shead [Tue, 3 Sep 2024 16:42:58 +0000 (02:42 +1000)] 
c++/modules: Use decl_linkage in maybe_record_mergeable_decl

This avoids any possible inconsistencies (current or future) about
whether a declaration is internal or not.

gcc/cp/ChangeLog:

* name-lookup.cc (maybe_record_mergeable_decl): Use decl_linkage
instead of ad-hoc checks.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoc++: Update decl_linkage for C++11
Nathaniel Shead [Mon, 19 Aug 2024 06:38:41 +0000 (16:38 +1000)] 
c++: Update decl_linkage for C++11

Currently modules code uses a variety of ad-hoc methods to attempt to
determine whether an entity has internal linkage, which leads to
inconsistencies and some correctness issues as different edge cases are
neglected.  While investigating this I discovered 'decl_linkage', but it
doesn't seem to have been updated to account for the C++11 clarification
that all entities declared in an anonymous namespace are internal.

I'm not convinced that even in C++98 it was intended that e.g. types in
anonymous namespaces should be external, but some tests in the testsuite
rely on this, so for compatibility I restricted those modifications to
C++11 and later.

This should have relatively minimal impact as not much seems to actually
rely on decl_linkage, but does change the mangling of symbols in
anonymous namespaces slightly.  Previously, we had

  namespace {
    int x;  // mangled as '_ZN12_GLOBAL__N_11xE'
    static int y;  // mangled as '_ZN12_GLOBAL__N_1L1yE'
  }

but with this patch the x is now mangled like y (with the extra 'L').
For contrast, Clang currently mangles neither x nor y with the 'L'.
Since this only affects internal-linkage entities I don't believe this
should break ABI in any observable fashion.

gcc/cp/ChangeLog:

* name-lookup.cc (do_namespace_alias): Propagate TREE_PUBLIC for
namespace aliases.
* tree.cc (decl_linkage): Update rules for C++11.

gcc/testsuite/ChangeLog:

* g++.dg/modules/mod-sym-4.C: Update test to account for
non-static internal-linkage variables new mangling.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agotestsuite/gfortran.dg/open_errors_2.f90: Remove now-redundant file deletion
Hans-Peter Nilsson [Thu, 26 Sep 2024 21:07:01 +0000 (23:07 +0200)] 
testsuite/gfortran.dg/open_errors_2.f90: Remove now-redundant file deletion

Now that fort.N files are removed by the testsuite
framework, remove this single "manual" file deletion.
(Also, it should have been "remote_file target delete",
since it's the target that creates the file, not the build
framework, which might matter to some setups.)

* gfortran.dg/open_errors_2.f90: Remove now-redundant file deletion.

10 months agoDaily bump.
GCC Administrator [Fri, 27 Sep 2024 00:18:47 +0000 (00:18 +0000)] 
Daily bump.

10 months agolibstdc++: Add missing 'inline' to always_inline function
Jonathan Wakely [Thu, 26 Sep 2024 22:36:46 +0000 (23:36 +0100)] 
libstdc++: Add missing 'inline' to always_inline function

This fixes a -Wattributes warning for the COW std::string which was
previously suppressed due to being in a system header.

libstdc++-v3/ChangeLog:

* include/bits/cow_string.h (__resize_for_overwrite): Add
inline keyword to function with always_inline attribute.

10 months agolibgcc, libstdc++: Make declarations no longer TU-local [PR115126]
Nathaniel Shead [Tue, 24 Sep 2024 13:53:59 +0000 (23:53 +1000)] 
libgcc, libstdc++: Make declarations no longer TU-local [PR115126]

In C++20, modules streaming check for exposures of TU-local entities.
In general exposing internal linkage functions in a header is liable to
cause ODR violations in C++, and this is now detected in a module
context.

This patch goes through and removes 'static' from many declarations
exposed through libstdc++ to prevent code like the following from
failing:

  export module M;
  extern "C++" {
    #include <bits/stdc++.h>
  }

Since gthreads is used from C as well, we need to choose whether to use
'inline' or 'static inline' depending on whether we're compiling for C
or C++ (since the semantics of 'inline' are different between the
languages).  Additionally we need to remove static global variables, so
we migrate these to function-local statics to avoid the ODR issues.

There doesn't seem to be a good workaround for weakrefs, so I've left
them as-is and will work around it in the modules streaming code to
consider them as not TU-local.

The same issue occurs in the objective-C specific parts of gthreads, but
I'm not familiar with the surrounding context and we don't currently
test modules with Objective C++ anyway so I've left it as-is.

PR libstdc++/115126

libgcc/ChangeLog:

* gthr-posix.h (__GTHREAD_ALWAYS_INLINE): New macro.
(__GTHREAD_INLINE): New macro.
(__gthread_active): Convert from variable to (hidden) function.
(__gthread_active_p): Mark as __GTHREAD_INLINE instead of
static; make visibility("hidden") when it has a static local
variable.
(__gthread_trigger): Mark as __GTHREAD_INLINE instead of static.
(__gthread_create): Likewise.
(__gthread_join): Likewise.
(__gthread_detach): Likewise.
(__gthread_equal): Likewise.
(__gthread_self): Likewise.
(__gthread_yield): Likewise.
(__gthread_once): Likewise.
(__gthread_key_create): Likewise.
(__gthread_key_delete): Likewise.
(__gthread_getspecific): Likewise.
(__gthread_setspecific): Likewise.
(__gthread_mutex_init_function): Likewise.
(__gthread_mutex_destroy): Likewise.
(__gthread_mutex_lock): Likewise.
(__gthread_mutex_trylock): Likewise.
(__gthread_mutex_timedlock): Likewise.
(__gthread_mutex_unlock): Likewise.
(__gthread_recursive_mutex_init_function): Likewise.
(__gthread_recursive_mutex_lock): Likewise.
(__gthread_recursive_mutex_trylock): Likewise.
(__gthread_recursive_mutex_timedlock): Likewise.
(__gthread_recursive_mutex_unlock): Likewise.
(__gthread_recursive_mutex_destroy): Likewise.
(__gthread_cond_init_function): Likewise.
(__gthread_cond_broadcast): Likewise.
(__gthread_cond_signal): Likewise.
(__gthread_cond_wait): Likewise.
(__gthread_cond_timedwait): Likewise.
(__gthread_cond_wait_recursive): Likewise.
(__gthread_cond_destroy): Likewise.
(__gthread_rwlock_rdlock): Likewise.
(__gthread_rwlock_tryrdlock): Likewise.
(__gthread_rwlock_wrlock): Likewise.
(__gthread_rwlock_trywrlock): Likewise.
(__gthread_rwlock_unlock): Likewise.
* gthr-single.h: (__GTHREAD_ALWAYS_INLINE): New macro.
(__GTHREAD_INLINE): New macro.
(__gthread_active_p): Mark as __GTHREAD_INLINE instead of static.
(__gthread_once): Likewise.
(__gthread_key_create): Likewise.
(__gthread_key_delete): Likewise.
(__gthread_getspecific): Likewise.
(__gthread_setspecific): Likewise.
(__gthread_mutex_destroy): Likewise.
(__gthread_mutex_lock): Likewise.
(__gthread_mutex_trylock): Likewise.
(__gthread_mutex_unlock): Likewise.
(__gthread_recursive_mutex_lock): Likewise.
(__gthread_recursive_mutex_trylock): Likewise.
(__gthread_recursive_mutex_unlock): Likewise.
(__gthread_recursive_mutex_destroy): Likewise.

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr.h (std::__is_shared_ptr): Remove
unnecessary 'static'.
* include/bits/unique_ptr.h (std::__is_unique_ptr): Likewise.
* include/std/future (std::__create_task_state): Likewise.
* include/std/shared_mutex (_GLIBCXX_GTRHW): Likewise.
(__glibcxx_rwlock_init): Likewise.
(__glibcxx_rwlock_timedrdlock): Likewise.
(__glibcxx_rwlock_timedwrlock): Likewise.
(__glibcxx_rwlock_rdlock): Likewise.
(__glibcxx_rwlock_tryrdlock): Likewise.
(__glibcxx_rwlock_wrlock): Likewise.
(__glibcxx_rwlock_trywrlock): Likewise.
(__glibcxx_rwlock_unlock): Likewise.
(__glibcxx_rwlock_destroy): Likewise.
(__glibcxx_rwlock_init): Likewise.
* include/pstl/algorithm_impl.h
(__pstl::__internal::__set_algo_cut_off): Mark inline.
* include/pstl/unseq_backend_simd.h
(__pstl::__unseq_backend::__lane_size): Mark inline.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Jakub Jelinek <jakub@redhat.com>
10 months agoc++: tweak for -Wrange-loop-construct [PR116731]
Marek Polacek [Tue, 17 Sep 2024 20:58:37 +0000 (16:58 -0400)] 
c++: tweak for -Wrange-loop-construct [PR116731]

This PR reports that the warning would be better off using a check
for trivially constructible rather than trivially copyable.

LLVM accepted a similar fix:
https://github.com/llvm/llvm-project/issues/47355

PR c++/116731

gcc/cp/ChangeLog:

* parser.cc (warn_for_range_copy): Check if TYPE is trivially
constructible, not copyable.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wrange-loop-construct3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agolibstdc++: Fix freebsd/dragonfly build [PR116859]
Jakub Jelinek [Thu, 26 Sep 2024 21:45:22 +0000 (23:45 +0200)] 
libstdc++: Fix freebsd/dragonfly build [PR116859]

As reported in the PR, the system headers libstdc++ changes result in
-Werror=expansion-to-defined errors on FreeBSD and supposedly on DragonFly
too.

The following patch fixes those by performing the preprocessor test right
away, rather than using defined in the macro definitions.

I think neither __ISO_C_VISIBLE nor __LONG_LONG_SUPPORTED should normally
change during compilation.

2024-09-26  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/116859
* config/os/bsd/freebsd/os_defines.h
(_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC,
_GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC): Avoid
-Wexpansion-to-defined warnings.
* config/os/bsd/dragonfly/os_defines.h
(_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC): Likewise.

10 months agolibstdc++: Preserve signbit of nan when converting float to double [PR113578]
Jonathan Wakely [Tue, 30 Jan 2024 14:47:34 +0000 (14:47 +0000)] 
libstdc++: Preserve signbit of nan when converting float to double [PR113578]

LWG 117 specifies that inserting a float into an ostream should cast it
to double, because there's no std::num_put::put member that takes a
float. However, on RISC-V converting a NaN float to double loses the
sign, which means that negative NaN floats are printed as positive.

This has been reported as LWG 4101 and there is good support for fixing
the standard to preserve the sign bit when printing negative NaN values.

This change uses copysign((double)f, (double)std::bit_cast<int>(f)) to
get a double that preserves the sign. The bit_cast gives us an integer
with the same signbit, and casting that to the target type preserves
the signbit. We don't care about the value, as copysign only uses the
signbit.

The inserters for extended floating-point types need the same treatment,
so add a new _S_cast_flt helper to do the signbit-preserving conversion
generically.

So far only RISC-V has been confirmed to need this treatment, but we
might need to extend it to other targets later.

libstdc++-v3/ChangeLog:

PR libstdc++/113578
* include/std/ostream (_S_cast_flt): New static member function
to restore signbit after casting to double or long double.
(operator<<(float), operator<<(_Float16), operator<<(_Float32))
(operator<<(_Float64), operator(_Float128))
(operator<<(__bfloat16_t)): Use _S_cast_flt.
testsuite/27_io/basic_ostream/inserters_arithmetic/lwg4101.cc:
New test.

Co-authored-by: Andrew Waterman <andrew@sifive.com>
10 months agolibstdc++: Fix comments in <sstream> tests that mention basic_filebuf
Jonathan Wakely [Fri, 20 Sep 2024 23:08:23 +0000 (00:08 +0100)] 
libstdc++: Fix comments in <sstream> tests that mention basic_filebuf

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_istringstream/cons/2020.cc: Fix comment
referring to basic_filebuf.
* testsuite/27_io/basic_istringstream/requirements/base_classes.cc:
Likewise.
* testsuite/27_io/basic_ostringstream/cons/2020.cc: Likewise.
* testsuite/27_io/basic_ostringstream/requirements/base_classes.cc:
Likewise.
* testsuite/27_io/basic_stringbuf/cons/2020.cc: Likewise.
* testsuite/27_io/basic_stringbuf/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/27_io/basic_stringbuf/requirements/explicit_instantiation/4.cc:
Likewise.
* testsuite/27_io/basic_stringstream/cons/2020.cc: Likewise.
* testsuite/27_io/basic_stringstream/requirements/base_classes.cc:
Likewise.

10 months agolibstdc++: Add [[nodiscard]] to iostream members
Jonathan Wakely [Thu, 26 Sep 2024 11:14:54 +0000 (12:14 +0100)] 
libstdc++: Add [[nodiscard]] to iostream members

These are all pure functions and MSVC also marks all of these as
nodiscard except for std::basic_ios::tie() const, but that's been
confirmed as an accidental omission.

libstdc++-v3/ChangeLog:

* include/bits/basic_ios.h (basic_ios::operator bool()):
Add [[nodiscard]] attribute.
(basic_ios::operator!(), basic_ios::rdstate())
(basic_ios::good(), basic_ios::eof(), basic_ios::fail())
(basic_ios::bad(), basic_ios::exceptions(), basic_ios::tie())
(basic_ios::rdbuf(), basic_ios::fill()): Likewise.
* include/bits/ios_base.h (ios_base::flags()): Likewise.
(ios_base::precision(), ios_base::width(), ios_base::getloc()):
Likewise.
* include/std/fstream (basic_filebuf::is_open)
(basic_ifstream::rdbuf(), basic_ifstream::is_open)
(basic_ofstream::rdbuf(), basic_ofstream::is_open)
(basic_fstream::rdbuf(), basic_fstream::is_open): Likewise.
* include/std/spanstream (basic_spanbuf::span())
(basic_ispanstream::span(), basic_ispanstream::rdbuf())
(basic_ospanstream::span(), basic_ospanstream::rdbuf())
(basic_spanstream::span(), basic_spanstream::rdbuf()):
Likewise.
* include/std/sstream (basic_stringbuf::str())
(basic_istringstream::rdbuf(), basic_istringstream::str())
(basic_ostringstream::rdbuf(), basic_ostringstream::str())
(basic_stringstream::rdbuf(), basic_stringstream::str()):
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc:
Suppress -Wunused-result warnings.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/01.cc:
Likewise.

10 months agolibgomp.texi: Fix deprecation note for omp_{get,set}_nested + OMP_NESTED
Tobias Burnus [Thu, 26 Sep 2024 15:25:34 +0000 (17:25 +0200)] 
libgomp.texi: Fix deprecation note for omp_{get,set}_nested + OMP_NESTED

libgomp/ChangeLog:

* libgomp.texi (omp_get_nested,omp_set_nested, OMP_NESTED): Fix
note about deprecation - correct is 5.0 not 5.2.

10 months agotestsuite: XFAIL gfortran.dg/initialization_25.f90 properly
Sam James [Thu, 26 Sep 2024 14:43:33 +0000 (15:43 +0100)] 
testsuite: XFAIL gfortran.dg/initialization_25.f90 properly

The test was disabled/XFAIL'd informally in r0-100012-gcdc6637d7c78ec,
but r15-3890-g34bf6aa41ba539 didn't realize this, causing a FAIL.

Fix that by marking it as XFAIL per the original intent.

gcc/testsuite/ChangeLog:
PR fortran/35779
PR fortran/116858

* gfortran.dg/initialization_25.f90: Mark as XFAIL.

10 months agodoc: Remove index reference to removed documentation in fortran manual
Mikael Morin [Thu, 26 Sep 2024 12:23:06 +0000 (14:23 +0200)] 
doc: Remove index reference to removed documentation in fortran manual

Fortran option -M used to be an alias for -J.  After some deprecation time,
it was reused for another purpose at revision
r0-100725-gd8ddea4044ee8212d5fe305e8e2a547700cd7b8f.
That revision removed the documentation parts of -J mentioning -M, but left
a reference to -M in the index.

This change removes the remaining reference.

gcc/fortran/ChangeLog:

* invoke.texi (-M): Remove index reference to removed documentation.

10 months agoAdd virtual destructor to AbstractExpr
Owen Avery [Tue, 3 Sep 2024 20:11:58 +0000 (16:11 -0400)] 
Add virtual destructor to AbstractExpr

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir.h
(class AbstractExpr): Add virtual destructor.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
10 months agotree-optimization/114855 - speed up dom_oracle::register_transitives
Richard Biener [Wed, 25 Sep 2024 08:38:12 +0000 (10:38 +0200)] 
tree-optimization/114855 - speed up dom_oracle::register_transitives

dom_oracle::register_transitives contains an unbound dominator walk
which for the testcase in PR114855 dominates the profile.  The following
fixes the unbound work done by assigning a constant work budget to the
loop, bounding the number of dominators visited but also the number of
relations processed.  This gets both dom_oracle::register_transitives and
get_immediate_dominator off the profile.

I'll note that we're still doing an unbound dominator walk via
equiv_set in find_equiv_dom at the start of the function and when
we register a relation that also looks up the same way.  At least
for the testcase at hand this isn't an issue.

I've also amended the guard to register_transitives with the
per-basic-block limit for the number of relations registered not
being exhausted.

PR tree-optimization/114855
* params.opt (--param transitive-relations-work-bound): New.
* doc/invoke.texi (--param transitive-relations-work-bound):
Document.
* value-relation.cc (dom_oracle::register_transitives):
Assing an overall work budget, bounding the dominator walk and
the number of relations processed.
(dom_oracle::record): Only register_transitives when the
number of already registered relations does not yet exceed
the per-BB limit.

10 months agoFortran/OpenMP: Middle-end support for mapping of DT with allocatable components
Tobias Burnus [Thu, 26 Sep 2024 12:01:20 +0000 (14:01 +0200)] 
Fortran/OpenMP: Middle-end support for mapping of DT with allocatable components

gcc/ChangeLog:

* langhooks-def.h (lhd_omp_deep_mapping_p,
lhd_omp_deep_mapping_cnt, lhd_omp_deep_mapping): New.
(LANG_HOOKS_OMP_DEEP_MAPPING_P, LANG_HOOKS_OMP_DEEP_MAPPING_CNT,
LANG_HOOKS_OMP_DEEP_MAPPING): Define.
(LANG_HOOKS_DECLS): Use it.
* langhooks.cc (lhd_omp_deep_mapping_p, lhd_omp_deep_mapping_cnt,
lhd_omp_deep_mapping): New stubs.
* langhooks.h (struct lang_hooks_for_decls): Add new hooks
* omp-expand.cc (expand_omp_target): Handle dynamic-size
addr/sizes/kinds arrays.
* omp-low.cc (build_sender_ref, fixup_child_record_type,
scan_sharing_clauses, lower_omp_target): Update to handle
new hooks and dynamic-size addr/sizes/kinds arrays.

10 months agolibstdc++: Suppress an attribute suggestion warning [PR116853].
Iain Sandoe [Thu, 26 Sep 2024 10:07:41 +0000 (11:07 +0100)] 
libstdc++: Suppress an attribute suggestion warning [PR116853].

This warning is triggering during the build and breaking bootstrap on
at least two targets.  The warning appears valid, but the final fix for
it is not yet clear.

In the meantime, to restore bootstrap, the following patch ignores the
warning in the relevant code section.

PR libstdc++/116853

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: Ignore suggest-attribute=format
warning when using posix vsnprintf in to_string() implementations.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
10 months agolibstdc++: Fix std::basic_stracktrace to not assume allocators throw std::bad_alloc
Jonathan Wakely [Tue, 24 Sep 2024 11:44:09 +0000 (12:44 +0100)] 
libstdc++: Fix std::basic_stracktrace to not assume allocators throw std::bad_alloc

The standard allows allocators to throw any kind of exception, not only
something that can be caught as std::bad_alloc. std::basic_stracktrace
was assuming std::bad_alloc.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
Do not assume allocators only throw std::bad_alloc.

10 months agolibstdc++: Remove noexcept-specifier from MCF __cxa_guard_acquire [PR116857]
Jonathan Wakely [Thu, 26 Sep 2024 11:12:13 +0000 (12:12 +0100)] 
libstdc++: Remove noexcept-specifier from MCF __cxa_guard_acquire [PR116857]

This function definition should not be marked as non-throwing, because
the declaration in <cxxabi.h> is potentially throwing.

Also fix whitespace.

libstdc++-v3/ChangeLog:

PR libstdc++/116857
* libsupc++/guard.cc (__cxa_guard_acquire): Remove
_GLIBCXX_NOTHROW to match declaration in <cxxabi.h>.

10 months agopretty-print: Fix up allocate_object
Jakub Jelinek [Thu, 26 Sep 2024 09:55:13 +0000 (11:55 +0200)] 
pretty-print: Fix up allocate_object

On Thu, Aug 29, 2024 at 06:58:12PM -0400, David Malcolm wrote:
> The following patch rewrites the internals of pp_format.

> The tokens and token lists are allocated on the chunk_obstack, and so
> there's no additional heap activity required, with the memory reclaimed
> when the chunk_obstack is freed after phase 3 of formatting.

> +static void *
> +allocate_object (size_t sz, obstack &s)
> +{
> +  /* We must not be half-way through an object.  */
> +  gcc_assert (obstack_base (&s) == obstack_next_free (&s));
> +
> +  obstack_grow (&s, obstack_base (&s), sz);
> +  void *buf = obstack_finish (&s);
> +  return buf;
>  }

I think this is wrong.  I hoped it would be the reason of the
unexpected libstdc++ warnings on certain architectures after
seeing
==4027220== Source and destination overlap in memcpy(0x4627154, 0x4627154, 12)
==4027220==    at 0x404B93E: memcpy (vg_replace_strmem.c:1123)
==4027220==    by 0xAAD5618: allocate_object(unsigned int, obstack&) (pretty-print.cc:1183)
==4027220==    by 0xAAD8C0E: operator new (pretty-print.cc:1210)
==4027220==    by 0xAAD8C0E: make (pretty-print-format-impl.h:305)
==4027220==    by 0xAAD8C0E: format_phase_1 (pretty-print.cc:1659)
==4027220==    by 0xAAD8C0E: pretty_printer::format(text_info&) (pretty-print.cc:1618)
==4027220==    by 0xAAA840E: pp_format (pretty-print.h:583)
==4027220==    by 0xAAA840E: diagnostic_context::report_diagnostic(diagnostic_info*) (diagnostic.cc:1260)
==4027220==    by 0xAAA8703: diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, char**, diagnostic_t) (diagnostic.cc:1404)
==4027220==    by 0xAAB8682: warning(diagnostic_option_id, char const*, ...) (diagnostic-global-context.cc:166)
==4027220==    by 0x97725F5: warn_deprecated_use(tree_node*, tree_node*) (tree.cc:12485)
==4027220==    by 0x8B6694B: mark_used(tree_node*, int) (decl2.cc:6121)
==4027220==    by 0x8C9E25E: tsubst_expr(tree_node*, tree_node*, int, tree_node*) [clone .part.0] (pt.cc:21626)
==4027220==    by 0x8C9E5E6: tsubst_expr(tree_node*, tree_node*, int, tree_node*) [clone .part.0] (pt.cc:20935)
==4027220==    by 0x8C9E1D7: tsubst_expr(tree_node*, tree_node*, int, tree_node*) [clone .part.0] (pt.cc:20424)
==4027220==    by 0x8C9DF2E: tsubst_expr(tree_node*, tree_node*, int, tree_node*) [clone .part.0] (pt.cc:20496)
==4027220==
etc. valgrind warnings, unfortunately it is not, but still
I think this is a bug.
If the obstack has enough space in it, i.e. if obstack_room (&s) >= sz,
then obstack_grow from obstack_base will copy uninitialized bytes
through memcpy (obstack_base (&s), obstack_base (&s), sz);
(which pedantically isn't valid due to the overlap, and so
the reason why valgrind complains, but in reality I think most
implementations can handle it fine, after all, we also use it for
structure assignments which could have full or no overlap but never
partial).
If obstack_room (&s) < sz, then obstack_grow will first
_obstack_newchunk (&s, sz); which will allocate new memory and
copy the existing data of the object (but the above assertion
guartantees it will copy 0 bytes) and then the memcpy copies
sz bytes from the old base to the new (if unlucky, that could crash
as there could be end of page and unmapped next page in between).

I think we should use obstack_blank instead of obstack_grow, which
does everything obstack_grow does, except for the memcpy of the
uninitialized data.

2024-09-25  Jakub Jelinek  <jakub@redhat.com>

* pretty-print.cc (allocate_object): Use obstack_blank rather than
obstack_grow.

10 months agotestsuite: fix hyphen typos
Sam James [Fri, 2 Aug 2024 05:38:34 +0000 (06:38 +0100)] 
testsuite: fix hyphen typos

gcc/testsuite/ChangeLog:

* g++.dg/modules/reparent-1_c.C: Fix whitespace around '-' in dg directive.
* gfortran.dg/initialization_25.f90: Ditto.

10 months agotestsuite: fix comment-only directive typos
Sam James [Mon, 5 Aug 2024 04:01:17 +0000 (05:01 +0100)] 
testsuite: fix comment-only directive typos

Doing this to avoid FPs from grepping but also to avoid the potential
for people learning bad habits.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/caf.exp: Fix 'dg-do-run' typo.
* lib/gfortran-dg.exp: Ditto.
* lib/gm2-dg.exp: Ditto.
* lib/go-dg.exp: Ditto.

10 months agodoc: Remove MinGW note on binutils 2.16
Gerald Pfeifer [Wed, 25 Sep 2024 13:43:29 +0000 (21:43 +0800)] 
doc: Remove MinGW note on binutils 2.16

Binutils 2.16 is 13 years old; no need to specifically refer to it as a
requirement.

gcc:
PR target/69374
* doc/install.texi (Specific) <*-*-mingw32>: Remove note regarding
binutils 2.16.

10 months ago[match.pd] Handle abs pattern with convert
Kugan Vivekanandarajah [Thu, 26 Sep 2024 05:56:06 +0000 (15:56 +1000)] 
[match.pd] Handle abs pattern with convert

gcc/ChangeLog:

* match.pd: Extend A CMP 0 ? A : -A into (type)A CMP 0 ? A : -A.
Extend A CMP 0 ? A : -A into (type) A CMP 0 ? A : -A.

gcc/testsuite/ChangeLog:

* g++.dg/absvect.C: New test.
* gcc.dg/tree-ssa/absfloat16.c: New test.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
10 months agox86: Extend AVX512 Vectorization for Popcount in Various Modes
Levy Hsu [Wed, 11 Sep 2024 04:49:02 +0000 (14:19 +0930)] 
x86: Extend AVX512 Vectorization for Popcount in Various Modes

This patch enables vectorization of the popcount operation for V2QI, V4QI,
V8QI, V2HI, V4HI, and V2SI modes.

gcc/ChangeLog:

* config/i386/mmx.md:
(VQI_16_32_64): New mode iterator for 8-byte, 4-byte, and 2-byte QImode.
(popcount<mode>2): New pattern for popcount of V2QI/V4QI/V8QI mode.
(popcount<mode>2): New pattern for popcount of V2HI/V4HI mode.
(popcountv2si2): New pattern for popcount of V2SI mode.

gcc/testsuite/ChangeLog:

* gcc.target/i386/part-vect-popcount-1.c: New test.

10 months agoDefine VECTOR_STORE_FLAG_VALUE
liuhongt [Mon, 23 Sep 2024 03:06:04 +0000 (11:06 +0800)] 
Define VECTOR_STORE_FLAG_VALUE

gcc/ChangeLog:

* config/i386/i386.h (VECTOR_STORE_FLAG_VALUE): New macro.

gcc/testsuite/ChangeLog:
* gcc.dg/rtl/x86_64/vector_eq.c: New test.

10 months agotestsuite: Fix testcase g++.dg/modules/indirect-1_b.C [PR116846]
Nathaniel Shead [Thu, 26 Sep 2024 01:12:02 +0000 (11:12 +1000)] 
testsuite: Fix testcase g++.dg/modules/indirect-1_b.C [PR116846]

r15-3878 exposed a mistake in the testcase, probably from an older
version of the dumping logic.

Apart from the slightly different syntax for the dump line, also check
for importing the type_decl rather than the const_decl (we need the type
anyway and importing the type also brings along the enumerators so it
would be unnecessary to seed an import for them as well).

PR c++/116846

gcc/testsuite/ChangeLog:

* g++.dg/modules/indirect-1_b.C: Fix testcase.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
10 months agoRISC-V: Add testcases for form 3 of signed vector SAT_ADD
Pan Li [Sat, 21 Sep 2024 04:51:58 +0000 (12:51 +0800)] 
RISC-V: Add testcases for form 3 of signed vector SAT_ADD

Form 3:
  #define DEF_VEC_SAT_S_ADD_FMT_3(T, UT, MIN, MAX)                     \
  void __attribute__((noinline))                                       \
  vec_sat_s_add_##T##_fmt_3 (T *out, T *op_1, T *op_2, unsigned limit) \
  {                                                                    \
    unsigned i;                                                        \
    for (i = 0; i < limit; i++)                                        \
      {                                                                \
        T x = op_1[i];                                                 \
        T y = op_2[i];                                                 \
        T sum;                                                         \
        bool overflow = __builtin_add_overflow (x, y, &sum);           \
        out[i] = overflow ? x < 0 ? MIN : MAX : sum;                   \
      }                                                                \
  }

DEF_VEC_SAT_S_ADD_FMT_3 (int8_t, uint8_t, INT8_MIN, INT8_MAX)

The below test are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper macros.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-10.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-11.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-12.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-9.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-10.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-11.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-12.c: New test.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-9.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoMatch: Support form 3 for vector signed integer .SAT_ADD
Pan Li [Sat, 21 Sep 2024 01:28:39 +0000 (09:28 +0800)] 
Match: Support form 3 for vector signed integer .SAT_ADD

This patch would like to support the form 3 of the vector signed
integer .SAT_ADD.  Aka below example:

Form 3:
  #define DEF_VEC_SAT_S_ADD_FMT_3(T, UT, MIN, MAX)                     \
  void __attribute__((noinline))                                       \
  vec_sat_s_add_##T##_fmt_3 (T *out, T *op_1, T *op_2, unsigned limit) \
  {                                                                    \
    unsigned i;                                                        \
    for (i = 0; i < limit; i++)                                        \
      {                                                                \
        T x = op_1[i];                                                 \
        T y = op_2[i];                                                 \
        T sum;                                                         \
        bool overflow = __builtin_add_overflow (x, y, &sum);           \
        out[i] = overflow ? x < 0 ? MIN : MAX : sum;                   \
      }                                                                \
  }

DEF_VEC_SAT_S_ADD_FMT_3(int8_t, uint8_t, INT8_MIN, INT8_MAX)

Before this patch:
  40   │   # ivtmp.7_34 = PHI <0(3), ivtmp.7_30(7)>
  41   │   _26 = op_1_12(D) + ivtmp.7_34;
  42   │   x_29 = MEM[(int8_t *)_26];
  43   │   _1 = op_2_14(D) + ivtmp.7_34;
  44   │   y_24 = MEM[(int8_t *)_1];
  45   │   _9 = .ADD_OVERFLOW (y_24, x_29);
  46   │   _7 = IMAGPART_EXPR <_9>;
  47   │   if (_7 != 0)
  48   │     goto <bb 6>; [50.00%]
  49   │   else
  50   │     goto <bb 5>; [50.00%]
  51   │ ;;    succ:       6
  52   │ ;;                5
  53   │
  54   │ ;;   basic block 5, loop depth 1
  55   │ ;;    pred:       4
  56   │   _42 = REALPART_EXPR <_9>;
  57   │   _2 = out_17(D) + ivtmp.7_34;
  58   │   MEM[(int8_t *)_2] = _42;
  59   │   ivtmp.7_27 = ivtmp.7_34 + 1;
  60   │   if (_13 != ivtmp.7_27)
  61   │     goto <bb 7>; [89.00%]
  62   │   else
  63   │     goto <bb 8>; [11.00%]
  64   │ ;;    succ:       7
  65   │ ;;                8
  66   │
  67   │ ;;   basic block 6, loop depth 1
  68   │ ;;    pred:       4
  69   │   _38 = x_29 < 0;
  70   │   _39 = (signed char) _38;
  71   │   _40 = -_39;
  72   │   _41 = _40 ^ 127;
  73   │   _33 = out_17(D) + ivtmp.7_34;
  74   │   MEM[(int8_t *)_33] = _41;
  75   │   ivtmp.7_25 = ivtmp.7_34 + 1;
  76   │   if (_13 != ivtmp.7_25)

After this patch:
  77   │   _94 = .SELECT_VL (ivtmp_92, POLY_INT_CST [16, 16]);
  78   │   vect_x_13.9_81 = .MASK_LEN_LOAD (vectp_op_1.7_79, 8B, { -1, ... }, _94, 0);
  79   │   vect_y_15.12_85 = .MASK_LEN_LOAD (vectp_op_2.10_83, 8B, { -1, ... }, _94, 0);
  80   │   vect_patt_49.13_86 = .SAT_ADD (vect_x_13.9_81, vect_y_15.12_85);
  81   │   .MASK_LEN_STORE (vectp_out.14_88, 8B, { -1, ... }, _94, 0, vect_patt_49.13_86);
  82   │   vectp_op_1.7_80 = vectp_op_1.7_79 + _94;
  83   │   vectp_op_2.10_84 = vectp_op_2.10_83 + _94;
  84   │   vectp_out.14_89 = vectp_out.14_88 + _94;
  85   │   ivtmp_93 = ivtmp_92 - _94;

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Add optional nop_convert for signed SAT_ADD case 4.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoDaily bump.
GCC Administrator [Thu, 26 Sep 2024 00:19:14 +0000 (00:19 +0000)] 
Daily bump.

10 months agogfortran testsuite: Remove unit-files in files having open-statements, PR116701
Hans-Peter Nilsson [Mon, 23 Sep 2024 16:44:11 +0000 (18:44 +0200)] 
gfortran testsuite: Remove unit-files in files having open-statements, PR116701

PR testsuite/116701 shows that left-behind files from
unnamed gfortran open statements (named unit.N, where N =
unit number) can interfere with the result of a subsequent
run.  While that's unlikely to happen for a "real" fortran
target or a test with a deleting close-statement, test-cases
should not rely on previous test-cases passing and not
execute along different execution paths depending on earlier
runs, even if the difference is benevolent.

Most but not all fortran test-cases go through
gfortran-dg-runtest (gfortran.dg) or fortran-torture-execute
(gfortran.fortran-torture).  However, the exceptions, with
more complex framework and call-chains, either don't run or
don't have open-statements, so a more complex solution
doesn't seem worthwhile.  If test-cases with open-statements
are added later to those parts of the test-suite, calls to
fortran-delete-unit-files at the right spot may be added or
worst case, "manual" cleanup-calls added, like:
! { dg-final { remote_file target delete "fort.10" } }
Put the new proc in fortran-modules.exp since that's where other
common fortran-testsuite dejagnu-library functions are located.

PR testsuite/116701
* lib/fortran-modules.exp (fortran-delete-unit-files): New proc.
* lib/gfortran-dg.exp (gfortran-dg-runtest): Call
fortran-delete-unit-files after executing test.
* lib/fortran-torture.exp (fortran-torture-execute): Ditto.

10 months agotestsuite: XFAIL g++.dg/modules/indirect-1_b.C
Sam James [Wed, 25 Sep 2024 20:03:49 +0000 (21:03 +0100)] 
testsuite: XFAIL g++.dg/modules/indirect-1_b.C

Mark the newly typo-fixed dg-final bits as XFAIL until investigated.

gcc/testsuite/ChangeLog:
PR c++/116846

* g++.dg/modules/indirect-1_b.C: Add XFAIL.

10 months agotestsuite: fix dejagnu typos with underscores
Sam James [Wed, 31 Jul 2024 16:26:05 +0000 (17:26 +0100)] 
testsuite: fix dejagnu typos with underscores

Fix typos in dejagnu 'dg-*' directives with erroneous underscores like
'dg_'.

gcc/testsuite/ChangeLog:
PR debug/30161
PR c++/91826
PR c++/116846

* g++.dg/debug/dwarf2/template-func-params-7.C: Fix errant underscore.
Cleanup whitespace in directives too.
* g++.dg/lookup/pr91826.C: Fix errant underscore.
* g++.dg/modules/indirect-1_b.C: Ditto.
* gcc.target/powerpc/vsx-builtin-msum.c: Ditto.

10 months agodoc: Remove @code wrapping of fortran option names [PR116801]
Mikael Morin [Wed, 25 Sep 2024 19:23:00 +0000 (21:23 +0200)] 
doc: Remove @code wrapping of fortran option names [PR116801]

The documentation of gfortran options uses @code wrappings for arguments
to @opindex.  This is superfluous, as 'op' index is a texinfo 'code' index,
that is it already implicitly formats its arguments as if in a @code block.
The superfluous wrapping has the effect of creating a nested
<code class="..."> tag inside the regular automatic <code> tag, in the
option index HTML page, preventing the recognition of the corresponding
option by the option URL generation script.

This change removes those superfluous @code wrappings.  Additionally,
variables appearing as separate argument in index are removed, permitting
a few more URL recognition.  Finally, the URL files are regenerated with the
new URLs recognized on the updated HTML files.

By the way, a spurious 'option' is removed from the label of the std= option
in the index, without any effect on URL recognition.

PR other/116801

gcc/fortran/ChangeLog:

* invoke.texi: Remove @code wrapping in arguments to @opindex.
(std=): Remove spurious 'option' in index.
(idirafter, imultilib, iprefix, isysroot, iquote, isystem,
fintrinsic-modules-path): Remove variable from index.
* lang.opt.urls: Regenerate.

gcc/ada/ChangeLog:

* gcc-interface/lang.opt.urls: Regenerate.

gcc/c-family/ChangeLog:

* c.opt.urls: Regenerate.

gcc/ChangeLog:

* common.opt.urls: Regenerate.

gcc/d/ChangeLog:

* lang.opt.urls: Regenerate.

gcc/go/ChangeLog:

* lang.opt.urls: Regenerate.

gcc/m2/ChangeLog:

* lang.opt.urls: Regenerate.

gcc/rust/ChangeLog:

* lang.opt.urls: Regenerate.

10 months agoi386: Add GENERIC and GIMPLE folders of __builtin_ia32_{min,max}* [PR116738]
Jakub Jelinek [Wed, 25 Sep 2024 18:17:11 +0000 (20:17 +0200)] 
i386: Add GENERIC and GIMPLE folders of __builtin_ia32_{min,max}* [PR116738]

The following patch adds GENERIC and GIMPLE folders for various
x86 min/max builtins.
As discussed, these builtins have effectively x < y ? x : y
(or x > y ? x : y) behavior.
The GENERIC folding is done if all the (relevant) arguments are
constants (such as VECTOR_CST for vectors) and is done because
the GIMPLE folding can't easily handle masking, rounding and the
ss/sd cases (in a way that it would be pattern recognized back to the
corresponding instructions).  The GIMPLE folding is also done just
for TARGET_SSE4 or later when optimizing, otherwise it is apparently
not matched back.

2024-09-25  Jakub Jelinek  <jakub@redhat.com>

PR target/116738
* config/i386/i386.cc (ix86_fold_builtin): Handle
IX86_BUILTIN_M{IN,AX}{S,P}{S,H,D}*.
(ix86_gimple_fold_builtin): Handle IX86_BUILTIN_M{IN,AX}P{S,H,D}*.

* gcc.target/i386/avx512f-pr116738-1.c: New test.
* gcc.target/i386/avx512f-pr116738-2.c: New test.

10 months agox86: Don't use address override with segment regsiter
H.J. Lu [Wed, 25 Sep 2024 08:39:04 +0000 (16:39 +0800)] 
x86: Don't use address override with segment regsiter

Address override only applies to the (reg32) part in the thread address
fs:(reg32).  Don't rewrite thread address like

(set (reg:CCZ 17 flags)
    (compare:CCZ (reg:SI 98 [ __gmpfr_emax.0_1 ])
        (mem/c:SI (plus:SI (plus:SI (unspec:SI [
                            (const_int 0 [0])
                        ] UNSPEC_TP)
                    (reg:SI 107))
                (const:SI (unspec:SI [
                            (symbol_ref:SI ("previous_emax") [flags 0x1a] <var_decl 0x7fffe9a11cf0 previous_emax>)
                        ] UNSPEC_DTPOFF))) [1 previous_emax+0 S4 A32])))

if address override is used to avoid the invalid memory operand like

cmpl %fs:previous_emax@dtpoff(%eax), %r12d

gcc/

PR target/116839
* config/i386/i386.cc (ix86_rewrite_tls_address_1): Make it
static.  Return if TLS address is thread register plus an integer
register.

gcc/testsuite/

PR target/116839
* gcc.target/i386/pr116839.c: New file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 months agoltmain.sh: allow more flags at link-time
Sam James [Wed, 14 Aug 2024 03:09:39 +0000 (04:09 +0100)] 
ltmain.sh: allow more flags at link-time

libtool defaults to filtering flags passed at link-time.

This brings the filtering in GCC's 'fork' of libtool into sync with
upstream libtool commit 22a7e547e9857fc94fe5bc7c921d9a4b49c09f8e.

In particular, this now allows some harmless diagnostic flags (especially
useful for things like -Werror=odr), more optimization flags, and some
Clang-specific options.

GCC's -flto documentation mentions:
> To use the link-time optimizer, -flto and optimization options should be
> specified at compile time and during the final link. It is recommended
> that you compile all the files participating in the same link with the
> same options and also specify those options at link time.

This allows compliance with that.

* ltmain.sh (func_mode_link): Allow various flags through filter.

10 months agolibstdc++: testsuite: fix dg-bogus directive syntax
Sam James [Fri, 20 Sep 2024 07:31:45 +0000 (08:31 +0100)] 
libstdc++: testsuite: fix dg-bogus directive syntax

These dg-bogus directives were bogus as they missed a closing brace.

```
+PASS: 23_containers/array/capacity/empty.cc  -std=gnu++17  (test for bogus messages, line 54)
 PASS: 23_containers/array/capacity/empty.cc  -std=gnu++17 (test for excess errors)
 PASS: 23_containers/array/capacity/empty.cc  -std=gnu++17 execution test
+PASS: 23_containers/array/capacity/max_size.cc  -std=gnu++17  (test for bogus messages, line 54)
 PASS: 23_containers/array/capacity/max_size.cc  -std=gnu++17 (test for excess errors)
 PASS: 23_containers/array/capacity/max_size.cc  -std=gnu++17 execution test
+PASS: 23_containers/array/capacity/size.cc  -std=gnu++17  (test for bogus messages, line 54)
```

libstdc++-v3/ChangeLog:
PR libstdc++/101831

* testsuite/23_containers/array/capacity/empty.cc: Add missing brace.
* testsuite/23_containers/array/capacity/max_size.cc: Ditto.
* testsuite/23_containers/array/capacity/size.cc: Ditto.

10 months agoFix testsuite failure on 32-bit targets.
Thomas Koenig [Wed, 25 Sep 2024 16:51:48 +0000 (18:51 +0200)] 
Fix testsuite failure on 32-bit targets.

gcc/testsuite/ChangeLog:

* gfortran.dg/unsigned_25.f90: Change KIND=16 to KIND=8.

10 months agoAdd an alternative testcase for PR 70740
Andrew Pinski [Tue, 24 Sep 2024 02:17:42 +0000 (19:17 -0700)] 
Add an alternative testcase for PR 70740

While looking into improving phiprop, I noticed that
the current pr70740.c testcase was being optimized almost
all the way before phiprop because the addresses were considered
the same; the arrays were all zero in size.

This adds an alternative testcase which changes the array sizes to be 1
and phiprop can and will act on this testcase now and the fix which was
being tested is actually tested now.

Tested on x86_64-linux-gnu.

PR tree-optimization/70740

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr70740-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
10 months agomatch: Fix `a != 0 ? a * b : 0` patterns for things that trap [PR116772]
Andrew Pinski [Thu, 19 Sep 2024 20:50:14 +0000 (13:50 -0700)] 
match: Fix `a != 0 ? a * b : 0` patterns for things that trap [PR116772]

For generic, `a != 0 ? a * b : 0` would match where `b` would be an expression
which trap (in the case of the testcase, it was an integer division but it could be any).

This adds a new helper function, expr_no_side_effects_p which tests if there is no side effects
and the expression is not trapping which might be used in other locations.

Changes since v1:
* v2: Add move check to helper function instead of inlining it.

PR middle-end/116772

gcc/ChangeLog:

* generic-match-head.cc (expr_no_side_effects_p): New function
* gimple-match-head.cc (expr_no_side_effects_p): New function
* match.pd (`a != 0 ? a / b : 0`): Check expr_no_side_effects_p.
(`a != 0 ? a * b : 0`, `a != 0 ? a & b : 0`): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116772-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
10 months agoc++: Add testcase for DR 2874
Jakub Jelinek [Wed, 25 Sep 2024 14:08:33 +0000 (16:08 +0200)] 
c++: Add testcase for DR 2874

Seems we already allow the partial specializations the way the DR clarifies,
so this patch just adds a testcase which verifies that.

2024-09-25  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/DRs/dr2874.C: New test.

10 months agoc++: Add testcase for DR 2836
Jakub Jelinek [Wed, 25 Sep 2024 14:07:50 +0000 (16:07 +0200)] 
c++: Add testcase for DR 2836

Seems we already handle it the way the DR clarifies, if double/long double
and std::float64_t have the same mode, foo has long double type (while
x + y would be _Float64 in C23), so this patch just adds a testcase which
verifies that.

2024-09-25  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/DRs/dr2836.C: New test.

10 months agoc++: Add testcase for DR 2728
Jakub Jelinek [Wed, 25 Sep 2024 14:07:11 +0000 (16:07 +0200)] 
c++: Add testcase for DR 2728

Seems we already handle delete expressions the way the DR clarifies,
so this patch just adds a testcase which verifies that.

2024-09-25  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/DRs/dr2728.C: New test.

10 months agomatch: Fix A || B not optimized to true when !B implies A [PR114326]
Konstantinos Eleftheriou [Wed, 7 Aug 2024 15:54:30 +0000 (17:54 +0200)] 
match: Fix A || B not optimized to true when !B implies A [PR114326]

In expressions like (a != b || ((a ^ b) & c) == d) and
(a != b || (a ^ b) == c), (a ^ b) is folded to false.
In the equivalent expressions (((a ^ b) & c) == d || a != b) and
((a ^ b) == c || a != b) this is not happening.

This patch adds the following simplifications in match.pd:
((a ^ b) & c) cmp d || a != b --> 0 cmp d || a != b
(a ^ b) cmp c || a != b --> 0 cmp c || a != b

PR tree-optimization/114326

gcc/ChangeLog:

* match.pd: Add two patterns to fold a ^ b to 0, when a == b.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/fold-xor-and-or.c: New test.
* gcc.dg/tree-ssa/fold-xor-or.c: New test.

Tested-by: Christoph Müllner <christoph.muellner@vrull.eu>
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Signed-off-by: Konstantinos Eleftheriou <konstantinos.eleftheriou@vrull.eu>
10 months agoSpeed up get_bitmask_from_range
Richard Biener [Wed, 25 Sep 2024 11:37:59 +0000 (13:37 +0200)] 
Speed up get_bitmask_from_range

When min != max we know min ^ max != 0.

* value-range.cc (get_bitmask_from_range): Remove redundant
compare of xorv with zero.

10 months agoSpeed up wide_int_storage::operator=(wide_int_storage const&)
Richard Biener [Wed, 25 Sep 2024 11:15:42 +0000 (13:15 +0200)] 
Speed up wide_int_storage::operator=(wide_int_storage const&)

wide_int_storage shows up high in the profile for the testcase in
PR114855 where the apparent issue is that the conditional jump
on 'precision' after the (inlined) memcpy stalls the pipeline due
to the data dependence and required store-to-load forwarding.  We
can add scheduling freedom by instead testing precision as from the
source which speeds up the function by 30%.  I've applied the
same logic to the copy CTOR.

* wide-int.h (wide_int_storage::wide_int_storage): Branch
on source precision to avoid data dependence on memcpy
destination.
(wide_int_storage::operator=): Likewise.

10 months agoc++: use TARGET_EXPR accessors
Marek Polacek [Tue, 24 Sep 2024 21:54:04 +0000 (17:54 -0400)] 
c++: use TARGET_EXPR accessors

While futzing around with PR116416 I noticed that we can use
the _SLOT and _INITIAL macros to make the code more readable.

gcc/c-family/ChangeLog:

* c-pretty-print.cc (c_pretty_printer::primary_expression): Use
TARGET_EXPR accessors.
(c_pretty_printer::expression): Likewise.

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Use TARGET_EXPR accessors.
(finish_co_yield_expr): Likewise.
(register_awaits): Likewise.
(tmp_target_expr_p): Likewise.
(flatten_await_stmt): Likewise.
* error.cc (dump_expr): Likewise.
* semantics.cc (finish_omp_target_clauses): Likewise.
* tree.cc (bot_manip): Likewise.
(cp_tree_equal): Likewise.
* typeck.cc (cxx_mark_addressable): Likewise.
(cp_build_compound_expr): Likewise.
(cp_build_modify_expr): Likewise.
(check_return_expr): Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agomatch: Change (A * B) + (-C) to (B - C/A) * A, if C multiple of A [PR109393]
Konstantinos Eleftheriou [Thu, 5 Sep 2024 13:59:59 +0000 (15:59 +0200)] 
match: Change (A * B) + (-C) to (B - C/A) * A, if C multiple of A [PR109393]

The following function:

int foo(int *a, int j)
{
  int k = j - 1;
  return a[j - 1] == a[k];
}

does not fold to `return 1;` using -O2 or higher. The cause of this is that
the expression `4 * j + (-4)` for the index computation is not folded to
`4 * (j - 1)`. Existing simplifications that handle similar cases are applied
when A == C, which is not the case in this instance.

A previous attempt to address this issue is
https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649896.html

This patch adds the following simplification in match.pd:
(A * B) + (-C) -> (B - C/A) * A, if C a multiple of A

which also handles cases where the index is j - 2, j - 3, etc.

Bootstrapped for all languages and regression tested on x86-64 and aarch64.

PR tree-optimization/109393

gcc/ChangeLog:

* match.pd: (A * B) + (-C) -> (B - C/A) * A, if C a multiple of A.

gcc/testsuite/ChangeLog:

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

Tested-by: Christoph Müllner <christoph.muellner@vrull.eu>
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Signed-off-by: Konstantinos Eleftheriou <konstantinos.eleftheriou@vrull.eu>
10 months agoremove dominator recursion from reassoc
Richard Biener [Wed, 25 Sep 2024 10:46:28 +0000 (12:46 +0200)] 
remove dominator recursion from reassoc

The reassoc pass currently walks dominators in a recursive way where
I ran into a stack overflow with.  The following replaces it with
worklists following patterns used elsewhere.

* tree-ssa-reassoc.cc (break_up_subtract_bb): Remove recursion.
(reassociate_bb): Likewise.
(do_reassoc): Implement worklist based dominator walks for
both break_up_subtract_bb and reassociate_bb.

10 months agoRemove recursion in simplify_control_stmt_condition_1 [PR114855].
Aldy Hernandez [Mon, 26 Aug 2024 05:33:38 +0000 (07:33 +0200)] 
Remove recursion in simplify_control_stmt_condition_1 [PR114855].

Remove some ad-hoc simplification code in the forward threader, as the
call into the ranger in m_simplifier->simplify() will handle anything we
can do manually in simplify_control_stmt_condition_1.

In PR114855, DOM time is reduced from 120s to 92s (-23%) and overall
compilation time from 235s to 205s (-12%).  The total thread count at -O1 is
unchanged for the testcase.

In our bootstrap .ii benchmark suite, I see we thread 3 threads less
over all files at -O1.  At -O2, the backward threader picks up one more,
for no difference over all.

PR tree-optimization/114855

gcc/ChangeLog:

* tree-ssa-threadedge.cc: Remove unneeded recursion.

10 months agolibstdc++: #ifdef out #pragma GCC system_header
Jason Merrill [Thu, 12 Sep 2024 16:15:51 +0000 (12:15 -0400)] 
libstdc++: #ifdef out #pragma GCC system_header

In r15-3714-gd3a7302ec5985a I added -Wsystem-headers to the libstdc++ build
flags to help catch problems in the library.  This patch takes a different
approach, of disabling the #pragma system_header unless _GLIBCXX_SYSHDR is
defined.  As a result, the testsuites will treat them as non-system-headers
to get better warning coverage during regression testing of both gcc and
libstdc++, not just when building the library.

My rationale for the #ifdef instead of just removing the #pragma is the
three G++ tests that want to test libstdc++ system header behavior, so we
need a way to select it.

This doesn't affect installed libraries, as they get their
system-header status from the lookup path.  But testsuite_flags
--build-includes gives -I directives rather than -isystem.

This patch doesn't change the headers in config/ because I'm not compiling
with most of them, so won't see any warnings that need fixing.  Adjusting
them could happen later, or we can not bother.

libstdc++-v3/ChangeLog:

* acinclude.m4 (WARN_FLAGS): Remove -Wsystem-headers.
* configure: Regenerate.
* include/bits/algorithmfwd.h: #ifdef out #pragma GCC system_header.
* include/bits/atomic_base.h
* include/bits/atomic_futex.h
* include/bits/atomic_timed_wait.h
* include/bits/atomic_wait.h
* include/bits/basic_ios.h
* include/bits/basic_string.h
* include/bits/boost_concept_check.h
* include/bits/char_traits.h
* include/bits/charconv.h
* include/bits/chrono.h
* include/bits/chrono_io.h
* include/bits/codecvt.h
* include/bits/concept_check.h
* include/bits/cpp_type_traits.h
* include/bits/elements_of.h
* include/bits/enable_special_members.h
* include/bits/erase_if.h
* include/bits/forward_list.h
* include/bits/functional_hash.h
* include/bits/gslice.h
* include/bits/gslice_array.h
* include/bits/hashtable.h
* include/bits/indirect_array.h
* include/bits/invoke.h
* include/bits/ios_base.h
* include/bits/iterator_concepts.h
* include/bits/locale_classes.h
* include/bits/locale_facets.h
* include/bits/locale_facets_nonio.h
* include/bits/localefwd.h
* include/bits/mask_array.h
* include/bits/max_size_type.h
* include/bits/memory_resource.h
* include/bits/memoryfwd.h
* include/bits/move_only_function.h
* include/bits/node_handle.h
* include/bits/ostream_insert.h
* include/bits/out_ptr.h
* include/bits/parse_numbers.h
* include/bits/postypes.h
* include/bits/quoted_string.h
* include/bits/range_access.h
* include/bits/ranges_base.h
* include/bits/refwrap.h
* include/bits/sat_arith.h
* include/bits/semaphore_base.h
* include/bits/slice_array.h
* include/bits/std_abs.h
* include/bits/std_function.h
* include/bits/std_mutex.h
* include/bits/std_thread.h
* include/bits/stl_iterator_base_funcs.h
* include/bits/stl_iterator_base_types.h
* include/bits/stl_tree.h
* include/bits/stream_iterator.h
* include/bits/streambuf_iterator.h
* include/bits/stringfwd.h
* include/bits/this_thread_sleep.h
* include/bits/unique_lock.h
* include/bits/uses_allocator_args.h
* include/bits/utility.h
* include/bits/valarray_after.h
* include/bits/valarray_array.h
* include/bits/valarray_before.h
* include/bits/version.h
* include/c_compatibility/fenv.h
* include/c_compatibility/inttypes.h
* include/c_compatibility/stdint.h
* include/decimal/decimal.h
* include/experimental/bits/net.h
* include/experimental/bits/shared_ptr.h
* include/ext/aligned_buffer.h
* include/ext/alloc_traits.h
* include/ext/atomicity.h
* include/ext/concurrence.h
* include/ext/numeric_traits.h
* include/ext/pod_char_traits.h
* include/ext/pointer.h
* include/ext/stdio_filebuf.h
* include/ext/stdio_sync_filebuf.h
* include/ext/string_conversions.h
* include/ext/type_traits.h
* include/ext/vstring.h
* include/ext/vstring_fwd.h
* include/ext/vstring_util.h
* include/parallel/algorithmfwd.h
* include/parallel/numericfwd.h
* include/tr1/functional_hash.h
* include/tr1/hashtable.h
* include/tr1/random.h
* libsupc++/exception.h
* libsupc++/hash_bytes.h
* include/bits/basic_ios.tcc
* include/bits/basic_string.tcc
* include/bits/fstream.tcc
* include/bits/istream.tcc
* include/bits/locale_classes.tcc
* include/bits/locale_facets.tcc
* include/bits/locale_facets_nonio.tcc
* include/bits/ostream.tcc
* include/bits/sstream.tcc
* include/bits/streambuf.tcc
* include/bits/string_view.tcc
* include/bits/version.tpl
* include/experimental/bits/string_view.tcc
* include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp
* include/ext/random.tcc
* include/ext/vstring.tcc
* include/tr2/bool_set.tcc
* include/tr2/dynamic_bitset.tcc
* include/bits/c++config
* include/c/cassert
* include/c/cctype
* include/c/cerrno
* include/c/cfloat
* include/c/ciso646
* include/c/climits
* include/c/clocale
* include/c/cmath
* include/c/csetjmp
* include/c/csignal
* include/c/cstdarg
* include/c/cstddef
* include/c/cstdio
* include/c/cstdlib
* include/c/cstring
* include/c/ctime
* include/c/cuchar
* include/c/cwchar
* include/c/cwctype
* include/c_global/cassert
* include/c_global/ccomplex
* include/c_global/cctype
* include/c_global/cerrno
* include/c_global/cfenv
* include/c_global/cfloat
* include/c_global/cinttypes
* include/c_global/ciso646
* include/c_global/climits
* include/c_global/clocale
* include/c_global/cmath
* include/c_global/csetjmp
* include/c_global/csignal
* include/c_global/cstdalign
* include/c_global/cstdarg
* include/c_global/cstdbool
* include/c_global/cstddef
* include/c_global/cstdint
* include/c_global/cstdio
* include/c_global/cstdlib
* include/c_global/cstring
* include/c_global/ctgmath
* include/c_global/ctime
* include/c_global/cuchar
* include/c_global/cwchar
* include/c_global/cwctype
* include/c_std/cassert
* include/c_std/cctype
* include/c_std/cerrno
* include/c_std/cfloat
* include/c_std/ciso646
* include/c_std/climits
* include/c_std/clocale
* include/c_std/cmath
* include/c_std/csetjmp
* include/c_std/csignal
* include/c_std/cstdarg
* include/c_std/cstddef
* include/c_std/cstdio
* include/c_std/cstdlib
* include/c_std/cstring
* include/c_std/ctime
* include/c_std/cuchar
* include/c_std/cwchar
* include/c_std/cwctype
* include/debug/array
* include/debug/bitset
* include/debug/deque
* include/debug/forward_list
* include/debug/list
* include/debug/map
* include/debug/set
* include/debug/string
* include/debug/unordered_map
* include/debug/unordered_set
* include/debug/vector
* include/decimal/decimal
* include/experimental/algorithm
* include/experimental/any
* include/experimental/array
* include/experimental/buffer
* include/experimental/chrono
* include/experimental/contract
* include/experimental/deque
* include/experimental/executor
* include/experimental/filesystem
* include/experimental/forward_list
* include/experimental/functional
* include/experimental/internet
* include/experimental/io_context
* include/experimental/iterator
* include/experimental/list
* include/experimental/map
* include/experimental/memory
* include/experimental/memory_resource
* include/experimental/net
* include/experimental/netfwd
* include/experimental/numeric
* include/experimental/propagate_const
* include/experimental/ratio
* include/experimental/regex
* include/experimental/scope
* include/experimental/set
* include/experimental/socket
* include/experimental/string
* include/experimental/string_view
* include/experimental/synchronized_value
* include/experimental/system_error
* include/experimental/timer
* include/experimental/tuple
* include/experimental/type_traits
* include/experimental/unordered_map
* include/experimental/unordered_set
* include/experimental/vector
* include/ext/algorithm
* include/ext/cmath
* include/ext/functional
* include/ext/iterator
* include/ext/memory
* include/ext/numeric
* include/ext/random
* include/ext/rb_tree
* include/ext/rope
* include/parallel/algorithm
* include/std/algorithm
* include/std/any
* include/std/array
* include/std/atomic
* include/std/barrier
* include/std/bit
* include/std/bitset
* include/std/charconv
* include/std/chrono
* include/std/codecvt
* include/std/complex
* include/std/concepts
* include/std/condition_variable
* include/std/coroutine
* include/std/deque
* include/std/execution
* include/std/expected
* include/std/filesystem
* include/std/format
* include/std/forward_list
* include/std/fstream
* include/std/functional
* include/std/future
* include/std/generator
* include/std/iomanip
* include/std/ios
* include/std/iosfwd
* include/std/iostream
* include/std/istream
* include/std/iterator
* include/std/latch
* include/std/limits
* include/std/list
* include/std/locale
* include/std/map
* include/std/memory
* include/std/memory_resource
* include/std/mutex
* include/std/numbers
* include/std/numeric
* include/std/optional
* include/std/ostream
* include/std/print
* include/std/queue
* include/std/random
* include/std/ranges
* include/std/ratio
* include/std/regex
* include/std/scoped_allocator
* include/std/semaphore
* include/std/set
* include/std/shared_mutex
* include/std/span
* include/std/spanstream
* include/std/sstream
* include/std/stack
* include/std/stacktrace
* include/std/stdexcept
* include/std/streambuf
* include/std/string
* include/std/string_view
* include/std/syncstream
* include/std/system_error
* include/std/text_encoding
* include/std/thread
* include/std/tuple
* include/std/type_traits
* include/std/typeindex
* include/std/unordered_map
* include/std/unordered_set
* include/std/utility
* include/std/valarray
* include/std/variant
* include/std/vector
* include/std/version
* include/tr1/array
* include/tr1/cfenv
* include/tr1/cinttypes
* include/tr1/cmath
* include/tr1/complex
* include/tr1/cstdbool
* include/tr1/cstdint
* include/tr1/cstdio
* include/tr1/cstdlib
* include/tr1/cwchar
* include/tr1/cwctype
* include/tr1/functional
* include/tr1/memory
* include/tr1/random
* include/tr1/regex
* include/tr1/tuple
* include/tr1/type_traits
* include/tr1/unordered_map
* include/tr1/unordered_set
* include/tr1/utility
* include/tr2/bool_set
* include/tr2/dynamic_bitset
* include/tr2/type_traits
* libsupc++/atomic_lockfree_defines.h
* libsupc++/compare
* libsupc++/cxxabi.h
* libsupc++/cxxabi_forced.h
* libsupc++/cxxabi_init_exception.h
* libsupc++/exception
* libsupc++/initializer_list
* libsupc++/new
* libsupc++/typeinfo: Likewise.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc
* testsuite/23_containers/array/tuple_interface/get_neg.cc
* testsuite/23_containers/vector/cons/destructible_debug_neg.cc
* testsuite/24_iterators/operations/prev_neg.cc
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Adjust
line numbers.

gcc/testsuite/ChangeLog

* g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C
* g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C
* g++.dg/diagnostic/disable.C: #define _GLIBCXX_SYSHDR.

10 months agolibstdc++: more #pragma diagnostic
Jason Merrill [Tue, 24 Sep 2024 03:38:34 +0000 (23:38 -0400)] 
libstdc++: more #pragma diagnostic

The CI saw failures on 17_intro/headers/c++2011/parallel_mode.cc due to
-Wdeprecated-declarations warnings in some parallel/ headers.

libstdc++-v3/ChangeLog:

* include/parallel/base.h: Suppress -Wdeprecated-declarations.
* include/parallel/multiseq_selection.h: Likewise.

10 months agoUse tree view for find_always_executed_bbs result
Richard Biener [Wed, 25 Sep 2024 10:52:32 +0000 (12:52 +0200)] 
Use tree view for find_always_executed_bbs result

The following makes us use bitmap tree view for the always-executed-BBs
bitmap as computed by IPA utils find_always_executed_bbs and used by
IPA modref (where it shows up in the profile for PR114855.

* ipa-utils.cc (find_always_executed_bbs): Switch result
bitmap to tree view.

10 months agoOpenMP: Update OMP_REQUIRES_TARGET_USED for declare_target + interop
Tobias Burnus [Wed, 25 Sep 2024 11:57:02 +0000 (13:57 +0200)] 
OpenMP: Update OMP_REQUIRES_TARGET_USED for declare_target + interop

Older versions of the OpenMP specification were not clear about what counted
as device usage. Newer (like TR13) are rather clear. Hence, this commit adds
GCC's target-used flag also when a 'declare target' or an 'interop' are
encountered.  (The latter only to Fortran as C/C++ parsing support is still
missing.) TR13 also lists 'dispatch' as target-used construct (as it has the
device clause) and 'device_safesync' as clause with global requirement
property, but both are not yet supported in GCC.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_declare_target): Set target-used bit
in omp_requires_mask.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_declare_target): Set target-used bit
in omp_requires_mask.

gcc/fortran/ChangeLog:

* parse.cc (decode_omp_directive): Set target-used bit of
omp_requires_mask when encountering the declare_target or interop
directive.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/interop-1.f90: Add dg-error for missing
omp requires requirement and declare_variant usage.
* gfortran.dg/gomp/requires-8.f90: Likewise.

10 months agoRISC-V: Cleanup debug code for SAT_* testcases [NFC]
Pan Li [Wed, 25 Sep 2024 08:00:27 +0000 (16:00 +0800)] 
RISC-V: Cleanup debug code for SAT_* testcases [NFC]

Some print code for debugging is committed by mistake, remove them
from the test header file.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/scalar_sat_binary_run_xxx.h: Remove printf
code for debugging.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agortl-optimization/114855 - slow add_store_equivs in IRA
Richard Biener [Tue, 24 Sep 2024 12:10:13 +0000 (14:10 +0200)] 
rtl-optimization/114855 - slow add_store_equivs in IRA

For the testcase in PR114855 at -O1 add_store_equivs shows up as the
main sink for bitmap_set_bit because it uses a bitmap to mark all
seen insns by UID to make sure the forward walk in memref_used_between_p
will find the insn in question.  Given we do have a CFG here the
functions operation is questionable, given memref_used_between_p
together with the walk of all insns is obviously quadratic in the
worst case that whole thing should be re-done ... but, for the
testcase, using a sbitmap of size get_max_uid () + 1 gets
bitmap_set_bit off the profile and improves IRA time from 15.58s (8%)
to 3.46s (2%).

Now, given above quadraticness I wonder whether we should instead
gate add_store_equivs on optimize > 1 or flag_expensive_optimizations.

PR rtl-optimization/114855
* ira.cc (add_store_equivs): Use sbitmap for tracking
visited insns.

10 months agoDisable add_store_equivs when -fno-expensive-optimizations
Richard Biener [Tue, 24 Sep 2024 12:21:33 +0000 (14:21 +0200)] 
Disable add_store_equivs when -fno-expensive-optimizations

IRAs add_store_equivs is quadratic in the size of the function worst
case, disable it when -fno-expensive-optimizations which means at
-O1 and -Og.

* ira.cc (ira): Gate add_store_equivs on flag_expensive_optimizations.

10 months agotree-optimization/114855 - slow VRP due to equiv oracle queries
Richard Biener [Tue, 24 Sep 2024 09:47:26 +0000 (11:47 +0200)] 
tree-optimization/114855 - slow VRP due to equiv oracle queries

For the testcase in PR114855 VRP takes 320.41s (23%) (after mitigating
backwards threader slowness).  This is mostly due to the bitmap check
in equiv_oracle::find_equiv_dom.  The following turns this bitmap
to tree view, trading the linear search for a O(log N) one which
improves VRP time to 54.54s (5%).

PR tree-optimization/114855
* value-relation.cc (equiv_oracle::equiv_oracle): Switch
m_equiv_set to tree view.

10 months agoRISC-V: Refine the testcase of vector SAT_TRUNC
Pan Li [Wed, 25 Sep 2024 06:37:46 +0000 (14:37 +0800)] 
RISC-V: Refine the testcase of vector SAT_TRUNC

Take scan-assembler-times for vnclip insn check instead of function body,
as we only care about if we can generate the fixed point insn vnclip.

The below test are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c: Remove
func body check and take scan asm times instead.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-13.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-14.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-15.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-16.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-17.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-18.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-19.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-20.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-21.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-22.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-23.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-24.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-9.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Refine the testcase of vector SAT_SUB
Pan Li [Wed, 25 Sep 2024 05:55:22 +0000 (13:55 +0800)] 
RISC-V: Refine the testcase of vector SAT_SUB

Take scan-assembler-times for vssub insn check instead of function body,
as we only care about if we can generate the fixed point insn vssub.

The below test are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c: Remove
func body check and take scan asm times instead.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-13.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-14.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-15.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-16.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-17.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-18.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-19.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-20.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-21.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-22.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-23.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-24.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-25.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-26.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-27.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-28.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-29.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-30.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-31.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-32.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-33.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-34.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-35.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-36.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-37.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-38.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-39.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-40.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-9.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_trunc-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub_zip.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Refine the testcase of vector SAT_ADD
Pan Li [Wed, 25 Sep 2024 03:41:22 +0000 (11:41 +0800)] 
RISC-V: Refine the testcase of vector SAT_ADD

Take scan-assembler-times for vsadd insn check instead of function body,
as we only care about if we can generate the fixed point insn vsadd.

The below test are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-1.c: Remove
func body check and take scan asm times instead.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-9.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-13.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-14.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-15.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-16.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-9.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoi386: Update the comment for mapxf option
Lingling Kong [Wed, 25 Sep 2024 03:18:44 +0000 (11:18 +0800)] 
i386: Update the comment for mapxf option

gcc/ChangeLog:

* config/i386/i386.opt: Update the features included in apxf.

10 months agoOpenMP: Fix testsuite failure on x86 with -m32
Sandra Loosemore [Wed, 25 Sep 2024 02:59:53 +0000 (02:59 +0000)] 
OpenMP: Fix testsuite failure on x86 with -m32

The testcase decare-variant-duplicates.c added in commit
96246bff0bcd9e5cdec9e6cf811ee3db4997f6d4 failed on 32-bit x86
because on that target "i386" is defined as a preprocessor macro
and cannot be used as an identifier.  Fixed by rewriting that test
not to do that.

gcc/testsuite/ChangeLog
* c-c++-common/gomp/declare-variant-duplicates.c: Avoid using
"i386" as an identifier.

10 months agoDaily bump.
GCC Administrator [Wed, 25 Sep 2024 00:18:47 +0000 (00:18 +0000)] 
Daily bump.

10 months agoAdd random numbers and fix some bugs.
Thomas Koenig [Tue, 24 Sep 2024 20:57:42 +0000 (22:57 +0200)] 
Add random numbers and fix some bugs.

This patch adds random number support for UNSIGNED, plus fixes
two bugs, with array I/O where the type used to be set to BT_INTEGER,
and for division with the divisor being a constant.

gcc/fortran/ChangeLog:

* check.cc (gfc_check_random_number): Adjust for unsigned.
* iresolve.cc (gfc_resolve_random_number): Handle unsigned.
* trans-expr.cc (gfc_conv_expr_op): Handle BT_UNSIGNED for divide.
* trans-types.cc (gfc_get_dtype_rank_type): Handle BT_UNSIGNED.
* gfortran.texi: Add RANDOM_NUMBER for UNSIGNED.

libgfortran/ChangeLog:

* gfortran.map: Add _gfortran_random_m1, _gfortran_random_m2,
_gfortran_random_m4, _gfortran_random_m8 and _gfortran_random_m16.
* intrinsics/random.c (random_m1): New function.
(random_m2): New function.
(random_m4): New function.
(random_m8): New function.
(random_m16): New function.
(arandom_m1): New function.
(arandom_m2): New function.
(arandom_m4): New function.
(arandom_m8): New funciton.
(arandom_m16): New function.

gcc/testsuite/ChangeLog:

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

10 months agoImplement IANY, IALL and IPARITY for unsigned.
Thomas Koenig [Tue, 24 Sep 2024 20:53:59 +0000 (22:53 +0200)] 
Implement IANY, IALL and IPARITY for unsigned.

gcc/fortran/ChangeLog:

* check.cc (gfc_check_transf_bit_intrins): Handle unsigned.
* gfortran.texi: Docment IANY, IALL and IPARITY for unsigned.
* iresolve.cc (gfc_resolve_iall): Set flag to use integer
if type is BT_UNSIGNED.
(gfc_resolve_iany): Likewise.
(gfc_resolve_iparity): Likewise.
* simplify.cc (do_bit_and): Adjust asserts for BT_UNSIGNED.
(do_bit_ior): Likewise.
(do_bit_xor): Likewise

gcc/testsuite/ChangeLog:

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

10 months agooptions: Regenerate c.opt.urls
Jakub Jelinek [Tue, 24 Sep 2024 20:21:26 +0000 (22:21 +0200)] 
options: Regenerate c.opt.urls

Forgot to regenerate URLs for the C++23 P2718R0 patch.

2024-09-24  Jakub Jelinek  <jakub@redhat.com>

* c.opt.urls: Regenerate.

10 months agoImplement SUM and PRODUCT for unsigned.
Thomas Koenig [Tue, 24 Sep 2024 19:59:10 +0000 (21:59 +0200)] 
Implement SUM and PRODUCT for unsigned.

gcc/fortran/ChangeLog:

* gfortran.texi: Document SUM and PRODUCT.
* iresolve.cc (resolve_transformational): New argument,
use_integer, to translate calls to unsigned to calls to
integer.
(gfc_resolve_product): Use it
(gfc_resolve_sum): Use it.
* simplify.cc (init_result_expr): Handle BT_UNSIGNED.

libgfortran/ChangeLog:

* generated/product_c10.c: Regenerated.
* generated/product_c16.c: Regenerated.
* generated/product_c17.c: Regenerated.
* generated/product_c4.c: Regenerated.
* generated/product_c8.c: Regenerated.
* generated/product_i1.c: Regenerated.
* generated/product_i16.c: Regenerated.
* generated/product_i2.c: Regenerated.
* generated/product_i4.c: Regenerated.
* generated/product_i8.c: Regenarated.
* generated/product_r10.c: Regenerated.
* generated/product_r16.c: Regenerated.
* generated/product_r17.c: Regenerated.
* generated/product_r4.c: Regenerated.
* generated/product_r8.c: Regenarated.
* generated/sum_c10.c: Regenerated.
* generated/sum_c16.c: Regenerated.
* generated/sum_c17.c: Regenerated.
* generated/sum_c4.c: Regenerated.
* generated/sum_c8.c: Regenerated.
* generated/sum_i1.c: Regenerated.
* generated/sum_i16.c: Regenerated.
* generated/sum_i2.c: Regenerated.
* generated/sum_i4.c: Regenerated.
* generated/sum_i8.c: Regenerated.
* generated/sum_r10.c: Regenerated.
* generated/sum_r16.c: Regenerated.
* generated/sum_r17.c: Regenerated.
* generated/sum_r4.c: Regenerated.
* generated/sum_r8.c: Regenerated.
* m4/ifunction.m4: Whitespace fix.
* m4/product.m4: If type is integer, change to unsigned.
* m4/sum.m4: Likewise.

10 months agoImplement MATMUL and DOT_PRODUCT for unsigned.
Thomas Koenig [Tue, 24 Sep 2024 19:51:42 +0000 (21:51 +0200)] 
Implement MATMUL and DOT_PRODUCT for unsigned.

gcc/fortran/ChangeLog:

* arith.cc (gfc_arith_uminus): Fix warning.
(gfc_arith_minus): Correctly truncate unsigneds.
* check.cc (gfc_check_dot_product): Handle unsigned arguments.
(gfc_check_matmul): Likewise.
* expr.cc (gfc_get_unsigned_expr): New function.
* gfortran.h (gfc_get_unsigned_expr): Add prototype.
* iresolve.cc (gfc_resolve_matmul): If using UNSIGNED, use the
signed integer version.
* gfortran.texi: Document MATMUL and DOT_PRODUCT for unsigned.
* simplify.cc (compute_dot_product): Handle unsigneds.

libgfortran/ChangeLog:

* m4/iparm.m4: Add UNSIGED if type is m.
* m4/matmul.m4: If type is GFC_INTEGER, use GFC_UINTEGER instead.
Whitespace fixes.
* m4/matmul_internal.m4: Whitespace fixes.

* generated/matmul_c10.c: Regenerated.
* generated/matmul_c16.c: Regenerated.
* generated/matmul_c17.c: Regenerated.
* generated/matmul_c4.c: Regenerated.
* generated/matmul_c8.c: Regeneraated.
* generated/matmul_i1.c: Regenerated.
* generated/matmul_i16.c: Regenerated.
* generated/matmul_i2.c: Regenerated.
* generated/matmul_i4.c: Regenerated.
* generated/matmul_i8.c: Regenerated.
* generated/matmul_r10.c: Regenerated.
* generated/matmul_r16.c: Regenerated.
* generated/matmul_r17.c: Regenerated.
* generated/matmul_r4.c: Regenerated.
* generated/matmul_r8.c: Regenerated.
* libgfortran.h: Add array types for unsiged.

gcc/testsuite/ChangeLog:

* gfortran.dg/unsigned_25.f90: New test.
* gfortran.dg/unsigned_26.f90: New test.

10 months agoc++: Implement C++23 P2718R0 - Wording for P2644R1 Fix for Range-based for Loop ...
Jakub Jelinek [Tue, 24 Sep 2024 18:19:50 +0000 (20:19 +0200)] 
c++: Implement C++23 P2718R0 - Wording for P2644R1 Fix for Range-based for Loop [PR107637]

The following patch implements the C++23 P2718R0 paper
- Wording for P2644R1 Fix for Range-based for Loop.
The patch introduces a new option, -f{,no-}range-for-ext-temps so that
user can control the behavior even in older C++ versions.
The option is on by default in C++23 and later (-fno-range-for-ext-temps
is an error in that case) and in the -std=gnu++11 ... -std=gnu++20 modes
(one can use -fno-range-for-ext-temps to request previous behavior in that
case), and is not enabled by default in -std=c++11 ... -std=c++20 modes
but one can explicitly enable it with -frange-for-ext-temps.
As all the temporaries from __for_range initialization should have life
extended until the end of __for_range scope, this patch disables (for
-frange-for-ext-temps and if !processing_template_decl) CLEANUP_POINT_EXPR wrapping
of the __for_range declaration, also disables -Wdangling-reference warning
as well as the rest of extend_ref_init_temps (we know the __for_range temporary
is not TREE_STATIC and as all the temporaries from the initializer will be life
extended, we shouldn't try to handle temporaries referenced by references any
differently) and adds an extra push_stmt_list/pop_stmt_list before
cp_finish_decl of __for_range and after end of the for body and wraps all
that into CLEANUP_POINT_EXPR.
I had to repeat that also for OpenMP range loops because those are handled
differently.

2024-09-24  Jakub Jelinek  <jakub@redhat.com>

PR c++/107637
gcc/
* omp-general.cc (find_combined_omp_for, find_nested_loop_xform):
Handle CLEANUP_POINT_EXPR like TRY_FINALLY_EXPR.
* doc/invoke.texi (frange-for-ext-temps): Document.  Add
-fconcepts to the C++ option list.
gcc/c-family/
* c.opt (frange-for-ext-temps): New option.
* c-opts.cc (c_common_post_options): Set flag_range_for_ext_temps
for C++23 or later or for C++11 or later in !flag_iso mode if
the option wasn't set by user.
* c-cppbuiltin.cc (c_cpp_builtins): Change __cpp_range_based_for
value for flag_range_for_ext_temps from 201603L to 202212L in C++17
or later.
* c-omp.cc (c_find_nested_loop_xform_r): Handle CLEANUP_POINT_EXPR
like TRY_FINALLY_EXPR.
gcc/cp/
* cp-tree.h: Implement C++23 P2718R0 - Wording for P2644R1 Fix for
Range-based for Loop.
(cp_convert_omp_range_for): Add bool tmpl_p argument.
(find_range_for_decls): Declare.
* parser.cc (cp_convert_range_for): For flag_range_for_ext_temps call
push_stmt_list () before cp_finish_decl for range_temp and save it
temporarily to FOR_INIT_STMT.
(cp_convert_omp_range_for): Add tmpl_p argument.  If set, remember
DECL_NAME of range_temp and for cp_finish_decl call restore it before
clearing it again, if unset, don't adjust DECL_NAME of range_temp at
all.
(cp_parser_omp_loop_nest): For flag_range_for_ext_temps range for add
CLEANUP_POINT_EXPR around sl.  Call find_range_for_decls and adjust
DECL_NAMEs for range fors if not processing_template_decl.  Adjust
cp_convert_omp_range_for caller.  Remove superfluous backslash at the
end of line.
* decl.cc (initialize_local_var): For flag_range_for_ext_temps
temporarily clear stmts_are_full_exprs_p rather than set for
for_range__identifier decls.
* call.cc (extend_ref_init_temps): For flag_range_for_ext_temps return
init early for for_range__identifier decls.
* semantics.cc (find_range_for_decls): New function.
(finish_for_stmt): Use it.  For flag_range_for_ext_temps if
cp_convert_range_for set FOR_INIT_STMT, pop_stmt_list it and wrap
into CLEANUP_POINT_EXPR.
* pt.cc (tsubst_omp_for_iterator): Adjust tsubst_omp_for_iterator
caller.
(tsubst_stmt) <case OMP_FOR>: For flag_range_for_ext_temps if there
are any range fors in the loop nest, add push_stmt_list starting
before the initializations, pop_stmt_list it after the body and wrap
into CLEANUP_POINT_EXPR.  Change DECL_NAME of range for temps from
NULL to for_range_identifier.
gcc/testsuite/
* g++.dg/cpp23/range-for1.C: New test.
* g++.dg/cpp23/range-for2.C: New test.
* g++.dg/cpp23/range-for3.C: New test.
* g++.dg/cpp23/range-for4.C: New test.
* g++.dg/cpp23/range-for5.C: New test.
* g++.dg/cpp23/range-for6.C: New test.
* g++.dg/cpp23/range-for7.C: New test.
* g++.dg/cpp23/range-for8.C: New test.
* g++.dg/cpp23/feat-cxx2b.C (__cpp_range_based_for): Check for
202212L rather than 201603L.
* g++.dg/cpp26/feat-cxx26.C (__cpp_range_based_for): Likewise.
* g++.dg/warn/Wdangling-reference4.C: Don't expect warning for C++23
or newer.  Use dg-additional-options rather than dg-options.
libgomp/
* testsuite/libgomp.c++/range-for-1.C: New test.
* testsuite/libgomp.c++/range-for-2.C: New test.
* testsuite/libgomp.c++/range-for-3.C: New test.
* testsuite/libgomp.c++/range-for-4.C: New test.
* testsuite/libgomp.c++/range-for-5.C: New test.

10 months agolibgcc, Darwin: Drop the legacy library build for macOS >= 15 [PR116809].
Iain Sandoe [Sun, 22 Sep 2024 10:43:32 +0000 (11:43 +0100)] 
libgcc, Darwin: Drop the legacy library build for macOS >= 15 [PR116809].

We have been building a legacy libgcc_s.1 DSO to support code that
was built with older compilers.

From macOS 15,  the unwinder no longer exports some of the symbols used
in that library which (a) cuases bootstrap fail and (b) means that the
legacy library is no longer useful.

No open branch of GCC emits references to this library - and any already
-built code that depends on the symbols would need rework anyway.

PR target/116809

libgcc/ChangeLog:

* config.host: Build legacy libgcc_s.1 on hosts before macOS 15.
* config/i386/t-darwin: Remove reference to legacy libgcc_s.1
* config/rs6000/t-darwin: Likewise.
* config/t-darwin-libgccs1: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
10 months agoi386: Fix comment typo
Jakub Jelinek [Tue, 24 Sep 2024 17:00:38 +0000 (19:00 +0200)] 
i386: Fix comment typo

Found a comment typo, fixed as obvious.

2024-09-24  Jakub Jelinek  <jakub@redhat.com>

* config/i386/i386-expand.cc (ix86_expand_round_builtin): Fix comment
typo, insead -> instead.

10 months agoc++/contracts: ICE in build_contract_condition_function [PR116490]
Nina Dinka Ranns [Fri, 30 Aug 2024 12:49:07 +0000 (13:49 +0100)] 
c++/contracts: ICE in build_contract_condition_function [PR116490]

We currently do not expect comdat group of the guarded function to
be set at the time of generating pre and post check function.
However, in the case of an explicit instantiation, the guarded
function has been added to a comdat group before generating contract
check functions, which causes the observed ICE. Current assert
removed and an additional check for comdat group of the guarded
function added. With this change, the pre and post check functions
get added to the same comdat group of the guarded function if the
guarded function is already placed in a comdat group.

PR c++/116490

gcc/cp/ChangeLog:

* contracts.cc (build_contract_condition_function): added
a check for comdat group of the guarded function. If set,
the condition check function is added to the same comdat
group.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/pr116490.C: New test.

Signed-off-by: Nina Ranns <dinka.ranns@gmail.com>
10 months agolibgomp: with USM, init 'link' variables with host address
Tobias Burnus [Tue, 24 Sep 2024 15:41:39 +0000 (17:41 +0200)] 
libgomp: with USM, init 'link' variables with host address

If requires unified_shared_memory or self_maps is set, make
'declare target link' variables to point initially to the host pointer.

libgomp/ChangeLog:

* target.c (gomp_load_image_to_device): For requires
unified_shared_memory, update 'link' vars to point to the host var.
* testsuite/libgomp.c-c++-common/target-link-3.c: New test.
* testsuite/libgomp.c-c++-common/target-link-4.c: New test.