]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
7 months agovarasm: Fix up array_size_for_constructor RAW_DATA_CST handling once again [PR118275]
Jakub Jelinek [Fri, 3 Jan 2025 16:59:57 +0000 (17:59 +0100)] 
varasm: Fix up array_size_for_constructor RAW_DATA_CST handling once again [PR118275]

As the following testcases show (the latter only if I revert the
temporary reversion of the C++ large array speedup), the FEs aren't
really consistent in the type of array CONSTRUCTOR_ELTS indexes,
it can be bitsizetype, but can be sizetype as well.
Given that everything else is able to cope with it just fine,
I'm using build_int_cst which also doesn't care what type it is,
instead of bitsize_int, which I've used in PR117190 fix (previously
it was size_int).

2025-01-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/118275
* varasm.cc (array_size_for_constructor): Use build_int_cst
with TREE_TYPE (index) as first argument, instead of bitsize_int.

* g++.dg/cpp/embed-18.C: New test.
* g++.dg/ext/flexary41.C: New test.

7 months agoforwprop: Use tree_fits_shwi_p in check_ctz_array
Jakub Jelinek [Fri, 3 Jan 2025 16:55:04 +0000 (17:55 +0100)] 
forwprop: Use tree_fits_shwi_p in check_ctz_array

When touching the function yesterday, I was surprised to see just
TREE_CODE (something) != INTEGER_CST checks followed by tree_to_shwi.
That would ICE if the INTEGER_CST doesn't fit.

I have actually not been able to reproduce an ICE for the elt case
as the caller gives up if the precision of the array type is larger than 32
bits (but I think it is still cleaner to use it), the idx case can actually
ICE e.g. on
static const unsigned long long magic = 0x03f08c5392f756cdULL;
static const char table[] = {
     0, [0x8000000000000000ULL] = 1, 12,  2, 13, 22, 17,  3, 14, 33, 23, 36, 18, 58, 28,  4,
    62, 15, 34, 26, 24, 48, 50, 37, 19, 55, 59, 52, 29, 44, 39,  5,
    63, 11, 21, 16, 32, 35, 57, 27, 61, 25, 47, 49, 54, 51, 43, 38,
    10, 20, 31, 56, 60, 46, 53, 42, 9, 30, 45, 41,  8, 40,  7,  6,
};

int ctz (unsigned long x)
{
  unsigned long lsb = x & -x;
  return table[(lsb * magic) >> 58];
}
~/src/gcc/obj20/gcc/cc1 -quiet /tmp/1.c -O2 -mbmi
/tmp/1.c:2:19: warning: size of ‘table’ 9223372036854775871 bytes exceeds maximum object size 9223372036854775807 [-Wlarger-than=]
    2 | static const char table[] = {
      |                   ^~~~~
during GIMPLE pass: forwprop
/tmp/1.c: In function ‘ctz’:
/tmp/1.c:13:1: internal compiler error: in tree_to_shwi, at tree.cc:6518
   13 | }
      | ^
0x2efa51f internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:517
0xf3c617 fancy_abort(char const*, int, char const*)
        ../../gcc/diagnostic.cc:1722
0x949a36 tree_to_shwi(tree_node const*)
        ../../gcc/tree.cc:6518
0x949a36 tree_to_shwi(tree_node const*)
        ../../gcc/tree.cc:6516
0x18472d5 check_ctz_array
        ../../gcc/tree-ssa-forwprop.cc:2286
but given the 9223372036854775871 bytes long array
I'm not sure it is appropriate for the testsuite.

2025-01-03  Jakub Jelinek  <jakub@redhat.com>

* tree-ssa-forwprop.cc (check_ctz_array): Use tree_fits_shwi_p instead
of just TREE_CODE tests for INTEGER_CST.

7 months agotestsuite: torture: add LLVM testcase for DSE vs. -ftrivial-auto-var-init=
Sam James [Fri, 13 Dec 2024 04:42:29 +0000 (04:42 +0000)] 
testsuite: torture: add LLVM testcase for DSE vs. -ftrivial-auto-var-init=

This testcase came up in a recent LLVM bug report [0] for DSE vs
-ftrivial-auto-var-init=. Add it to our testsuite given that area
could do with better coverage.

[0] https://github.com/llvm/llvm-project/issues/119646

gcc/testsuite/ChangeLog:

* gcc.dg/torture/dse-trivial-auto-var-init.c: New test.

Co-authored-by: Andrew Pinski <pinskia@gmail.com>
7 months agoFortran: Cray pointer comparison wrongly optimized away [PR106692]
Harald Anlauf [Thu, 2 Jan 2025 19:22:23 +0000 (20:22 +0100)] 
Fortran: Cray pointer comparison wrongly optimized away [PR106692]

PR fortran/106692

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_expr_op): Inhibit excessive optimization
of Cray pointers by treating them as volatile in comparisons.

gcc/testsuite/ChangeLog:

* gfortran.dg/cray_pointers_13.f90: New test.

7 months agoada: Rely on default parameter when making non-null nodes
Piotr Trojanek [Thu, 5 Dec 2024 17:03:26 +0000 (18:03 +0100)] 
ada: Rely on default parameter when making non-null nodes

When calling Make_Access_To_Object_Definition and Make_Parameter_Specification
we can rely on the default value of parameter Null_Exclusion_Present being
False. This makes code cleaner and consistent with relying on the default value
of other parameters of this routine.

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_ch3.adb, exp_ch4.adb, exp_disp.adb, inline.adb: Remove explicit
actual parameter Null_Exclusion_Present equal False.

7 months agoada: Rely on default parameter when making non-constant nodes
Piotr Trojanek [Thu, 5 Dec 2024 16:55:09 +0000 (17:55 +0100)] 
ada: Rely on default parameter when making non-constant nodes

When calling Make_Access_To_Object_Definition and Make_Object_Declaration we
can rely on the default value of parameter Constant_Present being False. This
makes code cleaner and consistent with relying on the default value of other
parameters of this routine, like Null_Exclusion_Present.

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_ch3.adb, exp_disp.adb: Remove explicit actual parameter
Constant_Present equal False; tune comments.

7 months agoada: Rely on default parameter when making component definition nodes
Piotr Trojanek [Thu, 5 Dec 2024 16:38:43 +0000 (17:38 +0100)] 
ada: Rely on default parameter when making component definition nodes

When calling Make_Component_Definition we can rely on the default value of
parameter Aliased_Present being False. This makes code cleaner and consistent
with relying on the default value of other parameters of this routine, e.g.
Null_Exclusion_Present.

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_ch3.adb, exp_ch9.adb, exp_dist.adb, exp_imgv.adb, exp_util.adb,
sem_dist.adb: Remove explicit actual parameter Aliased_Present equal
False; tune comments and whitespace.

7 months agoada: Simplify code for obtaining function entity from a function call
Piotr Trojanek [Thu, 5 Dec 2024 16:12:55 +0000 (17:12 +0100)] 
ada: Simplify code for obtaining function entity from a function call

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_ch5.adb (Check_Call): Reuse Get_Called_Entity.

7 months agoada: Remove extra checks for raising a constraint error
Piotr Trojanek [Thu, 5 Dec 2024 15:59:36 +0000 (16:59 +0100)] 
ada: Remove extra checks for raising a constraint error

Routine Is_OK_Static_Expression itself calls Raises_Constraint_Error, so there
is no need to call both of these routines in a row. Code cleanup; semantics is
unaffected.

gcc/ada/ChangeLog:

* sem_attr.adb (Check_Array_Type): Remove extra call.
* sem_util.adb (Static_Boolean): Likewise.

7 months agoada: Reuse and simplify counting the length of various lists
Piotr Trojanek [Thu, 5 Dec 2024 13:12:25 +0000 (14:12 +0100)] 
ada: Reuse and simplify counting the length of various lists

Use utility routines to compute number of elements in lists of nodes and chains
of formal parameters. Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_aggr.adb (Others_Check): Reuse List_Length; tune whitespace.
* exp_ch3.adb (Constrain_Array): Remove counting of constraints.
* exp_disp.adb (Make_DT): Use Elist utility routines; tune whitespace.
* sem_ch12.adb (Formal_Dimensions): Reuse List_Length.
(Valid_Default_Attribute): Reuse Number_Formals.
* sem_prag.adb (Process_Convention): Likewise.
* sem_util.adb (Normalize_Actuals): Likewise.
(Check_Function_Writable_Actuals): Reuse List_Length.

7 months agoada: Remove guards against empty lists
Piotr Trojanek [Thu, 5 Dec 2024 14:14:58 +0000 (15:14 +0100)] 
ada: Remove guards against empty lists

There is no need to guard against calling First on a No_List, in which case
the call intentionally returns Empty. Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* contracts.adb (Create_Generic_Contract): Remove calls to Present.
* sem_util.adb (Normalize_Actuals): Likewise.

7 months agoada: Enclosing_Entity of specless subprogram bodies
Bob Duff [Wed, 4 Dec 2024 23:30:03 +0000 (18:30 -0500)] 
ada: Enclosing_Entity of specless subprogram bodies

Correct Enclosing_Entity of specless subprogram bodies;
these are marked as Comes_From_Source = False,
so the simple name was missing.

gcc/ada/ChangeLog:

* sem_util.adb (Append_Entity_Name): Do not skip the
simple name for a compilation unit (which includes
the case of specless subprogram bodies).

7 months agoada: Fix comments and change subtype name in response to review
Tucker Taft [Thu, 5 Dec 2024 14:47:37 +0000 (14:47 +0000)] 
ada: Fix comments and change subtype name in response to review

gcc/ada/ChangeLog:

* pprint.adb (Expression_Image): Adjust and improve comments
to match style recommendations, and change name of subtype
from Not_Associative to Non_Associative, in response to
code review.

7 months agoada: Add parentheses in expressions involving combinations of and & or
Tucker Taft [Wed, 4 Dec 2024 16:22:10 +0000 (16:22 +0000)] 
ada: Add parentheses in expressions involving combinations of and & or

In the Expression_Image function, we were not inserting
parentheses properly when there was a sequence of
and and or operators, even though Ada requires such
parentheses to show the correct order of association.

gcc/ada/ChangeLog:

* pprint.adb (Expression_Image): In local function Expr_Name
add a No_Parens flag and define a subtype Not_Associative
to represent the short-circuit operations and And/Or/Xor.
Insert parentheses to separate the subexpressions when
different "Not_Associative" operations occur in a
sequence.

7 months agoada: Fix latent issue exposed by latest change
Eric Botcazou [Thu, 5 Dec 2024 10:15:10 +0000 (11:15 +0100)] 
ada: Fix latent issue exposed by latest change

The finalization machinery needs to precisely locate the point where the
initialization of objects is complete in order to generate the attachment
to the finalization master.  For objects initialized with a built-in-place
function call, this is achieved by means of the BIP_Initialization_Call
field present in their entity node, but this field is only set in the case
where the enclosing scope is transient, which is not guaranteed.

gcc/ada/ChangeLog:

* einfo.ads (BIP_Initialization_Call): Adjust description.
* exp_ch4.adb (Expand_N_Case_Expression): Adjust commentary.
(Expand_N_If_Expression): Likewise.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Object_Declaration):
Set BIP_Initialization_Call unconditionally in the definite case.

7 months agoada: Refine subtype of a universal arithmetic utility routine
Piotr Trojanek [Wed, 4 Dec 2024 18:23:08 +0000 (19:23 +0100)] 
ada: Refine subtype of a universal arithmetic utility routine

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* uintp.adb (N_Digits): Refine return subtype, since this routine
always returns a positive number of digits.

7 months agoada: Reuse existing utility routine to detect attribute Loop_Entry
Piotr Trojanek [Wed, 4 Dec 2024 18:20:31 +0000 (19:20 +0100)] 
ada: Reuse existing utility routine to detect attribute Loop_Entry

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* checks.adb (Generate_Index_Checks): Reuse existing utility routine.
* sem_ch4.adb (Analyze_Indexed_Component_Form): Likewise.
* sem_prag.adb (Analyze_Pragma): Likewise.

7 months agoada: Simplify uses of the global name buffer
Piotr Trojanek [Wed, 4 Dec 2024 15:42:29 +0000 (16:42 +0100)] 
ada: Simplify uses of the global name buffer

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_dist.adb (Assign_Subprogram_Identifier,
Reserve_NamingContext_Methods): Simplify.
* osint.adb (Append_Suffix_To_File_Name, Find_File, Get_Directory,
Object_File_Name, Strip_Directory): Likewise.

7 months agoada: Simplify check for No_Coextensions restriction
Piotr Trojanek [Wed, 4 Dec 2024 15:26:45 +0000 (16:26 +0100)] 
ada: Simplify check for No_Coextensions restriction

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Alocator): Move unrelated code out of a declare
block.

7 months agoada: Simplify traversal procedures into traversal functions
Piotr Trojanek [Wed, 31 Jan 2024 12:44:19 +0000 (13:44 +0100)] 
ada: Simplify traversal procedures into traversal functions

Instead of using the generic routine Traverse_Proc to set a global flag when a
particular node is found, we can use its underlying routine Traverse_Func and
check if traversal has been abandoned. We already used this pattern in a number
of places; this patch merely applies it the remaining uses of Traverse_Proc.

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_ch3.adb (Search_Access_Discriminant, Search_Current_Instance,
Search_Internal_Call): Use traversal function instead of traversal
procedure and remove associated global variables.
* exp_util.adb (Search_Calls): Likewise.
* sem_prag.adb (Contains_Loop_Entry): Likewise.
* sem_util.adb (Mentions_Post_State): Likewise.

7 months agoada: Assorted style cleanups
Piotr Trojanek [Wed, 4 Dec 2024 15:22:05 +0000 (16:22 +0100)] 
ada: Assorted style cleanups

Whitespace and comment cleanups.

gcc/ada/ChangeLog:

* sem_attr.adb (Eval_Attribute): Fix comment for attribute Image.
* tbuild.adb (Make_SC): Remove extra whitespace.

7 months agoada: Handle C++ exception hierarchies
Alexandre Oliva [Wed, 13 Nov 2024 22:21:56 +0000 (19:21 -0300)] 
ada: Handle C++ exception hierarchies

This patch introduces support for defining exceptions in Ada with
C++'s notion of exception type compatibility, such as handling
occurrences of derived types, and obtaining class-wide access to the
thrown/raised objects.  As a bonus, it adds support for C++ dependent
(wrapped) exceptions, and introduces types and interfaces to match
C++'s std::type_info and std::exception.

Support for C++ exceptions with base-type matching, added to raise-gcc
by calling subprograms in Ada units, requires these units and their
dependencies to be linked into programs that link with raise-gcc.

gcc/ada/ChangeLog:

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-cpp, g-cppstd,
and g-cstyin.
* doc/gnat_rm/interfacing_to_other_languages.rst (Interfacing to C++):
Document class-wide matching and new interfaces.
* exp_prag.adb (Expand_Pragma_Import_Or_Interface): Add class-wide
exception matching support with 'B' as language identifier.
* libgnat/a-exexpr.adb (Setup_Current_Excep): Add Id formal.
(Set_Foreign_Occurrence): Likewise.
(Propagate_GCC_Exception): Adjust.
(Set_Exception_Parameter): Likewise.
(Unhandled_Except_Handler): Likewise.
* libgnat/g-cpp.ads: New.
* libgnat/g-cppexc.adb (Raise_Cpp_Exception): Match 'B' lang id.
(Get_Object_Address): New.
(Get_Object): Rewrite.
(Get_Access_To_Object): New.
(Get_Access_To_Tagged_Object): New.
(Get_Type_Info): New.
(Convert_Caught_Object): New.
* libgnat/g-cppexc.ads (Get_Object_Address): New.
(Get_Object): Note the Cpp Convention requirement.
(Get_Access_To_Object): New.
(Get_Access_To_Tagged_Object): New.
(Get_Type_Info): New.
* libgnat/g-cppstd.adb: New.
* libgnat/g-cppstd.ads: New.
* libgnat/g-csclex.ads: New, unused.
* libgnat/g-cstyin.adb: New.
* libgnat/g-cstyin.ads: New.
* libgnat/g-excact.adb (Exception_Language): New.
(Is_Foreign_Exception): Rewrite.
* libgnat/g-excact.ads (Exception_Languages): New.
(Exception_Language): New.
* libgnat/s-stalib.ads (Lang): Document 'B'.
* raise-gcc.c (__gnat_setup_current_excep): Add Exception_Id formal.
(CXX_DEPENDENT_EXCEPTION_CLASS): New.
(cxx_type_info): New.
(__cxa_exception): Rename exceptionType to encompass PrimaryException.
(_GNAT_Exception): Drop wrapper.
(EID_For): Adjust.
(exception_class_eq): Likewise.
(__gnat_exception_language_is_cplusplus): New.
(__gnat_exception_language_is_ada): New.
(__gnat_convert_caught_object): Declare.
(__gnat_get_cxx_dependent_exception): New.
(__gnat_maybe_get_cxx_dependent_exception): New.
(__gnat_get_cxx_exception_type_info): New.
(__gnat_obtain_caught_object): New.
(is_handled_by): Adjust.   [!CERT] Add eid formal, handle dependent
exceptions and base-type matches.
(get_action_description_for) [!CERT]: Add eid formal.  Adjust.
(personality_body): Adjust.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS) [!STAGE1]:
Add new g-cpp, g-cppstd, g-cstyin + preexisting g-cppexc
and i-cstrin.
* gnat-style.texi: Regenerate.
* gnat_rm.texi: Regenerate.

7 months agoada: Improve and correct support for inheritance of nonoverriding aspects
Gary Dismukes [Mon, 4 Nov 2024 06:06:21 +0000 (06:06 +0000)] 
ada: Improve and correct support for inheritance of nonoverriding aspects

This set of changes fixes various issues with the handling of inheritance
of nonoverridable aspects (such as for Aggregate, and the indexing and
iterator aspects, among others), plus improves some of the error reporting
related to those. The prior implementation incorrectly handled types
derived from container types with respect to such aspect inheritance,
not properly inheriting the parent type's aspects, leading to rejection
of legal constructs (such as container aggregates for the derived type).
Also, various errors were incorrect (such as stating the wrong aspect)
or unclear.

In the case of types with indexing aspects, the resolution of indexed
names for such types involved locating the eligible indexing functions
anew with the analysis of each indexed name, which was both inefficient
and wrong in some cases. That is addressed by locating the functions once,
when the aspects are resolved, rather doing the location of those in two
places, which is a maintenance hazard and could result in inconsistent
resolution.

Note that this completes work originally undertaken by Ed Schonberg
that was also worked on by Steve Baird.

gcc/ada/ChangeLog:

* diagnostics-constructors.adb (Make_Default_Iterator_Not_Primitive_Error):
Revise message to match message change made in sem_ch13.adb.
* freeze.adb (Freeze_Record_Type): Output appropriate aspect name in
error message, using Get_Name_String.
(Freeze_Entity): For derived types, call Analyze_Aspects_At_Freeze_Point
on the parent type, and call Inherit_Nonoverridable_Aspects on the type
(for both parent type and any progenitor types). Add with_clause for
System.Case_Util.
* gen_il-fields.ads: Add Aspect_Subprograms to type Opt_Field_Enum.
* gen_il-gen-gen_nodes.adb: Add field Aspect_Subprograms to
N_Aspect_Specification nodes.
* sem_ch4.adb (Try_Container_Indexing): Remove Find_Indexing_Operations
and the code calling it. Add new function Indexing_Interpretations for
retrieving the eligible indexing functions from the appropriate aspect's
Aspect_Subprograms list and call that instead of Find_Value_Of_Aspect.
* sem_ch7.adb (Analyze_Package_Specification): In loop over entities,
call Analyze_Aspects_At_Freeze_Point for types that have delayed
aspects.
* sem_ch13.ads (Analyze_Aspects_At_Freeze_Point): Add Nonoverridable_Only
formal to restrict processing to nonoverridable aspects.
(Check_Function_For_Indexing_Aspect): New exported procedure renamed
from Check_One_Function and moved to library level.
* sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Test new formal
Nonoverridable_Only formal to skip processing of aspects that are not
nonoverridable when the formal is True. Skip the processing for
Aspect_Full_Access_Only when Nonoverridable_Only is True. Call
Check_Indexing_Functions in the case of indexing aspects (procedure
moved from Analyze_Attribute_Definition_Clause to top level).
(Analyze_Aspect_Specifications): Locate closest ancestor type with an
explicit matching aspect to determine the aspect spec to reference in
the error about a nonoverridable aspect not confirming an inherited
aspect (skipping intermediate derived parents). Ensures that we retain
existing errors flagged on explicit ancestor aspects rather than
implicit inherited ones. Change names of variables Parent_Type and
Inherited_Aspect to Ancestor_Type and Ancestor_Aspect respectively
for clarity.
(Analyze_Attribute_Definition_Clause): Move nested subprograms
Check_Iterator_Functions and Check_Primitive_Function to top level
of package. Move Check_Indexing_Functions (and its nested subprograms)
from here to within Analyze_Aspects_At_Freeze_Point (adding some
formal parameters and adjusting the code appropriately, and no longer
call it from this procedure).
(Is_CW_Or_Access_To_CW): Add test for the parent type having the
indexing aspect for proper setting of Aspect_Specification_Is_Inherited.
Delete "???" comment.
(Look_Through_Anon_Access): Remove unneeded tests of Is_Access_Constant
and Name_Constant_Indexing, which lead to wrong messages in some cases.
(Check_Function_For_Indexing_Aspect): Procedure renamed from
Check_One_Function and moved to library level (was nested within
Check_Indexing_Functions), plus added formals (including Valid, to
check result). Move scope test to beginning, to immediately exclude
subprograms not declared immediately within the same scope as the type.
Improve several error messages. Add error checking for Constant_Indexing
functions. Append the function entity to the Aspect_Subprograms list of
the aspect specification. Move code for checking for nonconfirming
index aspects and for checking for illegal indexing aspects on full
views to Check_Indexing_Functions.
(Check_Indexing_Functions): Move procedure Illegal_Indexing from
here to within Check_Function_For_Indexing_Aspect. Add a comment
to the loop over interpretations about the checking being done as
legality rules rather than resolution rules, plus a note referencing
AI22-0084. Check for nonconfirming indexing aspects and illegal
indexing aspects on full views here rather than in Check_One_Function
(now named Check_Function_For_Indexing_Aspect). Remove function
Check_One_Function (moved to library level and renamed), and call
Check_Function_For_Indexing_Aspect instead.
(Check_Inherited_Indexing): Improve spec comment. Remove nested function
Same_Chars, and replace call Same_Chars with call to Sem_Util.Same_Name.
Replace call to Illegal_Indexing with call to Error_Msg_NE.
(Check_One_Function): Unnested from Check_Indexing_Functions, rename
to Check_Function_For_Indexing_Aspect, move body to library level,
and move declaration to Sem_Ch13 spec.
(Analyze_Attribute_Definition_Clause, case Attribute_Default_Iterator):
Improve error message related to tagged-type requirement. Suppress call
to Check_Iterator_Functions for attribute definition clauses associated
with inherited aspects. Remove error checking that is redundant with
checking done in Check_Iterator_Functions.
(Check_Aspect_At_Freeze_Point, case Attribute_Default_Iterator): Call
Check_Iterator_Functions (only if the aspect is not Comes_From_Source).
(Check_Iterator_Functions): Procedure unnested from
Analyze_Attribute_Definition_Clause. Add formals Typ and Expr.
Error messages corrected to say "aspect Default_Iterator" instead of
"aspect Iterator".
(Valid_Default_Iterator): Improve error message to say "must be
a local primitive or class-wide function" instead of "must be
a primitive function".
(Check_Primitive_Function): Unnested from Analyze_Attribute_Definition_Clause.
Add formal Ent.
(Rep_Item_Too_Late): Return False when an attribute_definition_clause
is not Comes_From_Source, since it was generated by the compiler (such
as for an inherited aspect).
(Resolve_Aspect_Aggregate): Capture implementation base type.
(Valid_Empty): Use implementation base types for result type comparison.
(Valid_Add_Named): Use impl base types for comparison of formal's type.
(Valid_Add_Unnamed): Use impl base types for comparison of formal's type.
(Valid_New_Indexed): Use impl base types for result type comparison.
(Validate_Literal_Aspect): Return immediately when aspect does not have
Comes_From_Source True (no point in validating inherited aspects).
* sem_res.adb (Has_Applicable_User_Defined_Literal): Remove Base_Type
comparison and always call Corresponding_Op_Of_Derived_Type for derived
types. Add "???" comment about issue with wrapper functions (and
indicate that it would be nice to eliminate the call to
Corresponding_Primitive_Op).
* sem_util.ads (Inherit_Nonoverridable_Aspects): New procedure.
(Corresponding_Op_Of_Derived_Type): Update spec comment to indicate
return of Ancestor_Op and name changed from Corresponding_Primitive_Op.
* sem_util.adb (Check_Inherited_Nonoverridable_Aspects): Fix name in
header comment.
(Corresponding_Op_Of_Derived_Type): Move declaration of Typ down with
other local variables. Remove Assert that doesn't apply in some cases.
Simply return Ancestor_Op when it isn't a primitive (it can be a
class-wide op). Function name changed from Corresponding_Primitive_Op.
(Find_Untagged_Type_Of): Add test of Is_Type (E) as a guard for checking
Direct_Primitive_Operations. Remove Assert (False), and return Empty
when the primitive is not found.
(Profile_Matches_Ancestor): Change comparisons to use implementation
base types of the operations' formal and result types. Add tests for
interface ancestors. Revise "???" comment.
(Is_Confirming): Simplify name-matching test to use the names associated
with the aspects rather than going to the N_Attribute_Definition_Clause
nodes (may facilitate elimination of those clauses at some point).
(Inherit_Nonoverridable_Aspects): New procedure to traverse the
aspects of a derived type's parent type and create inherited versions
of the parent type's nonoverridable aspects, identifying the appropriate
subprograms for each such inherited aspect.
(Inherit_Nonoverridable_Aspect): New procedure nested in
Inherit_Nonoverridable_Aspects to inherit individual nonoverridable
aspects. Identifies the corresponding subprogram(s) associated with
an inherited nonoverridable aspect. In the case of indexing aspects,
new eligible indexing functions of the type are also identified here,
and the entities of all of the identified subprograms are appended to
the aspect's Aspect_Subprograms Elist. Add a "???" comment about this.
* sinfo.ads: Add documentation for the new Aspect_Subprograms field.

7 months agoada: Fix small thinko in previous change
Eric Botcazou [Wed, 4 Dec 2024 11:35:29 +0000 (12:35 +0100)] 
ada: Fix small thinko in previous change

Even if the declaration of the conditional object is turned into a renaming
during expansion, the conditional object must be finalized when the original
object would have been.

gcc/ada/ChangeLog:

* exp_ch4.adb (Insert_Conditional_Object_Declaration): Create the
Master_Node even if the declaration is turned into a renaming.

7 months agoada: Leave empty parent in an array component of an anonymous access type
Piotr Trojanek [Wed, 4 Dec 2024 12:45:24 +0000 (13:45 +0100)] 
ada: Leave empty parent in an array component of an anonymous access type

An itype created for a record component with an anonymous access type has empty
parent. However, a similar itype created for an array component has its parent
copied from the parent of the array type.

The above discrepancy appears to be not needed for the frontend. Also, it is
confusing for the GNATprove backend, because it looks like the itype entity
of the array component comes from a declaration of the array itself.

gcc/ada/ChangeLog:

* sem_ch3.adb (Array_Type_Declaration): Don't copy parent for an itype
created by an array component declaration.

7 months agoada: Incompatible conversion on vxworks in socket.c
Douglas B Rupp [Mon, 5 Aug 2024 20:17:38 +0000 (13:17 -0700)] 
ada: Incompatible conversion on vxworks in socket.c

In the vxworks section, a conversion between char* and int is
attempted, which results in a warning with gcc. However with clang
with is an error. Note also on 64bit targets, there's a size
mismatch.

gcc/ada/ChangeLog:

* socket.c [__vxworks]: Change vxw_h_addr type to long from
int, and cast the conversion of char* to vxw_h_addr to avoid
warning/error.

7 months agoada: Do not search executables in current dir by default
Tonu Naks [Tue, 3 Dec 2024 12:50:45 +0000 (12:50 +0000)] 
ada: Do not search executables in current dir by default

gcc/ada/ChangeLog:

* adaint.c: change default behaviour of __gnat_locate_exec_on_path
* adaint.h: change prototype of __gnat_locate_exec_on_path
* libgnat/s-os_lib.adb: pass optional argument in Locate_Exec_On_Path
* libgnat/s-os_lib.ads: change spec of Locate_Exec_On_Path
* libgnat/s-trasym__dwarf.adb: update import of __gnat_locate_exec_on_path

7 months agoada: Fix double free at run time for class-wide allocation
Eric Botcazou [Tue, 3 Dec 2024 21:36:15 +0000 (22:36 +0100)] 
ada: Fix double free at run time for class-wide allocation

The previous change was too aggressive and overlooked a specific case.

gcc/ada/ChangeLog:

* exp_ch4.adb (Expand_Allocator_Expression): Put back the call to
Remove_Side_Effects in the case of a function call, a class-wide
designated type and a regular storage pool.

7 months agoada: Warn on unmodified parameters of expression functions
Bob Duff [Tue, 3 Dec 2024 22:49:15 +0000 (17:49 -0500)] 
ada: Warn on unmodified parameters of expression functions

If an 'out' or 'in out' parameter is not modified in a function body,
we warn. However, the warning was missing when we have an expression
function instead of a proper body. This patch enables the warning
on expression functions.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Expression_Function): Mark the implicit
spec for an expression function as Comes_From_Source.
(Analyze_Null_Procedure): Minor cleanup.
* sem_warn.adb (Source_E1): New function to compute whether
to give warnings. In particular, return True for [in] out
parameters of expression functions.

7 months agoada: Avoid failing reanalysis of aggregate bounds
Steve Baird [Tue, 3 Dec 2024 00:45:37 +0000 (16:45 -0800)] 
ada: Avoid failing reanalysis of aggregate bounds

An expression like Some_Package."+" (Arg1, Arg2) is sometimes transformed
during expansion into an unqualified call of the form "+" (Arg1, Arg2).
This is normally ok, but it means that reanalysis of the expression is likely
to fail and must therefore be avoided. Remove code that was forcing such
reanalysis (the original reason for the now-removed code is unknown).

gcc/ada/ChangeLog:

* exp_aggr.adb (Check_Bounds): Remove calls that were setting the
Analyzed flag to False for two aggregate bound expressions.

7 months agoada: Improve expansion of conditional expressions in object declarations
Eric Botcazou [Mon, 2 Dec 2024 20:58:29 +0000 (21:58 +0100)] 
ada: Improve expansion of conditional expressions in object declarations

This arranges for conditional expressions in objects declarations to have
their expansion delayed when they have a type that cannot be easily copied
or copied at all, including limited and controlled types.

The ultimate goal is to replace the declaration with a renaming declaration
of the dereference of an access value designating an object initialized with
the dependent expression chosen by the condition.

gcc/ada/ChangeLog:

* einfo.ads (Is_Independent): Document usage on Master_Node objects.
* exp_aggr.adb (In_Place_Assign_OK): Remove Parent_Kind variable.
(Convert_To_Assignments): Call Unconditional_Parent and remove the
restriction on the known size for the in-place expansion of the
aggregate in the context of an object declaration.
(Expand_Array_Aggregate): Remove Parent_Kind variable and call
Unconditional_Parent and Delay_Conditional_Expressions_Between
* exp_ch3.adb: Remove clauses for Exp_Dbug.
(Expand_N_Object_Declaration): Factor out the code rewriting the
declaration as a renaming in Rewrite_Object_Declaration_As_Renaming
and call the procedure.
* exp_ch4.adb (Insert_Conditional_Object_Declaration): Declare.
(Expand_N_Case_Expression): Delay expanding the expression if it is
in the context of an optimizable object declaration.  If the parent
node is this object declaration, then replace it with a renaming of
the dereference of an access value designating an object initialized
with the dependent expression chosen by the condition.
(Expand_N_If_Expression): Likewise.
(Insert_Conditional_Object_Declaration): New procedure.
* exp_ch6.adb (Expand_Ctrl_Function_Call): Test the unconditional
parent in the case of an object declaration too.
* exp_ch7.adb (Build_Finalizer.Process_Declarations): Pass Strict to
Processing_Actions from the Is_Independent flag on a Master_Node.
* exp_util.ads (Rewrite_Object_Declaration_As_Renaming): Declare.
* exp_util.adb: Add clauses for Exp_Dbug.
(Rewrite_Object_Declaration_As_Renaming): New procedure extracted
from Expand_N_Object_Declaration.
* sem_ch3.adb (Analyze_Object_Declaration): Also leave the analysis
if the declaration has been replaced with a renaming in the case of
an initialization expression that is a conditional expression.

7 months agoada: Preliminary work in analysis and expansion of initialized allocators
Eric Botcazou [Sun, 1 Dec 2024 10:46:46 +0000 (11:46 +0100)] 
ada: Preliminary work in analysis and expansion of initialized allocators

This makes the expansion of the various cases of initialized allocators more
uniform by factoring out common processing as much as possible.  This also
avoids giving the warning or error for a default-initialized allocator when
it is marked with No_Initialization.  No functional changes.

gcc/ada/ChangeLog:

* checks.adb (Apply_Predicate_Check): Preserve Comes_From_Source.
* exp_ch4.adb (Expand_Allocator_Expression): Factor out common code
for the various cases.  Also delay applying the 2nd predicate check.
In the default case, defer to Make_Build_In_Place_Call_In_Allocator
entirely in the build-in-place case.
* sem_ch4.adb (Analyze_Allocator): Do not give the warning or error
for a default-initialized allocator with No_Initialization.

7 months agoada: Remove useless space in ALI P lines
Ronan Desplanques [Thu, 28 Nov 2024 10:45:25 +0000 (11:45 +0100)] 
ada: Remove useless space in ALI P lines

The generated ALI files are syntactically unchanged.

gcc/ada/ChangeLog:

* lib-writ.adb (Write_ALI): Remove useless space.

7 months agoada: Fix omissions of ALI P line parameters
Ronan Desplanques [Thu, 28 Nov 2024 10:08:46 +0000 (11:08 +0100)] 
ada: Fix omissions of ALI P line parameters

Before this patch, the compiler would not report various tasking
settings specified in library units when these library units did not use
tasking, or when they were predefined. While this behavior was
implemented deliberately, that was a long time ago and it proved to be
a pitfall that could cause configuration pragmas to be silently ignored.

This patch makes the compiler report the aforementioned tasking settings
in ALI files unconditionally.

Also, this patch fixes an incorrect statement and a couple of typos in
the spec of Lib.Writ.

gcc/ada/ChangeLog:

* lib-writ.adb (Write_ALI): Remove condition for writing P line
parameters.
* lib-writ.ads: Fix typos. Clarify comment.

7 months agobpf: install a wrapping stdint.h for bpf-none-unknown targets
Jose E. Marchesi [Fri, 3 Jan 2025 12:42:26 +0000 (13:42 +0100)] 
bpf: install a wrapping stdint.h for bpf-none-unknown targets

This patch makes GCC to wrap the host's stdint.h header when operating
in the default hosted/non-freestanding mode.  It is thus up to the
user to provide a suitable standard header unless -ffreestanding gets
explicitly passed in the compilation line.

A few tests that use stdint.h are adapted to explicitly pass
-ffreestanding.

Tested in a x86_64-linux-gnu host with target bpf-unknown-none.

gcc/ChangeLog:

* config.gcc: install a wrapping stdint.h in bpf targets.

gcc/testsuite/ChangeLog:

* gcc.target/bpf/diag-funargs-2.c: Use -ffreestanding.
* gcc.target/bpf/helper-skb-ancestor-cgroup-id.c: Likewise.
* gcc.target/bpf/helper-bind.c: Likewise.
* gcc.target/bpf/diag-funargs-3.c: Likewise.

7 months agoOpenMP: update documentation for dispatch and adjust_args
Paul-Antoine Arras [Mon, 27 May 2024 09:48:34 +0000 (11:48 +0200)] 
OpenMP: update documentation for dispatch and adjust_args

libgomp/ChangeLog:

* libgomp.texi:

7 months agoOpenMP/C++: Store location in cp_parser_omp_var_list for kind=0
Tobias Burnus [Fri, 3 Jan 2025 09:12:32 +0000 (10:12 +0100)] 
OpenMP/C++: Store location in cp_parser_omp_var_list for kind=0

cp_parser_omp_var_list and cp_parser_omp_var_list_no_open have a special
modus: kind = 0 alias kind = OMP_CLAUSE_ERROR, which returns a simple tree
list; however, for a decl, no location is associated with that variable,
yielding to confusing error locations. With this patch, also for kind=0,
a reasonable error location is stored, albeit with creating a tree node
(build_empty_stmt), which is otherwise not used.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_var_list_no_open,
cp_parser_omp_var_list): For kind=0 (= OMP_CLAUSE_ERROR),
store also the expression location in the tree list.
(cp_parser_oacc_data_clause_deviceptr,
cp_finish_omp_declare_variant): Use that location instead or
input_location/the before-parsing location.
* semantics.cc (finish_omp_threadprivate): Likewise.

7 months agoFortran: Fix typo in ATAN documentation.
Sandra Loosemore [Fri, 3 Jan 2025 04:02:44 +0000 (04:02 +0000)] 
Fortran: Fix typo in ATAN documentation.

gcc/fortran/ChangeLog
* intrinsic.texi (ATAN): Add missing verb.

7 months agoDaily bump.
GCC Administrator [Fri, 3 Jan 2025 00:17:15 +0000 (00:17 +0000)] 
Daily bump.

7 months agoOpenMP: Enable has_device_addr clause for 'dispatch' in Fortran
Tobias Burnus [Thu, 2 Jan 2025 21:41:03 +0000 (22:41 +0100)] 
OpenMP: Enable has_device_addr clause for 'dispatch' in Fortran

Fortran version of commit r15-6178-g2cbb2408a830a6 for C/C++.
However, the has_device_addr clause on dispatch only becomes really
useful (for C++ and Fortran) once the 'need_device_addr' modifier
to declare variant's 'adjust_args' clause is supported (i.e. with
a future commit).

gcc/fortran/ChangeLog:

* openmp.cc (OMP_DISPATCH_CLAUSES): Add OMP_CLAUSE_HAS_DEVICE_ADDR.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/adjust-args-10.f90: New test.

7 months agoOpenMP: Fortran front-end support for dispatch + adjust_args
Paul-Antoine Arras [Fri, 24 May 2024 17:13:50 +0000 (19:13 +0200)] 
OpenMP: Fortran front-end support for dispatch + adjust_args

This patch adds support for the `dispatch` construct and the `adjust_args`
clause to the Fortran front-end.

Handling of `adjust_args` across translation units is missing due to PR115271.

Minor modifications to the C++ FE and the ME are also folded into this patch as
a side effect of the Fortran work.

gcc/c-family/ChangeLog:

* c-attribs.cc: (c_common_gnu_attributes): Rename "omp declare variant
variant adjust_args" into "omp declare variant variant args" to also
accommodate append_args.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_dispatch): Handle INDIRECT_REF.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_clauses): Handle novariants and nocontext
clauses.
(show_omp_node): Handle EXEC_OMP_DISPATCH.
(show_code_node): Likewise.
* frontend-passes.cc (gfc_code_walker): Handle novariants and nocontext.
* gfortran.h (enum gfc_statement): Add ST_OMP_DISPATCH.
(symbol_attribute): Add omp_declare_variant_need_device_ptr.
(gfc_omp_clauses): Add novariants and nocontext.
(gfc_omp_declare_variant): Add need_device_ptr_arg_list.
(enum gfc_exec_op): Add EXEC_OMP_DISPATCH.
* match.h (gfc_match_omp_dispatch): Declare.
* openmp.cc (gfc_free_omp_clauses): Free novariants and nocontext
clauses.
(gfc_free_omp_declare_variant_list): Free need_device_ptr_arg_list
namelist.
(enum omp_mask2): Add OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT.
(gfc_match_omp_clauses): Handle OMP_CLAUSE_NOVARIANTS and
OMP_CLAUSE_NOCONTEXT.
(OMP_DISPATCH_CLAUSES): Define.
(gfc_match_omp_dispatch): New function.
(gfc_match_omp_declare_variant): Parse adjust_args.
(resolve_omp_clauses): Handle adjust_args, novariants and nocontext.
Adjust handling of OMP_LIST_IS_DEVICE_PTR.
(icode_code_error_callback): Handle EXEC_OMP_DISPATCH.
(omp_code_to_statement): Likewise.
(resolve_omp_dispatch): New function.
(gfc_resolve_omp_directive): Handle EXEC_OMP_DISPATCH.
* parse.cc (decode_omp_directive): Match dispatch.
(next_statement): Handle ST_OMP_DISPATCH.
(gfc_ascii_statement): Likewise.
(parse_omp_dispatch): New function.
(parse_executable): Handle ST_OMP_DISPATCH.
* resolve.cc (gfc_resolve_blocks): Handle EXEC_OMP_DISPATCH.
* st.cc (gfc_free_statement): Likewise.
* trans-decl.cc (create_function_arglist): Declare.
(gfc_get_extern_function_decl): Call it.
* trans-openmp.cc (gfc_trans_omp_clauses): Handle novariants and
nocontext.
(replace_omp_dispatch_call): New function.
(gfc_trans_omp_dispatch): New function.
(gfc_trans_omp_directive): Handle EXEC_OMP_DISPATCH.
(gfc_trans_omp_declare_variant): Handle adjust_args.
* trans.cc (trans_code): Handle EXEC_OMP_DISPATCH:.

gcc/ChangeLog:

* gimplify.cc (gimplify_call_expr): Fix handling of need_device_ptr for
type(c_ptr). Fix handling of nested function calls in a dispatch region.
(find_ifn_gomp_dispatch): Return the IFN without stripping it.
(gimplify_omp_dispatch): Keep IFN_GOMP_DISPATCH until
gimplify_call_expr.

libgomp/ChangeLog:
* testsuite/libgomp.fortran/declare-variant-2-aux.f90: New test.
* testsuite/libgomp.fortran/declare-variant-2.f90: New test (xfail).
* testsuite/libgomp.fortran/dispatch-1.f90: New test.
* testsuite/libgomp.fortran/dispatch-2.f90: New test.
* testsuite/libgomp.fortran/dispatch-3.f90: New test.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/dispatch-3.C: Update scan dumps.
* gfortran.dg/gomp/declare-variant-2.f90: Update dg-error.
* gfortran.dg/gomp/adjust-args-1.f90: New test.
* gfortran.dg/gomp/adjust-args-2.f90: New test.
* gfortran.dg/gomp/adjust-args-2a.f90: New test.
* gfortran.dg/gomp/adjust-args-3.f90: New test.
* gfortran.dg/gomp/adjust-args-4.f90: New test.
* gfortran.dg/gomp/adjust-args-5.f90: New test.
* gfortran.dg/gomp/adjust-args-6.f90: New test.
* gfortran.dg/gomp/adjust-args-7.f90: New test.
* gfortran.dg/gomp/adjust-args-8.f90: New test.
* gfortran.dg/gomp/adjust-args-9.f90: New test.
* gfortran.dg/gomp/dispatch-1.f90: New test.
* gfortran.dg/gomp/dispatch-2.f90: New test.
* gfortran.dg/gomp/dispatch-3.f90: New test.
* gfortran.dg/gomp/dispatch-4.f90: New test.
* gfortran.dg/gomp/dispatch-5.f90: New test.
* gfortran.dg/gomp/dispatch-6.f90: New test.
* gfortran.dg/gomp/dispatch-7.f90: New test.
* gfortran.dg/gomp/dispatch-8.f90: New test.
* gfortran.dg/gomp/dispatch-9.f90: New test.
* gfortran.dg/gomp/dispatch-9a.f90: New test.
* gfortran.dg/gomp/dispatch-10.f90: New test.

7 months agoc: special-case some "bool" errors with C23 (v2) [PR117629]
David Malcolm [Thu, 2 Jan 2025 20:10:15 +0000 (15:10 -0500)] 
c: special-case some "bool" errors with C23 (v2) [PR117629]

Changed in v2:
- distinguish between "bool" and "_Bool" when determining
  standard version

This patch attempts to provide better error messages for
code compiled with C23 that hasn't been updated for
"bool", "true", and "false" becoming keywords.

Specifically:

(1) with "typedef int bool;" previously we emitted:

t1.c:7:13: error: two or more data types in declaration specifiers
    7 | typedef int bool;
      |             ^~~~
t1.c:7:1: warning: useless type name in empty declaration
    7 | typedef int bool;
      | ^~~~~~~

whereas with this patch we emit:

t1.c:7:13: error: 'bool' cannot be defined via 'typedef'
    7 | typedef int bool;
      |             ^~~~
t1.c:7:13: note: 'bool' is a keyword with '-std=c23' onwards
t1.c:7:1: warning: useless type name in empty declaration
    7 | typedef int bool;
      | ^~~~~~~

(2) with "int bool;" previously we emitted:

t2.c:7:5: error: two or more data types in declaration specifiers
    7 | int bool;
      |     ^~~~
t2.c:7:1: warning: useless type name in empty declaration
    7 | int bool;
      | ^~~

whereas with this patch we emit:

t2.c:7:5: error: 'bool' cannot be used here
    7 | int bool;
      |     ^~~~
t2.c:7:5: note: 'bool' is a keyword with '-std=c23' onwards
t2.c:7:1: warning: useless type name in empty declaration
    7 | int bool;
      | ^~~

(3) with "typedef enum { false = 0, true = 1 } _Bool;" previously we
emitted:

t3.c:7:16: error: expected identifier before 'false'
    7 | typedef enum { false = 0, true = 1 } _Bool;
      |                ^~~~~
t3.c:7:38: error: expected ';', identifier or '(' before '_Bool'
    7 | typedef enum { false = 0, true = 1 } _Bool;
      |                                      ^~~~~
t3.c:7:38: warning: useless type name in empty declaration

whereas with this patch we emit:

t3.c:7:16: error: cannot use keyword 'false' as enumeration constant
    7 | typedef enum { false = 0, true = 1 } _Bool;
      |                ^~~~~
t3.c:7:16: note: 'false' is a keyword with '-std=c23' onwards
t3.c:7:38: error: expected ';', identifier or '(' before '_Bool'
    7 | typedef enum { false = 0, true = 1 } _Bool;
      |                                      ^~~~~
t3.c:7:38: warning: useless type name in empty declaration

gcc/c/ChangeLog:
PR c/117629
* c-decl.cc (declspecs_add_type): Special-case attempts to use
bool as a typedef name or declaration name.
* c-errors.cc (get_std_for_keyword): New.
(add_note_about_new_keyword): New.
* c-parser.cc (report_bad_enum_name): New, split out from...
(c_parser_enum_specifier): ...here, adding handling for RID_FALSE
and RID_TRUE.
* c-tree.h (add_note_about_new_keyword): New decl.

gcc/testsuite/ChangeLog:
PR c/117629
* gcc.dg/auto-type-2.c: Update expected output with _Bool.
* gcc.dg/c23-bool-errors-1.c: New test.
* gcc.dg/c23-bool-errors-2.c: New test.
* gcc.dg/c23-bool-errors-3.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
7 months agoUse _Float128 in test for PR118184
Richard Sandiford [Thu, 2 Jan 2025 17:33:49 +0000 (17:33 +0000)] 
Use _Float128 in test for PR118184

The test was failing on x86 because longdouble128 only checks sizeof,
rather than a full 128-bit payload.  Using _Float128 is more portable
and still exposes the original bug.

gcc/testsuite/
PR target/118184
* gcc.dg/torture/pr118184.c: Use _Float128 instead of long double.

7 months ago[GCN] install.texi: Refer to Newlib 4.5.0 instead to certain git commits
Tobias Burnus [Thu, 2 Jan 2025 14:43:30 +0000 (15:43 +0100)] 
[GCN] install.texi: Refer to Newlib 4.5.0 instead to certain git commits

gcc/ChangeLog:

* doc/install.texi (amdgcn-x-amdhsa): Refer to Newlib 4.5.0 for
the I/O locking fixes.

7 months agotree-optimization/118171 - GENERIC folding in PRE results in invalid GIMPLE
Richard Biener [Wed, 1 Jan 2025 15:07:03 +0000 (16:07 +0100)] 
tree-optimization/118171 - GENERIC folding in PRE results in invalid GIMPLE

PRE applies GENERIC folding to some component ref components which
might result in invalid GIMPLE, like a VIEW_CONVERT_EXPR wrapping
a REALPART_EXPR as in the PR.  The following removes all GENERIC
folding in the code re-constructing a GENERIC component-ref from
the PRE VN IL.

PR tree-optimization/118171
* tree-ssa-pre.cc (create_component_ref_by_pieces_1): Do not
fold any component ref parts.

* gcc.dg/torture/pr118171.c: New testcase.

7 months agoaarch64: Detect word-level modification in early-ra [PR118184]
Richard Sandiford [Thu, 2 Jan 2025 11:34:52 +0000 (11:34 +0000)] 
aarch64: Detect word-level modification in early-ra [PR118184]

REGMODE_NATURAL_SIZE is set to 64 bits for everything except
VLA SVE modes.  This means that it's possible to modify (say)
the highpart of a TI pseudo or a V2DI pseudo independently
of the lowpart.  Modifying such highparts requires a reload
if the highpart ends up in the upper 64 bits of an FPR,
since RTL semantics do not allow the highpart of a single
hard register to be modified independently of the lowpart.

early-ra missed a check for this case, which meant that it
effectively treated an assignment to (subreg:DI (reg:TI R) 0)
as an assignment to the whole of R.

gcc/
PR target/118184
* config/aarch64/aarch64-early-ra.cc (allocno_assignment_is_rmw):
New function.
(early_ra::record_insn_defs): Mark the live range information as
untrustworthy if an assignment would change part of an allocno
but preserve the rest.

gcc/testsuite/
* gcc.dg/torture/pr118184.c: New test.

7 months agoforwprop: Handle RAW_DATA_CST in check_ctz_array
Jakub Jelinek [Thu, 2 Jan 2025 11:29:31 +0000 (12:29 +0100)] 
forwprop: Handle RAW_DATA_CST in check_ctz_array

In order to stress test RAW_DATA_CST handling, I've tested trunk gcc with
r15-6339 reapplied and a hack where I've changed
  const unsigned int raw_data_min_len = 128;
to
  const unsigned int raw_data_min_len = 2;
in cp_lexer_new_main and 64 to 4 several times in c_parser_initval
and c_maybe_optimize_large_byte_initializer, so that RAW_DATA_CST doesn't
trigger just on very large initializers, but even quite small ones.

One of the regressions (will work on the others next) was that pr90838.c
testcase regressed, check_ctz_array needs to handle RAW_DATA_CST, otherwise
on larger initializers or if those come from #embed just won't trigger.
The new testcase shows when it doesn't trigger anymore (regression from 14).

The patch just handles RAW_DATA_CST in the CONSTRUCTOR_ELTS the same as is
it was a series of INTEGER_CSTs.

2025-01-02  Jakub Jelinek  <jakub@redhat.com>

* tree-ssa-forwprop.cc (check_ctz_array): Handle also RAW_DATA_CST
in the CONSTRUCTOR_ELTS.

* gcc.dg/pr90838-2.c: New test.

7 months agoUpdate copyright years.
Jakub Jelinek [Thu, 2 Jan 2025 11:17:04 +0000 (12:17 +0100)] 
Update copyright years.

7 months agoUpdate copyright years.
Jakub Jelinek [Thu, 2 Jan 2025 10:59:57 +0000 (11:59 +0100)] 
Update copyright years.

7 months agoUse u'' instead of '' in libgdiagnostics/conf.py
Jakub Jelinek [Thu, 2 Jan 2025 10:57:40 +0000 (11:57 +0100)] 
Use u'' instead of '' in libgdiagnostics/conf.py

libgdiagnostics/conf.py breaks update-copyright.py --this-year,
which only accepts copyright year in u'' literals in python files,
not in ''.

2025-01-02  Jakub Jelinek  <jakub@redhat.com>

* doc/libgdiagnostics/conf.py: Use u'' instead of '' in
project and copyright initialization.

7 months agoTweak update-copyright.py script
Jakub Jelinek [Thu, 2 Jan 2025 10:53:57 +0000 (11:53 +0100)] 
Tweak update-copyright.py script

When running update-copyright.py --this-year, I've encountered various
failures, this patch works around those.

2025-01-02  Jakub Jelinek  <jakub@redhat.com>

* update-copyright.py (GCCFilter): Ignore gen-evolution.awk and
gen-cxxapi-file.py.
(TestsuiteFilter): Ignore spec-example-4.sarif.
(LibCppFilter): Ignore uname2c.h.

7 months agoUpdate copyright dates.
Jakub Jelinek [Thu, 2 Jan 2025 10:18:39 +0000 (11:18 +0100)] 
Update copyright dates.

Manual part of copyright year updates.

2025-01-02  Jakub Jelinek  <jakub@redhat.com>

gcc/
* gcc.cc (process_command): Update copyright notice dates.
* gcov-dump.cc (print_version): Ditto.
* gcov.cc (print_version): Ditto.
* gcov-tool.cc (print_version): Ditto.
* gengtype.cc (create_file): Ditto.
* doc/cpp.texi: Bump @copying's copyright year.
* doc/cppinternals.texi: Ditto.
* doc/gcc.texi: Ditto.
* doc/gccint.texi: Ditto.
* doc/gcov.texi: Ditto.
* doc/install.texi: Ditto.
* doc/invoke.texi: Ditto.
gcc/ada/
* gnat_ugn.texi: Bump @copying's copyright year.
* gnat_rm.texi: Likewise.
gcc/d/
* gdc.texi: Bump @copyrights-d year.
gcc/fortran/
* gfortranspec.cc (lang_specific_driver): Update copyright notice
dates.
* gfc-internals.texi: Bump @copying's copyright year.
* gfortran.texi: Ditto.
* intrinsic.texi: Ditto.
* invoke.texi: Ditto.
gcc/go/
* gccgo.texi: Bump @copyrights-go year.
libgomp/
* libgomp.texi: Bump @copying's copyright year.
libitm/
* libitm.texi: Bump @copying's copyright year.
libquadmath/
* libquadmath.texi: Bump @copying's copyright year.

7 months agoUpdate Copyright year in ChangeLog files
Jakub Jelinek [Thu, 2 Jan 2025 10:13:18 +0000 (11:13 +0100)] 
Update Copyright year in ChangeLog files

2024 -> 2025

7 months agoRotate ChangeLog files.
Jakub Jelinek [Thu, 2 Jan 2025 10:06:31 +0000 (11:06 +0100)] 
Rotate ChangeLog files.

Rotate ChangeLog files for ChangeLogs with yearly cadence.
Also remove empty lines before Form Feed line.

7 months agoRISC-V: Add testcases for unsigned imm vec SAT_SUB form2~4
xuli [Fri, 13 Dec 2024 04:28:48 +0000 (04:28 +0000)] 
RISC-V: Add testcases for unsigned imm vec SAT_SUB form2~4

Form2:
void __attribute__((noinline))             \
vec_sat_u_sub_imm##IMM##_##T##_fmt_2 (T *out, T *in, unsigned limit)  \
{                                                   \
  unsigned i;                                       \
  for (i = 0; i < limit; i++)                       \
    out[i] = in[i] >= (T)IMM ? in[i] - (T)IMM : 0;  \
}

Form3:
void __attribute__((noinline))             \
vec_sat_u_sub_imm##IMM##_##T##_fmt_3 (T *out, T *in, unsigned limit)  \
{                                                   \
  unsigned i;                                       \
  for (i = 0; i < limit; i++)                       \
    out[i] = (T)IMM > in[i] ? (T)IMM - in[i] : 0;   \
}

Form4:
void __attribute__((noinline))             \
vec_sat_u_sub_imm##IMM##_##T##_fmt_4 (T *out, T *in, unsigned limit)  \
{                                                   \
  unsigned i;                                       \
  for (i = 0; i < limit; i++)                       \
    out[i] = in[i] > (T)IMM ? in[i] - (T)IMM : 0;   \
}

Passed the rv64gcv full regression test.

Signed-off-by: Li Xu <xuli1@eswincomputing.com>
gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_arith.h: add unsigned imm vec sat_sub form2~4.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_data.h: add data for vec sat_sub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-2-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-2-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-2-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-2-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-3-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-3-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-3-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-3-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-4-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-4-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-4-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-4-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-2-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-2-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-2-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-2-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-3-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-3-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-3-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-3-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-4-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-4-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-4-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-run-4-u8.c: New test.

7 months agoLoongArch: Optimize for conditional move operations
Guo Jie [Mon, 30 Dec 2024 02:39:13 +0000 (10:39 +0800)] 
LoongArch: Optimize for conditional move operations

The optimization example is as follows.

From:
  if (condition)
    dest += 1 << 16;
To:
  dest += (condition ? 1 : 0) << 16;

It does not use maskeqz and masknez, thus reducing the number of
instructions.

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_expand_conditional_move): Add some optimization
implementations based on noce_try_cmove_arith.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/conditional-move-opt-1.c: New test.
* gcc.target/loongarch/conditional-move-opt-2.c: New test.

7 months agoLoongArch: Add standard patterns uabd and sabd
Guo Jie [Mon, 30 Dec 2024 07:12:02 +0000 (15:12 +0800)] 
LoongArch: Add standard patterns uabd and sabd

gcc/ChangeLog:

* config/loongarch/lasx.md (lasx_xvabsd_s_<lasxfmt>): Remove.
(<su>abd<mode>3): New insn pattern.
(lasx_xvabsd_u_<lasxfmt_u>): Remove.
* config/loongarch/loongarch-builtins.cc (CODE_FOR_lsx_vabsd_b):
Rename.
(CODE_FOR_lsx_vabsd_h): Ditto.
(CODE_FOR_lsx_vabsd_w): Ditto.
(CODE_FOR_lsx_vabsd_d): Ditto.
(CODE_FOR_lsx_vabsd_bu): Ditto.
(CODE_FOR_lsx_vabsd_hu): Ditto.
(CODE_FOR_lsx_vabsd_wu): Ditto.
(CODE_FOR_lsx_vabsd_du): Ditto.
(CODE_FOR_lasx_xvabsd_b): Ditto.
(CODE_FOR_lasx_xvabsd_h): Ditto.
(CODE_FOR_lasx_xvabsd_w): Ditto.
(CODE_FOR_lasx_xvabsd_d): Ditto.
(CODE_FOR_lasx_xvabsd_bu): Ditto.
(CODE_FOR_lasx_xvabsd_hu): Ditto.
(CODE_FOR_lasx_xvabsd_wu): Ditto.
(CODE_FOR_lasx_xvabsd_du): Ditto.
* config/loongarch/loongarch.md (u): Add smax/umax.
* config/loongarch/lsx.md (SU_MAX): New iterator.
(su_min): New attr.
(lsx_vabsd_s_<lsxfmt>): Remove.
(<su>abd<mode>3): New insn pattern.
(lsx_vabsd_u_<lsxfmt_u>): Remove.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/abd-lasx.c: New test.
* gcc.target/loongarch/abd-lsx.c: New test.

7 months agoLoongArch: Add some vector pack/unpack patterns
Guo Jie [Mon, 30 Dec 2024 02:38:51 +0000 (10:38 +0800)] 
LoongArch: Add some vector pack/unpack patterns

gcc/ChangeLog:

* config/loongarch/lasx.md (vec_unpacks_lo_<mode>): Redefine.
(vec_unpacku_lo_<mode>): Ditto.
(lasx_vext2xv_h<u>_b<u>): Replaced by vec_unpack<su>_lo_v32qi.
(vec_unpack<su>_lo_v32qi): New insn.
(lasx_vext2xv_w<u>_h<u>): Replaced by vec_unpack<su>_lo_v16hi.
(vec_unpack<su>_lo_v16qi_internal): New insn, for 128 bits.
(vec_unpack<su>_lo_v16hi): New insn.
(lasx_vext2xv_d<u>_w<u>): Replaced by vec_unpack<su>_lo_v8si.
(vec_unpack<su>_lo_v8hi_internal): New insn, for 128 bits.
(vec_unpack<su>_lo_v8si): New insn.
(vec_unpack<su>_lo_v4si_internal): New insn, for 128 bits.
(vec_packs_float_v4di): New expander.
(vec_pack_sfix_trunc_v4df): Ditto.
(vec_unpacks_float_hi_v8si): Ditto.
(vec_unpacks_float_lo_v8si): Ditto.
(vec_unpack_sfix_trunc_hi_v8sf): Ditto.
(vec_unpack_sfix_trunc_lo_v8sf): Ditto.
* config/loongarch/loongarch-builtins.cc
(CODE_FOR_lsx_vftintrz_w_d): Rename.
(CODE_FOR_lsx_vftintrzh_l_s): Ditto.
(CODE_FOR_lsx_vftintrzl_l_s): Ditto.
(CODE_FOR_lsx_vffint_s_l): Ditto.
(CODE_FOR_lsx_vffinth_d_w): Ditto.
(CODE_FOR_lsx_vffintl_d_w): Ditto.
(CODE_FOR_lsx_vexth_h_b): Ditto.
(CODE_FOR_lsx_vexth_w_h): Ditto.
(CODE_FOR_lsx_vexth_d_w): Ditto.
(CODE_FOR_lsx_vexth_hu_bu): Ditto.
(CODE_FOR_lsx_vexth_wu_hu): Ditto.
(CODE_FOR_lsx_vexth_du_wu): Ditto.
(CODE_FOR_lsx_vfcvth_d_s): Ditto.
(CODE_FOR_lsx_vfcvtl_d_s): Ditto.
(CODE_FOR_lasx_vext2xv_h_b): Ditto.
(CODE_FOR_lasx_vext2xv_w_h): Ditto.
(CODE_FOR_lasx_vext2xv_d_w): Ditto.
(CODE_FOR_lasx_vext2xv_hu_bu): Ditto.
(CODE_FOR_lasx_vext2xv_wu_hu): Ditto.
(CODE_FOR_lasx_vext2xv_du_wu): Ditto.
(loongarch_expand_builtin_insn): Swap source operands in
CODE_FOR_lsx_vftintrz_w_d and CODE_FOR_lsx_vffint_s_l.
* config/loongarch/loongarch-protos.h
(loongarch_expand_vec_unpack): Remove useless parameter high_p.
* config/loongarch/loongarch.cc (loongarch_expand_vec_unpack):
Rewrite.
* config/loongarch/lsx.md (vec_unpacks_hi_v4sf): Redefine.
(vec_unpacks_lo_v4sf): Ditto.
(vec_unpacks_hi_<mode>): Ditto.
(vec_unpacku_hi_<mode>): Ditto.
(lsx_vfcvth_d_s): Replaced by vec_unpacks_hi_v4sf.
(lsx_vfcvtl_d_s): Replaced by vec_unpacks_lo_v4sf.
(lsx_vffint_s_l): Replaced by vec_packs_float_v2di.
(vec_packs_float_v2di): New insn.
(lsx_vftintrz_w_d): Replaced by vec_pack_sfix_trunc_v2df.
(vec_pack_sfix_trunc_v2df): New insn.
(lsx_vffinth_d_w): Replaced by vec_unpacks_float_hi_v4si.
(vec_unpacks_float_hi_v4si): New insn.
(lsx_vffintl_d_w): Replaced by vec_unpacks_float_lo_v4si.
(vec_unpacks_float_lo_v4si): New insn.
(lsx_vftintrzh_l_s): Replaced by vec_unpack_sfix_trunc_hi_v4sf.
(vec_unpack_sfix_trunc_hi_v4sf): New insn.
(lsx_vftintrzl_l_s): Replaced by vec_unpack_sfix_trunc_lo_v4sf.
(vec_unpack_sfix_trunc_lo_v4sf): New insn.
(lsx_vexth_h<u>_b<u>): Replaced by vec_unpack<su>_hi_v16qi.
(vec_unpack<su>_hi_v16qi): New insn.
(lsx_vexth_w<u>_h<u>): Replaced by vec_unpack<su>_hi_v8hi.
(vec_unpack<su>_hi_v8hi): New insn.
(lsx_vexth_d<u>_w<u>): Replaced by vec_unpack<su>_hi_v4si.
(vec_unpack<su>_hi_v4si): New insn.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vec_pack_unpack_128.c: New test.
* gcc.target/loongarch/vec_pack_unpack_256.c: New test.

7 months agoLoongArch: Adjust insn patterns for better combine
Guo Jie [Mon, 30 Dec 2024 02:38:35 +0000 (10:38 +0800)] 
LoongArch: Adjust insn patterns for better combine

For some instruction patterns with commutative operands,
the order of operands needs to be adjusted to match the rules.

gcc/ChangeLog:

* config/loongarch/loongarch.md
(bytepick_d_<bytepick_imm>_rev): New combiner.
(bstrpick_alsl_paired): Reorder input operands.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/bstrpick_alsl_paired.c: New test.
* gcc.target/loongarch/bytepick_combine.c: New test.

7 months agoLoongArch: Fix bugs in insn patterns lasx_xvrepl128vei_b/h/w/d_internal
Guo Jie [Mon, 30 Dec 2024 02:37:57 +0000 (10:37 +0800)] 
LoongArch: Fix bugs in insn patterns lasx_xvrepl128vei_b/h/w/d_internal

There are two aspects that affect the matching of instruction templates:

1. vec_duplicate is redundant in the following operations.
    set (match_operand:V4DI ...)
(vec_duplicate:V4DI (vec_select:V4DI ...))

2. The range of values for testing predicate const_8_to_15_operand and
const_16_to_31_operand should be [8, 15] and [16, 31] respectively.

However, there is currently no suitable testcase to verify.

gcc/ChangeLog:

* config/loongarch/lasx.md: Remove useless vec_select.
* config/loongarch/predicates.md: Correct error predicate.

7 months agoLoongArch: Fix selector error in lasx_xvexth_h/w/d* patterns
Guo Jie [Mon, 30 Dec 2024 02:37:18 +0000 (10:37 +0800)] 
LoongArch: Fix selector error in lasx_xvexth_h/w/d* patterns

The xvexth related instructions operate SEPARATELY according to
the high and low 128 bits, and sign/zero extend the upper half
of every 128 bits in src to the corresponding 128 bits in dest.

For xvexth.d.w, the rule for the first element of dest should be:
    dest.D[0] = sign_extend (src.W[2] ,64);
instead of:
    dest.D[0] = sign_extend (src.W[4] ,64);

gcc/ChangeLog:

* config/loongarch/lasx.md: Fix selector index.

7 months agoLoongArch: Remove useless UNSPECs and define_mode_attrs
Guo Jie [Mon, 30 Dec 2024 02:34:56 +0000 (10:34 +0800)] 
LoongArch: Remove useless UNSPECs and define_mode_attrs

gcc/ChangeLog:

* config/loongarch/lasx.md: Remove useless code.
* config/loongarch/lsx.md: Ditto.

7 months agoDaily bump.
GCC Administrator [Thu, 2 Jan 2025 00:19:02 +0000 (00:19 +0000)] 
Daily bump.

7 months agodoc: cpp: fix version test example syntax
Sam James [Wed, 1 Jan 2025 17:16:17 +0000 (17:16 +0000)] 
doc: cpp: fix version test example syntax

gcc/ChangeLog:

* doc/cpp.texi (Common Predefined Macros): Fix syntax.

7 months agomiddle-end/118174 - bogus TER of tailcall
Richard Biener [Tue, 31 Dec 2024 13:47:03 +0000 (14:47 +0100)] 
middle-end/118174 - bogus TER of tailcall

The following avoids applying TER to direct internal functions that
are tailcall since the involved expansion code path doesn't honor
TER constraints.

PR middle-end/118174
* tree-outof-ssa.cc (ssa_is_replaceable_p): Exclude tailcalls.

* gcc.dg/torture/pr118174.c: New testcase.

7 months agoFortran: Fix Texinfo warnings building the manual.
Sandra Loosemore [Sat, 28 Dec 2024 16:29:44 +0000 (16:29 +0000)] 
Fortran: Fix Texinfo warnings building the manual.

gcc/fortran/ChangeLog
* gfortran.texi (Function ABI Documentation): Make menu ordering
consistent with subsection ordering.

7 months agoFortran: Fix that/which usage in the manual.
Sandra Loosemore [Sat, 28 Dec 2024 03:51:50 +0000 (03:51 +0000)] 
Fortran: Fix that/which usage in the manual.

In English usage, "that" introduces a restrictive clause while "which"
introduces a non-restrictive or descriptive clause.  "That" is almost
never preceded by a comma while "which" often is.  The Fortran manual
had many instances where these uses were reversed, or where a comma
was used with "that"; this patch fixes them.  In some cases I have
substituted less convoluted wording instead.

gcc/fortran/ChangeLog
* gfortran.texi: Clean up that/which usage throughout the file.
* intrinsic.texi: Likewise.
* invoke.texi: Likewise.

7 months agoFortran: Grammar/markup fixes in intrinsics documentation
Sandra Loosemore [Fri, 27 Dec 2024 20:45:14 +0000 (20:45 +0000)] 
Fortran: Grammar/markup fixes in intrinsics documentation

Continuing a series of patches to tidy the Fortran manual, this
installment fixes problems with inappropriate use of future tense and
adds some missing markup I noticed in passing.

gcc/fortran/ChangeLog
* intrinsic.texi: Grammar and markup fixes throughout
the file.

7 months agoDocumentation: Fix Machine-Dependent Options ordering
Sandra Loosemore [Mon, 30 Dec 2024 19:53:50 +0000 (19:53 +0000)] 
Documentation: Fix Machine-Dependent Options ordering

Per comments in invoke.texi, target option groups in the Option
Summary section are supposed to be alphabetized and in the same order
as the documentation sections they refer to.  "M32C Options" was
misordered in the Option Summary.  "Cygwin and MinGW Options" was
ordered incorrectly in both places, which also caused Texinfo
diagnostics because the ordering in the menu (which was correctly
alphabetized) didn't match the node order.

I also added a reference to the appropriate section to each entry in
the Option Summary so that you can go directly to the detailed
description for that set of target options.  I'm not real happy with
the formatting of the tables in that section but the experiments I
tried all looked worse.  :-(

gcc/ChangeLog
* doc/invoke.texi (Option Summary): Put "M32C Options" and
"Cygwin and MinGW Options" in alphabetical order.  Add
cross-references.
(Cygwin and MinGW Options): Likewise move the section to its
correct alphabetical location.
* config/lynx.opt.urls: Regenerated.
* config/mingw/cygming.opt.urls: Regenerated.

7 months agolibstdc++: Delete further Profile Mode leftovers
Gerald Pfeifer [Wed, 1 Jan 2025 01:05:02 +0000 (09:05 +0800)] 
libstdc++: Delete further Profile Mode leftovers

Commit 544be2beb1fa in 2019 remove Profile Mode and associated docs.
Now also remove generated HTML files.

libstdc++-v3:
* doc/html/manual/profile_mode.html: Delete.
* doc/html/manual/profile_mode_api.html: Ditto.
* doc/html/manual/profile_mode_cost_model.html: Ditto.
* doc/html/manual/profile_mode_design.html: Ditto.
* doc/html/manual/profile_mode_devel.html: Ditto.
* doc/html/manual/profile_mode_impl.html: Ditto.

7 months agoDaily bump.
GCC Administrator [Wed, 1 Jan 2025 00:18:07 +0000 (00:18 +0000)] 
Daily bump.

7 months agoLoongArch: Implement vector cbranch optab for LSX and LASX
Jiahao Xu [Wed, 25 Dec 2024 09:59:36 +0000 (17:59 +0800)] 
LoongArch: Implement vector cbranch optab for LSX and LASX

In order to support vectorization of loops with multiple exits, this
patch adds the implementation of the conditional branch optab for
LoongArch LSX/LASX instructions.

This patch causes the gen-vect-{2,25}.c tests to fail.  This is because
the support for vectorizing loops with multiple exits has vectorized
the loop checking the results.  The failure is due to an issue in the
test case's own implementation.

gcc/ChangeLog:

* config/loongarch/simd.md (cbranch<mode>4): New expander.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_vect_early_break_hw,
check_effective_target_vect_early_break): Support LoongArch LSX.
* gcc.target/loongarch/vector/lasx/lasx-vseteqz.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-vseteqz.c: New test.

Co-authored-by: Deng Jianbo <dengjianbo@loongson.cn>
7 months ago[PATCH v2] varasm: Use native_encode_rtx for constant vectors.
Robin Dapp [Tue, 31 Dec 2024 06:47:53 +0000 (23:47 -0700)] 
[PATCH v2] varasm: Use native_encode_rtx for constant vectors.

optimize_constant_pool hashes vector masks by native_encode_rtx and
merges identically hashed values in the constant pool.  Afterwards the
optimized values are written in output_constant_pool_2.

However, native_encode_rtx and output_constant_pool_2 disagree in their
encoding of vector masks:  native_encode_rtx does not pad with zeroes
while output_constant_pool_2 implicitly does.

In RVV's shuffle-evenodd-run.c there are two masks
  (a) "0101" for V4BI
  (b) "01010101" for V8BI and
that have the same representation/encoding ("1010101") in native_encode_rtx.
output_constant_pool_2 uses "101" for (a) and "1010101" for (b).

Now, optimize_constant_pool might happen to merge both masks using
(a) as representative.  Then, output_constant_pool_2 will output "1010"
which is only valid for the second mask as the implicit zero padding
doesn't agree with (b).
(b)'s "1010101" works for both masks as a V4BI load will ignore the last four
padding bits.

This patch makes output_constant_pool_2 use native_encode_rtx so both
functions will agree on an encoding and output the correct constant.

PR target/118036
gcc/ChangeLog:

* varasm.cc (output_constant_pool_2): Use native_encode_rtx for
building the memory image of a const vector mask.

7 months ago[RISC-V][PR target/115375] Fix expected dump output
Jeff Law [Tue, 31 Dec 2024 06:40:58 +0000 (23:40 -0700)] 
[RISC-V][PR target/115375] Fix expected dump output

Several months ago changes were made to the vectorizer which mucked up several
of the scan tests.  All but one of the cases in pr115375 have since been fixed.

The remaining failure seems to be primarily a debugging dump issue -- we're
still selecting the same lmul values.  This patch adjusts the dump scan
appropriately.

PR target/115375

gcc/testsuite

* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c: Adjust expected
output.

7 months agoDaily bump.
GCC Administrator [Tue, 31 Dec 2024 00:18:15 +0000 (00:18 +0000)] 
Daily bump.

7 months ago[PR testsuite/114182] Fix minor testsuite issue when double == float
Jeff Law [Mon, 30 Dec 2024 23:14:29 +0000 (16:14 -0700)] 
[PR testsuite/114182] Fix minor testsuite issue when double == float

This is a minor testsuite adjustment

attr-complex-method-2.c selects between two scan-tree-dump clauses based on
avr, !avr.  But what they really should be checking is "large_double" that way
it works for avr, h8, rl78 and any other target which makes doubles the same
size as floats.

attr-complex-method.c should be doing the same thing.

After this change avr passes attr-complex-method.c and the rl78 and h8 ports
will pass both tests.  Other targets in my tester are unaffected.

PR testsuite/114182

gcc/testsuite/

* gcc.c-torture/compile/attr-complex-method.c: Use
"large_double" to select between scan outputs.
* gcc.c-torture/compile/attr-complex-method-2.c: Similarly.

7 months ago[RISC-V][PR target/106544] Avoid ICEs due to bogus asms
Jeff Law [Mon, 30 Dec 2024 20:51:55 +0000 (13:51 -0700)] 
[RISC-V][PR target/106544] Avoid ICEs due to bogus asms

This is a fix for a bug Andrew P filed a while back where essentially a poorly
crafted asm statement could trigger a ICE during assembly output.  Various
cases will use INTVAL (op) without verifying the operand is a CONST_INT node
first.

The usual way to handle this is via output_operand_lossage, which this patch
implements.

I focused primarily on the CONST_INT cases, there could well be other problems
in this space, if so they should get distinct bugs with testcases.

Tested in my tester on rv32 and rv64.  Waiting for pre-commit testing before
moving forward.

PR target/106544
gcc/

* config/riscv/riscv.cc (riscv_print_operand): Issue an error for
invalid operands rather than invalidly accessing INTVAL of an
object that is not a CONST_INT.  Fix one error string for 'N'.

gcc/testsuite
* gcc.target/riscv/pr106544.c: New test.

7 months agoFortran: Implement f_c_string function.
Steven G. Kargl [Sun, 29 Dec 2024 22:19:18 +0000 (14:19 -0800)] 
Fortran: Implement f_c_string function.

Fortran 2023 has added the new intrinsic function F_C_STRING to
convert fortran strings of default character kind to a null
terminated C string.

Contributions from Steve Kargl, Harald Anlauf, FX Coudert, Mikael Morin,
and Jerry DeLisle.

PR fortran/117643

gcc/fortran/ChangeLog:

* check.cc (gfc_check_f_c_string): Check arguments of f_c_string().
* gfortran.h (enum gfc_isym_id): New symbol GFC_ISYM_F_C_STRING.
* intrinsic.cc (add_functions): Add the ISO C Binding routine f_c_string().
Wrap nearby long line to less than 80 characters.
* intrinsic.h (gfc_check_f_c_string): Prototype for gfc_check_f_c_string().
* iso-c-binding.def (NAMED_FUNCTION): Declare for ISO C Binding
routine f_c_string().
* primary.cc (gfc_match_rvalue): Fix comment that has been untrue since 2011.
Add ISOCBINDING_F_C_STRING to conditional.
* trans-intrinsic.cc (conv_trim): Specialized version of trim() for
f_c_string().
(gfc_conv_intrinsic_function): Use GFC_ISYM_F_C_STRING to trigger in-lining.

gcc/testsuite/ChangeLog:

* gfortran.dg/f_c_string1.f90: New test.
* gfortran.dg/f_c_string2.f90: New test.

7 months ago[RISC-V][PR target/118122] Fix modes in recently added risc-v pattern
Jeff Law [Mon, 30 Dec 2024 14:40:07 +0000 (07:40 -0700)] 
[RISC-V][PR target/118122] Fix modes in recently added risc-v pattern

The new pattern to optimize certain code sequences on RISC-V played things a
bit fast and loose with modes -- some operands were using the ALLI iterator
while the scratch used X and the split codegen used X.

Naturally under the "right" circumstances this would trigger an ICE due to
mismatched modes.  This patch uses X consistently in that pattern. It also
fixes some formatting nits.

Tested in my tester, but waiting on the pre-commit verdict before moving
forward.

PR target/118122
gcc/
* config/riscv/riscv.md (lui_constraint<X:mode>_and_to_or): Use
X iterator rather than ANYI consistently.  Fix formatting.

gcc/testsuite

* gcc.target/riscv/pr118122.c: New test.

7 months agoaarch64: Add mf8 data movement intrinsics
Richard Sandiford [Mon, 30 Dec 2024 12:50:56 +0000 (12:50 +0000)] 
aarch64: Add mf8 data movement intrinsics

This patch adds mf8 variants of what I'll loosely call the existing
"data movement" intrinsics, including the recent FEAT_LUT ones.
I think this completes the FP8 intrinsic definitions.

The new intrinsics are defined entirely in the compiler.  This should
make it easy to move the existing non-mf8 variants into the compiler
as well, but that's too invasive for stage 3 and so is left to GCC 16.

I wondered about trying to reduce the cut-&-paste in the .def file,
but in the end decided against it.  I have a plan for specifying this
information in a different format, but again that would need to wait
until GCC 16.

The patch includes some support for gimple folding.  I initially
tested the patch without it, so that all the rtl expansion code
was exercised.

vlut.c fails for all types with big-endian ILP32, but that's
for a later patch.

gcc/
* config/aarch64/aarch64.md (UNSPEC_BSL, UNSPEC_COMBINE, UNSPEC_DUP)
(UNSPEC_DUP_LANE, UNSPEC_GET_LANE, UNSPEC_LD1_DUP, UNSPEC_LD1x2)
(UNSPEC_LD1x3, UNSPEC_LD1x4, UNSPEC_SET_LANE, UNSPEC_ST1_LANE)
(USNEPC_ST1x2, UNSPEC_ST1x3, UNSPEC_ST1x4, UNSPEC_VCREATE)
(UNSPEC_VEC_COPY): New unspecs.
* config/aarch64/iterators.md (UNSPEC_TBL): Likewise.
* config/aarch64/aarch64-simd-pragma-builtins.def: Add definitions
of the mf8 data movement intrinsics.
* config/aarch64/aarch64-protos.h
(aarch64_advsimd_vector_array_mode): Declare.
* config/aarch64/aarch64.cc
(aarch64_advsimd_vector_array_mode): Make public.
* config/aarch64/aarch64-builtins.h (qualifier_const_pointer): New
aarch64_type_qualifiers member.
* config/aarch64/aarch64-builtins.cc (AARCH64_SIMD_VGET_LOW_BUILTINS)
(AARCH64_SIMD_VGET_HIGH_BUILTINS): Add mf8 variants.
(aarch64_int_or_fp_type): Handle qualifier_modal_float.
(aarch64_num_lanes): New function.
(binary_two_lanes, load, load_lane, store, store_lane): New signatures.
(unary_lane): Likewise.
(simd_type::nunits): New member function.
(simd_types): Add pointer types.
(aarch64_fntype): Handle the new signatures.
(require_immediate_lane_index): Use aarch64_num_lanes.
(aarch64_pragma_builtins_checker::check): Handle the new intrinsics.
(aarch64_convert_address): (aarch64_dereference_pointer):
(aarch64_canonicalize_lane, aarch64_convert_to_lane_mask)
(aarch64_pack_into_v128s, aarch64_expand_permute_pair)
(aarch64_expand_tbl_tbx): New functions.
(aarch64_expand_pragma_builtin): Handle the new intrinsics.
(aarch64_force_gimple_val, aarch64_copy_vops, aarch64_fold_to_val)
(aarch64_dereference, aarch64_get_lane_bit_index, aarch64_get_lane)
(aarch64_set_lane, aarch64_fold_combine, aarch64_fold_load)
(aarch64_fold_store, aarch64_ext_index, aarch64_rev_index)
(aarch64_trn_index, aarch64_uzp_index, aarch64_zip_index)
(aarch64_fold_permute): New functions, some split out from
aarch64_general_gimple_fold_builtin.
(aarch64_gimple_fold_pragma_builtin): New function.
(aarch64_general_gimple_fold_builtin): Use the new functions above.
* config/aarch64/aarch64-simd.md (aarch64_dup_lane<mode>)
(aarch64_dup_lane_<vswap_width_name><mode>): Add "@" to name.
(aarch64_simd_vec_set<mode>): Likewise.
(*aarch64_simd_vec_copy_lane_<vswap_width_name><mode>): Likewise.
(aarch64_simd_bsl<mode>): Likewise.
(aarch64_combine<mode>): Likewise.
(aarch64_cm<optab><mode><vczle><vczbe>): Likewise.
(aarch64_simd_ld2r<vstruct_elt>): Likewise.
(aarch64_vec_load_lanes<mode>_lane<vstruct_elt>): Likewise.
(aarch64_simd_ld3r<vstruct_elt>): Likewise.
(aarch64_simd_ld4r<vstruct_elt>): Likewise.
(aarch64_ld1x3<vstruct_elt>): Likewise.
(aarch64_ld1x4<vstruct_elt>): Likewise.
(aarch64_st1x2<vstruct_elt>): Likewise.
(aarch64_st1x3<vstruct_elt>): Likewise.
(aarch64_st1x4<vstruct_elt>): Likewise.
(aarch64_ld<nregs><vstruct_elt>): Likewise.
(aarch64_ld1<VALL_F16: Likewise.mode>): Likewise.
(aarch64_ld1x2<vstruct_elt>): Likewise.
(aarch64_ld<nregs>_lane<vstruct_elt>): Likewise.
(aarch64_<PERMUTE: Likewise.perm_insn><mode><vczle><vczbe>): Likewise.
(aarch64_ext<mode>): Likewise.
(aarch64_rev<REVERSE: Likewise.rev_op><mode><vczle><vczbe>): Likewise.
(aarch64_st<nregs><vstruct_elt>): Likewise.
(aarch64_st<nregs>_lane<vstruct_elt>): Likewise.
(aarch64_st1<VALL_F16: Likewise.mode>): Likewise.

gcc/testsuite/
* gcc.target/aarch64/advsimd-intrinsics/arm-neon-ref.h: Add mfloat8
support.
* gcc.target/aarch64/advsimd-intrinsics/compute-ref-data.h: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vbsl.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vcombine.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vcreate.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vdup-vmov.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vdup_lane.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vext.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vget_high.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vld1.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vld1_dup.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vld1_lane.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vld1x2.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vld1x3.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vld1x4.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vldX.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vldX_dup.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vldX_lane.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vrev.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vset_lane.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vshuffle.inc: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vst1_lane.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vst1x2.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vst1x3.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vst1x4.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vstX_lane.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vtbX.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vtrn.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vtrn_half.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vuzp.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vuzp_half.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vzip.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vzip_half.c: Likewise.
* gcc.target/aarch64/simd/lut.c: Likewise.
* gcc.target/aarch64/vdup_lane_1.c: Likewise.
* gcc.target/aarch64/vdup_lane_2.c: Likewise.
* gcc.target/aarch64/vdup_n_1.c: Likewise.
* gcc.target/aarch64/vect_copy_lane_1.c: Likewise.
* gcc.target/aarch64/simd/mf8_data_1.c: New test.
* gcc.target/aarch64/simd/mf8_data_2.c: Likewise.

Co-authored-by: Saurabh Jha <saurabh.jha@arm.com>
7 months agoaarch64: Add missing makefile dependency
Richard Sandiford [Mon, 30 Dec 2024 12:50:56 +0000 (12:50 +0000)] 
aarch64: Add missing makefile dependency

gcc/
* config/aarch64/t-aarch64 (aarch64-builtins.o): Depend on
aarch64-simd-pragma-builtins.def.

7 months agoaarch64: Use mf8 instead of f8 in builtin definitions
Richard Sandiford [Mon, 30 Dec 2024 12:50:55 +0000 (12:50 +0000)] 
aarch64: Use mf8 instead of f8 in builtin definitions

The intrinsic type suffix for modal floating-point types is _mf8,
so it's more convenient if we use that for the simd_types as well.

gcc/
* config/aarch64/aarch64-builtins.cc (simd_types::f8): Rename to...
(simd_types::mf8): ...this.
* config/aarch64/aarch64-simd-pragma-builtins.def: Update accordingly.

7 months agoaarch64: Macroise simd_type definitions
Richard Sandiford [Mon, 30 Dec 2024 12:50:55 +0000 (12:50 +0000)] 
aarch64: Macroise simd_type definitions

This patch tries to regularise the definitions of the new pragma
simd types.  Not all of the new types are currently used, but they
will be by later patches.

gcc/
* config/aarch64/aarch64-builtins.cc (simd_types): Use one macro
invocation for each element type.

7 months agoDon't include subst attributes in "@" md helpers
Richard Sandiford [Mon, 30 Dec 2024 12:50:54 +0000 (12:50 +0000)] 
Don't include subst attributes in "@" md helpers

In a later patch, I need to add "@" to a pattern that uses subst
attributes.  This combination is problematic for two reasons:

(1) define_substs are applied and filtered at a later stage than the
    handling of "@" patterns, so that the handling of "@" patterns
    doesn't know which subst variants are valid and which will later be
    dropped.  Just adding a "@" therefore triggers a build error due to
    references to non-existent patterns.

(2) Currently, the code will treat a single "@" pattern as contributing
    to a single set of overloaded functions.  These overloaded functions
    will have an integer argument for every subst attribute.  For example,
    the vczle and vczbe in:

      "@aarch64_rev<REVERSE:rev_op><mode><vczle><vczbe>"

    are subst attributes, and so currently we'd try to generate a
    single set of overloads that take four arguments: one for rev_op,
    one for the mode, one for vczle, and one for vczbe.  The gen_*
    and maybe_gen_* functions will also have one rtx argument for
    each operand in the original pattern.

    This model doesn't really make sense for define_substs, since
    define_substs are allowed to add extra operands to an instruction.
    The number of rtx operands to the generators would then be
    incorrect.

I think a more sensible way of handling define_substs would be to
apply them first (and thus expand things like <vczle> and <vczbe>
above) and then apply "@".  However, that's a relatively invasive
change and not suitable for stage 3.

This patch instead skips over subst attributes and restricts "@"
overload handling to the cases where no define_subst is applied.
I looked through all uses of "@" names in target code and there
seemed to be only one current use of "@" with define_substs,
in x86 vector code.  The current behaviour seemed to be unwanted there,
and the x86 code was having to work around it.

gcc/
* read-rtl.cc (md_reader::handle_overloaded_name): Don't add
arguments for uses of subst attributes.
(apply_iterators): Only add instructions to an overloaded helper
if they use the default subst iterator values.
* doc/md.texi: Update documentation accordingly.
* config/i386/i386-expand.cc (expand_vec_perm_broadcast_1): Update
accordingly.

7 months agoavoid-store-forwarding: fix reg init on load-eliminiation [PR117835]
kelefth [Mon, 16 Dec 2024 13:36:59 +0000 (14:36 +0100)] 
avoid-store-forwarding: fix reg init on load-eliminiation [PR117835]

During the initialization of the base register for the zero-offset
store, in the case that we are eliminating the load, we used a
paradoxical subreg assuming that we don't care about the higher bits
of the register. This led to writing wrong values when we were not
updating the whole register.

This patch fixes the issue by zero-extending the value stored in the
base register instead of using a paradoxical subreg.

Bootstrapped/regtested on x86 and AArch64.

PR rtl-optimization/117835
PR rtl-optimization/117872

gcc/ChangeLog:

* avoid-store-forwarding.cc
(store_forwarding_analyzer::process_store_forwarding):
Zero-extend the value stored in the base register instead of
using a paradoxical subreg.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr117835.c: New test.

7 months agoMMIX: Correct handling of C23 (...) functions, PR117618
Hans-Peter Nilsson [Sun, 29 Dec 2024 07:14:14 +0000 (08:14 +0100)] 
MMIX: Correct handling of C23 (...) functions, PR117618

This commit fixes a MMIX C23 (...)-handling bug; failing
gcc.dg/c23-stdarg-[46789].c execution tests.   But, this
isn't about a missing "|| arg.type != NULL_TREE" in the
PORT_setup_incoming_varargs function like most other
PR114175 port bugs exposed by the gcc.dg/c23-stdarg-6.c
.. -9.c tests; the MMIX port passes struct-return-values in
a register.  But, the bug is somewhat similar.

This bug seems like it was added already in
r13-3549-g4fe34cdcc80ac2, by incorrectly handling
TYPE_NO_NAMED_ARGS_STDARG_P-functions ((...)-functions);
counting them as having one parameter instead of none.  That
"+ 1" below is a kind-of hidden function_arg_advance call,
which shouldn't happen for (...)-functions.

PR target/117618
* config/mmix/mmix.cc (mmix_setup_incoming_varargs):
Correct handling of C23 (...)-functions.

7 months agotree-optimization: Fix ICE in tree-parloops.cc reduction_phi() [PR118205]
Lewis Hyatt [Thu, 26 Dec 2024 15:58:57 +0000 (10:58 -0500)] 
tree-optimization: Fix ICE in tree-parloops.cc reduction_phi() [PR118205]

Prior to r15-6001, reduction_phi() could be called with the PHI parameter
not actually being a gphi*. The search through reduction_list would fail and
return NULL. r15-6001 added a requirement that PHI actually be a gphi*, but
did not add a check for this. The PR shows an example where the check is
needed; fix by explicitly returning NULL in this case.

gcc/ChangeLog:

PR tree-optimization/118205
* tree-parloops.cc (reduction_phi): Return NULL if PHI parameter is
not a phi node.

gcc/testsuite/ChangeLog:

PR tree-optimization/118205
* c-c++-common/pr118205.c: New test.

7 months agoDaily bump.
GCC Administrator [Mon, 30 Dec 2024 00:17:12 +0000 (00:17 +0000)] 
Daily bump.

7 months ago[RISC-V] [V2] [PR target/116715] Remove bogus bitmanip pattern
Jeff Law [Sun, 29 Dec 2024 23:34:52 +0000 (16:34 -0700)] 
[RISC-V] [V2] [PR target/116715] Remove bogus bitmanip pattern

So for this bug we have what appears to me to just be a bogus pattern.

Essentially the pattern tries to detect cases where we have an SI mode value
and we can use the Zbs instructions to manipulate a bit. Conceptually that's
great.

The problem is the pattern assumes that SI objects are sign extended. It uses a
test to try and filter out a problematical case (subregs), but that simply
won't work with late-combine since the subreg will be stripped away and we have
no way of knowing if the SI value was already sign extended to 64 bits or not.

You might think we could look for a way to salvage the pattern and make it only
usable prior to register allocation.  I pondered that extensively, but
ultimately concluded that with the introduction of ext-dce it wasn't safe.

So this just removes the problematical pattern.  Thankfully there aren't any
regressions in the testsuite.  Even the test designed to test this pattern's
applicability still generates the desired code.

Changes since v1:
  - Adjust testcase so that it works for rv32 and rv64.
  - Adjust PR number in subject line.

PR target/116715
gcc/
* config/riscv/bitmanip.md: Drop bogus pattern.

gcc/testsuite
* gcc.target/riscv/pr116715.c: New test.

7 months agoAdd support to provide libiberty mkstemps in gcc
John David Anglin [Sun, 29 Dec 2024 19:38:09 +0000 (14:38 -0500)] 
Add support to provide libiberty mkstemps in gcc

2024-12-28  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

PR target/118121
* configure.ac: Check for mkstemps declaration.
* configure: Regenerate.
* config.in: Regenerate.

include/ChangeLog:

* libiberty.h (mkstemps): Declare

7 months ago[PR target/116720] Fix test for valid mempair operands
Jeff Law [Sun, 29 Dec 2024 15:27:30 +0000 (08:27 -0700)] 
[PR target/116720] Fix test for valid mempair operands

So this BZ is a case where we incorrectly indicated that the operand array was
suitable for the t-head load/store pair instructions.

In particular there's a test which checks alignment, but that happens *before*
we know if the operands are going to be reversed.  So the routine reported the
operands are suitable.

At a later point the operands have been reversed into the proper order and we
realize the alignment test should have failed, resulting in the unrecognized
insn.

This fixes the code by moving the reversal check earlier and actually swapping
the local variables with the operands.  That in turn allows for simpler testing
of alignments, ordering, etc.

I've tested this on rv32 and rv64 in my tester.  I don't offhand know if the
patch from Filip that's been causing headaches for the RISC-V port has been
reverted/fixed.  So there's a nonzero chance the pre-commit CI tester will
fail.  I'll keep an eye on it and act appropriately.

PR target/116720
gcc/
* config/riscv/thead.cc (th_mempair_operands_p): Test for
aligned memory after swapping operands.  Simplify test for
first memory access as well.

gcc/testsuite/
* gcc.target/riscv/pr116720.c: New test.

7 months agolibstdc++: Delete leftover from Profile Mode removal
Gerald Pfeifer [Sun, 29 Dec 2024 13:44:50 +0000 (21:44 +0800)] 
libstdc++: Delete leftover from Profile Mode removal

Commit 544be2beb1fa in 2019 remove Profile Mode and associated docs
including the XML version of profile_mode_diagnostics.html. Somehow
the latter survived until now. Simply delete it as well.

libstdc++-v3:
* doc/html/manual/profile_mode_diagnostics.html: Delete.

7 months agolibstdc++-v3/testsuite/.../year_month_day/3.cc, 4.cc: Cut down for simulators
Hans-Peter Nilsson [Sun, 29 Dec 2024 02:32:04 +0000 (03:32 +0100)] 
libstdc++-v3/testsuite/.../year_month_day/3.cc, 4.cc: Cut down for simulators

These two long-running tests happened to fail for me when
run in parallel (nprocs - 1) compared to a serial run, for
target mmix on my laptop.  The runtime is 3m40s for 3.cc
before this change, and 0.9s afterwards.

* testsuite/std/time/year_month_day/3.cc (test01): Add ifdeffery to
limit the tested dates.  For simulators, pass start and end dates
limiting the tested range to 100000 days, centered on days (0).
* testsuite/std/time/year_month_day/4.cc: Ditto.

7 months agoDaily bump.
GCC Administrator [Sun, 29 Dec 2024 00:16:51 +0000 (00:16 +0000)] 
Daily bump.

7 months agoc++/modules: Fallback to ftruncate if posix_fallocate fails [PR115008]
Nathaniel Shead [Sat, 21 Dec 2024 12:42:28 +0000 (23:42 +1100)] 
c++/modules: Fallback to ftruncate if posix_fallocate fails [PR115008]

Depending on the libc and filesystem, in cases where posix_fallocate
cannot do an efficient preallocation it may return EINVAL.  In such a
case we should fall back to ftruncate instead.

Apparently, depending on the system the use of posix_fallocate can have
a noticeable speedup over ftruncate in general (depending on the system)
so it probably isn't worth it to use ftruncate in all cases.

PR c++/100358
PR c++/115008

gcc/cp/ChangeLog:

* module.cc (elf_out::create_mapping): Fallback to ftruncate if
posix_fallocate fails.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
7 months agoc++: Don't treat lambda typedef as lambda declaration [PR106221]
Nathaniel Shead [Sat, 21 Dec 2024 14:18:16 +0000 (01:18 +1100)] 
c++: Don't treat lambda typedef as lambda declaration [PR106221]

I noticed that in a couple of places we sometimes treat any TYPE_DECL of
lambda type as defining a lambda, which isn't always true since C++20:
in `using T = decltype([]{})`, T is not a lambda-declaration.

PR c++/106221
PR c++/110680

gcc/cp/ChangeLog:

* pt.cc (check_default_tmpl_args): Check this is actually a
lambda declaration and not just a typedef.
(push_template_decl): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval19.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
7 months agogimple-fold: Fix up fold_array_ctor_reference RAW_DATA_CST handling [PR118207]
Jakub Jelinek [Sat, 28 Dec 2024 14:42:56 +0000 (15:42 +0100)] 
gimple-fold: Fix up fold_array_ctor_reference RAW_DATA_CST handling [PR118207]

The following testcases ICE because fold_array_ctor_reference in the
RAW_DATA_CST handling just return build_int_cst without actually checking
that if type is non-NULL, TREE_TYPE (val) is uselessly convertible to it.

By falling through the code after it without *suboff += we get everything
we need, the two if conditionals will never be true (we've already
checked that size == BITS_PER_UNIT and so can't be 0, and val will be
INTEGER_CST), but it will do the important fold_ctor_reference call
which will deal with type incompatibilities.

2024-12-28  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/118207
* gimple-fold.cc (fold_array_ctor_reference): For RAW_DATA_CST,
just set val to build_int_cst and fall through to the normal
element handling code instead of returning build_int_cst right away.

* gcc.dg/pr118207.c: New test.

7 months agolibstdc++: Fix up pr118196.cc test [PR118196]
Jakub Jelinek [Sat, 28 Dec 2024 07:50:28 +0000 (08:50 +0100)] 
libstdc++: Fix up pr118196.cc test [PR118196]

The test used #include "<generator>", so FAILed everywhere with
fatal error: <generator>: No such file or directory

2024-12-28  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/118196
* testsuite/24_iterators/range_generators/pr118196.cc: Include
<generator> rather than "<generator>".

7 months agodoc: Simplify references to PTFs for AIX
Gerald Pfeifer [Fri, 27 Dec 2024 08:11:53 +0000 (16:11 +0800)] 
doc: Simplify references to PTFs for AIX

gcc:
* doc/install.texi (Specific) <*-ibm-aix*>: Drop verbose
references to PTFs for AIX.

7 months agoDaily bump.
GCC Administrator [Sat, 28 Dec 2024 00:16:40 +0000 (00:16 +0000)] 
Daily bump.