Commit graph

195609 commits

Author SHA1 Message Date
Jakub Jelinek
b04208895f c++: Implement P1467R9 - Extended floating-point types and standard names compiler part except for bfloat16 [PR106652]
The following patch implements the compiler part of C++23
P1467R9 - Extended floating-point types and standard names compiler part
by introducing _Float{16,32,64,128} as keywords and builtin types
like they are implemented for C already since GCC 7, with DF{16,32,64,128}_
mangling.
It also introduces _Float{32,64,128}x for C++ with the
https://github.com/itanium-cxx-abi/cxx-abi/pull/147
proposed mangling of DF{32,64,128}x.
The patch doesn't add anything for bfloat16_t support, as right now
__bf16 type refuses all conversions and arithmetic operations.
The patch wants to keep backwards compatibility with how __float128 has
been handled in C++ before, both for mangling and behavior in binary
operations, overload resolution etc.  So, there are some backend changes
where for C __float128 and _Float128 are the same type (float128_type_node
and float128t_type_node are the same pointer), but for C++ they are distinct
types which mangle differently and _Float128 is treated as extended
floating-point type while __float128 is treated as non-standard floating
point type.  The various C++23 changes about how floating-point types
are changed are actually implemented as written in the spec only if at least
one of the types involved is _Float{16,32,64,128,32x,64x,128x} (_FloatNx are
also treated as extended floating-point types) and kept previous behavior
otherwise.  For float/double/long double the rules are actually written that
they behave the same as before.
There is some backwards incompatibility at least on x86 regarding _Float16,
because that type was already used by that name and with the DF16_ mangling
(but only since GCC 12 and I think it isn't that widely used in the wild
yet).  E.g. config/i386/avx512fp16intrin.h shows the issues, where
in C or in GCC 12 in C++ one could pass 0.0f to a builtin taking _Float16
argument, but with the changes that is not possible anymore, one needs
to either use 0.0f16 or (_Float16) 0.0f.
We have also a problem with glibc headers, where since glibc 2.27
math.h and complex.h aren't compilable with these changes.  One gets
errors like:
In file included from /usr/include/math.h:43,
                 from abc.c:1:
/usr/include/bits/floatn.h:86:9: error: multiple types in one declaration
   86 | typedef __float128 _Float128;
      |         ^~~~~~~~~~
/usr/include/bits/floatn.h:86:20: error: declaration does not declare anything [-fpermissive]
   86 | typedef __float128 _Float128;
      |                    ^~~~~~~~~
In file included from /usr/include/bits/floatn.h:119:
/usr/include/bits/floatn-common.h:214:9: error: multiple types in one declaration
  214 | typedef float _Float32;
      |         ^~~~~
/usr/include/bits/floatn-common.h:214:15: error: declaration does not declare anything [-fpermissive]
  214 | typedef float _Float32;
      |               ^~~~~~~~
/usr/include/bits/floatn-common.h:251:9: error: multiple types in one declaration
  251 | typedef double _Float64;
      |         ^~~~~~
/usr/include/bits/floatn-common.h:251:16: error: declaration does not declare anything [-fpermissive]
  251 | typedef double _Float64;
      |                ^~~~~~~~
This is from snippets like:
 /* The remaining of this file provides support for older compilers.  */
 # if __HAVE_FLOAT128

 /* The type _Float128 exists only since GCC 7.0.  */
 #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
 typedef __float128 _Float128;
 #  endif
where it hardcodes that C++ doesn't have _Float{16,32,64,128,32x,64x,128x} support nor
{f,F}{16,32,64,128}{,x} literal suffixes nor _Complex _Float{16,32,64,128,32x,64x,128x}.
The patch fixincludes this for now and hopefully if this is committed, then
glibc can change those.  The patch changes those
 #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
conditions to
 #  if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0))
Another thing is mangling, as said above, Itanium C++ ABI specifies
DF <number> _ as _Float{16,32,64,128} mangling, but GCC was implementing
a mangling incompatible with that starting with DF for fixed point types.
Fixed point was never supported in C++ though, I believe the reason why
the mangling has been added was that due to a bug it would leak into the
C++ FE through decltype (0.0r) etc.  But that has been shortly after the
mangling was added fixed (I think in the same GCC release cycle), so we
now reject 0.0r etc. in C++.  If we ever need the fixed point mangling,
I think it can be readded but better with a different prefix so that it
doesn't conflict with the published standard manglings.  So, this patch
also kills the fixed point mangling and implements the DF <number> _
demangling.
The patch predefines __STDCPP_FLOAT{16,32,64,128}_T__ macros when
those types are available, but only for C++23, while the underlying types
are available in C++98 and later including the {f,F}{16,32,64,128} literal
suffixes (but those with a pedwarn for C++20 and earlier).  My understanding
is that it needs to be predefined by the compiler, on the other side
predefining even for older modes when <stdfloat> is a new C++23 header
would be weird.  One can find out if _Float{16,32,64,128,32x,64x,128x} is
supported in C++ by
__GNUC__ >= 13 && defined(__FLT{16,32,64,128,32X,64X,128X}_MANT_DIG__)
(but that doesn't work well with older G++ 13 snapshots).

As for std::bfloat16_t, three targets (aarch64, arm and x86) apparently
"support" __bf16 type which has the bfloat16 format, but isn't really
usable, e.g. {aarch64,arm,ix86}_invalid_conversion disallow any conversions
from or to type with BFmode, {aarch64,arm,ix86}_invalid_unary_op disallows
any unary operations on those except for ADDR_EXPR and
{aarch64,arm,ix86}_invalid_binary_op disallows any binary operation on
those.  So, I think we satisfy:
"If the implementation supports an extended floating-point type with the
properties, as specified by ISO/IEC/IEEE 60559, of radix (b) of 2, storage
width in bits (k) of 16, precision in bits (p) of 8, maximum exponent (emax)
of 127, and exponent field width in bits (w) of 8, then the typedef-name
std::bfloat16_t is defined in the header <stdfloat> and names such a type,
the macro __STDCPP_BFLOAT16_T__ is defined, and the floating-point literal
suffixes bf16 and BF16 are supported."
because we don't really support those right now.

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

	PR c++/106652
	PR c++/85518
gcc/
	* tree-core.h (enum tree_index): Add TI_FLOAT128T_TYPE
	enumerator.
	* tree.h (float128t_type_node): Define.
	* tree.cc (build_common_tree_nodes): Initialize float128t_type_node.
	* builtins.def (DEF_FLOATN_BUILTIN): Adjust comment now that
	_Float<N> is supported in C++ too.
	* config/i386/i386.cc (ix86_mangle_type): Only mangle as "g"
	float128t_type_node.
	* config/i386/i386-builtins.cc (ix86_init_builtin_types): Use
	float128t_type_node for __float128 instead of float128_type_node
	and create it if NULL.
	* config/i386/avx512fp16intrin.h (_mm_setzero_ph, _mm256_setzero_ph,
	_mm512_setzero_ph, _mm_set_sh, _mm_load_sh): Use 0.0f16 instead of
	0.0f.
	* config/ia64/ia64.cc (ia64_init_builtins): Use
	float128t_type_node for __float128 instead of float128_type_node
	and create it if NULL.
	* config/rs6000/rs6000-c.cc (is_float128_p): Also return true
	for float128t_type_node if non-NULL.
	* config/rs6000/rs6000.cc (rs6000_mangle_type): Don't mangle
	float128_type_node as "u9__ieee128".
	* config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Use
	float128t_type_node for __float128 instead of float128_type_node
	and create it if NULL.
gcc/c-family/
	* c-common.cc (c_common_reswords): Change _Float{16,32,64,128} and
	_Float{32,64,128}x flags from D_CONLY to 0.
	(shorten_binary_op): Punt if common_type returns error_mark_node.
	(shorten_compare): Likewise.
	(c_common_nodes_and_builtins): For C++ record _Float{16,32,64,128}
	and _Float{32,64,128}x builtin types if available.  For C++
	clear float128t_type_node.
	* c-cppbuiltin.cc (c_cpp_builtins): Predefine
	__STDCPP_FLOAT{16,32,64,128}_T__ for C++23 if supported.
	* c-lex.cc (interpret_float): For q/Q suffixes prefer
	float128t_type_node over float128_type_node.  Allow
	{f,F}{16,32,64,128} suffixes for C++ if supported with pedwarn
	for C++20 and older.  Allow {f,F}{32,64,128}x suffixes for C++
	with pedwarn.  Don't call excess_precision_type for C++.
gcc/cp/
	* cp-tree.h (cp_compare_floating_point_conversion_ranks): Implement
	P1467R9 - Extended floating-point types and standard names except
	for std::bfloat16_t for now.  Declare.
	(extended_float_type_p): New inline function.
	* mangle.cc (write_builtin_type): Mangle float{16,32,64,128}_type_node
	as DF{16,32,64,128}_.  Mangle float{32,64,128}x_type_node as
	DF{32,64,128}x.  Remove FIXED_POINT_TYPE mangling that conflicts
	with that.
	* typeck2.cc (check_narrowing): If one of ftype or type is extended
	floating-point type, compare floating-point conversion ranks.
	* parser.cc (cp_keyword_starts_decl_specifier_p): Handle
	CASE_RID_FLOATN_NX.
	(cp_parser_simple_type_specifier): Likewise and diagnose missing
	_Float<N> or _Float<N>x support if not supported by target.
	* typeck.cc (cp_compare_floating_point_conversion_ranks): New function.
	(cp_common_type): If both types are REAL_TYPE and one or both are
	extended floating-point types, select common type based on comparison
	of floating-point conversion ranks and subranks.
	(cp_build_binary_op): Diagnose operation with floating point arguments
	with unordered conversion ranks.
	* call.cc (standard_conversion): For floating-point conversion, if
	either from or to are extended floating-point types, set conv->bad_p
	for implicit conversion from larger to smaller conversion rank or
	with unordered conversion ranks.
	(convert_like_internal): Emit a pedwarn on such conversions.
	(build_conditional_expr): Diagnose operation with floating point
	arguments with unordered conversion ranks.
	(convert_arg_to_ellipsis): Don't promote extended floating-point types
	narrower than double to double.
	(compare_ics): Implement P1467R9 [over.ics.rank]/4 changes.
gcc/testsuite/
	* g++.dg/cpp23/ext-floating1.C: New test.
	* g++.dg/cpp23/ext-floating2.C: New test.
	* g++.dg/cpp23/ext-floating3.C: New test.
	* g++.dg/cpp23/ext-floating4.C: New test.
	* g++.dg/cpp23/ext-floating5.C: New test.
	* g++.dg/cpp23/ext-floating6.C: New test.
	* g++.dg/cpp23/ext-floating7.C: New test.
	* g++.dg/cpp23/ext-floating8.C: New test.
	* g++.dg/cpp23/ext-floating9.C: New test.
	* g++.dg/cpp23/ext-floating10.C: New test.
	* g++.dg/cpp23/ext-floating.h: New file.
	* g++.target/i386/float16-1.C: Adjust expected diagnostics.
libcpp/
	* expr.cc (interpret_float_suffix): Allow {f,F}{16,32,64,128} and
	{f,F}{32,64,128}x suffixes for C++.
include/
	* demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.
	(struct demangle_component): Add u.s_extended_builtin member.
libiberty/
	* cp-demangle.c (d_dump): Handle
	DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.  Don't handle
	DEMANGLE_COMPONENT_FIXED_TYPE.
	(d_make_extended_builtin_type): New function.
	(cplus_demangle_builtin_types): Add _Float entry.
	(cplus_demangle_type): For DF demangle it as _Float<N> or
	_Float<N>x rather than fixed point which conflicts with it.
	(d_count_templates_scopes): Handle
	DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.  Just break; for
	DEMANGLE_COMPONENT_FIXED_TYPE.
	(d_find_pack): Handle DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.
	Don't handle DEMANGLE_COMPONENT_FIXED_TYPE.
	(d_print_comp_inner): Likewise.
	* cp-demangle.h (D_BUILTIN_TYPE_COUNT): Bump.
	* testsuite/demangle-expected: Replace _Z3xxxDFyuVb test
	with _Z3xxxDF16_DF32_DF64_DF128_CDF16_Vb.  Add
	_Z3xxxDF32xDF64xDF128xCDF32xVb test.
fixincludes/
	* inclhack.def (glibc_cxx_floatn_1, glibc_cxx_floatn_2,
	glibc_cxx_floatn_3): New fixes.
	* tests/base/bits/floatn.h: New file.
	* fixincl.x: Regenerated.
2022-09-27 08:18:00 +02:00
Meghan Denny
8be65640e1 Updated constants from <https://dwarfstd.org/Languages.php>
include
	* dwarf2.h: Update with additional languages from dwarf
	standard.
2022-09-26 23:51:52 -04:00
GCC Administrator
220c4d8e44 Daily bump. 2022-09-27 00:17:52 +00:00
Jonathan Wakely
03cb9ed8dd libstdc++: Update std::pointer_traits to match new LWG 3545 wording
It was pointed out in recent LWG 3545 discussion that having a
constrained partial specialization of std::pointer_traits can cause
ambiguities with program-defined specializations. For example, the
addition to the testcase has:

template<typename P> requires std::derived_from<P, base_type
struct std::pointer_traits<P>;

This would be ambiguous with the library's own constrained partial
specialization:

template<typename Ptr> requires requires { typename Ptr::element_type; }
struct std::pointer_traits<Ptr>;

Neither specialization is more specialized than the other for a type
that is derived from base_type and also has an element_type member.

The solution is to remove the library's partial specialization, and do
the check for Ptr::element_type in the __ptr_traits_elem helper (which
is what we already do for !__cpp_concepts anyway).

libstdc++-v3/ChangeLog:

	* include/bits/ptr_traits.h (__ptr_traits_elem) [__cpp_concepts]:
	Also define the __ptr_traits_elem class template for the
	concepts case.
	(pointer_traits<Ptr>): Remove constrained partial
	specialization.
	* testsuite/20_util/pointer_traits/lwg3545.cc: Check for
	ambiguitiy with program-defined partial specialization.
2022-09-26 23:47:37 +01:00
Jonathan Wakely
af85ad8917 libstdc++: Use new built-ins for std::is_convertible traits
libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_convertible, is_convertible_v):
	Define using new built-in.
	(is_nothrow_convertible is_nothrow_convertible_v): Likewise.
2022-09-26 23:47:37 +01:00
Martin Liska
7701ea4a70 docs: add missing dash in option name
gcc/ChangeLog:

	* doc/invoke.texi: Add missing dash for
	  Wanalyzer-exposure-through-uninit-copy.
2022-09-26 21:04:11 +02:00
Marek Polacek
567329fdd9 c++: P2513R4, char8_t Compatibility and Portability Fix [PR106656]
P0482R6, which added char8_t, didn't allow

  const char arr[] = u8"howdy";

because it said "Declarations of arrays of char may currently be initialized
with UTF-8 string literals. Under this proposal, such initializations would
become ill-formed."  This caused too many issues, so P2513R4 alleviates some
of those compatibility problems.  In particular, "Arrays of char or unsigned
char may now be initialized with a UTF-8 string literal."  This restriction
has been lifted for initialization only, not implicit conversions.  Also,
my reading is that 'signed char' was excluded from the allowable conversions.

This is supposed to be treated as a DR in C++20.

	PR c++/106656

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Update value of __cpp_char8_t
	for C++20.

gcc/cp/ChangeLog:

	* typeck2.cc (array_string_literal_compatible_p): Allow
	initializing arrays of char or unsigned char by a UTF-8 string literal.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/feat-cxx2b.C: Adjust.
	* g++.dg/cpp2a/feat-cxx2a.C: Likewise.
	* g++.dg/ext/char8_t-feature-test-macro-2.C: Likewise.
	* g++.dg/ext/char8_t-init-2.C: Likewise.
	* g++.dg/cpp2a/char8_t3.C: New test.
	* g++.dg/cpp2a/char8_t4.C: New test.
2022-09-26 13:34:04 -04:00
Aldy Hernandez
5e77d4082f Optimize [0 = x & MASK] in range-ops.
For [0 = x & MASK], we can determine that x is ~MASK.  This is
something we're picking up in DOM thanks to maybe_set_nonzero_bits,
but is something we should handle natively.

This is a good example of how much easier to maintain the range-ops
entries are versus the ad-hoc pattern matching stuff we had to do
before.  For the curious, compare the changes to range-op here,
versus maybe_set_nonzero_bits.

I'm leaving the call to maybe_set_nonzero_bits until I can properly
audit it to make sure we're catching it all in range-ops.  It won't
hurt, since both set_range_info() and set_nonzero_bits() are
intersect operations, so we'll never lose information if we do both.

	PR tree-optimization/107009

gcc/ChangeLog:

	* range-op.cc (operator_bitwise_and::op1_range): Optimize 0 = x & MASK.
	(range_op_bitwise_and_tests): New test.
2022-09-26 19:24:58 +02:00
Marek Polacek
be4b32b9ef c++: Instantiate less when evaluating __is_convertible
Jon reported that evaluating __is_convertible in a test led to
instantiating something ill-formed and so we failed to compile the test.
__is_convertible doesn't and shouldn't need to instantiate so much, so
let's limit it with a cp_unevaluated guard.  Use a helper function to
implement both built-ins.

	PR c++/106784

gcc/cp/ChangeLog:

	* method.cc (is_convertible_helper): New.
	(is_convertible): Use it.
	(is_nothrow_convertible): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/is_convertible3.C: New test.
	* g++.dg/ext/is_nothrow_convertible3.C: New test.
2022-09-26 12:20:38 -04:00
Patrick Palka
099a66498b c++ modules: variable template partial spec fixes [PR107033]
In r13-2775-g32d8123cd6ce87 I missed that we need to adjust the call to
add_mergeable_specialization in the MK_partial case to correctly handle
variable template partial specializations (it currently assumes we're
always dealing with one for a class template).  This fixes an ICE when
converting the testcase from that commit to use an importable header
instead of a named module.

	PR c++/107033

gcc/cp/ChangeLog:

	* module.cc (trees_in::decl_value): In the MK_partial case for
	a variable template partial specialization, pass decl_p=true to
	add_mergeable_specialization, and set spec to the VAR_DECL not
	the TEMPLATE_DECL.
	* pt.cc (add_mergeable_specialization): For a variable template
	partial specialization, set the TREE_TYPE of the new
	DECL_TEMPLATE_SPECIALIZATIONS node to the TREE_TYPE of the
	VAR_DECL not the VAR_DECL itself.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/partial-2.cc, g++.dg/modules/partial-2.h: New
	files, factored out from ...
	* g++.dg/modules/partial-2_a.C, g++.dg/modules/partial-2_b.C: ...
	these.
	* g++.dg/modules/partial-2_c.H: New test.
	* g++.dg/modules/partial-2_d.C: New test.
2022-09-26 11:30:17 -04:00
Jeff Law
1b5432b401 Update my address and DCO entry in MAINTAINERS file
/
	* MAINTAINERS: Update my email address and DCO entry.
2022-09-26 09:14:55 -06:00
Aldy Hernandez
2460f7cdef Set ranges from unreachable edges for all known ranges.
In the conversion of DOM+evrp to DOM+ranger, we missed that evrp was
exporting ranges for unreachable edges for all SSA names for which we
have ranges for.  Instead we have only been exporting ranges for the
SSA name in the final conditional to the BB involving the unreachable
edge.

This patch adjusts adjusts DOM to iterate over the exports, similarly
to what evrp was doing.

Note that I also noticed that we don't calculate the nonzero bit mask
for op1, when 0 = op1 & MASK.  This isn't needed for this PR,
since maybe_set_nonzero_bits() is chasing the definition and
parsing the bitwise and on its own.  However, I'll be adding the
functionality for completeness sake, plus we could probably drop the
maybe_set_nonzero_bits legacy call entirely.

	PR tree-optimization/107009

gcc/ChangeLog:

	* tree-ssa-dom.cc
	(dom_opt_dom_walker::set_global_ranges_from_unreachable_edges):
	Iterate over exports.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr107009.c: New test.
2022-09-26 16:39:29 +02:00
Thomas Schwinge
e9019085e1 nvptx: Allow '--with-arch' to override the default '-misa'
gcc/
	* config.gcc (with_arch) [nvptx]: Allow '--with-arch' to override
	the default.
	* config/nvptx/gen-multilib-matches.sh: New.
	* config/nvptx/t-nvptx (MULTILIB_OPTIONS, MULTILIB_MATCHES)
	(MULTILIB_EXCEPTIONS): Handle this.
	* doc/install.texi (Specific) <nvptx-*-none>: Document this.
	* doc/invoke.texi (Nvidia PTX Options): Likewise.
2022-09-26 16:06:01 +02:00
Thomas Schwinge
4d94582e0d nvptx: Introduce dummy multilib option for default '-misa=sm_30'
... primarily in preparation for later changes.

	gcc/
	* config.gcc (TM_MULTILIB_CONFIG) [nvptx]: Set to '$with_arch'.
	* config/nvptx/t-nvptx (MULTILIB_OPTIONS, MULTILIB_MATCHES)
	(MULTILIB_EXCEPTIONS): Handle it.
2022-09-26 16:03:36 +02:00
Thomas Schwinge
108b99b6c4 nvptx: Make default '-misa=sm_30' explicit
... primarily in preparation for later changes.

	gcc/
	* config.gcc (with_arch) [nvptx]: Set to 'sm_30'.
	* config/nvptx/nvptx.cc (nvptx_option_override): Assert that
	'-misa' appeared.
	* config/nvptx/nvptx.h (OPTION_DEFAULT_SPECS): Define.
	* config/nvptx/nvptx.opt (misa=): Remove 'Init'.
2022-09-26 16:00:38 +02:00
Thomas Schwinge
84072a2615 nvptx: forward '-v' command-line option to assembler
For example, for offloading compilation with '-save-temps -v', before vs. after
word-diff then looks like:

    [...]
     [...]/build-gcc-offload-nvptx-none/gcc/as {+-v -v+} -o ./a.xnvptx-none.mkoffload.o ./a.xnvptx-none.mkoffload.s
    {+Verifying sm_30 code with sm_35 code generation.+}
    {+ ptxas -c -o /dev/null ./a.xnvptx-none.mkoffload.o --gpu-name sm_35 -O0+}
    [...]

(This depends on <https://github.com/MentorEmbedded/nvptx-tools/pull/37>
"Put '-v' verbose output onto stderr instead of stdout".)

	gcc/
	* config/nvptx/nvptx.h (ASM_SPEC): Define.
2022-09-26 16:00:09 +02:00
Jeff Law
1b74b5cb4e [RFA] Minor improvement to coremark, avoid unconditional jump to return
gcc/
	* cfgcleanup.cc (bb_is_just_return): No longer static.
	* cfgcleanup.h (bb_is_just_return): Add prototype.
	* cfgrtl.cc (fixup_reorder_chain): Do not create an
	unconditional jump to a return block.  Conditionally
	remove unreachable blocks.

gcc/testsuite/

	* gcc.target/riscv/ret-1.c: New test.
2022-09-26 09:40:41 -04:00
Thomas Neumann
386ebf75f4 fix assert in __deregister_frame_info_bases
When using the atomic fast path deregistering can fail during
program shutdown if the lookup structures are already destroyed.
The assert in __deregister_frame_info_bases takes that into
account. In the non-fast-path case however is not aware of
program shutdown, which caused a compiler error on such platforms.
We fix that by introducing a constant for in_shutdown in
non-fast-path builds.
We also drop the destructor priority, as it is not supported on
all platforms and we no longer rely upon the priority anyway.

libgcc/ChangeLog:
	* unwind-dw2-fde.c: Introduce a constant for in_shutdown
	for the non-fast-path case. Drop destructor priority.
2022-09-26 15:12:02 +02:00
Jonathan Wakely
6904ed80a2 libstdc++: Add #if around non-C++03 code in std::bitset [PR107037]
libstdc++-v3/ChangeLog:

	PR libstdc++/107037
	* include/std/bitset (_Base_bitset::_M_do_reset): Use
	preprocessor conditional around non-C++03 code.
	* testsuite/20_util/bitset/107037.cc: New test.
2022-09-26 12:00:07 +01:00
Tobias Burnus
d3df98807b OpenACC: Fix reduction tree-sharing issue [PR106982]
The tree for var == incoming == outgound was
'MEM <double[5]> [(double *)&reduced]' which caused the ICE
"incorrect sharing of tree nodes".

	PR middle-end/106982

gcc/ChangeLog:

	* omp-low.cc (lower_oacc_reductions): Add some unshare_expr.

gcc/testsuite/ChangeLog:

	* c-c++-common/goacc/reduction-7.c: New test.
	* c-c++-common/goacc/reduction-8.c: New test.
2022-09-26 12:45:28 +02:00
Martin Liska
2387cfc7f6 s390: fix wrong refactoring
Since r13-2251-g1930c5d05ceff2, the refactoring is not 1:1 and we end
up with a wrong rtx type.

gcc/ChangeLog:

	* config/s390/s390.cc (s390_rtx_costs): Remove dest variable
	and use only dst.
2022-09-26 12:08:13 +02:00
Kyrylo Tkachov
c33e12fa47 aarch64: Add -march support for Armv9.1-A, Armv9.2-A, Armv9.3-A
This is a straightforward patch that allows targeting the architecture revisions mentioned in the subject
through -march. These are already supported in binutils.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

	* config/aarch64/aarch64-arches.def (armv9.1-a): Define.
	(armv9.2-a): Likewise.
	(armv9.3-a): Likewise.
	* config/aarch64/aarch64.h (AARCH64_FL_V9_1): Likewise.
	(AARCH64_FL_V9_2): Likewise.
	(AARCH64_FL_V9_3): Likewise.
	(AARCH64_FL_FOR_ARCH9_1): Likewise.
	(AARCH64_FL_FOR_ARCH9_2): Likewise.
	(AARCH64_FL_FOR_ARCH9_3): Likewise.
	(AARCH64_ISA_V9_1): Likewise.
	(AARCH64_ISA_V9_2): Likewise.
	(AARCH64_ISA_V9_3): Likewise.
	* doc/invoke.texi (AArch64 Options): Document armv9.1-a, armv9.2-a,
	armv9.3-a values to -march.
2022-09-26 10:14:30 +01:00
Ghjuvan Lacambre
3a2ae05208 ada: Doc: rename Valid_Image to Valid_Value
This renaming happened some time ago in the code, but the documentation
was not updated.

gcc/ada/

	* doc/gnat_rm/implementation_defined_attributes.rst: Rename Valid_Image.
	* gnat_rm.texi: Regenerate.
	* gnat_ugn.texi: Regenerate.
2022-09-26 11:02:31 +02:00
Piotr Trojanek
a490e7da3a ada: Fix location of pragmas coming from aspects in top-level instances
This patch fixes an AST anomaly where pragmas that correspond to aspects
of a generic package declaration appeared as the auxiliary declarations
of the compilation unit for the instantiated package body.

In particular, this anomaly happened for aspect Annotate and affected
GNATprove, which didn't pick pragma corresponding to this aspect.

gcc/ada/

	* sem_ch12.adb (Build_Instance_Compilation_Unit_Nodes): Relocate
	auxiliary declarations from the original compilation unit to the
	newly created compilation unit for the spec.
2022-09-26 11:02:31 +02:00
Piotr Trojanek
756efb7484 ada: Remove unreferenced Rtsfind entries
Remove unreferenced entries for finding runtime units and runtime
entities by the compiler. Code cleanup using basic grep scripting.

gcc/ada/

	* rtsfind.ads
	(RTU_Id): Remove unreferenced packages; fix whitespace.
	(RE_Id): Remove unreferenced entities; add comment about entity
	that is only used by GNATprove and not by GNAT.
2022-09-26 11:02:31 +02:00
Piotr Trojanek
dda025c9ce ada: Remove unreferenced C macro from OS constants template
The STR/STR1 macros in OS constants template has been unreferenced since
2005, so we can safely remove them.

gcc/ada/

	* s-oscons-tmplt.c (STR, STR1): Remove.
2022-09-26 11:02:31 +02:00
Eric Botcazou
c381ccdf06 ada: Document Long_Long_Long_Size parameter for -gnateT
This was overlooked when the new parameter was created.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(-gnateT): Document new parameter Long_Long_Long_Size.
	* gnat_ugn.texi: Regenerate.
2022-09-26 11:02:30 +02:00
Steve Baird
37645e2cd7 ada: Improve CUDA host-side and device-side binder support
Binder-generated code is not allowed to use Ada2012 syntax. In order to
specify an aspect, a pragma must be used.

gcc/ada/

	* bindgen.adb: When the binder is invoked for the device, specify
	the CUDA_Global aspect for the adainit and adafinal procedures via
	a pragma instead of via an aspect_specification.
2022-09-26 11:02:30 +02:00
Kévin Le Gouguec
6b8e3ee10f ada: Document support for the mold linker
gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(Linker Switches): Document support for mold along with gold; add some
	advice regarding OpenSSL in the Pro version.
	* gnat_ugn.texi: Regenerate.
2022-09-26 11:02:30 +02:00
Tucker Taft
91c706565f ada: Make Original_Aspect_Pragma_Name more precise
This commit makes Original_Aspect_Pragma_Name more precise in cases
where there is a second level of indirection caused by pragmas being
turned into Check pragmas.

gcc/ada/

	* sem_util.adb (Original_Aspect_Pragma_Name): Check for Check
	pragmas.
2022-09-26 11:02:30 +02:00
Piotr Trojanek
4450567167 ada: Delay expansion of iterator specification in preanalysis
When preanalysing spec expression (e.g. expression of an expression
function), the name of iterator specification should not be expanded.

This patch simplifies a complicated condition for delaying expansion
within quantified expressions and iterated component associations.

gcc/ada/

	* sem_ch5.adb (Analyze_Iterator_Specification): Delay expansion
	based on Full_Analysis flag.
2022-09-26 11:02:30 +02:00
Piotr Trojanek
2ef56cae72 ada: Delay expansion of iterated component association
When preanalysing spec expression (e.g. expression of an expression
function), the name of iterator specification within an iterated
component association should not be expanded, especially in GNATprove
mode.

gcc/ada/

	* sem_ch5.adb (Analyze_Iterator_Specification): Delay expansion of
	for iterated component association just like it is done within
	quantified expression.
2022-09-26 11:02:30 +02:00
Piotr Trojanek
5549d2695a ada: Only reject volatile ghost objects when SPARK_Mode is On
SPARK rule that forbids ghost volatile objects is only affecting proof
and not generation of object code. It is now only applied where SPARK_Mode
is On. This flexibility is needed to compile code automatically instrumented
by GNATcoverage.

gcc/ada/

	* contracts.adb (Analyze_Object_Contract): Check SPARK_Mode before
	applying SPARK rule.
2022-09-26 11:02:30 +02:00
Justin Squirek
6305563579 ada: Improve accessibility check generation
Improve accessibility check generation by more precisely identifying cases in
which an Original_Node call is needed.

Instead of grabbing the Original_Node of a prefix in all cases (since this
can cause issues where unanalyzed instance names get referenced) we only
obtain the original node when said prefix comes as a result of expanding
function calls.

gcc/ada/

	* sem_util.adb
	(Accessibility_Level): Modify indexed and selected components case
	by reducing the scope where Original_Node gets used.
2022-09-26 11:02:30 +02:00
Boris Yakobowski
9677984d7b ada: Remove GNATmetric's documentation from GNAT's documentation
gcc/ada/

	* doc/gnat_ugn/gnat_utility_programs.rst: Remove documentation for
	gnatmetric.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
092d7509db ada: Remove socket definitions for ancient MinGW
Modern MinGW defines _WIN32_WINNT as 0xa00, so there is no need go guard
against it being lower than 0x0600 or setting it to 0x0501.

gcc/ada/

	* gsocket.h: Remove redefinition of _WIN32_WINNT.
	* mingw32.h: Remove conditional definition of _WIN32_WINNT.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
af61dc3ffd ada: Remove definition of MAXPATHLEN for ancient MinGW
Modern MinGW defines MAXPATHLEN in sys/param.h, so better to use it
directly.

gcc/ada/

	* mingw32.h: Remove condition definition of MAXPATHLEN; the include
	directive for stdlib.h was most likely intended to provide the
	MAX_PATH.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
09b91bbcdd ada: Deconstruct build support for ancient MinGW
Remove conditional C code for building GNAT with MinGW earlier than 2.0,
which was released in 2007.

gcc/ada/

	* adaint.c: Remove conditional #include directives for old MinGW.
	* cal.c: Always include winsock.h, since it is part of modern
	MinGW.
	* cstreams.c: Remove workaround for old MinGW.
	* expect.c: Remove conditional #include directive for old MinGW.
	* mingw32.h: Remove STD_MINGW and OLD_MINGW declarations.
	* sysdep.c: Remove conditional #include directive for old MinGW.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
fb95fb2125 ada: Tune comment of routine for detecting junk names
Reword comment to avoid repetition between spec and body.

gcc/ada/

	* sem_warn.ads (Has_Junk_Name): Reword comment.
2022-09-26 11:02:29 +02:00
Eric Botcazou
6c37375640 Small tweaks. 2022-09-26 10:44:43 +02:00
Martin Liska
7ed1a816ba ranger: remove unused function
gcc/ChangeLog:

	* value-range.cc (tree_compare): Remove unused function.
2022-09-26 09:30:44 +02:00
Kewen Lin
5be0950d22 rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]
As PR96072 shows, the code adding REG_CFA_DEF_CFA reg note
makes one assumption that we have emitted one insn which
restores the frame pointer previously.  That part of code
was guarded with flag frame_pointer_needed before, it was
consistent, but it was replaced with flag
frame_pointer_needed_indeed since commit r10-7981.  It
caused ICE due to unexpected NULL insn.

	PR target/96072

gcc/ChangeLog:

	* config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): Update the
	condition for adding REG_CFA_DEF_CFA reg note with
	frame_pointer_needed_indeed.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr96072.c: New test.
2022-09-26 00:33:18 -05:00
Hu, Lin1
9c9cf4f087 testsuite: Fix up avx256-unaligned-store-3.c test.
gcc/testsuite/ChangeLog:

	PR target/94962
	* gcc.target/i386/avx256-unaligned-store-3.c: Add -mno-avx512f
2022-09-26 13:30:26 +08:00
Kewen Lin
bfad7069b7 rs6000: Fix condition of define_expand vec_shr_<mode> [PR100645]
PR100645 exposes one latent bug in define_expand vec_shr_<mode>
that the current condition TARGET_ALTIVEC is too loose.  The
mode iterator VEC_L contains a few modes, they are not always
supported as vector mode, VECTOR_UNIT_ALTIVEC_OR_VSX_P should
be used like some other VEC_L usages.

	PR target/100645

gcc/ChangeLog:

	* config/rs6000/vector.md (vec_shr_<mode>): Replace condition
	TARGET_ALTIVEC with VECTOR_UNIT_ALTIVEC_OR_VSX_P.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr100645.c: New test.
2022-09-25 22:23:44 -05:00
liuhongt
3db8e9c242 Support 2-instruction vector shuffle for V4SI/V4SF in ix86_expand_vec_perm_const_1.
2022-09-23  Hongtao Liu  <hongtao.liu@intel.com>
	    Liwei Xu  <liwei.xu@intel.com>

gcc/ChangeLog:

	PR target/53346
	* config/i386/i386-expand.cc (expand_vec_perm_shufps_shufps):
	New function.
	(ix86_expand_vec_perm_const_1): Insert
	expand_vec_perm_shufps_shufps at the end of 2-instruction
	expand sequence.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr53346-1.c: New test.
	* gcc.target/i386/pr53346-2.c: New test.
	* gcc.target/i386/pr53346-3.c: New test.
	* gcc.target/i386/pr53346-4.c: New test.
2022-09-26 11:20:46 +08:00
GCC Administrator
de613c6295 Daily bump. 2022-09-26 00:18:09 +00:00
Mikael Morin
77bbf69d29 fortran: Support clobbering of derived types [PR41453]
This adds support for clobbering of non-polymorphic derived type
variables, when they are passed as actual argument whose associated
dummy has the INTENT(OUT) attribute.

We avoid to play with non-constant type sizes or class descriptors by
requiring that the types are derived (not class) and strictly matching,
and by excluding parameterized derived types.

Types that are used in the callee are also excluded: they are types with
allocatable components (the components will be deallocated), and
finalizable types or types with finalizable components (they will be
passed to finalization routines).

	PR fortran/41453

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Allow strictly
	matching derived types.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_10.f90: New test.
2022-09-25 14:44:54 +02:00
Mikael Morin
95375ffb3d fortran: Support clobbering of allocatables and pointers [PR41453]
This adds support for clobbering of allocatable and pointer scalar
variables passed as actual argument to a subroutine when the associated
dummy has the INTENT(OUT) attribute.
Support was explicitly disabled (since the beginning for pointers, since
r11-7315-g2df374b337a5f6cf5528e91718e4e12e4006b7ae for allocatables),
but the clobber generation code seems to support it well, as
demonstrated by the newly added testcase.

	PR fortran/41453
	PR fortran/99169

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Remove conditions
	on ALLOCATABLE and POINTER attributes guarding clobber
	generation.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_9.f90: New test.
2022-09-25 14:44:54 +02:00
Mikael Morin
d5e1935b09 fortran: Support clobbering of ASSOCIATE variables [PR41453]
This is in spirit a revert of:
r9-3051-gc109362313623d83fe0a5194bceaf994cf0c6ce0

That commit added a condition to avoid generating ICE with clobbers
of ASSOCIATE variables.
The test added at that point continues to pass if we remove that
condition now.

	PR fortran/41453
	PR fortran/87401

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Remove condition
	disabling clobber generation for ASSOCIATE variables.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_8.f90: New test.
2022-09-25 14:44:54 +02:00
Mikael Morin
467ef2c40d fortran: Support clobbering of SAVE variables [PR41453]
This removes a condition added in:
r9-3032-gee7fb0588c6361b4d77337ab0f7527be64fcdde2.

That commit added a condition to avoid generating ICE with clobbers
of variables with the SAVE attribute.
The test added at that point continues to pass if we remove that
condition now.

	PR fortran/41453
	PR fortran/87395

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Remove condition
	on SAVE attribute guarding clobber generation.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_7.f90: New test.
2022-09-25 14:44:54 +02:00