]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 years agoada: Remove unnecessary call to Detach.
Vadim Godunko [Wed, 15 Feb 2023 08:22:27 +0000 (12:22 +0400)] 
ada: Remove unnecessary call to Detach.

Holder object is constant and protected from modification by tampering
rules.

gcc/ada/

* libgnat/a-coinho__shared.adb (Constant_Reference): Remove call
of Detach
(Query_Element): Likewise.

2 years agoada: Fix reference to Ada issue in comment
Ronan Desplanques [Wed, 22 Feb 2023 17:40:16 +0000 (18:40 +0100)] 
ada: Fix reference to Ada issue in comment

gcc/ada/

* sem_disp.adb: Fix reference to Ada issue in comment.

2 years agoada: Fix address arithmetic issues in the expanded code
Eric Botcazou [Wed, 22 Feb 2023 16:00:06 +0000 (17:00 +0100)] 
ada: Fix address arithmetic issues in the expanded code

This is most notably the addition of addresses in Expand_Interface_Thunk.
There is also a small change to Expand_Dispatching_Call, which was directly
accessing a class-wide interface object as a tag, thus giving rise later to
unchecked conversions between either the root or the equivalent record type
and access types.

gcc/ada/

* exp_disp.adb (Expand_Dispatching_Call): In the abstract interface
class-wide case, use 'Tag of the object as the controlling tag.
(Expand_Interface_Thunk): Perform address arithmetic using operators
of System.Storage_Elements.

2 years agoada: Fix address arithmetic issues in the runtime
Eric Botcazou [Wed, 22 Feb 2023 13:43:37 +0000 (14:43 +0100)] 
ada: Fix address arithmetic issues in the runtime

This is most notably the addition of addresses in Interfaces.C.Pointers and
System.Bitfield_Utils.  There is also a change to System.Stream_Attributes,
which was representing a thin pointer as a record, which is not problematic
per se, but is in the end, because the expanded code performs an unchecked
conversion from it to the access type instead of accessing the component.

gcc/ada/

* libgnat/i-cpoint.adb: Add clauses for System.Storage_Elements.
(Addr): Delete.
(Offset): New subtype of Storage_Offset.
(To_Offset): New instance of Unchecked_Conversion.
(To_Pointer): Adjust.
(To_Addr): Likewise.
(To_Ptrdiff): Likewise.
("+"): Call To_Offset on the offset.
("-"): Likewise.
* libgnat/s-bituti.adb: Add clauses for System.Storage_Elements.
(Val_Bytes): Change type to Storage_Count.
(Get_Val_2): Add qualification to second operand of mod operator.
(Set_Val_2): Likewise.
(Copy_Bitfield): Likewise.  Change type of Src_Adjust & Dest_Adjust.
* libgnat/s-stratt.ads (Thin_Pointer): Change to subtype of Address.
* libgnat/s-statxd.adb (I_AD): Adjust.
(I_AS): Likewise.
(W_AS): Likewise.

2 years agoada: A discriminant of a variable is not a variable
Steve Baird [Thu, 16 Feb 2023 00:13:06 +0000 (16:13 -0800)] 
ada: A discriminant of a variable is not a variable

gcc/ada/

* sem_util.adb
(Is_Variable): Correctly return False for a selected component
name of the form Some_Object.Some_Discriminant, even if
Some_Object is a variable. We don't want to allow such a name as
an actual parameter in a call if the corresponding formal
parameter's mode is not "in".

2 years agoada: Add default value at initialization for CodePeer
Yannick Moy [Wed, 22 Feb 2023 16:25:33 +0000 (17:25 +0100)] 
ada: Add default value at initialization for CodePeer

Avoid spurious alarm by CodePeer analysis by adding default value
for a variable initialization.

gcc/ada/

* sem_util.adb (Check_Node): Add default init on local Id.

2 years agoada: Facilitate proof of Interfaces.C.To_Ada
Yannick Moy [Wed, 22 Feb 2023 13:36:09 +0000 (13:36 +0000)] 
ada: Facilitate proof of Interfaces.C.To_Ada

Nightly runs of GNATprove fail on proof of the assertion following
the loop. Add a loop invariant to facilitate that proof.

gcc/ada/

* libgnat/i-c.adb (To_Ada): Add loop invariant.

2 years agoada: Remove the body of System.Storage_Elements
Eric Botcazou [Sun, 19 Feb 2023 17:45:00 +0000 (18:45 +0100)] 
ada: Remove the body of System.Storage_Elements

All the subprograms declared in the unit have convention Intrinsic and
their current implementation makes some implicit assumptions that are
not valid universally, so it is replaced by a direct expansion.

This is mostly straightforward because Resolve_Intrinsic_Operator already
contains the required circuitry, but a few adjustements are necessary.

gcc/ada/

* exp_ch4.adb (Expand_N_Op_Mod): Deal with the special mod
operator of System.Storage_Elements.
* exp_intr.adb (Expand_To_Integer): New procedure.
(Expand_Intrinsic_Call): Call Expand_To_Integer appropriately.
(Expand_To_Address): Deal with an argument with modular type.
* sem_ch3.adb (Derive_Subprogram): Also set convention Intrinsic
on a derived intrinsic subprogram.
* sem_res.adb (Resolve_Arithmetic_Op): Deal with intrinsic
operators not coming from source exactly as those coming from
source and also generate a reference in both cases.
(Resolve_Op_Expon): Likewise.
(Resolve_Intrinsic_Operator): Call Implementation_Base_Type to get
a nonprivate base type.
* snames.ads-tmpl (Name_To_Integer): New intrinsic name.
* libgnat/s-stoele.ads: Replace pragma Convention with pragma
Import throughout and remove pragma Inline_Always and
Pure_Function.
* libgnat/s-stoele.adb: Replace entire contents with pragma
No_Body.
* libgnat/s-atacco.adb: Adjust comment about pragma No_Body.

2 years agoada: Spurious errors on class-wide preconditions of private types
Javier Miranda [Fri, 17 Feb 2023 18:57:07 +0000 (18:57 +0000)] 
ada: Spurious errors on class-wide preconditions of private types

The compiler reports spurious errors processing the class-wide
preconditions of a dispatching primitive of a private type T, when
the class-wide precondition invokes another dispatching primitive
of T that has the same name as a record component of T.

gcc/ada/

* sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part): Remove
call to preanalyze class-wide conditions since here it is too
early; they must be preanalyzed when full views of private types
have been analyzed.
* sem_ch7.adb (Analyze_Package_Specification): Preanalyze
class-wide conditions of dispatching primitives defined in nested
packages.

2 years agoada: Turn assertions into defensive code in error locations
Piotr Trojanek [Mon, 20 Feb 2023 13:01:36 +0000 (14:01 +0100)] 
ada: Turn assertions into defensive code in error locations

We pretty-print numeric literals that do not come from source by relying
on their Sloc. This generally works well, but sporadically the Sloc is
set wrongly. We might want to trace and fix such occurrences, but for
now it is simpler to replace an otherwise reasonable assertions with
defensive code.

gcc/ada/

* errout.adb (Last_Sloc): Refactor a heavily repeated "S := S + 1"
statement into a subprogram; replace assertions with defensive code;
fix few more off-by-one errors.

2 years agoada: Add mention of what LSP stands for
Ronan Desplanques [Fri, 17 Feb 2023 15:00:33 +0000 (16:00 +0100)] 
ada: Add mention of what LSP stands for

There are multiple possible interpretations of "LSP". For example,
"Language Server Protocol". This patch clarifies that the
occurrences of "LSP" in GNAT's source code refer to the Liskov
Substitution Principle.

gcc/ada/

* einfo.ads: Mention full name of LSP.

2 years agoada: Fix endings of pretty-printed numeric literals
Piotr Trojanek [Fri, 17 Feb 2023 23:02:08 +0000 (00:02 +0100)] 
ada: Fix endings of pretty-printed numeric literals

When looking for the end of an numeric literal we consumed '+' and '-'
characters, because they might appear in the exponent part. This was too
aggressive when they separated the number from the subsequent operand,
like in "123+456". Now we skip past numeric literals by strictly
following their grammar and only consume '+' and '-' when they belong to
the exponent.

gcc/ada/

* errout.adb (Last_Sloc): Rewrite skipping past numeric literals.

2 years agoada: Fix internal error on quantified expression with predicated type
Eric Botcazou [Wed, 15 Feb 2023 14:52:00 +0000 (15:52 +0100)] 
ada: Fix internal error on quantified expression with predicated type

The problem is that the special function created by the compiler to check
the predicate does not inherit the public status of the type, because it
is generated as part of the freezing of the quantified expression, which
occurs from within a couple of intermediate internal scopes.

gcc/ada/

* sem_ch13.adb (Build_Predicate_Function_Declaration): Adjust the
commentary to the current implementation.
* sem_util.ads (Current_Scope_No_Loops): Move around.
(Current_Scope_No_Loops_No_Blocks): New declaration.
(Add_Block_Identifier): Fix formatting.
* sem_util.adb (Add_Block_Identifier): Likewise.
(Current_Scope_No_Loops_No_Blocks): New function.
(Set_Public_Status): Call Current_Scope_No_Loops_No_Blocks instead
of Current_Scope to get the current scope.

2 years agoada: Fix bogus error on predicated limited record declared in protected type
Eric Botcazou [Fri, 17 Feb 2023 17:01:52 +0000 (18:01 +0100)] 
ada: Fix bogus error on predicated limited record declared in protected type

This happens when the limited record is initialized with a function call
because of a couple of issues: incorrect tree sharing when building the
predicate check and too late freezing for a compiler-generated subtype.

It turns out that building the predicate check manually is redundant here,
since predicate checks are automatically generated during the expansion of
assignment statements, and the late freezing can be easily fixed.

gcc/ada/

* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do not
manually generate a predicate check.  Call Unqualify before doing
pattern matching on the expression.
* sem_ch3.adb (Analyze_Object_Declaration): Also freeze the actual
subtype when it is built in the definite case.

2 years agoada: Sync different variants of interrupt handler registration
Piotr Trojanek [Fri, 9 Sep 2022 15:49:39 +0000 (17:49 +0200)] 
ada: Sync different variants of interrupt handler registration

This patch propagates the apparently cleanest solutions between various
variants of the runtime units for interrupt handler registration.

In particular, the unnecessary default expressions for list cells with
interrupt handler addresses are removed, the list is changed from
doubly-linked to singly-linked, and assertion preventing registration of
null addresses now appears in all runtimes.

Effectively, it is just a code cleanup and minor optimization; behavior
of the runtime unit is unaffected.

gcc/ada/

* libgnarl/s-interr.adb
(Registered_Handler): Remove default expression.
(Registered_Handlers): Switch to singly-linked list.
(Bind_Interrupt_To_Entry): Sync whitespace with other unit variants.
(Is_Registered): Use singly-linked list.
(Register_Interrupt_Handler): Use singly-linked list and initialized
allocator; sync assertion with other unit variants.
* libgnarl/s-interr__sigaction.adb: Likewise.
* libgnarl/s-interr__vxworks.adb: Likewise.
* libgnarl/s-interr__hwint.adb: Likewise.
(Is_Registered): Remove repeated declaration.

2 years agoada: Revert to old pretty-printing of internal entities for CodePeer
Piotr Trojanek [Tue, 14 Feb 2023 16:05:59 +0000 (17:05 +0100)] 
ada: Revert to old pretty-printing of internal entities for CodePeer

Add some defensive code to get pretty-printed CodePeer outputs for ACATS
back to shape. At least some of this code appears to be redundant and
perhaps unnecessary, but we can this up later.

Expression pretty-printer should not be called with
N_Defining_Identifier nodes at all, since they are not expressions.
However, for those that come not from source, CodePeer expects that the
Ident_Image routine will convert the internal names like "xL" to their
corresponding human-readable representation like "x'Accesibility_Level".

gcc/ada/

* pprint.adb (Expression_Image): Restore some of the old pretty-printing
for CodePeer.

2 years agoada: Ignore accessibility actuals in expression pretty-printer
Piotr Trojanek [Mon, 13 Feb 2023 21:49:39 +0000 (22:49 +0100)] 
ada: Ignore accessibility actuals in expression pretty-printer

Extra actual parameters for accessibility checks are confusing for the
expression pretty-printer that is used by CodePeer. It seems that nodes
created for the accessibility checks should use the Sloc of the source
expression of accessibility checks, not the target. However, this is
problematic to achieve with the current implementation of accessibility
checks, so with this patch we will simply ignore the accessibility
actuals when computing Slocs for expression pretty-printing.

gcc/ada/

* errout.adb (First_And_Last_Nodes): Ignore accessibility parameters.

2 years agoada: Remove special-case for parentheses in expansion for GNATprove
Piotr Trojanek [Mon, 13 Feb 2023 21:13:32 +0000 (22:13 +0100)] 
ada: Remove special-case for parentheses in expansion for GNATprove

When expanding of inequality operators for GNAT we were adding extra
parens, supposedly to "fix Sprint output" (source print); for GNATprove
we didn't, as these extra parens were leading to wrong columns for check
messages.

Adding these extra parens couldn't be a right, because Sprint should
produce reasonable output regardless of the parens, especially since we
don't care about parens when creating AST in expansion. Avoiding them
for GNATprove couldn't be right either, because source printing should
work regardless of the GNAT/GNATprove mode.

The proper fix for GNAT is rather to not add parens at all and tune
source printing, if necessary. The proper fix for GNATprove is not have
them either, as it confuses the heuristic in First_Sloc, which is then
used by Compute_Sloc.

gcc/ada/

* exp_ch4.adb (Expand_N_Op_Ne): Simply don't add extra parens.

2 years agoada: Transfer fix for pretty-printed parentheses from GNATprove to GNAT
Piotr Trojanek [Sat, 11 Feb 2023 20:09:11 +0000 (21:09 +0100)] 
ada: Transfer fix for pretty-printed parentheses from GNATprove to GNAT

Expressions with parentheses are notoriously problematic to
pretty-print. In GNATprove we had a post-processing fix for them,
but it is better to have this fix in the GNAT frontend repository
and apply it for CodePeer as well.

gcc/ada/

* pprint.adb (Expression_Image): Move Count_Parentheses and
Fix_Parentheses routines from GNATprove and apply them before
returning the slice of a source code buffer.

2 years agoada: Fix expression pretty-printer for SPARK counterexamples
Piotr Trojanek [Fri, 10 Feb 2023 23:43:41 +0000 (00:43 +0100)] 
ada: Fix expression pretty-printer for SPARK counterexamples

The expression pretty-printer that is used for SPARK counterexamples was
essentially duplicating the logic of First_Node/Last_Node and
First_Sloc/Last_Sloc routines. Now it simply reuses those routines.

gcc/ada/

* errout.adb
(Paren_Required): New subsidiary routine for better handling of
parentheses in First_Node/Last_Node.
(First_Sloc, Last_Sloc): Use Get_Source_File_Index to correctly
handle generic instances and inlined subprograms; tune handling of
parentheses; improve handling of literals.
* pprint.adb (Expression_Image): Simplify using
First_Sloc/Last_Sloc.
* sem_ch6.adb (Analyze_Expression_Function): Remove parenthesis
when relocating expression from expression function to simple
return statement.

2 years agoada: Suppress warning about Subprogram_Variant failing at run time
Piotr Trojanek [Wed, 15 Feb 2023 20:20:42 +0000 (21:20 +0100)] 
ada: Suppress warning about Subprogram_Variant failing at run time

Warning about check failing at run time is likely spurious for mutually
recursive subprograms with multiple variant clauses. These will be
non-trivial to detect, so we simply suppress the warning altogether for
all subprogram variants.

gcc/ada/

* exp_prag.adb (Expand_Pragma_Check): Suppress warning for checks of
subprogram variants.

2 years agoada: Small code cleanup
Eric Botcazou [Tue, 14 Feb 2023 16:03:19 +0000 (17:03 +0100)] 
ada: Small code cleanup

This just merges two conditional blocks depending on the same condition.

gcc/ada/

* frontend.adb (Frontend): Merge two conditional blocks and adjust.

2 years agoada: Minor fix typo in comment
Piotr Trojanek [Tue, 14 Feb 2023 12:14:08 +0000 (13:14 +0100)] 
ada: Minor fix typo in comment

Spotted while reviewing a patch with a similar typo.

gcc/ada/

* libgnat/s-mmap.adb (Mapped_Region_Record): Fix typo in comment.

2 years agoada: Remove duplicate comment
Ronan Desplanques [Mon, 13 Feb 2023 10:56:55 +0000 (11:56 +0100)] 
ada: Remove duplicate comment

gcc/ada/

* sem_ch7.adb: Remove duplicate comment.

2 years agoada: Crash on dispatching primitive referencing limited-with type
Javier Miranda [Sun, 12 Feb 2023 13:37:39 +0000 (13:37 +0000)] 
ada: Crash on dispatching primitive referencing limited-with type

The compiler crashes processing a compilation unit has limited-with
context clauses, and the profile of some dispatching primitive
references a type visible through a limited-with clause, and
the dispatching primitive has class-wide preconditions.

gcc/ada/

* sem_ch10.adb
(Analyze_Required_Limited_With_Units): New subprogram.
(Depends_On_Limited_Views): New subprogram.
(Has_Limited_With_Clauses): New subprogram.
(Analyze_Compilation_Unit): Call the new subprogram that performs
the full analysis of required limited-with units.

2 years agolibstdc++: Add missing constexpr to simd
Matthias Kretz [Thu, 23 Mar 2023 08:32:58 +0000 (09:32 +0100)] 
libstdc++: Add missing constexpr to simd

The constexpr API is only available with -std=gnu++XX (and proposed for
C++26). The proposal is to have the complete simd API usable in constant
expressions.

This patch resolves several issues with using simd in constant
expressions.

Issues why constant_evaluated branches are necessary:
* subscripting vector builtins is not allowed in constant expressions
* if the implementation needs/uses memcpy
* if the implementation would otherwise call SIMD intrinsics/builtins

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/109261
* include/experimental/bits/simd.h (_SimdWrapper::_M_set):
Avoid vector builtin subscripting in constant expressions.
(resizing_simd_cast): Avoid memcpy if constant_evaluated.
(const_where_expression, where_expression, where)
(__extract_part, simd_mask, _SimdIntOperators, simd): Add either
_GLIBCXX_SIMD_CONSTEXPR (on public APIs), or constexpr (on
internal APIs).
* include/experimental/bits/simd_builtin.h (__vector_permute)
(__vector_shuffle, __extract_part, _GnuTraits::_SimdCastType1)
(_GnuTraits::_SimdCastType2, _SimdImplBuiltin)
(_MaskImplBuiltin::_S_store): Add constexpr.
(_CommonImplBuiltin::_S_store_bool_array)
(_SimdImplBuiltin::_S_load, _SimdImplBuiltin::_S_store)
(_SimdImplBuiltin::_S_reduce, _MaskImplBuiltin::_S_load): Add
constant_evaluated case.
* include/experimental/bits/simd_fixed_size.h
(_S_masked_load): Reword comment.
(__tuple_element_meta, __make_meta, _SimdTuple::_M_apply_r)
(_SimdTuple::_M_subscript_read, _SimdTuple::_M_subscript_write)
(__make_simd_tuple, __optimize_simd_tuple, __extract_part)
(__autocvt_to_simd, _Fixed::__traits::_SimdBase)
(_Fixed::__traits::_SimdCastType, _SimdImplFixedSize): Add
constexpr.
(_SimdTuple::operator[], _M_set): Add constexpr and add
constant_evaluated case.
(_MaskImplFixedSize::_S_load): Add constant_evaluated case.
* include/experimental/bits/simd_scalar.h: Add constexpr.

* include/experimental/bits/simd_x86.h (_CommonImplX86): Add
constexpr and add constant_evaluated case.
(_SimdImplX86::_S_equal_to, _S_not_equal_to, _S_less)
(_S_less_equal): Value-initialize to satisfy constexpr
evaluation.
(_MaskImplX86::_S_load): Add constant_evaluated case.
(_MaskImplX86::_S_store): Add constexpr and constant_evaluated
case. Value-initialize local variables.
(_MaskImplX86::_S_logical_and, _S_logical_or, _S_bit_not)
(_S_bit_and, _S_bit_or, _S_bit_xor): Add constant_evaluated
case.
* testsuite/experimental/simd/pr109261_constexpr_simd.cc: New
test.

2 years agoUse delete[] in int_range destructor [PR109920]
Aldy Hernandez [Mon, 22 May 2023 19:03:05 +0000 (21:03 +0200)] 
Use delete[] in int_range destructor [PR109920]

gcc/ChangeLog:

PR tree-optimization/109920
* value-range.h (RESIZABLE>::~int_range): Use delete[].

2 years agoFortran: Fix assumed length chars and len inquiry [PR103716]
Paul Thomas [Tue, 23 May 2023 05:46:37 +0000 (06:46 +0100)] 
Fortran: Fix assumed length chars and len inquiry [PR103716]

2023-05-23  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/103716
* resolve.cc (gfc_resolve_ref): Conversion of array_ref into an
element should be done for all characters without a len expr,
not just deferred lens, and for integer expressions.
* trans-expr.cc (conv_inquiry): For len and kind inquiry refs,
set the se string_length to NULL_TREE.

gcc/testsuite/
PR fortran/103716
* gfortran.dg/pr103716.f90 : New test.

2 years agoFortran: Allow declaration of finalizable DT in a submodule [PR97122]
Paul Thomas [Tue, 23 May 2023 05:33:44 +0000 (06:33 +0100)] 
Fortran: Allow declaration of finalizable DT in a submodule [PR97122]

2023-05-23  Paul Thomas  <pault@gcc.gnu.org>
    Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran
PR fortran/97122
* decl.cc (variable_decl): Clean up white space issues.
(gfc_match_final_decl): Declaration of finalizable derived type
is allowed in a submodule.

gcc/testsuite/
PR fortran/97122
* gfortran.dg/finalize_8.f03 : Replace testcase that checks
declaration of finalizable derived types in submodules works.

2 years agoDaily bump.
GCC Administrator [Tue, 23 May 2023 00:17:11 +0000 (00:17 +0000)] 
Daily bump.

2 years agolibobjc: Add local macros to support encode generation [P109913].
Iain Sandoe [Mon, 22 May 2023 19:15:36 +0000 (20:15 +0100)] 
libobjc: Add local macros to support encode generation [P109913].

r14-976-g9907413a3a6aa3 alters code to use the preferred _P-style
macros rather than direct comparisons of (for example) tree codes.

In the context of libobjc this does not work, since we do not include
the relevant headers; the encoding implementation contains a local
emulation of the target type layouts.

The fix here provides relevant macros local to the use.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR libobjc/109913

libobjc/ChangeLog:

* encoding.c (RECORD_OR_UNION_TYPE_P, VECTOR_TYPE_P): New.

Co-authored-by: Andrew Pinski <apinski@marvell.com>
2 years agoi386: Adjust emulated integer vector mode shift costs
Uros Bizjak [Mon, 22 May 2023 20:37:14 +0000 (22:37 +0200)] 
i386: Adjust emulated integer vector mode shift costs

Returned integer vector mode costs of emulated instructions in
ix86_shift_rotate_cost are wrong and do not reflect generated
instruction sequences.  Rewrite handling of different integer vector
modes and different target ABIs to return real instruction
counts in order to calcuate better costs of various emulated modes.

Also add the cost of a memory read, when the instruction in the
sequence reads memory.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_shift_rotate_cost): Correct
calcuation of integer vector mode costs to reflect generated
instruction sequences of different integer vector modes and
different target ABIs.  Remove "speed" function argument.
(ix86_rtx_costs): Update call for removed function argument.
(ix86_vector_costs::add_stmt_cost): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/sse2-shiftqihi-constant-1.c: Remove XFAILs.

2 years agoImplement some miscellaneous zero accessors for Value_Range.
Aldy Hernandez [Mon, 22 May 2023 18:15:19 +0000 (20:15 +0200)] 
Implement some miscellaneous zero accessors for Value_Range.

This adds some missing accessors to the type agnostic Value_Range
class.  They'll be used in the upcoming IPA work.

gcc/ChangeLog:

* value-range.h (class Value_Range): Implement set_zero,
set_nonzero, and nonzero_p.

2 years agotestsuite/52641: Fix more of implicit int=32 assumption fallout.
Georg-Johann Lay [Mon, 22 May 2023 18:14:51 +0000 (20:14 +0200)] 
testsuite/52641: Fix more of implicit int=32 assumption fallout.

gcc/testsuite/
PR testsuite/52641
* gcc.c-torture/compile/pr108892.c: Require int32.
* gcc.c-torture/compile/pr98199.c: Require int32plus.
* gcc.dg/analyzer/call-summaries-pr107072.c: Same.
* gcc.dg/analyzer/null-deref-pr105755.c: Same.
* gcc.dg/tree-ssa/pr102232.c: Same.
* gcc.dg/tree-ssa/pr105860.c: Same.
* gcc.dg/tree-ssa/pr96730.c: Same.
* gcc.dg/tree-ssa/pr96779-disabled.c: Same.
* gcc.dg/tree-ssa/pr96779.c: Same.
* gcc.dg/tree-ssa/pr98513.c: Same.
* gcc.dg/tree-ssa/ssa-sink-18.c
* gcc.dg/analyzer/coreutils-cksum-pr108664.c: Require int32plus,
size24plus.
* gcc.dg/analyzer/doom-s_sound-pr108867.c: Require size32plus.
* gcc.dg/analyzer/malloc-CWE-590-examples.c: Same.
* gcc.dg/debug/btf/btf-bitfields-4.c: Same.
* gcc.dg/tree-ssa/pr93435.c: Same.
* gcc.dg/analyzer/null-deref-pr102671-1.c: Require ptr_eq_long:
* gcc.dg/analyzer/null-deref-pr102671-2.c: Same.
* gcc.dg/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c:
Same.
* gcc.dg/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
Same.
* gcc.dg/tree-ssa/pr103345.c: Use uint32_t.
* gcc.dg/tree-ssa/ssa-ccp-41.c [sizeof(int)==2]: Same.
* gcc.dg/tree-ssa/pr109031-1.c: Use uint16_t, uint32_t.
* gcc.dg/tree-ssa/pr109031-2.c: Same.
* gcc.dg/Warray-bounds-49.c (dg-warning): Discriminate int != short.
* gcc.dg/Warray-bounds-52.c (dg-warning): Discriminate avr.
* gcc.dg/Warray-bounds-33.c: Skip target avr.
* gcc.dg/analyzer/fd-access-mode-target-headers.c: Same.
* gcc.dg/analyzer/flex-with-call-summaries.c: Same.
* gcc.dg/analyzer/isatty-1.c: Same.
* gcc.dg/analyzer/pipe-glibc.c: Same.

2 years agolibstdc++: Resolve -Wunused-variable warnings in stdx::simd and tests
Matthias Kretz [Mon, 22 May 2023 14:58:30 +0000 (16:58 +0200)] 
libstdc++: Resolve -Wunused-variable warnings in stdx::simd and tests

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd_builtin.h (_S_fpclassify): Move
__infn into #ifdef'ed block.
* testsuite/experimental/simd/tests/fpclassify.cc: Declare
constants only when used.
* testsuite/experimental/simd/tests/frexp.cc: Likewise.
* testsuite/experimental/simd/tests/logarithm.cc: Likewise.
* testsuite/experimental/simd/tests/trunc_ceil_floor.cc:
Likewise.
* testsuite/experimental/simd/tests/ldexp_scalbn_scalbln_modf.cc:
Move totest and expect1 into #ifdef'ed block.

2 years agotestsuite/52641: Fix tests that fail for 16-bit int / pointer targets.
Georg-Johann Lay [Mon, 22 May 2023 14:47:56 +0000 (16:47 +0200)] 
testsuite/52641: Fix tests that fail for 16-bit int / pointer targets.

gcc/testsuite/
PR testsuite/52641
* c-c++-common/pr19807-2.c: Use __SIZEOF_INT__ instead of 4.
* gcc.c-torture/compile/pr103813.c: Require size32plus.
* gcc.c-torture/execute/pr108498-2.c: Same.
* gcc.c-torture/compile/pr96426.c: Condition on
__SIZEOF_LONG_LONG__ == __SIZEOF_DOUBLE__.
* gcc.c-torture/execute/pr103417.c: Require int32plus.
* gcc.dg/pr104198.c: Same.
* gcc.dg/pr21137.c: Same.
* gcc.dg/pr88905.c: Same.
* gcc.dg/pr90838.c: Same.
* gcc.dg/pr97317.c: Same.
* gcc.dg/pr100292.c: Require int32.
* gcc.dg/pr101008.c: Same.
* gcc.dg/pr96542.c: Same.
* gcc.dg/pr96674.c: Same.
* gcc.dg/pr97750.c: Require ptr_eq_long.

2 years agoi386: Account for the memory read in V*QImode multiplication sequences
Uros Bizjak [Mon, 22 May 2023 14:31:41 +0000 (16:31 +0200)] 
i386: Account for the memory read in V*QImode multiplication sequences

Add the cost of a memory read to the cost of V*QImode vector mult sequences.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_multiplication_cost): Add
the cost of a memory read to the cost of V?QImode sequences.

2 years agoSkip some tests that won't work for target AVR.
Georg-Johann Lay [Mon, 22 May 2023 14:21:58 +0000 (16:21 +0200)] 
Skip some tests that won't work for target AVR.

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_lra) [avr]: Return 0.
* gcc.dg/pr19402-2.c: Skip for avr.
* gcc.dg/pr86124.c: Same.
* gcc.dg/pr94291.c: Same.
* gcc.dg/torture/builtin-complex-1.c: Same.
* gcc.dg/torture/fp-int-convert-float32x-timode.c: Same.
* gcc.dg/torture/fp-int-convert-float32x.c: Same.
* gcc.dg/torture/fp-int-convert-float64-timode.c: Same.
* gcc.dg/torture/fp-int-convert-float64.c: Same.
* gcc.dg/torture/fp-int-convert-long-double.c: Same.
* gcc.dg/torture/fp-int-convert-timode.c: Same.
* c-c++-common/torture/builtin-convertvector-1.c: Same.
* c-c++-common/torture/complex-sign-add.c: Same.
* c-c++-common/torture/complex-sign-mixed-add.c: Same.
* c-c++-common/torture/complex-sign-mixed-div.c: Same.
* c-c++-common/torture/complex-sign-mixed-mul.c: Same.
* c-c++-common/torture/complex-sign-mixed-sub.c: Same.
* c-c++-common/torture/complex-sign-mul-minus-one.c: Same.
* c-c++-common/torture/complex-sign-mul-one.c: Same.
* c-c++-common/torture/complex-sign-mul.c: Same.
* c-c++-common/torture/complex-sign-sub.c: Same.

2 years agoRISC-V: Add "m_" prefix for private member
Juzhe-Zhong [Mon, 22 May 2023 14:05:18 +0000 (22:05 +0800)] 
RISC-V: Add "m_" prefix for private member

Since the current framework is hard to maintain and
hard to be used in the future possible auto-vectorization patterns.

We will need to keep adding more helpers and arguments during the
auto-vectorization supporting. We should refactor the framework
now for the future use since the we don't support too much
auto-vectorization
patterns for now.

Start with this simple patch, this patch is adding "m_" prefix for
private the members.

gcc/ChangeLog:

* config/riscv/riscv-v.cc: Add "m_" prefix.

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
2 years agoRISC-V: Fix typo of multiple_rgroup-2.h
Juzhe-Zhong [Mon, 22 May 2023 10:38:26 +0000 (18:38 +0800)] 
RISC-V: Fix typo of multiple_rgroup-2.h

Just notice this following fail in the regression:
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-2.c (test for
excess errors)
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c (test
for excess errors)

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-2.h: Fix
typo

2 years agoada: Reuse idiomatic procedure in CStand
Ronan Desplanques [Thu, 9 Feb 2023 22:00:41 +0000 (23:00 +0100)] 
ada: Reuse idiomatic procedure in CStand

This change replaces a call to Set_Name_Entity_Id with a call to
the higher-level Set_Current_Entity.

gcc/ada/

* cstand.adb: Use more idiomatic procedure.

2 years agoada: Avoid repeated calls when looking for first/last slocs of a node
Piotr Trojanek [Thu, 9 Feb 2023 18:20:14 +0000 (19:20 +0100)] 
ada: Avoid repeated calls when looking for first/last slocs of a node

gcc/ada/

* errout.adb (First_Loc): Avoid repeated calls.
(Last_Loc): Likewise.

2 years agoada: Small cleanup in support for protected subprograms
Eric Botcazou [Fri, 10 Feb 2023 18:07:33 +0000 (19:07 +0100)] 
ada: Small cleanup in support for protected subprograms

This moves the propagation of the Uses_Sec_Stack flag, from the original to
the rewritten subprogram, to the point where the latter is expanded, along
with the propagation of the Has_Nested_Subprogram flag, as well as addresses
a ??? comment in the same block of code.  No functional changes.

gcc/ada/

* inline.adb (Cleanup_Scopes): Do not propagate the Uses_Sec_Stack
flag from original to rewritten protected subprograms here...
* exp_ch9.adb (Expand_N_Protected_Body) <N_Subprogram_Body>:
...but here instead. Add local variables and remove a useless
test.

2 years agoada: Use idiomatic construct in Expand_N_Package_Body
Eric Botcazou [Fri, 10 Feb 2023 10:15:15 +0000 (11:15 +0100)] 
ada: Use idiomatic construct in Expand_N_Package_Body

gcc/ada/

* exp_ch7.adb (Expand_N_Package_Body): Call Defining_Entity to get
the entity of the body.

2 years agoada: Fix source location for crashes in expanded Loop_Entry attributes
Piotr Trojanek [Fri, 10 Feb 2023 15:28:41 +0000 (16:28 +0100)] 
ada: Fix source location for crashes in expanded Loop_Entry attributes

Historically, Loop_Entry attributes were expanded while expanding their
corresponding loops, so it was easier to use location of these loops for
expanded code. Now, these attributes are expanded where they appear, so
we can easily use the location of the attribute reference for expanded
code.

This matters when there is a crash in the expanded code, e.g. because of
a stack overflow in the declaration of an constant object that captures
the Loop_Entry prefix. Now backtrace will point to the source location
of the attribute, which is more helpful than the location of the loop.

gcc/ada/

* exp_attr.adb (Expand_Loop_Entry_Attribute): Use location of the
attribute reference, not of the loop statement.

2 years agoada: Add missing word in comment
Ronan Desplanques [Thu, 9 Feb 2023 09:34:11 +0000 (10:34 +0100)] 
ada: Add missing word in comment

gcc/ada/

* par-ch3.adb: Add missing word in comment.

2 years agoada: Incorrect constant folding in postcondition involving 'Old
Justin Squirek [Thu, 9 Feb 2023 17:00:46 +0000 (17:00 +0000)] 
ada: Incorrect constant folding in postcondition involving 'Old

The following patch fixes an issue in the compiler whereby certain flavors of
access comparisons may be incorrectly constant-folded out of contract
expressions - notably in postcondition expressions featuring a reference to
'Old.

gcc/ada/

* checks.adb (Install_Null_Excluding_Check): Avoid non-null
optimizations when assertions are enabled.

2 years agoada: Fix crash caused by incorrect expansion of iterated component
Marc Poulhiès [Thu, 9 Feb 2023 08:36:14 +0000 (09:36 +0100)] 
ada: Fix crash caused by incorrect expansion of iterated component

The way iterated component are expanded could lead to inconsistent tree.

This change fixes 2 issues:

- in an early step during Pre_Analyze, the loop variable still has
Any_Type and the compiler must not emit an error. A later full Analyze
is supposed to correctly set the Etype, and only then should the
compiler emit an error if Any_Type is still used.

- when expanding into a loop with assignments statement, the expression
is analyzed in an early context (where the loop variable still has
Any_Type Etype) and then copied. The compiler would crash because this
Any_Type is never changed because the expression node has its Analyzed
flag set. Resetting the flag ensures the later Analyze call also
analyzes these nodes and set Etype correctly.

gcc/ada/

* exp_aggr.adb (Process_Transient_Component): Reset Analyzed flag
for the copy of the initialization expression.
* sem_attr.adb (Validate_Non_Static_Attribute_Function_Call): Skip
error emission during Pre_Analyze.

2 years agoada: Fix missing finalization in separate package body
Eric Botcazou [Thu, 9 Feb 2023 15:05:16 +0000 (16:05 +0100)] 
ada: Fix missing finalization in separate package body

This directly comes from a loophole in the implementation.

gcc/ada/

* exp_ch7.adb (Process_Package_Body): New procedure taken from...
(Build_Finalizer.Process_Declarations): ...here.  Call the above
procedure to deal with both package bodies and package body stubs.

2 years agoada: Remove outdated part of comment
Ronan Desplanques [Thu, 9 Feb 2023 13:07:01 +0000 (14:07 +0100)] 
ada: Remove outdated part of comment

The concept of extended nodes was retired with the introduction of
variable-sized node types, but a reference to that concept was left
over in a comment. This change removes that reference.

gcc/ada/

* atree.ads: Remove outdated part of comment.

2 years agoada: Fix missing finalization in library-unit instance spec
Eric Botcazou [Wed, 8 Feb 2023 21:16:23 +0000 (22:16 +0100)] 
ada: Fix missing finalization in library-unit instance spec

This fixes the missing finalization of objects declared in the spec of
package instances that are library units (and only them, i.e. not all
library-level package instances) when the instances have a package body.

The finalization is done when there is no package body, and supporting
this case precisely broke the other case because of a thinko or a typo.

This also requires a small adjustment to the routine writing ALI files.

gcc/ada/

* exp_ch7.adb (Build_Finalizer): Reverse the test comparing the
instantiation and declaration nodes of a package instance, and
therefore bail out only when they are equal.  Adjust comments.
(Expand_N_Package_Declaration): Do not clear the Finalizer field.
* lib-writ.adb: Add with and use clauses for Sem_Util.
(Write_Unit_Information): Look at unit nodes to find finalizers.
* sem_ch12.adb (Analyze_Package_Instantiation): Beef up the comment
about the rewriting of the instantiation node into a declaration.

2 years agoada: Rename Is_Past_Self_Hiding_Point flag to be Is_Not_Self_Hidden
Bob Duff [Wed, 8 Feb 2023 16:46:10 +0000 (11:46 -0500)] 
ada: Rename Is_Past_Self_Hiding_Point flag to be Is_Not_Self_Hidden

...which seems clearer.

Still work in progress.

gcc/ada/

* cstand.adb (Is_Past_Self_Hiding_Point): Rename to be
Is_Not_Self_Hidden.
* einfo.ads: Likewise.
* exp_aggr.adb: Likewise.
* gen_il-fields.ads: Likewise.
* gen_il-gen-gen_entities.adb: Likewise.
* sem.adb: Likewise.
* sem_aggr.adb: Likewise.
* sem_ch11.adb: Likewise.
* sem_ch12.adb: Likewise.
* sem_ch5.adb: Likewise.
* sem_ch6.adb: Likewise.
* sem_ch7.adb: Likewise.
* sem_prag.adb: Likewise.

2 years agoada: Fix spurious freezing error on nonabstract null extension
Eric Botcazou [Wed, 8 Feb 2023 15:26:46 +0000 (16:26 +0100)] 
ada: Fix spurious freezing error on nonabstract null extension

This prevents the wrapper function created for each nonoverridden inherited
function with a controlling result of nonabstract null extensions of tagged
types from causing premature freezing of types referenced in its profile.

gcc/ada/

* exp_ch3.adb (Make_Controlling_Function_Wrappers): Create the body
as the expanded body of an expression function.

2 years agoada: Further fixes to GNATprove and CodePeer expression pretty-printer
Piotr Trojanek [Tue, 7 Feb 2023 20:36:36 +0000 (21:36 +0100)] 
ada: Further fixes to GNATprove and CodePeer expression pretty-printer

The expression pretty-printer still crashes on several tests, but
already gives much better outputs for many previously unsupported
constructs.

gcc/ada/

* pprint.adb (Expression_Image): Handle several previously unsupported
constructs.

2 years agoada: Cleanup redundant condition in resolution of entity names
Piotr Trojanek [Mon, 6 Feb 2023 21:56:49 +0000 (22:56 +0100)] 
ada: Cleanup redundant condition in resolution of entity names

Code cleanup related to new contract for SPARK; semantics is unaffected.

gcc/ada/

* sem_res.adb (Resolve_Entity_Name): Combine two IF statements that
execute code only for references that come from source.

2 years agoada: Add Is_Past_Self_Hiding_Point flag
Bob Duff [Mon, 6 Feb 2023 16:58:52 +0000 (11:58 -0500)] 
ada: Add Is_Past_Self_Hiding_Point flag

This patch adds a flag Is_Past_Self_Hiding_Point. When False,
this will replace E_Void as the indicator for a premature use of
a declaration within itself -- for example, "X : T := X;".

One might think this flag should be called something like
Is_Hidden_From_All_Visibility, reversing the sense of
Is_Past_Self_Hiding_Point. We don't do that because we want
Is_Past_Self_Hiding_Point to be initially False by default (and we have
no mechanism for defaulting to True), and because it doesn't exactly
match the RM definition of "hidden from all visibility" (for
example, for record components).

This is work in progress; more changes are needed before we
can remove all Mutate_Ekind(..., E_Void).

gcc/ada/

* einfo.ads (Is_Past_Self_Hiding_Point): Document.
* gen_il-fields.ads (Is_Past_Self_Hiding_Point): Add to list of
fields.
* gen_il-gen-gen_entities.adb (Is_Past_Self_Hiding_Point): Declare
in all entities.
* exp_aggr.adb: Set Is_Past_Self_Hiding_Point as appropriate.
* sem.adb: Likewise.
* sem_aggr.adb: Likewise.
* sem_ch11.adb: Likewise.
* sem_ch12.adb: Likewise.
* sem_ch5.adb: Likewise.
* sem_ch7.adb: Likewise.
* sem_prag.adb: Likewise.
* sem_ch6.adb: Likewise.
(Set_Formal_Mode): Minor cleanup: Move from spec.
* sem_ch6.ads:
(Set_Formal_Mode): Minor cleanup: Move to body.
* cstand.adb: Call Set_Is_Past_Self_Hiding_Point on all entities
as soon as they are created.
* comperr.adb (Compiler_Abort): Minor cleanup -- use 'in' instead
of 'or else'.
* debug.adb: Minor comment cleanups.

2 years agoada: Accept Assert pragmas in expression functions
Steve Baird [Fri, 3 Feb 2023 01:33:53 +0000 (17:33 -0800)] 
ada: Accept Assert pragmas in expression functions

gcc/ada/

* sem_ch4.adb (Analyze_Expression_With_Actions.Check_Action_Ok):
Accept an executable pragma occuring in a declare expression as
per AI22-0045. This means Assert and Inspection_Point pragmas as
well as any implementation-defined pragmas that the implementation
chooses to categorize as executable. Currently Assume and Debug
are the only such pragmas.

2 years agoada: Add warning on frontend inlining of Subprogram_Variant
Piotr Trojanek [Mon, 6 Feb 2023 13:45:22 +0000 (14:45 +0100)] 
ada: Add warning on frontend inlining of Subprogram_Variant

We already warned when contracts like pre/postcondition appear together
with pragma Inline_Always and they are ignored by the frontend inlining.

For consistency we now also warn for Subprogram_Variant, which is
similarly ignored even though this contract is only meaningful for
recursive subprograms and those can't be inlined anyway (but error about
this might only be emitted when full compilation is done).

gcc/ada/

* sem_prag.adb
(Check_Postcondition_Use_In_Inlined_Subprogram): Mention
Subprogram_Variant in the comment.
(Analyze_Subprogram_Variant_In_Decl_Part): Warn when contract is
ignored because of pragma Inline_Always and frontend inlining.

2 years agoada: Fix spurious warning on Inline_Always and contracts
Piotr Trojanek [Mon, 6 Feb 2023 13:40:26 +0000 (14:40 +0100)] 
ada: Fix spurious warning on Inline_Always and contracts

Warnings about pre/postconditions being ignored with Inline_Always were
only true for the obsolete frontend inlining. With the current backend
pre/postconditions work fine with Inline_Always.

gcc/ada/

* sem_prag.adb (Check_Postcondition_Use_In_Inlined_Subprogram): Only
emit warning when frontend inlining is enabled.

2 years agoada: Improve -gnatyx style check
Arnaud Charlet [Mon, 6 Feb 2023 08:50:42 +0000 (08:50 +0000)] 
ada: Improve -gnatyx style check

Check redundant parentheses in many more places, for now only under
-gnatdQ, while pending violations are fixed.

gcc/ada/

* par-ch3.adb, sem_ch4.adb (P_Discrete_Range, Analyze_Logical_Op,
Analyze_Short_Circuit): Add calls to Check_Xtra_Parentheses.
* par-ch5.adb (P_Condition): Move logic to Check_Xtra_Parentheses.
* style.ads, styleg.adb, styleg.ads (Check_Xtra_Parens): Move logic
related to expressions requiring parentheses here.

2 years agoada: Remove extra parentheses
Arnaud Charlet [Fri, 3 Feb 2023 11:07:24 +0000 (11:07 +0000)] 
ada: Remove extra parentheses

In preparation of enhancing -gnatyx to check for these automatically.

gcc/ada/

* ali-util.adb, par-endh.adb, par-prag.adb, par-ch2.adb,
checks.adb, fmap.adb, libgnat/a-nbnbig.ads, libgnat/g-dynhta.adb,
libgnat/s-carun8.adb, libgnat/s-strcom.adb, libgnat/a-dhfina.adb,
libgnat/a-direct.adb, libgnat/a-rbtgbo.adb, libgnat/a-strsea.adb,
libgnat/a-ststio.adb, libgnat/a-suenco.adb, libgnat/a-costso.adb,
libgnat/a-strmap.adb, libgnat/g-alleve.adb,
libgnat/g-debpoo.adb, libgnat/g-sercom__linux.adb,
libgnat/s-genbig.adb, libgnat/s-mmap.adb, libgnat/s-regpat.adb,
par-ch5.adb, sem_case.adb, sem_ch12.adb, sem_ch13.adb,
sem_ch8.adb, sem_eval.adb, sem_prag.adb, sem_type.adb,
exp_ch11.adb, exp_ch2.adb, exp_ch3.adb, exp_ch4.adb, exp_ch5.adb,
exp_ch6.adb, exp_ch9.adb, exp_put_image.adb, freeze.adb, live.adb,
sem_aggr.adb, sem_cat.adb, sem_ch10.adb, sem_ch3.adb, sem_ch6.adb,
sem_ch9.adb, sem_disp.adb, sem_elab.adb, sem_res.adb,
sem_util.adb, sinput.adb, uintp.adb, bcheck.adb, binde.adb,
binderr.adb, einfo-utils.adb, clean.adb, sem_ch4.adb, gnatls.adb,
gprep.adb, sem_ch11.adb: Remove extra parentheses.

2 years agoada: Remove a remaining reference to ?
Arnaud Charlet [Fri, 3 Feb 2023 11:08:35 +0000 (11:08 +0000)] 
ada: Remove a remaining reference to ?

We should no longer use ? anywhere when emitting warnings.

gcc/ada/

* sem_aggr.adb (Get_Value): Use ?? instead of ?.

2 years agoada: Remove redundant protection against empty lists
Piotr Trojanek [Wed, 1 Feb 2023 12:24:43 +0000 (13:24 +0100)] 
ada: Remove redundant protection against empty lists

Calls to List_Length on No_List intentionally return 0 (and likewise
call to First on No_List intentionally return Empty), so explicit guards
against No_List are unnecessary. Code cleanup; semantics is unaffected.

gcc/ada/

* exp_aggr.adb (Aggregate_Size): Remove redundant calls to
Present.
* exp_ch5.adb (Expand_N_If_Statement): Likewise.
* sem_prag.adb (Analyze_Pragma): Likewise.
* sem_warn.adb (Find_Var): Likewise.

2 years agoada: Support calls through dereferences in Find_Actual
Claire Dross [Fri, 3 Feb 2023 15:42:15 +0000 (16:42 +0100)] 
ada: Support calls through dereferences in Find_Actual

Return the corresponding formal in the designated subprogram profile in
that case.

gcc/ada/

* sem_util.adb (Find_Actual): On calls through dereferences,
return the corresponding formal in the designated subprogram
profile.

2 years agoada: Remove unreferenced utility routine Is_Actual_Tagged_Parameter
Piotr Trojanek [Fri, 3 Feb 2023 14:57:28 +0000 (15:57 +0100)] 
ada: Remove unreferenced utility routine Is_Actual_Tagged_Parameter

Routine Is_Actual_Tagged_Parameter was added to detect unsupported SPARK
2005 constructs, but this feature was deconstructed in favor of SPARK
2014 and its SPARK_Mode aspects.

gcc/ada/

* sem_util.ads (Is_Actual_Tagged_Parameter): Remove spec.
* sem_util.adb (Is_Actual_Tagged_Parameter): Remove body.

2 years agoada: Add contracts to Ada.Strings.Unbounded library
Joffrey Huguet [Mon, 16 Jan 2023 15:44:14 +0000 (16:44 +0100)] 
ada: Add contracts to Ada.Strings.Unbounded library

This patch adds contracts to the conversions between
Unbounded_String and String, the Element function and the
equality between two Unbounded_String, or between
Unbounded_String and String.
This patch also disallows the use of a function in SPARK, because
it returns an uninitialized Unbounded_String.

gcc/ada/

* libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads
(To_Unbounded_String): Add postcondition. Add aspect SPARK_Mode
Off on the version that takes a Natural as parameter.
(To_String): Complete postcondition.
(Set_Unbounded_String): Add postcondition.
(Element): Likewise.
("="): Likewise.

2 years agoada: Fix crash on Ada.Containers with No_Dispatching_Calls restriction
Eric Botcazou [Wed, 1 Feb 2023 16:46:17 +0000 (17:46 +0100)] 
ada: Fix crash on Ada.Containers with No_Dispatching_Calls restriction

This makes it so that the compiler does not crash and flags the underlying
violation of the restriction instead.

gcc/ada/

* exp_ch3.adb (Freeze_Type): Do not associate the Finalize_Address
routine for a class-wide type if restriction No_Dispatching_Calls
is in effect.

2 years agoada: Implement conversions from Big_Integer to large types
Eric Botcazou [Wed, 1 Feb 2023 13:15:19 +0000 (14:15 +0100)] 
ada: Implement conversions from Big_Integer to large types

This implements the conversion from Big_Integer to Long_Long_Unsigned on
32-bit platforms and to Long_Long_Long_{Integer,Unsigned} on 64-bit ones.

gcc/ada/

* libgnat/s-genbig.ads (From_Bignum): New overloaded declarations.
* libgnat/s-genbig.adb (LLLI): New subtype.
(LLLI_Is_128): New boolean constant.
(From_Bignum): Change the return type of the signed implementation
to Long_Long_Long_Integer and add support for the case where its
size is 128 bits.  Add a wrapper around it for Long_Long_Integer.
Add an unsigned implementation returning Unsigned_128 and a wrapper
around it for Unsigned_64.
(To_Bignum): Test LLLI_Is_128 instead of its size.
(To_String.Image): Add qualification to calls to From_Bignum.
* libgnat/a-nbnbin.adb (To_Big_Integer): Likewise.
(Signed_Conversions.From_Big_Integer): Likewise.
(Unsigned_Conversions): Likewise.

2 years agoada: Fix error and crash on imported function with precondition and 'Base
Eric Botcazou [Wed, 1 Feb 2023 11:35:08 +0000 (12:35 +0100)] 
ada: Fix error and crash on imported function with precondition and 'Base

This fixes a spurious error on an imported function with a precondition
and a parameter declared with a 'Base formal type, and even a crash in
the case where this function is declared in a generic package.

gcc/ada/

* freeze.adb (Wrap_Imported_Subprogram): Use Copy_Subprogram_Spec
to copy the spec from the subprogram to the generated subprogram
body.
(Freeze_Entity): Do not wrap imported subprograms inside generics.

2 years agoada: Reject illegal declarations in expression functions
Steve Baird [Tue, 31 Jan 2023 01:05:13 +0000 (17:05 -0800)] 
ada: Reject illegal declarations in expression functions

gcc/ada/

* sem_ch4.adb (Analyze_Expression_With_Actions.Check_Action_Ok):
If Comes_From_Source (A) is False, then look at Original_Node (A)
instead of A. In particular, if an (illegal) expression function
is transformed into a "vanilla" function, we don't want to allow
it just because Comes_From_Source is now False.

2 years agoada: Better error message if non-Ada2022 code declares No_Return function
Steve Baird [Mon, 30 Jan 2023 23:41:48 +0000 (15:41 -0800)] 
ada: Better error message if non-Ada2022 code declares No_Return function

When a feature that is legal in Ada2022 but not in earlier Ada versions
is used, we typically want to call Error_Msg_Ada_2022_Feature in order to
generate an informative message in the error case. Specifying No_Return
for a function (as opposed to a procedure) is no exception to this rule.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): In Check_No_Return, call
Error_Msg_Ada_2022_Feature in the case of a function. Remove code
outside of Check_No_Return that was querying Ada_Version.

2 years agoada: Fix double finalization in conditional exit statement
Eric Botcazou [Tue, 31 Jan 2023 15:04:01 +0000 (16:04 +0100)] 
ada: Fix double finalization in conditional exit statement

The temporary is first finalized through its enclosing block.

gcc/ada/

* exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action): Do
not look into nested blocks.

2 years agoada: Fix handling of constrained array declarations in declare-expression
Eric Botcazou [Tue, 31 Jan 2023 13:33:44 +0000 (14:33 +0100)] 
ada: Fix handling of constrained array declarations in declare-expression

They need to go through Constrain_Array or else they do not really work.

gcc/ada/

* sem_ch3.adb (Find_Type_Of_Object): In a spec expression, also set
the Scope of the type, and call Constrain_Array for array subtypes.

2 years agoada: Fix traversal for the rightmost node of a pretty-printed expression
Piotr Trojanek [Tue, 31 Jan 2023 12:45:23 +0000 (13:45 +0100)] 
ada: Fix traversal for the rightmost node of a pretty-printed expression

When getting the rightmost node of a pretty-printed expression we
incorrectly traversed some composite nodes, which caused the expression
image to be chopped.

gcc/ada/

* pprint.adb (Expression_Image): Reduce scope of local variables; inline
local uncommented constant From_Source; concatenate string with a single
character, as it is likely to execute faster; add missing cases to
traversal for the rightmost node and assertion to demonstrate that the
??? comment is no longer relevant.

2 years agoada: Restrict expression pretty-printer to subexpressions
Piotr Trojanek [Mon, 30 Jan 2023 11:21:24 +0000 (12:21 +0100)] 
ada: Restrict expression pretty-printer to subexpressions

When pretty-printing expressions with a CASE alternatives we can qualify
the call to Nkind using N_Subexpr, so that we will get compile-time
errors when new node kinds are added (e.g. Ada 2022 case expressions).

gcc/ada/

* pprint.adb (Expr_Name): Qualify CASE expression with N_Subexpr; add
missing alternative for N_Raise_Storage_Error; remove dead alternatives;
explicitly list unsupported alternatives.

2 years agoada: Don't pretty-print DEL within expression images
Piotr Trojanek [Mon, 30 Jan 2023 10:28:55 +0000 (11:28 +0100)] 
ada: Don't pretty-print DEL within expression images

When printing expression images, e.g. for GNATprove counterexamples,
it seems better to print DEL not directly but with its numeric code.

gcc/ada/

* pprint.adb (Expr_Name): Exclude DEL from printable range.

2 years agoada: Update Controlling_Argument when copying trees
Piotr Trojanek [Fri, 27 Jan 2023 11:37:25 +0000 (12:37 +0100)] 
ada: Update Controlling_Argument when copying trees

When copying the AST we need to update fields that carry semantic
meaning and not just copy them. We already updated some of them,
e.g. the First/Next_Named_Association chain, but failed to update
the Controlling_Argument.

This fix doesn't appear to change anything for the compiler, but it is
needed for GNATprove, where we no longer want to expand expression
functions and instead we want to copy their preanalyzed expressions.

gcc/ada/

* sem_util.ads (New_Copy_Tree): Update comment.
* sem_util.adb (New_Copy_Tree): Update Controlling_Argument, very
much like we update the First/Next_Named_Association.

2 years agoada: update Ada_Version_Type in fe.h to match opt.ads
Bob Duff [Mon, 30 Jan 2023 21:56:08 +0000 (16:56 -0500)] 
ada: update Ada_Version_Type in fe.h to match opt.ads

Remove Ada_With_Extensions, which is not used on the C side.
Do not add Ada_With_Core_Extensions and Ada_With_All_Extensions,
which are also not used on the C side, and on the Ada side
are always used via functions All_Extensions_Allowed and
Core_Extensions_Allowed. Explain this in comments.

Move the functions closer to the type declaration,
so the usage style is clearer.

Cleanup only -- no change in compiler behavior.

gcc/ada/

* fe.h: Remove Ada_With_Extensions and add commentary.
* opt.ads: Rearrange code and add commentary.

2 years agoada: prevent infinite recursion in Collect_Types_In_Hierarchy
Bob Duff [Mon, 30 Jan 2023 16:25:08 +0000 (11:25 -0500)] 
ada: prevent infinite recursion in Collect_Types_In_Hierarchy

In (illegal) mutually-dependent type declarations, it is possible for
Etype (Etype (Typ)) to point back to Typ. This patch stops the recursion
in such cases.

gcc/ada/

* sem_util.adb (Process_Type): Stop the recursion.
* exp_aggr.adb (Build_Record_Aggr_Code): Add assertion.

2 years agoVECT: Fix bug of multiple-rgroup for length is counting elements
Ju-Zhe Zhong [Mon, 22 May 2023 08:35:37 +0000 (16:35 +0800)] 
VECT: Fix bug of multiple-rgroup for length is counting elements

Address comments from Richard that splits the patch of fixing
multiple-rgroup
handling of length counting elements.

This patch is fixing issue of handling multiple-rgroup of length is
counting elements

Before this patch, multiple rgroup run fail:
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c
execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c
execution test

After this patch, These tests are all passed.

gcc/ChangeLog:

* tree-vect-loop.cc (vect_get_loop_len): Fix issue for
multiple-rgroup of length.
* tree-vect-stmts.cc (vectorizable_store): Ditto.
(vectorizable_load): Ditto.
* tree-vectorizer.h (vect_get_loop_len): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-1.c: New
test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-1.h: New
test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-2.c: New
test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-2.h: New
test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c:
New test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c:
New test.

2 years agoRISC-V: Reorganize the code of CONST_VECTOR handling in riscv.cc
Juzhe-Zhong [Mon, 22 May 2023 07:42:18 +0000 (15:42 +0800)] 
RISC-V: Reorganize the code of CONST_VECTOR handling in riscv.cc

Since satisfies_constraint_vi (x) belongs to RVV region.
We make this condition inside riscv_v_ext_vector_mode_p to make codes
more reasonable.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_const_insns): Reorganize the
codes.

2 years agovect: Refactor code for index == count in vect_transform_slp_perm_load_1
Kewen Lin [Mon, 22 May 2023 02:19:02 +0000 (21:19 -0500)] 
vect: Refactor code for index == count in vect_transform_slp_perm_load_1

This patch is to refactor the handlings for the case (index
== count) in a loop of vect_transform_slp_perm_load_1, in
order to prepare a subsequent adjustment on *nperm.  This
patch doesn't have any functional changes.

Basically this is to rewrite two if below:

  if (index == count && !noop_p)
    {
       // A ...
       // ++*n_perms;
    }

  if (index == count)
    {
       if (!analyze_only)
 {
    if (!noop_p)
       // B1 ...

    // B2 ...

    for ...
      {
 if (!noop_p)
    // B3 building VEC_PERM_EXPR
 else
    // B4 building nothing (no uses for B2 and its seq)
      }
 }
       // B5
    }

into one hunk below:

  if (index == count)
    {
       if (!noop_p)
 {
   // A ...
   // ++*n_perms;

   if (!analyze_only)
     {
// B1 ...
// B2 ...
for ...
   // B3 building VEC_PERM_EXPR
     }
 }
       else if (!analyze_only)
 {
    // no B2 since no any further uses here.
    for ...
      // B4 building nothing
 }
// B5 ...
    }

gcc/ChangeLog:

* tree-vect-slp.cc (vect_transform_slp_perm_load_1): Refactor the
handling for the case index == count.

2 years agoDaily bump.
GCC Administrator [Mon, 22 May 2023 00:17:09 +0000 (00:17 +0000)] 
Daily bump.

2 years agolibgomp: Honor OpenMP's nteams-var ICV as upper limit on num teams [PR109875]
Tobias Burnus [Sun, 21 May 2023 18:36:19 +0000 (20:36 +0200)] 
libgomp: Honor OpenMP's nteams-var ICV as upper limit on num teams [PR109875]

The nteams-var ICV exists per device and can be set either via the routine
omp_set_num_teams or as environment variable (OMP_NUM_TEAMS with optional
_ALL/_DEV/_DEV_<num> suffix); it is default-initialized to zero. The number
of teams created is described under the num_teams clause. If the clause is
absent, the number of teams is implementation defined but at least
one team must exist and, if nteams-var is positive, at most nteams-var
teams may exist.

The latter condition was not honored in a target region before this
commit, such that too many teams were created.

Already before this commit, both the num_teams([lower:]upper) clause
(on the host and in target regions) and, only on the host, the nteams-var
ICV were honored. And as only one teams is created for host fallback,
unless the clause specifies otherwise, the nteams-var ICV was and is
effectively honored.

libgomp/ChangeLog:

PR libgomp/109875
* config/gcn/target.c (GOMP_teams4): Honor nteams-var ICV.
* config/nvptx/target.c (GOMP_teams4): Likewise.
* testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c: New test.
* testsuite/libgomp.c-c++-common/teams-nteams-icv-2.c: New test.
* testsuite/libgomp.c-c++-common/teams-nteams-icv-3.c: New test.
* testsuite/libgomp.c-c++-common/teams-nteams-icv-4.c: New test.

2 years agotarget/90622: __builtin_avr_insert bits: Use BLD/BST for one bit in place.
Georg-Johann Lay [Sun, 21 May 2023 16:54:21 +0000 (18:54 +0200)] 
target/90622: __builtin_avr_insert bits: Use BLD/BST for one bit in place.

If just one bit is inserted in the same position like with:
    __builtin_avr_insert_bits (0xFFFFF2FF, src, dst);
a BLD/BST sequence is better than XOR/AND/XOR.  Thus, don't fold that
case to the latter sequence.

gcc/
PR target/90622
* config/avr/avr.cc (avr_fold_builtin) [AVR_BUILTIN_INSERT_BITS]:
Don't fold to XOR / AND / XOR if just one bit is copied to the
same position.

2 years agonvptx: Add suppport for __builtin_nvptx_brev instrinsic.
Roger Sayle [Sun, 21 May 2023 14:06:52 +0000 (15:06 +0100)] 
nvptx: Add suppport for __builtin_nvptx_brev instrinsic.

This patch adds support for (a pair of) bit reversal intrinsics
__builtin_nvptx_brev and __builtin_nvptx_brevll which perform 32-bit
and 64-bit bit reversal (using nvptx's brev instruction) matching
the __brev and __brevll instrinsics provided by NVidia's nvcc compiler.
https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH__INTRINSIC__INT.html

2023-05-21  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/nvptx/nvptx.cc (nvptx_expand_brev): Expand target
builtin for bit reversal using brev instruction.
(enum nvptx_builtins): Add NVPTX_BUILTIN_BREV and
NVPTX_BUILTIN_BREVLL.
(nvptx_init_builtins): Define "brev" and "brevll".
(nvptx_expand_builtin): Expand NVPTX_BUILTIN_BREV and
NVPTX_BUILTIN_BREVLL via nvptx_expand_brev function.
* doc/extend.texi (Nvidia PTX Builtin-in Functions): New
section, document __builtin_nvptx_brev{,ll}.

gcc/testsuite/ChangeLog
* gcc.target/nvptx/brev-1.c: New 32-bit test case.
* gcc.target/nvptx/brev-2.c: Likewise.
* gcc.target/nvptx/brevll-1.c: New 64-bit test case.
* gcc.target/nvptx/brevll-2.c: Likewise.

2 years agoatch.pd: Ensure (op CONSTANT_CLASS_P CONSTANT_CLASS_P) is simplified [PR109505]
Jakub Jelinek [Sun, 21 May 2023 11:36:56 +0000 (13:36 +0200)] 
atch.pd: Ensure (op CONSTANT_CLASS_P CONSTANT_CLASS_P) is simplified [PR109505]

On the following testcase we hang, because POLY_INT_CST is CONSTANT_CLASS_P,
but BIT_AND_EXPR with it and INTEGER_CST doesn't simplify and the
(x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2)
simplification actually relies on the (CST1 & CST2) simplification,
otherwise it is a deoptimization, trading 2 ops for 3 and furthermore
running into
/* Given a bit-wise operation CODE applied to ARG0 and ARG1, see if both
   operands are another bit-wise operation with a common input.  If so,
   distribute the bit operations to save an operation and possibly two if
   constants are involved.  For example, convert
     (A | B) & (A | C) into A | (B & C)
   Further simplification will occur if B and C are constants.  */
simplification which simplifies that
(x & CST2) | (CST1 & CST2) back to
CST2 & (x | CST1).
I went through all other places I could find where we have a simplification
with 2 CONSTANT_CLASS_P operands and perform some operation on those two,
while the other spots aren't that severe (just trade 2 operations for
another 2 if the two constants don't simplify, rather than as in the above
case trading 2 ops for 3), I still think all those spots really intend
to optimize only if the 2 constants simplify.

So, the following patch adds to those a ! modifier to ensure that,
even at GENERIC that modifier means !EXPR_P which is exactly what we want
IMHO.

2023-05-21  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109505
* match.pd ((x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2),
Combine successive equal operations with constants,
(A +- CST1) +- CST2 -> A + CST3, (CST1 - A) +- CST2 -> CST3 - A,
CST1 - (CST2 - A) -> CST3 + A): Use ! on ops with 2 CONSTANT_CLASS_P
operands.

* gcc.target/aarch64/sve/pr109505.c: New test.

2 years agoFix expand_single_bit_test for big-endian
Andrew Pinski [Sun, 21 May 2023 04:01:46 +0000 (21:01 -0700)] 
Fix expand_single_bit_test for big-endian

I had thought extract_bit_field bitpos argument was the shifted position
and not the bitposition like BIT_FIELD_REF so I had removed the code which
would use the correct bitposition for BYTES_BIG_ENDIAN.

Committed as obvious; I checked big-endian MIPS to make sure we are now
producing the correct code.

gcc/ChangeLog:

* expr.cc (expand_single_bit_test): Correct bitpos for big-endian.

2 years agoRISC-V: Support RVV VREINTERPRET from v{u}int*_t to vbool[2-64]_t
Pan Li [Wed, 17 May 2023 07:59:30 +0000 (15:59 +0800)] 
RISC-V: Support RVV VREINTERPRET from v{u}int*_t to vbool[2-64]_t

This patch support the RVV VREINTERPRET from the int to the
vbool[2|4|8|16|32|64]_t.  Aka:

vbool[2|4|8|16|32|64]_t __riscv_vreinterpret_x_x(v{u}int[8|16|32|64]_t);

These APIs help the users to convert vector LMUL=1 integer to
vbool[2-64]_t.  According to the RVV intrinsic SPEC as below,
the reinterpret intrinsics only change the types of the underlying
contents.

https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#reinterpret-vbool-o-vintm1

For example, given below code.
vbool64_t test_vreinterpret_v_u8m1_b64 (vuint8m1_t src) {
  return __riscv_vreinterpret_v_u8m1_b64 (src);
}

It will generate the assembly code similar as below:
vsetvli a5,zero,e8,mf8,ta,ma
vlm.v   v1,0(a1)
vsm.v   v1,0(a0)
ret

Please NOTE the test files doesn't cover all the possible combinations
of the intrinsic APIs introduced by this PATCH due to too many.
The reinterpret from vbool*_t to v{u}int*_t with lmul=1 will be coverred
int another PATCH.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:

* config/riscv/genrvv-type-indexer.cc (BOOL_SIZE_LIST): Add the
rest bool size, aka 2, 4, 8, 16, 32, 64.
* config/riscv/riscv-vector-builtins-functions.def (vreinterpret):
Register vbool[2|4|8|16|32|64] interpret function.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_BOOL2_INTERPRET_OPS):
New macro for vbool2_t.
(DEF_RVV_BOOL4_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL8_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL16_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL32_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL64_INTERPRET_OPS): Likewise.
(vint8m1_t): Add the type to bool[2|4|8|16|32|64]_interpret_ops.
(vint16m1_t): Likewise.
(vint32m1_t): Likewise.
(vint64m1_t): Likewise.
(vuint8m1_t): Likewise.
(vuint16m1_t): Likewise.
(vuint32m1_t): Likewise.
(vuint64m1_t): Likewise.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_BOOL2_INTERPRET_OPS):
New macro for vbool2_t.
(DEF_RVV_BOOL4_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL8_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL16_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL32_INTERPRET_OPS): Likewise.
(DEF_RVV_BOOL64_INTERPRET_OPS): Likewise.
(required_extensions_p): Add vbool[2|4|8|16|32|64] interpret case.
* config/riscv/riscv-vector-builtins.def (bool2_interpret): Add
vbool2_t interprect to base type.
(bool4_interpret): Likewise.
(bool8_interpret): Likewise.
(bool16_interpret): Likewise.
(bool32_interpret): Likewise.
(bool64_interpret): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c: Add
test cases for vbool[2|4|8|16|32|64]_t.

2 years agoFix PR 109919: ICE in emit_move_insn with some bit tests
Andrew Pinski [Sat, 20 May 2023 21:14:23 +0000 (21:14 +0000)] 
Fix PR 109919: ICE in emit_move_insn with some bit tests

The problem is I used expand_expr with the target but
we don't want to use the target here as it is the wrong
mode for the original expression. The testcase would ICE
deap down while trying to do a move to use the target.
Anyways just calling expand_expr with NULL_EXPR fixes
the issue.

Committed as obvious after a bootstrap/test on x86_64-linux-gnu.

PR middle-end/109919

gcc/ChangeLog:

* expr.cc (expand_single_bit_test): Don't use the
target for expand_expr.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr109919-1.c: New test.

2 years agoDaily bump.
GCC Administrator [Sun, 21 May 2023 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

2 years agoinstall.texi: Remove alpha*-*-* section
Gerald Pfeifer [Sat, 20 May 2023 22:23:59 +0000 (00:23 +0200)] 
install.texi: Remove alpha*-*-* section

gcc/ChangeLog:

* doc/install.texi (Specific): Remove de facto empty alpha*-*-*
section.

2 years agoMode-Switching: Fix local array maybe uninitialized warning
Pan Li [Fri, 19 May 2023 23:49:00 +0000 (07:49 +0800)] 
Mode-Switching: Fix local array maybe uninitialized warning

There are 2 local array in function optimize_mode_switching. It will be
initialized conditionally at the beginning but then always consumed in
another loop. It may trigger the warning maybe-uninitialized, and may
result in build failure when enable werror, aka warning as error.

This patch will initialize the local array to zero explictly when
declaration.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:

* mode-switching.cc (entity_map): Initialize the array to zero.
(bb_info): Ditto.

2 years agotarget/105753: Fix ICE in add_clobbers due to extra PARALLEL in insn.
Triffid Hunter [Sat, 20 May 2023 05:50:00 +0000 (07:50 +0200)] 
target/105753: Fix ICE in add_clobbers due to extra PARALLEL in insn.

This patch removes the superfluous parallel in [u]divmod patterns in
the AVR backend.  Effect of extra parallel is that add_clobbers reaches
gcc_unreachable() because the clobbers for [u]divmod are missing.
If an insn has multiple parts like clobbers, the parallel around the
parts of the insn pattern is implicit.

gcc/
PR target/105753
* config/avr/avr.md (divmodpsi, udivmodpsi, divmodsi, udivmodsi):
Remove superfluous "parallel" in insn pattern.
([u]divmod<mode>4): Tidy code.  Use gcc_unreachable() instead of
printing error text to assembly.

gcc/testsuite/
PR target/105753
* gcc.target/avr/torture/pr105753.c: New test.

2 years agoExpand directly for single bit test
Andrew Pinski [Fri, 19 May 2023 22:09:04 +0000 (22:09 +0000)] 
Expand directly for single bit test

Instead of using creating trees to the expansion,
just expand directly which makes the code a little simplier
but also reduces how much GC memory will be used during the expansion.

gcc/ChangeLog:

* expr.cc (fold_single_bit_test): Rename to ...
(expand_single_bit_test): This and expand directly.
(do_store_flag): Update for the rename function.

2 years agoUse BIT_FIELD_REF inside fold_single_bit_test
Andrew Pinski [Fri, 19 May 2023 19:44:35 +0000 (19:44 +0000)] 
Use BIT_FIELD_REF inside fold_single_bit_test

Instead of depending on combine to do the extraction,
Let's create a tree which will expand directly into
the extraction. This improves code generation on some
targets.

gcc/ChangeLog:

* expr.cc (fold_single_bit_test): Use BIT_FIELD_REF
instead of shift/and.

2 years agoSimplify fold_single_bit_test with respect to code
Andrew Pinski [Fri, 19 May 2023 18:52:45 +0000 (18:52 +0000)] 
Simplify fold_single_bit_test with respect to code

Since we know that fold_single_bit_test is now only passed
NE_EXPR or EQ_EXPR, we can simplify it and just use a gcc_assert
to assert that is the code that is being passed.

gcc/ChangeLog:

* expr.cc (fold_single_bit_test): Add an assert
and simplify based on code being NE_EXPR or EQ_EXPR.

2 years agoSimplify fold_single_bit_test slightly
Andrew Pinski [Fri, 19 May 2023 18:36:39 +0000 (18:36 +0000)] 
Simplify fold_single_bit_test slightly

Now the only use of fold_single_bit_test is in do_store_flag,
we can change it such that to pass the inner arg and bitnum
instead of building a tree. There is no code generation changes
due to this change, only a decrease in GC memory that is produced
during expansion.

gcc/ChangeLog:

* expr.cc (fold_single_bit_test): Take inner and bitnum
instead of arg0 and arg1. Update the code.
(do_store_flag): Don't create a tree when calling
fold_single_bit_test instead just call it with the bitnum
and the inner tree.

2 years agoUse get_def_for_expr in fold_single_bit_test
Andrew Pinski [Fri, 19 May 2023 18:21:59 +0000 (18:21 +0000)] 
Use get_def_for_expr in fold_single_bit_test

The code in fold_single_bit_test, checks if
the inner was a right shift and improve the bitnum
based on that. But since the inner will always be a
SSA_NAME at this point, the code is dead. Move it over
to use the helper function get_def_for_expr instead.

gcc/ChangeLog:

* expr.cc (fold_single_bit_test): Use get_def_for_expr
instead of checking the inner's code.

2 years agoInline and simplify fold_single_bit_test_into_sign_test into fold_single_bit_test
Andrew Pinski [Fri, 19 May 2023 17:47:14 +0000 (17:47 +0000)] 
Inline and simplify fold_single_bit_test_into_sign_test into fold_single_bit_test

Since the last use of fold_single_bit_test is fold_single_bit_test,
we can inline it and even simplify the inlined version. This has
no behavior change.

gcc/ChangeLog:

* expr.cc (fold_single_bit_test_into_sign_test): Inline into ...
(fold_single_bit_test): This and simplify.