[gcc r15-3562] ada: Whitespace cleanup in declaration of calendar-related routines
https://gcc.gnu.org/g:c8352514cd0903d00e0e4df106bd921897f90e63 commit r15-3562-gc8352514cd0903d00e0e4df106bd921897f90e63 Author: Piotr Trojanek Date: Tue Aug 27 12:45:07 2024 +0200 ada: Whitespace cleanup in declaration of calendar-related routines Code cleanup. gcc/ada/ * libgnat/s-os_lib.ads: Remove extra whitespace. Diff: --- gcc/ada/libgnat/s-os_lib.ads | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads index 46e11f708a20..54e7205c3e6a 100644 --- a/gcc/ada/libgnat/s-os_lib.ads +++ b/gcc/ada/libgnat/s-os_lib.ads @@ -130,12 +130,12 @@ package System.OS_Lib is -- Returns current local time in the form -MM-DD HH:MM:SS. The result -- has bounds 1 .. 19. - function GM_Year(Date : OS_Time) return Year_Type; - function GM_Month (Date : OS_Time) return Month_Type; - function GM_Day (Date : OS_Time) return Day_Type; - function GM_Hour(Date : OS_Time) return Hour_Type; - function GM_Minute (Date : OS_Time) return Minute_Type; - function GM_Second (Date : OS_Time) return Second_Type; + function GM_Year (Date : OS_Time) return Year_Type; + function GM_Month (Date : OS_Time) return Month_Type; + function GM_Day(Date : OS_Time) return Day_Type; + function GM_Hour (Date : OS_Time) return Hour_Type; + function GM_Minute (Date : OS_Time) return Minute_Type; + function GM_Second (Date : OS_Time) return Second_Type; -- Functions to extract information from OS_Time value in GMT form procedure GM_Split
[gcc r15-3563] ada: Simplify code for inserting checks into expressions
https://gcc.gnu.org/g:7b77938c1b52e067db919b83c67bb7ca9e88b84c commit r15-3563-g7b77938c1b52e067db919b83c67bb7ca9e88b84c Author: Piotr Trojanek Date: Mon Aug 26 16:16:19 2024 +0200 ada: Simplify code for inserting checks into expressions Code cleanup; semantics is unaffected. gcc/ada/ * checks.adb (Remove_Checks): Combine CASE alternatives. Diff: --- gcc/ada/checks.adb | 34 -- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 5d7f4cca70ae..57307c3da1b5 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -9712,10 +9712,6 @@ package body Checks is Set_Do_Range_Check (N, False); case Nkind (N) is -when N_And_Then => - Traverse (Left_Opnd (N)); - return Skip; - when N_Attribute_Reference => Set_Do_Overflow_Check (N, False); @@ -9723,35 +9719,29 @@ package body Checks is Set_Do_Overflow_Check (N, False); case Nkind (N) is - when N_Op_Divide => - Set_Do_Division_Check (N, False); - - when N_Op_And => - Set_Do_Length_Check (N, False); - - when N_Op_Mod => - Set_Do_Division_Check (N, False); - - when N_Op_Or => - Set_Do_Length_Check (N, False); - - when N_Op_Rem => + when N_Op_Divide + | N_Op_Mod + | N_Op_Rem + => Set_Do_Division_Check (N, False); - when N_Op_Xor => + when N_Op_And + | N_Op_Or + | N_Op_Xor + => Set_Do_Length_Check (N, False); when others => null; end case; -when N_Or_Else => - Traverse (Left_Opnd (N)); - return Skip; - when N_Selected_Component => Set_Do_Discriminant_Check (N, False); +when N_Short_Circuit => + Traverse (Left_Opnd (N)); + return Skip; + when N_Type_Conversion => Set_Do_Length_Check (N, False); Set_Do_Overflow_Check (N, False);
[gcc r15-3565] ada: Normalize span generation on different platforms
https://gcc.gnu.org/g:5b701ee737c41cd0ca54f1343620170d92344e6a commit r15-3565-g5b701ee737c41cd0ca54f1343620170d92344e6a Author: Viljar Indus Date: Fri Aug 30 14:22:16 2024 +0300 ada: Normalize span generation on different platforms The total number of characters on a source code line is different on Windows and Linux based systems (CRLF vs LF endings). Use the last non line change character to adjust printing the spans that go over the end of line. gcc/ada/ * diagnostics-pretty_emitter.adb (Get_Last_Line_Char): New. Get the last non line change character. Write_Span_Labels use the adjusted line end pointer to calculate the length of the span. Diff: --- gcc/ada/diagnostics-pretty_emitter.adb | 30 +++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/gcc/ada/diagnostics-pretty_emitter.adb b/gcc/ada/diagnostics-pretty_emitter.adb index 927e50578e98..389be8a6533d 100644 --- a/gcc/ada/diagnostics-pretty_emitter.adb +++ b/gcc/ada/diagnostics-pretty_emitter.adb @@ -165,7 +165,7 @@ package body Diagnostics.Pretty_Emitter is function Get_Line_End (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr; - -- Get the source location for the end of the line in Buf for Loc. If + -- Get the source location for the end of the line (LF) in Buf for Loc. If -- Loc is past the end of Buf already, return Buf'Last. function Get_Line_Start @@ -177,6 +177,10 @@ package body Diagnostics.Pretty_Emitter is (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr; -- Get first non-space character in the line containing Loc + function Get_Last_Line_Char + (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr; + -- Get last non line end [LF, CR] character in the line containing Loc + function Image (X : Positive; Width : Positive) return String; -- Output number X over Width characters, with whitespace padding. -- Only output the low-order Width digits of X, if X is larger than @@ -314,6 +318,25 @@ package body Diagnostics.Pretty_Emitter is return Cur_Loc; end Get_First_Line_Char; + + -- Get_Last_Line_Char -- + + + function Get_Last_Line_Char + (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr + is + Cur_Loc : Source_Ptr := Get_Line_End (Buf, Loc); + begin + + while Cur_Loc > Buf'First +and then Buf (Cur_Loc) in ASCII.LF | ASCII.CR + loop + Cur_Loc := Cur_Loc - 1; + end loop; + + return Cur_Loc; + end Get_Last_Line_Char; + --- -- Image -- --- @@ -720,8 +743,9 @@ package body Diagnostics.Pretty_Emitter is Source_Text (Get_Source_File_Index (L.First)); Col_L_Fst : constant Natural := Natural - (Get_Column_Number (Get_First_Line_Char (Buf, L.First))); - Col_L_Lst : constant Natural := Natural (Get_Column_Number (L.Last)); +(Get_Column_Number (Get_First_Line_Char (Buf, L.First))); + Col_L_Lst : constant Natural := Natural +(Get_Column_Number (Get_Last_Line_Char (Buf, L.Last))); -- Carret positions Ptr : constant Source_Ptr := Loc.Span.Ptr;
[gcc r15-3566] ada: First controlling parameter: report error without Extensions allowed
https://gcc.gnu.org/g:356536a4e6bce777e9f150e0bdcd627cd73068cd commit r15-3566-g356536a4e6bce777e9f150e0bdcd627cd73068cd Author: Javier Miranda Date: Mon Aug 26 18:56:37 2024 + ada: First controlling parameter: report error without Extensions allowed Enable reporting an error when this new aspect/pragma is set to True, and the sources are compiled without language extensions allowed. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Call Error_Msg_GNAT_Extension() to report an error when the aspect First_Controlling_Parameter is set to True and the sources are compiled without Core_Extensions_ Allowed. * sem_prag.adb (Pragma_First_Controlling_Parameter): Call subprogram Error_Msg_GNAT_Extension() to report an error when the aspect First_Controlling_Parameter is set to True and the sources are compiled without Core_Extensions_Allowed. Report an error when the aspect pragma does not confirm an inherited True value. Diff: --- gcc/ada/sem_ch13.adb | 28 +-- gcc/ada/sem_prag.adb | 53 ++-- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index ab8cc1012c31..0770bafd2316 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -4530,6 +4530,9 @@ package body Sem_Ch13 is if (No (Expr) or else Entity (Expr) = Standard_True) and then not Core_Extensions_Allowed then + Error_Msg_GNAT_Extension + ("'First_'Controlling_'Parameter", Sloc (Aspect), + Is_Core_Extension => True); goto Continue; end if; @@ -4545,19 +4548,24 @@ package body Sem_Ch13 is goto Continue; end if; --- If the aspect is specified for a derived type, the --- specified value shall be confirming. - if Present (Expr) - and then Is_Derived_Type (E) - and then -Has_First_Controlling_Parameter_Aspect (Etype (E)) and then Entity (Expr) = Standard_False then - Error_Msg_Name_1 := Nam; - Error_Msg_N - ("specification of inherited aspect% can only " - & "confirm parent value", Id); + -- If the aspect is specified for a derived type, + -- the specified value shall be confirming. + + if Is_Derived_Type (E) + and then Has_First_Controlling_Parameter_Aspect +(Etype (E)) + then + Error_Msg_Name_1 := Nam; + Error_Msg_N +("specification of inherited True value for " + & "aspect% can only confirm parent value", + Id); + end if; + + goto Continue; end if; -- Given that the aspect has been explicitly given, diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index b139bd4cf4e7..2d31c71f366e 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -17761,22 +17761,55 @@ package body Sem_Prag is when Pragma_First_Controlling_Parameter => First_Ctrl_Param : declare -Arg : Node_Id; -E : Entity_Id := Empty; +Arg : Node_Id; +E: Entity_Id := Empty; +Expr : Node_Id := Empty; begin -if not Core_Extensions_Allowed then - return; -end if; - GNAT_Pragma; -Check_Arg_Count (1); +Check_At_Least_N_Arguments (1); +Check_At_Most_N_Arguments (2); Arg := Get_Pragma_Arg (Arg1); +Check_Arg_Is_Identifier (Arg); -if Nkind (Arg) = N_Identifier then - Analyze (Arg); - E := Entity (Arg); +Analyze (Arg); +E := Entity (Arg); + +if Present (Arg2) then + Check_Arg_Is_OK_Static_Expression (Arg2, Standard_Boolean); + Expr := Get_Pragma_Arg (Arg2); + Analyze_And_Resolve (Expr, Standard_Boolean); +end if; + +if not Core_Extensions_Allowed then + if No (Expr) + or else +
[gcc r15-3567] ada: Use the same warning character in continuations
https://gcc.gnu.org/g:4930e82f63b98fa637e27a53f1722fe63b7e3be2 commit r15-3567-g4930e82f63b98fa637e27a53f1722fe63b7e3be2 Author: Viljar Indus Date: Thu Jul 18 10:52:03 2024 +0300 ada: Use the same warning character in continuations gcc/ada/ * gcc-interface/decl.cc: Use same warning characters in continuation messages. * gcc-interface/trans.cc: Likewise. Diff: --- gcc/ada/gcc-interface/decl.cc | 8 gcc/ada/gcc-interface/trans.cc | 14 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 655ba0b8a105..4252e627b0ce 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -1430,7 +1430,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) post_error ("??too large object cannot be allocated statically", gnat_entity); - post_error ("\\?dynamic allocation will be used instead", + post_error ("\\??dynamic allocation will be used instead", gnat_entity); } @@ -6565,7 +6565,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition, ("??cannot import type-generic 'G'C'C builtin!", gnat_subprog); post_error - ("\\?use a supported result type", + ("\\??use a supported result type", gnat_subprog); gnu_builtin_decl = NULL_TREE; } @@ -6587,7 +6587,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition, ("??cannot import type-generic 'G'C'C builtin!", gnat_subprog); post_error - ("\\?use a supported second parameter type", + ("\\??use a supported second parameter type", gnat_subprog); gnu_builtin_decl = NULL_TREE; } @@ -6608,7 +6608,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition, ("??cannot import type-generic 'G'C'C builtin!", gnat_subprog); post_error - ("\\?use a supported third parameter type", + ("\\??use a supported third parameter type", gnat_subprog); gnu_builtin_decl = NULL_TREE; } diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 92e000686fb2..710907bb999f 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -4949,10 +4949,10 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target, ("unchecked conversion implemented by copy??", gnat_actual); post_error - ("\\?use pragma Universal_Aliasing on either type", + ("\\??use pragma Universal_Aliasing on either type", gnat_actual); post_error - ("\\?to enable RM 13.9(12) implementation permission", + ("\\??to enable RM 13.9(12) implementation permission", gnat_actual); } @@ -4962,10 +4962,10 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target, ("value conversion implemented by copy??", gnat_actual); post_error - ("\\?use pair of types with same root type", + ("\\??use pair of types with same root type", gnat_actual); post_error - ("\\?to avoid new object in RM 4.6(58.5/5)", + ("\\??to avoid new object in RM 4.6(58.5/5)", gnat_actual); } } @@ -10644,9 +10644,9 @@ validate_unchecked_conversion (Node_Id gnat_node) { post_error_ne ("??possible aliasing problem for type&", gnat_node, Target_Type (gnat_node)); - post_error ("\\?use -fno-strict-aliasing switch for references", + post_error ("\\??use -fno-strict-aliasing switch for references", gnat_node); - post_error_ne ("\\?or use `pragma No_Strict_Aliasing (&);`", + post_error_ne ("\\??or use `pragma No_Strict_Aliasing (&);`", gnat_node, Target_Type (gnat_node)); } } @@ -10670,7 +10670,7 @@ validate_unchecked_conversion (Node_Id gnat_node) { post_error_ne ("??possible al
[gcc r15-3561] x86: Refine V4BF/V2BF FMA Testcase
https://gcc.gnu.org/g:3d031cc4465a32bbc82c96e3e07894eb6dc4d3ec commit r15-3561-g3d031cc4465a32bbc82c96e3e07894eb6dc4d3ec Author: Levy Hsu Date: Tue Sep 10 15:12:09 2024 +0930 x86: Refine V4BF/V2BF FMA Testcase gcc/testsuite/ChangeLog: * gcc.target/i386/avx10_2-partial-bf-vector-fma-1.c: Separated 32-bit scan and removed register checks in spill situations. Diff: --- .../gcc.target/i386/avx10_2-partial-bf-vector-fma-1.c| 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/avx10_2-partial-bf-vector-fma-1.c b/gcc/testsuite/gcc.target/i386/avx10_2-partial-bf-vector-fma-1.c index 72e17e99603b..8a9096a300af 100644 --- a/gcc/testsuite/gcc.target/i386/avx10_2-partial-bf-vector-fma-1.c +++ b/gcc/testsuite/gcc.target/i386/avx10_2-partial-bf-vector-fma-1.c @@ -1,9 +1,13 @@ /* { dg-do compile } */ /* { dg-options "-mavx10.2 -O2" } */ -/* { dg-final { scan-assembler-times "vfmadd132nepbf16\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 2 } } */ -/* { dg-final { scan-assembler-times "vfmsub132nepbf16\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 2 } } */ -/* { dg-final { scan-assembler-times "vfnmadd132nepbf16\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 2 } } */ -/* { dg-final { scan-assembler-times "vfnmsub132nepbf16\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 2 } } */ +/* { dg-final { scan-assembler-times "vfmadd132nepbf16\[^\n\r\]*xmm\[0-9\]" 3 { target ia32 } } } */ +/* { dg-final { scan-assembler-times "vfmsub132nepbf16\[^\n\r\]*xmm\[0-9\]" 3 { target ia32 } } } */ +/* { dg-final { scan-assembler-times "vfnmadd132nepbf16\[^\n\r\]*xmm\[0-9\]" 3 { target ia32 } } } */ +/* { dg-final { scan-assembler-times "vfnmsub132nepbf16\[^\n\r\]*xmm\[0-9\]" 3 { target ia32 } } } */ +/* { dg-final { scan-assembler-times "vfmadd132nepbf16\[^\n\r\]*xmm\[0-9\]" 2 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "vfmsub132nepbf16\[^\n\r\]*xmm\[0-9\]" 2 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "vfnmadd132nepbf16\[^\n\r\]*xmm\[0-9\]" 2 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "vfnmsub132nepbf16\[^\n\r\]*xmm\[0-9\]" 2 { target { ! ia32 } } } } */ typedef __bf16 v4bf __attribute__ ((__vector_size__ (8))); typedef __bf16 v2bf __attribute__ ((__vector_size__ (4)));
[gcc r15-3568] ada: Include missing associated header file
https://gcc.gnu.org/g:73dc46f47be6157eaebc3fd089f57fab2304bb01 commit r15-3568-g73dc46f47be6157eaebc3fd089f57fab2304bb01 Author: Eric Botcazou Date: Tue Aug 27 16:13:08 2024 +0200 ada: Include missing associated header file memmodel.h must be included alongside tm_p.h for the sake of the SPARC port. gcc/ada/ * gcc-interface/misc.cc: Include memmodel.h before tm_p.h. Diff: --- gcc/ada/gcc-interface/misc.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc index 645937f796ca..2aa1bfd410b2 100644 --- a/gcc/ada/gcc-interface/misc.cc +++ b/gcc/ada/gcc-interface/misc.cc @@ -28,6 +28,7 @@ #include "coretypes.h" #include "target.h" #include "tree.h" +#include "memmodel.h" #include "tm_p.h" #include "diagnostic.h" #include "opts.h"
[gcc r15-3564] ada: Evaluate calls to GNAT.Source_Info routines in semantic checking
https://gcc.gnu.org/g:ac957a621cf1e9beeb52695250b7600ed066448f commit r15-3564-gac957a621cf1e9beeb52695250b7600ed066448f Author: Piotr Trojanek Date: Wed Aug 28 17:56:06 2024 +0200 ada: Evaluate calls to GNAT.Source_Info routines in semantic checking When semantic checking mode is active, i.e. when switch -gnatc is present or when the frontend is operating in the GNATprove mode, we now rewrite calls to GNAT.Source_Info routines in evaluation and not expansion (which is disabled in these modes). This is needed to recognize constants initialized with calls to GNAT.Source_Info as static constants, regardless of expansion being enabled. gcc/ada/ * exp_intr.ads, exp_intr.adb (Expand_Source_Info): Move declaration to package spec. * sem_eval.adb (Eval_Intrinsic_Call): Evaluate calls to GNAT.Source_Info where possible. Diff: --- gcc/ada/exp_intr.adb | 6 -- gcc/ada/exp_intr.ads | 5 + gcc/ada/sem_eval.adb | 37 ++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/gcc/ada/exp_intr.adb b/gcc/ada/exp_intr.adb index a076eb0eeb6a..0db0a66ab1c9 100644 --- a/gcc/ada/exp_intr.adb +++ b/gcc/ada/exp_intr.adb @@ -109,12 +109,6 @@ package body Exp_Intr is -- Expand a call to corresponding function, declared in an instance of -- System.Address_To_Access_Conversions. - procedure Expand_Source_Info (N : Node_Id; Nam : Name_Id); - -- Rewrite the node as the appropriate string literal or positive - -- constant. Nam is the name of one of the intrinsics declared in - -- GNAT.Source_Info; see g-souinf.ads for documentation of these - -- intrinsics. - - -- Add_Source_Info -- - diff --git a/gcc/ada/exp_intr.ads b/gcc/ada/exp_intr.ads index 699d1c8164f9..75f24bf54950 100644 --- a/gcc/ada/exp_intr.ads +++ b/gcc/ada/exp_intr.ads @@ -39,6 +39,11 @@ package Exp_Intr is -- documentation of these intrinsics. Loc is passed to provide location -- information where it is needed. + procedure Expand_Source_Info (N : Node_Id; Nam : Name_Id); + -- Rewrite the node as the appropriate string literal or positive constant. + -- Nam is the name of one of the intrinsics declared in GNAT.Source_Info; + -- see g-souinf.ads for documentation of these intrinsics. + procedure Expand_Intrinsic_Call (N : Node_Id; E : Entity_Id); -- N is either a function call node, a procedure call statement node, or -- an operator where the corresponding subprogram is intrinsic (i.e. was diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index aaf0a766dc31..de3f35e9a619 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -33,6 +33,7 @@ with Einfo.Utils;use Einfo.Utils; with Elists; use Elists; with Errout; use Errout; with Eval_Fat; use Eval_Fat; +with Exp_Intr; use Exp_Intr; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Lib;use Lib; @@ -191,7 +192,7 @@ package body Sem_Eval is -- (it is an error to make the call if these conditions are not met). procedure Eval_Intrinsic_Call (N : Node_Id; E : Entity_Id); - -- Evaluate a call N to an intrinsic subprogram E. + -- Evaluate a call N to an intrinsic subprogram E function Find_Universal_Operator_Type (N : Node_Id) return Entity_Id; -- Check whether an arithmetic operation with universal operands which is a @@ -2888,13 +2889,43 @@ package body Sem_Eval is end if; case Nam is - when Name_Shift_Left => + + -- Compilation date and time are the same for the entire compilation + -- unit, so we can replace them with static strings. + + when Name_Compilation_ISO_Date +| Name_Compilation_Date +| Name_Compilation_Time + => +Expand_Source_Info (N, Nam); + + -- Calls to other intrinsics from the GNAT.Source_Info package give + -- different results, depending on where they occur. In particular, + -- for generics their results depend on where those generics are + -- instantiated; same for default values of subprogram parameters. + -- Those calls will behave as nonstatic, and we postpone their + -- rewriting until expansion. + + when Name_Enclosing_Entity +| Name_File +| Name_Line +| Name_Source_Location + => +if Inside_A_Generic + or else In_Spec_Expression +then + null; +else + Expand_Source_Info (N, Nam); +end if; + + when Name_Shift_Left => Eval_Shift (N, E, N_Op_Shift_Left); when Name_Shift_Right => Eval_Shift (N, E, N_Op_Shift_Right); when Name_Shift_Right_Arithmetic => Eval_Shift (N, E, N_
[gcc r15-3569] Match: Support form 2 for scalar signed integer .SAT_ADD
https://gcc.gnu.org/g:a7eaf7d5edb194bae0d7d9bc3d20bb5730be57d8 commit r15-3569-ga7eaf7d5edb194bae0d7d9bc3d20bb5730be57d8 Author: Pan Li Date: Tue Sep 3 15:39:16 2024 +0800 Match: Support form 2 for scalar signed integer .SAT_ADD This patch would like to support the form 2 of the scalar signed integer .SAT_ADD. Aka below example: Form 2: #define DEF_SAT_S_ADD_FMT_2(T, UT, MIN, MAX) \ T __attribute__((noinline)) \ sat_s_add_##T##_fmt_2 (T x, T y) \ {\ T sum = (UT)x + (UT)y; \ \ if ((x ^ y) < 0 || (sum ^ x) >= 0) \ return sum; \ \ return x < 0 ? MIN : MAX; \ } DEF_SAT_S_ADD_FMT_2(int8_t, uint8_t, INT8_MIN, INT8_MAX) We can tell the difference before and after this patch if backend implemented the ssadd3 pattern similar as below. Before this patch: 4 │ __attribute__((noinline)) 5 │ int8_t sat_s_add_int8_t_fmt_2 (int8_t x, int8_t y) 6 │ { 7 │ int8_t sum; 8 │ unsigned char x.0_1; 9 │ unsigned char y.1_2; 10 │ unsigned char _3; 11 │ signed char _4; 12 │ signed char _5; 13 │ int8_t _6; 14 │ _Bool _11; 15 │ signed char _12; 16 │ signed char _13; 17 │ signed char _14; 18 │ signed char _22; 19 │ signed char _23; 20 │ 21 │ ;; basic block 2, loop depth 0 22 │ ;;pred: ENTRY 23 │ x.0_1 = (unsigned char) x_7(D); 24 │ y.1_2 = (unsigned char) y_8(D); 25 │ _3 = x.0_1 + y.1_2; 26 │ sum_9 = (int8_t) _3; 27 │ _4 = x_7(D) ^ y_8(D); 28 │ _5 = x_7(D) ^ sum_9; 29 │ _23 = ~_4; 30 │ _22 = _5 & _23; 31 │ if (_22 >= 0) 32 │ goto ; [42.57%] 33 │ else 34 │ goto ; [57.43%] 35 │ ;;succ: 4 36 │ ;;3 37 │ 38 │ ;; basic block 3, loop depth 0 39 │ ;;pred: 2 40 │ _11 = x_7(D) < 0; 41 │ _12 = (signed char) _11; 42 │ _13 = -_12; 43 │ _14 = _13 ^ 127; 44 │ ;;succ: 4 45 │ 46 │ ;; basic block 4, loop depth 0 47 │ ;;pred: 2 48 │ ;;3 49 │ # _6 = PHI 50 │ return _6; 51 │ ;;succ: EXIT 52 │ 53 │ } After this patch: 4 │ __attribute__((noinline)) 5 │ int8_t sat_s_add_int8_t_fmt_2 (int8_t x, int8_t y) 6 │ { 7 │ int8_t _6; 8 │ 9 │ ;; basic block 2, loop depth 0 10 │ ;;pred: ENTRY 11 │ _6 = .SAT_ADD (x_7(D), y_8(D)); [tail call] 12 │ return _6; 13 │ ;;succ: EXIT 14 │ 15 │ } The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Add the form 2 of signed .SAT_ADD matching. Signed-off-by: Pan Li Diff: --- gcc/match.pd | 14 ++ 1 file changed, 14 insertions(+) diff --git a/gcc/match.pd b/gcc/match.pd index bc6a83b47fb0..a664be5fe238 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3207,6 +3207,20 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (type) && !TYPE_UNSIGNED (type) && types_match (type, @0, @1 +/* Signed saturation add, case 2: + T sum = (T)((UT)X + (UT)Y) + SAT_S_ADD = (X ^ sum) & !(X ^ Y) >= 0 ? sum : (-(T)(X < 0) ^ MAX); + + The T and UT are type pair like T=int8_t, UT=uint8_t. */ +(match (signed_integer_sat_add @0 @1) + (cond^ (ge (bit_and:c (bit_xor @0 (nop_convert@2 (plus (nop_convert @0) + (nop_convert @1 + (bit_not (bit_xor:c @0 @1))) + integer_zerop) + @2 + (bit_xor:c (negate (convert (lt @0 integer_zerop))) max_value)) + (if (INTEGRAL_TYPE_P (type) && !TYPE_UNSIGNED (type + /* Unsigned saturation sub, case 1 (branch with gt): SAT_U_SUB = X > Y ? X - Y : 0 */ (match (unsigned_integer_sat_sub @0 @1)
[gcc r15-3570] tree-optimization/116658 - latent issue in vect_is_slp_load_node
https://gcc.gnu.org/g:747700cdb564ed1c5ef13bc73c2fe48639964c0f commit r15-3570-g747700cdb564ed1c5ef13bc73c2fe48639964c0f Author: Richard Biener Date: Tue Sep 10 09:39:16 2024 +0200 tree-optimization/116658 - latent issue in vect_is_slp_load_node Permute nodes do not have a representative so we have to guard vect_is_slp_load_node against those. PR tree-optimization/116658 * tree-vect-slp.cc (vect_is_slp_load_node): Make sure node isn't a permute. * g++.dg/vect/pr116658.cc: New testcase. Diff: --- gcc/testsuite/g++.dg/vect/pr116658.cc | 58 +++ gcc/tree-vect-slp.cc | 7 +++-- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/g++.dg/vect/pr116658.cc b/gcc/testsuite/g++.dg/vect/pr116658.cc new file mode 100644 index ..c3ff23a2b604 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr116658.cc @@ -0,0 +1,58 @@ +// { dg-do compile } +// { dg-require-effective-target c++11 } +// { dg-additional-options "-O3" } +// { dg-additional-options "-mavx512f" { target avx512f } } + +struct bb { + bb operator+=(bb bc) { + bd[0] += bc.bd[0]; +return *this; + } + bb operator-=(bb bc) { + bd[0] -= bc.bd[0]; +return *this; + } + bb operator*=(double be) { + bd[0] *= be; +return *this; + } + double bd[1]; +}; + +bb operator+(bb n, bb v) { + bb bf = n; + return bf += v; +} + +bb operator-(bb n, bb v) { + bb bf = n; + return bf -= v; +} +bb operator*(double n, bb v) { + bb bf = v; + return bf *= n; +} + +using az = bb; +struct cc { + void apply(bb *ci) { + bb xm[1]; + for (int cm = 0; cm < 2; ++cm) { +az cn, co = cv[cm] * xm[0]; +ci[cm] = cn + co; +ci[-1] = cn - co; + } + } + double *cu; + double *cv; +}; +void dc(unsigned de, int di, az *dk, az *dl, cc dh) { + for (int c; c < 1024; ++c) { +if (de & 1) + dh.apply(dk); +if (de & 2) + dh.apply(dl); +dk += di; +dl += di; + } +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 0fb17340bd3c..31c7e20f8c9a 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3265,9 +3265,10 @@ calculate_unrolling_factor (poly_uint64 nunits, unsigned int group_size) static inline bool vect_is_slp_load_node (slp_tree root) { - return SLP_TREE_DEF_TYPE (root) == vect_internal_def -&& STMT_VINFO_GROUPED_ACCESS (SLP_TREE_REPRESENTATIVE (root)) -&& DR_IS_READ (STMT_VINFO_DATA_REF (SLP_TREE_REPRESENTATIVE (root))); + return (SLP_TREE_CODE (root) != VEC_PERM_EXPR + && SLP_TREE_DEF_TYPE (root) == vect_internal_def + && STMT_VINFO_GROUPED_ACCESS (SLP_TREE_REPRESENTATIVE (root)) + && DR_IS_READ (STMT_VINFO_DATA_REF (SLP_TREE_REPRESENTATIVE (root; }
[gcc r14-10660] libstdc++: Fix std::chrono::tzdb to work with vanguard format
https://gcc.gnu.org/g:ab884fffe3fc82a710bea66ad651720d71c938b8 commit r14-10660-gab884fffe3fc82a710bea66ad651720d71c938b8 Author: Jonathan Wakely Date: Tue Apr 30 09:52:13 2024 +0100 libstdc++: Fix std::chrono::tzdb to work with vanguard format I found some issues in the std::chrono::tzdb parser by testing the tzdata "vanguard" format, which uses new features that aren't enabled in the "main" and "rearguard" data formats. Since 2024a the keyword "minimum" is no longer valid for the FROM and TO fields in a Rule line, which means that "m" is now a valid abbreviation for "maximum". Previously we expected either "mi" or "ma". For backwards compatibility, a FROM field beginning with "mi" is still supported and is treated as 1900. The "maximum" keyword is only allowed in TO now, because it makes no sense in FROM. To support these changes the minmax_year and minmax_year2 classes for parsing FROM and TO are replaced with a single years_from_to class that reads both fields. The vanguard format makes use of %z in Zone FORMAT fields, which caused an exception to be thrown from ZoneInfo::set_abbrev because no % or / characters were expected when a Zone doesn't use a named Rule. The ZoneInfo::to(sys_info&) function now uses format_abbrev_str to replace any %z with the current offset. Although format_abbrev_str also checks for %s and STD/DST formats, those only make sense when a named Rule is in effect, so won't occur when ZoneInfo::to(sys_info&) is used. Since making this change on trunk, the tzdata-2024b release started using %z in the main format, not just vanguard. This makes a backport to release branches necessary (see PR 116657). This change also implements a feature that has always been missing from time_zone::_M_get_sys_info: finding the Rule that is active before the specified time point, so that we can correctly handle %s in the FORMAT for the first new sys_info that gets created. This requires implementing a poorly documented feature of zic, to get the LETTERS field from a later transition, as described at https://mm.icann.org/pipermail/tz/2024-April/058891.html In order for this to work we need to be able to distinguish an empty letters field (as used by CE%sT where the variable part is either empty or "S") from "the letters field is not known for this transition". The tzdata file uses "-" for an empty letters field, which libstdc++ was previously replacing with "" when the Rule was parsed. Instead, we now preserve the "-" in the Rule object, so that "" can be used for the case where we don't know the letters (and so need to decide it). libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (minmax_year, minmax_year2): Remove. (years_from_to): New class replacing minmax_year and minmax_year2. (format_abbrev_str, select_std_or_dst_abbrev): Move earlier in the file. Handle "-" for letters. (ZoneInfo::to): Use format_abbrev_str to expand %z. (ZoneInfo::set_abbrev): Remove exception. Change parameter from reference to value. (operator>>(istream&, Rule&)): Do not clear letters when it contains "-". (time_zone::_M_get_sys_info): Add missing logic to find the Rule in effect before the time point. * testsuite/std/time/tzdb/1.cc: Adjust for vanguard format using "GMT" as the Zone name, not as a Link to "Etc/GMT". * testsuite/std/time/time_zone/sys_info_abbrev.cc: New test. (cherry picked from commit 0ca8d56f2085715f27ee536c6c344bc47af49cdd) Diff: --- libstdc++-v3/src/c++20/tzdb.cc | 265 + .../std/time/time_zone/sys_info_abbrev.cc | 106 + libstdc++-v3/testsuite/std/time/tzdb/1.cc | 6 +- 3 files changed, 274 insertions(+), 103 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index c7c7cc9deee6..7e8cce7ce8cf 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -342,51 +342,103 @@ namespace std::chrono friend istream& operator>>(istream&, on_day&); }; -// Wrapper for chrono::year that reads a year, or one of the keywords -// "minimum" or "maximum", or an unambiguous prefix of a keyword. -struct minmax_year +// Wrapper for two chrono::year values, which reads the FROM and TO +// fields of a Rule line. The FROM field is a year and TO is a year or +// one of the keywords "maximum" or "only" (or an abbreviation of those). +// For backwards compatibility, the keyword "minimum" is recognized +// for FROM and interpreted as 1900. +struct years_from_to { - year& y; + year& from; + year& to; - friend istream& operator>>(istream& in, minmax_year&& y) +
[gcc r13-9013] [libstdc++] define zoneinfo_dir_override on vxworks
https://gcc.gnu.org/g:2913d33b47f9169a8b80628b4382558a98d5c26e commit r13-9013-g2913d33b47f9169a8b80628b4382558a98d5c26e Author: Alexandre Oliva Date: Thu Apr 18 08:00:52 2024 -0300 [libstdc++] define zoneinfo_dir_override on vxworks VxWorks fails to load kernel-mode modules with weak undefined symbols. In RTP mode modules, that undergo final linking, weak undefined symbols are not a problem. This patch adds kernel-mode VxWorks multilibs to the set of targets that don't support weak undefined symbols without special flags, in which tzdb's zoneinfo_dir_override is given a weak definition. for libstdc++-v3/ChangeLog * src/c++20/tzdb.cc (__gnu_cxx::zoneinfo_dir_override): Define on VxWorks non-RTP. (cherry picked from commit da3504ae4d1e6872585b1107a4932efd3824e943) Diff: --- libstdc++-v3/src/c++20/tzdb.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index e03f4a5c32ac..dfd4c71a152e 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -70,8 +70,9 @@ namespace __gnu_cxx #else [[gnu::weak]] const char* zoneinfo_dir_override(); -#if defined(__APPLE__) || defined(__hpux__) - // Need a weak definition for Mach-O. +#if defined(__APPLE__) || defined(__hpux__) \ + || (defined(__VXWORKS__) && !defined(__RTP__)) + // Need a weak definition for Mach-O et al. [[gnu::weak]] const char* zoneinfo_dir_override() { #ifdef _GLIBCXX_ZONEINFO_DIR
[gcc r13-9014] libstdc++: Support link chains in std::chrono::tzdb::locate_zone [PR114770]
https://gcc.gnu.org/g:e9b2f1f4f30371ea04efe83c0ebea4e07f3afec3 commit r13-9014-ge9b2f1f4f30371ea04efe83c0ebea4e07f3afec3 Author: Jonathan Wakely Date: Thu Apr 18 12:14:41 2024 +0100 libstdc++: Support link chains in std::chrono::tzdb::locate_zone [PR114770] Since 2022 the TZif format defined in the zic(8) man page has said that links can refer to other links, rather than only referring to a zone. This isn't supported by the C++20 spec, which assumes that the target() for a chrono::time_zone_link always names a chrono::time_zone, not another chrono::time_zone_link. This hasn't been a problem until now, because there are no entries in the tzdata file that chain links together. However, Debian Sid has changed the target of the Asia/Chungking link from the Asia/Shanghai zone to the Asia/Chongqing link, creating a link chain. The libstdc++ code is unable to handle this, so chrono::locate_zone("Asia/Chungking") will fail with the tzdata.zi file from Debian Sid. It seems likely that the C++ spec will need a change to allow link chains, so that the original structure of the IANA database can be fully represented by chrono::tzdb. The alternative would be for chrono::tzdb to flatten all chains when loading the data, so that a link's target is always a zone, but this means throwing away information present in the tzdata.zi input file. In anticipation of a change to the spec, this commit adds support for chained links to libstdc++. When a name is found to be a link, we try to find its target in the list of zones as before, but now if the target isn't the name of a zone we don't fail. Instead we look for another link with that name, and keep doing that until we reach the end of the chain of links, and then look up the last target as a zone. This new logic would get stuck in a loop if the tzdata.zi file is buggy and defines a link chain that contains a cycle, e.g. two links that refer to each other. To deal with that unlikely case, we use the tortoise and hare algorithm to detect cycles in link chains, and throw an exception if we detect a cycle. Cycles in links should never happen, and it is expected that link chains will be short (if they occur at all) and so the code is optimized for short chains without cycles. Longer chains (four or more links) and cycles will do more work, but won't fail to resolve a chain or get stuck in a loop. The new test file checks various forms of broken links and cycles. Also add a new check in the testsuite that every element in the get_tzdb().zones and get_tzdb().links sequences can be successfully found using locate_zone. libstdc++-v3/ChangeLog: PR libstdc++/114770 * src/c++20/tzdb.cc (do_locate_zone): Support links that have another link as their target. * testsuite/std/time/tzdb/1.cc: Check that all zones and links can be found by locate_zone. * testsuite/std/time/tzdb/links.cc: New test. (cherry picked from commit eed7fb1b2fe72150cd6af10dd3b8f7fc4f0a4da1) Diff: --- libstdc++-v3/src/c++20/tzdb.cc| 57 ++- libstdc++-v3/testsuite/std/time/tzdb/1.cc | 12 ++ libstdc++-v3/testsuite/std/time/tzdb/links.cc | 215 ++ 3 files changed, 280 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index dfd4c71a152e..e058caf27d89 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -1594,7 +1594,7 @@ namespace std::chrono const time_zone* do_locate_zone(const vector& zones, const vector& links, - string_view tz_name) noexcept + string_view tz_name) { // Lambda mangling changed between -fabi-version=2 and -fabi-version=18 auto search = [](const Vec& v, string_view name) { @@ -1605,13 +1605,62 @@ namespace std::chrono return ptr; }; + // Search zones first. if (auto tz = search(zones, tz_name)) return tz; + // Search links second. if (auto tz_l = search(links, tz_name)) - return search(zones, tz_l->target()); + { + // Handle the common case of a link that has a zone as the target. + if (auto tz = search(zones, tz_l->target())) [[likely]] + return tz; + + // Either tz_l->target() doesn't exist, or we have a chain of links. + // Use Floyd's cycle-finding algorithm to avoid infinite loops, + // at the cost of extra lookups. In the common case we expect a + // chain of links to be short so the loop won't run many times. + // In particular, the duplicate lookups to move the tortoise + // never happen unless the chain has four or more links. + // When a chain contains a c
[gcc r13-9015] libstdc++: Fix std::chrono::tzdb to work with vanguard format
https://gcc.gnu.org/g:5ceea2ac106d6dd1aa8175670b15a801316cf1c9 commit r13-9015-g5ceea2ac106d6dd1aa8175670b15a801316cf1c9 Author: Jonathan Wakely Date: Tue Apr 30 09:52:13 2024 +0100 libstdc++: Fix std::chrono::tzdb to work with vanguard format I found some issues in the std::chrono::tzdb parser by testing the tzdata "vanguard" format, which uses new features that aren't enabled in the "main" and "rearguard" data formats. Since 2024a the keyword "minimum" is no longer valid for the FROM and TO fields in a Rule line, which means that "m" is now a valid abbreviation for "maximum". Previously we expected either "mi" or "ma". For backwards compatibility, a FROM field beginning with "mi" is still supported and is treated as 1900. The "maximum" keyword is only allowed in TO now, because it makes no sense in FROM. To support these changes the minmax_year and minmax_year2 classes for parsing FROM and TO are replaced with a single years_from_to class that reads both fields. The vanguard format makes use of %z in Zone FORMAT fields, which caused an exception to be thrown from ZoneInfo::set_abbrev because no % or / characters were expected when a Zone doesn't use a named Rule. The ZoneInfo::to(sys_info&) function now uses format_abbrev_str to replace any %z with the current offset. Although format_abbrev_str also checks for %s and STD/DST formats, those only make sense when a named Rule is in effect, so won't occur when ZoneInfo::to(sys_info&) is used. Since making this change on trunk, the tzdata-2024b release started using %z in the main format, not just vanguard. This makes a backport to release branches necessary (see PR 116657). This change also implements a feature that has always been missing from time_zone::_M_get_sys_info: finding the Rule that is active before the specified time point, so that we can correctly handle %s in the FORMAT for the first new sys_info that gets created. This requires implementing a poorly documented feature of zic, to get the LETTERS field from a later transition, as described at https://mm.icann.org/pipermail/tz/2024-April/058891.html In order for this to work we need to be able to distinguish an empty letters field (as used by CE%sT where the variable part is either empty or "S") from "the letters field is not known for this transition". The tzdata file uses "-" for an empty letters field, which libstdc++ was previously replacing with "" when the Rule was parsed. Instead, we now preserve the "-" in the Rule object, so that "" can be used for the case where we don't know the letters (and so need to decide it). libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (minmax_year, minmax_year2): Remove. (years_from_to): New class replacing minmax_year and minmax_year2. (format_abbrev_str, select_std_or_dst_abbrev): Move earlier in the file. Handle "-" for letters. (ZoneInfo::to): Use format_abbrev_str to expand %z. (ZoneInfo::set_abbrev): Remove exception. Change parameter from reference to value. (operator>>(istream&, Rule&)): Do not clear letters when it contains "-". (time_zone::_M_get_sys_info): Add missing logic to find the Rule in effect before the time point. * testsuite/std/time/tzdb/1.cc: Adjust for vanguard format using "GMT" as the Zone name, not as a Link to "Etc/GMT". * testsuite/std/time/time_zone/sys_info_abbrev.cc: New test. (cherry picked from commit 0ca8d56f2085715f27ee536c6c344bc47af49cdd) Diff: --- libstdc++-v3/src/c++20/tzdb.cc | 265 + .../std/time/time_zone/sys_info_abbrev.cc | 106 + libstdc++-v3/testsuite/std/time/tzdb/1.cc | 6 +- 3 files changed, 274 insertions(+), 103 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index e058caf27d89..034e72f02743 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -342,51 +342,103 @@ namespace std::chrono friend istream& operator>>(istream&, on_day&); }; -// Wrapper for chrono::year that reads a year, or one of the keywords -// "minimum" or "maximum", or an unambiguous prefix of a keyword. -struct minmax_year +// Wrapper for two chrono::year values, which reads the FROM and TO +// fields of a Rule line. The FROM field is a year and TO is a year or +// one of the keywords "maximum" or "only" (or an abbreviation of those). +// For backwards compatibility, the keyword "minimum" is recognized +// for FROM and interpreted as 1900. +struct years_from_to { - year& y; + year& from; + year& to; - friend istream& operator>>(istream& in, minmax_year&& y) +
[gcc r15-3571] Pass host specific ABI opts from mkoffload.
https://gcc.gnu.org/g:e783a4a683762487cb003ae48235f3d44875de1b commit r15-3571-ge783a4a683762487cb003ae48235f3d44875de1b Author: Prathamesh Kulkarni Date: Tue Sep 10 21:01:58 2024 +0530 Pass host specific ABI opts from mkoffload. The patch adds an option -foffload-abi-host-opts, which is set by host in TARGET_OFFLOAD_OPTIONS, and mkoffload then passes its value to host_compiler. gcc/ChangeLog: PR target/96265 * common.opt (foffload-abi-host-opts): New option. * config/aarch64/aarch64.cc (aarch64_offload_options): Pass -foffload-abi-host-opts. * config/i386/i386-options.cc (ix86_offload_options): Likewise. * config/rs6000/rs6000.cc (rs6000_offload_options): Likewise. * config/nvptx/mkoffload.cc (offload_abi_host_opts): Define. (compile_native): Append offload_abi_host_opts to argv_obstack. (main): Handle option -foffload-abi-host-opts. * config/gcn/mkoffload.cc (offload_abi_host_opts): Define. (compile_native): Append offload_abi_host_opts to argv_obstack. (main): Handle option -foffload-abi-host-opts. * lto-wrapper.cc (merge_and_complain): Handle -foffload-abi-host-opts. (append_compiler_options): Likewise. * opts.cc (common_handle_option): Likewise. Signed-off-by: Prathamesh Kulkarni Diff: --- gcc/common.opt | 4 gcc/config/aarch64/aarch64.cc | 4 ++-- gcc/config/gcn/mkoffload.cc | 26 +++--- gcc/config/i386/i386-options.cc | 4 ++-- gcc/config/nvptx/mkoffload.cc | 25 ++--- gcc/config/rs6000/rs6000.cc | 4 ++-- gcc/lto-wrapper.cc | 2 ++ gcc/opts.cc | 7 +-- 8 files changed, 46 insertions(+), 30 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index ea39f87ae716..d270e524ff45 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2361,6 +2361,10 @@ Enum(offload_abi) String(ilp32) Value(OFFLOAD_ABI_ILP32) EnumValue Enum(offload_abi) String(lp64) Value(OFFLOAD_ABI_LP64) +foffload-abi-host-opts= +Common Joined MissingArgError(option missing after %qs) +-foffload-abi-host-opts= Specify host ABI options. + fomit-frame-pointer Common Var(flag_omit_frame_pointer) Optimization When possible do not generate stack frames. diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 6a3f1a23a9f4..6ccf08d1cc0a 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -19000,9 +19000,9 @@ static char * aarch64_offload_options (void) { if (TARGET_ILP32) -return xstrdup ("-foffload-abi=ilp32"); +return xstrdup ("-foffload-abi=ilp32 -foffload-abi-host-opts=-mabi=ilp32"); else -return xstrdup ("-foffload-abi=lp64"); +return xstrdup ("-foffload-abi=lp64 -foffload-abi-host-opts=-mabi=lp64"); } static struct machine_function * diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc index b8d981878edf..345bbf7709c4 100644 --- a/gcc/config/gcn/mkoffload.cc +++ b/gcc/config/gcn/mkoffload.cc @@ -133,6 +133,8 @@ static const char *gcn_dumpbase; static struct obstack files_to_cleanup; enum offload_abi offload_abi = OFFLOAD_ABI_UNSET; +const char *offload_abi_host_opts = NULL; + uint32_t elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX900; // Default GPU architecture. uint32_t elf_flags = EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4; @@ -819,17 +821,10 @@ compile_native (const char *infile, const char *outfile, const char *compiler, obstack_ptr_grow (&argv_obstack, gcn_dumpbase); obstack_ptr_grow (&argv_obstack, "-dumpbase-ext"); obstack_ptr_grow (&argv_obstack, ".c"); - switch (offload_abi) -{ -case OFFLOAD_ABI_LP64: - obstack_ptr_grow (&argv_obstack, "-m64"); - break; -case OFFLOAD_ABI_ILP32: - obstack_ptr_grow (&argv_obstack, "-m32"); - break; -default: - gcc_unreachable (); -} + if (!offload_abi_host_opts) +fatal_error (input_location, +"%<-foffload-abi-host-opts%> not specified."); + obstack_ptr_grow (&argv_obstack, offload_abi_host_opts); obstack_ptr_grow (&argv_obstack, infile); obstack_ptr_grow (&argv_obstack, "-c"); obstack_ptr_grow (&argv_obstack, "-o"); @@ -998,6 +993,15 @@ main (int argc, char **argv) "unrecognizable argument of option %<" STR "%>"); } #undef STR + else if (startswith (argv[i], "-foffload-abi-host-opts=")) + { + if (offload_abi_host_opts) + fatal_error (input_location, +"%<-foffload-abi-host-opts%> specified " +"multiple times"); + offload_abi_host_opts + = argv[i] + strlen ("-foffload-abi-host-opts="); + } else if (strcmp (argv[i], "-fopenmp") == 0) fopenmp = true; else if (strcmp (argv[i], "-fopenacc") == 0) diff
[gcc r15-3572] c++: mutable temps in rodata [PR116369]
https://gcc.gnu.org/g:2801a49d1144bce5568b527d1972952ad3420f66 commit r15-3572-g2801a49d1144bce5568b527d1972952ad3420f66 Author: Marek Polacek Date: Thu Aug 29 15:13:03 2024 -0400 c++: mutable temps in rodata [PR116369] Here we wrongly mark the reference temporary for g TREE_READONLY, so it's put in .rodata and so we can't modify its subobject even when the subobject is marked mutable. This is so since r9-869. r14-1785 fixed a similar problem, but not in set_up_extended_ref_temp. PR c++/116369 gcc/cp/ChangeLog: * call.cc (set_up_extended_ref_temp): Don't mark a temporary TREE_READONLY if its type is TYPE_HAS_MUTABLE_P. gcc/testsuite/ChangeLog: * g++.dg/tree-ssa/initlist-opt7.C: New test. Diff: --- gcc/cp/call.cc| 4 +++- gcc/testsuite/g++.dg/tree-ssa/initlist-opt7.C | 13 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index fa7f05d76f68..d30f36d49ff6 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13964,7 +13964,9 @@ set_up_extended_ref_temp (tree decl, tree expr, vec **cleanups, init = cp_fully_fold (init); if (TREE_CONSTANT (init)) { - if (literal_type_p (type) && CP_TYPE_CONST_NON_VOLATILE_P (type)) + if (literal_type_p (type) + && CP_TYPE_CONST_NON_VOLATILE_P (type) + && !TYPE_HAS_MUTABLE_P (type)) { /* 5.19 says that a constant expression can include an lvalue-rvalue conversion applied to "a glvalue of literal type diff --git a/gcc/testsuite/g++.dg/tree-ssa/initlist-opt7.C b/gcc/testsuite/g++.dg/tree-ssa/initlist-opt7.C new file mode 100644 index ..2420db502a67 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/initlist-opt7.C @@ -0,0 +1,13 @@ +// PR c++/116369 +// { dg-do run { target c++11 } } + +struct f{ + mutable int t; +}; + +const f &g = {1}; + +int main() +{ + g.t++; +}
[gcc r15-3573] libstdc++: Add missing exception specifications in tests
https://gcc.gnu.org/g:4e1e50458b2004d0f08ac8c64f89b85fc1a87057 commit r15-3573-g4e1e50458b2004d0f08ac8c64f89b85fc1a87057 Author: Jonathan Wakely Date: Tue Sep 10 16:59:29 2024 +0100 libstdc++: Add missing exception specifications in tests Since r15-3532-g7cebc6384a0ad6 18_support/new_nothrow.cc fails in C++98 mode because G++ diagnoses missing exception specifications for the user-defined (de)allocation functions. Add throw(std::bad_alloc) and throw() for C++98 mode. Similarly, 26_numerics/headers/numeric/synopsis.cc fails in C++20 mode because the declarations of gcd and lcm are not noexcept. libstdc++-v3/ChangeLog: * testsuite/18_support/new_nothrow.cc (THROW_BAD_ALLOC): Define macro to add exception specifications for C++98 mode. (NOEXCEPT): Expand to throw() for C++98 mode. * testsuite/26_numerics/headers/numeric/synopsis.cc (gcd, lcm): Add noexcept. Diff: --- libstdc++-v3/testsuite/18_support/new_nothrow.cc | 18 ++ .../testsuite/26_numerics/headers/numeric/synopsis.cc | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/testsuite/18_support/new_nothrow.cc b/libstdc++-v3/testsuite/18_support/new_nothrow.cc index a3251f5ad64e..551b71dfa589 100644 --- a/libstdc++-v3/testsuite/18_support/new_nothrow.cc +++ b/libstdc++-v3/testsuite/18_support/new_nothrow.cc @@ -41,7 +41,15 @@ static void new_handler () throw MyBadAlloc (); } -void* operator new (size_t n) +#if __cplusplus >= 201103L +# define THROW_BAD_ALLOC noexcept(false) +# define NOEXCEPT noexcept +# else +# define THROW_BAD_ALLOC throw(std::bad_alloc) +# define NOEXCEPT throw() +#endif + +void* operator new (size_t n) THROW_BAD_ALLOC { static size_t cntr; @@ -64,12 +72,6 @@ void* operator new (size_t n) } } -#if __cplusplus >= 201103L -#define NOEXCEPT noexcept -#else -#define NOEXCEPT -#endif - void operator delete (void *p) NOEXCEPT { ++delete_called; @@ -77,7 +79,7 @@ void operator delete (void *p) NOEXCEPT free (static_cast(p) - 1); } -void* operator new[] (size_t n) +void* operator new[] (size_t n) THROW_BAD_ALLOC { ++new_vec_called; return operator new(n); diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc index 87670090f72f..8c33974c2e96 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc @@ -161,10 +161,10 @@ namespace std { #if __cplusplus > 201703L template -constexpr common_type_t gcd(M m, N n); +constexpr common_type_t gcd(M m, N n) noexcept; template -constexpr common_type_t lcm(M m, N n); +constexpr common_type_t lcm(M m, N n) noexcept; template constexpr T midpoint(T a, T b) noexcept;
[gcc r15-3574] c++: Fix get_member_function_from_ptrfunc with -fsanitize=bounds [PR116449]
https://gcc.gnu.org/g:0008050b9d6046ba4e811a03b406fb5d98707cae commit r15-3574-g0008050b9d6046ba4e811a03b406fb5d98707cae Author: Jakub Jelinek Date: Tue Sep 10 18:32:58 2024 +0200 c++: Fix get_member_function_from_ptrfunc with -fsanitize=bounds [PR116449] The following testcase is miscompiled, because get_member_function_from_ptrfunc emits something like (((FUNCTION.__pfn & 1) != 0) ? ptr + FUNCTION.__delta + FUNCTION.__pfn - 1 : FUNCTION.__pfn) (ptr + FUNCTION.__delta, ...) or so, so FUNCTION tree is used there 5 times. There is if (TREE_SIDE_EFFECTS (function)) function = save_expr (function); but in this case function doesn't have side-effects, just nested ARRAY_REFs. Now, if all the FUNCTION trees would be shared, it would work fine, FUNCTION is evaluated in the first operand of COND_EXPR; but unfortunately that isn't the case, both the BIT_AND_EXPR shortening and conversion to bool done for build_conditional_expr actually unshare_expr that first expression, but none of the other 4 are unshared. With -fsanitize=bounds, .UBSAN_BOUNDS calls are added to the ARRAY_REFs and use save_expr to avoid evaluating the argument multiple times, but because that FUNCTION tree is first used in the second argument of COND_EXPR (i.e. conditionally), the SAVE_EXPR initialization is done just there and then the third argument of COND_EXPR just uses the uninitialized temporary and so does the first argument computation as well. The following patch fixes that by doing save_expr even if !TREE_SIDE_EFFECTS, but to avoid doing that too often only if !nonvirtual and if the expression isn't a simple decl. 2024-09-10 Jakub Jelinek PR c++/116449 * typeck.cc (get_member_function_from_ptrfunc): Use save_expr on instance_ptr and function even if it doesn't have side-effects, as long as it isn't a decl. * g++.dg/ubsan/pr116449.C: New test. Diff: --- gcc/cp/typeck.cc | 19 --- gcc/testsuite/g++.dg/ubsan/pr116449.C | 14 ++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index e4e260645f65..b6835286cff3 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -4193,10 +4193,23 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function, if (!nonvirtual && is_dummy_object (instance_ptr)) nonvirtual = true; - if (TREE_SIDE_EFFECTS (instance_ptr)) - instance_ptr = instance_save_expr = save_expr (instance_ptr); + /* Use save_expr even when instance_ptr doesn't have side-effects, +unless it is a simple decl (save_expr won't do anything on +constants), so that we don't ubsan instrument the expression +multiple times. See PR116449. */ + if (TREE_SIDE_EFFECTS (instance_ptr) + || (!nonvirtual && !DECL_P (instance_ptr))) + { + instance_save_expr = save_expr (instance_ptr); + if (instance_save_expr == instance_ptr) + instance_save_expr = NULL_TREE; + else + instance_ptr = instance_save_expr; + } - if (TREE_SIDE_EFFECTS (function)) + /* See above comment. */ + if (TREE_SIDE_EFFECTS (function) + || (!nonvirtual && !DECL_P (function))) function = save_expr (function); /* Start by extracting all the information from the PMF itself. */ diff --git a/gcc/testsuite/g++.dg/ubsan/pr116449.C b/gcc/testsuite/g++.dg/ubsan/pr116449.C new file mode 100644 index ..f13368a51b00 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr116449.C @@ -0,0 +1,14 @@ +// PR c++/116449 +// { dg-do compile } +// { dg-options "-O2 -Wall -fsanitize=undefined" } + +struct C { void foo (int); void bar (); int c[16]; }; +typedef void (C::*P) (); +struct D { P d; }; +static D e[1] = { { &C::bar } }; + +void +C::foo (int x) +{ + (this->*e[c[x]].d) (); +}
[gcc r15-3576] libstdc++: Only use std::ios_base_library_init() for ELF [PR116159]
https://gcc.gnu.org/g:fc7a1fb0238e379d466316aa219734ac61f4bc0e commit r15-3576-gfc7a1fb0238e379d466316aa219734ac61f4bc0e Author: Jonathan Wakely Date: Tue Sep 10 14:36:26 2024 +0100 libstdc++: Only use std::ios_base_library_init() for ELF [PR116159] The undefined std::ios_base_library_init() symbol that is referenced by is only supposed to be used for targets where symbol versioning is supported. The mingw-w64 target defaults to --enable-symvers=gnu due to using GNU ld but doesn't actually support symbol versioning. This means it tries to emit references to the std::ios_base_library_init() symbol, which isn't really defined in the library. This causes problems when using lld to link user binaries. Disable the undefined symbol reference for non-ELF targets. libstdc++-v3/ChangeLog: PR libstdc++/116159 * include/std/iostream (ios_base_library_init): Only define for ELF targets. * src/c++98/ios_init.cc (ios_base_library_init): Likewise. Diff: --- libstdc++-v3/include/std/iostream | 2 +- libstdc++-v3/src/c++98/ios_init.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/iostream b/libstdc++-v3/include/std/iostream index 4f4fa6880d57..4a6dc584d38a 100644 --- a/libstdc++-v3/include/std/iostream +++ b/libstdc++-v3/include/std/iostream @@ -78,7 +78,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if !(_GLIBCXX_USE_INIT_PRIORITY_ATTRIBUTE \ && __has_attribute(__init_priority__)) static ios_base::Init __ioinit; -#elif defined(_GLIBCXX_SYMVER_GNU) +#elif defined(_GLIBCXX_SYMVER_GNU) && defined(__ELF__) __extension__ __asm (".globl _ZSt21ios_base_library_initv"); #endif diff --git a/libstdc++-v3/src/c++98/ios_init.cc b/libstdc++-v3/src/c++98/ios_init.cc index 1422e20d9405..6e2e5014cf0f 100644 --- a/libstdc++-v3/src/c++98/ios_init.cc +++ b/libstdc++-v3/src/c++98/ios_init.cc @@ -199,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __ret; } -#ifdef _GLIBCXX_SYMVER_GNU +#if defined(_GLIBCXX_SYMVER_GNU) && defined(__ELF__) #pragma GCC diagnostic ignored "-Wattribute-alias" void ios_base_library_init (void)
[gcc r15-3575] libstdc++: std::string move assignment should not use POCCA trait [PR116641]
https://gcc.gnu.org/g:c07cf418fdde0c192e370a8d76a991cc7215e9c4 commit r15-3575-gc07cf418fdde0c192e370a8d76a991cc7215e9c4 Author: Jonathan Wakely Date: Tue Sep 10 14:25:41 2024 +0100 libstdc++: std::string move assignment should not use POCCA trait [PR116641] The changes to implement LWG 2579 (r10-327-gdb33efde17932f) made std::string::assign use the propagate_on_container_copy_assignment (POCCA) trait, for consistency with operator=(const basic_string&). However, this also unintentionally affected operator=(basic_string&&) which calls assign(str) to make a deep copy when performing a move is not possible. The fix is for the move assignment operator to call _M_assign(str) instead of assign(str), as this just does the deep copy and doesn't check the POCCA trait first. The bug only affects the unlikely/useless combination of POCCA==true and POCMA==false, but we should fix it for correctness anyway. it should also make move assignment slightly cheaper to compile and execute, because we skip the extra code in assign(const basic_string&). libstdc++-v3/ChangeLog: PR libstdc++/116641 * include/bits/basic_string.h (operator=(basic_string&&)): Call _M_assign instead of assign. * testsuite/21_strings/basic_string/allocator/116641.cc: New test. Diff: --- libstdc++-v3/include/bits/basic_string.h | 2 +- .../21_strings/basic_string/allocator/116641.cc| 53 ++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 944bd230704b..120c0bc9a179 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -915,7 +915,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 __str._M_data(__str._M_use_local_data()); } else // Need to do a deep copy - assign(__str); + _M_assign(__str); __str.clear(); return *this; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/116641.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/116641.cc new file mode 100644 index ..a1a411b87faa --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/116641.cc @@ -0,0 +1,53 @@ +// { dg-do run { target c++11 } } +// { dg-require-effective-target cxx11_abi } + +// Bug 116641 - std::string move assignment incorrectly depends on POCCA + +#include +#include + +template +struct Alloc +{ + using value_type = T; + using propagate_on_container_swap = std::false_type; + using propagate_on_container_copy_assignment = std::true_type; + using propagate_on_container_move_assignment = std::false_type; + + Alloc(int id) : id(id) { } + + template +Alloc(const Alloc& a) : id(a.id) { } + + T* allocate(unsigned long n) + { return std::allocator().allocate(n); } + + void deallocate(T* p, unsigned long n) + { std::allocator().deallocate(p, n); } + + Alloc& operator=(const Alloc&) { throw; } + + bool operator==(const Alloc& a) const { return id == a.id; } + bool operator!=(const Alloc& a) const { return id != a.id; } + + int id; +}; + +void +test_pr116641() +{ + Alloc a1(1), a2(2); + std::basic_string, Alloc> s1(a1), s2(a2); + + s1 = "allocator should not propagate on move assignment"; + VERIFY( s1.get_allocator() == a1 ); + VERIFY( s2.get_allocator() == a2 ); + s2 = std::move(s1); + VERIFY( s1.get_allocator() == a1 ); + VERIFY( s2.get_allocator() == a2 ); +} + +int main() +{ + test_pr116641(); +}
[gcc r15-3578] RISC-V: Fix asm check for Vector SAT_* due to middle-end change
https://gcc.gnu.org/g:6bd3ee7f2f2f4beed5b9d9a530736ad69d2cac42 commit r15-3578-g6bd3ee7f2f2f4beed5b9d9a530736ad69d2cac42 Author: Pan Li Date: Wed Sep 11 07:00:13 2024 +0800 RISC-V: Fix asm check for Vector SAT_* due to middle-end change The middle-end change makes the effect on the layout of the assembly for vector SAT_*. This patch would like to fix it and make it robust. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c: Adjust asm check and make it robust. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-10.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-11.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-12.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-9.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-10.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-11.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-12.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-13.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-14.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-15.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-16.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-17.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-18.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-19.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-20.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-21.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-22.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-23.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-24.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-25.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-26.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-27.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-28.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-29.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-30.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-31.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-32.c: Ditto. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-33.c: Ditto. * gcc.target/riscv/rvv/autovec/bino
[gcc r15-3579] Enable tune fuse_move_and_alu for GNR.
https://gcc.gnu.org/g:f80e4ba94e41410219bdcdb1a0f204ea3f148666 commit r15-3579-gf80e4ba94e41410219bdcdb1a0f204ea3f148666 Author: liuhongt Date: Tue Sep 10 15:04:58 2024 +0800 Enable tune fuse_move_and_alu for GNR. According to Intel Software Optimization Manual[1], the Redwood cove microarchitecture supports LD+OP and MOV+OP macro fusions. The patch enables MOV+OP tune for GNR. [1] https://www.intel.com/content/www/us/en/content-details/814198/intel-64-and-ia-32-architectures-optimization-reference-manual-volume-1.html gcc/ChangeLog: * config/i386/x86-tune.def (X86_TUNE_FUSE_MOV_AND_ALU): Enable for GNR and GNR-D. Diff: --- gcc/config/i386/x86-tune.def | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def index d7e2ad7fd250..3d123da95f0c 100644 --- a/gcc/config/i386/x86-tune.def +++ b/gcc/config/i386/x86-tune.def @@ -153,7 +153,8 @@ DEF_TUNE (X86_TUNE_FUSE_ALU_AND_BRANCH, "fuse_alu_and_branch", /* X86_TUNE_FUSE_MOV_AND_ALU: mov and alu in case mov is reg-reg mov and the destination is used by alu. alu must be one of ADD, ADC, AND, XOR, OR, SUB, SBB, INC, DEC, NOT, SAL, SHL, SHR, SAR. */ -DEF_TUNE (X86_TUNE_FUSE_MOV_AND_ALU, "fuse_mov_and_alu", m_ZNVER5) +DEF_TUNE (X86_TUNE_FUSE_MOV_AND_ALU, "fuse_mov_and_alu", +m_ZNVER5 | m_GRANITERAPIDS | m_GRANITERAPIDS_D) /*/ /* Function prologue, epilogue and function calling sequences. */
[gcc r15-3580] Vect: Support form 1 of vector signed integer .SAT_ADD
https://gcc.gnu.org/g:9b14a5823b685e3a604dc17b02c033f60ad90414 commit r15-3580-g9b14a5823b685e3a604dc17b02c033f60ad90414 Author: Pan Li Date: Wed Sep 11 09:54:38 2024 +0800 Vect: Support form 1 of vector signed integer .SAT_ADD This patch would like to support the vector signed ssadd pattern for the RISC-V backend. Aka Form 1: #define DEF_VEC_SAT_S_ADD_FMT_1(T, UT, MIN, MAX) \ void __attribute__((noinline)) \ vec_sat_s_add_##T##_fmt_1 (T *out, T *x, T *y, unsigned n) \ { \ for (unsigned i = 0; i < n; i++) \ { \ T sum = (UT)x[i] + (UT)y[i]; \ out[i] = (x[i] ^ y[i]) < 0 \ ? sum \ : (sum ^ x[i]) >= 0\ ? sum\ : x[i] < 0 ? MIN : MAX; \ } \ } DEF_VEC_SAT_S_ADD_FMT_1(int64_t, uint64_t, INT64_MIN, INT64_MAX) If the backend implemented the vector mode of ssadd, we will see IR diff similar as below: Before this patch: 108 │ _114 = .SELECT_VL (ivtmp_112, POLY_INT_CST [2, 2]); 109 │ ivtmp_77 = _114 * 8; 110 │ vect__4.9_80 = .MASK_LEN_LOAD (vectp_x.7_78, 64B, { -1, ... }, _114, 0); 111 │ vect__5.10_81 = VIEW_CONVERT_EXPR(vect__4.9_80); 112 │ vect__7.13_85 = .MASK_LEN_LOAD (vectp_y.11_83, 64B, { -1, ... }, _114, 0); 113 │ vect__8.14_86 = VIEW_CONVERT_EXPR(vect__7.13_85); 114 │ vect__9.15_87 = vect__5.10_81 + vect__8.14_86; 115 │ vect_sum_20.16_88 = VIEW_CONVERT_EXPR(vect__9.15_87); 116 │ vect__10.17_89 = vect__4.9_80 ^ vect__7.13_85; 117 │ vect__11.18_90 = vect__4.9_80 ^ vect_sum_20.16_88; 118 │ mask__46.19_92 = vect__10.17_89 >= { 0, ... }; 119 │ _36 = vect__4.9_80 >> 63; 120 │ mask__44.26_104 = vect__11.18_90 < { 0, ... }; 121 │ mask__43.27_105 = mask__46.19_92 & mask__44.26_104; 122 │ _115 = .COND_XOR (mask__43.27_105, _36, { 9223372036854775807, ... }, vect_sum_20.16_88); 123 │ .MASK_LEN_STORE (vectp_out.29_108, 64B, { -1, ... }, _114, 0, _115); 124 │ vectp_x.7_79 = vectp_x.7_78 + ivtmp_77; 125 │ vectp_y.11_84 = vectp_y.11_83 + ivtmp_77; 126 │ vectp_out.29_109 = vectp_out.29_108 + ivtmp_77; 127 │ ivtmp_113 = ivtmp_112 - _114; After this patch: 94 │ # vectp_x.7_82 = PHI 95 │ # vectp_y.10_86 = PHI 96 │ # vectp_out.14_91 = PHI 97 │ # ivtmp_95 = PHI 98 │ _97 = .SELECT_VL (ivtmp_95, POLY_INT_CST [2, 2]); 99 │ ivtmp_81 = _97 * 8; 100 │ vect__4.9_84 = .MASK_LEN_LOAD (vectp_x.7_82, 64B, { -1, ... }, _97, 0); 101 │ vect__7.12_88 = .MASK_LEN_LOAD (vectp_y.10_86, 64B, { -1, ... }, _97, 0); 102 │ vect_patt_40.13_89 = .SAT_ADD (vect__4.9_84, vect__7.12_88); 103 │ .MASK_LEN_STORE (vectp_out.14_91, 64B, { -1, ... }, _97, 0, vect_patt_40.13_89); 104 │ vectp_x.7_83 = vectp_x.7_82 + ivtmp_81; 105 │ vectp_y.10_87 = vectp_y.10_86 + ivtmp_81; 106 │ vectp_out.14_92 = vectp_out.14_91 + ivtmp_81; 107 │ ivtmp_96 = ivtmp_95 - _97; The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. gcc/ChangeLog: * match.pd: Add case 2 for the signed .SAT_ADD consumed by vect pattern. * tree-vect-patterns.cc (gimple_signed_integer_sat_add): Add new matching func decl for signed .SAT_ADD. (vect_recog_sat_add_pattern): Add signed .SAT_ADD pattern match. Signed-off-by: Pan Li Diff: --- gcc/match.pd | 16 gcc/tree-vect-patterns.cc | 5 - 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/match.pd b/gcc/match.pd index a664be5fe238..4cef965c9c7a 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3221,6 +3221,22 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_xor:c (negate (convert (lt @0 integer_zerop))) max_value)) (if (INTEGRAL_TYPE_P (type) && !TYPE_UNSIGNED (type +/* Signed saturation add, case 3: + T sum = (T)((UT)X + (UT)Y) + SAT_S_ADD = (X ^ Y) < 0 && (X ^ sum) >= 0 ? (-(T)(X < 0) ^ MAX) : sum; + + The T and UT are type pair like T=int8_t, UT=uint8_t. */ +(match (signed_integer_sat_add @0 @1) + (cond^ (bit_and:c (lt (bit_xor @0 (nop_convert@2 (plus (nop_convert @0) + (nop_convert @1 +