197167 Commits

Author SHA1 Message Date
Maciej W. Rozycki
936d40b9ba testsuite: Fix missing EFFECTIVE_TARGETS variable errors
Permit running vector tests outside `check_vect_support_and_set_flags'
environment, removing errors such as:

ERROR: gcc.dg/analyzer/torture/pr93350.c   -O0 : can't read "EFFECTIVE_TARGETS": no such variable for " dg-require-effective-target 1 vect_int "

or:

ERROR: gcc.dg/bic-bitmask-13.c: error executing dg-final: can't read "EFFECTIVE_TARGETS": no such variable

with `mips-linux-gnu' target testing.

The EFFECTIVE_TARGETS variable has originated from commit 9b7937cf8a06
("Add support to run auto-vectorization tests for multiple effective
targets."), where arrangements have been made to run vector tests run
within `check_vect_support_and_set_flags' environment iteratively over
all the vector unit variants available in the architecture using extra
compilation flags regardless of whether the target environment arranged
for a particular testsuite run has vector support enabled by default.
So far this has been used for the MIPS target only.

Vector tests have since been added though that run outside environment
set up by `check_vect_support_and_set_flags' just using the current
compilation environment with no extra flags added.  This works for most
targets, however causes problems with the MIPS target, because outside
`check_vect_support_and_set_flags' environment the EFFECTIVE_TARGETS
variable will not have been correctly set up even if it was added to
the particular script invoking the test in question.

Fix this by using just the current compilation environment whenever a
vector feature is requested by `et-is-effective-target' in the absence
of the EFFECTIVE_TARGETS variable.  This required some modification to
individual vector feature tests, which always added the compilation
flags required for the determination of whether the given vector unit
variant can be verified with the current testsuite run (except for the
Loongson MMI variant).  Now explicit flags are only passed in setting up
EFFECTIVE_TARGETS and otherwise the current compilation environment will
determine whether such a vector test is applicable.

This changes how Loongson MMI is handled in that the `-mloongson-mmi'
flag is explicitly passed for the determination of whether this vector
unit variant can be verified, which I gather is how it was supposed to
be arranged anyway because the flag is then added for testing the
Loongson MMI variant.

	gcc/testsuite/
	* lib/target-supports.exp
	(check_effective_target_mpaired_single): Add `args' argument and
	pass it to `check_no_compiler_messages' replacing
	`-mpaired-single'.
	(add_options_for_mips_loongson_mmi): Add `args' argument and
	pass it to `check_no_compiler_messages'.
	(check_effective_target_mips_msa): Add `args' argument and pass
	it to `check_no_compiler_messages' replacing `-mmsa'.
	(check_effective_target_mpaired_single_runtime)
	(add_options_for_mpaired_single): Pass `-mpaired-single' to
	`check_effective_target_mpaired_single'.
	(check_effective_target_mips_loongson_mmi_runtime)
	(add_options_for_mips_loongson_mmi): Pass `-mloongson-mmi' to
	`check_effective_target_mips_loongson_mmi'.
	(check_effective_target_mips_msa_runtime)
	(add_options_for_mips_msa): Pass `-mmsa' to
	`check_effective_target_mips_msa'.
	(et-is-effective-target): Verify that EFFECTIVE_TARGETS exists
	and if not, just check if the current compilation environment
	supports the target feature requested.
	(check_vect_support_and_set_flags): Pass `-mpaired-single',
	`-mloongson-mmi', and `-mmsa' to the respective target feature
	checks.
2022-11-22 18:22:16 +00:00
Eric Botcazou
55cb8c5c9a Fix wrong array type conversion with different storage orde
When two arrays of scalars have a different storage order in Ada, the
front-end makes sure that the conversion is performed component-wise
so that each component can be reversed.  So it's a little bit counter
productive that the ldist pass performs the opposite transformation
and synthesizes a memcpy/memmove in this case.

gcc/
	* tree-loop-distribution.cc (loop_distribution::classify_builtin_ldst):
	Bail out if source and destination do not have the same storage order.

gcc/testsuite/
	* gnat.dg/sso18.adb: New test.
2022-11-22 19:04:58 +01:00
Jonathan Wakely
dfc1ea414e libstdc++: Replace std::isdigit and std::isxdigit in <format> [PR107817]
These functions aren't usable in constant expressions. Provide our own
implementations, based on __from_chars_alnum_to_val from <charconv>.

libstdc++-v3/ChangeLog:

	PR libstdc++/107817
	* include/std/charconv (__from_chars_alnum_to_val): Add
	constexpr for C++20.
	* include/std/format (__is_digit, __is_xdigit): New functions.
	(_Spec::_S_parse_width_or_precision): Use __is_digit.
	(__formatter_fp::parse): Use __is_xdigit.
2022-11-22 17:45:46 +00:00
Jonathan Wakely
6b859736bb libstdc++: Add testcase for fs::path constraint recursion [PR106201]
libstdc++-v3/ChangeLog:

	PR libstdc++/106201
	* testsuite/27_io/filesystem/iterators/106201.cc: New test.
2022-11-22 17:43:58 +00:00
Martin Jambor
95489a2a27
ipa-sra: Dump edge summaries also for non-candidates
This should have been part of r12-578-g717d278af93a4a.  Call edge
summaries provide information required for IPA-SRA transformations in
the callees but are generated when analyzing callers and thus also
callers which are not IPA-SRA candidates themselves.  Therefore we
analyze them but don't dump them, which makes the dumops quite
incomplete. This patch fixes that.

gcc/ChangeLog:

2021-12-14  Martin Jambor  <mjambor@suse.cz>

	* ipa-sra.cc (ipa_sra_dump_all_summaries): Dump edge summaries even
	for non-candidates.
2022-11-22 18:29:24 +01:00
Martin Jambor
feeb0d68f1
ipa-cp: Do not consider useless aggregate constants
When building vectors of known aggregate values, there is no point in
including those for parameters which are not used in any way
whatsoever.  This patch avoids that together with also other kinds of
constants.

gcc/ChangeLog:

2022-11-13  Martin Jambor  <mjambor@suse.cz>

	* ipa-cp.cc (push_agg_values_from_edge): Do not consider constants
	in unused aggregate parameters.
2022-11-22 18:29:06 +01:00
Martin Jambor
c826a04108
ipa: IPA-SRA split detection simplification
I have noticed that the flag m_split_modifications_p of
ipa_param_body_adjustments is not really necessary as it has to
correspond to whether m_replacements is non-empty so this patches
removes it.  This also simplifies a bit some patches I work on.

gcc/ChangeLog:

2022-11-10  Martin Jambor  <mjambor@suse.cz>

	* ipa-param-manipulation.h (ipa_param_body_adjustments): Removed
	member m_split_modifications_p.
	* ipa-param-manipulation.cc
	(ipa_param_body_adjustments::common_initialization): Do not set
	m_split_modifications_p.
	(ipa_param_body_adjustments::ipa_param_body_adjustments): Remove
	initializations of m_split_modifications_p.
	(ipa_param_body_adjustments::modify_call_stmt): Check that
	m_replacements is empty instead of m_split_modifications_p.
2022-11-22 18:29:01 +01:00
Martin Jambor
c4a92a9117
ipa-cp: Do not be too optimistic about self-recursive edges (PR 107661)
PR 107661 shows that function push_agg_values_for_index_from_edge
should not attempt to optimize self-recursive call graph edges when
called from cgraph_edge_brings_all_agg_vals_for_node.  Unlike when
being called from find_aggregate_values_for_callers_subset, we cannot
expect that any cloning for constants would lead to the edge leading
from a new clone to the same new clone, in this case it would only be
redirected to a new callee.

Fixed by adding a parameter to push_agg_values_from_edge whether being
optimistic about self-recursive edges is possible.

gcc/ChangeLog:

2022-11-22  Martin Jambor  <mjambor@suse.cz>

	PR ipa/107661
	* ipa-cp.cc (push_agg_values_from_edge): New parameter
	optimize_self_recursion, use it to decide whether to pass interim to
	the helper function.
	(find_aggregate_values_for_callers_subset): Pass true in the new
	parameter of push_agg_values_from_edge.
	(cgraph_edge_brings_all_agg_vals_for_node): Pass false in the new
	parameter of push_agg_values_from_edge.

gcc/testsuite/ChangeLog:

2022-11-22  Martin Jambor  <mjambor@suse.cz>

	PR ipa/107661
	* g++.dg/ipa/pr107661.C: New test.
2022-11-22 18:28:44 +01:00
Tobias Burnus
d6bbca7b78 gcn: Add __builtin_gcn_{get_stack_limit,first_call_this_thread_p}
The new builtins have been added for newlib to reduce dependency on
compiler-internal implementation choices of GCC in newlibs' getreent.c.

gcc/ChangeLog:

	* config/gcn/gcn-builtins.def (FIRST_CALL_THIS_THREAD_P,
	GET_STACK_LIMIT): Add new builtins.
	* config/gcn/gcn.cc (gcn_expand_builtin_1): Expand them.
	* config/gcn/gcn.md (prologue_use): Add "register_operand" as
	arg to match_operand.
	(prologue_use_di): New; DI insn_and_split variant of the former.

Co-Authored-By: Andrew Stubbs <ams@codesourcery.com>
2022-11-22 17:57:35 +01:00
Jason Merrill
ac5054144b c++: don't use strchrnul [PR107781]
The contracts implementation was using strchrnul, which is a glibc
extension, so bootstrap broke on non-glibc targets.  Use C89 strcspn
instead.

	PR c++/107781

gcc/cp/ChangeLog:

	* contracts.cc (role_name_equal): Use strcspn instead
	of strchrnul.
2022-11-22 09:27:02 -05:00
Christophe Lyon
4eb3a48698 aarch64: Fix test_dfp_17.c for big-endian [PR 107604]
gcc.target/aarch64/aapcs64/test_dfp_17.c has been failing on
big-endian, because the _Decimal32 on-stack argument is not padded in
the same direction depending on endianness.

This patch fixes the testcase so that it expects the argument in the
right stack location, similarly to what other tests do in the same
directory.

gcc/testsuite/ChangeLog:

	PR target/107604
	* gcc.target/aarch64/aapcs64/test_dfp_17.c: Fix for big-endian.
2022-11-22 14:05:50 +01:00
Piotr Trojanek
61351ab96a ada: Accept aspects Global and Depends on abstract subprograms
Aspects Global and Depends are now allowed on abstract subprograms
(as substitutes for Global'Class and Depends'Class).

This patch implements the recently modified rules SPARK RM 6.1.2(2-3).
The behavior for Contract_Cases and aspects on null subprograms stays
as it was.

gcc/ada/

	* sem_prag.adb (Analyze_Depends_Global): Accept aspects on
	abstract subprograms.
2022-11-22 13:34:51 +01:00
Ghjuvan Lacambre
05894d1c5c ada: Disable checking of Elab_Spec procedures in CodePeer_Mode
This commit re-enables the Validate_Subprogram_Calls check that had been
disabled in a previous commit and has said check skip over Elab_Spec
procedures in CodePeer_Mode.

gcc/ada/

	* frontend.adb (Frontend): Re-enable Validate_Subprogram_Calls.
	* exp_ch6.adb (Check_BIP_Actuals): When in CodePeer mode, do not
	attempt to validate procedures coming from an
	Elab_Spec/Elab_Body/Elab_Subp_Body procedure.
2022-11-22 13:34:51 +01:00
Piotr Trojanek
29b7e00589 ada: Adjust number of errors when removing warning in dead code
When a warning about a runtime exception is emitted for a code in
generic instance, we add continuation warnings "in instantiation ..."
and only the original message increase the total number of errors.

When removing these messages, e.g. after detecting that the code inside
generic instance is dead, we must decrease the total number of errors,
as otherwise the compiler exit status might stop gnatmake or gprbuild.

gcc/ada/

	* errout.adb (To_Be_Removed): Decrease total number of errors when
	removing a warning that has been escalated into error.
	* erroutc.adb (dmsg): Print Warn_Runtime_Raise flag.
2022-11-22 13:34:51 +01:00
Eric Botcazou
3b5f3138dc ada: Fix formatting glitches in Make_Tag_Assignment
gcc/ada/

	* exp_ch3.adb (Make_Tag_Assignment): Fix formatting glitches.
2022-11-22 13:34:51 +01:00
Eric Botcazou
cd4b47a9f7 ada: Fix recent assertion failure on GPR2
It's the compiler trying to load the nonexistent body of a generic package
when trying to inline a call to an expression function of this package that
has a pre or post-condition (hence the need for -gnata to trigger the ICE).

gcc/ada/

	* contracts.adb (Build_Subprogram_Contract_Wrapper): Do not fiddle
	with the Was_Expression_Function flag. Move a few lines around.
2022-11-22 13:34:51 +01:00
Richard Biener
e4faee8d02 tree-optimization/107803 - abnormal cleanup from the SSA propagator
The SSA propagator is missing abnormal cleanup which shows in a
sanity check in the uninit engine (and missed CFG verification).
The following adds that.

	PR tree-optimization/107803
	* tree-ssa-propagate.cc (substitute_and_fold_dom_walker): Add
	need_ab_cleanup member.
	(substitute_and_fold_dom_walker::before_dom_children): When
	a stmt can no longer transfer control flow abnormally set
	need_ab_cleanup.
	(substitute_and_fold_engine::substitute_and_fold): Cleanup
	abnormal control flow.

	* g++.dg/pr107803.C: New testcase.
2022-11-22 12:04:58 +01:00
Jonathan Wakely
0f9659e770 libstdc++: Fix pool resource build errors for H8 [PR107801]
The array of pool sizes was previously adjusted to work for msp430-elf
which has 16-bit int and either 16-bit size_t or 20-bit size_t. The
largest pool sizes were disabled unless size_t has more than 20 bits.

The H8 family has 16-bit int but 32-bit size_t, which means that the
largest sizes are enabled, but 1<<15 produces a negative number that
then cannot be narrowed to size_t.

Replace the test for 32-bit size_t with a test for 32-bit int, which
means we won't use the 4kiB to 4MiB pools for targets with 16-bit int
even if they have a wider size_t.

libstdc++-v3/ChangeLog:

	PR libstdc++/107801
	* src/c++17/memory_resource.cc (pool_sizes): Disable large pools
	for targets with 16-bit int.
2022-11-22 10:24:54 +00:00
Richard Biener
09b7993ab6 tree-optimization/107672 - avoid vector mode type_for_mode call
The following avoids using type_for_mode on vector modes which might
not work for all frontends.  Instead we look for the inner mode
type and use build_vector_type_for_mode instead.

	PR tree-optimization/107672
	* tree-vect-stmts.cc (supportable_widening_operation): Avoid
	type_for_mode on vector modes.
2022-11-22 09:05:18 +01:00
Richard Biener
1a06ae6f2f tree-optimization/107766 - ICE with recent -ffp-contract=off fix
The following uses *node to check for FP types rather than the
child nodes which could be constant leafs and thus without a
vector type.

	PR tree-optimization/107766
	* tree-vect-slp-patterns.cc (complex_mul_pattern::matches):
	Use *node to check for FP vector types.

	* g++.dg/vect/pr107766.cc: New testcase.
2022-11-22 08:06:14 +01:00
liuhongt
d5fce9f6c1 Guard 64/32-bit vector move patterns with ix86_hard_reg_move_ok.
gcc/ChangeLog:

	* config/i386/mmx.md (*mov<mode>_internal): Add
	ix86_hard_reg_move_ok to condition.
2022-11-22 12:50:02 +08:00
liuhongt
826c22dff6 Some tidy up for RA related hooks.
1. We also need to guard size of TO to be
less than TARGET_SSE2 ? 2 : 4 in ix86_can_change_mode_class.
2. Merge VALID_AVX512FP16_SCALAR_MODE plus BFmode
into VALID_AVX512F_SCALAR_MODE since we've support 16-bit data move
above SSE2, so no need for the condition of AVX512FP16 for those evex
sse registers.
3. Allocate DI/HImode to sse register for SSE2 above just like
SImode since we've supported 16-bit data move between sse and gpr
above SSE2, this will help RA to handle cases like (subreg:HI (reg:V8HI)
0) or else RA will spill it. This enable optimization for
pices-memset-{3,37,39}.c

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_can_change_mode_class): Also guard
	size of TO.
	(ix86_hard_regno_mode_ok): Remove VALID_AVX512FP16_SCALAR_MODE
	* config/i386/i386.h (VALID_AVX512FP16_SCALAR_MODE): Merged to
	..
	(VALID_AVX512F_SCALAR_MODE): .. this, also add HImode.
	(VALID_SSE_REG_MODE): Add DI/HImode.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pieces-memset-3.c: Remove xfail.
	* gcc.target/i386/pieces-memset-37.c: Remove xfail.
	* gcc.target/i386/pieces-memset-39.c: Remove xfail.
2022-11-22 12:49:53 +08:00
Jason Merrill
b20a3854c9 c++: contracts fixes
Fixing -Wunused-parm warnings and link errors depending on where -fcontracts
appears on the command line.

gcc/cp/ChangeLog:

	* contracts.cc (build_contract_condition_function):
	Set DECL_ARTIFICIAL on return value parm.
	* g++spec.cc (lang_specific_driver): Add -lstdc++exp
	just before -lstdc++.
2022-11-21 20:23:38 -05:00
GCC Administrator
8b7fee1de9 Daily bump. 2022-11-22 00:17:49 +00:00
David Malcolm
4e4e45a4fd analyzer: fix ICE on 'bind' that returns a struct [PR107788]
gcc/analyzer/ChangeLog:
	PR analyzer/107788
	* region-model.cc (region_model::update_for_int_cst_return):
	Require that the return type be an integer type.
	(region_model::update_for_nonzero_return): Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/107788
	* g++.dg/analyzer/fd-bind-pr107783.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21 19:08:18 -05:00
David Malcolm
12a4785c91 analyzer: fix ICE on 'bind' with non-pointer arg [P107783]
gcc/analyzer/ChangeLog:
	PR analyzer/107783
	* region-model-impl-calls.cc (kf_accept::matches_call_types_p):
	Require that args 1 and 2 be pointers.
	(kf_bind::matches_call_types_p): Require that arg 1 be a pointer.
	* region-model.h (call_details::arg_is_pointer_p): New

gcc/testsuite/ChangeLog:
	PR analyzer/107783
	* gcc.dg/analyzer/fd-bind-pr107783.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21 19:08:17 -05:00
David Malcolm
358dab9018 analyzer: fix ICE on writes to errno [PR107777]
gcc/analyzer/ChangeLog:
	PR analyzer/107777
	* call-summary.cc
	(call_summary_replay::convert_region_from_summary_1): Handle
	RK_THREAD_LOCAL and RK_ERRNO in switch.
	* region-model.cc (region_model::get_representative_path_var_1):
	Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/107777
	* gcc.dg/analyzer/call-summaries-errno.c: New test.
	* gcc.dg/analyzer/errno-pr107777.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21 19:08:17 -05:00
David Malcolm
9ada45967b analyzer, testsuite: add more examples taken from CWE
gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/CWE-131-examples.c: New test.
	* gcc.dg/analyzer/file-CWE-1341-example.c: New test.
	* gcc.dg/analyzer/malloc-CWE-401-example.c: New test.
	* gcc.dg/analyzer/malloc-CWE-415-examples.c: New test.
	* gcc.dg/analyzer/malloc-CWE-416-examples.c: New test.
	* gcc.dg/analyzer/malloc-CWE-590-examples.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21 19:08:17 -05:00
Lewis Hyatt
6f46d14d49 libcpp: Fix paste error with unknown pragma after macro expansion
In directives.cc, do_pragma() contains logic to handle a case such as the new
testcase pragma-omp-unknown.c, where an unknown pragma was the result of macro
expansion (for pragma namespaces that permit expansion). This no longer works
correctly as shown by the testcase, fixed by adding PREV_WHITE to the flags on
the second token to prevent an unwanted paste.  Also fixed the memory leak,
since the temporary tokens are pushed on their own context, nothing prevents
freeing of the buffer that holds them when the context is eventually popped.

libcpp/ChangeLog:

	* directives.cc (do_pragma): Fix memory leak in token buffer.  Fix
	unwanted paste between two tokens.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/pragma-omp-unknown.c: New test.
2022-11-21 17:47:19 -05:00
Sebastian Huber
5c0d171f67 RTEMS: Use local-exec TLS model by default
gcc/ChangeLog:

	* config/rtems.h (SUBTARGET_CC1_SPEC): Undef and define.
2022-11-21 20:39:14 +01:00
Sebastian Huber
58c3d9cde1 Allow subtarget customization of CC1_SPEC
gcc/ChangeLog:

	* gcc.cc (SUBTARGET_CC1_SPEC): Define if not defined.
	(cc1_spec): Append SUBTARGET_CC1_SPEC.
2022-11-21 20:39:14 +01:00
Jonathan Wakely
cbd05ca5ab libstdc++: Reduce size of std::bind_front(F) result
When there are no bound arguments to a std::bind_front call we don't
need the overhead of compiling, initializing, and accessing an empty
tuple.

libstdc++-v3/ChangeLog:

	* include/std/functional (_Bind_front0): New class template.
	(_Bind_front_t): Use _Bind_front0 when there are no bound
	arguments.
	* testsuite/20_util/function_objects/bind_front/107784.cc:
	New test.
2022-11-21 17:46:42 +00:00
Jonathan Wakely
ed77dcb9be libstdc++: Check static assertions earlier in chrono::duration
This ensures that we fail a static assertion before giving any other
errors. Instantiating chrono::duration<int, chrono::seconds> will now
print this before the other errors caused by it:

error: static assertion failed: period must be a specialization of ratio

libstdc++-v3/ChangeLog:

	* include/bits/chrono.h (duration): Check preconditions on
	template arguments before using them.
2022-11-21 17:46:42 +00:00
Jonathan Wakely
94f7baf219 libstdc++: Improve Doxygen comments in <tuple>
libstdc++-v3/ChangeLog:

	* include/std/tuple: Add better Doxygen comments.
2022-11-21 17:46:42 +00:00
Dimitar Dimitrov
9fe9dd2455 testsuite: Add filter for target socket support
The new analyzer tests for sockets are failing on embedded targets.
The newlib and avr-libc C libraries do not support sockets.

Testing done:
  - No changes in gcc.sum for x86_64-pc-linux-gnu, with or without this
    patch.
  - Filtered cases are now UNSUPPORTED instead of failing on AVR and PRU
    backends.

gcc/ChangeLog:

	* doc/sourcebuild.texi (sockets): Document new check.

gcc/testsuite/ChangeLog:

	* gcc.dg/analyzer/fd-accept.c: Require sockets.
	* gcc.dg/analyzer/fd-bind.c: Ditto.
	* gcc.dg/analyzer/fd-connect.c: Ditto.
	* gcc.dg/analyzer/fd-datagram-socket.c: Ditto.
	* gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c:
	Ditto.
	* gcc.dg/analyzer/fd-glibc-byte-stream-socket.c: Ditto.
	* gcc.dg/analyzer/fd-glibc-datagram-client.c: Ditto.
	* gcc.dg/analyzer/fd-glibc-datagram-socket.c: Ditto.
	* gcc.dg/analyzer/fd-listen.c: Ditto.
	* gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c: Ditto.
	* gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c: Ditto.
	* gcc.dg/analyzer/fd-socket-meaning.c: Ditto.
	* gcc.dg/analyzer/fd-socket-misuse.c: Ditto.
	* gcc.dg/analyzer/fd-stream-socket-active-open.c: Ditto.
	* gcc.dg/analyzer/fd-stream-socket-passive-open.c: Ditto.
	* gcc.dg/analyzer/fd-stream-socket.c: Ditto.
	* gcc.dg/analyzer/fd-symbolic-socket.c: Ditto.
	* lib/target-supports.exp (check_effective_target_sockets): New
	check.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2022-11-21 18:13:53 +02:00
Andrew Carlotti
f80bfdcc84 Expand comment for tree_niter_desc.max
This requirement is enforced by a gcc_checking_assert in
record_estimate.

gcc/ChangeLog:

	* tree-ssa-loop.h (tree_niter_desc): Update comment.
2022-11-21 16:00:52 +00:00
Andrew Carlotti
2aec408883 Modify test, to prevent the next patch breaking it
The upcoming c[lt]z idiom recognition patch eliminates the need for a
brute force computation of the iteration count of these loops. The test
is intended to verify that ivcanon can determine the loop count when the
condition is given by a chain of constant computations.

We replace the constant operations with a more complicated chain that should
resist future idiom recognition.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr77975.c: Make tests more robust.
2022-11-21 16:00:51 +00:00
Andrew Carlotti
eea52e38dd Refactor number_of_iterations_popcount
This includes various changes to improve clarity, and to enable the code
to be more similar to the clz and ctz idiom recognition added in
subsequent patches.

We create new number_of_iterations_bitcount function, which will be used
to call the other bit-counting recognition functions added in subsequent
patches, as well as a generic comment describing the loop structures
that are common to each idiom. Some of the variables in
number_of_iterations_popcount are given more descriptive names, and the
popcount expression builder is extracted into a separate function.

As part of the refactoring, we also fix a bug where the max loop count
for modes shorter than an integer would be incorrectly computed as if
the input mode were actually an integer.

We also ensure that niter->max takes into account the final value for
niter->niter (after any folding and simplifying), since if the latter is a
constant, then record_estimate mandates that the two values are equivalent.

gcc/ChangeLog:

	* tree-ssa-loop-niter.cc
	(number_of_iterations_exit_assumptions): Modify to call...
	(number_of_iterations_bitcount): ...this new function.
	(number_of_iterations_popcount): Now called by the above.
	Refactor, and extract popcount expression builder to...
	(build_popcount_expr): this new function.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/popcount-max.c: New test.
2022-11-21 16:00:51 +00:00
Andrew Carlotti
fe985a2363 Remove prototype for number_of_iterations_popcount
gcc/ChangeLog:

	* tree-ssa-loop-niter.cc (ssa_defined_by_minus_one_stmt_p): Move
	(number_of_iterations_popcount): Move, and remove separate prototype.
2022-11-21 16:00:37 +00:00
Andrew Carlotti
f0e4f676aa Ensure at_stmt is defined before an early exit
This prevents a null dereference error when outputing debug information
following an early exit from number_of_iterations_exit_assumptions.

gcc/ChangeLog:

	* tree-ssa-loop-niter.cc (number_of_iterations_exit_assumptions):
	Move at_stmt assignment.
2022-11-21 15:59:21 +00:00
Torbjörn SVENSSON
9df85f331f testsuite: Windows paths use \ and not /
Without this patch, the following error is reported on Windows:

In file included from t:\build\arm-none-eabi\include\c++\11.3.1\string:54,
                  from t:\build\arm-none-eabi\include\c++\11.3.1\bits\locale_classes.h:40,
                  from t:\build\arm-none-eabi\include\c++\11.3.1\bits\ios_base.h:41,
                  from t:\build\arm-none-eabi\include\c++\11.3.1\ios:42,
                  from t:\build\arm-none-eabi\include\c++\11.3.1\ostream:38,
                  from t:\build\arm-none-eabi\include\c++\11.3.1\iostream:39:
t:\build\arm-none-eabi\include\c++\11.3.1\bits\range_access.h:36:10: note: include 't:\build\arm-none-eabi\include\c++\11.3.1\initializer_list' translated to import
arm-none-eabi-g++.exe: warning: .../gcc/testsuite/g++.dg/modules/pr99023_b.X: linker input file unused because linking not done
FAIL: g++.dg/modules/pr99023_b.X -std=c++2a  dg-regexp 6 not found: "[^\n]*: note: include '[^\n]*/initializer_list' translated to import\n"

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr99023_b.X: Match Windows paths too.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-11-21 16:36:23 +01:00
Tobias Burnus
6edcb5dc42 libgomp/gcn: fix/improve struct output
output.printf_data.(value union) contains text[128], which has the size
of 128 bytes, sufficient for 16 uint64_t variables; hence value_u64[2]
could be extended to value_u64[6] - sufficient for all required arguments
to gomp_target_rev.  Additionally, next_output.printf_data.(msg union)
contained msg_u64 which then is no longer needed and also caused 32bit
vs 64bit alignment issues.

libgomp/
	* config/gcn/libgomp-gcn.h (struct output):
	Remove 'msg_u64' from the union, change
	value_u64[2] to value_u64[6].
	* config/gcn/target.c (GOMP_target_ext): Update accordingly.
	* plugin/plugin-gcn.c (process_reverse_offload, console_output):
	Likewise.
2022-11-21 15:22:35 +01:00
Torbjörn SVENSSON
711f56ad90 libcpp/remap: Only override if string matched
For systems with HAVE_DOS_BASED_FILE_SYSTEM set, only override the
pointer if the backslash pattern matches.

Output without this patch:
.../gcc/testsuite/gcc.dg/cpp/pr71681-2.c:5:10: fatal error: a/t2.h: No such file or directory

With patch applied, no output and the test case succeeds.

libcpp/ChangeLog

	* files.cc: Ensure pattern matches before use.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-11-21 13:37:05 +01:00
Christophe Lyon
ccb9c7b129 genmultilib: Fix sanity check
My previous patch to add a sanity check to genmultilib actually
checked the number of dirnames with the number of "sets of options"
rather than the number of options, thus breaking the build on some
targets.

To avoid duplicating once more the loop that constructs the sed
patterns, this patch checks that the current dirname/osdirname is not
empty in the existing loops.

Are there targets where:
if [ "$1" != "${opt}" ]; then
is "legally" executed with an empty $1? (and thus where this patch
would incorrectly trigger an error?)

Sorry for the breakage. Tested on aarch64 by adding an option to
t-aarch64 and no corresponding dirname, and on x86_64.

gcc/ChangeLog:

	* genmultilib: Fix options and dirnames/osdirnames sanity check.
2022-11-21 13:19:53 +01:00
Philipp Tomsich
4c7d336b67 RISC-V: Fix ICE in branch<ANYI:mode>_shiftedarith_equals_zero
With the recent improvements to the splitting of special cases of
branch patterns on RISC-V, a dependency on an unmerged/in-discussion
change for branch-equals-zero slipped in: this allowed a non-X mode to
be presented to branch-equals-zero (where only X mode is permissible).

This addresses the issue by wrapping the ANYI operand in a paradoxical
SUBREG:X (the high bits can be safely ignored, as we we perform an
and-immediate before the branch in the pattern).

Tested against the GCC testsuite and committed as obvious.

gcc/ChangeLog:

	PR target/107786
	* config/riscv/riscv.md
	(*branch<ANYI:mode>_shiftedarith_equals_zero): Wrap ANYI
	in a subreg, as our branch instructions only supports X.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/pr107786-2.c: New test.
	* gcc.target/riscv/pr107786.c: New test.
2022-11-21 12:53:45 +01:00
Eric Botcazou
2473f28d79 ada: Adjust recent change for returns involving function calls
gcc/ada/

	* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Constant>: Revert
	latest change.
	* gcc-interface/trans.cc (gnat_to_gnu) <N_Object_Declaration>:
	Tweak latest change.
2022-11-21 11:10:35 +01:00
Marc Poulhiès
a186dd158d ada: Do not share Packed Array Type if sizes of types differ
If a subtype has a Size attribute value different than the size of its
ancestor, then the Packed Array Type can't be shared and a new one must
be created.

gcc/ada/

	* exp_pakd.adb (Create_Packed_Array_Impl_Type): Do not share PAT
	if sizes of types differ.
2022-11-21 11:10:34 +01:00
Ronan Desplanques
6f089469f4 ada: Order pragmas alphabetically in reference manual
gcc/ada/

	* doc/gnat_rm/implementation_defined_pragmas.rst: Restore
	alphabetical ordering.
	* gnat_rm.texi: Regenerate.
	* gnat_ugn.texi: Regenerate.
2022-11-21 11:10:34 +01:00
Eric Botcazou
5947b1ee8a ada: Minor tweak in assertion
For an array subtype, being definite is the same as being constrained.

gcc/ada/

	* sem_util.adb (Needs_Secondary_Stack): Test Is_Constrained
	directly instead of Is_Definite_Subtype for an array subtype.
2022-11-21 11:10:34 +01:00
Steve Baird
24dde337d8 ada: Internal compiler error for Sequential Partition_Elaboration_Policy
In some cases, compilation of a function with a limited class-wide result
type could fail with an internal error if a Sequential
Partition_Elaboration_Policy is specified. To prevent this, we want specifying
a Sequential Partition_Elaboration_Policy to have the side effect of
imposing a No_Task_Hierarchy restriction. But doing that in a straightforward
way leads to problems with incorrectly accepting violations of H.6(6). So
a new restriction, No_Task_Hierarchy_Implicit, is introduced.

gcc/ada/

	* libgnat/s-rident.ads: Define a new restriction,
	No_Task_Hierarchy_Implicit. This is like the No_Task_Hierarchy
	restriction, but with the difference that setting this restriction
	does not mean the H.6(6) post-compilation check is satisified.
	* exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call): If it is
	known that the function result cannot have tasks, then pass in a
	null literal for the activation chain actual parameter. This
	avoids generating a reference to an entity that
	Build_Activation_Chain_Entity may have chosen not to generate a
	declaration for.
	* gnatbind.adb (List_Applicable_Restrictions): Do not list the
	No_Task_Hierarchy_Implicit restriction.
	* restrict.adb: Special treatment for the
	No_Task_Hierarchy_Implicit restriction in functions
	Get_Restriction_Id and Restriction_Active. The former is needed to
	disallow the (unlikely) case that a user tries to explicitly
	reference the No_Task_Hierarchy_Implicit restriction.
	* sem_prag.adb (Analyze_Pragma): If a Sequential
	Partition_Elaboration_Policy is specified (and the
	No_Task_Hierarchy restriction is not already enabled), then enable
	the No_Task_Hierarchy_Implicit restriction.
2022-11-21 11:10:33 +01:00