platform/upstream/gcc.git
22 months agoRISC-V: Add RVV instructions classification
zhongjuzhe [Sat, 27 Aug 2022 10:57:23 +0000 (18:57 +0800)]
RISC-V: Add RVV instructions classification

gcc/ChangeLog:

* config/riscv/riscv.md: Add new type for vector instructions.

22 months agoDaily bump.
GCC Administrator [Mon, 29 Aug 2022 00:16:26 +0000 (00:16 +0000)]
Daily bump.

22 months agors6000: Allow conversions of MMA pointer types [PR106017]
Peter Bergner [Sun, 28 Aug 2022 00:44:16 +0000 (19:44 -0500)]
rs6000: Allow conversions of MMA pointer types [PR106017]

GCC incorrectly disables conversions between MMA pointer types, which
are allowed with clang.  The original intent was to disable conversions
between MMA types and other other types, but pointer conversions should
have been allowed.  The fix is to just remove the MMA pointer conversion
handling code altogether.

gcc/
PR target/106017
* config/rs6000/rs6000.cc (rs6000_invalid_conversion): Remove handling
of MMA pointer conversions.

gcc/testsuite/
PR target/106017
* gcc.target/powerpc/pr106017.c: New test.

22 months agoDaily bump.
GCC Administrator [Sun, 28 Aug 2022 00:16:28 +0000 (00:16 +0000)]
Daily bump.

22 months agod: Merge upstream dmd 817610b16d, phobos b578dfad9
Iain Buclaw [Thu, 25 Aug 2022 17:04:50 +0000 (19:04 +0200)]
d: Merge upstream dmd 817610b16d, phobos b578dfad9

D front-end changes:

    - Import latest bug fixes to mainline.

Phobos changes:

    - Import latest bug fixes to mainline.
    - std.logger module has been moved out of experimental.
    - Removed std.experimental.typecons module.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 817610b16d.
* d-ctfloat.cc (CTFloat::parse): Update for new front-end interface.
* d-lang.cc (d_parse_file): Likewise.
* expr.cc (ExprVisitor::visit (AssignExp *)): Remove handling of array
assignments to non-trivial static and dynamic arrays.
* runtime.def (ARRAYASSIGN): Remove.
(ARRAYASSIGN_L): Remove.
(ARRAYASSIGN_R): Remove.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 817610b16d.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add
core/internal/array/arrayassign.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos b578dfad9.
* src/Makefile.am (PHOBOS_DSOURCES): Remove
std/experimental/typecons.d. Add std/logger package.
* src/Makefile.in: Regenerate.

22 months agolibstdc++: Add test for std::con/disjunction's base class
Patrick Palka [Sat, 27 Aug 2022 14:15:55 +0000 (10:15 -0400)]
libstdc++: Add test for std::con/disjunction's base class

libstdc++-v3/ChangeLog:

* testsuite/20_util/logical_traits/requirements/base_classes.cc: New test.

22 months agoRequire fgraphite effective target for pr106737.c test [PR106737]
Jakub Jelinek [Sat, 27 Aug 2022 07:28:02 +0000 (09:28 +0200)]
Require fgraphite effective target for pr106737.c test [PR106737]

The test uses -floop-parallelize-all which emits a sorry when graphite
isn't configured in.

2022-08-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/106737
* gcc.dg/autopar/pr106737.c: Require fgraphite effective target.

22 months agocontrib: modernize gen_autofdo_event.py
Xi Ruoyao [Mon, 27 Jun 2022 06:15:22 +0000 (14:15 +0800)]
contrib: modernize gen_autofdo_event.py

Python 2 has been EOL'ed for two years.  egrep has been deprecated
for many years and the next grep release will start to print warning if
it is used.

-E option may be unsupported by some non-POSIX grep implementations, but
gcc-auto-profile won't work on non-Linux systems anyway.

contrib/ChangeLog:

* gen_autofdo_event.py: Port to Python 3, and use grep -E
instead of egrep.

gcc/ChangeLog:

* config/i386/gcc-auto-profile: Regenerate.

22 months agoDaily bump.
GCC Administrator [Sat, 27 Aug 2022 00:17:09 +0000 (00:17 +0000)]
Daily bump.

22 months agolibstdc++: Implement LWG 3692/3702 changes to zip_/zip_transform_view
Patrick Palka [Fri, 26 Aug 2022 22:59:36 +0000 (18:59 -0400)]
libstdc++: Implement LWG 3692/3702 changes to zip_/zip_transform_view

libstdc++-v3/ChangeLog:

* include/std/ranges (zip_view::_Iterator::operator<): Remove
as per LWG 3692.
(zip_view::_Iterator::operator>): Likewise.
(zip_view::_Iterator::operator<=): Likewise.
(zip_view::_Iterator::operator>=): Likewise.
(zip_view::_Iterator::operator<=>): Remove three_way_comparable
constraint as per LWG 3692.
(zip_transform_view::_Iterator): Ditto as per LWG 3702.

22 months agolibstdc++: Implement ranges::zip_transform_view from P2321R2
Patrick Palka [Fri, 26 Aug 2022 22:59:20 +0000 (18:59 -0400)]
libstdc++: Implement ranges::zip_transform_view from P2321R2

libstdc++-v3/ChangeLog:

* include/std/ranges (zip_view::_Iterator): Befriend
zip_transform_view.
(__detail::__range_iter_cat): Define.
(zip_transform_view): Define.
(zip_transform_view::_Iterator): Define.
(zip_transform_view::_Sentinel): Define.
(views::__detail::__can_zip_transform_view): Define.
(views::_ZipTransform): Define.
(views::zip_transform): Define.
* testsuite/std/ranges/zip_transform/1.cc: New test.

22 months agolibstdc++: Optimize std::con/disjunction, __and_/__or_, etc
Patrick Palka [Fri, 26 Aug 2022 19:10:57 +0000 (15:10 -0400)]
libstdc++: Optimize std::con/disjunction, __and_/__or_, etc

The internal type-level logical operator traits __and_ and __or_ seem to
have high overhead for a couple of reasons:

  1. They are drop-in replacements for std::con/disjunction, which
     are rigidly specified to form a type that derives from the first
     type argument that caused the overall computation to short-circuit.
     In practice this inheritance property seems to be rarely needed;
     usually all we care about is the value of the overall result.
  2. Their recursive implementations instantiate O(N) class templates
     and form an inheritance chain of depth O(N).

This patch gets rid of this inheritance property of __and_ and __or_
(which seems to be unneeded in the library except indirectly by
std::con/disjunction) which allows us to redefine them non-recursively
as alias templates that yield either false_type or true_type via
enable_if_t and partial ordering of a pair of function templates
(alternatively we could use an equivalent partially specialized class
template, but using function templates appears to be slightly more
efficient).

As for std::con/disjunction, it seems we need to keep implementing them
via a recursive class template for sake of the inheritance property.
But instead of using inheritance recursion, use a recursive member
typedef that gets immediately flattened, so that specializations thereof
now have O(1) instead of O(N) inheritance depth.

In passing, redefine __not_ as an alias template for consistency with
__and_ and __or_, and to remove a layer of indirection.

Together these changes have a substantial effect on compile time and
memory usage for code that heavily uses these internal type traits.
For the following example (which tests constructibility between two
compatible 257-element tuple types):

  #include <tuple>

  #define M(x) x, x

  using ty1 = std::tuple<M(M(M(M(M(M(M(M(int)))))))), int>;
  using ty2 = std::tuple<M(M(M(M(M(M(M(M(int)))))))), long>;

  static_assert(std::is_constructible_v<ty2, ty1>);

memory usage improves ~27% from 440MB to 320MB and compile time improves
~20% from ~2s to ~1.6s (with -std=c++23).

libstdc++-v3/ChangeLog:

* include/std/type_traits (enable_if, __enable_if_t): Define them
earlier.
(__detail::__first_t): Define.
(__detail::__or_fn, __detail::__and_fn): Declare.
(__or_, __and_): Redefine as alias templates in terms of __or_fn
and __and_fn.
(__not_): Redefine as an alias template.
(__detail::__disjunction_impl, __detail::__conjunction_impl):
Define.
(conjuction, disjunction): Redefine in terms of __disjunction_impl
and __conjunction_impl.

22 months agoAdd real_iszero to real.*
Aldy Hernandez [Fri, 26 Aug 2022 14:57:09 +0000 (16:57 +0200)]
Add real_iszero to real.*

We have real_isnegzero but no real_iszero.  We could memcmp with 0,
but that's just ugly.

gcc/ChangeLog:

* real.cc (real_iszero): New.
* real.h (real_iszero): New.

22 months agoAdd set/get functions for negative infinity in real.*
Aldy Hernandez [Sat, 20 Aug 2022 10:41:53 +0000 (12:41 +0200)]
Add set/get functions for negative infinity in real.*

For the frange implementation with endpoints I'm about to contribute,
we need to set REAL_VALUE_TYPEs with negative infinity.  The support
is already there in real.cc, but it is awkward to get at.  One could
call real_inf() and then negate the value, but I've added the ability
to pass the sign argument like many of the existing real.* functions.

I've declared the functions in such a way to avoid changes to the
existing code base:

// Unchanged function returning true for either +-INF.
bool real_isinf (const REAL_VALUE_TYPE *r);
// New overload to be able to specify the sign.
bool real_isinf (const REAL_VALUE_TYPE *r, int sign);
// Replacement function for setting INF, defaults to +INF.
void real_inf (REAL_VALUE_TYPE *, int sign = 0);

gcc/ChangeLog:

* real.cc (real_isinf): New overload.
(real_inf): Add sign argument.
* real.h (real_isinf): New overload.
(real_inf): Add sign argument.

22 months agoc++: Implement -Wself-move warning [PR81159]
Marek Polacek [Mon, 8 Aug 2022 21:45:28 +0000 (17:45 -0400)]
c++: Implement -Wself-move warning [PR81159]

About 5 years ago we got a request to implement -Wself-move, which
warns about useless moves like this:

  int x;
  x = std::move (x);

This patch implements that warning.

PR c++/81159

gcc/c-family/ChangeLog:

* c.opt (Wself-move): New option.

gcc/cp/ChangeLog:

* typeck.cc (maybe_warn_self_move): New.
(cp_build_modify_expr): Call maybe_warn_self_move.

gcc/ChangeLog:

* doc/invoke.texi: Document -Wself-move.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wself-move1.C: New test.

22 months agoMake all default vrange setters set VARYING.
Aldy Hernandez [Fri, 26 Aug 2022 14:58:58 +0000 (16:58 +0200)]
Make all default vrange setters set VARYING.

frange is using some of the default vrange setters, some of which are
leaving the range in an undefined state.  We hadn't noticed this
because neither frange nor unsupported_range, both which use some of
the default implementation, weren't being used much.

We can never go wrong with setting VARYING ;-).

gcc/ChangeLog:

* value-range.cc (vrange::set): Set varying.
(vrange::set_nonzero): Same.
(vrange::set_zero): Same.
(vrange::set_nonnegative): Same.

22 months ago[ranger] x == -0.0 does not mean we can replace x with -0.0
Aldy Hernandez [Fri, 26 Aug 2022 14:55:52 +0000 (16:55 +0200)]
[ranger] x == -0.0 does not mean we can replace x with -0.0

On the true side of x == -0.0, we can't just blindly value propagate
the -0.0 into every use of x because x could be +0.0.

With this change, we only allow the transformation if
!HONOR_SIGNED_ZEROS or if the range is known not to contain 0.

gcc/ChangeLog:

* range-op-float.cc (foperator_equal::op1_range): Do not blindly
copy op2 range when honoring signed zeros.

22 months agoAdd newline when checking path profitability.
Aldy Hernandez [Tue, 23 Aug 2022 06:02:33 +0000 (08:02 +0200)]
Add newline when checking path profitability.

It looks like we're missing a newline for cases where we don't print
anything.

gcc/ChangeLog:

* tree-ssa-threadbackward.cc (possibly_profitable_path_p): Always
add newline.
(profitable_path_p): Same.

22 months agolibstdc++: Simplify std::error_code and std::error_condition
Jonathan Wakely [Fri, 26 Aug 2022 11:55:02 +0000 (12:55 +0100)]
libstdc++: Simplify std::error_code and std::error_condition

This removes the redundant operator=(E) from std::error_code and
std::error_condition. Without that overload, assignment from a custom
type will use the templated constructor to create a temporary and then
use the trivial copy assignment operator. With the overloaded
assignment, we have to check the constraints twice as often, because
that overload and its constraints are checked for simple copy
assignments (including the one in the overloaded assignment operator
itself!)

Also add tests that ADL is used as per LWG 3629.

libstdc++-v3/ChangeLog:

* include/std/system_error (error_code::_Check): New alias
template for constructor SFINAE constraint.
(error_code::error_code(ErrorCodeEnum)): Use it.
(error_code::operator=(ErrorCodeEnum)): Remove.
(error_condition::_Check): New alias template for constraint.
(error_condition::error_condition(ErrorConditionEnum)): Use it.
(error_condition::operator=(ErrorConditionEnum)): Remove.
* testsuite/19_diagnostics/error_code/cons/1.cc: Check
constructor taking user-defined error enum.
* testsuite/19_diagnostics/error_condition/cons/1.cc: Likewise.

22 months agolibstdc++: Add nonnull to starts_with/ends_with/contains string members
Jonathan Wakely [Fri, 26 Aug 2022 08:43:32 +0000 (09:43 +0100)]
libstdc++: Add nonnull to starts_with/ends_with/contains string members

Ideally this wouldn't be needed, because eventually these pointers all
get passed to either the basic_string_view(const CharT*) constructor, or
to basic_string_view::find(const CharT*), both of which already have the
attribute. But for that to work requires optimization, so that the null
value gets propagated through the call chain.

Adding it explicitly to each member that requires a non-null pointer
makes the diagnostics more reliable even without optimization. It's
better to give a diagnostic earlier anyway, at the actual problematic
call in the user's code.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (starts_with, ends_with, contains):
Add nonnull attribute.
* include/bits/cow_string.h (starts_with, ends_with, contains):
Likewise.
* include/std/string_view (starts_with, ends_with, contains):
Likewise.
* testsuite/21_strings/basic_string/operations/contains/nonnull.cc
* testsuite/21_strings/basic_string/operations/ends_with/nonnull.cc
* testsuite/21_strings/basic_string/operations/starts_with/nonnull.cc
* testsuite/21_strings/basic_string_view/operations/contains/nonnull.cc
* testsuite/21_strings/basic_string_view/operations/ends_with/nonnull.cc
* testsuite/21_strings/basic_string_view/operations/starts_with/nonnull.cc

22 months agolibcpp: Implement P2362R3 - Remove non-encodable wide character literals and multicha...
Jakub Jelinek [Fri, 26 Aug 2022 14:06:20 +0000 (16:06 +0200)]
libcpp: Implement P2362R3 - Remove non-encodable wide character literals and multicharacter [PR106647]

My understanding of the paper is that we just want to promote the CPP_WCHAR
"character constant too long for its type" warning to error as it is already
error for u8, u and U literals.

2022-08-26  Jakub Jelinek  <jakub@redhat.com>

PR c++/106647
* charset.cc (wide_str_to_charconst): Implement P2362R3 - Remove
non-encodable wide character literals and multicharacter.  For
C++23 use CPP_DL_ERROR instead of CPP_DL_WARNING for
"character constant too long for its type" diagnostics on CPP_WCHAR
literals.

* g++.dg/cpp23/wchar-multi1.C: New test.
* g++.dg/cpp23/wchar-multi2.C: New test.

22 months agoRemove uninit_analysis::use_cannot_happen
Richard Biener [Fri, 26 Aug 2022 06:50:07 +0000 (08:50 +0200)]
Remove uninit_analysis::use_cannot_happen

As written earlier uninit_analysis::use_cannot_happen is duplicate
functionality implemented in a complement way, not adhering to
the idea of disproving a may-uninit use and eventually (I have not
yet found a testcase it helps to avoid false positives) avoiding
false positives because of this or different ways it imposes limits
on the predicate computations.

This patch removes it.

* gimple-predicate-analysis.h
(uninit_analysis::use_cannot_happen): Remove.
* gimple-predicate-analysis.cc (can_be_invalidated_p): Remove.
(uninit_analysis::use_cannot_happen): Likewise.
(uninit_analysis::is_use_guarded): Do not call
use_cannot_happen.
(dump_predicates): Remove.
(simple_control_dep_chain): Remove edge overload.

22 months agoNew testcase for uninit
Richard Biener [Fri, 26 Aug 2022 10:56:30 +0000 (12:56 +0200)]
New testcase for uninit

The following adds a testcase that illustrates a defect in
compute_control_dep_chain and its attempt to identify loop
exits as special to continue walking post-dominators but failing
to do so for following post-dominators.  On trunk there is now
simple_control_dep_chain saving the day, avoiding the false
positive but with GCC 12 we get a bogus diagnostic.

* gcc.dg/uninit-pred-11.c: New testcase.

22 months agoOpenMP: Support reverse offload (middle end part)
Tobias Burnus [Fri, 26 Aug 2022 10:12:25 +0000 (12:12 +0200)]
OpenMP: Support reverse offload (middle end part)

gcc/ChangeLog:

* internal-fn.cc (expand_GOMP_TARGET_REV): New.
* internal-fn.def (GOMP_TARGET_REV): New.
* lto-cgraph.cc (lto_output_node, verify_node_partition): Mark
'omp target device_ancestor_host' as in_other_partition and don't
error if absent.
* omp-low.cc (create_omp_child_function): Mark as 'noclone'.
* omp-expand.cc (expand_omp_target): For reverse offload, remove
sorry, use device = GOMP_DEVICE_HOST_FALLBACK and create
empty-body nohost function.
* omp-offload.cc (execute_omp_device_lower): Handle
IFN_GOMP_TARGET_REV.
(pass_omp_target_link::execute): For ACCEL_COMPILER, don't
nullify fn argument for reverse offload

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.0): Mark 'ancestor' as implemented but
refer to 'requires'.
* testsuite/libgomp.c-c++-common/reverse-offload-1-aux.c: New test.
* testsuite/libgomp.c-c++-common/reverse-offload-1.c: New test.
* testsuite/libgomp.fortran/reverse-offload-1-aux.f90: New test.
* testsuite/libgomp.fortran/reverse-offload-1.f90: New test.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/reverse-offload-1.c: Remove dg-sorry.
* c-c++-common/gomp/target-device-ancestor-4.c: Likewise.
* gfortran.dg/gomp/target-device-ancestor-4.f90: Likewise.
* gfortran.dg/gomp/target-device-ancestor-5.f90: Likewise.
* c-c++-common/goacc/classify-kernels-parloops.c: Add 'noclone' to
scan-tree-dump-times.
* c-c++-common/goacc/classify-kernels-unparallelized-parloops.c:
Likewise.
* c-c++-common/goacc/classify-kernels-unparallelized.c: Likewise.
* c-c++-common/goacc/classify-kernels.c: Likewise.
* c-c++-common/goacc/classify-parallel.c: Likewise.
* c-c++-common/goacc/classify-serial.c: Likewise.
* c-c++-common/goacc/kernels-counter-vars-function-scope.c: Likewise.
* c-c++-common/goacc/kernels-loop-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-3.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-enter-exit-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-enter-exit.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-update.c: Likewise.
* c-c++-common/goacc/kernels-loop-data.c: Likewise.
* c-c++-common/goacc/kernels-loop-g.c: Likewise.
* c-c++-common/goacc/kernels-loop-mod-not-zero.c: Likewise.
* c-c++-common/goacc/kernels-loop-n.c: Likewise.
* c-c++-common/goacc/kernels-loop-nest.c: Likewise.
* c-c++-common/goacc/kernels-loop.c: Likewise.
* c-c++-common/goacc/kernels-one-counter-var.c: Likewise.
* c-c++-common/goacc/kernels-parallel-loop-data-enter-exit.c: Likewise.
* gfortran.dg/goacc/classify-kernels-parloops.f95: Likewise.
* gfortran.dg/goacc/classify-kernels-unparallelized-parloops.f95:
Likewise.
* gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise.
* gfortran.dg/goacc/classify-kernels.f95: Likewise.
* gfortran.dg/goacc/classify-parallel.f95: Likewise.
* gfortran.dg/goacc/classify-serial.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-2.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-2.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-enter-exit-2.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-enter-exit.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-update.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-n.f95: Likewise.
* gfortran.dg/goacc/kernels-loop.f95: Likewise.
* gfortran.dg/goacc/kernels-parallel-loop-data-enter-exit.f95: Likewise.

22 months agofortran: Expand ieee_arithmetic module's ieee_value inline [PR106579]
Jakub Jelinek [Fri, 26 Aug 2022 07:56:19 +0000 (09:56 +0200)]
fortran: Expand ieee_arithmetic module's ieee_value inline [PR106579]

The following patch expands IEEE_VALUE function inline in the FE.

2022-08-26  Jakub Jelinek  <jakub@redhat.com>

PR fortran/106579
* trans-intrinsic.cc: Include realmpfr.h.
(conv_intrinsic_ieee_value): New function.
(gfc_conv_ieee_arithmetic_function): Handle ieee_value.

22 months agofortran: Expand ieee_arithmetic module's ieee_class inline [PR106579]
Jakub Jelinek [Fri, 26 Aug 2022 07:52:02 +0000 (09:52 +0200)]
fortran: Expand ieee_arithmetic module's ieee_class inline [PR106579]

The following patch expands IEEE_CLASS inline in the FE, using the
__builtin_fpclassify, __builtin_signbit and the new __builtin_issignaling
builtins.

2022-08-26  Jakub Jelinek  <jakub@redhat.com>

PR fortran/106579
gcc/fortran/
* f95-lang.cc (gfc_init_builtin_functions): Initialize
BUILT_IN_FPCLASSIFY.
* libgfortran.h (IEEE_OTHER_VALUE, IEEE_SIGNALING_NAN,
IEEE_QUIET_NAN, IEEE_NEGATIVE_INF, IEEE_NEGATIVE_NORMAL,
IEEE_NEGATIVE_DENORMAL, IEEE_NEGATIVE_SUBNORMAL,
IEEE_NEGATIVE_ZERO, IEEE_POSITIVE_ZERO, IEEE_POSITIVE_DENORMAL,
IEEE_POSITIVE_SUBNORMAL, IEEE_POSITIVE_NORMAL, IEEE_POSITIVE_INF):
New enum.
* trans-intrinsic.cc (conv_intrinsic_ieee_class): New function.
(gfc_conv_ieee_arithmetic_function): Handle ieee_class.
libgfortran/
* ieee/ieee_helper.c (IEEE_OTHER_VALUE, IEEE_SIGNALING_NAN,
IEEE_QUIET_NAN, IEEE_NEGATIVE_INF, IEEE_NEGATIVE_NORMAL,
IEEE_NEGATIVE_DENORMAL, IEEE_NEGATIVE_SUBNORMAL,
IEEE_NEGATIVE_ZERO, IEEE_POSITIVE_ZERO, IEEE_POSITIVE_DENORMAL,
IEEE_POSITIVE_SUBNORMAL, IEEE_POSITIVE_NORMAL, IEEE_POSITIVE_INF):
Move to gcc/fortran/libgfortran.h.

22 months agolibgfortran: Use __builtin_issignaling in libgfortran [PR105105]
Jakub Jelinek [Fri, 26 Aug 2022 07:45:19 +0000 (09:45 +0200)]
libgfortran: Use __builtin_issignaling in libgfortran [PR105105]

The following patch makes use of the new __builtin_issignaling,
so it no longer needs the fallback implementation and can use
the builtin even where glibc provides the macro.

2022-08-26  Jakub Jelinek  <jakub@redhat.com>

PR fortran/105105
* ieee/ieee_helper.c: Don't include issignaling_fallback.h.
(CLASSMACRO): Use __builtin_issignaling instead of issignaling.
* ieee/issignaling_fallback.h: Removed.

22 months agoImplement __builtin_issignaling
Jakub Jelinek [Fri, 26 Aug 2022 07:39:51 +0000 (09:39 +0200)]
Implement __builtin_issignaling

The following patch implements a new builtin, __builtin_issignaling,
which can be used to implement the ISO/IEC TS 18661-1  issignaling
macro.

It is implemented as type-generic function, so there is just one
builtin, not many with various suffixes.
This patch doesn't address PR56831 nor PR58416, but I think compared to
using glibc issignaling macro could make some cases better (as
the builtin is expanded always inline and for SFmode/DFmode just
reinterprets a memory or pseudo register as SImode/DImode, so could
avoid some raising of exception + turning sNaN into qNaN before the
builtin can analyze it).

For floading point modes that do not have NaNs it will return 0,
otherwise I've tried to implement this for all the other supported
real formats.
It handles both the MIPS/PA floats where a sNaN has the mantissa
MSB set and the rest where a sNaN has it cleared, with the exception
of format which are known never to be in the MIPS/PA form.
The MIPS/PA floats are handled using a test like
(x & mask) == mask,
the other usually as
((x ^ bit) & mask) > val
where bit, mask and val are some constants.
IBM double double is done by doing DFmode test on the most significant
half, and Intel/Motorola extended (12 or 16 bytes) and IEEE quad are
handled by extracting 32-bit/16-bit words or 64-bit parts from the
value and testing those.
On x86, XFmode is handled by a special optab so that even pseudo numbers
are considered signaling, like in glibc and like the i386 specific testcase
tests.

2022-08-26  Jakub Jelinek  <jakub@redhat.com>

gcc/
* builtins.def (BUILT_IN_ISSIGNALING): New built-in.
* builtins.cc (expand_builtin_issignaling): New function.
(expand_builtin_signbit): Don't overwrite target.
(expand_builtin): Handle BUILT_IN_ISSIGNALING.
(fold_builtin_classify): Likewise.
(fold_builtin_1): Likewise.
* optabs.def (issignaling_optab): New.
* fold-const-call.cc (fold_const_call_ss): Handle
BUILT_IN_ISSIGNALING.
* config/i386/i386.md (issignalingxf2): New expander.
* doc/extend.texi (__builtin_issignaling): Document.
(__builtin_isinf, __builtin_isnan): Clarify behavior with
-ffinite-math-only.
* doc/md.texi (issignaling<mode>2): Likewise.
gcc/c-family/
* c-common.cc (check_builtin_function_arguments): Handle
BUILT_IN_ISSIGNALING.
gcc/c/
* c-typeck.cc (convert_arguments): Handle BUILT_IN_ISSIGNALING.
gcc/fortran/
* f95-lang.cc (gfc_init_builtin_functions): Initialize
BUILT_IN_ISSIGNALING.
gcc/testsuite/
* gcc.dg/torture/builtin-issignaling-1.c: New test.
* gcc.dg/torture/builtin-issignaling-2.c: New test.
* gcc.dg/torture/float16-builtin-issignaling-1.c: New test.
* gcc.dg/torture/float32-builtin-issignaling-1.c: New test.
* gcc.dg/torture/float32x-builtin-issignaling-1.c: New test.
* gcc.dg/torture/float64-builtin-issignaling-1.c: New test.
* gcc.dg/torture/float64x-builtin-issignaling-1.c: New test.
* gcc.dg/torture/float128-builtin-issignaling-1.c: New test.
* gcc.dg/torture/float128x-builtin-issignaling-1.c: New test.
* gcc.target/i386/builtin-issignaling-1.c: New test.

22 months agointernal-fn, tree-cfg: Fix .TRAP handling and another __builtin_trap vops issue ...
Jakub Jelinek [Fri, 26 Aug 2022 07:28:48 +0000 (09:28 +0200)]
internal-fn, tree-cfg: Fix .TRAP handling and another __builtin_trap vops issue [PR106099]

This patch fixes 2 __builtin_unreachable/__builtin_trap related issues.
One (first hunk) is that CDDCE happily removes calls to .TRAP ()
internal-fn as useless.  The problem is that the internal-fn is
ECF_CONST | ECF_NORETURN, doesn't have lhs and so DCE thinks it doesn't
have side-effects and removes it.  __builtin_unreachable which has
the same ECF_* flags works fine, as since PR44485 we implicitly add
ECF_LOOPING_CONST_OR_PURE to ECF_CONST | ECF_NORETURN builtins, but
do it in flags_from_decl_or_type which isn't called for internal-fns.
As IFN_TRAP is the only ifn with such flags, it seems easier to
add it explicitly.

The other issue (which on the testcase can be seen only with the
first bug unfixed) is that execute_fixup_cfg can add a __builtin_trap
which needs vops, but nothing adds it and it can appear in many passes
which don't have corresponding TODO_update_ssa_only_virtuals etc.
Fixed similarly as last time but emitting ifn there instead.

2022-08-26  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/106099
* internal-fn.def (TRAP): Add ECF_LOOPING_CONST_OR_PURE flag.
* tree-cfg.cc (execute_fixup_cfg): Add IFN_TRAP instead of
__builtin_trap to avoid the need of vops.

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

22 months agoc++: Implement C++23 P2071R2 - Named universal character escapes [PR106648]
Jakub Jelinek [Fri, 26 Aug 2022 07:24:56 +0000 (09:24 +0200)]
c++: Implement C++23 P2071R2 - Named universal character escapes [PR106648]

The following patch implements the
C++23 P2071R2 - Named universal character escapes
paper to support \N{LATIN SMALL LETTER E} etc.
I've used Unicode 14.0, there are 144803 character name properties
(including the ones generated by Unicode NR1 and NR2 rules)
and correction/control/alternate aliases, together with zero terminators
that would be 3884745 bytes, which is clearly unacceptable for libcpp.
This patch instead contains a generator which from the UnicodeData.txt
and NameAliases.txt files emits a space optimized radix tree (208765
bytes long for 14.0), a single string literal dictionary (59418 bytes),
maximum name length (currently 88 chars) and two small helper arrays
for the NR1/NR2 name generation.
The radix tree needs 2 to 9 bytes per node, the exact format is
described in the generator program.  There could be ways to shrink
the dictionary size somewhat at the expense of slightly slower lookups.

Currently the patch implements strict matching (that is what is needed
to actually implement it on valid code) and Unicode UAX44-LM2 algorithm
loose matching to provide hints (that algorithm essentially ignores
hyphens in between two alphanumeric characters, spaces and underscores
(with one exception for hyphen) and does case insensitive matching).
In the attachment is a WIP patch that shows how to implement also
spellcheck.{h,cc} style discovery of misspellings, but I'll need to talk
to David Malcolm about it, as spellcheck.{h,cc} is in gcc/ subdir
(so the WIP incremental patch instead prints all the names to stderr).

2022-08-26  Jakub Jelinek  <jakub@redhat.com>

PR c++/106648
libcpp/
* charset.cc: Implement C++23 P2071R2 - Named universal character
escapes.  Include uname2c.h.
(hangul_syllables, hangul_count): New variables.
(struct uname2c_data): New type.
(_cpp_uname2c, _cpp_uname2c_uax44_lm2): New functions.
(_cpp_valid_ucn): Use them.  Handle named universal character escapes.
(convert_ucn): Adjust comment.
(convert_escape): Call convert_ucn even for \N.
(_cpp_interpret_identifier): Handle named universal character escapes.
* lex.cc (get_bidi_ucn): Fix up function comment formatting.
(get_bidi_named): New function.
(forms_identifier_p, lex_string): Handle named universal character
escapes.
* makeuname2c.cc: New file.  Small parts copied from makeucnid.cc.
* uname2c.h: New generated file.
gcc/c-family/
* c-cppbuiltin.cc (c_cpp_builtins): Predefine
__cpp_named_character_escapes to 202207L.
gcc/testsuite/
* c-c++-common/cpp/named-universal-char-escape-1.c: New test.
* c-c++-common/cpp/named-universal-char-escape-2.c: New test.
* c-c++-common/cpp/named-universal-char-escape-3.c: New test.
* c-c++-common/cpp/named-universal-char-escape-4.c: New test.
* c-c++-common/Wbidi-chars-25.c: New test.
* gcc.dg/cpp/named-universal-char-escape-1.c: New test.
* gcc.dg/cpp/named-universal-char-escape-2.c: New test.
* g++.dg/cpp/named-universal-char-escape-1.C: New test.
* g++.dg/cpp/named-universal-char-escape-2.C: New test.
* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_named_character_escapes.

22 months agoImprove compute_control_dep_chain path finding
Richard Biener [Thu, 25 Aug 2022 11:04:43 +0000 (13:04 +0200)]
Improve compute_control_dep_chain path finding

This improves the compute_control_dep_chain path finding by first
marking the dominating region we search and then making sure to
not walk outside if it when enumerating all paths from the dominating
block to the interesting PHI edge source.  I have limited the DFS
walk done for the marking in similar ways as we limit the walking
in compute_control_dep_chain, more careful limiting might be
necessary though - the --param uninit-control-dep-attempts param
I re-use has a rather high default of 1000 which we might be able
to reduce with this patch as well (I think we'll usually hit some of the
other limits before ever reaching this).

* gimple-predicate-analysis.cc (dfs_mark_dominating_region):
New helper.
(compute_control_dep_chain): Adjust to honor marked region
if provided.
(uninit_analysis::init_from_phi_def): Pre-mark the dominating
region to improve compute_control_dep_chain walking.
* vec.h (vec<T, va_heap, vl_ptr>::allocated): Add forwarder.

22 months agoImprove uninit_analysis::collect_phi_def_edges
Richard Biener [Thu, 25 Aug 2022 14:27:12 +0000 (16:27 +0200)]
Improve uninit_analysis::collect_phi_def_edges

This avoids expanding an edge to those of a PHI def if it is not
may-undefined, reducing the number of compute_control_dep_chain calls.

* gimple-predicate-analysis.cc
(uninit_analysis::collect_phi_def_edges): Only expand a
PHI def edge when it is possibly undefined.

22 months agocr16: remove obsoleted port
Martin Liska [Thu, 25 Aug 2022 08:21:20 +0000 (10:21 +0200)]
cr16: remove obsoleted port

contrib/ChangeLog:

* config-list.mk: Remove cr16.

gcc/ChangeLog:

* doc/extend.texi: Remove cr16 related stuff.
* doc/install.texi: Likewise.
* doc/invoke.texi: Likewise.
* doc/md.texi: Likewise.
* function-tests.cc (test_expansion_to_rtl): Likewise.
* common/config/cr16/cr16-common.cc: Removed.
* config/cr16/constraints.md: Removed.
* config/cr16/cr16-protos.h: Removed.
* config/cr16/cr16.cc: Removed.
* config/cr16/cr16.h: Removed.
* config/cr16/cr16.md: Removed.
* config/cr16/cr16.opt: Removed.
* config/cr16/predicates.md: Removed.
* config/cr16/t-cr16: Removed.

libgcc/ChangeLog:

* config.host: Remove cr16 related stuff.
* config/cr16/crti.S: Removed.
* config/cr16/crtlibid.S: Removed.
* config/cr16/crtn.S: Removed.
* config/cr16/divmodhi3.c: Removed.
* config/cr16/lib1funcs.S: Removed.
* config/cr16/t-cr16: Removed.
* config/cr16/t-crtlibid: Removed.
* config/cr16/unwind-cr16.c: Removed.
* config/cr16/unwind-dw2.h: Removed.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Remove cr16 related stuff.

22 months agoDon't gimple fold ymm-version vblendvpd/vblendvps/vpblendvb w/o TARGET_AVX2
liuhongt [Mon, 22 Aug 2022 02:41:16 +0000 (10:41 +0800)]
Don't gimple fold ymm-version vblendvpd/vblendvps/vpblendvb w/o TARGET_AVX2

Since 256-bit vector integer comparison is under TARGET_AVX2,
and gimple folding for vblendvpd/vblendvps/vpblendvb relies on that.
Restrict gimple fold condition to TARGET_AVX2.

gcc/ChangeLog:

PR target/106704
* config/i386/i386-builtin.def (BDESC): Add
CODE_FOR_avx_blendvpd256/CODE_FOR_avx_blendvps256 to
corresponding builtins.
* config/i386/i386.cc (ix86_gimple_fold_builtin):
Don't fold IX86_BUILTIN_PBLENDVB256, IX86_BUILTIN_BLENDVPS256,
IX86_BUILTIN_BLENDVPD256 w/o TARGET_AVX2.

gcc/testsuite/ChangeLog:

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

22 months agoDaily bump.
GCC Administrator [Fri, 26 Aug 2022 00:16:21 +0000 (00:16 +0000)]
Daily bump.

22 months agoc: Implement C23 nullptr (N3042)
Marek Polacek [Wed, 10 Aug 2022 19:00:49 +0000 (15:00 -0400)]
c: Implement C23 nullptr (N3042)

This patch implements the C23 nullptr literal:
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3042.htm> (with
wording fixes from N3047), which is intended to replace the problematic
definition of NULL which might be either of integer type or void*.

Since C++ has had nullptr for over a decade now, it was relatively easy
to just move the built-in node definitions from the C++ FE to the C/C++
common code.  Also, our DWARF emitter already handles NULLPTR_TYPE by
emitting DW_TAG_unspecified_type.  However, I had to handle a lot of
contexts such as ?:, comparison, conversion, etc.

There are some minor differences, e.g. in C you can do

  bool b = nullptr;

but in C++ you have to use direct-initialization:

  bool b{nullptr};

And I think that

  nullptr_t n = 0;

is only valid in C++.

Of course, C doesn't have to handle mangling, RTTI, substitution,
overloading, ...

This patch also defines nullptr_t in <stddef.h>.  However, it does not
define __STDC_VERSION_STDDEF_H__ yet, because we don't know yet what value
it should be defined to.

gcc/c-family/ChangeLog:

* c-common.cc (c_common_reswords): Enable nullptr in C2X.
(c_common_nodes_and_builtins): Create the built-in node for nullptr.
* c-common.h (enum c_tree_index): Add CTI_NULLPTR, CTI_NULLPTR_TYPE.
(struct c_common_resword): Resize the disable member.
(D_C2X): Add.
(nullptr_node): Define.
(nullptr_type_node): Define.
(NULLPTR_TYPE_P): Define.
* c-pretty-print.cc (c_pretty_printer::simple_type_specifier): Handle
NULLPTR_TYPE.
(c_pretty_printer::direct_abstract_declarator): Likewise.
(c_pretty_printer::constant): Likewise.

gcc/c/ChangeLog:

* c-convert.cc (c_convert) <case POINTER_TYPE>: Handle NULLPTR_TYPE.
Give a better diagnostic when converting to nullptr_t.
* c-decl.cc (c_init_decl_processing): Perform C-specific nullptr
initialization.
* c-parser.cc (c_parse_init): Maybe OR D_C2X into mask.
(c_parser_postfix_expression): Handle RID_NULLPTR.
* c-typeck.cc (null_pointer_constant_p): Return true when expr is
nullptr_node.
(build_unary_op) <case TRUTH_NOT_EXPR>: Handle NULLPTR_TYPE.
(build_conditional_expr): Handle the case when the second/third operand
is NULLPTR_TYPE and third/second operand is POINTER_TYPE.
(convert_for_assignment): Handle converting an expression of type
nullptr_t to pointer/bool.
(build_binary_op) <case TRUTH_XOR_EXPR>: Handle NULLPTR_TYPE.
<case EQ_EXPR>: Handle comparing operands of type nullptr_t.

gcc/cp/ChangeLog:

* cp-tree.h (enum cp_tree_index): Remove CTI_NULLPTR, CTI_NULLPTR_TYPE.
Move it to c_tree_index.
(nullptr_node): No longer define here.
(nullptr_type_node): Likewise.
(NULLPTR_TYPE_P): Likewise.
* decl.cc (cxx_init_decl_processing): Only keep C++-specific nullptr
initialization; move the shared code to c_common_nodes_and_builtins.

gcc/ChangeLog:

* ginclude/stddef.h: Define nullptr_t.

gcc/testsuite/ChangeLog:

* gcc.dg/c11-nullptr-1.c: New test.
* gcc.dg/c17-nullptr-1.c: New test.
* gcc.dg/c17-nullptr-2.c: New test.
* gcc.dg/c2x-nullptr-1.c: New test.
* gcc.dg/c2x-nullptr-2.c: New test.
* gcc.dg/c2x-nullptr-3.c: New test.
* gcc.dg/c2x-nullptr-4.c: New test.
* gcc.dg/c2x-nullptr-5.c: New test.

22 months agoc: Support C2x empty initializer braces
Joseph Myers [Thu, 25 Aug 2022 21:02:57 +0000 (21:02 +0000)]
c: Support C2x empty initializer braces

ISO C2x standardizes empty initializer braces {}.  Implement this
feature accordingly.  The basic case was already supported and so just
needed diagnostic adjustments.  However, the standard feature also
includes two cases that were not previously supported: empty
initializer braces for scalars, and empty initializer braces for
VLAs.  Thus, add support for those features as well, updating existing
tests that expected them to be diagnosed.

There was already some gimplifier support for converting
variable-sized initializations with empty CONSTRUCTORs to memset.
However, it didn't apply here; code earlier in gimplify_modify_expr
ended up calling gimplify_init_constructor via
gimplify_modify_expr_rhs, which ended up handling the CONSTRUCTOR in a
way that generated an ICE later.  Add a check for this case earlier in
gimplify_modify_expr to avoid that issue.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/
* gimplify.cc (gimplify_modify_expr): Convert initialization from
a variable-size CONSTRUCTOR to memset before call to
gimplify_modify_expr_rhs.

gcc/c/
* c-decl.cc (start_decl): Do not diagnose initialization of
variable-sized objects here.
* c-parser.cc (c_parser_braced_init): Add argument DECL.  All
callers changed.
(c_parser_initializer): Diagnose initialization of variable-sized
objects other than with braced initializer.
(c_parser_braced_init): Use pedwarn_c11 for empty initializer
braces and update diagnostic text.  Diagnose initialization of
variable-sized objects with nonempty braces.
* c-typeck.cc (digest_init): Update diagnostic for initialization
of variable-sized objects.
(really_start_incremental_init, set_designator)
(process_init_element): Update comments.
(pop_init_level): Allow scalar empty initializers.

gcc/testsuite/
* gcc.dg/c11-empty-init-1.c, gcc.dg/c11-empty-init-2.c,
gcc.dg/c11-empty-init-3.c, gcc.dg/c2x-empty-init-1.c,
gcc.dg/c2x-empty-init-2.c, gcc.dg/c2x-empty-init-3.c,
gcc.dg/gnu2x-empty-init-1.c, gcc.dg/gnu2x-empty-init-2.c: New
tests.
* gcc.dg/torture/dfp-default-init-1.c: Also test empty
initializers.
* gcc.dg/init-bad-1.c, gcc.dg/noncompile/pr71583.c,
gcc.dg/pr61096-1.c, gcc.dg/vla-init-2.c, gcc.dg/vla-init-3.c,
gcc.target/i386/sse2-bfloat16-scalar-typecheck.c: Update expected
diagnostics.
* gcc.dg/ubsan/c-shift-1.c: Use nonempty initializers for VLA
initializations expected to be diagnosed.

22 months agoc++: block copy elision in delegating ctor
Jason Merrill [Wed, 24 Aug 2022 20:28:32 +0000 (16:28 -0400)]
c++: block copy elision in delegating ctor

CWG2403 deals with the issue that copy elision is not possible when the
initialized object is a potentially-overlapping subobject and the
initializer is a function that returns by value.  Jonathan pointed out that
this also affects delegating constructors, which might be used to construct
a base subobject.

gcc/cp/ChangeLog:

* call.cc (unsafe_return_slot_p): Return 2 for *this in a
constructor.

gcc/testsuite/ChangeLog:

* g++.dg/init/elide8.C: New test.

22 months agodwarf2: use DW_ATE_UTF for char8_t
Jason Merrill [Wed, 24 Aug 2022 20:31:04 +0000 (16:31 -0400)]
dwarf2: use DW_ATE_UTF for char8_t

While looking at the Rust changes to dwarf2out I noticed that this was
missing from the char8_t support.

gcc/ChangeLog:

* dwarf2out.cc (base_type_die): Also use DW_ATE_UTF for char8_t.

gcc/testsuite/ChangeLog:

* g++.dg/debug/dwarf2/utf-1.C: New test.

22 months agolibstdc++: Some minor <ranges> cleanups
Patrick Palka [Thu, 25 Aug 2022 15:11:04 +0000 (11:11 -0400)]
libstdc++: Some minor <ranges> cleanups

libstdc++-v3/ChangeLog:

* include/std/ranges (lazy_split_view::_OuterIter::_M_current):
Remove redundant comment.
(lazy_split_view::_M_current): Likewise.
(common_view::common_view): Remove commented out view-converting
constructor as per LWG3405.
(elements_view::_Iterator::_Iterator): Uglify 'current' and 'i'.

22 months agoPR 106101: IBM zSystems: Fix strict_low_part problem
Andreas Krebbel [Fri, 29 Jul 2022 07:55:54 +0000 (09:55 +0200)]
PR 106101: IBM zSystems: Fix strict_low_part problem

This avoids generating illegal (strict_low_part (reg ...)) RTXs. This
required two changes:

1. Do not use gen_lowpart to generate the inner expression of a
STRICT_LOW_PART.  gen_lowpart might fold the SUBREG either because
there is already a paradoxical subreg or because it can directly be
applied to the register. A new wrapper function makes sure that we
always end up having an actual SUBREG.

2. Change the movstrict patterns to enforce a SUBREG as inner operand
of the STRICT_LOW_PARTs.  The new predicate introduced for the
destination operand requires a SUBREG expression with a
register_operand as inner operand.  However, since reload strips away
the majority of the SUBREGs we have to accept single registers as well
once we reach reload.

Bootstrapped and regression tested on IBM zSystems 64 bit.

gcc/ChangeLog:

PR target/106101
* config/s390/predicates.md (subreg_register_operand): New
predicate.
* config/s390/s390-protos.h (s390_gen_lowpart_subreg): New
function prototype.
* config/s390/s390.cc (s390_gen_lowpart_subreg): New function.
(s390_expand_insv): Use s390_gen_lowpart_subreg instead of
gen_lowpart.
* config/s390/s390.md ("*get_tp_64", "*zero_extendhisi2_31")
("*zero_extendqisi2_31", "*zero_extendqihi2_31"): Likewise.
("movstrictqi", "movstricthi", "movstrictsi"): Use the
subreg_register_operand predicate instead of register_operand.

gcc/testsuite/ChangeLog:

PR target/106101
* gcc.c-torture/compile/pr106101.c: New test.

22 months agoregenerate configure files and config.h.in files
Martin Liska [Thu, 25 Aug 2022 09:36:52 +0000 (11:36 +0200)]
regenerate configure files and config.h.in files

fixincludes/ChangeLog:

* config.h.in: Regenerate.
* configure: Regenerate.

libada/ChangeLog:

* configure: Regenerate.

libiberty/ChangeLog:

* configure: Regenerate.

libobjc/ChangeLog:

* configure: Regenerate.

liboffloadmic/ChangeLog:

* configure: Regenerate.
* plugin/configure: Regenerate.

libquadmath/ChangeLog:

* configure: Regenerate.

libssp/ChangeLog:

* configure: Regenerate.

libvtv/ChangeLog:

* configure: Regenerate.

zlib/ChangeLog:

* configure: Regenerate.

22 months agoLoongArch: add model attribute
Xi Ruoyao [Fri, 29 Jul 2022 13:45:40 +0000 (21:45 +0800)]
LoongArch: add model attribute

A linker script and/or a section attribute may locate some object
specially, so we need to handle the code model for such objects
differently than the -mcmodel setting. This happens when the Linux
kernel loads a module with per-CPU variables.

Add an attribute to override the code model for a specific variable.

gcc/ChangeLog:

* config/loongarch/loongarch-protos.h (loongarch_symbol_type):
Add SYMBOL_PCREL64 and change the description for SYMBOL_PCREL.
* config/loongarch/loongarch.cc (loongarch_attribute_table):
New attribute table.
(TARGET_ATTRIBUTE_TABLE): Define the target hook.
(loongarch_handle_model_attribute): New static function.
(loongarch_classify_symbol): Take TARGET_CMODEL_EXTREME and the
model attribute of SYMBOL_REF_DECL into account returning
SYMBOL_PCREL or SYMBOL_PCREL64.
(loongarch_use_anchors_for_symbol_p): New static function.
(TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define the target hook.
(loongarch_symbol_extreme_p): New static function.
(loongarch_symbolic_constant_p): Handle SYMBOL_PCREL64.
(loongarch_symbol_insns): Likewise.
(loongarch_split_symbol_type): Likewise.
(loongarch_split_symbol): Check SYMBOL_PCREL64 instead of
TARGET_CMODEL_EXTREME for PC-relative addressing.
(loongarch_print_operand_reloc): Likewise.
* doc/extend.texi (Variable Attributes): Document new
LoongArch specific attribute.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/attr-model-test.c: New test.
* gcc.target/loongarch/attr-model-1.c: New test.
* gcc.target/loongarch/attr-model-2.c: New test.
* gcc.target/loongarch/attr-model-diag.c: New test.

22 months agoLoongArch: Avoid RTL flag check failure in loongarch_classify_symbol
Xi Ruoyao [Wed, 24 Aug 2022 13:31:34 +0000 (21:31 +0800)]
LoongArch: Avoid RTL flag check failure in loongarch_classify_symbol

SYMBOL_REF_TLS_MODEL invokes SYMBOL_REF_FLAGS, and SYMBOL_REF_FLAGS
invokes RTL_FLAG_CHECK1 and aborts when RTL code is not SYMBOL_REF.

r13-1833 removed "gcc_assert (SYMBOL_REF_P (x))" before invoking
"SYMBOL_REF_TLS_MODEL (x)", indicating that it's now possible that "x"
is not a SYMBOL_REF.  So we need to check if "x" is SYMBOL_REF first.

This fixes a test failure happening with r13-2173 with RTL flag
checking enabled:

    pr106096.C:26:1: internal compiler error: RTL flag check:
    SYMBOL_REF_FLAGS used with unexpected rtx code 'const' in
    loongarch_classify_symbol

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_classify_symbol):
Return early if the rtx is not SYMBOL_REF.

22 months agotree-optimization/106737 - remove intermediate SSA verification in autopar
Richard Biener [Thu, 25 Aug 2022 08:42:30 +0000 (10:42 +0200)]
tree-optimization/106737 - remove intermediate SSA verification in autopar

The following removes intermediate SSA verification in autopar which
isn't expected to succeed after previous changes delaying (virtual)
SSA update to the end of the pass.

PR tree-optimization/106737
* tree-parloops.cc (transform_to_exit_first_loop_alt): Do not
verify SSA form.

* gcc.dg/autopar/pr106737.c: New testcase.

22 months agoFortran/OpenMP: Fix strictly structured blocks parsing
Tobias Burnus [Thu, 25 Aug 2022 06:34:03 +0000 (08:34 +0200)]
Fortran/OpenMP: Fix strictly structured blocks parsing

gcc/fortran/ChangeLog:

* parse.cc (parse_omp_structured_block): When parsing strictly
structured blocks, issue an error if the end-directive comes
before the 'end block'.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/strictly-structured-block-4.f90: New test.

22 months agoLoongArch: Fix pr106459 by use HWIT instead of 1UL.
Chenghua Xu [Wed, 24 Aug 2022 07:34:07 +0000 (15:34 +0800)]
LoongArch: Fix pr106459 by use HWIT instead of 1UL.

gcc/ChangeLog:

PR target/106459
* config/loongarch/loongarch.cc (loongarch_build_integer):
Use HOST_WIDE_INT.
* config/loongarch/loongarch.h (IMM_REACH): Likewise.
(HWIT_1U): New Defined.
(LU12I_OPERAND): Use HOST_WIDE_INT.
(LU32I_OPERAND): Likewise.
(LU52I_OPERAND): Likewise.
(HWIT_UC_0xFFF): Likwise.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/pr106459.c: New test.

22 months agoDaily bump.
GCC Administrator [Thu, 25 Aug 2022 00:16:33 +0000 (00:16 +0000)]
Daily bump.

22 months agolibstdc++: Implement ranges::zip_view from P2321R2
Patrick Palka [Wed, 24 Aug 2022 23:17:27 +0000 (19:17 -0400)]
libstdc++: Implement ranges::zip_view from P2321R2

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__min_fn, min): Move to ...
* include/bits/ranges_util.h: ... here, in order to avoid
including all of ranges_algo.h from <ranges>.
* include/std/ranges (__detail::__zip_is_common): Define for
C++23 as per P2321R2.
(__detail::__tuple_or_pair): Likewise.
(__detail::__tuple_or_pair_t): Likewise.
(__detail::__tuple_transform): Likewise.
(__detail::__tuple_for_each): Likewise.
(zip_view): Likewise.
(enable_borrowed_range<zip_view>): Likewise.
(__detail::__all_random_access): Likewise.
(__detail::__all_bidirectional): Likewise.
(__detail::__all_forward): Likewise.
(__detail::__zip_view_iter_cat): Likewise.
(zip_view::_Iterator): Likewise.
(zip_view::_Sentinel): Likewise.
* testsuite/std/ranges/zip/1.cc: New test.

22 months agoRevert "libstdc++: Optimize operator+(string/char*, char*/string) equally"
Jonathan Wakely [Wed, 24 Aug 2022 22:47:43 +0000 (23:47 +0100)]
Revert "libstdc++: Optimize operator+(string/char*, char*/string) equally"

This reverts commit 0b7c9254998b3fb2c39f6b86b5b196f415530205.

22 months agolibstdc++: Fix fallout from P2321R2 std::pair/tuple enhancements
Patrick Palka [Wed, 24 Aug 2022 20:38:45 +0000 (16:38 -0400)]
libstdc++: Fix fallout from P2321R2 std::pair/tuple enhancements

r13-2159-g72886fcc626953 caused some testsuite regressions in C++23 mode:

  FAIL: 20_util/pair/requirements/explicit_instantiation/1.cc (test for excess errors)
  FAIL: 20_util/tuple/53648.cc (test for excess errors)
  FAIL: 20_util/tuple/cons/noexcept_specs.cc (test for excess errors)
  FAIL: 20_util/tuple/requirements/explicit_instantiation.cc (test for excess errors)

The test noexcept_specs.cc just needs to be updated to consider the
additional converting constructors of tuple in C++23 mode, which happen
to improve constructing from a const tuple rvalue that has an rvalue
reference element (for the better, as far as I can tell).

The other three tests fail because they explicitly instantiate a
specialization of pair/tuple whose elements are not all const swappable,
which in C++23 mode now results in a hard error due to the new const
swap member function.  Rather than XFAILing the tests in C++23 mode,
this patch adds non-standard constraints to this member function so that
we continue to accept such explicit instantiations.

libstdc++-v3/ChangeLog:

* include/bits/stl_pair.h (pair::swap const): Add non-standard
is_swappable_v constraints.
* include/std/tuple (tuple::swap const): Likewise.
* testsuite/20_util/tuple/cons/noexcept_specs.cc: Correct some
asserts in C++23 mode.

22 months ago[RISCV] Fix PR 106632 and PR 106588 a few constraints in bitmanip.md
Andrew Pinski [Mon, 15 Aug 2022 22:58:09 +0000 (22:58 +0000)]
[RISCV] Fix PR 106632 and PR 106588 a few constraints in bitmanip.md

The constraints should be n instead of i. Also there
needs to a check for out of bounds zero_extract for
*bexti.

gcc/ChangeLog:

PR target/106632
PR target/106588
* config/riscv/bitmanip.md (*shNadduw): Use n constraint
instead of i.
(*slliuw): Likewise.
(*bexti): Likewise. Also add a check for operands[2] to be less
than the mode bitsize.

22 months ago[RISCV] Add constraints for not_single_bit_mask_operand/single_bit_mask_operand
Andrew Pinski [Mon, 15 Aug 2022 22:48:25 +0000 (22:48 +0000)]
[RISCV] Add constraints for not_single_bit_mask_operand/single_bit_mask_operand

Like a previous patch, just add constraints for predicates
not_single_bit_mask_operand and single_bit_mask_operand.

OK? Built and tested for riscv32-linux-gnu and riscv64-linux-gnu.

Thanks,
Andrew Pinski

gcc/ChangeLog:

* config/riscv/constraints.md (DbS): New constraint.
(DnS): New constraint.
* config/riscv/bitmanip.md (*bset<mode>_1_mask): Use new constraint.
(*bclr<mode>): Likewise.
(*binvi<mode>): Likewise.

22 months ago[RISCV] Fix PR 106586: riscv32 vs ZBS
Andrew Pinski [Mon, 15 Aug 2022 22:25:13 +0000 (22:25 +0000)]
[RISCV] Fix PR 106586: riscv32 vs ZBS

The problem here is two fold. With RISCV32, 32bit
const_int are always signed extended to 64bit in HWI.
So that means for SINGLE_BIT_MASK_OPERAND, it should
mask off the upper bits to see it is a single bit
for !TARGET_64BIT.
Plus there are a few locations which forget to call
trunc_int_for_mode when generating a SImode constant
so they are not sign extended correctly for HWI.
The predicates single_bit_mask_operand and
not_single_bit_mask_operand need get the same handling
as SINGLE_BIT_MASK_OPERAND so just use SINGLE_BIT_MASK_OPERAND.

OK? Built and tested on riscv32-linux-gnu and riscv64-linux-gnu with
--with-arch=rvNimafdc_zba_zbb_zbc_zbs where N is replaced with 32 or 64.

Thanks,
Andrew Pinski

gcc/ChangeLog:

PR target/106586
* config/riscv/predicates.md (single_bit_mask_operand):
Use SINGLE_BIT_MASK_OPERAND instead of directly calling pow2p_hwi.
(not_single_bit_mask_operand): Likewise.
* config/riscv/riscv.cc (riscv_build_integer_1): Don't special case
1<<31 for 32bits as it is already handled.
Call trunc_int_for_mode on the upper part after the subtraction.
(riscv_move_integer): Call trunc_int_for_mode before generating
the integer just make sure the constant has been sign extended
corectly.
(riscv_emit_int_compare): Call trunc_int_for_mode after doing the
addition for the new rhs.
* config/riscv/riscv.h (SINGLE_BIT_MASK_OPERAND): If !TARGET64BIT,
then mask off the upper 32bits of the HWI as it will be sign extended.

22 months ago[RISCV] Use a constraint for bset<mode>_mask and bset<mode>_1_mask
Andrew Pinski [Mon, 15 Aug 2022 18:39:17 +0000 (18:39 +0000)]
[RISCV] Use a constraint for bset<mode>_mask and bset<mode>_1_mask

A constraint here just makes it easier to understand what the
operands are.

OK? Built and tested on riscv32-linux-gnu and riscv64-linux-gnu with
--with-arch=rvNimafdc_zba_zbb_zbc_zbs (where N is 32 and 64).

Thanks,
Andrew Pinski

gcc/ChangeLog:

* config/riscv/constraints.md (DsS): New constraint.
(DsD): New constraint.
* config/riscv/iterators.md (shiftm1c): New iterator.
* config/riscv/bitmanip.md (*bset<mode>_mask):
Use shiftm1c.
(*bset<mode>_1_mask): Likewise.

22 months ago[RISCV] Use constraints/predicates instead of checking const_int directly for shNadd...
Andrew Pinski [Mon, 15 Aug 2022 17:50:50 +0000 (17:50 +0000)]
[RISCV] Use constraints/predicates instead of checking const_int directly for shNadd patterns

This simplifies the code by adding a predicate and a constraint for 1/2/3.
The aarch64 backend has a similar predicate called aarch64_shift_imm_<mode>
which they use there.

OK? Built and tested on riscv32-linux-gnu and riscv64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

gcc/ChangeLog:

* config/riscv/constraints.md (Ds3): New constraint.
* config/riscv/predicates.md (imm123_operand): New predicate.
* config/riscv/bitmanip.md (*shNadd): Use Ds3 and imm123_operand.
(*shNadduw): Likewise.

22 months ago[RISCV] Add %~ to print w if TARGET_64BIT and use it
Andrew Pinski [Fri, 12 Aug 2022 17:46:16 +0000 (17:46 +0000)]
[RISCV] Add %~ to print w if TARGET_64BIT and use it

To make things easier and more maintainable, we need to
add support printing out w if TARGET_64BIT so this patch
adds %~ to do that, similar how the x86 backend uses %~
to print out i/f for TARGET_AVX2. We could have chosen any
punctuation symbol but ~ looks the closest to w.

OK? Build and tested for riscv64-linux-gnu and riscv32-linux-gnu with no regressions.

Thanks,
Andrew Pinski

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_print_operand):
Handle '~'.
(riscv_print_operand_punct_valid_p): New function
(TARGET_PRINT_OPERAND_PUNCT_VALID_P): Define.
* config/riscv/bitmanip.md (<bitmanip_optab>si2/clz_ctz_pcnt):
Use %~ instead of conditional the pattern on TARGET_64BIT.
(rotrsi3): Likewise.
(rotlsi3): Likewise.
* config/riscv/riscv.md: Add ~ to the list of modifiers.
(addsi3): Use %~ instead of conditional the pattern on TARGET_64BIT.
(subsi3): Likewise.
(negsi2): Likewise.
(mulsi3): Likewise.
(optab>si3/any_div): Likewise.
(*add<mode>hi3): Likewise.
(<optab>si3/any_shift): Likewise.

22 months ago[RISCV] Add the list of operand modifiers to riscv.md too
Andrew Pinski [Fri, 12 Aug 2022 17:19:36 +0000 (17:19 +0000)]
[RISCV] Add the list of operand modifiers to riscv.md too

To make it easier to find operands modifiers while in the md
file, add the list of modifiers to the top of the md file.
This is similar to i386 target.

OK? Built and tested for riscv32-linux-gnu and riscv64-linux-gnu.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_print_operand): Make a mention to
keep the list in riscv.md in sync with this list.
* config/riscv/riscv.md: Add list of modifiers as comments.

22 months ago[RISCV] Move iterators from sync.md to iterators.md
Andrew Pinski [Fri, 12 Aug 2022 00:44:16 +0000 (00:44 +0000)]
[RISCV] Move iterators from sync.md to iterators.md

Like the previous two patches this moves the iterators
that are in sync.md to iterators.md.

OK? build and tested for riscv64-linux-gnu.

gcc/ChangeLog:

* config/riscv/sync.md (any_atomic, atomic_optab): Move to ...
* config/riscv/iterators.md: Here.

22 months ago[RISCV] Move iterators from bitmanip.md to iterators.md
Andrew Pinski [Thu, 11 Aug 2022 23:52:29 +0000 (23:52 +0000)]
[RISCV] Move iterators from bitmanip.md to iterators.md

Just like the previous patch this move all of the iterators
of bitmanip.md to iterators.md.  All modern backends put the
iterators in iterators.md for easier access.

OK? Built and tested for riscv32-linux-gnu with --with-arch=rv32imafdc_zba_zbb_zbc_zbs.

Thanks,
Andrew Pinski

gcc/ChangeLog:

* config/riscv/bitmanip.md
(bitmanip_bitwise, bitmanip_minmax, clz_ctz_pcna,
tbitmanip_optab, bitmanip_insn, shiftm1): Move to ...
* config/riscv/iterators.md: Here.

22 months ago[RISCV] Move iterators from riscv.md to iterators.md
Andrew Pinski [Thu, 11 Aug 2022 23:29:50 +0000 (16:29 -0700)]
[RISCV] Move iterators from riscv.md to iterators.md

This moves the iterators out from riscv.md to iterators.md
like most modern backends.
I have not moved the iterators from the other .md files yet.

OK? Build and tested on riscv64-linux-gnu and riscv32-linux-gnu.

Thanks,
Andrew Pinski

gcc/ChangeLog:

* config/riscv/riscv.md (GPR): Move to new file.
(P, X, BR): Likewise.
(MOVE32, MOVE64, SHORT): Likewise.
(HISI, SUPERQI, SUBX): Likewise.
(ANYI, ANYF, SOFTF): Likewise.
(size, load, default_load): Likewise.
(softload, store, softstore): Likewise.
(reg, fmt, ifmt, amo): Likewise.
(UNITMODE, HALFMODE): Likewise.
(RINT, rint_pattern, rint_rm): Likewise.
(QUIET_COMPARISON, quiet_pattern, QUIET_PATTERN): Likewise.
(any_extend, any_shiftrt, any_shift): Likewise.
(any_bitwise): Likewise.
(any_div, any_mod): Likewise.
(any_gt, any_ge, any_lt, any_le): Likewise.
(u, su): Likewise.
(optab, insn): Likewise.
* config/riscv/iterators.md: New file.

22 months agoFix PR 106690: enable effective_target_bswap for RISCV targets with ZBB enabled by...
Andrew Pinski [Fri, 19 Aug 2022 22:09:30 +0000 (22:09 +0000)]
Fix PR 106690: enable effective_target_bswap for RISCV targets with ZBB enabled by default

While looking for testcases to quickly test, I Noticed that
check_effective_target_bswap was not enabled for riscv when
ZBB is enabled. This patch checks if ZBB is enabled when
targeting RISCV* for bswap.

OK? Ran the testsuite for riscv32-linux-gnu both with and without ZBB enabled.

PR testsuite/106690
gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_bswap):
Return true if riscv and ZBB ISA extension is enabled.

22 months agoFix PR 106601: __builtin_bswap16 code gen could be improved with ZBB enabled
Andrew Pinski [Fri, 19 Aug 2022 17:46:40 +0000 (17:46 +0000)]
Fix PR 106601: __builtin_bswap16 code gen could be improved with ZBB enabled

The default expansion for bswap16 is two extractions (shift/and)
followed by an insertation (ior) and then a zero extend. This can be improved
with ZBB enabled to just full byteswap followed by a (logical) shift right.
This patch adds a new pattern for this which does that.

OK? Built and tested on riscv32-linux-gnu and riscv64-linux-gnu.

gcc/ChangeLog:

PR target/106601
* config/riscv/bitmanip.md (bswaphi2): New pattern.

gcc/testsuite/ChangeLog:

PR target/106601
* gcc.target/riscv/zbb_32_bswap-2.c: New test.
* gcc.target/riscv/zbb_bswap-2.c: New test.

22 months agoFix PR 106600: __builtin_bswap32 is not hooked up for ZBB for 32bit
Andrew Pinski [Fri, 19 Aug 2022 17:01:02 +0000 (17:01 +0000)]
Fix PR 106600: __builtin_bswap32 is not hooked up for ZBB for 32bit

The problem here is the bswap<mode>2 pattern had a check for TARGET_64BIT
but then used the X iterator. Since the X iterator is either SI or DI depending
on the setting TARGET_64BIT, there is no reason for the TARGET_64BIT.

OK? Built and tested on both riscv32-linux-gnu and riscv64-linux-gnu.

Thanks,
Andrew Pinski

gcc/ChangeLog:

PR target/106600
* config/riscv/bitmanip.md (bswap<mode>2): Remove
condition on TARGET_64BIT as X is already conditional there.

gcc/testsuite/ChangeLog:

PR target/106600
* gcc.target/riscv/zbb_32_bswap-1.c: New test.
* gcc.target/riscv/zbb_bswap-1.c: New test.

22 months agoFortran: improve error recovery while simplifying size of bad array [PR103694]
Harald Anlauf [Tue, 23 Aug 2022 20:16:14 +0000 (22:16 +0200)]
Fortran: improve error recovery while simplifying size of bad array [PR103694]

gcc/fortran/ChangeLog:

PR fortran/103694
* simplify.cc (simplify_size): The size expression of an array cannot
be simplified if an error occurs while resolving the array spec.

gcc/testsuite/ChangeLog:

PR fortran/103694
* gfortran.dg/pr103694.f90: New test.

22 months agolibstdc++: Fix regression in std::stable_sort
Jonathan Wakely [Wed, 24 Aug 2022 12:53:27 +0000 (13:53 +0100)]
libstdc++: Fix regression in std::stable_sort

The recent change to split out the cold path of std::stable_sort caused
a regression for some Qt code. The problem is that the library now adds
a value of type ptrdiff_t to the iterator, which is ambiguous with
-pedantic. The addition could either convert the iterator to a built-in
pointer and add the ptrdiff_t to that, or it could convert the ptrdiff_t
to the iterator's difference_type and use the iterator's own operator+.

The fix is to cast the ptrdiff_t value to the difference type first.

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h (__stable_sort): Cast size to
iterator's difference type.
* testsuite/25_algorithms/stable_sort/4.cc: New test.

22 months agolibstdc++: Optimize operator+(string/char*, char*/string) equally
Will Hawkins [Wed, 24 Aug 2022 06:16:48 +0000 (02:16 -0400)]
libstdc++: Optimize operator+(string/char*, char*/string) equally

Until now operator+(char*, const string&) and operator+(const string&,
char*) had different performance characteristics. The former required a
single memory allocation and the latter required two. This patch makes
the performance equal.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (operator+(const string&, const char*)):
Remove naive implementation.
* include/bits/basic_string.tcc (operator+(const string&, const char*)):
Add single-allocation implementation.

Signed-off-by: Will Hawkins <whh8b@obs.cr>
22 months agotree.cc: Fix optimization of DFP default initialization
Joseph Myers [Wed, 24 Aug 2022 14:10:25 +0000 (14:10 +0000)]
tree.cc: Fix optimization of DFP default initialization

When an object of decimal floating-point type is default-initialized,
GCC is inconsistent about whether it is given the all-zero-bits
representation (zero with the least quantum exponent) or whether it
acts like a conversion of integer 0 to the DFP type (zero with quantum
exponent 0).  In particular, the representation stored in memory can
have all zero bits, but optimization of access to the same object
based on its known constant value can then produce zero with quantum
exponent 0 instead.

C2x leaves the quantum exponent for default initialization
implementation-defined, but that doesn't allow such inconsistency in
the interpretation of a single object.  All zero bits seems most
appropriate; change build_real to special-case dconst0 the same way
other constants are special-cased and ensure that the correct zero for
the type is generated.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/
* tree.cc (build_real): Give DFP dconst0 the minimum quantum
exponent for the type.

gcc/testsuite/
* gcc.dg/torture/dfp-default-init-1.c,
gcc.dg/torture/dfp-default-init-2.c,
gcc.dg/torture/dfp-default-init-3.c: New tests.

22 months agobpf: facilitate constant propagation of function addresses
Jose E. Marchesi [Wed, 24 Aug 2022 11:07:57 +0000 (13:07 +0200)]
bpf: facilitate constant propagation of function addresses

eBPF effectively supports two kind of call instructions:

- The so called pseudo-calls ("bpf to bpf").
- External calls ("bpf to kernel").

The BPF call instruction always gets an immediate argument, whose
interpretation varies depending on the purpose of the instruction:

- For pseudo-calls, the immediate argument is interpreted as a
  32-bit PC-relative displacement measured in number of 64-bit words
  minus one.

- For external calls, the immediate argument is interpreted as the
  identification of a kernel helper.

In order to differenciate both flavors of CALL instructions the SRC
field of the instruction (otherwise unused) is abused as an opcode;
if the field holds 0 the instruction is an external call, if it holds
BPF_PSEUDO_CALL the instruction is a pseudo-call.

C-to-BPF toolchains, including the GNU toolchain, use the following
practical heuristic at assembly time in order to determine what kind
of CALL instruction to generate: call instructions requiring a fixup
at assembly time are interpreted as pseudo-calls.  This means that in
practice a call instruction involving symbols at assembly time (such
as `call foo') is assembled into a pseudo-call instruction, whereas
something like `call 12' is assembled into an external call
instruction.

In both cases, the argument of CALL is an immediate: at the time of
writing eBPF lacks support for indirect calls, i.e. there is no
call-to-register instruction.

This is the reason why BPF programs, in practice, rely on certain
optimizations to happen in order to generate calls to immediates.
This is a typical example involving a kernel helper:

  static void * (*bpf_map_lookup_elem)(void *map, const void *key)
    = (void *) 1;

  int foo (...)
  {
    char *ret;

    ret = bpf_map_lookup_elem (args...);
    if (ret)
      return 1;
    return 0;
  }

Note how the code above relies on the compiler to do constant
propagation so the call to bpf_map_lookup_elem can be compiled to a
`call 1' instruction.

While GCC provides a kernel_helper function declaration attribute that
can be used in a robust way to tell GCC to generate an external call
despite of optimization level and any other consideration, the Linux
kernel bpf_helpers.h file relies on tricks like the above.

This patch modifies the BPF backend to avoid SSA sparse constant
propagation to be "undone" by the expander loading the function
address into a register.  A new test is also added.

Tested in bpf-unknown-linux-gnu.
No regressions.

gcc/ChangeLog:

PR target/106733
* config/bpf/bpf.cc (bpf_legitimate_address_p): Recognize integer
constants as legitimate addresses for functions.
(bpf_small_register_classes_for_mode_p): Define target hook.

gcc/testsuite/ChangeLog:

PR target/106733
* gcc.target/bpf/constant-calls.c: Rename to ...
* gcc.target/bpf/constant-calls-1.c: and modify to not expect
failure anymore.
* gcc.target/bpf/constant-calls-2.c: New test.

22 months agolibstdc++: Add check for LWG 3741 problem case
Jonathan Wakely [Tue, 23 Aug 2022 23:10:59 +0000 (00:10 +0100)]
libstdc++: Add check for LWG 3741 problem case

This LWG issue was closed as NAD, as it was just a bug in an
implementation, not a defect in the standard. Libstdc++ never had that
bug and always worked for the problem case. Add a test to ensure we
don't regress.

The problem occurs when abs is implemented using a ternary expression:

 return d >= d.zero() ? d : -d;

If decltype(-d) is not the same as decltype(d) then this is ambiguous,
because each type can be converted to the other, so there is no common
type.

libstdc++-v3/ChangeLog:

* testsuite/20_util/duration_cast/rounding.cc: Check abs with
non-reduced duration.

22 months agoMove things around in predicate analysis
Richard Biener [Wed, 24 Aug 2022 09:45:43 +0000 (11:45 +0200)]
Move things around in predicate analysis

This moves a few functions, notably normalization after a big comment
documenting it.  I've left the rest unorganized for now.

* gimple-predicate-analysis.cc: Move predicate normalization
after the comment documenting it.

22 months agoSplit uninit analysis from predicate analysis
Richard Biener [Wed, 24 Aug 2022 09:22:55 +0000 (11:22 +0200)]
Split uninit analysis from predicate analysis

This splits the API collected in gimple-predicate-analysis.h into
what I'd call a predicate and assorted functionality plus utility
used by the uninit pass that happens to use that.  I've tried to
be minimalistic with refactoring, there's still recursive
instantiation of uninit_analysis, the new class encapsulating a
series of uninit analysis queries from the uninit pass.  But it
at least should make the predicate part actually reusable and
what predicate is dealt with is a little bit more clear in the
uninit_analysis part.

I will followup with moving the predicate implementation bits
together in the gimple-predicate-analysis.cc file.

* gimple-predicate-analysis.h (predicate): Split out
non-predicate related functionality into ..
(uninit_analysis): .. this new class.
* gimple-predicate-analysis.cc: Refactor into two classes.
* tree-ssa-uninit.cc (find_uninit_use): Use uninit_analysis.

22 months agoSome more predicate analysis TLC
Richard Biener [Wed, 24 Aug 2022 08:08:17 +0000 (10:08 +0200)]
Some more predicate analysis TLC

This limits the simple control dep also to the cd_root plus avoids
filling the lazily computed PHI def predicate in the early out path
which would leave it not simplified and normalized if it were
re-used.  It also avoids computing the use predicates when the
post-dominance early out doesn't need it.  It also syncs
predicate::use_cannot_happen with init_from_phi_def, adding the
missing PHI edge to the computed chains (the simple control dep
code already adds it).

* gimple-predicate-analysis.cc (predicate::use_cannot_happen):
Do simple_control_dep_chain only up to cd_root, add the PHI
operand edge to the chains like init_from_phi_def does.
(predicate::is_use_guarded): Speedup early out, avoid half-way
initializing the PHI def predicate.

22 months agoi386: Fix up mode iterators that weren't expanded [PR106721]
Jakub Jelinek [Wed, 24 Aug 2022 07:57:09 +0000 (09:57 +0200)]
i386: Fix up mode iterators that weren't expanded [PR106721]

Currently, when md file reader sees <something> and something is valid mode
(or code) attribute but which doesn't include case for the current mode
(or code), it just keeps the <something> untouched.
I went through all cases matching <[a-zA-Z] in tmp-mddump.md after make mddump.
Most of the cases were related to the recent V*BF mode additions, some
to V*HF mode too, and there was one typo.

2022-08-24  Jakub Jelinek  <jakub@redhat.com>

PR target/106721
* config/i386/sse.md (shuffletype): Add V32BF, V16BF and V8BF entries.
Change V32HF, V16HF and V8HF entries from "f" to "i".
(iptr): Add V32BF, V16BF, V8BF and BF entries.
(i128vldq): Add V16HF and V16BF entries.
(avx512er_vmrcp28<mode><mask_name><round_saeonly_name>): Fix typo,
mask_opernad3 -> mask_operand3.

* gcc.target/i386/avx512vl-pr106721.c: New test.

22 months agopreprocessor: Implement C++23 P2437R1 - Support for #warning [PR106646]
Jakub Jelinek [Wed, 24 Aug 2022 07:55:57 +0000 (09:55 +0200)]
preprocessor: Implement C++23 P2437R1 - Support for #warning [PR106646]

On Thu, Aug 18, 2022 at 11:02:44PM +0000, Joseph Myers wrote:
> ISO C2x standardizes the existing #warning extension.  Arrange
> accordingly for it not to be diagnosed with -std=c2x -pedantic, but to
> be diagnosed with -Wc11-c2x-compat.

And here is the corresponding C++ version.
Don't pedwarn about this for C++23/GNU++23 and tweak the diagnostics
for C++ otherwise, + testsuite coverage.
The diagnostic wording is similar e.g. to the #elifdef diagnostics.

2022-08-24  Jakub Jelinek  <jakub@redhat.com>

PR c++/106646
* init.cc: Implement C++23 P2437R1 - Support for #warning.
(lang_defaults): Set warning_directive for GNUCXX23 and CXX23.
* directives.cc (directive_diagnostics): Use different wording of
#warning pedwarn for C++.

* g++.dg/cpp/warning-1.C: New test.
* g++.dg/cpp/warning-2.C: New test.
* g++.dg/cpp/warning-3.C: New test.

22 months agogcov: fix file and function summary information
Martin Liska [Wed, 10 Aug 2022 10:51:12 +0000 (12:51 +0200)]
gcov: fix file and function summary information

gcc/ChangeLog:

* gcov.cc (add_line_counts): Add group functions to coverage
summary.
(accumulate_line_counts): Similarly for files.

Co-Authored-By: Jørgen Kvalsvik <j@lambda.is>
22 months agoLoongArch: Add new code model 'medium'.
Lulu Cheng [Sat, 20 Aug 2022 07:19:51 +0000 (15:19 +0800)]
LoongArch: Add new code model 'medium'.

The function jump instruction in normal mode is 'bl',
so the scope of the function jump is +-128MB.

Now we've added support for 'medium' mode, this mode is
to complete the function jump through two instructions:
pcalau12i + jirl
So in this mode the function jump range is increased to +-2GB.

Compared with 'normal' mode, 'medium' mode only affects the
jump range of functions.

gcc/ChangeLog:

* config/loongarch/genopts/loongarch-strings: Support code model medium.
* config/loongarch/genopts/loongarch.opt.in: Likewise.
* config/loongarch/loongarch-def.c: Likewise.
* config/loongarch/loongarch-def.h (CMODEL_LARGE): Likewise.
(CMODEL_EXTREME): Likewise.
(N_CMODEL_TYPES): Likewise.
(CMODEL_MEDIUM): Likewise.
* config/loongarch/loongarch-opts.cc: Likewise.
* config/loongarch/loongarch-opts.h (TARGET_CMODEL_MEDIUM): Likewise.
* config/loongarch/loongarch-str.h (STR_CMODEL_MEDIUM): Likewise.
* config/loongarch/loongarch.cc (loongarch_call_tls_get_addr):
Tls symbol Loading support medium mode.
(loongarch_legitimize_call_address): When medium mode, make a symbolic
jump with two instructions.
(loongarch_option_override_internal): Support medium.
* config/loongarch/loongarch.md (@pcalau12i<mode>): New template.
(@sibcall_internal_1<mode>): New function call templates added to support
medium mode.
(@sibcall_value_internal_1<mode>): Likewise.
(@sibcall_value_multiple_internal_1<mode>): Likewise.
(@call_internal_1<mode>): Likewise.
(@call_value_internal_1<mode>): Likewise.
(@call_value_multiple_internal_1<mode>): Likewise.
* config/loongarch/loongarch.opt: Support medium.
* config/loongarch/predicates.md: Add processing about medium mode.
* doc/invoke.texi: Document for '-mcmodel=medium'.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/func-call-medium-1.c: New test.
* gcc.target/loongarch/func-call-medium-2.c: New test.
* gcc.target/loongarch/func-call-medium-3.c: New test.
* gcc.target/loongarch/func-call-medium-4.c: New test.
* gcc.target/loongarch/func-call-medium-5.c: New test.
* gcc.target/loongarch/func-call-medium-6.c: New test.
* gcc.target/loongarch/func-call-medium-7.c: New test.
* gcc.target/loongarch/func-call-medium-8.c: New test.
* gcc.target/loongarch/tls-gd-noplt.c: Add compile parameter '-mexplicit-relocs'.

22 months agoSpeedup path discovery in predicate::use_cannot_happen
Richard Biener [Tue, 23 Aug 2022 12:05:34 +0000 (14:05 +0200)]
Speedup path discovery in predicate::use_cannot_happen

The following reverts a hunk from r8-5789-g11ef0b22d68cd1 that
made compute_control_dep_chain start from function entry rather
than the immediate dominator of the source block of the edge with
the undefined value on the PHI node.  Reverting at that point
does not reveal any testsuite FAIL, in particular the added
testcase still passes.  The following adjusts this to the other
function that computes predicates that hold on the PHI incoming
edges with undefined values, predicate::init_from_phi_def, which
starts at the immediate dominator of the PHI.  That's much less
likely to run into the CFG walking limit.

* gimple-predicate-analysis.cc (predicate::use_cannot_happen):
Start the compute_control_dep_chain walk from the immediate
dominator of the PHI.

22 months agoDaily bump.
GCC Administrator [Wed, 24 Aug 2022 00:16:39 +0000 (00:16 +0000)]
Daily bump.

22 months agoc++: Quash bogus -Wredundant-move warning
Marek Polacek [Mon, 22 Aug 2022 23:13:16 +0000 (19:13 -0400)]
c++: Quash bogus -Wredundant-move warning

This patch fixes a pretty stoopid thinko.  When I added code to warn
about pessimizing std::move in initializations like

  T t{std::move(T())};

I also added code to unwrap the expression from { }.  But when we have

  return {std::move(t)};

we cannot warn about a redundant std::move because the implicit move
wouldn't happen for "return {t};" because the expression isn't just
a name.  However, we still want to warn about

  return {std::move(T())};

so let's not disable the -Wpessimizing-move warning.  Tests added for
both cases.

gcc/cp/ChangeLog:

* typeck.cc (maybe_warn_pessimizing_move): Don't warn about
redundant std::move when the expression was wrapped in { }.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/Wpessimizing-move10.C: New test.
* g++.dg/cpp0x/Wredundant-move12.C: New test.

22 months agox86: Replace vmovdqu with movdqu in BF16 XMM ABI tests
H.J. Lu [Tue, 23 Aug 2022 20:32:01 +0000 (13:32 -0700)]
x86: Replace vmovdqu with movdqu in BF16 XMM ABI tests

Since XMM BF16 tests only require SSE2, replace vmovdqu with movdqu in
BF16 XMM ABI tests to support SSE2 machines without AVX.

Tested on x86-64 machines with and without AVX.

* gcc.target/x86_64/abi/bf16/asm-support.S: Replace vmovdqu with
movdqu.

22 months agoUpdate gcc .po files
Joseph Myers [Tue, 23 Aug 2022 19:18:31 +0000 (19:18 +0000)]
Update gcc .po files

* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
zh_TW.po: Update.

22 months agolibstdc++: Implement std::pair/tuple/misc enhancements from P2321R2
Patrick Palka [Tue, 23 Aug 2022 17:42:37 +0000 (13:42 -0400)]
libstdc++: Implement std::pair/tuple/misc enhancements from P2321R2

This implements the non-<ranges> changes from P2321R2, which primarily
consist of additional converting constructors, assignment operator and
swap overloads for std::pair and std::tuple.

libstdc++-v3/ChangeLog:

* include/bits/stl_bvector.h (_Bit_reference::operator=): Define
const overload for C++23 as per P2321R2.
* include/bits/stl_pair.h (pair::swap): Likewise.
(pair::pair): Define additional converting constructors for
C++23 as per P2321R2.
(pair::operator=): Define const overloads for C++23 as per
P2321R2.
(swap): Define overload taking const pair& for C++23 as per
P2321R2.
(basic_common_reference): Define partial specialization for
pair for C++23 as per P2321R2.
(common_type): Likewise.
* include/bits/uses_allocator_args.h
(uses_allocator_construction_args): Define additional pair
overloads for C++23 as per P2321R2.
* include/std/tuple (_Tuple_impl::_Tuple_impl): Define
additional converting constructors for C++23 as per P2321R2.
(_Tuple_impl::_M_assign): Define const overloads for C++23
as per P2321R2.
(_Tuple_impl::_M_swap): Likewise.
(tuple::__constructible): Define as a convenient renaming of
_TCC<true>::__constructible.
(tuple::__convertible): As above but for _TCC<true>::__convertible.
(tuple::tuple): Define additional converting constructors for
C++23 as per P2321R2.
(tuple::operator=): Define const overloads for C++23 as per
P2321R2.
(tuple::swap): Likewise.
(basic_common_reference): Define partial specialization for
tuple for C++23 as per P2321R2.
(common_type): Likewise.
* testsuite/20_util/pair/p2321r2.cc: New test.
* testsuite/20_util/tuple/p2321r2.cc: New test.
* testsuite/23_containers/vector/bool/element_access/1.cc: New test.

22 months agolibstdc++: Separate construct/convertibility tests for std::tuple
Patrick Palka [Tue, 23 Aug 2022 17:35:49 +0000 (13:35 -0400)]
libstdc++: Separate construct/convertibility tests for std::tuple

P2321R2 adds additional conditionally explicit constructors to std::tuple
which we'll concisely implement in a subsequent patch using explicit(bool),
like in our C++20 std::pair implementation.  This prerequisite patch
adds member typedefs to _TupleConstraints for testing element-wise
constructibility and convertibility separately; we'll use the first in
the new constructors' constraints, and the second in their explicit
specifier.

In passing, this patch also redefines the existing member predicates
__is_ex/implicitly_constructible in terms of these new members.  This
seems to reduce compile time and memory usage by about 10% for large
tuples when using the converting constructors that're constrained by
_Explicit/_ImplicitCtor.

libstdc++-v3/ChangeLog:

* include/std/tuple (_TupleConstraints::__convertible): Define.
(_TupleConstraints::__constructible): Define.
(_TupleConstraints::__is_explicitly_constructible): Redefine this
in terms of __convertible and __constructible.
(_TupleConstraints::__is_implicitly_constructible): Likewise.

22 months agolibstdc++: Fix visit<void>(v) for non-void visitors [PR106589]
Jonathan Wakely [Tue, 23 Aug 2022 14:46:16 +0000 (15:46 +0100)]
libstdc++: Fix visit<void>(v) for non-void visitors [PR106589]

The optimization for the common case of std::visit forgot to handle the
edge case of passing zero variants to a non-void visitor and converting
the result to void.

libstdc++-v3/ChangeLog:

PR libstdc++/106589
* include/std/variant (__do_visit): Handle is_void<R> for zero
argument case.
* testsuite/20_util/variant/visit_r.cc: Check std::visit<void>(v).

22 months agox86: Cast stride to __PTRDIFF_TYPE__ in AMX intrinsics
H.J. Lu [Thu, 18 Aug 2022 21:17:33 +0000 (14:17 -0700)]
x86: Cast stride to __PTRDIFF_TYPE__ in AMX intrinsics

On 64-bit Windows, long is 32 bits and can't be used as stride in memory
operand when base is a pointer which is 64 bits.  Cast stride to
__PTRDIFF_TYPE__, instead of long.

PR target/106714
* config/i386/amxtileintrin.h (_tile_loadd_internal): Cast to
__PTRDIFF_TYPE__.
(_tile_stream_loadd_internal): Likewise.
(_tile_stored_internal): Likewise.

22 months agotree-optimization/106722 - uninit analysis with long def -> use path
Richard Biener [Tue, 23 Aug 2022 11:58:31 +0000 (13:58 +0200)]
tree-optimization/106722 - uninit analysis with long def -> use path

The following applies similar measures as r13-2133-ge66cf626c72d58
to the computation of the use predicate when the path from PHI def
to use is too long and we run into compute_control_dep_chain limits.

It also moves the preprocessor define limits internal.

This resolves the reduced testcase but not the original one.

PR tree-optimization/106722
* gimple-predicate-analysis.h (MAX_NUM_CHAINS, MAX_CHAIN_LEN,
MAX_POSTDOM_CHECK, MAX_SWITCH_CASES): Move ...
* gimple-predicate-analysis.cc: ... here and document.
(simple_control_dep_chain): New function, factored from
predicate::use_cannot_happen.
(predicate::use_cannot_happen): Adjust.
(predicate::predicate): Use simple_control_dep_chain as fallback.

* g++.dg/uninit-pr106722-1.C: New testcase.

22 months agotestsuite: Add test for r11-4123
Marek Polacek [Mon, 22 Aug 2022 16:43:30 +0000 (12:43 -0400)]
testsuite: Add test for r11-4123

r11-4123 came without a test but I happened upon a nice test case that
got fixed by that revision.  So I think it'd be good to add it.  The
ICE was:

phi-1.C: In constructor 'ElementManager::ElementManager()':
phi-1.C:28:1: error: missing definition
   28 | ElementManager::ElementManager() : array_(makeArray()) {}
      | ^~~~~~~~~~~~~~
for SSA_NAME: _12 in statement:
_10 = PHI <_12(3), _11(5)>
PHI argument
_12
for PHI node
_10 = PHI <_12(3), _11(5)>
during GIMPLE pass: fixup_cfg
phi-1.C:28:1: internal compiler error: verify_ssa failed

gcc/testsuite/ChangeLog:

* g++.dg/torture/phi-1.C: New test.

22 months agoNew uninit testcase
Richard Biener [Tue, 23 Aug 2022 12:30:05 +0000 (14:30 +0200)]
New uninit testcase

I've reduced the following which doesn't seem covered in a good enough
way in the testsuite.

* gcc.dg/uninit-pred-10.c: New testcase.

22 months agogfortran.dg/gomp/depend-6.f90: Minor fix
Tobias Burnus [Tue, 23 Aug 2022 11:14:19 +0000 (13:14 +0200)]
gfortran.dg/gomp/depend-6.f90: Minor fix

Exactly the same as previous commit for depend-4.f90, r13-2151.

gcc/testsuite/

* gfortran.dg/gomp/depend-6.f90: Fix array index use for
depobj var + update scan-tree-dump-times.

22 months agogfortran.dg/gomp/depend-4.f90: Minor fix
Tobias Burnus [Tue, 23 Aug 2022 10:31:43 +0000 (12:31 +0200)]
gfortran.dg/gomp/depend-4.f90: Minor fix

gcc/testsuite/

* gfortran.dg/gomp/depend-4.f90: Fix array index use for
depobj var + update scan-tree-dump-times.

22 months agoCopy range from op2 in foperator_equal::op1_range.
Aldy Hernandez [Sat, 20 Aug 2022 10:41:27 +0000 (12:41 +0200)]
Copy range from op2 in foperator_equal::op1_range.

Like the integer version, when op1 == op2 is known to be true the
ranges are also equal.

gcc/ChangeLog:

* range-op-float.cc (foperator_equal::op1_range): Set range to
range of op2.

22 months agoRefactor is_non_loop_exit_postdominating
Richard Biener [Mon, 22 Aug 2022 13:24:23 +0000 (15:24 +0200)]
Refactor is_non_loop_exit_postdominating

That's a weird function in predicate analysis that currently looks like

/* Return true if BB1 is postdominating BB2 and BB1 is not a loop exit
   bb.  The loop exit bb check is simple and does not cover all cases.  */
static bool
is_non_loop_exit_postdominating (basic_block bb1, basic_block bb2)
{
  if (!dominated_by_p (CDI_POST_DOMINATORS, bb2, bb1))
    return false;
  if (single_pred_p (bb1) && !single_succ_p (bb2))
    return false;
  return true;
}

One can refactor this to

  return (dominated_by_p (CDI_POST_DOMINATORS, bb2, bb1)
          && !(single_pred_p (bb1) && !single_succ_p (bb2)));

Notable is that the comment refers to BB1 with respect to a loop
exit but the test seems to be written with an exit edge bb1 -> bb2
in mind.  None of the three callers are guaranteed to have bb1 and
bb2 connected directly with an edge.

The patch now introduces a is_loop_exit function and inlines
the post-dominance check which makes the find_control_equiv_block
case simpler because the post-dominance check can be elided.
It also avoids the double negation in compute_control_dep_chain
and makes it obvious this is the case where we do look at an edge.
For the main is_use_guarded API I chose to elide the loop exit
test, if the use block post-dominates the definition block of the
PHI node the use is always unconditional.  I don't quite understand
the loop exit special-casing of the remaining two uses though.

* gimple-predicate-analysis.cc (is_loop_exit): Split out
from ...
(is_non_loop_exit_postdominating): ... here.  Remove after
inlining ...
(find_control_equiv_block): ... here.
(compute_control_dep_chain): ... and here.
(predicate::is_use_guarded): Do not excempt loop exits
from short-cutting the case of the use post-dominating the
PHI definition.

22 months agoAdd __m128bf16/__m256bf16/__m512bf16 type for bf16 abi test
Haochen Jiang [Mon, 22 Aug 2022 02:04:16 +0000 (10:04 +0800)]
Add __m128bf16/__m256bf16/__m512bf16 type for bf16 abi test

Fix the abi test fail issue caused by type missing.

gcc/testsuite/ChangeLog:

* gcc.target/x86_64/abi/bf16/bf16-helper.h:
Add _m128bf16/m256bf16/_m512bf16.
* gcc.target/x86_64/abi/bf16/m512bf16/bf16-zmm-check.h:
Include bf16-helper.h.

22 months agoReturn the correct relation
Andrew MacLeod [Mon, 22 Aug 2022 19:40:48 +0000 (15:40 -0400)]
Return the correct relation

With an input condition of op1 > op2, and evaluating the unsigned expression:
LHS = op1 - op2
range-ops was returning LHS < op1 , which is incorrect as op2 coould be
zero.  This patch adjusts it to return LHS <= op1.

PR tree-optimization/106687
gcc/
* range-op.cc (operator_minus::lhs_op1_relation): Return VREL_LE
for the VREL_GT case as well.

gcc/testsuite/
* g++.dg/pr106687.C: New.

22 months agoDaily bump.
GCC Administrator [Tue, 23 Aug 2022 00:16:29 +0000 (00:16 +0000)]
Daily bump.

22 months agolibstdc++: Document linker option for C++23 <stacktrace> [PR105678]
Jonathan Wakely [Mon, 22 Aug 2022 16:24:27 +0000 (17:24 +0100)]
libstdc++: Document linker option for C++23 <stacktrace> [PR105678]

libstdc++-v3/ChangeLog:

PR libstdc++/105678
* doc/xml/manual/using.xml: Document -lstdc++_libbacktrace
requirement for using std::stacktrace. Also adjust -frtti and
-fexceptions to document non-default (i.e. negative) forms.
* doc/html/*: Regenerate.

22 months agolibstdc++: Fix for explicit copy ctors in <thread> and <future> [PR106695]
Jonathan Wakely [Mon, 22 Aug 2022 14:42:17 +0000 (15:42 +0100)]
libstdc++: Fix for explicit copy ctors in <thread> and <future> [PR106695]

When I changed std::thread and std::async to avoid unnecessary move
construction of temporaries, I introduced a regression where types with
an explicit copy constructor could not be passed to std::thread or
std::async. The fix is to add a constructor instead of using aggregate
initialization of an unnamed temporary.

libstdc++-v3/ChangeLog:

PR libstdc++/106695
* include/bits/std_thread.h (thread::_State_impl): Forward
individual arguments to _Invoker constructor.
(thread::_Invoker): Add constructor. Delete copies.
* include/std/future (__future_base::_Deferred_state): Forward
individual arguments to _Invoker constructor.
(__future_base::_Async_state_impl): Likewise.
* testsuite/30_threads/async/106695.cc: New test.
* testsuite/30_threads/thread/106695.cc: New test.

22 months agolibstdc++: Check for overflow in regex back-reference [PR106607]
Jonathan Wakely [Mon, 22 Aug 2022 14:16:16 +0000 (15:16 +0100)]
libstdc++: Check for overflow in regex back-reference [PR106607]

Currently we fail to notice integer overflow when parsing a
back-reference expression, or when converting the parsed result from
long to int. This changes the result to be int, so no conversion is
needed, and uses the overflow-checking built-ins to detect an
out-of-range back-reference.

libstdc++-v3/ChangeLog:

PR libstdc++/106607
* include/bits/regex_compiler.tcc (_Compiler::_M_cur_int_value):
Use built-ins to check for integer overflow in back-reference
number.
* testsuite/28_regex/basic_regex/106607.cc: New test.

22 months agopru: Optimize 64-bit logical operations
Dimitar Dimitrov [Sat, 20 Aug 2022 20:58:27 +0000 (23:58 +0300)]
pru: Optimize 64-bit logical operations

The earlyclobber in the pattern yields inefficient code due to
unnecessarily generated moves.  Optimize by removing the earlyclobber
for two special alternatives:
  - If OP2 is a small constant integer.
  - If the logical bit operation has only two operands.

gcc/ChangeLog:

* config/pru/pru.md (pru_<code>di3): New alternative for
two operands but without earlyclobber.

gcc/testsuite/ChangeLog:

* gcc.target/pru/bitop-di.c: New test.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>