]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
11 months agoc++, coroutines: Tidy up awaiter variable checks.
Iain Sandoe [Thu, 22 Aug 2024 07:10:14 +0000 (08:10 +0100)] 
c++, coroutines: Tidy up awaiter variable checks.

When we build an await expression, we might need to materialise the awaiter
if it is a prvalue.  This re-implements this using core APIs instead of local
code.

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Simplify checks for the cases that
we need to materialise an awaiter.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
11 months agoc++: Add testcase for (now fixed) regression [PR113746]
Simon Martin [Fri, 23 Aug 2024 08:49:31 +0000 (10:49 +0200)] 
c++: Add testcase for (now fixed) regression [PR113746]

The case in PR113746 used to ICE until commit r15-123-gf04dc89a991ddc.
This patch simply adds the case to the testsuite.

PR c++/113746

gcc/testsuite/ChangeLog:

* g++.dg/parse/crash76.C: New test.

11 months agotestsuite: Add dg-require-effective-target scheduling for some tests that set -fsched...
Georg-Johann Lay [Sat, 24 Aug 2024 08:23:39 +0000 (10:23 +0200)] 
testsuite: Add dg-require-effective-target scheduling for some tests that set -fschedule-insns.

gcc/testsuite/
* gcc.dg/torture/pr115929-2.c: Add dg-require-effective-target scheduling.
* gcc.dg/torture/pr116343.c: Same.

11 months agoDaily bump.
GCC Administrator [Sat, 24 Aug 2024 00:18:13 +0000 (00:18 +0000)] 
Daily bump.

11 months agolibstdc++: Update and clarify Doxygen version requirements in manual
Jonathan Wakely [Fri, 23 Aug 2024 20:32:14 +0000 (21:32 +0100)] 
libstdc++: Update and clarify Doxygen version requirements in manual

There are lots of bugs that affect libstdc++ output from Doxygen, so
using 1.9.6 or later is recommended. Give a lower minimum, because some
distros still use 1.9.1 and that will work, albeit suboptimally.

libstdc++-v3/ChangeLog:

* doc/xml/manual/documentation_hacking.xml: Update minimum
Doxygen version.
* doc/html/*: Regenerate.

11 months agolibstdc++: Hide std::tuple internals from Doxygen docs
Jonathan Wakely [Fri, 23 Aug 2024 21:06:43 +0000 (22:06 +0100)] 
libstdc++: Hide std::tuple internals from Doxygen docs

libstdc++-v3/ChangeLog:

* include/std/tuple: Do not include implementation details in
Doxygen documentation.

11 months agolibstdc++: Improve Doxygen docs for std::allocator_traits specializations
Jonathan Wakely [Fri, 23 Aug 2024 20:54:21 +0000 (21:54 +0100)] 
libstdc++: Improve Doxygen docs for std::allocator_traits specializations

The main fix here is to use @header so that the docs show the correct
header file instead of an internal header like alloc_traits.h.

libstdc++-v3/ChangeLog:

* include/bits/alloc_traits.h: Improve doxygen docs for
allocator_traits specializations.
* include/bits/memory_resource.h: Likewise.

11 months agoRISC-V: Use encoded nelts when calling repeating_sequence_p
Patrick O'Neill [Mon, 19 Aug 2024 19:19:33 +0000 (12:19 -0700)] 
RISC-V: Use encoded nelts when calling repeating_sequence_p

repeating_sequence_p operates directly on the encoded pattern and does
not derive elements using the .elt() accessor. Passing in the length of
the unencoded vector can cause an out-of-bounds read of the encoded
pattern.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (rvv_builder::can_duplicate_repeating_sequence_p):
Use encoded_nelts when calling repeating_sequence_p.
(rvv_builder::is_repeating_sequence): Ditto.
(rvv_builder::repeating_sequence_use_merge_profitable_p): Ditto.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
11 months agoifcvt: Do not overwrite results in noce_convert_multiple_sets [PR116372, PR116405]
Manolis Tsamis [Tue, 20 Aug 2024 07:16:29 +0000 (09:16 +0200)] 
ifcvt: Do not overwrite results in noce_convert_multiple_sets [PR116372, PR116405]

Now that more operations are allowed for noce_convert_multiple_sets,
it is possible that the same register appears multiple times as target
in a basic block.  After noce_convert_multiple_sets_1 is called we
potentially also emit register moves from temporaries back to the
original targets.  In some cases where the target registers overlap
with the block's condition, these register moves may overwrite
intermediate variables because they're emitted after the if-converted
code.  To address this issue we now iterate backwards and keep track
of seen registers when emitting these final register moves.

PR rtl-optimization/116372
PR rtl-optimization/116405

gcc/ChangeLog:

* ifcvt.cc (noce_convert_multiple_sets): Iterate backwards and track
target registers.

gcc/testsuite/ChangeLog:

* gcc.dg/pr116372.c: New test.
* gcc.dg/pr116405.c: New test.

11 months agoifcvt: disallow call instructions in noce_convert_multiple_sets [PR116358]
Manolis Tsamis [Thu, 22 Aug 2024 09:59:11 +0000 (02:59 -0700)] 
ifcvt: disallow call instructions in noce_convert_multiple_sets [PR116358]

Similar to not allowing jump instructions in the generated code, we
also shouldn't allow call instructions in noce_convert_multiple_sets.
In the case of PR116358 a libcall was generated from force_operand.

PR middle-end/116358

gcc/ChangeLog:

* ifcvt.cc (noce_convert_multiple_sets): Disallow call insns.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr116358.c: New test.

11 months agors6000: Fix PTImode handling in power8 swap optimization pass [PR116415]
Peter Bergner [Fri, 23 Aug 2024 16:45:40 +0000 (11:45 -0500)] 
rs6000: Fix PTImode handling in power8 swap optimization pass [PR116415]

Our power8 swap optimization pass has some special handling for optimizing
swaps of TImode variables.  The test case reported in bugzilla uses a call
to  __atomic_compare_exchange, which introduces a variable of PTImode and
that does not get the same treatment as TImode leading to wrong code
generation.  The simple fix is to treat PTImode identically to TImode.

2024-08-23  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR target/116415
* config/rs6000/rs6000.h (TI_OR_PTI_MODE): New define.
* config/rs6000/rs6000-p8swap.cc (rs6000_analyze_swaps): Use it to
handle PTImode identically to TImode.

gcc/testsuite/
PR target/116415
* gcc.target/powerpc/pr116415.c: New test.

11 months agolto: Don't check obj.found for offload section
H.J. Lu [Fri, 23 Aug 2024 12:36:45 +0000 (05:36 -0700)] 
lto: Don't check obj.found for offload section

obj.found is the number of LTO symbols.  We should include the offload
section when it is used by linker even if there are no LTO symbols.

PR lto/116361
* lto-plugin.c (claim_file_handler_v2): Don't check obj.found
for the offload section.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 months agolibstdc++: Implement LWG 3746 for std::optional
Jonathan Wakely [Tue, 25 Jun 2024 20:58:34 +0000 (21:58 +0100)] 
libstdc++: Implement LWG 3746 for std::optional

This avoids constraint recursion in operator<=> for std::optional.
The resolution was approved in Kona 2022.

libstdc++-v3/ChangeLog:

* include/std/optional (__is_derived_from_optional): New
concept.
(operator<=>): Use __is_derived_from_optional.
* testsuite/20_util/optional/relops/lwg3746.cc: New test.

11 months agolibstdc++: Optimize __try_use_facet for const types
Jonathan Wakely [Wed, 22 May 2024 15:49:31 +0000 (16:49 +0100)] 
libstdc++: Optimize __try_use_facet for const types

LWG 436 confirmed that const-qualified types are valid arguments for
Facet template parameters (but volatile-qualified types are not). Use the
fast path in std::use_facet and std::has_facet for const T as well as T.

libstdc++-v3/ChangeLog:

* include/bits/locale_classes.tcc (__try_use_facet): Also avoid
dynamic_cast for const-qualified facet types.

11 months agolibstdc++: Fix std::allocator_traits::construct constraints [PR108619]
Jonathan Wakely [Wed, 10 Jul 2024 22:14:19 +0000 (23:14 +0100)] 
libstdc++: Fix std::allocator_traits::construct constraints [PR108619]

Using std::is_constructible in the constraints introduces a spurious
dependency on the type being destructible, which should not be required
for constructing with an allocator. The test case shows a case where the
type has a private destructor, which can be destroyed by the allocator,
but std::is_destructible and std::is_constructible are false.

Similarly, using is_nothrow_constructible in the noexcept-specifiers
for the construct members of allocator_traits and std::allocator,
__gnu_cxx::__new_allocator, and __gnu_cxx::__malloc_allocator gives the
wrong answer if the type isn't destructible.
We need a new type trait to define those correctly, so that we only
check if the placement new-expression is nothrow after using
is_constructible to check that it would be well-formed.

Instead of just fixing the overly restrictive constraint to check for
placement new, rewrite allocator_traits in terms of 'if constexpr' using
variable templates and the detection idiom.

Although we can use 'if constexpr' and variable templates in C++11 with
appropriate uses of diagnostic pragmas, we can't have constexpr
functions with multiple return statements. This means that in C++11 mode
the _S_nothrow_construct and _S_nothrow_destroy helpers used for
noexcept-specifiers still need to be overlaods using enable_if. Nearly
everything else can be simplified to reduce overload resolution and
enable_if checks.

libstdc++-v3/ChangeLog:

PR libstdc++/108619
* include/bits/alloc_traits.h (__allocator_traits_base): Add
variable templates for detecting which allocator operations are
supported.
(allocator_traits): Use 'if constexpr' instead of dispatching to
overloads constrained with enable_if.
(allocator_traits<allocator<T>>::construct): Use Construct if
construct_at is not supported. Use
__is_nothrow_new_constructible for noexcept-specifier.
(allocator_traits<allocator<void>>::construct): Use
__is_nothrow_new_constructible for noexcept-specifier.
* include/bits/new_allocator.h (construct): Likewise.
* include/ext/malloc_allocator.h (construct): Likewise.
* include/std/type_traits (__is_nothrow_new_constructible): New
variable template.
* testsuite/20_util/allocator/89510.cc: Adjust expected results.
* testsuite/ext/malloc_allocator/89510.cc: Likewise.
* testsuite/ext/new_allocator/89510.cc: Likewise.
* testsuite/20_util/allocator_traits/members/108619.cc: New test.

11 months agolibstdc++: Only use std::time_put in std::format for non-C locales
Jonathan Wakely [Wed, 31 Jul 2024 15:32:44 +0000 (16:32 +0100)] 
libstdc++: Only use std::time_put in std::format for non-C locales

When testing on Solaris I noticed that std/time/year/io.cc was FAILing
because the year 1642 was being formatted as "+(" by %Ey. This turns out
to be because we defer to std::time_put for modified conversion specs,
and std::time_put uses std::strftime, and that's undefined for years
before 1970. In particular, years before 1900 mean that the tm_year
field is negative, which then causes incorrect results from strftime on
at least Solaris and AIX.

I've raised the general problem with LWG, but we can fix the FAILing
test case (and probably improve performance slightly) by ignoring the E
and O modifiers when the formatting locale is the "C" locale. The
modifiers have no effect for the C locale, so we can just treat %Ey as
%y and format it directly. This doesn't fix anything when the formatting
locale isn't the C locale, but that case is not adequately tested, so
doesn't cause any FAIL right now!

The naïve fix would be simply:

  if (__mod)
    if (auto __loc = _M_locale(__ctx); __loc != locale::classic())
      // ...

However when the format string doesn't use the 'L' option, _M_locale
always returns locale::classic(). In that case, we make a copy of the
classic locale (which calls the non-inline copy constructor in
the library), then make another copy of the classic locale, then compare
the two. We can avoid all that by checking for the 'L' option first,
instead of letting _M_locale do that:

  if (__mod && _M_spec._M_localized)
    if (auto __loc = __ctx.locale(); __loc != locale::classic())
      // ...

We could optimize this further if we had a __is_classic(__loc) function
that would do the __loc == locale::classic() check without making any
copies or non-inline calls. That would require examining the locale's
_M_impl member, and probably require checking its name, because the
locale::_S_classic singleton is not exported from the library.

For _M_S the change is slightly different from the other functions,
because if we skip using std::time_put for %OS then we fall through to
the code that potentially prints fractional seconds, but the %OS format
only prints whole seconds. So we need to format whole seconds directly
when not using std::time_put, instead of falling through to the code
below.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y):
Ignore modifiers unless the formatting locale is not the C
locale.
(__formatter_chrono::_M_d_e): Likewise.
(__formatter_chrono::_M_H_I): Likewise.
(__formatter_chrono::_M_m): Likewise.
(__formatter_chrono::_M_M): Likewise.
(__formatter_chrono::_M_S): Likewise.
(__formatter_chrono::_M_u_w): Likewise.
(__formatter_chrono::_M_U_V_W): Likewise.

11 months agolibstdc++: Define operator== for hash table iterators [PR115939]
Jonathan Wakely [Tue, 16 Jul 2024 08:43:06 +0000 (09:43 +0100)] 
libstdc++: Define operator== for hash table iterators [PR115939]

Currently iterators for unordered containers do not directly define
operator== and operator!= overloads. Instead they rely on the base class
defining them, which is done so that iterator and const_iterator
comparisons work using the same overloads.

However this means a derived-to-base conversion is needed to call those
operators, and PR libstdc++/115939 shows that this can be ambiguous (for
-pedantic) when another overloaded operator could be used after an
implicit conversion.

This change defines operator== and operator!= directly for
_Node_iterator and _Node_const_iterator so that no derived-to-base
conversions are needed. The new overloads just forward to the base class
ones, so the implementation is still shared and doesn't need to be
duplicated.

libstdc++-v3/ChangeLog:

PR libstdc++/115939
* include/bits/hashtable_policy.h (_Node_iterator): Add
operator== and operator!=.
(_Node_const_iterator): Likewise.
* testsuite/23_containers/unordered_map/115939.cc: New test.

11 months agolibstdc++: Fix std::random_shuffle for low RAND_MAX [PR88935]
Giovanni Bajo [Wed, 31 Jul 2024 19:03:40 +0000 (20:03 +0100)] 
libstdc++: Fix std::random_shuffle for low RAND_MAX [PR88935]

When RAND_MAX is small and the number of elements being shuffled is
close to it, we get very uneven distributions in std::random_shuffle.

This uses a simple xorshift generator seeded by std::rand if we can't
rely on std::rand itself.

libstdc++-v3/ChangeLog:

PR libstdc++/88935
* include/bits/stl_algo.h (random_shuffle) [RAND_MAX < INT_MAX]:
Use xorshift instead of rand().
* testsuite/25_algorithms/random_shuffle/88935.cc: New test.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Giovanni Bajo <rasky@develer.com>
11 months agotree-optimization/116463 - complex lowering leaves around dead stmts
Richard Biener [Fri, 23 Aug 2024 11:44:29 +0000 (13:44 +0200)] 
tree-optimization/116463 - complex lowering leaves around dead stmts

Complex lowering generally replaces existing complex defs with
COMPLEX_EXPRs but those might be dead when it can always refer to
components from the lattice.  This in turn can pessimize followup
transforms like forwprop and reassoc, the following makes sure to
get rid of dead COMPLEX_EXPRs generated by using
simple_dce_from_worklist.

PR tree-optimization/116463
* tree-complex.cc: Include tree-ssa-dce.h.
(dce_worklist): New global.
(update_complex_assignment): Add SSA def to the DCE worklist.
(tree_lower_complex): Perform DCE.

11 months agolibstdc++: Make debug sequence members mutable [PR116369]
Jonathan Wakely [Wed, 21 Aug 2024 11:29:32 +0000 (12:29 +0100)] 
libstdc++: Make debug sequence members mutable [PR116369]

We need to be able to attach debug mode iterators to const containers,
so the safe iterator constructor uses const_cast to get a modifiable
pointer to the container. If the container was defined as const, that
const_cast to access its members results in undefined behaviour.  PR
116369 shows a case where it results in a segfault because the container
is in a rodata section (which shouldn't have happened, but the undefined
behaviour in the library still exists in any case).

This makes the _M_iterators and _M_const_iterators data members mutable,
so that it's safe to modify them even if the declared type of the
container is a const type.

Ideally we would not need the const_cast at all. Instead, the _M_attach
member (and everything it calls) should be const-qualified. That would
work fine now, because the members that it ends up modifying are
mutable. Making that change would require a number of new exports from
the shared library, and would require retaining the old non-const member
functions (maybe as symbol aliases) for backwards compatibility. That
might be worth changing at some point, but isn't done here.

libstdc++-v3/ChangeLog:

PR c++/116369
* include/debug/safe_base.h (_Safe_sequence_base::_M_iterators):
Add mutable specifier.
(_Safe_sequence_base::_M_const_iterators): Likewise.

11 months agolibstdc++: Use noexcept insted of throw() in src/c++11/debug.cc
Jonathan Wakely [Wed, 21 Aug 2024 11:22:58 +0000 (12:22 +0100)] 
libstdc++: Use noexcept insted of throw() in src/c++11/debug.cc

libstdc++-v3/ChangeLog:

* src/c++11/debug.cc: Replace throw() with noexcept.

11 months agolibstdc++: Simplify C++20 implementation of std::variant
Jonathan Wakely [Tue, 20 Aug 2024 17:07:32 +0000 (18:07 +0100)] 
libstdc++: Simplify C++20 implementation of std::variant

For C++20 the __detail::__variant::_Uninitialized primary template can
be used for all types, because _Variant_union can have a non-trivially
destructible union member in C++20, and the constrained user-provided
destructor will ensure we don't destroy inactive objects.

Since we always use the primary template for C++20, we don't need the
_Uninitialized::_M_get accessors to abstract the difference between the
primary template and the partial specialization. That allows us to
simplify __get_n for C++20 too.

Also improve the comments that explain the uses of _Uninitialized and
when/why _Variant_union needs a user-provided destructor.

libstdc++-v3/ChangeLog:

* include/std/variant [C++20] (_Uninitialized): Always use the
primary template.
[C++20] (__get_n): Access the _M_storage member directly.

11 months agolibstdc++: Make std::vector<bool>::reference constructor private [PR115098]
Jonathan Wakely [Wed, 21 Aug 2024 20:19:46 +0000 (21:19 +0100)] 
libstdc++: Make std::vector<bool>::reference constructor private [PR115098]

The standard says this constructor should be private.  LWG 4141 proposes
to remove it entirely. We still need it, but it doesn't need to be
public.

For std::bitset the default constructor is already private (and never
even defined) but there's a non-standard constructor that's public, but
doesn't need to be.

libstdc++-v3/ChangeLog:

PR libstdc++/115098
* include/bits/stl_bvector.h (_Bit_reference): Make default
constructor private. Declare vector and bit iterators as
friends.
* include/std/bitset (bitset::reference): Make constructor and
data members private.
* testsuite/20_util/bitset/115098.cc: New test.
* testsuite/23_containers/vector/bool/115098.cc: New test.

11 months agoRevert "Fortran: Fix class transformational intrinsic calls [PR102689]"
Paul Thomas [Fri, 23 Aug 2024 12:16:53 +0000 (13:16 +0100)] 
Revert "Fortran: Fix class transformational intrinsic calls [PR102689]"

This reverts commit 4cb07a38233aadb4b389a6e5236c95f52241b6e0.

11 months agoMatch: Support form 4 for unsigned integer .SAT_TRUNC
Pan Li [Tue, 20 Aug 2024 07:44:38 +0000 (15:44 +0800)] 
Match: Support form 4 for unsigned integer .SAT_TRUNC

This patch would like to support the form 4 of the unsigned integer
.SAT_TRUNC. Aka below example:

Form 4:
  #define DEF_SAT_U_TRUC_FMT_4(NT, WT)           \
  NT __attribute__((noinline))                   \
  sat_u_truc_##WT##_to_##NT##_fmt_4 (WT x)       \
  {                                              \
    bool not_overflow = x <= (WT)(NT)(-1);       \
    return ((NT)x) | (NT)((NT)not_overflow - 1); \
  }

DEF_SAT_U_TRUC_FMT_4(uint32_t, uint64_t)

Before this patch:
   4   │ __attribute__((noinline))
   5   │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x)
   6   │ {
   7   │   _Bool not_overflow;
   8   │   unsigned char _1;
   9   │   unsigned char _2;
  10   │   unsigned char _3;
  11   │   uint8_t _6;
  12   │
  13   │ ;;   basic block 2, loop depth 0
  14   │ ;;    pred:       ENTRY
  15   │   not_overflow_5 = x_4(D) <= 255;
  16   │   _1 = (unsigned char) x_4(D);
  17   │   _2 = (unsigned char) not_overflow_5;
  18   │   _3 = _2 + 255;
  19   │   _6 = _1 | _3;
  20   │   return _6;
  21   │ ;;    succ:       EXIT
  22   │
  23   │ }

After this patch:
   4   │ __attribute__((noinline))
   5   │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x)
   6   │ {
   7   │   uint8_t _6;
   8   │
   9   │ ;;   basic block 2, loop depth 0
  10   │ ;;    pred:       ENTRY
  11   │   _6 = .SAT_TRUNC (x_4(D)); [tail call]
  12   │   return _6;
  13   │ ;;    succ:       EXIT
  14   │
  15   │ }

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 form 4 for unsigned .SAT_TRUNC matching.

Signed-off-by: Pan Li <pan2.li@intel.com>
11 months agolibcpp: bump padding size in _cpp_convert_input [PR116458]
Alexander Monakov [Thu, 22 Aug 2024 18:09:47 +0000 (21:09 +0300)] 
libcpp: bump padding size in _cpp_convert_input [PR116458]

The recently introduced search_line_fast_ssse3 raised padding
requirement from 16 to 64, which was adjusted in read_file_guts,
but the corresponding ' + 16' in _cpp_convert_input was overlooked.

libcpp/ChangeLog:

PR preprocessor/116458
* charset.cc (_cpp_convert_input): Bump padding to 64 if
HAVE_SSSE3.

11 months agooptabs-query: Use opt_machine_mode for smallest_int_mode_for_size [PR115495].
Robin Dapp [Tue, 20 Aug 2024 12:02:09 +0000 (14:02 +0200)] 
optabs-query: Use opt_machine_mode for smallest_int_mode_for_size [PR115495].

In get_best_extraction_insn we use smallest_int_mode_for_size with
struct_bits as size argument.  PR115495 has struct_bits = 256 and we
don't have a mode for that.  This patch makes smallest_mode_for_size
and smallest_int_mode_for_size return opt modes so we can just skip
over the loop when there is no mode.

PR middle-end/115495

gcc/ChangeLog:

* cfgexpand.cc (expand_debug_expr): Require mode.
* combine.cc (make_extraction): Ditto.
* config/aarch64/aarch64.cc (aarch64_expand_cpymem): Ditto.
(aarch64_expand_setmem): Ditto.
* config/arc/arc.cc (arc_expand_cpymem): Ditto.
* config/arm/arm.cc (arm_expand_divmod_libfunc): Ditto.
* config/i386/i386.cc (ix86_get_mask_mode): Ditto.
* config/rs6000/predicates.md: Ditto.
* config/rs6000/rs6000.cc (vspltis_constant): Ditto.
* config/s390/s390.cc (s390_expand_insv): Ditto.
* config/sparc/sparc.cc (assign_int_registers): Ditto.
* coverage.cc (get_gcov_type): Ditto.
(get_gcov_unsigned_t): Ditto.
* dse.cc (find_shift_sequence): Ditto.
* expmed.cc (store_integral_bit_field): Ditto.
* expr.cc (convert_mode_scalar): Ditto.
(op_by_pieces_d::smallest_fixed_size_mode_for_size): Ditto.
(emit_block_move_via_oriented_loop): Ditto.
(copy_blkmode_to_reg): Ditto.
(store_field): Ditto.
* internal-fn.cc (expand_arith_overflow): Ditto.
* machmode.h (HAVE_MACHINE_MODES): Ditto.
(smallest_mode_for_size): Use opt_machine_mode.
(smallest_int_mode_for_size): Use opt_scalar_int_mode.
* optabs-query.cc (get_best_extraction_insn): Require mode.
* optabs.cc (expand_twoval_binop_libfunc): Ditto.
* stor-layout.cc (smallest_mode_for_size): Return
opt_machine_mode.
(layout_type): Require mode.
(initialize_sizetypes): Ditto.
* tree-ssa-loop-manip.cc (canonicalize_loop_ivs): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr115495.c: New test.

gcc/ada/ChangeLog:

* gcc-interface/utils2.cc (fast_modulo_reduction): Require mode.
(nonbinary_modular_operation): Ditto.

11 months agoRISC-V: Expand vec abs without masking.
Robin Dapp [Fri, 9 Aug 2024 13:05:39 +0000 (15:05 +0200)] 
RISC-V: Expand vec abs without masking.

Standard abs synthesis during expand is max (a, -a).  This
expansion has the advantage of avoiding masking and is thus potentially
faster than the a < 0 ? -a : a synthesis.

gcc/ChangeLog:

* config/riscv/autovec.md (abs<mode>2): Expand via max (a, -a).

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/unop/abs-rv32gcv.c: Adjust test
expectation.
* gcc.target/riscv/rvv/autovec/unop/abs-rv64gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/abs-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_unary-8.c: Ditto.

11 months agoFix test failure on powerpc targets
Bernd Edlinger [Fri, 23 Aug 2024 04:22:55 +0000 (06:22 +0200)] 
Fix test failure on powerpc targets

Apparently due to slightly different optimization levels
not always both subroutines have multiple subranges,
but having at least one such, and no lexical blocks
is sufficient to prove that the fix worked.  Q.E.D.
So reduce the test expectations to only at least one
inlined subroutine with multiple subranges.

gcc/testsuite/ChangeLog:

PR other/116462
* gcc.dg/debug/dwarf2/inline7.c: Reduce test expectations.

11 months agoada: Fix crash on aliased variable with packed array type and -g switch
Eric Botcazou [Mon, 5 Aug 2024 11:06:17 +0000 (13:06 +0200)] 
ada: Fix crash on aliased variable with packed array type and -g switch

This comes from a loophole in gnat_get_array_descr_info for record types
containing a template, which represent an aliased array, when this array
type is bit-packed and implemented as a modular integer.

gcc/ada/

* gcc-interface/misc.cc (gnat_get_array_descr_info): Test the
BIT_PACKED_ARRAY_TYPE_P flag only once on the final debug type. In
the case of records containing a template, replay the entire
processing for the array type contained therein.

11 months agoada: String interpolation: report error without Extensions allowed
Javier Miranda [Sun, 11 Aug 2024 11:11:29 +0000 (11:11 +0000)] 
ada: String interpolation: report error without Extensions allowed

The compiler does not report the correct error in occurrences
of interpolated strings, when the sources are compiled without
language extensions allowed.

gcc/ada/

* scng.adb (Scan): Call Error_Msg_GNAT_Extension() to report an
error, when the sources are compiled without Core_Extensions_
Allowed, and the scanner detects the beginning of an interpolated
string.

11 months agoada: Fix incorrect tracebacks on Windows
Sebastian Poeplau [Wed, 7 Aug 2024 09:21:25 +0000 (11:21 +0200)] 
ada: Fix incorrect tracebacks on Windows

PECOFF symbols don't have a size attached to them. The symbol size that
System.Object_Reader.Read_Symbol guesses to make up for the lack of
information can be wrong when the symbol table doesn't match the
algorithm's expectations; in particular that's the case when function
symbols aren't sorted by address.

To avoid incorrect tracebacks caused by wrong symbol size guesses, don't
use the symbol size for PECOFF files when producing a traceback and
instead pick the symbol with the highest address lower than the target
address.

gcc/ada/

* libgnat/s-dwalin.adb (Symbolic_Address): Ignore symbol size in
address-to-symbol translation for PECOFF files.

11 months agoada: Crash on string interpolation with custom string types
Javier Miranda [Wed, 7 Aug 2024 17:41:42 +0000 (17:41 +0000)] 
ada: Crash on string interpolation with custom string types

The compiler crashes when processing an object declaration
of a custom string type initialized with an interpolated
string.

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference: [Put_Image]): Add
support for custom string types.
* exp_ch2.adb (Expand_N_Interpolated_String_Literal): Add a type
conversion to the result object declaration of custom string
types.
* exp_put_image.adb (Build_String_Put_Image_Call): Handle custom
string types.

11 months agoada: Implicit_Dereference aspect specification for subtype incorrectly accepted
Steve Baird [Tue, 6 Aug 2024 21:44:54 +0000 (14:44 -0700)] 
ada: Implicit_Dereference aspect specification for subtype incorrectly accepted

Implicit_Dereference is a type-specific aspect and therefore cannot be
legally specified as part of a subtype declaration.

gcc/ada/

* sem_ch13.adb (Analyze_Aspect_Implicit_Dereference): Generate
error if an aspect specification specifies the
Implicit_Dereference aspect of a non-first subtype.

11 months agoada: Eliminated-mode overflow check not eliminated
Steve Baird [Mon, 5 Aug 2024 22:15:22 +0000 (15:15 -0700)] 
ada: Eliminated-mode overflow check not eliminated

If the Overflow_Mode in effect is Eliminated, then evaluating an arithmetic
op such as addition or subtraction should not fail an overflow check.
Fix a bug which resulted in such an overflow check failure.

gcc/ada/

* checks.adb (Is_Signed_Integer_Arithmetic_Op): Return True in the
case of relational operator whose operands are of a signed integer
type.

11 months agoada: Update libraries with the limited flag
Viljar Indus [Fri, 2 Aug 2024 06:09:10 +0000 (09:09 +0300)] 
ada: Update libraries with the limited flag

Records without a limited keyword now emit a warning if
they contain a member that has an inherently limited type.

gcc/ada/

* libgnat/a-coinho__shared.ads: add limited keyword.
* libgnat/g-awk.adb: add limited keyword.
* libgnat/g-comlin.ads: add limited keyword.
* libgnat/s-excmac__arm.ads: add limited keyword.
* libgnat/s-excmac__gcc.ads: add limited keyword.
* libgnat/s-soflin.ads: add limited keyword.

11 months agoada: Emit a warning on inheritly limited types
Viljar Indus [Thu, 1 Aug 2024 12:59:00 +0000 (15:59 +0300)] 
ada: Emit a warning on inheritly limited types

Record types that do not have a limited keyword but have a
member with a limited type are also considered to be limited types.
This can be confusing to understand for newer Ada users. It is
better to emit a warning in this scenario and suggest that the
type should be marked with a limited keyword. This diagnostic will
be acticated when the -gnatw_l switch is used.

gcc/ada/

* sem_ch3.adb: Add method Check_Inherited_Limted_Record for
emitting the warning for an inherited limited type.
* warnsw.adb: Add processing for the -gnatw_l switch that
triggeres the inheritly limited type warning.
* warnsw.ads: same as above.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add
entry for -gnatw_l switch.
* gnat_ugn.texi: Regenerate.

11 months agoada: First controlling parameter aspect
Javier Miranda [Tue, 6 Aug 2024 17:07:09 +0000 (17:07 +0000)] 
ada: First controlling parameter aspect

gcc/ada/

* sem_ch6.adb (Check_Private_Overriding): Improve code detecting
error on private function with controlling result. Fixes the
regression of ACATS bde0003.

11 months agoada: Fix style in lines starting with assignment operator
Piotr Trojanek [Tue, 30 Jul 2024 11:59:28 +0000 (13:59 +0200)] 
ada: Fix style in lines starting with assignment operator

Style cleanup; semantics is unaffected. Offending occurrences found with
grep "^ *:=" and fixed manually.

gcc/ada/

* checks.ads, cstand.adb, exp_aggr.adb, exp_ch4.adb, exp_ch5.adb,
exp_dbug.adb, exp_util.adb, gnatlink.adb, lib-util.adb,
libgnat/a-except.adb, libgnat/a-exexpr.adb, libgnat/a-ngcoar.adb,
libgnat/s-rannum.adb, libgnat/s-trasym__dwarf.adb, osint.adb,
rtsfind.adb, sem_case.adb, sem_ch12.adb, sem_ch13.adb,
sem_ch3.adb, sem_ch6.adb, sem_eval.adb, sem_prag.adb,
sem_util.adb: Fix style.

11 months agoada: Cleanup validity of boolean operators
Piotr Trojanek [Tue, 30 Jul 2024 14:17:29 +0000 (16:17 +0200)] 
ada: Cleanup validity of boolean operators

Move detection of always valid expressions from routine
Ensure_Valid (which inserts validity checks) to Expr_Known_Valid
(which decides their validity). In particular, this patch removes
duplicated detection of boolean operators, which were recognized
in both these routines.

Code cleanup; behavior is unaffected.

gcc/ada/

* checks.adb (Ensure_Valid): Remove detection of boolean and
short-circuit operators.
(Expr_Known_Valid): Detect short-circuit operators; detection of
boolean operators was already done in this routine.

11 months agoada: Simplify validity checks for scalar parameters
Piotr Trojanek [Tue, 30 Jul 2024 10:52:14 +0000 (12:52 +0200)] 
ada: Simplify validity checks for scalar parameters

Replace low-level iteration over formal and actual parameters with a
call to high-level Find_Actual routine. Code cleanup; behavior is
unaffected.

gcc/ada/

* checks.adb (Ensure_Valid): Use Find_Actual.

11 months agoada: Fix validity checks for named parameter associations
Piotr Trojanek [Tue, 30 Jul 2024 10:30:08 +0000 (12:30 +0200)] 
ada: Fix validity checks for named parameter associations

When iterating over actual and formal parameters, we should use
First_Actual/Next_Actual and not simply First/Next, because the
order of actual parameters might be different than the order of
formal parameters obtained with First_Formal/Next_Formal.

This patch fixes a glitch in validity checks for actual parameters
and applies the same fix to other misuses of First/Next as well.

gcc/ada/

* checks.adb (Ensure_Valid): Use First_Actual/Next_Actual.
* exp_ch6.adb (Is_Direct_Deep_Call): Likewise.
* exp_util.adb (Type_Of_Formal): Likewise.
* sem_util.adb (Is_Container_Element): Likewise; cleanup
membership test by using a subtype.

11 months agoada: First controlling parameter aspect
Javier Miranda [Mon, 5 Aug 2024 20:03:01 +0000 (20:03 +0000)] 
ada: First controlling parameter aspect

gcc/ada/

* sem_ch13.adb (Analyze_One_Aspect): Temporarily remove reporting
an error when the new aspect is set to True and the extensions are
not enabled.

11 months agoada: Error missing when 'access is applied to an interface type object
Javier Miranda [Mon, 5 Aug 2024 15:56:33 +0000 (15:56 +0000)] 
ada: Error missing when 'access is applied to an interface type object

The compiler does not report an error when 'access is applied to
a non-aliased class-wide interface type object.

gcc/ada/

* exp_util.ads (Is_Expanded_Class_Wide_Interface_Object_Decl): New
subprogram.
* exp_util.adb (Is_Expanded_Class_Wide_Interface_Object_Decl):
ditto.
* sem_util.adb (Is_Aliased_View): Handle expanded class-wide type
object declaration.
* checks.adb (Is_Aliased_Unconstrained_Component): Protect the
frontend against calling Is_Aliased_View with Empty. Found working
on this issue.

11 months agoada: First controlling parameter aspect
Javier Miranda [Fri, 26 Jul 2024 12:53:23 +0000 (12:53 +0000)] 
ada: First controlling parameter aspect

This patch adds support for a new GNAT aspect/pragma that modifies
the semantics of dispatching primitives. When a tagged type has
this aspect/pragma, only subprograms that have the first parameter
of this type will be considered dispatching primitives; this new
pragma/aspect is inherited by all descendant types.

gcc/ada/

* aspects.ads (Aspect_First_Controlling_Parameter): New aspect.
Defined as implementation defined aspect that has a static boolean
value and it is converted to pragma when the value is True.
* einfo.ads (Has_First_Controlling_Parameter): New attribute.
* exp_ch9.adb (Build_Corresponding_Record): Propagate the aspect
to the corresponding record type.
(Expand_N_Protected_Type_Declaration): Analyze the inherited
aspect to add the pragma.
(Expand_N_Task_Type_Declaration): ditto.
* freeze.adb (Warn_If_Implicitly_Inherited_Aspects): New
subprogram.
(Has_First_Ctrl_Param_Aspect): New subprogram.
(Freeze_Record_Type): Call Warn_If_Implicitly_Inherited_Aspects.
(Freeze_Subprogram): Check illegal subprograms of tagged types and
interface types that have this new aspect.
* gen_il-fields.ads (Has_First_Controlling_Parameter): New entity
field.
* gen_il-gen-gen_entities.adb (Has_First_Controlling_Parameter):
The new field is a semantic flag.
* gen_il-internals.adb (Image): Add
Has_First_Controlling_Parameter.
* par-prag.adb (Prag): No action for
Pragma_First_Controlling_Parameter since processing is handled
entirely in Sem_Prag.
* sem_ch12.adb (Validate_Private_Type_Instance): When the generic
formal has this new aspect, check that the actual type also has
this aspect.
* sem_ch13.adb (Analyze_One_Aspect): Check that the aspect is
applied to a tagged type or a concurrent type.
* sem_ch3.adb (Analyze_Full_Type_Declaration): Derived tagged
types inherit this new aspect, and also from their implemented
interface types.
(Process_Full_View): Propagate the aspect to the full view.
* sem_ch6.adb (Is_A_Primitive): New subprogram; used to factor
code and also clarify detection of primitives.
* sem_ch9.adb (Check_Interfaces): Propagate this new aspect to the
type implementing interface types.
* sem_disp.adb (Check_Controlling_Formals): Handle tagged type
that has the aspect and has subprograms overriding primitives of
tagged types that lack this aspect.
(Check_Dispatching_Operation): Warn on dispatching primitives
disallowed by this new aspect.
(Has_Predefined_Dispatching_Operation_Name): New subprogram.
(Find_Dispatching_Type): Handle dispatching functions of tagged
types that have the new aspect.
(Find_Primitive_Covering_Interface): For primitives of tagged
types that have the aspect and override a primitive of a parent
type that does not have the aspect, we must temporarily unset
attribute First_Controlling_ Parameter to properly check
conformance.
* sem_prag.ads (Aspect_Specifying_Pragma): Add new pragma.
* sem_prag.adb (Pragma_First_Controlling_Parameter): Handle new
pragma.
* snames.ads-tmpl (Name_First_Controlling_Parameter): New name.
* warnsw.ads (Warn_On_Non_Dispatching_Primitives): New warning.
* warnsw.adb (Warn_On_Non_Dispatching_Primitives): New warning;
not set by default when GNAT_Mode warnings are enabled, nor when
all warnings are enabled (-gnatwa).

11 months agofortran: Minor fix to -ffrontend-optimize description
Gerald Pfeifer [Fri, 23 Aug 2024 08:02:15 +0000 (10:02 +0200)] 
fortran: Minor fix to -ffrontend-optimize description

gcc/fortran:
* invoke.texi (Code Gen Options): Add a missing word.

11 months agodoc: Specifically link to GPL v3.0 for GM2
Gerald Pfeifer [Tue, 20 Aug 2024 22:50:01 +0000 (00:50 +0200)] 
doc: Specifically link to GPL v3.0 for GM2

The generic GPL link redirects to GPL v3.0 right now, but may redirect
to a different version at one point. Specifically link to the version we
are using

gcc:
* doc/gm2.texi (License): Specifically link to GPL v3.0

11 months agoRemove unnecessary view_convert obsoleted by [PR86468].
Andre Vehreschild [Wed, 21 Aug 2024 09:22:57 +0000 (11:22 +0200)] 
Remove unnecessary view_convert obsoleted by [PR86468].

This patch removes an unnecessary view_convert in trans_associate to
prevent hard to find runtime errors in the future.  The view_convert was
erroneously introduced not understanding why ranks of the arrays to
assign are different.  The ranks are fixed by PR86468 now and the
view_convert is obsolete.

gcc/fortran/ChangeLog:

PR fortran/86468

* trans-stmt.cc (trans_associate_var): Remove superfluous
view_convert.

11 months agotestsuite: Fix vect-mod-var.c for division by 0 [PR116461]
Andrew Pinski [Fri, 23 Aug 2024 04:15:21 +0000 (21:15 -0700)] 
testsuite: Fix vect-mod-var.c for division by 0 [PR116461]

The testcase cc.dg/vect/vect-mod-var.c has an division by 0
which is undefined. On some targets (aarch64), the scalar and
the vectorized version, the result of division by 0 is the same.
While on other targets (x86), we get a SIGFAULT. On other targets (powerpc),
the results are different.

The fix is to make sure the testcase does not test division by 0 (or really mod by 0).

Pushed as obvious after testing on x86_64-linux-gnu to make sure the testcase passes
now.

PR testsuite/116461

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-mod-var.c: Change the initialization loop so that
`b[i]` is never 0. Use 1 in those places.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 months agoDaily bump.
GCC Administrator [Fri, 23 Aug 2024 00:17:24 +0000 (00:17 +0000)] 
Daily bump.

11 months agotestsuite: Fix gcc.dg/torture/pr116420.c for targets default unsigned char [PR116464]
Andrew Pinski [Thu, 22 Aug 2024 21:50:47 +0000 (14:50 -0700)] 
testsuite: Fix gcc.dg/torture/pr116420.c for targets default unsigned char [PR116464]

This is an obvious fix to the gcc.dg/torture/pr116420.c testcase which simplier
changes from plain `char` to `signed char` so it works on targets where plain char defaults
to unsigned.

Pushed as obvious after a quick test for aarch64-linux-gnu to make sure the testcase
passes now.

PR testsuite/116464

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116420.c:

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 months ago[PR rtl-optimization/116420] Fix interesting block bitmap DF dataflow
Jeff Law [Thu, 22 Aug 2024 18:48:49 +0000 (12:48 -0600)] 
[PR rtl-optimization/116420] Fix interesting block bitmap DF dataflow

The DF framework provides us a way to run dataflow problems on sub-graphs.
Naturally a bitmap of interesting blocks is passed into those routines.   At a
confluence point, the DF framework will not mark a block for re-processing if
it's not in that set of interesting blocks.

When ext-dce sets up that set of interesting blocks it's using the wrong
counter.  ie, it's using n_basic_blocks rather than last_basic_block.  If there
are holes in the block indices, some number of blocks won't get marked as
interesting.

In this case the block needing reprocessing has an index higher than
n_basic_blocks.  It never gets reprocessed and the newly found live chunks
don't propagate further up the CFG -- ultimately resulting in a pseudo
appearing to have only the low 8 bits live, when in fact the low 32 bits are
actually live.

Fixed in the obvious way, by using last_basic_block instead.

Bootstrapped and regression tested on x86_64.  Pushing to the trunk.

PR rtl-optimization/116420
gcc/
* ext-dce.cc (ext_dce_init): Fix loop iteration when setting up the
interesting block for DF to analyze.

gcc/testsuite
* gcc.dg/torture/pr116420.c: New test.

11 months agolibstdc++: Add some missing ranges feature-test macro tests
Patrick Palka [Thu, 22 Aug 2024 15:24:07 +0000 (11:24 -0400)] 
libstdc++: Add some missing ranges feature-test macro tests

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/contains/1.cc: Verify value of
__cpp_lib_ranges_contains.
* testsuite/25_algorithms/find_last/1.cc: Verify value of
__cpp_lib_ranges_find_last.
* testsuite/26_numerics/iota/2.cc: Verify value of
__cpp_lib_ranges_iota.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 months agoRecompute TYPE_MODE and DECL_MODE for aggregate type for acclerator.
Prathamesh Kulkarni [Thu, 22 Aug 2024 13:55:20 +0000 (19:25 +0530)] 
Recompute TYPE_MODE and DECL_MODE for aggregate type for acclerator.

The patch streams out VOIDmode for aggregate types with offloading enabled,
and recomputes appropriate TYPE_MODE and DECL_MODE while streaming-in on accel
side. The rationale for this change is to avoid streaming out host-specific
modes that may be used for aggregate types, which may not be representable on
the accelerator. For eg, AArch64 uses OImode for ARRAY_TYPE whose size is 256-bits,
and nvptx doesn't have OImode, and thus ends up emitting an error from
lto_input_mode_table.

gcc/ChangeLog:
* lto-streamer-in.cc: (lto_read_tree_1): Set DECL_MODE (expr) to
TREE_TYPE (TYPE_MODE (expr)) if TREE_TYPE (expr) is aggregate type and
offloading is enabled.
* stor-layout.cc (layout_type): Move computation of mode for
ARRAY_TYPE from ...
(compute_array_mode): ... to here.
* stor-layout.h (compute_array_mode): Declare.
* tree-streamer-in.cc: Include stor-layout.h.
(unpack_ts_common_value_fields): Call compute_array_mode if offloading
is enabled.
* tree-streamer-out.cc (pack_ts_fixed_cst_value_fields): Stream out
VOIDmode if decl has aggregate type and offloading is enabled.
(pack_ts_type_common_value_fields): Stream out VOIDmode for aggregate
type if offloading is enabled.

Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
11 months agoRISC-V: Fix vector cfi notes for stack-clash protection
Raphael Moreira Zinsly [Wed, 21 Aug 2024 21:08:54 +0000 (18:08 -0300)] 
RISC-V: Fix vector cfi notes for stack-clash protection

The stack-clash code is generating wrong cfi directives in
riscv_v_adjust_scalable_frame because REG_CFA_DEF_CFA has a different
encoding than REG_FRAME_RELATED_EXPR, this patch fixes the offset sign
in prologue and starts using REG_CFA_DEF_CFA in the epilogue.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_v_adjust_scalable_frame): Add
epilogue code for stack-clash and fix prologue cfi note.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/stack-check-cfa-3.c: Fix the expected output.

11 months agolibstdc++: Optimize std::projected<I, std::identity>
Patrick Palka [Thu, 22 Aug 2024 13:24:39 +0000 (09:24 -0400)] 
libstdc++: Optimize std::projected<I, std::identity>

Algorithms that are generalized to take projections typically default the
projection to std::identity, which is equivalent to no projection at all.
In that case, I believe we could shortcut the projection logic to return
the iterator unchanged rather than wrapping it.  This should reduce compile
times especially after P2609R3 which made the indirect invocability
concepts more expensive to check when actual projections are involved.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (__detail::__projected): Define
an optimized partial specialization for when the projection is
std::identity.
* testsuite/24_iterators/indirect_callable/projected.cc: Verify the
optimization.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 months agolibstdc++: Implement P2997R1 changes to the indirect invocability concepts
Patrick Palka [Thu, 22 Aug 2024 13:24:20 +0000 (09:24 -0400)] 
libstdc++: Implement P2997R1 changes to the indirect invocability concepts

This implements the changes of this C++26 paper as a DR against C++20.

In passing this patch removes the std/ranges/version_c++23.cc test which
is now mostly obsolete after the version.def FTM refactoring, and instead
expands the __cpp_lib_ranges checks in another test so that it verifies
the exact value of the FTM on a per language version basis.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (indirectly_unary_invocable):
Relax as per P2997R1.
(indirectly_regular_unary_invocable): Likewise.
(indirect_unary_predicate): Likewise.
(indirect_binary_predicate): Likewise.
(indirect_equivalence_relation): Likewise.
(indirect_strict_weak_order): Likewise.
* include/bits/version.def (ranges): Update value for C++26.
* include/bits/version.h: Regenerate.
* testsuite/24_iterators/indirect_callable/p2997r1.cc: New test.
* testsuite/std/ranges/version_c++23.cc: Remove.
* testsuite/std/ranges/headers/ranges/synopsis.cc: Refine the
__cpp_lib_ranges checks.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 months agolibstdc++: Implement P2609R3 changes to the indirect invocability concepts
Patrick Palka [Thu, 22 Aug 2024 13:24:11 +0000 (09:24 -0400)] 
libstdc++: Implement P2609R3 changes to the indirect invocability concepts

This implements the changes of this C++23 paper as a DR against C++20.

Note that after the later P2538R1 "ADL-proof std::projected" (which we
already implement), we can't use a simple partial specialization to match
specializations of the 'projected' alias template.  So instead we identify
such specializations using a pair of distinguishing member aliases.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (__detail::__indirect_value):
Define.
(__indirect_value_t): Define as per P2609R3.
(iter_common_reference_t): Adjust as per P2609R3.
(indirectly_unary_invocable): Likewise.
(indirectly_regular_unary_invocable): Likewise.
(indirect_unary_predicate): Likewise.
(indirect_binary_predicate): Likewise.
(indirect_equivalence_relation): Likewise.
(indirect_strict_weak_order): Likewise.
(__detail::__projected::__type): Define member aliases
__projected_Iter and __projected_Proj providing the
template arguments of the current specialization.
* include/bits/version.def (ranges): Update value.
* include/bits/version.h: Regenerate.
* testsuite/24_iterators/indirect_callable/p2609r3.cc: New test.
* testsuite/std/ranges/version_c++23.cc: Update expected value
of __cpp_lib_ranges macro.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 months agoUpdate LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook
H.J. Lu [Wed, 21 Aug 2024 14:25:25 +0000 (07:25 -0700)] 
Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook

This hook allows the BFD linker plugin to distinguish calls to
claim_file_handler that know the object is being used by the linker
(from ldmain.c:add_archive_element), from calls that don't know it's
being used by the linker (from elf_link_is_defined_archive_symbol); in
the latter case, the plugin should avoid including the unused LTO archive
members in link output.  To get the proper support for archives with LTO
common symbols, the linker fix

commit a6f8fe0a9e9cbe871652e46ba7c22d5e9fb86208
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Aug 14 20:50:02 2024 -0700

    lto: Don't include unused LTO archive members in output

is required.

PR lto/116361
* lto-plugin.c (claim_file_handler_v2): Rename claimed to
can_be_claimed.  Include the LTO object only if it is known to
be included in link output.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 months agofold: Fix `a * 1j` if a has side effects [PR116454]
Andrew Pinski [Thu, 22 Aug 2024 00:41:38 +0000 (17:41 -0700)] 
fold: Fix `a * 1j` if a has side effects [PR116454]

The problem here was a missing save_expr around arg0 since
it is used twice, once in REALPART_EXPR and once in IMAGPART_EXPR.
Thia adds the save_expr and reformats the code slightly so it is a
little easier to understand.  It excludes the case when arg0 is
a COMPLEX_EXPR since in that case we'll end up with the distinct
real and imaginary parts.  This is important to retain early
optimization in some testcases.

Bootstapped and tested on x86_64-linux-gnu with no regressions.

PR middle-end/116454

gcc/ChangeLog:

* fold-const.cc (fold_binary_loc): Fix `a * +-1i`
by wrapping arg0 with save_expr when it is not COMPLEX_EXPR.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Co-Authored-By: Richard Biener <rguenther@suse.de>
11 months agofix single argument static_assert
Marc Poulhiès [Thu, 22 Aug 2024 10:46:18 +0000 (12:46 +0200)] 
fix single argument static_assert

Single argument static_assert is C++17 only.

libcpp/ChangeLog:

* lex.cc(search_line_ssse3): fix static_assert to use 2 arguments.

11 months agoPR target/116365: Add user-friendly arguments to --param aarch64-autovec-preference=N
Jennifer Schmitz [Mon, 19 Aug 2024 15:42:55 +0000 (08:42 -0700)] 
PR target/116365: Add user-friendly arguments to --param aarch64-autovec-preference=N

The param aarch64-autovec-preference=N is a useful tool for testing
auto-vectorisation in GCC as it allows the user to force a particular
strategy. So far, N could be a numerical value between 0 and 4.
This patch replaces the numerical values by more user-friendly
names to distinguish the options.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
Ok for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
PR target/116365
* config/aarch64/aarch64-opts.h
(enum aarch64_autovec_preference_enum): New enum.
* config/aarch64/aarch64.cc (aarch64_cmp_autovec_modes):
Change numerical to enum values.
(aarch64_autovectorize_vector_modes): Change numerical to enum
values.
(aarch64_vector_costs::record_potential_advsimd_unrolling):
Change numerical to enum values.
* config/aarch64/aarch64.opt: Change param type to enum.
* doc/invoke.texi: Update documentation.

gcc/testsuite/
PR target/116365
* gcc.target/aarch64/autovec_param_asimd-only.c: New test.
* gcc.target/aarch64/autovec_param_default.c: Likewise.
* gcc.target/aarch64/autovec_param_prefer-asimd.c: Likewise.
* gcc.target/aarch64/autovec_param_prefer-sve.c: Likewise.
* gcc.target/aarch64/autovec_param_sve-only.c: Likewise.
* gcc.target/aarch64/neoverse_v1_2.c: Update parameter value.
* gcc.target/aarch64/neoverse_v1_3.c: Likewise.
* gcc.target/aarch64/sve/cond_asrd_1.c: Likewise.
* gcc.target/aarch64/sve/cond_cnot_4.c: Likewise.
* gcc.target/aarch64/sve/cond_unary_5.c: Likewise.
* gcc.target/aarch64/sve/cond_uxt_5.c: Likewise.
* gcc.target/aarch64/sve/cond_xorsign_2.c: Likewise.
* gcc.target/aarch64/sve/pr98268-1.c: Likewise.
* gcc.target/aarch64/sve/pr98268-2.c: Likewise.

11 months agoRISC-V: Enable -gvariable-location-views by default
Bernd Edlinger [Mon, 19 Aug 2024 05:11:18 +0000 (07:11 +0200)] 
RISC-V: Enable -gvariable-location-views by default

This affects only the RISC-V targets, where the compiler options
-gvariable-location-views and consequently also -ginline-points
are disabled by default, which is unexpected and disables some
useful features of the generated debug info.

Due to a bug in the gas assembler the .loc statement
is not usable to generate location view debug info.
That is detected by configure:

configure:31500: checking assembler for dwarf2 debug_view support
configure:31509: .../riscv-unknown-elf/bin/as    -o conftest.o conftest.s >&5
conftest.s: Assembler messages:
conftest.s:5: Error: .uleb128 only supports constant or subtract expressions
conftest.s:6: Error: .uleb128 only supports constant or subtract expressions
configure:31512: $? = 1
configure: failed program was
        .file 1 "conftest.s"
        .loc 1 3 0 view .LVU1
        nop
        .data
        .uleb128 .LVU1
        .uleb128 .LVU1

configure:31523: result: no

This results in dwarf2out_as_locview_support being set to false,
and that creates a sequence of events, with the end result that
most inlined functions either have no DW_AT_entry_pc, or one
with a wrong entry pc value.

But the location views can also be generated without using any
.loc statements, therefore we should enable the option
-gvariable-location-views by default, regardless of the status
of -gas-locview-support.

Note however, that the combination of the following compiler options
-g -O2 -gvariable-location-views -gno-as-loc-support
turned out to create invalid assembler intermediate files,
with lots of assembler errors like:
Error: leb128 operand is an undefined symbol: .LVU3

This affects all targets, except RISC-V of course ;-)
and is fixed by the changes in dwarf2out.cc

Finally the .debug_loclists created without assembler locview support
did contain location view pairs like v0000000ffffffff v000000000000000
which is the value from FORCE_RESET_NEXT_VIEW, but that is most likely
not as expected either, so change that as well.

gcc/ChangeLog:

* dwarf2out.cc (dwarf2out_maybe_output_loclist_view_pair,
output_loc_list): Correct handling of -gno-as-loc-support,
use ZERO_VIEW_P to output view number as zero value.
* toplev.cc (process_options): Do not automatically disable
-gvariable-location-views when -gno-as-loc-support or
-gno-as-locview-support is used, instead do automatically
disable -gas-locview-support if -gno-as-loc-support is used.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/dwarf2/inline2.c: Add checks for inline entry_pc.
* gcc.dg/debug/dwarf2/inline6.c: Add -gno-as-loc-support and check
the resulting location views.

11 months agoDo not emit a redundant DW_TAG_lexical_block for inlined subroutines
Bernd Edlinger [Fri, 16 Aug 2024 10:26:27 +0000 (12:26 +0200)] 
Do not emit a redundant DW_TAG_lexical_block for inlined subroutines

While this already works correctly for the case when an inlined
subroutine contains only one subrange, a redundant DW_TAG_lexical_block
is still emitted when the subroutine has multiple blocks.

Fixes: ac02e5b75451 ("re PR debug/37801 (DWARF output for inlined functions
                      doesn't always use DW_TAG_inlined_subroutine)")

gcc/ChangeLog:

PR debug/87440
* dwarf2out.cc (gen_inlined_subroutine_die): Handle the case
of multiple subranges correctly.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/dwarf2/inline7.c: New test.

11 months agoPR tree-optimization/101390: Vectorize modulo operator
Jennifer Schmitz [Wed, 7 Aug 2024 15:56:45 +0000 (08:56 -0700)] 
PR tree-optimization/101390: Vectorize modulo operator

This patch adds a new vectorization pattern that detects the modulo
operation where the second operand is a variable.
It replaces the statement by division, multiplication, and subtraction.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
Ok for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
PR tree-optimization/101390
* tree-vect-patterns.cc (vect_recog_mod_var_pattern): Add new pattern.

gcc/testsuite/
PR tree-optimization/101390
* gcc.dg/vect/vect-mod-var.c: New test.
* gcc.target/aarch64/sve/mod_1.c: Likewise.
* lib/target-supports.exp: New selector expression.

11 months agoDump aliases in -fcallgraph-info
Alexandre Oliva [Thu, 22 Aug 2024 04:27:55 +0000 (01:27 -0300)] 
Dump aliases in -fcallgraph-info

Dump ICF-unified decls, thunks, aliases and whatnot along with their
ultimate targets, with edges from the alias to the target.

Add support for dropping the source file's suffix when forming from
dump-base, so that auxiliary files can be scanned, such as the .ci
files generated by -fcallgraph-info, as in the testcase.

for  gcc/ChangeLog

* toplev.cc (dump_final_alias_vcg): New.
(dump_final_node_vcg): Dump aliases along with node.

for  gcc/testsuite/ChangeLog

* lib/scandump.exp (dump-base): Support {} in dump base suffix
to drop it.
* gcc.dg/callgraph-info-1.c: New.

11 months agoMakefile.tpl: fix whitespace in licence header
Sam James [Wed, 14 Aug 2024 12:25:01 +0000 (13:25 +0100)] 
Makefile.tpl: fix whitespace in licence header

* Makefile.in: Regenerate.
* Makefile.tpl: Fix whitespace.

Signed-off-by: Sam James <sam@gentoo.org>
11 months agoMakefile.tpl: drop leftover intermodule cruft
Sam James [Wed, 14 Aug 2024 12:22:02 +0000 (13:22 +0100)] 
Makefile.tpl: drop leftover intermodule cruft

intermodule supported was dropped in r0-103106-gde6ba7aee152a0 with some
remaining bits for Fortran removed in r14-1696-gecc96eb5d2a0e5.

Remove some small leftovers.

* Makefile.in: Regenerate.
* Makefile.tpl (STAGE1_CONFIGURE_FLAGS): Remove --disable-intermodule.

11 months agoAlign ix86_{move_max,store_max} with vectorizer.
liuhongt [Thu, 15 Aug 2024 04:54:07 +0000 (12:54 +0800)] 
Align ix86_{move_max,store_max} with vectorizer.

When none of mprefer-vector-width, avx256_optimal/avx128_optimal,
avx256_store_by_pieces/avx512_store_by_pieces is specified, GCC will
set ix86_{move_max,store_max} as max available vector length except
for AVX part.

      if (TARGET_AVX512F_P (opts->x_ix86_isa_flags)
  && TARGET_EVEX512_P (opts->x_ix86_isa_flags2))
opts->x_ix86_move_max = PVW_AVX512;
      else
opts->x_ix86_move_max = PVW_AVX128;

So for -mavx2, vectorizer will choose 256-bit for vectorization, but
128-bit is used for struct copy, there could be a potential STLF issue
due to this "misalign".

The patch fixes that.

gcc/ChangeLog:

* config/i386/i386-options.cc (ix86_option_override_internal):
set ix86_{move_max,store_max} to PVW_AVX256 when TARGET_AVX
instead of PVW_AVX128.

gcc/testsuite/ChangeLog:
* gcc.target/i386/pieces-memcpy-10.c: Add -mprefer-vector-width=128.
* gcc.target/i386/pieces-memcpy-6.c: Ditto.
* gcc.target/i386/pieces-memset-38.c: Ditto.
* gcc.target/i386/pieces-memset-40.c: Ditto.
* gcc.target/i386/pieces-memset-41.c: Ditto.
* gcc.target/i386/pieces-memset-42.c: Ditto.
* gcc.target/i386/pieces-memset-43.c: Ditto.
* gcc.target/i386/pieces-strcpy-2.c: Ditto.
* gcc.target/i386/pieces-memcpy-22.c: New test.
* gcc.target/i386/pieces-memset-51.c: New test.
* gcc.target/i386/pieces-strcpy-3.c: New test.

11 months agoDaily bump.
GCC Administrator [Thu, 22 Aug 2024 00:18:14 +0000 (00:18 +0000)] 
Daily bump.

11 months agoRISC-V: Add testcases for unsigned vector .SAT_TRUNC form 3
Pan Li [Wed, 21 Aug 2024 09:57:47 +0000 (17:57 +0800)] 
RISC-V: Add testcases for unsigned vector .SAT_TRUNC form 3

This patch would like to add test cases for the unsigned vector
.SAT_TRUNC form 3.  Aka:

Form 3:
  #define DEF_VEC_SAT_U_TRUNC_FMT_3(NT, WT)                             \
  void __attribute__((noinline))                                        \
  vec_sat_u_trunc_##NT##_##WT##_fmt_3 (NT *out, WT *in, unsigned limit) \
  {                                                                     \
    unsigned i;                                                         \
    for (i = 0; i < limit; i++)                                         \
      {                                                                 \
        WT max = (WT)(NT)-1;                                            \
        out[i] = in[i] <= max ? (NT)in[i] : (NT)max;                    \
      }                                                                 \
  }

DEF_VEC_SAT_U_TRUNC_FMT_3 (uint32_t, uint64_t)

The below test is passed for this patch.
* The rv64gcv regression test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper macros.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-13.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-14.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-15.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-16.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-17.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-18.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-13.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-14.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-15.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-16.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-17.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-18.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
11 months agoRISC-V: Add testcases for unsigned vector .SAT_TRUNC form 2
Pan Li [Wed, 21 Aug 2024 09:43:12 +0000 (17:43 +0800)] 
RISC-V: Add testcases for unsigned vector .SAT_TRUNC form 2

This patch would like to add test cases for the unsigned vector
.SAT_TRUNC form 2.  Aka:

Form 2:
  #define DEF_VEC_SAT_U_TRUNC_FMT_2(NT, WT)                             \
  void __attribute__((noinline))                                        \
  vec_sat_u_trunc_##NT##_##WT##_fmt_2 (NT *out, WT *in, unsigned limit) \
  {                                                                     \
    unsigned i;                                                         \
    for (i = 0; i < limit; i++)                                         \
      {                                                                 \
        WT max = (WT)(NT)-1;                                            \
        out[i] = in[i] > max ? (NT)max : (NT)in[i];                     \
      }                                                                 \
  }

DEF_VEC_SAT_U_TRUNC_FMT_2 (uint32_t, uint64_t)

The below test is passed for this patch.
* The rv64gcv regression test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper macros.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-10.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-11.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-12.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-7.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-8.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-9.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-10.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-11.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-12.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-7.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-8.c: New test.
* gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-run-9.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
11 months ago[PR rtl-optimization/116437] Fix RTL checking issue in ext-dce
Jeff Law [Wed, 21 Aug 2024 22:52:23 +0000 (16:52 -0600)] 
[PR rtl-optimization/116437] Fix RTL checking issue in ext-dce

Another RTL checking failure in ext-dce.  An easy one to fix this time.

When we optimize an extension we have to go back and cleanup with
SUBREG_PROMOTED state.  So we record the destination register into a bitmap as
we make changes, then later do a single pass over the IL fixing any associated
subreg expressions.

The optimization is changing the SET_SRC and largely ignores the destination.
The LHS could be a REG, SUBREG, or ZERO_EXTRACT.  If the LHS is a SUBREG or
ZERO_EXTRACT we can just strip them.

Bootstrapped and ran the testsuite with an RTL checking compiler and verified
no ext-dce RTL checking failures tripped.  Also bootstrapped and regression
tested x86_64 in the usual way.

Pushing to the trunk.

PR rtl-optimization/116437
gcc/
* ext-dce.cc (ext_dce_try_optimize_insn): Handle SUBREG and
ZERO_EXTRACT destinations.

11 months agoaarch64: Fix caller saves of VNx2QI [PR116238]
Richard Sandiford [Wed, 21 Aug 2024 16:35:47 +0000 (17:35 +0100)] 
aarch64: Fix caller saves of VNx2QI [PR116238]

The testcase contains a VNx2QImode pseudo that is live across a call
and that cannot be allocated a call-preserved register.  LRA quite
reasonably tried to save it before the call and restore it afterwards.
Unfortunately, the target told it to do that in SImode, even though
punning between SImode and VNx2QImode is disallowed by both
TARGET_CAN_CHANGE_MODE_CLASS and TARGET_MODES_TIEABLE_P.

The natural class to use for SImode is GENERAL_REGS, so this led
to an unsalvageable situation in which we had:

  (set (subreg:VNx2QI (reg:SI A) 0) (reg:VNx2QI B))

where A needed GENERAL_REGS and B needed FP_REGS.  We therefore ended
up in a reload loop.

The hooks above should ensure that this situation can never occur
for incoming subregs.  It only happened here because the target
explicitly forced it.

The decision to use SImode for modes smaller than 4 bytes dates
back to the beginning of the port, before 16-bit floating-point
modes existed.  I'm not sure whether promoting to SImode really
makes sense for any FPR, but that's a separate performance/QoI
discussion.  For now, this patch just disallows using SImode
when it is wrong for correctness reasons, since that should be
safer to backport.

gcc/
PR testsuite/116238
* config/aarch64/aarch64.cc (aarch64_hard_regno_caller_save_mode):
Only return SImode if we can convert to and from it.

gcc/testsuite/
PR testsuite/116238
* gcc.target/aarch64/sve/pr116238.c: New test.

11 months agoaarch64: Implement popcountti2 pattern [PR113042]
Andrew Pinski [Fri, 16 Aug 2024 18:18:31 +0000 (11:18 -0700)] 
aarch64: Implement popcountti2 pattern [PR113042]

When CSSC is not enabled, 128bit popcount can be implemented
just via the vector (v16qi) cnt instruction followed by a reduction,
like how the 64bit one is currently implemented instead of
splitting into 2 64bit popcount.

Changes since v1:
* v2: Make operand 0 be DImode instead of TImode and simplify.

Build and tested for aarch64-linux-gnu.

PR target/113042

gcc/ChangeLog:

* config/aarch64/aarch64.md (popcountti2): New define_expand.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/popcnt10.c: New test.
* gcc.target/aarch64/popcnt9.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 months agotree-optimization/116406 - ICE with int<->float punning prevention
Richard Biener [Wed, 21 Aug 2024 12:15:33 +0000 (14:15 +0200)] 
tree-optimization/116406 - ICE with int<->float punning prevention

The following does away with the idea to use non-symmetrical
testing of mode_can_transfer_bits in hash-table equality testing.
It isn't feasible to always control query order to maintain
consistency.

PR tree-optimization/116406
* tree-ssa-sccvn.cc (vn_reference_eq): Never equate
float and int when the float mode cannot transfer bits.
Do not try to anticipate which is the mode we actually load
from.

* gcc.dg/tree-ssa/pr116406.c: New testcase.
* gcc.dg/tree-ssa/ssa-pre-30.c: On x86 dd -msse -mfpmath=sse.

11 months agosra: Avoid risking x87 magling binary representation of a replacement (PR 58416)
Martin Jambor [Wed, 21 Aug 2024 12:49:11 +0000 (14:49 +0200)] 
sra: Avoid risking x87 magling binary representation of a replacement (PR 58416)

PR 58416 shows that storing non-floating point data to floating point
scalar registers can lead to miscompilations when the data is
normalized or otherwise processed upon loading to a register.  To
avoid that risk, this patch detects situations where we have multiple
types and a we decide to represent the data in a type with a mode that
is known to not be able to transfer actual bits reliably using the new
TARGET_MODE_CAN_TRANSFER_BITS hook.

gcc/ChangeLog:

2024-08-19  Martin Jambor  <mjambor@suse.cz>

PR target/58416
* tree-sra.cc (types_risk_mangled_binary_repr_p): New function.
(sort_and_splice_var_accesses): Use it.
(propagate_subaccesses_from_rhs): Likewise.

gcc/testsuite/ChangeLog:

2024-08-19  Martin Jambor  <mjambor@suse.cz>

PR target/58416
* gcc.dg/torture/pr58416.c: New test.

11 months agotree-optimization/116380 - bogus SSA update with loop distribution
Richard Biener [Wed, 21 Aug 2024 11:56:40 +0000 (13:56 +0200)] 
tree-optimization/116380 - bogus SSA update with loop distribution

When updating LC PHIs after copying loops we have to handle defs
defined outside of the loop appropriately (by not setting them to
NULL ...).  This mimics how we handle this in the SSA updating
code of the vectorizer.

PR tree-optimization/116380
* tree-loop-distribution.cc (copy_loop_before): Handle
out-of-loop defs appropriately.

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

11 months agolibstdc++: Use strlen for std::char_traits<char8_t>::length [PR102958]
Jonathan Wakely [Tue, 9 Jan 2024 16:19:20 +0000 (16:19 +0000)] 
libstdc++: Use strlen for std::char_traits<char8_t>::length [PR102958]

libstdc++-v3/ChangeLog:

PR tree-optimization/102958
* include/bits/char_traits.h (char_traits<char8_t>::length): Use
strlen.

11 months agolibstdc++: Check ios::uppercase for ios::fixed floating-point output [PR114862]
Jonathan Wakely [Wed, 8 May 2024 09:03:20 +0000 (10:03 +0100)] 
libstdc++: Check ios::uppercase for ios::fixed floating-point output [PR114862]

This is LWG 4084 which I filed recently. LWG seems to support making the
change, so that std::num_put can use the %F format for floating-point
numbers.

libstdc++-v3/ChangeLog:

PR libstdc++/114862
* src/c++98/locale_facets.cc (__num_base::_S_format_float):
Check uppercase flag for fixed format.
* testsuite/22_locale/num_put/put/char/lwg4084.cc: New test.

11 months agoFix coarray rank for non-coarrays in derived types. [PR86468]
Andre Vehreschild [Fri, 16 Aug 2024 13:07:39 +0000 (15:07 +0200)] 
Fix coarray rank for non-coarrays in derived types. [PR86468]

The corank was propagated to array components in derived types.  Fix
this by setting a zero corank when the array component is not a pointer.
For pointer typed array components propagate the corank of the derived
type to allow associating the component to a coarray.

gcc/fortran/ChangeLog:

PR fortran/86468

* trans-intrinsic.cc (conv_intrinsic_move_alloc): Correct
comment.
* trans-types.cc (gfc_sym_type): Pass coarray rank, not false.
(gfc_get_derived_type): Only propagate codimension for coarrays
and pointers to array components in derived typed coarrays.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray_lib_this_image_2.f90: Fix array rank in
tree dump scan.
* gfortran.dg/coarray_lib_token_4.f90: Same.
* gfortran.dg/coarray/move_alloc_2.f90: New test.

11 months agolibstdc++: Fix std::variant to reject array types [PR116381]
Jonathan Wakely [Tue, 20 Aug 2024 15:52:22 +0000 (16:52 +0100)] 
libstdc++: Fix std::variant to reject array types [PR116381]

libstdc++-v3/ChangeLog:

PR libstdc++/116381
* include/std/variant (variant): Fix conditions for
static_assert to match the spec.
* testsuite/20_util/variant/types_neg.cc: New test.

11 months agoc++, coroutines: Check for malformed functions before splitting.
Iain Sandoe [Wed, 14 Aug 2024 12:30:30 +0000 (13:30 +0100)] 
c++, coroutines: Check for malformed functions before splitting.

This performs the same basic check that is done by finish_function
to catch cases where the function is so badly malformed that we
do not have a consistent binding level.

gcc/cp/ChangeLog:

* coroutines.cc (split_coroutine_body_from_ramp): Check
that the binding level is as expected before attempting
to outline the function body.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
11 months agotestsuite: i386: Fix g++.target/i386/pr116275-2.C on Solaris/x86
Rainer Orth [Wed, 21 Aug 2024 08:04:07 +0000 (10:04 +0200)] 
testsuite: i386: Fix g++.target/i386/pr116275-2.C on Solaris/x86

The new g++.target/i386/pr116275-2.C test FAILs on 32-bit Solaris/x86:

FAIL: g++.target/i386/pr116275-2.C   scan-assembler vpslld

This happens because Solaris defaults to -mstackrealign, disabling -mstv.

Fixed by disabling the former and enabling the latter.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2024-08-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* g++.target/i386/pr116275-2.C (dg-options): Add -mstv
-mno-stackrealign.

11 months agoFortran: Fix ICE in sizeof(coarray) [PR77518]
Andre Vehreschild [Thu, 18 Jul 2024 12:53:31 +0000 (14:53 +0200)] 
Fortran: Fix ICE in sizeof(coarray) [PR77518]

Use se's class_container where present in sizeof().

PR fortran/77518

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_sizeof): Use
class_container of se when set.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/sizeof_1.f90: New test.

11 months agors6000: Remove "+" constraint modifier from *vsx_le_perm_store_* insns
Kewen Lin [Wed, 21 Aug 2024 05:26:20 +0000 (00:26 -0500)] 
rs6000: Remove "+" constraint modifier from *vsx_le_perm_store_* insns

Since *vsx_le_perm_store_* can be split into vector
permute and vector store, after reload_completed, we reuse
the operand 1 as the destination of vector permute, so we
set operand 1 with constraint modifier "+".  But since
it's taken as pure input in DF and most passes as Richard
pointed out in [1], to ensure it's correct when operand 1
is still live, we actually restore the operand 1's value
after the store with vector permute, that is:
  op1 = vector permute op1 (doubleword swapping)
  op0 = op2
  op1 = vector permute op1 (doubleword swapping)
, it means op1's value isn't changed by this insn.

So according to the comments from Richard and Segher in
that thread, this patch is to remove the "+" constraint
modifier of operand 1 from *vsx_le_perm_store_* insns.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660145.html

gcc/ChangeLog:

* config/rs6000/vsx.md (define_insn *vsx_le_perm_store_{<VSX_D:mode>,
<VSX_W:mode>,v8hi,v16qi,<VSX_LE_128:mode>}): Remove constraint modifier
"+" from operand 1.

11 months agors6000: Fix vsx_le_perm_store_* splitters for !reload_completed
Kewen Lin [Wed, 21 Aug 2024 05:26:20 +0000 (00:26 -0500)] 
rs6000: Fix vsx_le_perm_store_* splitters for !reload_completed

For vsx_le_perm_store_* we have two splitters, one is for
!reload_completed and the other is for reload_completed.
As Richard pointed out in [1], operand 1 here is a pure
input for DF and most passes, but it could be used as the
vector rotation (64 bit) destination of itself, so we
re-compute the source (back to the original value) for
the case reload_completed, while for !reload_completed we
generate one new pseudo, so both cases are fine if operand
1 is still live after this insn.  But according to the
source code, for !reload_completed case, it can logically
reuse the operand 1 as the new pseudo generation is
conditional on can_create_pseudo_p, then it can cause
wrong result once operand 1 is live.  So considering this
and there is no splitting for this when reload_in_progress,
this patch is to fix the code to assert can_create_pseudo_p
there, so that both !reload_completed and reload_completed
cases would ensure operand 1 is unchanged (pure input), it
is also prepared for the following up patch which would
strip the unnecessary INOUT constraint modifier "+".

This also fixes an oversight in the splitter for VSX_LE_128
(!reload_completed), it should use operand 1 rather than
operand 0.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660145.html

gcc/ChangeLog:

* config/rs6000/vsx.md (*vsx_le_perm_store_{<VSX_D:mode>,<VSX_W:mode>,
v8hi,v16qi,<VSX_LE_128:mode>} !reload_completed splitters): Assert
can_create_pseudo_p and always generate one new pseudo for operand 1.

11 months agotestsuite, rs6000: Remove all powerpc-*paired* uses
Kewen Lin [Wed, 21 Aug 2024 05:26:20 +0000 (00:26 -0500)] 
testsuite, rs6000: Remove all powerpc-*paired* uses

Similar to r15-710-g458b23bc8b3e2b which removed all uses of
powerpc-*-linux*paired*, this patch is to remove the remaining
powerpc-*paired* uses which I missed to catch with "*linux*"
in search keyword.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_vect_support_and_set_flags): Remove
the if arm checking powerpc-*paired*.
(check_750cl_hw_available): Remove.
(check_effective_target_vect_unpack): Remove the check on
powerpc-*paired*.

11 months agoAlign predicates for operands[1] between mov<mode> and *mov<mode>_internal.
liuhongt [Tue, 20 Aug 2024 06:41:00 +0000 (14:41 +0800)] 
Align predicates for operands[1] between mov<mode> and *mov<mode>_internal.

 > It's not obvious to me why movv16qi requires a nonimmediate_operand
> > source, especially since ix86_expand_vector_mode does have code to
> > cope with constant operand[1]s.  emit_move_insn_1 doesn't check the
> > predicates anyway, so the predicate will have little effect.
> >
> > A workaround would be to check legitimate_constant_p instead of the
> > predicate, but I'm not sure that that should be necessary.
> >
> > Has this already been discussed?  If not, we should loop in the x86
> > maintainers (but I didn't do that here in case it would be a repeat).
>
> I also noticed it. Not sure why movv16qi requires a
> nonimmediate_operand, while ix86_expand_vector_mode could deal with
> constant op. Looking forward to Hongtao's comments.
The code has been there since 2005 before I'm involved.
 It looks to me at the beginning both mov<mode> and
*mov<mode>_internal only support nonimmediate_operand for the
operands[1].
And r0-75606-g5656a184e83983 adjusted the nonimmediate_operand to
nonimmediate_or_sse_const_operand for *mov<mode>_internal, but not for
mov<mode>. I think we can align the predicate between mov<mode>
and *mov<mode>_internal.

gcc/ChangeLog:

* config/i386/sse.md (mov<mode>): Align predicates for
operands[1] between mov<mode> and *mov<mode>_internal.
* config/i386/mmx.md (mov<mode>): Ditto.

11 months agoDaily bump.
GCC Administrator [Wed, 21 Aug 2024 00:19:34 +0000 (00:19 +0000)] 
Daily bump.

11 months agobuiltins: Don't expand bit query builtins for __int128_t if the target supports an...
Andrew Pinski [Fri, 16 Aug 2024 07:39:32 +0000 (00:39 -0700)] 
builtins: Don't expand bit query builtins for __int128_t if the target supports an optab for it

On aarch64 (without !CSSC instructions), since popcount is implemented using the SIMD instruction cnt,
instead of using two SIMD cnt (V8QI mode), it is better to use one 128bit cnt (V16QI mode). And only one
reduction addition instead of 2. Currently fold_builtin_bit_query will expand always without checking
if there was an optab for the type, so this changes that to check the optab to see if we should expand
or have the backend handle it.

Bootstrapped and tested on x86_64-linux-gnu and built and tested for aarch64-linux-gnu.

gcc/ChangeLog:

* builtins.cc (fold_builtin_bit_query): Don't expand double
`unsigned long long` typess if there is an optab entry for that
type.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 months agoASAN: call initialize_sanitizer_builtins for hwasan [PR115205]
Andrew Pinski [Mon, 12 Aug 2024 04:26:59 +0000 (21:26 -0700)] 
ASAN: call initialize_sanitizer_builtins for hwasan [PR115205]

Sometimes initialize_sanitizer_builtins is not called before emitting
the asan builtins with hwasan. In the case of the bug report, there
was a path with the fortran front-end where it was not called.
So let's call it in asan_instrument before calling transform_statements
and from hwasan_finish_file.

Built and tested for aarch64-linux-gnu with no regressions.

Changes since v1:
* v2: Add call of asan_instrument to hwasan_finish_file also.

gcc/ChangeLog:

PR sanitizer/115205
* asan.cc (asan_instrument): Call initialize_sanitizer_builtins
for hwasan.
(hwasan_finish_file): Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 months agoRISC-V: Fix one typo in .SAT_TRUNC test func name [NFC]
Pan Li [Tue, 20 Aug 2024 13:08:23 +0000 (21:08 +0800)] 
RISC-V: Fix one typo in .SAT_TRUNC test func name [NFC]

Fix one typo `sat_truc` to `sat_trunc`, as well as `SAT_TRUC` to `SAT_TRUNC`.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_arith.h: Fix SAT_TRUNC typo.
* gcc.target/riscv/sat_u_trunc-1.c: Ditto.
* gcc.target/riscv/sat_u_trunc-13.c: Ditto.
* gcc.target/riscv/sat_u_trunc-14.c: Ditto.
* gcc.target/riscv/sat_u_trunc-15.c: Ditto.
* gcc.target/riscv/sat_u_trunc-2.c: Ditto.
* gcc.target/riscv/sat_u_trunc-3.c: Ditto.
* gcc.target/riscv/sat_u_trunc-4.c: Ditto.
* gcc.target/riscv/sat_u_trunc-5.c: Ditto.
* gcc.target/riscv/sat_u_trunc-6.c: Ditto.
* gcc.target/riscv/sat_u_trunc-7.c: Ditto.
* gcc.target/riscv/sat_u_trunc-8.c: Ditto.
* gcc.target/riscv/sat_u_trunc-9.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-1.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-13.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-14.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-15.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-2.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-3.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-4.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-5.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-6.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-7.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-8.c: Ditto.
* gcc.target/riscv/sat_u_trunc-run-9.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
11 months agoc++/modules: Remove unnecessary errors when not writing compiled module
Nathaniel Shead [Sun, 18 Aug 2024 11:35:23 +0000 (21:35 +1000)] 
c++/modules: Remove unnecessary errors when not writing compiled module

It was pointed out to me that the current error referencing an internal
linkage entity reads almost like an ICE message, with the message
finishing with the unhelpful:

m.cpp:1:8: error: failed to write compiled module: Bad file data
    1 | export module M;
      |        ^~~~~~

Similarly, whenever we decide not to emit a module CMI due to other
errors we currently emit the following message:

m.cpp:1:8: warning: not writing module ‘M’ due to errors
    1 | export module M;
      |        ^~~~~~

Neither of these messages really add anything useful; users already
understand that when an error is reported then the normal outputs will
not be created, so these messages are just noise.

There is one case we still need this latter message, however; when an
error in a template has been silenced with '-Wno-template-body' we still
don't want to write a module CMI, so emit an error now instead.

This patch also removes a number of dg-prune-output directives in the
testsuite that are no longer needed with this change.

gcc/cp/ChangeLog:

* module.cc (module_state::write_begin): Return a boolean to
indicate errors rather than just doing set_error().
(finish_module_processing): Prevent emission of unnecessary
errors; only indicate module writing occurred if write_begin
succeeds.

gcc/testsuite/ChangeLog:

* g++.dg/modules/export-1.C: Remove message.
* g++.dg/modules/internal-1.C: Remove message.
* g++.dg/modules/ambig-2_b.C: Remove unnecessary pruning.
* g++.dg/modules/atom-decl-2.C: Likewise.
* g++.dg/modules/atom-pragma-3.C: Likewise.
* g++.dg/modules/atom-preamble-2_f.C: Likewise.
* g++.dg/modules/block-decl-2.C: Likewise.
* g++.dg/modules/dir-only-4.C: Likewise.
* g++.dg/modules/enum-12.C: Likewise.
* g++.dg/modules/exp-xlate-1_b.C: Likewise.
* g++.dg/modules/export-3.C: Likewise.
* g++.dg/modules/friend-3.C: Likewise.
* g++.dg/modules/friend-5_b.C: Likewise.
* g++.dg/modules/inc-xlate-1_e.C: Likewise.
* g++.dg/modules/linkage-2.C: Likewise.
* g++.dg/modules/local-extern-1.C: Likewise.
* g++.dg/modules/main-1.C: Likewise.
* g++.dg/modules/map-2.C: Likewise.
* g++.dg/modules/mod-decl-1.C: Likewise.
* g++.dg/modules/mod-decl-3.C: Likewise.
* g++.dg/modules/pr99174.H: Likewise.
* g++.dg/modules/pr99468.H: Likewise.
* g++.dg/modules/token-1.C: Likewise.
* g++.dg/modules/token-3.C: Likewise.
* g++.dg/modules/token-4.C: Likewise.
* g++.dg/modules/token-5.C: Likewise.
* g++.dg/modules/using-10.C: Likewise.
* g++.dg/modules/using-12.C: Likewise.
* g++.dg/modules/using-3.C: Likewise.
* g++.dg/modules/using-9.C: Likewise.
* g++.dg/modules/using-enum-2.C: Likewise.
* g++.dg/modules/permissive-error-1.C: New test.
* g++.dg/modules/permissive-error-2.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
11 months agomatch: Reject non-ssa name/min invariants in gimple_extract [PR116412]
Andrew Pinski [Mon, 19 Aug 2024 15:06:36 +0000 (08:06 -0700)] 
match: Reject non-ssa name/min invariants in gimple_extract [PR116412]

After the conversion for phiopt's conditional operand
to use maybe_push_res_to_seq, it was found that gimple_extract
will extract out from REALPART_EXPR/IMAGPART_EXPR/VCE and BIT_FIELD_REF,
a memory load. But that extraction was not needed as memory loads are not
simplified in match and simplify. So gimple_extract should return false
in those cases.

Changes since v1:
* Move the rejection to gimple_extract from factor_out_conditional_operation.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116412

gcc/ChangeLog:

* gimple-match-exports.cc (gimple_extract): Return false if op0
was not a SSA name nor a min invariant for REALPART_EXPR/IMAGPART_EXPR/VCE
and BIT_FIELD_REF.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 months agolibstdc++: Remove redundant reclaration of std::optional
Jonathan Wakely [Tue, 20 Aug 2024 10:54:25 +0000 (11:54 +0100)] 
libstdc++: Remove redundant reclaration of std::optional

We've already declared optional at the top of the header, so don't need
to do it again.

libstdc++-v3/ChangeLog:

* include/std/optional: Remove redundant redeclaration.

11 months agolibstdc++: Fix indentation of lines that follow a [[likely]] attribute
Jonathan Wakely [Mon, 19 Aug 2024 15:56:28 +0000 (16:56 +0100)] 
libstdc++: Fix indentation of lines that follow a [[likely]] attribute

libstdc++-v3/ChangeLog:

* include/std/text_encoding: Fix indentation.

11 months agolibstdc++: Adjust testcase for constexpr placement new [PR115744]
Jonathan Wakely [Tue, 20 Aug 2024 20:47:29 +0000 (21:47 +0100)] 
libstdc++: Adjust testcase for constexpr placement new [PR115744]

This test now fails in C++26 mode because the declaration in <new> is
constexpr and the one in the test isn't. Add constexpr to the test.

libstdc++-v3/ChangeLog:

PR libstdc++/115744
* testsuite/18_support/headers/new/synopsis.cc [C++26]: Add
constexpr to placement operator new and operator new[].

11 months agolibcpp: Adjust lang_defaults
Jakub Jelinek [Tue, 20 Aug 2024 20:25:57 +0000 (22:25 +0200)] 
libcpp: Adjust lang_defaults

The table over the years turned to be very wide, 147 columns
and any addition would add a couple of new ones.
We need a 28x23 bit matrix right now.

This patch changes the formatting, so that we need just 2 columns
per new feature and so we have some room for expansion.
In addition, the patch changes it to bitfields, which reduces
.rodata by 532 bytes (so 5.75x reduction of the variable) and
on x86_64-linux grows the cpp_set_lang function by 26 bytes (8.4%
growth).

2024-08-20  Jakub Jelinek  <jakub@redhat.com>

* init.cc (struct lang_flags): Change all members from char
typed fields to unsigned bit-fields.
(lang_defaults): Change formatting of the initializer so that it
fits to 68 columns rather than 147.

11 months agophi-opt: Fix for failing maybe_push_res_to_seq in factor_out_conditional_operation...
Andrew Pinski [Mon, 19 Aug 2024 03:45:35 +0000 (20:45 -0700)] 
phi-opt: Fix for failing maybe_push_res_to_seq in factor_out_conditional_operation [PR 116409]

The code was assuming that maybe_push_res_to_seq would not fail if the gimple_extract_op returned true.
But for some cases when the function is pure rather than const, then it can fail.
This change moves around the code to check the result of maybe_push_res_to_seq instead of assuming it will
always work.

Changes since v1:
* v2: Instead of directly testing non-pure builtin functions change to test if maybe_push_res_to_seq fails.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/116409

gcc/ChangeLog:

* tree-ssa-phiopt.cc (factor_out_conditional_operation): Move
maybe_push_res_to_seq before creating the phi node and the debug dump.
Return false if maybe_push_res_to_seq fails.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>