Commit Graph

185942 Commits

Author SHA1 Message Date
Jonathan Wright
d0889b5d37 aarch64: Model zero-high-half semantics of [SU]QXTN instructions
Split the aarch64_<su>qmovn<mode> pattern into separate scalar and
vector variants. Further split the vector RTL  pattern into big/
little endian variants that model the zero-high-half semantics of the
underlying instruction. Modeling these semantics allows for better
RTL combinations while also removing some register allocation issues
as the compiler now knows that the operation is totally destructive.

Add new tests to narrow_zero_high_half.c to verify the benefit of
this change.

gcc/ChangeLog:

2021-06-14  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Split generator
	for aarch64_<su>qmovn builtins into scalar and vector
	variants.
	* config/aarch64/aarch64-simd.md (aarch64_<su>qmovn<mode>_insn_le):
	Define.
	(aarch64_<su>qmovn<mode>_insn_be): Define.
	(aarch64_<su>qmovn<mode>): Split into scalar and vector
	variants. Change vector variant to an expander that emits the
	correct instruction depending on endianness.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/narrow_zero_high_half.c: Add new tests.
2021-06-16 14:22:22 +01:00
Jonathan Wright
c86a303968 aarch64: Model zero-high-half semantics of SQXTUN instruction in RTL
Split the aarch64_sqmovun<mode> pattern into separate scalar and
vector variants. Further split the vector pattern into big/little
endian variants that model the zero-high-half semantics of the
underlying instruction. Modeling these semantics allows for better
RTL combinations while also removing some register allocation issues
as the compiler now knows that the operation is totally destructive.

Add new tests to narrow_zero_high_half.c to verify the benefit of
this change.

gcc/ChangeLog:

2021-06-14  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Split generator
	for aarch64_sqmovun builtins into scalar and vector variants.
	* config/aarch64/aarch64-simd.md (aarch64_sqmovun<mode>):
	Split into scalar and vector variants. Change vector variant
	to an expander that emits the correct instruction depending
	on endianness.
	(aarch64_sqmovun<mode>_insn_le): Define.
	(aarch64_sqmovun<mode>_insn_be): Define.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/narrow_zero_high_half.c: Add new tests.
2021-06-16 14:22:08 +01:00
Jonathan Wright
d8a88cdae9 aarch64: Model zero-high-half semantics of XTN instruction in RTL
Modeling the zero-high-half semantics of the XTN narrowing
instruction in RTL indicates to the compiler that this is a totally
destructive operation. This enables more RTL simplifications and also
prevents some register allocation issues.

Add new tests to narrow_zero_high_half.c to verify the benefit of
this change.

gcc/ChangeLog:

2021-06-11  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd.md (aarch64_xtn<mode>_insn_le):
	Define - modeling zero-high-half semantics.
	(aarch64_xtn<mode>): Change to an expander that emits the
	appropriate instruction depending on endianness.
	(aarch64_xtn<mode>_insn_be): Define - modeling zero-high-half
	semantics.
	(aarch64_xtn2<mode>_le): Rename to...
	(aarch64_xtn2<mode>_insn_le): This.
	(aarch64_xtn2<mode>_be): Rename to...
	(aarch64_xtn2<mode>_insn_be): This.
	(vec_pack_trunc_<mode>): Emit truncation instruction instead
	of aarch64_xtn.
	* config/aarch64/iterators.md (Vnarrowd): Add Vnarrowd mode
	attribute iterator.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/narrow_zero_high_half.c: Add new tests.
2021-06-16 14:21:52 +01:00
Jonathan Wright
ac6c858d07 testsuite: aarch64: Add zero-high-half tests for narrowing shifts
Add tests to verify that Neon narrowing-shift instructions clear the
top half of the result vector. It is sufficient to show that a
subsequent combine with a zero-vector is optimized away - leaving
just the narrowing-shift instruction.

gcc/testsuite/ChangeLog:

2021-06-15  Jonathan Wright  <jonathan.wright@arm.com>

	* gcc.target/aarch64/narrow_zero_high_half.c: New test.
2021-06-16 14:21:34 +01:00
Martin Jambor
d7deee423f
tree-sra: Do not refresh readonly decls (PR 100453)
When SRA transforms an assignment where the RHS is an aggregate decl
that it creates replacements for, the (least efficient) fallback
method of dealing with them is to store all the replacements back into
the original decl and then let the original assignment takes its
course.

That of course should not need to be done for TREE_READONLY bases
which cannot change contents.  The SRA code handled this situation
only for DECL_IN_CONSTANT_POOL const decls, this patch modifies the
check so that it tests for TREE_READONLY and I also looked at all
other callers of generate_subtree_copies and added checks to another
one dealing with the same exact situation and one which deals with it
in a non-assignment context.

gcc/ChangeLog:

2021-06-11  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/100453
	* tree-sra.c (create_access): Disqualify any const candidates
	which are written to.
	(sra_modify_expr): Do not store sub-replacements back to a const base.
	(handle_unscalarized_data_in_subtree): Likewise.
	(sra_modify_assign): Likewise.  Earlier, use TREE_READONLy test
	instead of constant_decl_p.

gcc/testsuite/ChangeLog:

2021-06-10  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/100453
	* gcc.dg/tree-ssa/pr100453.c: New test.
2021-06-16 13:23:14 +02:00
Jakub Jelinek
a490b1dc0b testsuite: Use noipa attribute instead of noinline, noclone
I've noticed this test now on various arches sometimes FAILs, sometimes
PASSes (the line 12 test in particular).

The problem is that a = 0; initialization in the caller no longer happens
before the f(&a) call as what the argument points to is only used in
debug info.

Making the function noipa forces the caller to initialize it and still
tests what the test wants to test, namely that we don't consider *p as
valid location for the c variable at line 18 (after it has been overwritten
with *p = 1;).

2021-06-16  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/guality/pr49888.c (f): Use noipa attribute instead of
	noinline, noclone.
2021-06-16 13:10:48 +02:00
Jakub Jelinek
b4b50bf286 stor-layout: Create DECL_BIT_FIELD_REPRESENTATIVE even for bitfields in unions [PR101062]
The following testcase is miscompiled on x86_64-linux, the bitfield store
is implemented as a RMW 64-bit operation at d+24 when the d variable has
size of only 28 bytes and scheduling moves in between the R and W part
a store to a different variable that happens to be right after the d
variable.

The reason for this is that we weren't creating
DECL_BIT_FIELD_REPRESENTATIVEs for bitfields in unions.

The following patch does create them, but treats all such bitfields as if
they were in a structure where the particular bitfield is the only field.

2021-06-16  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/101062
	* stor-layout.c (finish_bitfield_representative): For fields in unions
	assume nextf is always NULL.
	(finish_bitfield_layout): Compute bit field representatives also in
	unions, but handle it as if each bitfield was the only field in the
	aggregate.

	* gcc.dg/pr101062.c: New test.
2021-06-16 12:17:55 +02:00
Richard Biener
43fc4234ad tree-optimization/101088 - fix SM invalidation issue
When we face a sm_ord vs sm_unord for the same ref during
store sequence merging we assert that the ref is already marked
unsupported.  But it can be that it will only be marked so
during the ongoing merging so instead of asserting mark it here.

Also apply some optimization to not waste resources to search
for already unsupported refs.

2021-06-16  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101088
	* tree-ssa-loop-im.c (sm_seq_valid_bb): Only look for
	supported refs on edges.  Do not assert same ref but
	different kind stores are unsuported but mark them so.
	(hoist_memory_references): Only look for supported refs
	on exits.

	* gcc.dg/torture/pr101088.c: New testcase.
2021-06-16 11:28:03 +02:00
Roger Sayle
3155d51bfd [PATCH] PR rtl-optimization/46235: Improved use of bt for bit tests on x86_64.
This patch tackles PR46235 to improve the code generated for bit tests
on x86_64 by making more use of the bt instruction.  Currently, GCC emits
bt instructions when followed by condition jumps (thanks to Uros' splitters).
This patch adds splitters in i386.md, to catch the cases where bt is followed
by a conditional move (as in the original report), or by a setc/setnc (as in
comment 5 of the Bugzilla PR).

With this patch, the function in the original PR
int foo(int a, int x, int y) {
    if (a & (1 << x))
       return a;
   return 1;
}

which with -O2 on mainline generates:
foo:	movl    %edi, %eax
        movl    %esi, %ecx
        sarl    %cl, %eax
        testb   $1, %al
        movl    $1, %eax
        cmovne  %edi, %eax
        ret

now generates:
foo:	btl     %esi, %edi
        movl    $1, %eax
        cmovc   %edi, %eax
        ret

Likewise, IsBitSet1 and IsBitSet2 (from comment 5)
bool IsBitSet1(unsigned char byte, int index) {
    return (byte & (1<<index)) != 0;
}
bool IsBitSet2(unsigned char byte, int index) {
    return (byte >> index) & 1;
}

Before:
        movzbl  %dil, %eax
        movl    %esi, %ecx
        sarl    %cl, %eax
        andl    $1, %eax
        ret

After:
        movzbl  %dil, %edi
        btl     %esi, %edi
        setc    %al
        ret

According to Agner Fog, SAR/SHR r,cl takes 2 cycles on skylake,
where BT r,r takes only one, so the performance improvements on
recent hardware may be more significant than implied by just
the reduced number of instructions.  I've avoided transforming cases
(such as btsi_setcsi) where using bt sequences may not be a clear
win (over sarq/andl).

2010-06-15  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	PR rtl-optimization/46235
	* config/i386/i386.md: New define_split for bt followed by cmov.
	(*bt<mode>_setcqi): New define_insn_and_split for bt followed by setc.
	(*bt<mode>_setncqi): New define_insn_and_split for bt then setnc.
	(*bt<mode>_setnc<mode>): New define_insn_and_split for bt followed
	by setnc with zero extension.

gcc/testsuite/ChangeLog
	PR rtl-optimization/46235
	* gcc.target/i386/bt-5.c: New test.
	* gcc.target/i386/bt-6.c: New test.
	* gcc.target/i386/bt-7.c: New test.
2021-06-16 09:56:09 +01:00
Jakub Jelinek
041f741770 libffi: Fix up x86_64 classify_argument
As the following testcase shows, libffi didn't handle properly
classify_arguments of structures at byte offsets not divisible by
UNITS_PER_WORD.  The following patch adjusts it to match what
config/i386/ classify_argument does for that and also ports the
PR38781 fix there (the second chunk).

This has been committed to upstream libffi already:
5651bea284

2021-06-16  Jakub Jelinek  <jakub@redhat.com>

	* src/x86/ffi64.c (classify_argument): For FFI_TYPE_STRUCT set words
	to number of words needed for type->size + byte_offset bytes rather
	than just type->size bytes.  Compute pos before the loop and check
	total size of the structure.
	* testsuite/libffi.call/nested_struct12.c: New test.
2021-06-16 10:45:27 +02:00
Piotr Trojanek
ccf0dee109 [Ada] Fix Is_Volatile_Function for functions declared in protected bodies
gcc/ada/

	* sem_util.adb (Is_Volatile_Function): Follow the exact wording
	of SPARK (regarding volatile functions) and Ada (regarding
	protected functions).
2021-06-16 04:43:05 -04:00
Piotr Trojanek
1a9ff8d39c [Ada] Ignore volatile restrictions in preanalysis
gcc/ada/

	* sem_util.adb (Is_OK_Volatile_Context): All references to
	volatile objects are legal in preanalysis.
	(Within_Volatile_Function): Previously it was wrongly called on
	Empty entities; now it is only called on E_Return_Statement,
	which allow the body to be greatly simplified.
2021-06-16 04:43:05 -04:00
Yannick Moy
3feba0a578 [Ada] Do not generate an Itype_Reference node for slices in GNATprove mode
gcc/ada/

	* sem_res.adb (Set_Slice_Subtype): Revert special-case
	introduced previously, which is not needed as Itypes created for
	slices are precisely always used.
2021-06-16 04:43:04 -04:00
Eric Botcazou
f4fe186bfe [Ada] Fix floating-point exponentiation with Integer'First exponent
gcc/ada/

	* urealp.adb (Scale): Change first paramter to Uint and adjust.
	(Equivalent_Decimal_Exponent): Pass U.Den directly to Scale.
	* libgnat/s-exponr.adb (Negative): Rename to...
	(Safe_Negative): ...this and change its lower bound.
	(Exponr): Adjust to above renaming and deal with Integer'First.
2021-06-16 04:43:04 -04:00
Piotr Trojanek
07b7dc09b2 [Ada] Fix detection of volatile expressions in restricted contexts
gcc/ada/

	* sem_res.adb (Flag_Effectively_Volatile_Objects): Detect also
	allocators within restricted contexts and not just entity names.
	(Resolve_Actuals): Remove duplicated code for detecting
	restricted contexts; it is now exclusively done in
	Is_OK_Volatile_Context.
	(Resolve_Entity_Name): Adapt to new parameter of
	Is_OK_Volatile_Context.
	* sem_util.ads, sem_util.adb (Is_OK_Volatile_Context): Adapt to
	handle contexts both inside and outside of subprogram call
	actual parameters.
	(Within_Subprogram_Call): Remove; now handled by
	Is_OK_Volatile_Context itself and its parameter.
2021-06-16 04:43:04 -04:00
Piotr Trojanek
207962b929 [Ada] Cleanup repeated calls in Sloc_Range
gcc/ada/

	* sinput.adb (Sloc_Range): Refactor several repeated calls to
	Sloc and two comparisons with No_Location.
2021-06-16 04:43:04 -04:00
Piotr Trojanek
cc9a7ae229 [Ada] Fix aliasing check for actual parameters passed by reference
gcc/ada/

	* checks.adb (Apply_Scalar_Range_Check): Fix handling of check depending
	on the parameter passing mechanism.  Grammar adjustment ("has"
	=> "have").
	(Parameter_Passing_Mechanism_Specified): Add a hyphen in a comment.
2021-06-16 04:43:03 -04:00
Piotr Trojanek
6dc7a8ab14 [Ada] Remove unused initialization with New_List
gcc/ada/

	* exp_ch3.adb (Build_Slice_Assignment): Remove unused
	initialization.
2021-06-16 04:43:03 -04:00
Piotr Trojanek
e027681d90 [Ada] Fix typos in all occurrences of "occuring" in GNAT
gcc/ada/

	* restrict.adb, sem_attr.adb, types.ads: Fix typos in
	"occuring"; refill comment as necessary.
2021-06-16 04:43:03 -04:00
Piotr Trojanek
7ef1d8e88b [Ada] Adapt Is_Actual_Parameter to also work for entry parameters
gcc/ada/

	* sem_util.ads (Is_Actual_Parameter): Update comment.
	* sem_util.adb (Is_Actual_Parameter): Also detect entry parameters.
2021-06-16 04:43:02 -04:00
Arnaud Charlet
37cd8d97f3 [Ada] Wrong reference to System.Tasking in expanded code
gcc/ada/

	* rtsfind.ads, libgnarl/s-taskin.ads, exp_ch3.adb, exp_ch4.adb,
	exp_ch6.adb, exp_ch9.adb, sem_ch6.adb: Move master related
	entities to the expander directly.
2021-06-16 04:43:02 -04:00
Piotr Trojanek
f7f37ed649 [Ada] Cleanup related to volatile objects in restricted contexts
gcc/ada/

	* sem_res.adb (Is_Assignment_Or_Object_Expression): Whitespace
	cleanup.
	(Is_Attribute_Expression): Prevent AST climbing from going to
	the root of the compilation unit.
2021-06-16 04:43:02 -04:00
Steve Baird
788fed4b39 [Ada] Include info about containers in GNAT RM Implementation Advice section
gcc/ada/

	* doc/gnat_rm/implementation_advice.rst: Add a section for RM
	A.18 .
	* gnat_rm.texi: Regenerate.
2021-06-16 04:43:01 -04:00
Justin Squirek
e66167fb49 [Ada] Mixing of positional and named entries allowed in enum rep
gcc/ada/

	* sem_ch13.adb (Analyze_Enumeration_Representation_Clause): Add
	check for the mixing of entries.
2021-06-16 04:43:01 -04:00
Justin Squirek
c5dc00ef38 [Ada] Non-static Interrupt_Priority allowed with restriction Static_Priorities
gcc/ada/

	* sem_ch13.adb (Make_Aitem_Pragma): Check for static expressions
	in Priority aspect arguments for restriction Static_Priorities.
2021-06-16 04:43:01 -04:00
Justin Squirek
f5b4b6bf14 [Ada] Spurious accessibility error on "for of" loop parameter
gcc/ada/

	* sem_util.adb (Accessibility_Level): Take into account
	renamings of loop parameters.
2021-06-16 04:43:00 -04:00
Matthieu Eyraud
7626537ae7 [Ada] Fix ALI source location for dominance markers
gcc/ada/

	* par_sco.adb (Set_Statement_Entry): Change sloc for dominance
	marker.
	(Traverse_One): Fix typo.
	(Output_Header): Fix comment.
2021-06-16 04:43:00 -04:00
Richard Kenner
ff4746bcde [Ada] Don't look for aliases for generic subprograms
gcc/ada/

	* exp_unst.adb (Register_Subprogram): Don't look for aliases for
	subprograms that are generic.  Reorder tests for efficiency.
2021-06-16 04:43:00 -04:00
Eric Botcazou
e505bf515f [Ada] Make Incomplete_Or_Partial_View independent of the context
gcc/ada/

	* sem_util.adb (Incomplete_Or_Partial_View): Retrieve the scope of
	the parameter and use it to find its incomplete view, if any.
2021-06-16 04:43:00 -04:00
Eric Botcazou
5c44cc1c73 [Ada] Do not perform useless work in Check_No_Parts_Violations
gcc/ada/

	* freeze.adb (Check_No_Parts_Violations): Return earlier if the
	type is elementary or does not come from source.
2021-06-16 04:42:59 -04:00
Bob Duff
1ac6fcf57c [Ada] Fix missing array bounds checking
gcc/ada/

	* ghost.adb: Add another special case where full analysis is
	needed. This bug is due to quirks in the way
	Mark_And_Set_Ghost_Assignment works (it happens very early,
	before name resolution is done).
2021-06-16 04:42:59 -04:00
Eric Botcazou
663e6d7960 [Ada] Use more straightforward implementation for Current_Entity_In_Scope
gcc/ada/

	* sem_util.adb (Current_Entity_In_Scope): Reimplement.
2021-06-16 04:42:59 -04:00
Piotr Trojanek
3e07c2df70 [Ada] Remove extra parens around a function call
gcc/ada/

	* sem_ch8.adb (End_Scope): Remove extra parens.
2021-06-16 04:42:59 -04:00
Javier Miranda
cbb64f6b9a [Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls
gcc/ada/

	* exp_disp.adb (Build_Class_Wide_Check): Ensure that evaluation
	of actuals is side effects free (since the check duplicates
	actuals).
2021-06-16 04:42:58 -04:00
Ed Schonberg
a2d2310d80 [Ada] Implementation of AI12-0152: legality rules for Raise_Expression
gcc/ada/

	* sem_res.adb (Resolve_Raise_Expression): Apply Ada_2020 rules
	concerning the need for parentheses around Raise_Expressions in
	various contexts.
2021-06-16 04:42:58 -04:00
Piotr Trojanek
c50041b99b [Ada] Reorder code for validity checks of unchecked conversions
gcc/ada/

	* sem_ch13.adb (Validate_Unchecked_Conversion): Move detection
	of generic types before switching to their private views; fix
	style in using AND THEN.
2021-06-16 04:42:58 -04:00
Arnaud Charlet
3311703920 [Ada] Raise expressions and unconstrained components
gcc/ada/

	* sem_ch3.adb (Analyze_Component_Declaration): Do not special
	case raise expressions.

gcc/testsuite/

	* gnat.dg/limited4.adb: Disable illegal code.
2021-06-16 04:42:57 -04:00
Sergey Rybin
a85d1c1407 [Ada] Clarify the documentation of -gnaty0 style check option
gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
	Instead of referring to the formatting of the Ada examples in
	Ada RM add use the list of checks that are actually performed.
	* gnat_ugn.texi: Regenerate.
2021-06-16 04:42:57 -04:00
Eric Botcazou
059a91ea91 [Ada] Small cleanup in C header files
gcc/ada/

	* initialize.c: Do not include vxWorks.h and fcntl.h from here.
	(__gnat_initialize) [__MINGW32__]: Remove #ifdef and attribute
	(__gnat_initialize) [init_float]: Delete.
	(__gnat_initialize) [VxWorks]: Likewise.
	(__gnat_initialize) [PA-RISC HP-UX 10]: Likewise.
	* runtime.h: Add comment about vxWorks.h include.
2021-06-16 04:42:57 -04:00
Eric Botcazou
6e96a5a503 [Ada] Small cleanup in System.Exceptions
gcc/ada/

	* libgnat/s-except.ads (ZCX_By_Default): Delete.
	(Require_Body): Likewise.
	* libgnat/s-except.adb: Replace body with pragma No_Body.
2021-06-16 04:42:57 -04:00
Richard Biener
4e56b13476 tree-optimization/101083 - fix ICE with SLP reassoc
This makes us pass down the vector type for the two-operand
SLP node build rather than picking that from operand one which,
when constant or external, could be NULL.

2021-06-16  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101083
	* tree-vect-slp.c (vect_slp_build_two_operator_nodes): Get
	vectype as argument.
	(vect_build_slp_tree_2): Adjust.

	* gcc.dg/vect/pr97832-4.c: New testcase.
2021-06-16 08:58:28 +02:00
GCC Administrator
ede6c3568f Daily bump. 2021-06-16 00:17:05 +00:00
David Malcolm
ec3fafa9ec analyzer: fix bitfield endianness issues [PR99212,PR101082]
Looks like my patch for PR analyzer/99212 implicitly assumed
little-endian, which the following patch fixes.

Fixes bitfields-1.c on:
- armeb-none-linux-gnueabihf
- cris-elf
- powerpc64-darwin
- s390-linux-gnu

gcc/analyzer/ChangeLog:
	PR analyzer/99212
	PR analyzer/101082
	* engine.cc: Include "target.h".
	(impl_run_checkers): Log BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and
	WORDS_BIG_ENDIAN.
	* region-model-manager.cc
	(region_model_manager::maybe_fold_binop): Move support for masking
	via ARG0 & CST into...
	(region_model_manager::maybe_undo_optimize_bit_field_compare):
	...this new function.  Flatten by converting from nested
	conditionals to a series of early return statements to reject
	failures.  Reject if type is not unsigned_char_type_node.
	Handle BYTES_BIG_ENDIAN when determining which bits are bound
	in the binding_map.
	* region-model.h
	(region_model_manager::maybe_undo_optimize_bit_field_compare):
	New decl.
	* store.cc (bit_range::dump): New function.
	* store.h (bit_range::dump): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-06-15 17:53:34 -04:00
Martin Sebor
71790f398e Consider size_t mangling as unsigned int and long [PR100876].
gcc/ChangeLog:

	PR middle-end/100876
	* builtins.c: (gimple_call_return_array): Account for size_t
	mangling as either unsigned int or unsigned long
2021-06-15 12:46:54 -06:00
Jonathan Wakely
8b93548778 libstdc++: Make ranges CPOs final and not addressable
This restricts the API of the CPOs and other function objects so they
cannot be misused by deriving from them or taking their addresses.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (ranges::begin, ranges::end)
	(ranges::cbegin, ranges::cend, ranges::rbeing, ranges::rend)
	(ranges::crbegin, ranges::crend, ranges::size, ranges::ssize)
	(ranges::empty, ranges::data, ranges::cdata): Make types final.
	Add deleted operator& overloads.
	(ranges::advance, ranges::distance, ranges::next, ranges::prev):
	Likewise.
	* testsuite/std/ranges/headers/ranges/synopsis.cc: Replace
	ill-formed & expressions with using-declarations. Add checks for
	other function objects.
2021-06-15 18:20:06 +01:00
Jonathan Wakely
9245b0e84c libstdc++: Add noexcept specifiers to some range adaptors
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (view_interface): Add noexcept to
	empty, operator bool, data and size members.
	(subrange): Add noexcept to constructors.
	* include/std/ranges (single_view, ref_view): Add noexcept to
	constructors.
	(views::single, views::all): Add noexcept.
	* testsuite/std/ranges/adaptors/all.cc: Check noexcept.
	* testsuite/std/ranges/single_view.cc: Likewise.
2021-06-15 18:20:06 +01:00
Jonathan Wakely
a88fc03ba7 libstdc++: Remove precondition checks from ranges::subrange
The assertion in the subrange constructor causes semantic changes,
because the call to ranges::distance performs additional operations that
are not part of the constructor's specification. That will fail to
compile if the iterator is move-only, because the argument to
ranges::distance is passed by value. It will modify the subrange if the
iterator is not a forward iterator, because incrementing the copy also
affects the _M_begin member. Those problems could be prevented by using
if-constexpr to only do the assertion for copyable forward iterators,
but the call to ranges::distance can also prevent the constructor being
usable in constant expressions. If the member initializers are usable in
constant expressions, but iterator increments of equality comparisons
are not, then the checks done by __glibcxx_assert might
make constant evaluation fail.

This change removes the assertion. Additionally, a new typedef is
introduced to simplify the declarations using __make_unsigned_like_t on
the iterator's difference type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange): Add __size_type typedef
	and use it to simplify declarations.
	(subrange(i, s, n)): Remove assertion.
	* testsuite/std/ranges/subrange/constexpr.cc: New test.
2021-06-15 18:20:06 +01:00
Jonathan Wakely
cb326a6442 libstdc++: Use function object for __decay_copy helper
By changing __cust_access::__decay_copy from a function template to a
function object we avoid ADL. That means it's fine to call it
unqualified (the compiler won't waste time doing ADL in associated
namespaces, and won't try to complete associated types).

This also makes some other minor simplications to other concepts for the
[range.access] CPOs.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__cust_access::__decay_copy):
	Replace with function object.
	(__cust_access::__member_begin, ___cust_access::_adl_begin): Use
	__decay_copy unqualified.
	* include/bits/ranges_base.h (__member_end, __adl_end):
	Likewise. Use __range_iter_t for type of ranges::begin.
	(__member_rend): Use correct value category for rbegin argument.
	(__member_data): Use __decay_copy unqualified.
	(__begin_data): Use __range_iter_t for type of ranges::begin.
2021-06-15 18:20:06 +01:00
Jeff Law
6d43ec5096 Minor improvement to compare elimination
gcc/
	* compare-elim.c (try_eliminate_compare): Run DCE to clean things
	up before eliminating comparisons.
2021-06-15 12:43:42 -04:00
Aldy Hernandez
4602714382 range-ops: (nonzero | X) is nonzero
For bitwise or, nonzero|X is always nonzero.  Make sure we don't drop to
varying in this case.

gcc/ChangeLog:

	* range-op.cc (operator_bitwise_or::wi_fold): Make sure
	nonzero|X is nonzero.
	(range_op_bitwise_and_tests): Add tests for above.
2021-06-15 18:41:09 +02:00