Commit graph

195715 commits

Author SHA1 Message Date
GCC Administrator
d0fc05e860 Daily bump. 2022-09-16 00:16:53 +00:00
Jonathan Wakely
d6ccad7641 libstdc++: Remove unnecessary header from <memory>
Previously <memory> included <bits/stl_algobase.h> so that std::copy,
std::fill etc. could be used by <bits/stl_uninitialized.h>. But that
includes it explicitly now, so that it can be compiled as a header unit.
There's no need to include it in <memory>, where its purpose isn't
obvious.

libstdc++-v3/ChangeLog:

	* include/std/memory: Do not include <bits/stl_algobase.h>.
2022-09-15 23:57:32 +01:00
Harald Anlauf
2b75d5f533 Fortran: catch NULL pointer dereferences while simplifying PACK [PR106857]
gcc/fortran/ChangeLog:

	PR fortran/106857
	* simplify.cc (gfc_simplify_pack): Check for NULL pointer dereferences
	while walking through constructors (error recovery).

gcc/testsuite/ChangeLog:

	PR fortran/106857
	* gfortran.dg/pr106857.f90: New test.
2022-09-15 22:39:24 +02:00
Harald Anlauf
7bd4deb2a7 Fortran: error recovery for bad deferred character length assignment [PR104314]
gcc/fortran/ChangeLog:

	PR fortran/104314
	* resolve.cc (deferred_op_assign): Do not try to generate temporary
	for deferred character length assignment if types do not agree.

gcc/testsuite/ChangeLog:

	PR fortran/104314
	* gfortran.dg/pr104314.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2022-09-15 22:12:47 +02:00
Joseph Myers
6248f4ff67 float.h: Do not define INFINITY for C2x when infinities not supported
C2x has changed the rules for defining INFINITY in <float.h> so it is
no longer defined when float does not support infinities, instead of
being defined to an expression that overflows at translation time.
Thus, make the definition conditional on __FLT_HAS_INFINITY__ (this is
already inside a C2x-conditional part of <float.h>, because previous C
standard versions only had this macro in <math.h>).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.  Also did a
spot test of the case of no infinities supported by building cc1 for
vax-netbsdelf and testing compiling the new c2x-float-11.c test with
it.

gcc/
	* ginclude/float.h (INFINITY): Define only if
	[__FLT_HAS_INFINITY__].

gcc/testsuite/
	* gcc.dg/c2x-float-2.c: Require inff effective-target.
	* gcc.dg/c2x-float-11.c: New test.
2022-09-15 20:10:42 +00:00
Jonathan Wakely
ecbdfa8b31 libstdc++: Tweak TSan annotations for std::atomic<shared_ptr<T>>
Do not use the __tsan_mutex_not_static flag for annotation functions
where it's not a valid flag.  Also use the try_lock and try_lock_failed
flags to more precisely annotate the CAS loop used to acquire a lock.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (_GLIBCXX_TSAN_MUTEX_PRE_LOCK):
	Replace with ...
	(_GLIBCXX_TSAN_MUTEX_TRY_LOCK): ... this, add try_lock flag.
	(_GLIBCXX_TSAN_MUTEX_TRY_LOCK_FAILED): New macro using
	try_lock_failed flag
	(_GLIBCXX_TSAN_MUTEX_POST_LOCK): Rename to ...
	(_GLIBCXX_TSAN_MUTEX_LOCKED): ... this.
	(_GLIBCXX_TSAN_MUTEX_PRE_UNLOCK): Remove invalid flag.
	(_GLIBCXX_TSAN_MUTEX_POST_UNLOCK): Remove invalid flag.
	(_Sp_atomic::_Atomic_count::lock): Use new macros.
2022-09-15 21:04:36 +01:00
Patrick Palka
29b39d4b0e libstdc++: Implement ranges::chunk_by_view from P2443R1
libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__adjacent_find_fn, adjacent_find):
	Move to ...
	* include/bits/ranges_util.h: ... here.
	* include/std/ranges (chunk_by_view): Define.
	(chunk_by_view::_Iterator): Define.
	(__detail::__can_chunk_by_view): Define.
	(_ChunkBy, chunk_by): Define.
	* testsuite/std/ranges/adaptors/chunk_by/1.cc: New test.
2022-09-15 13:16:51 -04:00
François Dumont
db58fa0b05 libstdc++: [_GLIBCXX_INLINE_VERSION] Fix test dg-prune-output
libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc:
	Adapt dg-prune-output to _GLIBCXX_INLINE_VERSION mode.
2022-09-15 18:59:49 +02:00
François Dumont
d26bcff991 libstdc++: [_GLIBCXX_INLINE_VERSION] Cleanup gnu-versioned-namespace.ver
Remove expressions for symbols in std::__detail::__8 namespace, they are obsolete since
version namespace applies only at std:: level, not at sub-levels.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu-versioned-namespace.ver: Remove obsolete std::__detail::__8
	symbols.
2022-09-15 18:58:50 +02:00
Torbjörn SVENSSON
1e4c7e870e MAINTAINERS: Add myself to Write After Approval
ChangeLog:

	* MAINTAINERS (Write After Approval): Add myself.
2022-09-15 14:44:58 +02:00
Richard Biener
5edf02ed2b tree-optimization/106922 - PRE and virtual operand translation
PRE implicitely keeps virtual operands at the blocks incoming version
but the explicit updating point during PHI translation fails to trigger
when there are no PHIs at all in a block.  Later lazy updating then
fails because of a too lose block check.  A similar issues plagues
reference invalidation when checking the ANTIC_OUT to ANTIC_IN
translation.  The following fixes both and makes the lazy updating
work.

The diagnostic testcase unfortunately requires boost so the
testcase is the one I reduced for a missed optimization in PRE.
The testcase fails with -m32 on x86_64 because we optimize too
much before PRE which causes PRE to not trigger so we fail to
eliminate a full redundancy.  I'm going to open a separate bug
for this.  Hopefully the !lp64 selector is good enough.

	PR tree-optimization/106922
	* tree-ssa-pre.cc (translate_vuse_through_block): Only
	keep the VUSE if its def dominates PHIBLOCK.
	(prune_clobbered_mems): Rewrite logic so we check whether
	a value dies in a block when the VUSE def doesn't dominate it.

	* g++.dg/tree-ssa/pr106922.C: New testcase.
2022-09-15 14:21:20 +02:00
Richard Biener
8ff2a92a04 Move void_list_node init to common code
All frontends replicate this, so move it.

gcc/
	* tree.cc (build_common_tree_nodes): Initialize void_list_node
	here.

gcc/ada/
	* gcc-interface/trans.cc (gigi): Do not initialize void_list_node.

gcc/c-family/
	* c-common.h (build_void_list_node): Remove.
	* c-common.cc (c_common_nodes_and_builtins): Do not initialize
	void_list_node.

gcc/c/
	* c-decl.cc (build_void_list_node): Remove.

gcc/cp/
	* decl.cc (cxx_init_decl_processing): Inline last
	build_void_list_node call.
	(build_void_list_node): Remove.

gcc/d/
	* d-builtins.cc (d_build_c_type_nodes): Do not initialize
	void_list_node.

gcc/fortran/
	* f95-lang.cc (gfc_init_decl_processing): Do not initialize
	void_list_node.

gcc/go/
	* go-lang.cc (go_langhook_init): Do not initialize
	void_list_node.

gcc/jit/
	* dummy-frontend.cc (jit_langhook_init): Do not initialize
	void_list_node.

gcc/lto/
	* lto-lang.cc (lto_build_c_type_nodes): Do not initialize
	void_list_node.
2022-09-15 14:16:25 +02:00
Julian Brown
e3220adc44 Fix c-c++-common/gomp/target-50.c test
The expected scan dump output for this test will change after the
following patch is committed:

  https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601558.html

But for now, this patch reverts to the old expected pattern so the test
passes. I will apply as obvious.

2022-09-15  Julian Brown  <julian@codesourcery.com>

gcc/testsuite/
	* c-c++-common/gomp/target-50.c: Modify scan pattern.
2022-09-15 12:01:28 +00:00
Julian Brown
d7171ba78d Fix c-c++-common/goacc/mdc-2.c and g++.dg/goacc/mdc.C tests
These testsuite hunks got left attached to the wrong patch in the series
I just posted. I will apply as obvious.

2022-09-15  Julian Brown  <julian@codesourcery.com>

gcc/testsuite/
	* c-c++-common/goacc/mdc-2.c: Update expected errors.
	* g++.dg/goacc/mdc.C: Likewise.
2022-09-15 11:32:36 +00:00
Jiufu Guo
7a3dfc23a9 rs6000: Using pli(paddi) and rotate to build 64bit constants
Hi,

Test cases are updated/added, and code is refined as the comments in the
review for previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-September/600768.html

As mentioned in PR106550, since pli could support 34bits immediate, we could
use less instructions(3insn would be ok) to build 64bits constant with pli.

For example, for constant 0x020805006106003, we could generate it with:
asm code1:
pli 9,101736451 (0x6106003)
sldi 9,9,32
paddi 9,9, 2130000 (0x0208050)

or asm code2:
pli 10, 2130000
pli 9, 101736451
rldimi 9, 10, 32, 0

The asm code2 would be better.
This patch generates the asm code2 in split1 pass, this patch also supports
to generate asm code1 when splitter is only after RA.

This patch pass boostrap and regtest on ppc64. P10 testing is running.
Thanks for any comments!

BR,
Jeff(Jiufu)

	PR target/106550

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Use pli.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr106550.c: New test.
	* gcc.target/powerpc/pr106550_1.c: New test.
2022-09-15 14:20:15 +08:00
GCC Administrator
ff822367bb Daily bump. 2022-09-15 00:17:35 +00:00
Jonathan Wakely
0abc63a5ea libstdc++: Add TSan annotations to std::atomic<shared_ptr<T>>
This adds annotations to std::atomic<shared_ptr<T>> to enable TSan to
understand the custom locking. Without this, TSan reports data races for
accesses to the _M_ptr member, even though those are correctly
synchronized using atomic operations on the tagged pointer.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (_GLIBCXX_TSAN_MUTEX_DESTROY)
	(_GLIBCXX_TSAN_MUTEX_PRE_LOCK, _GLIBCXX_TSAN_MUTEX_POST_LOCK)
	(_GLIBCXX_TSAN_MUTEX_PRE_UNLOCK, _GLIBCXX_TSAN_MUTEX_POST_UNLOCK)
	(_GLIBCXX_TSAN_MUTEX_PRE_SIGNAL, _GLIBCXX_TSAN_MUTEX_POST_SIGNAL):
	Define macros for TSan annotation functions.
	(_Sp_atomic::_Atomic_count): Add annotations.
2022-09-14 19:17:37 +01:00
Jonathan Wakely
7f1e3d06bb libstdc++: Add missing <new> header to <bits/stl_tempbuf.h>
This is needed for std::nothrow and the nothrow operator new overload,
so should be included explicitly.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tempbuf.h: Include <new>.
2022-09-14 19:17:36 +01:00
Jonathan Wakely
9a1bc4b463 libstdc++: Add comment to 17_intro/names.cc test
libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Explain why poison pragma can't
	be used.
2022-09-14 19:17:36 +01:00
Jonathan Wakely
0bc9aa9c3f libstdc++: Add assertion to std::promise::set_exception (LWG 2276)
Without this assertion, the shared state is made ready, but contains
neither a value nor an exception. Add an assertion to prevent users from
accessing a value that was never initialized in the shared state.

libstdc++-v3/ChangeLog:

	* include/std/future
	(_State_baseV2::__setter(exception_ptr&, promise&)): Add
	assertion for LWG 2276 precondition.
	* testsuite/30_threads/promise/members/set_exception_neg.cc:
	New test.
2022-09-14 19:17:36 +01:00
Jonathan Wakely
8b1bc3051b libstdc++: Document LWG 1203 API change in manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/intro.xml: Document LWG 1203.
	* doc/html/*: Regenerate.
2022-09-14 19:17:36 +01:00
Philipp Fent
93257ed603 libstdc++: Add pretty printer for std::stringstreams
To display (o-,i-)stringstreams in the common case, we just print the
underlying stringbuf, without the many ios_base members. In the
unconventional case that the underlying streambuf was redirected, we
report the redirected target.

Signed-off-by: Philipp Fent <fent@in.tum.de>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (access_streambuf_ptrs):
	New helper function.
	(StdStringBufPrinter, StdStringStreamPrinter): New printers.
	(build_libstdcxx_dictionary): Register stringstream printers.
	* testsuite/libstdc++-prettyprinters/debug.cc: Check string
	streams.
	* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
2022-09-14 19:17:36 +01:00
Aldy Hernandez
3c85c11885 frange: add both zeros to ranges when there's the possiblity of equality.
Every time there's equality at play, we must be careful that any
equality with zero matches both -0.0 and +0.0 when honoring signed
zeros.

We were doing this correctly for the == and != op1_range operators
(albeit inefficiently), but aren't doing it at all when building >=
and <=.  This fixes the oversight.

There is change in functionality here for the build_* functions.

This is the last "simple" patch I submit before overhauling NAN and
sign tracking.  And that will likely be after Cauldron because it will need
further testing (lapack, ppc64le, -ffinite-math-only, etc).

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

	* range-op-float.cc (frange_add_zeros): New.
	(build_le): Call frange_add_zeros.
	(build_ge): Same.
	(foperator_equal::op1_range): Same.
	(foperator_not_equal::op1_range): Same.
2022-09-14 17:06:48 +02:00
Aldy Hernandez
7d647a8d49 Pass full range to build_* in range-op-float.cc
The build_<relop> helper functions in range-op-float.cc take the
actual value from the operand's endpoint, but this value could be
deduced from the operand itself therefore cleaning up the call site.
This also reduces the potential of mistakenly passing the wrong bound.

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

	* range-op-float.cc (build_le): Accept frange instead of number.
	(build_lt): Same.
	(build_ge): Same.
	(build_gt): Same.
	(foperator_lt::op1_range): Pass full range to build_*.
	(foperator_lt::op2_range): Same.
	(foperator_le::op1_range): Same.
	(foperator_le::op2_range): Same.
	(foperator_gt::op1_range): Same.
	(foperator_gt::op2_range): Same.
	(foperator_ge::op1_range): Same.
	(foperator_ge::op2_range): Same.
2022-09-14 17:06:48 +02:00
Aldy Hernandez
4a311a6160 Use frange::set_nan() from the generic frange::set().
This patch cleans up the frange::set() code by passing all things NAN
to frange::set_nan().

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

	* value-range.cc (frange::set): Use set_nan.
	* value-range.h (frange::set_nan): Inline code originally in
	set().
2022-09-14 17:06:48 +02:00
Aldy Hernandez
9c4c4186eb Provide cleaner set_nan(), clear_nan(), and update_nan() methods.
set_* has a very specific meaning for irange's and friends.  Methods
prefixed with set_* are setters clobbering the existing range.  As
such, the current set_nan() method is confusing in that it's not
actually setting a range to a NAN, but twiddling the NAN flags for an
existing frange.

This patch replaces set_nan() with an update_nan() to set the flag,
and clear_nan() to clear it.  This makes the code clearer, and though
the confusing tristate is still there, it will be removed in upcoming
patches.

Also, there is now an actual set_nan() method to set the range to a
NAN.  This replaces two out of class functions doing the same thing.
In future patches I will also add the ability to create a NAN with a
specific sign, but doing so now would be confusing because we're not
tracking NAN signs.

We should also submit set_signbit to the same fate, but it's about to
get removed.

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

	* range-op-float.cc (frange_set_nan): Remove.
	(build_lt): Use set_nan, update_nan, clear_nan.
	(build_gt): Same.
	(foperator_equal::op1_range): Same.
	(foperator_not_equal::op1_range): Same.
	(foperator_lt::op1_range): Same.
	(foperator_lt::op2_range): Same.
	(foperator_le::op1_range): Same.
	(foperator_le::op2_range): Same.
	(foperator_gt::op1_range): Same.
	(foperator_gt::op2_range): Same.
	(foperator_ge::op1_range): Same.
	(foperator_ge::op2_range): Same.
	(foperator_unordered::op1_range): Same.
	(foperator_ordered::op1_range): Same.
	* value-query.cc (range_query::get_tree_range): Same.
	* value-range.cc (frange::set_nan): Same.
	(frange::update_nan): Same.
	(frange::union_): Same.
	(frange::intersect): Same.
	(range_tests_nan): Same.
	(range_tests_signed_zeros): Same.
	(range_tests_signbit): Same.
	(range_tests_floats): Same.
	* value-range.h (class frange): Add update_nan and clear_nan.
	(frange::set_nan): New.
2022-09-14 17:06:48 +02:00
Aldy Hernandez
6da65479fc Minor fixes to frange.
Following are a series of cleanups to the frange code in preparation
for a much more invasive patch rewriting the NAN and sign tracking
bits.  Please be patient, as I'm trying to break everything up into
small chunks instead of dropping a mondo patch removing the NAN and
sign tristate handling.

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

	* value-query.cc (range_query::get_tree_range): Remove check for overflow.
	* value-range-pretty-print.cc (vrange_printer::visit): Move read
	of type until after undefined_p is checked.
	* value-range.cc (frange::set): Remove asserts for REAL_CST.
	(frange::contains_p): Tidy up.
	(range_tests_nan):  Add comment.
	* value-range.h (frange::type): Check for undefined_p.
	(frange::set_undefined): Remove set of endpoints.
2022-09-14 17:06:48 +02:00
Julian Brown
f469ce1d3e OpenMP/OpenACC: mapping group list-handling improvements
This patch adjusts OpenMP/OpenACC clause list handling in a couple of
places, in preparation for the following mapping-clause expansion rework
patch. Firstly mapping groups are removed as a whole in the C and C++
front-ends when an error is detected, which avoids leaving "badly-formed"
mapping clause groups in the list.

Secondly, reindexing of the omp_mapping_group hashmap (during
omp_build_struct_sibling_lists) has been reimplemented, fixing some
tricky corner-cases where mapping groups are removed from a list at the
same time as it is being reordered.

Thirdly, code to check if a different clause on the same directive maps
the whole of a struct that we have a component mapping for (for example)
has been outlined, removing a bit of code duplication.

2022-09-13  Julian Brown  <julian@codesourcery.com>

gcc/
	* gimplify.cc (omp_group_last): Allow GOMP_MAP_ATTACH_DETACH after
	GOMP_MAP_STRUCT (for reindexing).
	(omp_gather_mapping_groups): Reimplement using...
	(omp_gather_mapping_groups_1): This new function.  Stop processing at
	GATHER_SENTINEL.
	(omp_group_base): Allow GOMP_MAP_TO_PSET without any following node.
	(omp_index_mapping_groups): Reimplement using...
	(omp_index_mapping_groups_1): This new function.  Handle
	REINDEX_SENTINEL.
	(omp_reindex_mapping_groups, omp_mapped_by_containing_struct): New
	functions.
	(omp_tsort_mapping_groups_1): Adjust handling of base group being the
	same as current group.  Use omp_mapped_by_containing_struct.
	(omp_build_struct_sibling_lists): Use omp_mapped_by_containing_struct
	and omp_reindex_mapping_groups.  Robustify group deletion for reordered
	lists.
	(gimplify_scan_omp_clauses): Update calls to
	omp_build_struct_sibling_lists.

gcc/c/
	* c-typeck.cc (c_finish_omp_clauses): Remove whole mapping node group
	on error.

gcc/cp/
	* semantics.cc (finish_omp_clauses): Likewise.
2022-09-14 13:59:55 +00:00
Julian Brown
23baa717c9 OpenMP/OpenACC struct sibling list gimplification extension and rework
This patch refactors struct sibling-list processing in gimplify.cc, and
adjusts some related mapping-clause processing in the Fortran FE and
omp-low.cc accordingly.

2022-09-13  Julian Brown  <julian@codesourcery.com>

gcc/fortran/
	* trans-openmp.cc (gfc_trans_omp_clauses): Don't create
	GOMP_MAP_TO_PSET mappings for class metadata, nor GOMP_MAP_POINTER
	mappings for POINTER_TYPE_P decls.

gcc/
	* gimplify.cc (gimplify_omp_var_data): Remove GOVD_MAP_HAS_ATTACHMENTS.
	(GOMP_FIRSTPRIVATE_IMPLICIT): Renumber.
	(insert_struct_comp_map): Refactor function into...
	(build_omp_struct_comp_nodes): This new function.  Remove list handling
	and improve self-documentation.
	(extract_base_bit_offset): Remove BASE_REF, OFFSETP parameters.  Move
	code to strip outer parts of address out of function, but strip no-op
	conversions.
	(omp_mapping_group): Add DELETED field for use during reindexing.
	(omp_strip_components_and_deref, omp_strip_indirections): New functions.
	(omp_group_last, omp_group_base): Add GOMP_MAP_STRUCT handling.
	(omp_gather_mapping_groups): Initialise DELETED field for new groups.
	(omp_index_mapping_groups): Notice DELETED groups when (re)indexing.
	(omp_siblist_insert_node_after, omp_siblist_move_node_after,
	omp_siblist_move_nodes_after, omp_siblist_move_concat_nodes_after): New
	helper functions.
	(omp_accumulate_sibling_list): New function to build up GOMP_MAP_STRUCT
	node groups for sibling lists. Outlined from gimplify_scan_omp_clauses.
	(omp_build_struct_sibling_lists): New function.
	(gimplify_scan_omp_clauses): Remove struct_map_to_clause,
	struct_seen_clause, struct_deref_set.  Call
	omp_build_struct_sibling_lists as pre-pass instead of handling sibling
	lists in the function's main processing loop.
	(gimplify_adjust_omp_clauses_1): Remove GOVD_MAP_HAS_ATTACHMENTS
	handling, unused now.
	* omp-low.cc (scan_sharing_clauses): Handle pointer-type indirect
	struct references, and references to pointers to structs also.

gcc/testsuite/
	* g++.dg/goacc/member-array-acc.C: New test.
	* g++.dg/gomp/member-array-omp.C: New test.
	* g++.dg/gomp/target-3.C: Update expected output.
	* g++.dg/gomp/target-lambda-1.C: Likewise.
	* g++.dg/gomp/target-this-2.C: Likewise.
	* c-c++-common/goacc/deep-copy-arrayofstruct.c: Move test from here.
	* c-c++-common/gomp/target-50.c: New test.

libgomp/
	* testsuite/libgomp.oacc-c-c++-common/deep-copy-15.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/deep-copy-16.c: New test.
	* testsuite/libgomp.oacc-c++/deep-copy-17.C: New test.
	* testsuite/libgomp.oacc-c-c++-common/deep-copy-arrayofstruct.c: Move
	test to here, make "run" test.
2022-09-14 13:59:55 +00:00
Richard Biener
cd14c97cd9 tree-optimization/106938 - cleanup abnormal edges after inlining
After inlining and IPA transforms we run fixup_cfg to fixup CFG
effects in other functions.  But that fails to clean abnormal
edges from non-pure/const calls which might no longer be necessary
when ->calls_setjmp is false.  The following ensures this happens
and refactors things so we call EH/abnormal cleanup only on the
last stmt in a block.

	PR tree-optimization/106938
	* tree-cfg.cc (execute_fixup_cfg): Purge dead abnormal
	edges for all last stmts in a block.  Do EH cleanup
	only on the last stmt in a block.

	* gcc.dg/pr106938.c: New testcase.
2022-09-14 14:50:36 +02:00
Aldy Hernandez
12a8d5e2f2 [PR106936] Remove assert from get_value_range.
This assert was put here to make sure that the legacy
get_value_range() wasn't being called on stuff that legacy couldn't
handle (floats, etc), because the result would ultimately be copied
into a value_range_equiv.

In this case, simplify_casted_cond() is calling it on an offset_type
which is neither an integer nor a pointer.  However, range_of_expr
happily punted on it, and then the fallthru code set the range to
VARYING.  As value_range_equiv can store VARYING types of anything
(including types it can't handle), this is fine.

The easiest thing to do is remove the assert.  If someone from the non
legacy world tries to get a non integer/pointer range here, it's going
to blow up anyhow because the temporary in get_value_range is
int_range_max.

	PR tree-optimization/106936

gcc/ChangeLog:

	* value-query.cc (range_query::get_value_range): Remove assert.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/pr106936.C: New test.
2022-09-14 14:48:36 +02:00
Jan-Benedict Glaw
1457be6dbd Drop unused variable
With the "STABS: remove -gstabs and -gxcoff functionality" patch, a left-over
`start` variable remained unused:

/usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o mips.o -MT mips.o -MMD -MP -MF ./.deps/mips.TPo ../../gcc/gcc/config/mips/mips.cc
../../gcc/gcc/config/mips/mips.cc: In function 'void mips_option_override()':
../../gcc/gcc/config/mips/mips.cc:20021:10: error: unused variable 'start' [-Werror=unused-variable]
20021 |   int i, start, regno, mode;
      |          ^~~~~

2022-09-14  Jan-Benedict Glaw  <jbglaw@lug-owl.de>

gcc/
	* config/mips/mips.cc (mips_option_override): Drop unused variable.
2022-09-14 14:18:03 +02:00
Julian Brown
b57abd072d OpenMP 5.0: Clause ordering for OpenMP 5.0 (topological sorting by base pointer)
This patch reimplements the omp_target_reorder_clauses function in
anticipation of supporting "deeper" struct mappings (that is, with
several structure dereference operators, or similar).

The idea is that in place of the (possibly quadratic) algorithm in
omp_target_reorder_clauses that greedily moves clauses containing
addresses that are subexpressions of other addresses before those other
addresses, we employ a topological sort algorithm to calculate a proper
order for map clauses. This should run in linear time, and hopefully
handles degenerate cases where multiple "levels" of indirect accesses
are present on a given directive.

The new method also takes care to keep clause groups together, addressing
the concerns raised in:

  https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570501.html

To figure out if some given clause depends on a base pointer in another
clause, we strip off the outer layers of the address expression, and check
(via a tree_operand_hash hash table we have built) if the result is a
"base pointer" as defined in OpenMP 5.0 (1.2.6 Data Terminology). There
are some subtleties involved, however:

 - We must treat MEM_REF with zero offset the same as INDIRECT_REF.
   This should probably be fixed in the front ends instead so we always
   use a canonical form (probably INDIRECT_REF). The following patch
   shows one instance of the problem, but there may be others:

   https://gcc.gnu.org/pipermail/gcc-patches/2021-May/571382.html

 - Mapping a whole struct implies mapping each of that struct's
   elements, which may be base pointers. Because those base pointers
   aren't necessarily explicitly referenced in the directive in question,
   we treat the whole-struct mapping as a dependency instead.

2022-09-13  Julian Brown  <julian@codesourcery.com>

gcc/
	* gimplify.cc (is_or_contains_p, omp_target_reorder_clauses): Delete
	functions.
	(omp_tsort_mark): Add enum.
	(omp_mapping_group): Add struct.
	(debug_mapping_group, omp_get_base_pointer, omp_get_attachment,
	omp_group_last, omp_gather_mapping_groups, omp_group_base,
	omp_index_mapping_groups, omp_containing_struct,
	omp_tsort_mapping_groups_1, omp_tsort_mapping_groups,
	omp_segregate_mapping_groups, omp_reorder_mapping_groups): New
	functions.
	(gimplify_scan_omp_clauses): Call above functions instead of
	omp_target_reorder_clauses, unless we've seen an error.
	* omp-low.cc (scan_sharing_clauses): Avoid strict test if we haven't
	sorted mapping groups.

gcc/testsuite/
	* g++.dg/gomp/target-lambda-1.C: Adjust expected output.
	* g++.dg/gomp/target-this-3.C: Likewise.
	* g++.dg/gomp/target-this-4.C: Likewise.
2022-09-14 12:14:19 +00:00
Robin Dapp
2aa5f8808d testsuite/s390: Add -mzarch to ifcvt test cases.
Add missing -mzarch to ifcvt test cases.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/ifcvt-one-insn-bool.c: Add -mzarch.
	* gcc.target/s390/ifcvt-one-insn-char.c: Dito.
	* gcc.target/s390/ifcvt-two-insns-bool.c: Dito.
	* gcc.target/s390/ifcvt-two-insns-int.c: Dito.
	* gcc.target/s390/ifcvt-two-insns-long.c: Add -mzarch and change
	long into long long.
2022-09-14 13:21:10 +02:00
Robin Dapp
48970cbaed testsuite/s390: Fix vperm-rev testcases.
Add -save-temps and tabs for matching.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/vector/vperm-rev-z14.c: Add -save-temps.
	* gcc.target/s390/vector/vperm-rev-z15.c: Likewise.
2022-09-14 13:21:10 +02:00
Jakub Jelinek
645ef01a46 Disallow pointer operands for |, ^ and partly & [PR106878]
My change to match.pd (that added the two simplifications this patch
touches) results in more |/^/& assignments with pointer arguments,
but since r12-1608 we reject pointer operands for BIT_NOT_EXPR.

Disallowing them for BIT_NOT_EXPR and allowing for BIT_{IOR,XOR,AND}_EXPR
leads to a match.pd maintainance nightmare (see one of the patches in the
PR), so either we want to allow pointer operand on BIT_NOT_EXPR (but then
we run into issues e.g. with the ranger which expects it can emulate
BIT_NOT_EXPR ~X as - 1 - X which doesn't work for pointers which don't
support MINUS_EXPR), or the following patch disallows pointer arguments
for all of BIT_{IOR,XOR,AND}_EXPR with the exception of BIT_AND_EXPR
with INTEGER_CST last operand (for simpler pointer realignment).
I had to tweak one reassoc optimization and the two match.pd
simplifications.

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

	PR tree-optimization/106878
	* tree-cfg.cc (verify_gimple_assign_binary): Disallow pointer,
	reference or OFFSET_TYPE BIT_IOR_EXPR, BIT_XOR_EXPR or, unless
	the second argument is INTEGER_CST, BIT_AND_EXPR.
	* match.pd ((type) X op CST -> (type) (X op ((type-x) CST)),
	(type) (((type2) X) op Y) -> (X op (type) Y)): Punt for
	POINTER_TYPE_P or OFFSET_TYPE.
	* tree-ssa-reassoc.cc (optimize_range_tests_cmp_bitwise): For
	pointers cast them to pointer sized integers first.

	* gcc.c-torture/compile/pr106878.c: New test.
2022-09-14 12:36:36 +02:00
Richard Biener
05f5c42cb4 tree-optimization/106934 - avoid BIT_FIELD_REF of bitfields
The following avoids creating BIT_FIELD_REF of bitfields in
update-address-taken.  The patch doesn't implement punning to
a full precision integer type but leaves a comment according to
that.

	PR tree-optimization/106934
	* tree-ssa.cc (non_rewritable_mem_ref_base): Avoid BIT_FIELD_REFs
	of bitfields.
	(maybe_rewrite_mem_ref_base): Likewise.

	* gfortran.dg/pr106934.f90: New testcase.
2022-09-14 11:57:23 +02:00
liuhongt
93b09bf324 Check another epilog variable peeling case in vectorizable_nonlinear_induction.
in vectorizable_nonlinear_induction, r13-2503-gc13223b790bbc5 prevent variable peeling by
only checking LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo). But when
"!vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0", vectorizer will
still do variable peeling for epilog, and it hits gcc_assert in
vect_peel_nonlinear_iv_init.

gcc/ChangeLog:

	PR tree-optimization/106905
	* tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
	false when !vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
	LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr106905.c: New test.
	* gcc.target/ia64/pr106905.c: New test.
2022-09-14 15:44:48 +08:00
Torbjörn SVENSSON
9d503515ce testsuite: gluefile file need to be prefixed
When the status wrapper is used, the gluefile need to be prefixed with
-Wl, in order for the test cases to have the dump files with the
expected names.

2022-09-14  Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>

gcc/testsuite/
	PR target/95720
	* lib/g++.exp: Moved gluefile block to after flags have been
	  prefixed for the target_compile call.
	* lib/gcc.exp: Likewise.
	* lib/wrapper.exp: Reset adjusted state flag.

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-14 08:58:15 +02:00
GCC Administrator
1995a0227d Daily bump. 2022-09-14 00:18:07 +00:00
Roger Sayle
ff85f0afc7 PR target/106877: Robustify reg-stack to malformed asm.
This patch resolves PR target/106877 an ICE-on-invalid inline-asm
regression.  An innocent upstream change means that the test case
from PR inline-asm/84683 now hits a different assert in reg-stack.cc's
move_for_stack_reg.  Fixed by duplicating Jakub's solution to PR 84683
https://gcc.gnu.org/pipermail/gcc-patches/2018-March/495193.html at
this second (similar) gcc_assert.

2022-09-13  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	PR target/106877
	* reg-stack.cc (move_for_stack_reg): Check for any_malformed_asm
	in gcc_assert.

gcc/testsuite/ChangeLog
	PR target/106877
	* g++.dg/ext/pr106877.C: New test case.
2022-09-13 19:49:20 +01:00
Jakub Jelinek
e11babbfac libgomp: Appease some static analyzers [PR106906]
While icv_addr[1] = false; assignments where icv_addr has void *
element type is correct and matches how it is used (in those cases
the void * pointer is then cast to bool and used that way), there is no
reason not to add explicit (void *) casts there which are there already
for (void *) true.  And, there is in fact even no point in actually
doing those stores at all because we set that pointer to NULL a few
lines earlier.  So, this patch adds the explicit casts and then
comments those out to show intent.

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

	PR libgomp/106906
	* env.c (get_icv_member_addr): Cast false to void * before assigning
	it to icv_addr[1], and comment the whole assignment out.
2022-09-13 19:00:02 +02:00
Patrick Palka
7d7e2149cd libstdc++: Implement ranges::slide_view from P2442R1
This also implements the LWG 3711 and 3712 changes to slide_view.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__slide_caches_nothing): Define.
	(__detail::__slide_caches_last): Define.
	(__detail::__slide_caches_first): Define.
	(slide_view): Define.
	(enable_borrowed_range<slide_view>): Define.
	(slide_view::_Iterator): Define.
	(slide_view::_Sentinel): Define.
	(views::__detail::__can_slide_view): Define.
	(views::_Slide, views::slide): Define.
	* testsuite/std/ranges/adaptors/slide/1.cc: New test.
2022-09-13 11:18:16 -04:00
Patrick Palka
5d84a4418a libstdc++: Implement ranges::chunk_view from P2442R1
This also implements the LWG 3707, 3710 and 3712 changes to chunk_view.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__div_ceil): Define.
	(chunk_view): Define.
	(chunk_view::_OuterIter): Define.
	(chunk_view::_OuterIter::value_type): Define.
	(chunk_view::_InnerIter): Define.
	(chunk_view<_Vp>): Define partial specialization for forward
	ranges.
	(enable_borrowed_range<chunk_view>): Define.
	(chunk_view<_Vp>::_Iterator): Define.
	(views::__detail::__can_chunk_view): Define.
	(views::_Chunk, views::chunk): Define.
	* testsuite/std/ranges/adaptors/chunk/1.cc: New test.
2022-09-13 11:18:14 -04:00
Patrick Palka
7aa80c82ec libstdc++: Implement LWG 3569 changes to join_view::_Iterator
libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view::_Iterator::_M_satisfy):
	Adjust resetting _M_inner as per LWG 3569.
	(join_view::_Iterator::_M_inner): Wrap in std::optional
	as per LWG 3569.
	(join_view::_Iterator::_Iterator): Relax constraints as
	per LWG 3569.
	(join_view::_Iterator::operator*): Adjust as per LWG 3569.
	(join_view::_Iterator::operator->): Likewise.
	(join_view::_Iterator::operator++): Likewise.
	(join_view::_Iterator::operator--): Likewise.
	(join_view::_Iterator::iter_move): Likewise.
	(join_view::_Iterator::iter_swap): Likewise.
	* testsuite/std/ranges/adaptors/join.cc (test14): New test.
2022-09-13 11:18:07 -04:00
Patrick Palka
edf6fe7800 libstdc++: Avoid -Wparentheses warning with debug iterators
I noticed compiling e.g. std/ranges/adaptors/join.cc with
-D_GLIBCXX_DEBUG -Wsystem-headers -Wall gives the warning:

  gcc/libstdc++-v3/include/debug/safe_iterator.h:477:9: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]

libstdc++-v3/ChangeLog:

	* include/debug/safe_iterator.h (_GLIBCXX_DEBUG_VERIFY_OPERANDS):
	Add parentheses to avoid -Wparentheses warning.
2022-09-13 10:41:47 -04:00
Patrick Palka
5e1031ff8e c++: remove single-parameter version of mark_used
gcc/cp/ChangeLog:

	* cp-tree.h (mark_used): Remove single-parameter overload.  Add
	default argument to the two-parameter overload.
	* decl2.cc (mark_used): Likewise.
2022-09-13 10:18:58 -04:00
Patrick Palka
fea6ae0e5d c++: two-parameter version of cxx_constant_value
Since some callers need the complain parameter but not the object
parameter, let's introduce and use an overload of cxx_constant_value
that omits the latter.

gcc/cp/ChangeLog:

	* cp-tree.h (cxx_constant_value): Define two-parameter version
	that omits the object parameter.
	* decl.cc (build_explicit_specifier): Omit NULL_TREE object
	argument to cxx_constant_value.
	* except.cc (build_noexcept_spec): Likewise.
	* pt.cc (expand_integer_pack): Likewise.
	(fold_targs_r): Likewise.
	* semantics.cc (finish_if_stmt_cond): Likewise.
2022-09-13 10:01:29 -04:00
Patrick Palka
441a4880cb c++: some missing-SFINAE fixes
It looks like we aren't respecting SFINAE for:

  * an invalid/non-constant conditional explicit-specifier
  * a non-constant conditional noexcept-specifier
  * a non-constant argument to __integer_pack

This patch fixes these in the usual way, by passing complain and
propagating error_mark_node appropriately.

gcc/cp/ChangeLog:

	* decl.cc (build_explicit_specifier): Pass complain to
	cxx_constant_value.
	* except.cc (build_noexcept_spec): Likewise.
	* pt.cc (expand_integer_pack): Likewise.
	(tsubst_function_decl): Propagate error_mark_node returned
	from build_explicit_specifier.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/noexcept-type26.C: New test.
	* g++.dg/cpp2a/explicit19.C: New test.
	* g++.dg/ext/integer-pack6.C: New test.
2022-09-13 09:48:04 -04:00
Max Filippov
48e40d0b65 Revert "xtensa: Implement new target hook: TARGET_CONSTANT_OK_FOR_CPROP_P"
This reverts commit 936efcac73.
2022-09-13 04:28:40 -07:00