Re: [PATCH] DWARF: Handle expressions containing "-1" in dw2_asm_output_delta_uleb128.
On Mon, May 28, 2018 at 08:50:46AM +0200, Mark Wielaard wrote: > gcc/ > > * dwarf2asm.c (dw2_asm_output_delta_uleb128): Add brackets around > lab2 if it is an expression containing a minus sign. Ok, thanks. > diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c > index 93577d1..62a1da9 100644 > --- a/gcc/dwarf2asm.c > +++ b/gcc/dwarf2asm.c > @@ -811,7 +811,17 @@ dw2_asm_output_delta_uleb128 (const char *lab1 > ATTRIBUTE_UNUSED, >fputs ("\t.uleb128 ", asm_out_file); >assemble_name (asm_out_file, lab1); >putc ('-', asm_out_file); > - assemble_name (asm_out_file, lab2); > + /* dwarf2out.c might give us an label expression (e.g. .LVL548-1) > + as second argument. If so, make it a subexpression, to make > + sure the substraction is done in the right order. */ > + if (strchr (lab2, '-') != NULL) > +{ > + putc ('(', asm_out_file); > + assemble_name (asm_out_file, lab2); > + putc (')', asm_out_file); > +} > + else > +assemble_name (asm_out_file, lab2); > >if (flag_debug_asm && comment) > { Jakub
Re: [ARM/FDPIC 02/21] [ARM] FDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts
On 25/05/2018 18:32, Joseph Myers wrote: On Fri, 25 May 2018, Christophe Lyon wrote: In libtool.m4, we use uclinuxfdpiceabi in cases where ELF shared libraries support is required, as uclinux does not guarantee that. To confirm: has this libtool.m4 patch gone upstream (or at least been submitted upstream, if not yet reviewed)? Hi Joseph, No sorry, I didn't realize I had to post this patch elsewhere than gcc-patches. I'm going to post it to the libtool project. Looking at gcc/libtool.m4's history, it seems the process would then be to cherry-pick my patch into gcc, rather than merge with the upstream version? Thanks, Christophe
[Ada] Misleading warning on unresolvable package name
This patch fixes an issue whereby the compiler misidentified a package name containing the name of a standard runtime package as said package - leading to and improper error message prompting the user to "With" a package already in scope. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Justin Squirek gcc/ada/ * sem_ch8.adb (Find_Expanded_Name): Add extra guard to make sure the misresolved package name is not a case of mistaken identity. gcc/testsuite/ * gnat.dg/warn15-core-main.adb, gnat.dg/warn15-core.ads, gnat.dg/warn15-interfaces.ads, gnat.dg/warn15.ads: New testcase.--- gcc/ada/sem_ch8.adb +++ gcc/ada/sem_ch8.adb @@ -6336,7 +6336,11 @@ package body Sem_Ch8 is -- If this is a selection from Ada, System or Interfaces, then -- we assume a missing with for the corresponding package. - if Is_Known_Unit (N) then + if Is_Known_Unit (N) + and then not (Present (Entity (Prefix (N))) +and then Scope (Entity (Prefix (N))) /= + Standard_Standard) + then if not Error_Posted (N) then Error_Msg_Node_2 := Selector; Error_Msg_N -- CODEFIX --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/warn15-core-main.adb @@ -0,0 +1,9 @@ +-- { dg-do compile } + +with Interfaces.C; + +procedure Warn15.Core.Main is + use type Interfaces.C.unsigned; -- { dg-error "\"C\" not declared in \"Interfaces\"" } +begin + null; +end Warn15.Core.Main; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/warn15-core.ads @@ -0,0 +1,4 @@ +with Warn15.Interfaces; + +package Warn15.Core is +end Warn15.Core; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/warn15-interfaces.ads @@ -0,0 +1,3 @@ +package Warn15.Interfaces is +end Warn15.Interfaces; + --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/warn15.ads @@ -0,0 +1,2 @@ +package Warn15 is +end Warn15;
[Ada] Further evaluation of type bounds in GNATprove mode
Some static bounds of types are not recognized and evaluated as such in the semantic analysis phase of the frontend, which leads to incomplete information in GNATprove. Fix that in the GNATprove mode only, as this is not needed when full expansion is used. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Yannick Moy gcc/ada/ * sem_res.adb (Resolve_Range): Re-resolve the low bound of a range in GNATprove mode, as the order of resolution (low then high) means that all the information is not available when resolving the low bound the first time.--- gcc/ada/sem_res.adb +++ gcc/ada/sem_res.adb @@ -9800,6 +9800,17 @@ package body Sem_Res is Resolve (L, Typ); Resolve (H, Base_Type (Typ)); + -- Reanalyze the lower bound after both bounds have been analyzed, so + -- that the range is known to be static or not by now. This may trigger + -- more compile-time evaluation, which is useful for static analysis + -- with GNATprove. This is not needed for compilation or static analysis + -- with CodePeer, as full expansion does that evaluation then. + + if GNATprove_Mode then + Set_Analyzed (L, False); + Resolve (L, Typ); + end if; + -- Check for inappropriate range on unordered enumeration type if Bad_Unordered_Enumeration_Reference (N, Typ)
[Ada] Warning on recursive call within postcondition
This patch adds a warning to a function call that appears within a postcondition for said function. This may mean an omission of an attribute reference 'Result, and may lead to an infinite loop on a call to that function. Compiling post_error.ads must yield: post_error.ads:3:11: warning: postcondition does not mention function result post_error.ads:3:19: warning: call to "Foo" within its postcondition will lead to infinite recursion package Post_Error is function Foo (A : out Integer) return Integer with Post => Foo (A) /= 0; pragma Import (C, Foo); end Post_Error; Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Ed Schonberg gcc/ada/ * sem_util.adb (Is_Function_Result): Add a warning if a postcondition includes a call to function to which it applies. This may mean an omission of an attribute reference 'Result, in particular if the function is pqrameterless.--- gcc/ada/sem_util.adb +++ gcc/ada/sem_util.adb @@ -3880,6 +3880,17 @@ package body Sem_Util is Result_Seen := True; return Abandon; +-- Warn on infinite recursion if call is to current function. + +elsif Nkind (N) = N_Function_Call + and then Is_Entity_Name (Name (N)) + and then Entity (Name (N)) = Subp_Id + and then not Is_Potentially_Unevaluated (N) +then + Error_Msg_NE ("call to & within its postcondition " + & "will lead to infinite recursion?", N, Subp_Id); + return OK; + -- Continue the traversal else
[Ada] Minor tweak to output of -gnatR
This changes the output of -gnatR for extensions of tagged record types to avoid displaying the internal _Parent component, which overlaps with other components and is thus more confusing than helpful. For the following hierarchy: type R1 is tagged record I : Integer; end record; type R2 is new R1 with record C : Character; end record; the output -gnatR must now be: for R1'Object_Size use 128; for R1'Value_Size use 96; for R1'Alignment use 8; for R1 use record _Tag at 0 range 0 .. 63; Iat 8 range 0 .. 31; end record; for R2'Object_Size use 192; for R2'Value_Size use 136; for R2'Alignment use 8; for R2 use record _Tag at 0 range 0 .. 63; Iat 8 range 0 .. 31; Cat 16 range 0 .. 7; end record; Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Eric Botcazou gcc/ada/ * repinfo.adb (Compute_Max_Length): Skip _Parent component. (List_Record_Layout): Likewise.--- gcc/ada/repinfo.adb +++ gcc/ada/repinfo.adb @@ -915,6 +915,12 @@ package body Repinfo is goto Continue; end if; +-- Skip _Parent component in extension (to avoid overlap) + +if Chars (Comp) = Name_uParent then + goto Continue; +end if; + -- All other cases declare @@ -1010,6 +1016,12 @@ package body Repinfo is goto Continue; end if; +-- Skip _Parent component in extension (to avoid overlap) + +if Chars (Comp) = Name_uParent then + goto Continue; +end if; + -- All other cases declare
[Ada] Crash on aspect/pragma Linked_Section with -gnatR2
This patch modifies the output of the representation information related to aspect or pragma Linker_Section, achieved with compiler switch -gnatR2. The value of the section argument is now properly retrieved. Previously it was assumed that the value is always a N_String_Literal, however the semantics of the annotation allow for any static string expression, including a reference to a static string. -- Source -- -- linker_sections.ads package Linker_Sections is LS_1 : constant String := "1"; LS_2 : constant String := "2" & "2"; LS_3 : constant String := LS_1 & "3"; LS_4 : constant String := "4" & LS_2; Val_1 : Integer with Linker_Section => LS_1; Val_2 : Integer with Linker_Section => LS_2; Val_3 : Integer with Linker_Section => LS_3; Val_4 : Integer with Linker_Section => LS_4; Val_5 : Integer with Linker_Section => LS_1 & "5"; Val_6 : Integer with Linker_Section => LS_2 & "6"; Val_7 : Integer with Linker_Section => LS_3 & "7"; Val_8 : Integer with Linker_Section => LS_4 & "8"; Val_9 : Integer with Linker_Section => "9" & LS_1; Val_10 : Integer with Linker_Section => "10" & LS_2; Val_11 : Integer with Linker_Section => "11" & LS_3; Val_12 : Integer with Linker_Section => "12" & LS_4; Val_13 : Integer; pragma Linker_Section (Val_13, LS_1); Val_14 : Integer; pragma Linker_Section (Val_14, LS_2); Val_15 : Integer; pragma Linker_Section (Val_15, LS_3); Val_16 : Integer; pragma Linker_Section (Val_16, LS_4); Val_17 : Integer; pragma Linker_Section (Val_17, LS_1 & "5"); Val_18 : Integer; pragma Linker_Section (Val_18, LS_2 & "6"); Val_19 : Integer; pragma Linker_Section (Val_19, LS_3 & "7"); Val_20 : Integer; pragma Linker_Section (Val_20, LS_4 & "8"); Val_21 : Integer; pragma Linker_Section (Val_21, "9" & LS_1); Val_22 : Integer; pragma Linker_Section (Val_22, "10" & LS_2); Val_23 : Integer; pragma Linker_Section (Val_23, "11" & LS_3); Val_24 : Integer; pragma Linker_Section (Val_24, "12" & LS_4); end Linker_Sections; - -- Compilation -- - $ gcc -c -gnatR2s linker_sections.ads Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Hristian Kirtchev gcc/ada/ * repinfo.adb (Expr_Value_S): New routine. (List_Linker_Section): Properly extract the value of the section argument.--- gcc/ada/repinfo.adb +++ gcc/ada/repinfo.adb @@ -685,23 +685,47 @@ package body Repinfo is - procedure List_Linker_Section (Ent : Entity_Id) is - Arg : Node_Id; + function Expr_Value_S (N : Node_Id) return Node_Id; + -- Returns the folded value of the expression. This function is called + -- in instances where it has already been determined that the expression + -- is static or its value is known at compile time. This version is used + -- for string types and returns the corresponding N_String_Literal node. + -- NOTE: This is an exact copy of Sem_Eval.Expr_Value_S. Licensing stops + -- Repinfo from within Sem_Eval. Once ASIS is removed, and the licenses + -- are modified, Repinfo should be able to rely on Sem_Eval. + + -- + -- Expr_Value_S -- + -- + + function Expr_Value_S (N : Node_Id) return Node_Id is + begin + if Nkind (N) = N_String_Literal then +return N; + else +pragma Assert (Ekind (Entity (N)) = E_Constant); +return Expr_Value_S (Constant_Value (Entity (N))); + end if; + end Expr_Value_S; + + -- Local variables + + Args : List_Id; + Sect : Node_Id; + + -- Start of processing for List_Linker_Section begin if Present (Linker_Section_Pragma (Ent)) then + Args := Pragma_Argument_Associations (Linker_Section_Pragma (Ent)); + Sect := Expr_Value_S (Get_Pragma_Arg (Last (Args))); + Write_Str ("pragma Linker_Section ("); List_Name (Ent); Write_Str (", """); - Arg := - Last (Pragma_Argument_Associations (Linker_Section_Pragma (Ent))); - - if Nkind (Arg) = N_Pragma_Argument_Association then -Arg := Expression (Arg); - end if; - - pragma Assert (Nkind (Arg) = N_String_Literal); - String_To_Name_Buffer (Strval (Arg)); + pragma Assert (Nkind (Sect) = N_String_Literal); + String_To_Name_Buffer (Strval (Sect)); Write_Str (Name_Buffer (1 .. Name_Len)); Write_Str (""");"); Write_Eol;
[Ada] Spurious constraint error on array of null-excluding components
This patch fixes an issue whereby the compiler would raise spurious runtime errors when an array of null-excluding components was initialized with an expression which required the secondary stack (such as with an concatination operation) due to certain generated checks which were incorrected performed on internal object declarations. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Justin Squirek gcc/ada/ * exp_ch3.adb (Build_Initialization_Call): Add logic to pass the appropriate actual to match new formal. (Init_Formals): Add new formal *_skip_null_excluding_check * exp_util.adb, exp_util.ads (Enclosing_Init_Proc): Added to fetch the enclosing Init_Proc from the current scope. (Inside_Init_Proc): Refactored to use Enclosing_Init_Proc (Needs_Conditional_Null_Excluding_Check): Added to factorize the predicate used to determine how to generate an Init_Proc for a given type. (Needs_Constant_Address): Minor reformatting * sem_res.adb (Resolve_Null): Add logic to generate a conditional check in certain cases gcc/testsuite/ * gnat.dg/array31.adb: New testcase.--- gcc/ada/exp_ch3.adb +++ gcc/ada/exp_ch3.adb @@ -1550,6 +1550,29 @@ package body Exp_Ch3 is Decl := Empty; end if; + -- Handle the optionally generated formal *_skip_null_excluding_checks + + if Needs_Conditional_Null_Excluding_Check (Full_Init_Type) then + + -- Look at the associated node for the object we are referencing and + -- verify that we are expanding a call to an Init_Proc for an + -- internally generated object declaration before passing True and + -- skipping the relevant checks. + + if Nkind (Id_Ref) in N_Has_Entity + and then Comes_From_Source (Associated_Node (Id_Ref)) + then +Append_To (Args, + New_Occurrence_Of (Standard_True, Loc)); + + -- Otherwise, we pass False to perform null excluding checks + + else +Append_To (Args, + New_Occurrence_Of (Standard_False, Loc)); + end if; + end if; + -- Add discriminant values if discriminants are present if Has_Discriminants (Full_Init_Type) then @@ -8643,6 +8666,24 @@ package body Exp_Ch3 is Parameter_Type => New_Occurrence_Of (Standard_String, Loc))); end if; + -- Due to certain edge cases such as arrays with null excluding + -- components being built with the secondary stack it becomes necessary + -- to add a formal to the Init_Proc which controls whether we raise + -- constraint errors on generated calls for internal object + -- declarations. + + if Needs_Conditional_Null_Excluding_Check (Typ) then + Append_To (Formals, + Make_Parameter_Specification (Loc, + Defining_Identifier => + Make_Defining_Identifier (Loc, + New_External_Name (Chars + (Component_Type (Typ)), "_skip_null_excluding_check")), + In_Present => True, + Parameter_Type => + New_Occurrence_Of (Standard_Boolean, Loc))); + end if; + return Formals; exception --- gcc/ada/exp_util.adb +++ gcc/ada/exp_util.adb @@ -4751,6 +4751,26 @@ package body Exp_Util is return New_Exp; end Duplicate_Subexpr_Move_Checks; + - + -- Enclosing_Init_Proc -- + - + + function Enclosing_Init_Proc return Entity_Id is + S : Entity_Id; + + begin + S := Current_Scope; + while Present (S) and then S /= Standard_Standard loop + if Is_Init_Proc (S) then +return S; + else +S := Scope (S); + end if; + end loop; + + return Empty; + end Enclosing_Init_Proc; + -- Ensure_Defined -- @@ -7534,19 +7554,10 @@ package body Exp_Util is -- function Inside_Init_Proc return Boolean is - S : Entity_Id; + Proc : constant Entity_Id := Enclosing_Init_Proc; begin - S := Current_Scope; - while Present (S) and then S /= Standard_Standard loop - if Is_Init_Proc (S) then -return True; - else -S := Scope (S); - end if; - end loop; - - return False; + return Proc /= Empty; end Inside_Init_Proc; @@ -10430,6 +10441,72 @@ package body Exp_Util is end if; end May_Generate_Large_Temp; + + -- Needs_Conditional_Null_Excluding_Check -- + + + function Needs_Conditional_Null_Excluding_Check + (Typ : Entity_Id) return Boolean + is + begin + return Is_Array_Type (Typ) + and then Ca
[Ada] Spurious error on aspect Volatile
This patch modifies the analysis of aspect/pragma Volatile to correct accept the annotation when it applies to single protected and single task types, and SPARK_Mode On is in effect. -- Source -- -- pack.ads package Pack with SPARK_Mode is protected PO_Aspect with Volatile is end; -- OK protected PO_Pragma is end; pragma Volatile (PO_Pragma); -- OK task TO_Aspect with Volatile; -- OK task TO_Pragma; pragma Volatile (TO_Pragma); -- OK end Pack; -- Compilation and output -- $ gcc -c pack.ads $ gcc -c pack.ads -gnatd.F cannot generate code for file pack.ads (package spec) Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Hristian Kirtchev gcc/ada/ * sem_prag.adb (Process_Atomic_Independent_Shared_Volatile): Include the declarations of single concurrent types because they fall in the category of full type and object declarations.--- gcc/ada/sem_prag.adb +++ gcc/ada/sem_prag.adb @@ -7399,9 +7399,11 @@ package body Sem_Prag is if SPARK_Mode = On and then Prag_Id = Pragma_Volatile - and then - not Nkind_In (Original_Node (Decl), N_Full_Type_Declaration, - N_Object_Declaration) + and then not Nkind_In (Original_Node (Decl), + N_Full_Type_Declaration, + N_Object_Declaration, + N_Single_Protected_Declaration, + N_Single_Task_Declaration) then Error_Pragma_Arg ("argument of pragma % must denote a full type or object "
[Ada] Fix internal error on nested record types with representation clause
This fixes a long-standing issue with the expansion of equality functions generated for discriminated record types with variant part. In this case the front-end recursively expands equality functions for the composite sub-components, in particular the array sub-components. But it systematically uses the unconstrained base type for them, which leads to both a more complex equality function, because of the need to compare the bounds, and an additional unchecked conversion from type to base type. Now this unchecked conversion may block a further expansion of the array sub-component, for example if it is a large array of record types subject to a component clause that causes it not to start on a byte boundary, and thus may lead to an internal error downstream in the back-end. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Eric Botcazou gcc/ada/ * exp_ch4.adb (Expand_Composite_Equality): For a composite (or FP) component type, do not expand array equality using the unconstrained base type, except for the case where the bounds of the type depend on a discriminant. gcc/testsuite/ * gnat.dg/rep_clause6.adb, gnat.dg/rep_clause6.ads: New testcase.--- gcc/ada/exp_ch4.adb +++ gcc/ada/exp_ch4.adb @@ -2428,12 +2428,34 @@ package body Exp_Ch4 is -- For composite component types, and floating-point types, use the -- expansion. This deals with tagged component types (where we use - -- the applicable equality routine) and floating-point, (where we + -- the applicable equality routine) and floating-point (where we -- need to worry about negative zeroes), and also the case of any -- composite type recursively containing such fields. else -return Expand_Array_Equality (Nod, Lhs, Rhs, Bodies, Full_Type); +declare + Comp_Typ : Entity_Id; + +begin + -- Do the comparison in the type (or its full view) and not in + -- its unconstrained base type, because the latter operation is + -- more complex and would also require an unchecked conversion. + + if Is_Private_Type (Typ) then + Comp_Typ := Underlying_Type (Typ); + else + Comp_Typ := Typ; + end if; + + -- Except for the case where the bounds of the type depend on a + -- discriminant, or else we would run into scoping issues. + + if Size_Depends_On_Discriminant (Comp_Typ) then + Comp_Typ := Full_Type; + end if; + + return Expand_Array_Equality (Nod, Lhs, Rhs, Bodies, Comp_Typ); +end; end if; -- Case of tagged record types --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/rep_clause6.adb @@ -0,0 +1,5 @@ +-- { dg-do compile } + +package body Rep_Clause6 is + procedure Dummy is null; +end Rep_Clause6; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/rep_clause6.ads @@ -0,0 +1,61 @@ +package Rep_Clause6 is + + type B1_Type is range 0 .. 2**1 - 1; + for B1_Type'Size use 1; + + type U10_Type is range 0 .. 2**10 - 1; + for U10_Type'Size use 10; + + type B5_Type is range 0 .. 2**5 - 1; + for B5_Type'Size use 5; + + type B11_Type is range 0 .. 2**11 - 1; + for B11_Type'Size use 11; + + type Rec1 is record + B1 : B1_Type; + U10 : U10_Type; + B5 : B5_Type; + end record; + + for Rec1 use record + B1 at 0 range 0 .. 0; + U10 at 0 range 1 .. 10; + B5 at 0 range 11 .. 15; + end record; + for Rec1'Size use 16; + + type Arr is array (1 .. 5) of Rec1; + for Arr'Size use 80; + + subtype Header_Type is String (1 .. 16); + + type Rec2 is record + Header : Header_Type; + Spare_5 : B5_Type; + Deleted_Reports : Arr; + Block_End : B11_Type; + end record; + + for Rec2 use record + Header at 0 range 0 .. 127; + Spare_5 at 16 range 0 .. 4; + Deleted_Reports at 16 range 5 .. 84; + Block_End at 24 range 21 .. 31; + end record; + for Rec2'Size use 224; + + type Enum is (A_Msg, B_Msg, C_Msg, D_Msg); + + type Rec3 (Msg_Type : Enum := Enum'First) is record + case Msg_Type is + when A_Msg => A_M : Arr; + when B_Msg => B_M : Arr; + when C_Msg => C_M : Rec2; + when others => null; + end case; + end record; + + procedure Dummy; + +end Rep_Clause6;
[Ada] Better accuracy in float-to-fixed conversions
This patch improves the accuracy of conversions from a floating point to a fixed point type when the fixed point type has a specified Snall that is not a power of two. Previously the conversion of Fixed_Point_Type'First to some floating point number and back to Fixed_Point_Type raised Constraint error. This result is within the accuracy imposed by tne Numerics annex of the RM but is certainly undesirable. This patch transforms the conversion to avoid extra manipulations of the 'Small of the type, so that the identity: Fixed_T (Float_T (Fixed_Val)) = Fixed_Val holds over the range of Fixed_T. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Ed Schonberg gcc/ada/ * exp_ch4.adb (Real_Range_Check): Specialize float-to-fixed conversions when bounds of fixed type are static, to remove some spuerfluous implicit conversions and provide an accurate result when converting back and forth between the fixed point type and a floating point type. gcc/testsuite/ * gnat.dg/fixedpnt5.adb: New testcase.--- gcc/ada/exp_ch4.adb +++ gcc/ada/exp_ch4.adb @@ -10937,8 +10937,13 @@ package body Exp_Ch4 is Lo : constant Node_Id := Type_Low_Bound (Target_Type); Hi : constant Node_Id := Type_High_Bound (Target_Type); Xtyp : constant Entity_Id := Etype (Operand); - Conv : Node_Id; - Tnn : Entity_Id; + + Conv : Node_Id; + Lo_Arg : Node_Id; + Lo_Val : Node_Id; + Hi_Arg : Node_Id; + Hi_Val : Node_Id; + Tnn: Entity_Id; begin -- Nothing to do if conversion was rewritten @@ -11041,34 +11046,108 @@ package body Exp_Ch4 is Tnn := Make_Temporary (Loc, 'T', Conv); + -- For a conversion from Float to Fixed where the bounds of the + -- fixed-point type are static, we can obtain a more accurate + -- fixed-point value by converting the result of the floating- + -- point expression to an appropriate integer type, and then + -- performing an unchecked conversion to the target fixed-point + -- type. The range check can then use the corresponding integer + -- value of the bounds instead of requiring further conversions. + -- This preserves the identity: + + --Fix_Val = Fixed_Type (Float_Type (Fix_Val)) + + -- which used to fail when Fix_Val was a bound of the type and + -- the 'Small was not a representable number. + -- This transformation requires an integer type large enough to + -- accommodate a fixed-point value. This will not be the case + -- in systems where Duration is larger than Long_Integer. + + if Is_Ordinary_Fixed_Point_Type (Target_Type) + and then Is_Floating_Point_Type (Operand_Type) + and then RM_Size (Base_Type (Target_Type)) <= + RM_Size (Standard_Long_Integer) + and then Nkind (Lo) = N_Real_Literal + and then Nkind (Hi) = N_Real_Literal + then +-- Find the integer type of the right size to perform an unchecked +-- conversion to the target fixed-point type. + +declare + Int_Type : Entity_Id; + Bfx_Type : constant Entity_Id := Base_Type (Target_Type); + +begin + if RM_Size (Bfx_Type) > RM_Size (Standard_Integer) then + Int_Type := Standard_Long_Integer; + + elsif + RM_Size (Bfx_Type) > RM_Size (Standard_Short_Integer) + then + Int_Type := Standard_Integer; + + else + Int_Type := Standard_Short_Integer; + end if; + + -- Create integer objects for range checking of result. + + Lo_Arg := Unchecked_Convert_To (Int_Type, + New_Occurrence_Of (Tnn, Loc)); + Lo_Val := Make_Integer_Literal (Loc, + Corresponding_Integer_Value (Lo)); + + Hi_Arg := Unchecked_Convert_To (Int_Type, + New_Occurrence_Of (Tnn, Loc)); + Hi_Val := Make_Integer_Literal (Loc, + Corresponding_Integer_Value (Hi)); + + -- Rewrite conversion as an integer conversion of the + -- original floating-point expression, followed by an + -- unchecked conversion to the target fixed-point type. + + Conv := Make_Unchecked_Type_Conversion (Loc, + Subtype_Mark => + New_Occurrence_Of (Target_Type, Loc), + Expression => + Convert_To (Int_Type, Expression (Conv))); +end; + + else -- For all other conversions + +Lo_Arg := New_Occurrence_Of (Tnn, Loc); +Lo_Val := Make_Attribute_Reference (Loc, +
[Ada] Fix internal error on renaming of equality for record type
This adjusts the previous change to the cases where the array type is not yet frozen and, therefore, where Size_Depends_On_Discriminant is not yet computed, by doing the computation manually. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Eric Botcazou gcc/ada/ * exp_ch4.adb (Expand_Composite_Equality): Compute whether the size depends on a discriminant manually instead of using the predicate Size_Depends_On_Discriminant in the array type case. gcc/testsuite/ * gnat.dg/renaming12.adb, gnat.dg/renaming12.ads: New testcase.--- gcc/ada/exp_ch4.adb +++ gcc/ada/exp_ch4.adb @@ -2435,6 +2435,10 @@ package body Exp_Ch4 is else declare Comp_Typ : Entity_Id; + Indx : Node_Id; + Ityp : Entity_Id; + Lo : Node_Id; + Hi : Node_Id; begin -- Do the comparison in the type (or its full view) and not in @@ -2450,9 +2454,25 @@ package body Exp_Ch4 is -- Except for the case where the bounds of the type depend on a -- discriminant, or else we would run into scoping issues. - if Size_Depends_On_Discriminant (Comp_Typ) then - Comp_Typ := Full_Type; - end if; + Indx := First_Index (Comp_Typ); + while Present (Indx) loop + Ityp := Etype (Indx); + + Lo := Type_Low_Bound (Ityp); + Hi := Type_High_Bound (Ityp); + + if (Nkind (Lo) = N_Identifier + and then Ekind (Entity (Lo)) = E_Discriminant) +or else + (Nkind (Hi) = N_Identifier + and then Ekind (Entity (Hi)) = E_Discriminant) + then + Comp_Typ := Full_Type; + exit; + end if; + + Next_Index (Indx); + end loop; return Expand_Array_Equality (Nod, Lhs, Rhs, Bodies, Comp_Typ); end; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/renaming12.adb @@ -0,0 +1,7 @@ +-- { dg-do compile } + +package body Renaming12 is + + procedure Dummy is null; + +end Renaming12; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/renaming12.ads @@ -0,0 +1,23 @@ +package Renaming12 is + + type Index_Type is range 0 .. 40; + + type Rec1 is record +B : Boolean; + end record; + + type Arr is array (Index_Type range <>) of Rec1; + + type Rec2 (Count : Index_Type := 0) is record +A : Arr (1 .. Count); + end record; + + package Ops is + +function "=" (L : Rec2; R : Rec2) return Boolean renames Renaming12."="; + + end Ops; + + procedure Dummy; + +end Renaming12;
[Ada] Update FE check following change in SPARK RM 7.1.3(12)
SPARK Reference Manual changed to accept attributes First, Last and Length as not leading to an evaluation of a part of the prefix object. This is reflected here in the checking code for that rule. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Yannick Moy gcc/ada/ * sem_util.adb (Is_OK_Volatile_Context): Add attributes First, Last and Length as valid non-interfering contexts for SPARK.--- gcc/ada/sem_util.adb +++ gcc/ada/sem_util.adb @@ -15999,16 +15999,19 @@ package body Sem_Util is return True; -- The volatile object appears as the prefix of attributes Address, - -- Alignment, Component_Size, First_Bit, Last_Bit, Position, Size, - -- Storage_Size. + -- Alignment, Component_Size, First, First_Bit, Last, Last_Bit, Length, + -- Position, Size, Storage_Size. elsif Nkind (Context) = N_Attribute_Reference and then Prefix (Context) = Obj_Ref and then Nam_In (Attribute_Name (Context), Name_Address, Name_Alignment, Name_Component_Size, + Name_First, Name_First_Bit, + Name_Last, Name_Last_Bit, + Name_Length, Name_Position, Name_Size, Name_Storage_Size)
[Ada] Minor cleanup in repinfo unit
This removes the Truth_Andif_Expr and Truth_Orif_Expr codes for expressions handled by the repinfo unit, since they are redundant with Truth_And_Expr and Truth_Or_Expr respectively in this context. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Eric Botcazou gcc/ada/ * repinfo.ads (TCode): Adjust range. (Truth_Andif_Expr): Remove. (Truth_Orif_Expr): Likewise. (Truth_And_Expr .. Dynamic_Val): Adjust value. * repinfo.adb (Print_Expr): Remove handling of Truth_{And,Or}if_Expr. (Rep_Value): Likewise. * repinfo.h (Truth_Andif_Expr): Remove. (Truth_Orif_Expr): Likewise. (Truth_And_Expr .. Dynamic_Val): Adjust value. * gcc-interface/decl.c (annotate_value) : Fall through to TRUTH_AND_EXPR case. : Fall through to TRUTH_OR_EXPR case.--- gcc/ada/gcc-interface/decl.c +++ gcc/ada/gcc-interface/decl.c @@ -8132,9 +8132,9 @@ annotate_value (tree gnu_size) case MIN_EXPR: tcode = Min_Expr; break; case MAX_EXPR: tcode = Max_Expr; break; case ABS_EXPR: tcode = Abs_Expr; break; -case TRUTH_ANDIF_EXPR: tcode = Truth_Andif_Expr; break; -case TRUTH_ORIF_EXPR: tcode = Truth_Orif_Expr; break; +case TRUTH_ANDIF_EXPR: case TRUTH_AND_EXPR: tcode = Truth_And_Expr; break; +case TRUTH_ORIF_EXPR: case TRUTH_OR_EXPR: tcode = Truth_Or_Expr; break; case TRUTH_XOR_EXPR: tcode = Truth_Xor_Expr; break; case TRUTH_NOT_EXPR: tcode = Truth_Not_Expr; break; --- gcc/ada/repinfo.adb +++ gcc/ada/repinfo.adb @@ -621,12 +621,6 @@ package body Repinfo is when Abs_Expr => Unop ("abs "); - when Truth_Andif_Expr => - Binop (" and if "); - - when Truth_Orif_Expr => - Binop (" or if "); - when Truth_And_Expr => Binop (" and "); @@ -1554,12 +1548,6 @@ package body Repinfo is when Abs_Expr => return UI_Abs (V (Node.Op1)); - when Truth_Andif_Expr => - return B (T (Node.Op1) and then T (Node.Op2)); - - when Truth_Orif_Expr => - return B (T (Node.Op1) or else T (Node.Op2)); - when Truth_And_Expr => return B (T (Node.Op1) and then T (Node.Op2)); --- gcc/ada/repinfo.ads +++ gcc/ada/repinfo.ads @@ -136,7 +136,7 @@ package Repinfo is -- Subtype used for values that can either be a Node_Ref (negative) -- or a value (non-negative) - type TCode is range 0 .. 29; + type TCode is range 0 .. 27; -- Type used on Ada side to represent DEFTREECODE values defined in -- tree.def. Only a subset of these tree codes can actually appear. -- The names are the names from tree.def in Ada casing. @@ -153,24 +153,22 @@ package Repinfo is Trunc_Mod_Expr : constant TCode := 8; -- mod for trunc_div2 Ceil_Mod_Expr: constant TCode := 9; -- mod for ceil_div 2 Floor_Mod_Expr : constant TCode := 10; -- mod for floor_div2 - Exact_Div_Expr : constant TCode := 11; -- exact div2 + Exact_Div_Expr : constant TCode := 11; -- exact division 2 Negate_Expr : constant TCode := 12; -- negation 1 Min_Expr : constant TCode := 13; -- minimum 2 Max_Expr : constant TCode := 14; -- maximum 2 Abs_Expr : constant TCode := 15; -- absolute value 1 - Truth_Andif_Expr : constant TCode := 16; -- Boolean and then 2 - Truth_Orif_Expr : constant TCode := 17; -- Boolean or else 2 - Truth_And_Expr : constant TCode := 18; -- Boolean and 2 - Truth_Or_Expr: constant TCode := 19; -- Boolean or 2 - Truth_Xor_Expr : constant TCode := 20; -- Boolean xor 2 - Truth_Not_Expr : constant TCode := 21; -- Boolean not 1 - Lt_Expr : constant TCode := 22; -- comparison < 2 - Le_Expr : constant TCode := 23; -- comparison <=2 - Gt_Expr : constant TCode := 24; -- comparison > 2 - Ge_Expr : constant TCode := 25; -- comparison >=2 - Eq_Expr : constant TCode := 26; -- comparison = 2 - Ne_Expr : constant TCode := 27; -- comparison /=2 - Bit_And_Expr : constant TCode := 28; -- Binary and 2 + Truth_And_Expr : constant TCode := 16; -- boolean and 2 + Truth_Or_Expr: constant TCode := 17; -- boolean or 2 + Truth_Xor_Expr : constant TCode := 18; -- boolean xor 2 + Truth_Not_Expr : constant TCode := 19; -- boolean not 1 + Lt_Expr : constant TCode := 20; -- comparison < 2 + Le_Expr : co
[Ada] Remove Valop from the Repinfo unit
This removes the recently added Valop as redundant. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-28 Eric Botcazou gcc/ada/ * repinfo.adb (List_GCC_Expression): Remove Valop and replace calls to it with calls to Unop.--- gcc/ada/repinfo.adb +++ gcc/ada/repinfo.adb @@ -530,9 +530,6 @@ package body Repinfo is procedure Binop (S : String); -- Output text for binary operator with S being operator name - procedure Valop (S : String); - -- Output text for special value with S being value symbol - -- -- Unop -- -- @@ -556,16 +553,6 @@ package body Repinfo is Write_Char (')'); end Binop; - --- - -- Valop -- - --- - - procedure Valop (S : String) is - begin - Write_Str (S); - UI_Write (Node.Op1); - end Valop; - -- Start of processing for Print_Expr begin @@ -655,10 +642,10 @@ package body Repinfo is Binop (" & "); when Discrim_Val => - Valop ("#"); + Unop ("#"); when Dynamic_Val => - Valop ("var"); + Unop ("var"); end case; end; end if;
Re: [PATCH] consider MIN_EXPR in get_size_range() (PR 85888)
On Fri, May 25, 2018 at 10:15 PM Martin Sebor wrote: > Attached is revision 3 of the patch incorporating your > determine_value_range function with the requested changes. I'm somewhat torn about removing the "basic" interface on SSA names so can you please not change get_range_info for now and instead use determine_value_range in get_size_range for now? OK with that change. Thanks, Richard. > Martin
Re: [PING] [PATCH] Avoid excessive function type casts with splay-trees
On Sat, May 26, 2018 at 10:19 AM Bernd Edlinger wrote: > On 05/17/18 16:37, Bernd Edlinger wrote: > > On 05/17/18 15:39, Richard Biener wrote: > >> On Thu, May 17, 2018 at 3:21 PM Bernd Edlinger > >> > >> wrote: > >> > >>> Ping... > >> > >> So this makes all traditional users go through the indirect > >> splay_tree_compare_wrapper > >> and friends (which is also exported for no good reason?). And all users > >> are traditional > >> at the moment. > >> > > > > all except gcc/typed-splay-tree.h which only works if VALUE_TYPE is > > compatible with uint_ptr_t but cannot check this requirement. > > This one worried me the most. > > > > But not having to rewrite omp-low.c for instance where splay_tree_lookup > > and access to n->value are made all the time, made me think it > > will not work to rip out the old interface completely. > > > Well, I think it will be best to split this patch in two parts: > One that adds just two utility functions for avoiding undefined > function type casts which can be used with the original C interface. > This first part is attached. > And another part that uses a similar approach as the splay-tree in > libgomp, but instead of creating a type-safe C interface it should > translate the complete code from splay-tree.c/.h into a template. > The second part, I plan to do at a later time. > Is this OK for trunk? Looks ok to me. Do we need to worry about !HAVE_STRING_H and using strcmp? Thanks, Richard. > Thanks > Bernd.
Re: [PATCH, rs6000] Remove incorrect built-in function documentation
Hi Kelvin, On Wed, May 23, 2018 at 05:04:23PM -0500, Kelvin Nilsen wrote: > The following two functions are removed because they are not implemented: > > vector float vec_copysign (vector float); > vector float vec_recip (vector float, vector float); Should they be though? The corresponding __builtin_* exist? But I guess no one has ever tried to use it even. > The following six functions are removed because though they are implemented, > they are not specified in the AltiVec PIM document and the type of the result > vector does not match the type of the supplied pointer argument: > > vector signed int vec_lde (int, const long long *); > vector unsigned int vec_lde (int, const unsigned long long *); > > vector int vec_ld (int, long *) > vector unsigned int vec_ld (int, const unsigned long *); > > vector signed int vec_lvewx (int, long *); > vector unsigned int vec_lvewx (int, unsigned long *); Ack. > The following two functions are removed because they are not implemented. > Also, they are not specified in the AltiVec PIM document and the type of > the result vector does not match the type of the supplied pointer argument: > > vector signed int vec_ldl (int, const long *); > vector unsigned int vec_ldl (int, const unsigned long *); Ah, you're leaving vec_ldl, just removing this paremeter combination. Ack. > The following four functions are removed because they are not implemented. > They do happen to be specified in the AltiVec PIM document. Until they are > implemented, they should not be documented: > > void vec_st (vector pixel, int, unsigned short *) > void vec_st (vector pixel, int, short *) > > void vec_stl (vector pixel, int, unsigned short *); > void vec_stl (vector pixel, int, short *); If no one missed it so far, it is never going to happen :-) > The following two functions are removed because they are not implemented. > They are not specified in the AltiVec PIM or ABI v.2 documents: > > void vec_stvehx (vector pixel, int, short *); > void vec_stvehx (vector pixel, int, unsigned short *); > > The following function was incompletely documented. The argument list lacked > a closing parenthesis. There is no function by this name. > > test_vsi_packsu_vssi_vssi (vector signed short x, Heh. Okay for trunk. Thanks! Segher > 2018-05-23 Kelvin Nilsen > > * doc/extend.texi (PowerPC AltiVec Built-in Functions): Remove > descriptions of various incorrectly documented functions.
[PATCH] Introduce VEC_UNPACK_FIX_TRUNC_{LO,HI}_EXPR and VEC_PACK_FLOAT_EXPR, use it in x86 vectorization (PR target/85918)
Hi! AVX512DQ and AVX512DQ/AVX512VL has instructions for vector float <-> {,unsigned} long long conversions. The following patch adds the missing tree codes, optabs and expanders to make this possible. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-05-28 Jakub Jelinek PR target/85918 * tree.def (VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR, VEC_PACK_FLOAT_EXPR): New tree codes. * tree-pretty-print.c (op_code_prio): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR and VEC_UNPACK_FIX_TRUNC_LO_EXPR. (dump_generic_node): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. * tree-inline.c (estimate_operator_cost): Likewise. * gimple-pretty-print.c (dump_binary_rhs): Handle VEC_PACK_FLOAT_EXPR. * fold-const.c (const_binop): Likewise. (const_unop): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR and VEC_UNPACK_FIX_TRUNC_LO_EXPR. * tree-cfg.c (verify_gimple_assign_unary): Likewise. (verify_gimple_assign_binary): Handle VEC_PACK_FLOAT_EXPR. * cfgexpand.c (expand_debug_expr): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. * expr.c (expand_expr_real_2): Likewise. * optabs.def (vec_packs_float_optab, vec_packu_float_optab, vec_unpack_sfix_trunc_hi_optab, vec_unpack_sfix_trunc_lo_optab, vec_unpack_ufix_trunc_hi_optab, vec_unpack_ufix_trunc_lo_optab): New optabs. * optabs.c (expand_widen_pattern_expr): For VEC_UNPACK_FIX_TRUNC_HI_EXPR and VEC_UNPACK_FIX_TRUNC_LO_EXPR use sign from result type rather than operand's type. (expand_binop_directly): For vec_packu_float_optab and vec_packs_float_optab allow result type to be different from operand's type. * optabs-tree.c (optab_for_tree_code): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. Formatting fixes. * tree-vect-generic.c (expand_vector_operations_1): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. * tree-vect-stmts.c (supportable_widening_operation): Handle FIX_TRUNC_EXPR. (supportable_narrowing_operation): Handle FLOAT_EXPR. * config/i386/i386.md (fixprefix, floatprefix): New code attributes. * config/i386/sse.md (*floatv2div2sf2): Rename to ... (floatv2div2sf2): ... this. Formatting fix. (vpckfloat_concat_mode, vpckfloat_temp_mode, vpckfloat_op_mode): New mode attributes. (vec_pack_float_): New expander. (vunpckfixt_mode, vunpckfixt_model, vunpckfixt_extract_mode): New mode attributes. (vec_unpack_fix_trunc_lo_, vec_unpack_fix_trunc_hi_): New expanders. * doc/md.texi (vec_packs_float_@var{m}, vec_packu_float_@var{m}, vec_unpack_sfix_trunc_hi_@var{m}, vec_unpack_sfix_trunc_lo_@var{m}, vec_unpack_ufix_trunc_hi_@var{m}, vec_unpack_ufix_trunc_lo_@var{m}): Document. * doc/generic.texi (VEC_UNPACK_FLOAT_HI_EXPR, VEC_UNPACK_FLOAT_LO_EXPR): Fix pasto in description. (VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR, VEC_PACK_FLOAT_EXPR): Document. * gcc.target/i386/avx512dq-pr85918.c: Add -mprefer-vector-width=512 and -fno-vect-cost-model options. Add aligned(64) attribute to the arrays. Add suffix 1 to all functions and use 4 iterations rather than N. Add functions with conversions to and from float. Add new set of functions with 8 iterations and another one with 16 iterations, expect 24 vectorized loops instead of just 4. * gcc.target/i386/avx512dq-pr85918-2.c: New test. --- gcc/tree.def.jj 2018-05-26 23:03:55.321873256 +0200 +++ gcc/tree.def2018-05-27 12:54:55.040197121 +0200 @@ -1371,6 +1371,15 @@ DEFTREECODE (VEC_UNPACK_LO_EXPR, "vec_un DEFTREECODE (VEC_UNPACK_FLOAT_HI_EXPR, "vec_unpack_float_hi_expr", tcc_unary, 1) DEFTREECODE (VEC_UNPACK_FLOAT_LO_EXPR, "vec_unpack_float_lo_expr", tcc_unary, 1) +/* Unpack (extract) the high/low elements of the input vector, convert + floating point values to integer and widen elements into the output + vector. The input vector has twice as many elements as the output + vector, that are half the size of the elements of the output vector. */ +DEFTREECODE (VEC_UNPACK_FIX_TRUNC_HI_EXPR, "vec_unpack_fix_trunc_hi_expr", +tcc_unary, 1) +DEFTREECODE (VEC_UNPACK_FIX_TRUNC_LO_EXPR, "vec_unpack_fix_trunc_lo_expr", +tcc_unary, 1) + /* Pack (demote/narrow and merge) the elements of the two input vectors into the output vector using truncation/saturation. The elements of the input vectors are twice the size of the elements of the @@ -1384,6 +1393,12 @@ DEFTREECODE (VEC_PACK_SAT_EXPR, "vec_pac the outp
[PATCH] Fix doc/invoke.texi ARM buglet
Hi! I've noticed ../../gcc/doc/invoke.texi:15971: warning: @itemx should not begin @table errors, fixed thusly, committed as obvious to trunk. Probably it needs backporting too. 2018-05-28 Jakub Jelinek * doc/invoke.texi (ARM Options): Use @item instead of @itemx for armv5te. --- gcc/doc/invoke.texi.jj 2018-05-25 14:34:35.589376306 +0200 +++ gcc/doc/invoke.texi 2018-05-28 12:11:59.028679696 +0200 @@ -15968,7 +15968,7 @@ The table below lists the supported exte Architectures not mentioned do not support any extensions. @table @samp -@itemx armv5te +@item armv5te @itemx armv6 @itemx armv6j @itemx armv6k Jakub
Re: [PATCH GCC][5/6]implement live range, reg pressure computation class
On Fri, May 18, 2018 at 1:57 PM Bin.Cheng wrote: > On Fri, May 4, 2018 at 5:23 PM, Bin Cheng wrote: > > Hi, > > Based on previous patch, this one implements live range, reg pressure computation > > class in tree-ssa-live.c. The user would only need to instantiate the class and > > call the computation interface as in next patch. > > During the work, I think it's also worthwhile to classify all live range and coalesce > > data structures and algorithms in the future. > > > > Bootstrap and test on x86_64 and AArch64 ongoing. Any comments? > Updated patch in line with change of previous patch. So I see you do not want to expose the magic '16' in pressure_threshold to the user because in theory the target should provide enough information. But why need it at all? Also + /* Calculate maximum reg pressure information for region and store it in + MAX_PRESSURE. Return true if the reg pressure is high. */ + bool calculate_pressure (unsigned *max_pressure); it looks like you expect a [N_REG_CLASSES] sized output array here, that's not clear from the documentation. The output information is a little shallow - I'd be interested in the number of live through region regs being separated from live in / out. That is, can you add additional outputs to the above and thus make it more like bool calculate_pressure (unsigned max_pressure[], unsigned live_in[], unsigned live_out[], unsigned live_through[]); with the numbers being on the region? It also seems to be a fire-and-forget class so I wonder why liveness is not computed at construction time so intermediate data can be freed and only the results stored? stmt_lr_info -> id seems to be unused? In fact what is the point of this structure (and the per stmt bitmap)? It looks write-only to me... Thanks and sorry for the delay in review. Richard. > Thanks, > bin > > > > Thanks, > > bin > > 2018-04-27 Bin Cheng > > > > * tree-ssa-live.c (memmodel.h, ira.h, tree-ssa-coalesce.h): Include. > > (struct stmt_lr_info, free_stmt_lr_info): New. > > (lr_region::lr_region, lr_region::~lr_region): New. > > (lr_region::create_stmt_lr_info): New. > > (lr_region::update_live_range_by_stmt): New. > > (lr_region::calculate_coalesced_pressure): New. > > (lr_region::calculate_pressure): New. > > * tree-ssa-live.h (struct stmt_lr_info): New declaration. > > (class lr_region): New class.
[PATCH] [MSP430] Fix PR39240 execution failure for msp430-elf
pr39240.c fails at execution at -O1 and above for msp430, due to an erroneous subreg expression in the zero_extendqisi2 msp430 insn pattern. This causes the zero extension operation to get optimized out. The attached patch fixes the insn pattern, and also removes the msp430x ISA restriction on zero_extendqisi2 and zero_extendhisi2. The assembly instructions in these patterns can be used in the base MSP430 ISA; they are not MSP430x specific. Successfully regtested the GCC testsuite for msp430-elf in the -mcpu=msp430x/-mlarge configuration. If the patch is acceptable, I would appreciate if someone would commit it for me, as I don't have write access. >From 4f96a05f4849e28064f5c202a55b753b59a106ef Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Sun, 27 May 2018 21:09:49 +0100 Subject: [PATCH] MSP430: Fix PR39240 execution failure for msp430-elf 2018-05-28 Jozef Lawrynowicz * gcc/config/msp430/msp430.md: Remove erroneous subreg expression from zero_extendqisi2 insn pattern. Remove msp430x ISA restriction on zero_extend{q,h}isi2. --- gcc/config/msp430/msp430.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/config/msp430/msp430.md b/gcc/config/msp430/msp430.md index 869b9ee..614d375 100644 --- a/gcc/config/msp430/msp430.md +++ b/gcc/config/msp430/msp430.md @@ -619,15 +619,15 @@ (define_insn "zero_extendqisi2" [(set (match_operand:SI 0 "nonimmediate_operand" "=r") - (zero_extend:SI (subreg:HI (match_operand:QI 1 "nonimmediate_operand" "rm") 0)))] - "msp430x" + (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rm")))] + "" "MOV.B\t%1,%L0 { CLR\t%H0" ) (define_insn "zero_extendhisi2" [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,r")))] - "msp430x" + "" "@ MOV.W\t#0,%H0 MOV.W\t%1,%L0 { MOV.W\t#0,%H0" -- 2.7.4
Re: [PATCH 1/3] Add vec::reverse.
On Fri, May 25, 2018 at 1:04 PM marxin wrote: > gcc/ChangeLog: > 2018-05-25 Martin Liska > David Malcolm > * vec.c (test_reverse): New. > (vec_c_tests): Add new test. > * vec.h (vl_ptr>::reverse): New function. OK. Richard. > --- > gcc/vec.c | 38 ++ > gcc/vec.h | 14 ++ > 2 files changed, 52 insertions(+)
Re: [PATCH] PR target/85358 patch v2: Add target hook to prevent default widening
On Fri, May 25, 2018 at 02:49:47PM -0400, Michael Meissner wrote: > * target.def (default_fp_widening_p): New target hook to automatic > widening betwen two floating point modes. "default" is a pretty bad name. The rs6000 parts are fine of course, if the rest is. Segher
[PATCH] Update comment about the format of attribute name in attribute_spec handler
With the changes in r250911 to canonicalize attribute names (i.e. remove leading and trailing underscores if present) a comment for "handler" in the attribute_spec struct needs to be updated to reflect that the NAME argument is now stripped of any underscores. Patch is attached. If the patch is acceptable, I would appreciate if someone would commit it for me, as I don't have write access. >From 386f8e6aadf5627fcba0955a8dbb6abcec69b1a5 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Mon, 28 May 2018 13:04:12 +0100 Subject: [PATCH] Update comment about the format of attribute name in attribute_spec handler 2018-05-28 Jozef Lawrynowicz * gcc/tree-core.h: Update comment about the format of NAME string passed to handler in attribute_spec. --- gcc/tree-core.h | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 478c631..f7be51f 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1942,14 +1942,14 @@ struct attribute_spec { bool affects_type_identity; /* Function to handle this attribute. NODE points to the node to which the attribute is to be applied. If a DECL, it should be modified in - place; if a TYPE, a copy should be created. NAME is the name of the - attribute (possibly with leading or trailing __). ARGS is the TREE_LIST - of the arguments (which may be NULL). FLAGS gives further information - about the context of the attribute. Afterwards, the attributes will - be added to the DECL_ATTRIBUTES or TYPE_ATTRIBUTES, as appropriate, - unless *NO_ADD_ATTRS is set to true (which should be done on error, - as well as in any other cases when the attributes should not be added - to the DECL or TYPE). Depending on FLAGS, any attributes to be + place; if a TYPE, a copy should be created. NAME is the canonicalized + name of the attribute i.e. without any leading or trailing underscores. + ARGS is the TREE_LIST of the arguments (which may be NULL). FLAGS gives + further information about the context of the attribute. Afterwards, the + attributes will be added to the DECL_ATTRIBUTES or TYPE_ATTRIBUTES, as + appropriate, unless *NO_ADD_ATTRS is set to true (which should be done on + error, as well as in any other cases when the attributes should not be + added to the DECL or TYPE). Depending on FLAGS, any attributes to be applied to another type or DECL later may be returned; otherwise the return value should be NULL_TREE. This pointer may be NULL if no special handling is required beyond the checks implied -- 2.7.4
Re: [PATCH] Introduce VEC_UNPACK_FIX_TRUNC_{LO,HI}_EXPR and VEC_PACK_FLOAT_EXPR, use it in x86 vectorization (PR target/85918)
On Mon, May 28, 2018 at 11:58 AM, Jakub Jelinek wrote: > Hi! > > AVX512DQ and AVX512DQ/AVX512VL has instructions for vector float <-> > {,unsigned} long long conversions. The following patch adds the missing > tree codes, optabs and expanders to make this possible. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2018-05-28 Jakub Jelinek > > PR target/85918 > * tree.def (VEC_UNPACK_FIX_TRUNC_HI_EXPR, > VEC_UNPACK_FIX_TRUNC_LO_EXPR, > VEC_PACK_FLOAT_EXPR): New tree codes. > * tree-pretty-print.c (op_code_prio): Handle > VEC_UNPACK_FIX_TRUNC_HI_EXPR and VEC_UNPACK_FIX_TRUNC_LO_EXPR. > (dump_generic_node): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR, > VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. > * tree-inline.c (estimate_operator_cost): Likewise. > * gimple-pretty-print.c (dump_binary_rhs): Handle VEC_PACK_FLOAT_EXPR. > * fold-const.c (const_binop): Likewise. > (const_unop): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR and > VEC_UNPACK_FIX_TRUNC_LO_EXPR. > * tree-cfg.c (verify_gimple_assign_unary): Likewise. > (verify_gimple_assign_binary): Handle VEC_PACK_FLOAT_EXPR. > * cfgexpand.c (expand_debug_expr): Handle > VEC_UNPACK_FIX_TRUNC_HI_EXPR, > VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. > * expr.c (expand_expr_real_2): Likewise. > * optabs.def (vec_packs_float_optab, vec_packu_float_optab, > vec_unpack_sfix_trunc_hi_optab, vec_unpack_sfix_trunc_lo_optab, > vec_unpack_ufix_trunc_hi_optab, vec_unpack_ufix_trunc_lo_optab): New > optabs. > * optabs.c (expand_widen_pattern_expr): For > VEC_UNPACK_FIX_TRUNC_HI_EXPR and VEC_UNPACK_FIX_TRUNC_LO_EXPR use > sign from result type rather than operand's type. > (expand_binop_directly): For vec_packu_float_optab and > vec_packs_float_optab allow result type to be different from operand's > type. > * optabs-tree.c (optab_for_tree_code): Handle > VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and > VEC_PACK_FLOAT_EXPR. Formatting fixes. > * tree-vect-generic.c (expand_vector_operations_1): Handle > VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and > VEC_PACK_FLOAT_EXPR. > * tree-vect-stmts.c (supportable_widening_operation): Handle > FIX_TRUNC_EXPR. > (supportable_narrowing_operation): Handle FLOAT_EXPR. > * config/i386/i386.md (fixprefix, floatprefix): New code attributes. > * config/i386/sse.md (*floatv2div2sf2): Rename to ... > (floatv2div2sf2): ... this. Formatting fix. > (vpckfloat_concat_mode, vpckfloat_temp_mode, vpckfloat_op_mode): New > mode attributes. > (vec_pack_float_): New expander. > (vunpckfixt_mode, vunpckfixt_model, vunpckfixt_extract_mode): New mode > attributes. > (vec_unpack_fix_trunc_lo_, > vec_unpack_fix_trunc_hi_): New expanders. > * doc/md.texi (vec_packs_float_@var{m}, vec_packu_float_@var{m}, > vec_unpack_sfix_trunc_hi_@var{m}, vec_unpack_sfix_trunc_lo_@var{m}, > vec_unpack_ufix_trunc_hi_@var{m}, vec_unpack_ufix_trunc_lo_@var{m}): > Document. > * doc/generic.texi (VEC_UNPACK_FLOAT_HI_EXPR, > VEC_UNPACK_FLOAT_LO_EXPR): Fix pasto in description. > (VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR, > VEC_PACK_FLOAT_EXPR): Document. > > * gcc.target/i386/avx512dq-pr85918.c: Add -mprefer-vector-width=512 > and -fno-vect-cost-model options. Add aligned(64) attribute to the > arrays. Add suffix 1 to all functions and use 4 iterations rather > than N. Add functions with conversions to and from float. > Add new set of functions with 8 iterations and another one > with 16 iterations, expect 24 vectorized loops instead of just 4. > * gcc.target/i386/avx512dq-pr85918-2.c: New test. LGTM for the x86 part. Thanks, Uros. > --- gcc/tree.def.jj 2018-05-26 23:03:55.321873256 +0200 > +++ gcc/tree.def2018-05-27 12:54:55.040197121 +0200 > @@ -1371,6 +1371,15 @@ DEFTREECODE (VEC_UNPACK_LO_EXPR, "vec_un > DEFTREECODE (VEC_UNPACK_FLOAT_HI_EXPR, "vec_unpack_float_hi_expr", > tcc_unary, 1) > DEFTREECODE (VEC_UNPACK_FLOAT_LO_EXPR, "vec_unpack_float_lo_expr", > tcc_unary, 1) > > +/* Unpack (extract) the high/low elements of the input vector, convert > + floating point values to integer and widen elements into the output > + vector. The input vector has twice as many elements as the output > + vector, that are half the size of the elements of the output vector. */ > +DEFTREECODE (VEC_UNPACK_FIX_TRUNC_HI_EXPR, "vec_unpack_fix_trunc_hi_expr", > +tcc_unary, 1) > +DEFTREECODE (VEC_UNPACK_FIX_TRUNC_LO_EXPR, "vec_unpack_fix_trunc_lo_expr", > +tcc_unary, 1) > + > /* Pack (d
[PATCH] [MSP430] Fix -fleading-underscore having no effect
Fix -fleading-underscore having no effect for msp430-elf by prepending user_label_prefix to name when outputting assembly labels. Successfully regtested the GCC testsuite for msp430-elf, and this fixed unwind-1.c from dg.exp. If the patch is acceptable, I would appreciate if someone would commit it for me, as I don't have write access. >From 4b9fc3e0bf3e746c6be95c994f5ea4882dcd3e1d Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Wed, 23 May 2018 21:52:24 +0100 Subject: [PATCH] MSP430: Fix -fleading-underscore having no effect 2018-05-28 Jozef Lawrynowicz * gcc/config/msp430/msp430.c (msp430_output_labelref): Prepend user_label_prefix to name. --- gcc/config/msp430/msp430.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index adde597..8c8e676 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -3416,6 +3416,9 @@ msp430_output_labelref (FILE *file, const char *name) } } + if (user_label_prefix[0] != 0) +fputs (user_label_prefix, file); + fputs (name, file); } -- 2.7.4
Re: [PING] [PATCH] Avoid excessive function type casts with splay-trees
On 05/28/18 11:19, Richard Biener wrote: > On Sat, May 26, 2018 at 10:19 AM Bernd Edlinger > wrote: > > > >> On 05/17/18 16:37, Bernd Edlinger wrote: >>> On 05/17/18 15:39, Richard Biener wrote: On Thu, May 17, 2018 at 3:21 PM Bernd Edlinger wrote: > Ping... So this makes all traditional users go through the indirect splay_tree_compare_wrapper and friends (which is also exported for no good reason?). And all > users are traditional at the moment. >>> >>> all except gcc/typed-splay-tree.h which only works if VALUE_TYPE is >>> compatible with uint_ptr_t but cannot check this requirement. >>> This one worried me the most. >>> >>> But not having to rewrite omp-low.c for instance where splay_tree_lookup >>> and access to n->value are made all the time, made me think it >>> will not work to rip out the old interface completely. >>> > >> Well, I think it will be best to split this patch in two parts: > >> One that adds just two utility functions for avoiding undefined >> function type casts which can be used with the original C interface. >> This first part is attached. > >> And another part that uses a similar approach as the splay-tree in >> libgomp, but instead of creating a type-safe C interface it should >> translate the complete code from splay-tree.c/.h into a template. >> The second part, I plan to do at a later time. > > >> Is this OK for trunk? > > Looks ok to me. Do we need to worry about !HAVE_STRING_H and > using strcmp? > No, I would be rather surprised if libiberty would compile at all without string.h. First some files include it without HAVE_STRING_H for instance sha1.c and argv.c, so I just replicated what the majority of the code base here did. Most sources include ifdef HAVE_STRING_H, and use strcmp even if it is not declared (which should work for functions with int result). So I would commit this patch as is, if you agree. Bernd. > Thanks, > Richard. > > >> Thanks >> Bernd.
[PATCH] Fix PR85933
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. >From f7b8dc6184448bc7fb7f8faa27281f2ac64b75a9 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 28 May 2018 09:48:28 +0200 Subject: [PATCH] fix-pr85933 2018-05-28 Richard Biener PR tree-optimization/85933 * tree-vect-data-refs.c (vect_record_base_alignments): Only look at stmts marked as vectorizable. diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 331423af821..f46eb467da6 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -829,7 +829,10 @@ vect_record_base_alignments (vec_info *vinfo) data_reference *dr; unsigned int i; FOR_EACH_VEC_ELT (vinfo->datarefs, i, dr) -if (!DR_IS_CONDITIONAL_IN_STMT (dr)) +{ + gimple *stmt = DR_STMT (dr); +if (!DR_IS_CONDITIONAL_IN_STMT (dr) + && STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (stmt))) { gimple *stmt = DR_STMT (dr); vect_record_base_alignment (vinfo, stmt, &DR_INNERMOST (dr)); @@ -843,6 +846,7 @@ vect_record_base_alignments (vec_info *vinfo) (vinfo, stmt, &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info)); } } +} } /* Return the target alignment for the vectorized form of DR. */
Re: [PATCH] Introduce VEC_UNPACK_FIX_TRUNC_{LO,HI}_EXPR and VEC_PACK_FLOAT_EXPR, use it in x86 vectorization (PR target/85918)
On Mon, 28 May 2018, Jakub Jelinek wrote: > Hi! > > AVX512DQ and AVX512DQ/AVX512VL has instructions for vector float <-> > {,unsigned} long long conversions. The following patch adds the missing > tree codes, optabs and expanders to make this possible. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Apart from --- gcc/tree-cfg.c.jj 2018-05-26 23:03:55.361873297 +0200 +++ gcc/tree-cfg.c 2018-05-27 12:54:55.046197128 +0200 @@ -3676,6 +3676,8 @@ verify_gimple_assign_unary (gassign *stm case VEC_UNPACK_LO_EXPR: case VEC_UNPACK_FLOAT_HI_EXPR: case VEC_UNPACK_FLOAT_LO_EXPR: +case VEC_UNPACK_FIX_TRUNC_HI_EXPR: +case VEC_UNPACK_FIX_TRUNC_LO_EXPR: /* FIXME. */ return false; the middle-end changes look OK. Can you please add verification for the new codes here? Thanks, Richard. > 2018-05-28 Jakub Jelinek > > PR target/85918 > * tree.def (VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR, > VEC_PACK_FLOAT_EXPR): New tree codes. > * tree-pretty-print.c (op_code_prio): Handle > VEC_UNPACK_FIX_TRUNC_HI_EXPR and VEC_UNPACK_FIX_TRUNC_LO_EXPR. > (dump_generic_node): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR, > VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. > * tree-inline.c (estimate_operator_cost): Likewise. > * gimple-pretty-print.c (dump_binary_rhs): Handle VEC_PACK_FLOAT_EXPR. > * fold-const.c (const_binop): Likewise. > (const_unop): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR and > VEC_UNPACK_FIX_TRUNC_LO_EXPR. > * tree-cfg.c (verify_gimple_assign_unary): Likewise. > (verify_gimple_assign_binary): Handle VEC_PACK_FLOAT_EXPR. > * cfgexpand.c (expand_debug_expr): Handle VEC_UNPACK_FIX_TRUNC_HI_EXPR, > VEC_UNPACK_FIX_TRUNC_LO_EXPR and VEC_PACK_FLOAT_EXPR. > * expr.c (expand_expr_real_2): Likewise. > * optabs.def (vec_packs_float_optab, vec_packu_float_optab, > vec_unpack_sfix_trunc_hi_optab, vec_unpack_sfix_trunc_lo_optab, > vec_unpack_ufix_trunc_hi_optab, vec_unpack_ufix_trunc_lo_optab): New > optabs. > * optabs.c (expand_widen_pattern_expr): For > VEC_UNPACK_FIX_TRUNC_HI_EXPR and VEC_UNPACK_FIX_TRUNC_LO_EXPR use > sign from result type rather than operand's type. > (expand_binop_directly): For vec_packu_float_optab and > vec_packs_float_optab allow result type to be different from operand's > type. > * optabs-tree.c (optab_for_tree_code): Handle > VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and > VEC_PACK_FLOAT_EXPR. Formatting fixes. > * tree-vect-generic.c (expand_vector_operations_1): Handle > VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR and > VEC_PACK_FLOAT_EXPR. > * tree-vect-stmts.c (supportable_widening_operation): Handle > FIX_TRUNC_EXPR. > (supportable_narrowing_operation): Handle FLOAT_EXPR. > * config/i386/i386.md (fixprefix, floatprefix): New code attributes. > * config/i386/sse.md (*floatv2div2sf2): Rename to ... > (floatv2div2sf2): ... this. Formatting fix. > (vpckfloat_concat_mode, vpckfloat_temp_mode, vpckfloat_op_mode): New > mode attributes. > (vec_pack_float_): New expander. > (vunpckfixt_mode, vunpckfixt_model, vunpckfixt_extract_mode): New mode > attributes. > (vec_unpack_fix_trunc_lo_, > vec_unpack_fix_trunc_hi_): New expanders. > * doc/md.texi (vec_packs_float_@var{m}, vec_packu_float_@var{m}, > vec_unpack_sfix_trunc_hi_@var{m}, vec_unpack_sfix_trunc_lo_@var{m}, > vec_unpack_ufix_trunc_hi_@var{m}, vec_unpack_ufix_trunc_lo_@var{m}): > Document. > * doc/generic.texi (VEC_UNPACK_FLOAT_HI_EXPR, > VEC_UNPACK_FLOAT_LO_EXPR): Fix pasto in description. > (VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR, > VEC_PACK_FLOAT_EXPR): Document. > > * gcc.target/i386/avx512dq-pr85918.c: Add -mprefer-vector-width=512 > and -fno-vect-cost-model options. Add aligned(64) attribute to the > arrays. Add suffix 1 to all functions and use 4 iterations rather > than N. Add functions with conversions to and from float. > Add new set of functions with 8 iterations and another one > with 16 iterations, expect 24 vectorized loops instead of just 4. > * gcc.target/i386/avx512dq-pr85918-2.c: New test. > > --- gcc/tree.def.jj 2018-05-26 23:03:55.321873256 +0200 > +++ gcc/tree.def 2018-05-27 12:54:55.040197121 +0200 > @@ -1371,6 +1371,15 @@ DEFTREECODE (VEC_UNPACK_LO_EXPR, "vec_un > DEFTREECODE (VEC_UNPACK_FLOAT_HI_EXPR, "vec_unpack_float_hi_expr", > tcc_unary, 1) > DEFTREECODE (VEC_UNPACK_FLOAT_LO_EXPR, "vec_unpack_float_lo_expr", > tcc_unary, 1) > > +/* Unpack (extract) the high/low elements of the input vector, convert > + floating point values to integer and widen elements into the output > + vector. The input vecto
[PATCH] Fix PR85934
Bootstraped and tested on x86_64-unknown-linux-gnu, applied. Richard. >From f21624d5d1b9bb6b65f499f5af34781acfa6c927 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 28 May 2018 09:41:39 +0200 Subject: [PATCH] fix-pr85934 PR tree-optimization/85934 * tree-vect-generic.c (expand_vector_operations_1): Hoist vector boolean check before scalar optimization. * gcc.target/i386/pr85934.c: New testcase. diff --git a/gcc/testsuite/gcc.target/i386/pr85934.c b/gcc/testsuite/gcc.target/i386/pr85934.c new file mode 100644 index 000..ac10cfb9d8f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85934.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-vectorize -mavx512vbmi" } */ + +int uf; + +int +l7 (int wk, int sv) +{ + while (sv < 1) +{ + int me; + + for (me = 0; me < 64; ++me) + wk += !!((unsigned char) sv) && (!!uf == !!me); + + ++sv; +} + + return wk; +} diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index 3dcbdeba959..2ade60b3398 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -1612,6 +1612,12 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi) if (!VECTOR_TYPE_P (type) || !VECTOR_TYPE_P (TREE_TYPE (rhs1))) return; + + /* A scalar operation pretending to be a vector one. */ + if (VECTOR_BOOLEAN_TYPE_P (type) + && !VECTOR_MODE_P (TYPE_MODE (type)) + && TYPE_MODE (type) != BLKmode) +return; /* If the vector operation is operating on all same vector elements implement it with a scalar operation and a splat if the target @@ -1638,12 +1644,6 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi) return; } } - - /* A scalar operation pretending to be a vector one. */ - if (VECTOR_BOOLEAN_TYPE_P (type) - && !VECTOR_MODE_P (TYPE_MODE (type)) - && TYPE_MODE (type) != BLKmode) -return; if (CONVERT_EXPR_CODE_P (code) || code == FLOAT_EXPR
Re: Remove support for FreeBSD 4.x (and earlier)
On 28.05.18 08:57, Gerald Pfeifer wrote: On Thu, 24 May 2018, Jeff Law wrote: Happy to trust you on what versions can be dropped and the resulting simplifications. Is it worth noting those old versions as deprecated/obsolete in config.gcc? Good catch, Jeff, thanks. Updated patch (also wrt. comments) below. Andreas, anyhing from your side? Ok. Thanks, Andreas Gerald 2018-05-27 Gerald Pfeifer * config.gcc: Identify FreeBSD 3.x and 4.x as unsupported. * config/freebsd-spec.h (FBSD_LIB_SPEC): Only consider FreeBSD 5 and later. Index: gcc/config.gcc === --- gcc/config.gcc (revision 260808) +++ gcc/config.gcc (working copy) @@ -268,7 +268,7 @@ | pdp11-*-bsd\ | sparc-hal-solaris2*\ | thumb-*-* \ - | *-*-freebsd[12] | *-*-freebsd[12].* \ + | *-*-freebsd[12] | *-*-freebsd[1234].* \ | *-*-freebsd*aout* \ | *-*-linux*aout*\ | *-*-linux*coff*\ Index: gcc/config/freebsd-spec.h === --- gcc/config/freebsd-spec.h (revision 260808) +++ gcc/config/freebsd-spec.h (working copy) @@ -79,15 +79,10 @@ #define FBSD_ENDFILE_SPEC \ "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" -/* Provide a LIB_SPEC appropriate for FreeBSD as configured and as - required by the user-land thread model. Before __FreeBSD_version - 500016, select the appropriate libc, depending on whether we're - doing profiling or need threads support. At __FreeBSD_version - 500016 and later, when threads support is requested include both - -lc and the threading lib instead of only -lc_r. To make matters - interesting, we can't actually use __FreeBSD_version provided by -directly since it breaks cross-compiling. As a final - twist, make it a hard error if -pthread is provided on the command +/* When threads support is requested include both -lc and the threading + library (which assumes FreeBSD 5.x or later, __FreeBSD_version 500016 + to be precise). + And make it a hard error if -pthread is provided on the command line and gcc was configured with --disable-threads (this will help avoid bug reports from users complaining about threading when they misconfigured the gcc bootstrap but are later consulting FreeBSD @@ -106,19 +101,8 @@ %{pg: -lc_p} \ }" #else -#if FBSD_MAJOR < 5 #define FBSD_LIB_SPEC " \ %{!shared: \ -%{!pg: \ - %{!pthread:-lc} \ - %{pthread:-lc_r}} \ -%{pg: \ - %{!pthread:-lc_p} \ - %{pthread:-lc_r_p}} \ - }" -#else -#define FBSD_LIB_SPEC " \ - %{!shared: \ %{!pg: %{pthread:-lpthread} -lc} \ %{pg: %{pthread:-lpthread_p} -lc_p} \ } \ @@ -126,8 +110,10 @@ %{pthread:-lpthread} -lc \ }" #endif -#endif +/* To make matters interesting, we can't actually use __FreeBSD_version + provided by directly since it breaks cross-compiling. */ + #if FBSD_MAJOR < 6 #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1" #else
[PATCH] Implement Fortran 2018's RANDOM_INIT
The attached patch implements the RANDOM_INIT intrinsic subroutine specified in Fortran 2018. I have had this patch in my local tree for the last 5+ months. Now that 8.1 is out, it is time to submit it. It has been built and regression tested on x86_64-*-freebsd. OK to commit? Note, I have only tested with -fcoarray=single as I don't have OpenCoarray set up to build with trunk. Testing with OpenCoarray is encouraged. 2018-05-28 Steven G. Kargl * check.c (gfc_check_random_init): New function. Check arguments of RANDOM_INIT. * gfortran.h (GFC_ISYM_RANDOM_INIT): New enum token. * intrinsic.c (add_subroutines): Add RANDOM_INIT to list of subroutines. * intrinsic.h: Add prototypes for gfc_check_random_init and gfc_resolve_random_init * intrinsic.texi: Document new intrinsic subprogram. * iresolve.c (gfc_resolve_random_init): Resolve routine name. * trans-decl.c: Declare gfor_fndecl_random_init * trans-intrinsic.c (conv_intrinsic_random_init): New function. Translate call to RANDOM_INIT. (gfc_conv_intrinsic_subroutine): Call it. * trans.h: Declare gfor_fndecl_random_init 2018-05-28 Steven G. Kargl * gfortran.dg/random_init_1.f90: New test. * gfortran.dg/random_init_2.f90: New test. * gfortran.dg/random_init_3.f90: New test. * gfortran.dg/random_init_4.f90: New test. * gfortran.dg/random_init_5.f90: New test. * gfortran.dg/random_init_6.f90: New test. 2018-05-28 Steven G. Kargl * libgfortran/Makefile.am: Add random_init.f90 to build. * libgfortran/Makefile.in: Regenerated. * libgfortran/gfortran.map: Expose symbol for _gfortran_random_init. * libgfortran/intrinsics/random_init.f90: Implementation. -- Steve Index: gcc/fortran/check.c === --- gcc/fortran/check.c (revision 256953) +++ gcc/fortran/check.c (working copy) @@ -5744,6 +5744,27 @@ gfc_check_mvbits (gfc_expr *from, gfc_expr *frompos, g } +/* Check the arguments for RANDOM_INIT. */ + +bool +gfc_check_random_init (gfc_expr *repeatable, gfc_expr *image_distinct) +{ + if (!type_check (repeatable, 0, BT_LOGICAL)) +return false; + + if (!scalar_check (repeatable, 0)) +return false; + + if (!type_check (image_distinct, 1, BT_LOGICAL)) +return false; + + if (!scalar_check (image_distinct, 1)) +return false; + + return true; +} + + bool gfc_check_random_number (gfc_expr *harvest) { Index: gcc/fortran/gfortran.h === --- gcc/fortran/gfortran.h (revision 256953) +++ gcc/fortran/gfortran.h (working copy) @@ -551,6 +551,7 @@ enum gfc_isym_id GFC_ISYM_PRODUCT, GFC_ISYM_RADIX, GFC_ISYM_RAND, + GFC_ISYM_RANDOM_INIT, GFC_ISYM_RANDOM_NUMBER, GFC_ISYM_RANDOM_SEED, GFC_ISYM_RANGE, Index: gcc/fortran/intrinsic.c === --- gcc/fortran/intrinsic.c (revision 256953) +++ gcc/fortran/intrinsic.c (working copy) @@ -3555,6 +3555,12 @@ add_subroutines (void) make_alias ("kmvbits", GFC_STD_GNU); } + add_sym_2s ("random_init", GFC_ISYM_RANDOM_INIT, CLASS_IMPURE, + BT_UNKNOWN, 0, GFC_STD_F2018, + gfc_check_random_init, NULL, gfc_resolve_random_init, + "repeatable", BT_LOGICAL, dl, REQUIRED, INTENT_IN, + "image_distinct", BT_LOGICAL, dl, REQUIRED, INTENT_IN); + add_sym_1s ("random_number", GFC_ISYM_RANDOM_NUMBER, CLASS_IMPURE, BT_UNKNOWN, 0, GFC_STD_F95, gfc_check_random_number, NULL, gfc_resolve_random_number, Index: gcc/fortran/intrinsic.h === --- gcc/fortran/intrinsic.h (revision 256953) +++ gcc/fortran/intrinsic.h (working copy) @@ -203,6 +203,7 @@ bool gfc_check_getlog (gfc_expr *); bool gfc_check_move_alloc (gfc_expr *, gfc_expr *); bool gfc_check_mvbits (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *); +bool gfc_check_random_init (gfc_expr *, gfc_expr *); bool gfc_check_random_number (gfc_expr *); bool gfc_check_random_seed (gfc_expr *, gfc_expr *, gfc_expr *); bool gfc_check_dtime_etime_sub (gfc_expr *, gfc_expr *); @@ -648,6 +649,7 @@ void gfc_resolve_lstat_sub (gfc_code *); void gfc_resolve_ltime (gfc_code *); void gfc_resolve_mvbits (gfc_code *); void gfc_resolve_perror (gfc_code *); +void gfc_resolve_random_init (gfc_code *); void gfc_resolve_random_number (gfc_code *); void gfc_resolve_random_seed (gfc_code *); void gfc_resolve_rename_sub (gfc_code *); Index: gcc/fortran/intrinsic.texi === --- gcc/fortran/intrinsic.texi (revision 256953) +++ gcc/fortran/intrinsic.texi (working copy) @@ -262,6 +262,7 @@ Some basic guidelines for editing this document: * @code{RADIX}: RADIX, Base of a data model * @
Re: [PING] [PATCH] Avoid excessive function type casts with splay-trees
On May 28, 2018 4:25:02 PM GMT+02:00, Bernd Edlinger wrote: >On 05/28/18 11:19, Richard Biener wrote: >> On Sat, May 26, 2018 at 10:19 AM Bernd Edlinger > >> wrote: >> >> >> >>> On 05/17/18 16:37, Bernd Edlinger wrote: On 05/17/18 15:39, Richard Biener wrote: > On Thu, May 17, 2018 at 3:21 PM Bernd Edlinger > > wrote: > >> Ping... > > So this makes all traditional users go through the indirect > splay_tree_compare_wrapper > and friends (which is also exported for no good reason?). And all >> users > are traditional > at the moment. > all except gcc/typed-splay-tree.h which only works if VALUE_TYPE is compatible with uint_ptr_t but cannot check this requirement. This one worried me the most. But not having to rewrite omp-low.c for instance where >splay_tree_lookup and access to n->value are made all the time, made me think it will not work to rip out the old interface completely. >> >>> Well, I think it will be best to split this patch in two parts: >> >>> One that adds just two utility functions for avoiding undefined >>> function type casts which can be used with the original C interface. >>> This first part is attached. >> >>> And another part that uses a similar approach as the splay-tree in >>> libgomp, but instead of creating a type-safe C interface it should >>> translate the complete code from splay-tree.c/.h into a template. >>> The second part, I plan to do at a later time. >> >> >>> Is this OK for trunk? >> >> Looks ok to me. Do we need to worry about !HAVE_STRING_H and >> using strcmp? >> > >No, I would be rather surprised if libiberty would compile at all >without string.h. First some files include it without HAVE_STRING_H >for instance sha1.c and argv.c, so I just replicated what >the majority of the code base here did. > >Most sources include ifdef HAVE_STRING_H, and use strcmp >even if it is not declared (which should work for functions with int >result). > >So I would commit this patch as is, if you agree. Sure - go ahead. Richard. > >Bernd. > > >> Thanks, >> Richard. >> >> >>> Thanks >>> Bernd.
[patch, libgfortran] Bug 85840 - Memory leak in write.c
The attached patch is a follow on from my previous for this PR. I could not reproduce the problem on these code paths, but one should not assume it won't happen. Patch is obvious and I will commit shortly. Regression tested on x86_64. 2018-05-28 Jerry DeLisle PR libgfortran/85840 * io/write.c (write_real, write_real_g0, write_complex): Use separate local variables for the float string length. diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 5d52fd6914f..dc6a234f42e 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -1682,7 +1682,7 @@ write_real (st_parameter_dt *dtp, const char *source, int kind) char buf_stack[BUF_STACK_SZ]; char str_buf[BUF_STACK_SZ]; char *buffer, *result; - size_t buf_size, res_len; + size_t buf_size, res_len, flt_str_len; int orig_scale = dtp->u.p.scale_factor; dtp->u.p.scale_factor = 1; set_fnode_default (dtp, &f, kind); @@ -1697,8 +1697,8 @@ write_real (st_parameter_dt *dtp, const char *source, int kind) buffer = select_buffer (dtp, &f, precision, buf_stack, &buf_size, kind); get_float_string (dtp, &f, source , kind, 1, buffer, - precision, buf_size, result, &res_len); - write_float_string (dtp, result, res_len); + precision, buf_size, result, &flt_str_len); + write_float_string (dtp, result, flt_str_len); dtp->u.p.scale_factor = orig_scale; if (buf_size > BUF_STACK_SZ) @@ -1717,7 +1717,7 @@ write_real_g0 (st_parameter_dt *dtp, const char *source, int kind, int d) char buf_stack[BUF_STACK_SZ]; char str_buf[BUF_STACK_SZ]; char *buffer, *result; - size_t buf_size, res_len; + size_t buf_size, res_len, flt_str_len; int comp_d; set_fnode_default (dtp, &f, kind); @@ -1741,8 +1741,8 @@ write_real_g0 (st_parameter_dt *dtp, const char *source, int kind, int d) buffer = select_buffer (dtp, &f, precision, buf_stack, &buf_size, kind); get_float_string (dtp, &f, source , kind, comp_d, buffer, - precision, buf_size, result, &res_len); - write_float_string (dtp, result, res_len); + precision, buf_size, result, &flt_str_len); + write_float_string (dtp, result, flt_str_len); dtp->u.p.g0_no_blanks = 0; if (buf_size > BUF_STACK_SZ) @@ -1767,7 +1767,7 @@ write_complex (st_parameter_dt *dtp, const char *source, int kind, size_t size) char str1_buf[BUF_STACK_SZ]; char str2_buf[BUF_STACK_SZ]; char *buffer, *result1, *result2; - size_t buf_size, res_len1, res_len2; + size_t buf_size, res_len1, res_len2, flt_str_len1, flt_str_len2; int width, lblanks, orig_scale = dtp->u.p.scale_factor; dtp->u.p.scale_factor = 1; @@ -1790,18 +1790,18 @@ write_complex (st_parameter_dt *dtp, const char *source, int kind, size_t size) buffer = select_buffer (dtp, &f, precision, buf_stack, &buf_size, kind); get_float_string (dtp, &f, source , kind, 0, buffer, - precision, buf_size, result1, &res_len1); + precision, buf_size, result1, &flt_str_len1); get_float_string (dtp, &f, source + size / 2 , kind, 0, buffer, - precision, buf_size, result2, &res_len2); + precision, buf_size, result2, &flt_str_len2); if (!dtp->u.p.namelist_mode) { - lblanks = width - res_len1 - res_len2 - 3; + lblanks = width - flt_str_len1 - flt_str_len2 - 3; write_x (dtp, lblanks, lblanks); } write_char (dtp, '('); - write_float_string (dtp, result1, res_len1); + write_float_string (dtp, result1, flt_str_len1); write_char (dtp, semi_comma); - write_float_string (dtp, result2, res_len2); + write_float_string (dtp, result2, flt_str_len2); write_char (dtp, ')'); dtp->u.p.scale_factor = orig_scale;