1. 25 May, 2018 38 commits
    • [Ada] Spurious range check with Initialize_Scalars · bf5899e7
      This patch modifies the expansion of default-initialized array objects when
      pragma Initialize_Scalars or Normalize_Scalars is in effect to suppress the
      generation of checks on the constructed in-place aggregate. The aggregate
      intentionally contains invalid values which may not necessarily fit the
      constraints of a particular component type. Check suppression ensures that
      no spurious checks are generated, and that the effects of the pragmas are
      carried out.
      
      ------------
      -- Source --
      ------------
      
      --  gnat.adc
      
      pragma Initialize_Scalars;
      
      --  init_scalar.adb
      
      with Ada.Text_IO; use Ada.Text_IO;
      
      procedure Init_Scalar is
         type Fixed is delta 0.25 range -12.0 .. 1270.0;
         type Fixed_Array is array (1 .. 1) of Fixed;
      
      begin
         begin
            declare
               Obj : Fixed;
               pragma Unreferenced (Obj);
            begin null; end;
         exception
            when others => Put_Line ("ERROR: Fixed raised exception");
         end;
      
         begin
            declare
               Obj : Fixed_Array;
               pragma Unreferenced (Obj);
            begin null; end;
         exception
            when others => Put_Line ("ERROR: Fixed_Array raised exception");
         end;
      end Init_Scalar;
      
      -----------------
      -- Compilation --
      -----------------
      
      $ gnatmake -q init_scalar.adb
      $ ./init_scalar
      
      2018-05-25  Hristian Kirtchev  <kirtchev@adacore.com>
      
      gcc/ada/
      
      	* exp_ch3.adb (Default_Initialize_Object): Ensure that the analysis of
      	the in-place initialization aggregate created for pragmas
      	Initialize_Scalars or Normalize_Scalars is performed with checks
      	suppressed.
      
      From-SVN: r260740
      Hristian Kirtchev committed
    • [Ada] Remove "constant" attribute on Osint.Unknown_Attributes · f70b0116
      2018-05-25  Arnaud Charlet  <charlet@adacore.com>
      
      gcc/ada/
      
      	* exp_aggr.adb (Convert_To_Positional): Bump default for
      	Max_Others_Replicate to 32. Update comments.
      	* osint.ads (Unknown_Attributes): No longer pretend this is a constant.
      	(No_File_Info_Cache): Initialize separately.
      	* osint.adb (No_File_Info_Cache): Update initializer.
      
      From-SVN: r260739
      Arnaud Charlet committed
    • [Ada] Membership test of class-wide interface · 25409c3c
      The compiler rejects the use of a membership test when the left operand
      is a class-wide interface type object and the right operand is not a
      class-wide type.
      
      2018-05-25  Javier Miranda  <miranda@adacore.com>
      
      gcc/ada/
      
      	* sem_res.adb (Resolve_Membership_Op): Allow the use of the membership
      	test when the left operand is a class-wide interface and the right
      	operand is not a class-wide type.
      	* exp_ch4.adb (Tagged_Membership): Adding support for interface as the
      	left operand.
      
      gcc/testsuite/
      
      	* gnat.dg/interface7.adb: New testcase.
      
      From-SVN: r260738
      Javier Miranda committed
    • [Ada] Fix expansion of quantified expressions as part of "others" associations · 1f6237e3
      2018-05-25  Ed Schonberg  <schonberg@adacore.com>
      
      gcc/ada/
      
      	* exp_aggr.adb (Flatten): A quantified expression cannot be duplicated
      	in an others clause to prevent visibility issues with the generated
      	loop variable.
      	(Component_OK_For_Backend): Return false for a quantified expression.
      	(Check_Static_Component): Ditto.
      
      From-SVN: r260737
      Ed Schonberg committed
    • [Ada] Spurious secondary stack depletion · 25eadeea
      This patch reimplements the secondary stack allocation logic to eliminate an
      issue which causes the memory index to overflow while the stack itself uses
      very little memory, thus causing a spurious Storage_Error.
      
      The issue in details:
      
      The total amount of memory that the secondary stack can accomodate is dictated
      by System.Parameters.Size_Type which is really an Integer, giving roughly 2 GB
      of storage.
      
      The secondary stack is comprised of multiple frames which logically form a
      contiguous array of memory. Each frame maintans a range over which it operates,
      where
      
         Low  bound = Previous frame's high bound + 1
         High bound = Previous frame's high bound + Frame size
      
      The allocation logic starts by first checking whether the current top frame
      (which may not be the "last" frame in the secondary stack) has enough memory to
      fit an object. If it does, then that frame is used. If it does not, the logic
      then examines the subsequent frames, while carrying out the following actions:
      
         * If the frame is too small to fit the object, it is deleted
      
         * If the frame is big enough to fit the object, it is used
      
      If all the frames were too small (and thus deleted), a new frame is added which
      is big enough to fit the object.
      
      Due to an issue with the deletion logic, the last frame would never be deleted.
      Since any new frame's range is based on the previous frame's range, the new
      range would keep growing, even though the secondary stack may have very few
      frames in use. Eventually this growth overflows the memory index type.
      
      The overflow of the memory index type happens only when the secondary stack
      is full, and thus signals a Storage_Error. Due to the spurious growth of the
      ranges, the overflow happens much faster and results in a bogus stack depleton.
      
      The issue manifests only when each new memory request to the secondary stack is
      slightly bigger than the previous memory request, thus prompring the secondary
      stack to delete all its frames, and create a new one.
      
      2018-05-25  Hristian Kirtchev  <kirtchev@adacore.com>
      
      gcc/ada/
      
      	* libgnat/s-secsta.adb (SS_Allocate): Reimplemented.
      	(SS_Allocate_Dynamic): New routine. The allocation logic is now split
      	into three distring cases rather than in one loop which attempts to
      	handle all three cases. This rewrite eliminates an issue where the last
      	frame of the stack cannot be freed, thus causing the memory range of a
      	new frame to approach the overflow point of the memory index type.
      	Since the overflow is logically treated as a
      	too-much-memory-on-the-stack scenario, it causes a bogus Storage_Error.
      	(SS_Allocate_Static): New routine. The routine factorizes the static
      	secondary stack-related code from the former SS_Allocate.
      
      gcc/testsuite/
      
      	* gnat.dg/sec_stack2.adb: New testcase.
      
      From-SVN: r260736
      Hristian Kirtchev committed
    • [Ada] Document the '-U' option for gnatelim · bd42db1f
      2018-05-25  Sergey Rybin  <rybin@adacore.com>
      
      gcc/ada/
      
      	* doc/gnat_ugn/gnat_and_program_execution.rst: Add description of '-U'
      	option for gnatelim.
      
      From-SVN: r260735
      Sergey Rybin committed
    • [Ada] Crash on classwide precondition on subprogram with stub · 6459a31f
      This patch allows the compiler to handle properly a classwide precondition
      on a primitive operation whose body is a stub and a separate subunit.
      
      Executing:
      
         gnatmake -gnata -q check
         ./check
      
      must yield:
      
         precondition violated
      
      ----
      with Text_IO;
      with Msg_Data_Block_Decoder; use Msg_Data_Block_Decoder;
      procedure Check is
         Thing : T_Msg_Data_Block_Decoder;
         Value : Integer;
      begin
         begin
            Value := Get_Long_Term_Corrections (Thing);
         exception
            when others => Text_IO.Put_Line ("precondition violated");
         end;
      end Check;
      ----
      package Msg_Data_Block_Decoder is
         pragma Preelaborate;
         type T_Msg_Data_Block_Decoder is Tagged Limited null record;
      
         type T_Msg_Data_Block_Decoder_Class_Access is
             access all T_Msg_Data_Block_Decoder'Class;
      
         function Get_Decoded_Data (This : in T_Msg_Data_Block_Decoder)
            return Integer;
      
         function Get_Long_Term_Corrections
           (This : in T_Msg_Data_Block_Decoder) return Integer  with
             Pre'
              Class => Get_Decoded_Data (T_Msg_Data_Block_Decoder'Class (This)) = 2;
      
      end Msg_Data_Block_Decoder;
      ----
      package body Msg_Data_Block_Decoder is
      
         function Get_Long_Term_Corrections (This : in T_Msg_Data_Block_Decoder)
         return Integer is separate;
      
         function Get_Decoded_Data (This : in T_Msg_Data_Block_Decoder)
           return Integer is
         begin
           return 0;
         end Get_Decoded_Data;
      
      end Msg_Data_Block_Decoder;
      ----
      separate (Msg_Data_Block_Decoder)
      function Get_Long_Term_Corrections (This : in T_Msg_Data_Block_Decoder)
         return Integer is
      begin
        return 0;
      end Get_Long_Term_Corrections;
      
      2018-05-25  Ed Schonberg  <schonberg@adacore.com>
      
      gcc/ada/
      
      	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not create
      	Class_Wide_Clone_Body when analyzing a subprogram_body_stub: the clone
      	is created when the proper body of the stub is analyzed.
      	* sem_util.adb (ZBuild_Class_Wide_Clone_Body): If the subprogram body
      	is the proper body of a subunit, the cloned body must be inserted in
      	the declarative list that contains the stub.
      
      From-SVN: r260734
      Ed Schonberg committed
    • [Ada] Fix for freezing of expression functions · 320fbd1e
      2018-05-25  Justin Squirek  <squirek@adacore.com>
      
      gcc/ada/
      
      	* exp_ch6.adb (Expand_Simple_Function_Return): Add guard in check to
      	generate code for 6.5(8-10) so that we don't get an assertion error
      	when dealing with an incomplete return type.
      
      From-SVN: r260733
      Justin Squirek committed
    • [Ada] Strip too long expressions in debug routines · 29192f7b
      2018-05-25  Arnaud Charlet  <charlet@adacore.com>
      
      gcc/ada/
      
      	* pprint.adb (Expression_Name): Strip too long expressions to avoid
      	carrying very large strings.
      
      From-SVN: r260732
      Arnaud Charlet committed
    • [Ada] Disable the creation of the main task secondary stack by the binder · 733a4a3d
      Users can now specify that the binder should not create a secondary stack for
      the main (environment) task through the binder switch -Q0. This is useful for
      ZFP runtime users who allocate secondary stacks for their application
      themselves.
      
      2018-05-25  Patrick Bernardi  <bernardi@adacore.com>
      
      gcc/ada/
      
      	* switch-b.adb (Scan_Binder_Switches): binder switch -Q accepts Natural
      	numbers.
      
      From-SVN: r260731
      Patrick Bernardi committed
    • [Ada] Implement stack unwinding for Linux on AArch64 · 8ad3525a
      2018-05-25  Doug Rupp  <rupp@adacore.com>
      
      gcc/ada/
      
      	* tracebak.c (aarch64-linux): Implement.
      
      From-SVN: r260730
      Doug Rupp committed
    • [Ada] Minor reformatting · f9a0fd0b
      2018-05-25  Justin Squirek  <squirek@adacore.com>
      
      gcc/ada/
      
      	* sem_ch8.adb: Minor reformatting.
      
      From-SVN: r260729
      Justin Squirek committed
    • [Ada] Fix convention for iteration with multiple loop variables · 308ac7f4
      Refactoring based on suggestions from GNAT frontend developers.  Semantics
      unaffected.
      
      2018-05-25  Piotr Trojanek  <trojanek@adacore.com>
      
      gcc/ada/
      
      	* sem_util.adb (Iterate_Call_Parameters): Fix code convention and
      	assertions.
      
      From-SVN: r260728
      Piotr Trojanek committed
    • [Ada] Minor reformatting · 9ea43db6
      2018-05-25  Hristian Kirtchev  <kirtchev@adacore.com>
      
      gcc/ada/
      
      	* einfo.adb, einfo.ads, exp_ch3.adb, exp_ch8.adb, exp_unst.adb,
      	pprint.adb, sem_ch12.adb, sem_ch3.adb, sem_prag.adb, sem_util.adb:
      	Minor reformatting.
      
      From-SVN: r260727
      Hristian Kirtchev committed
    • [Ada] Strengthen checks for instantiation with interface types · 41610f15
      2018-05-25  Ed Schonberg  <schonberg@adacore.com>
      
      gcc/ada/
      
      	* sem_ch12.adb (Instance_Exists): New function, subsidiary of
      	Validate_Derived_Type_Instance, to verify that all interfaces
      	implemented by the formal type are also implemented by the actual. The
      	verification is complicated when an interface of the formal is declared
      	in a generic unit and the actual is declared in an instance of it.
      	There is currently no mechanism to relate an interface declared within
      	a generic to the corresponding interface in an instance, so we must
      	traverse the list of interfaces of the actual, looking for a name
      	match, and verifying that that interface is declared in an instance.
      
      From-SVN: r260726
      Ed Schonberg committed
    • [Ada] Rewrite Iterate_Call_Parameters in more assertive style · 9da8032d
      The formal and actual parameters in a subprogram call must match each other.
      This is now checked with assertion (so that we can detect possible mistakes),
      while the production builds have less work to do. Semantics unchanged.
      
      2018-05-25  Piotr Trojanek  <trojanek@adacore.com>
      
      gcc/ada/
      
      	* sem_util.adb (Iterate_Call_Parameters): Rewrite with extra
      	assertions; replace function versions of Next_Formal/Next_Actual with
      	their procedural versions (which are more concise).
      
      From-SVN: r260725
      Piotr Trojanek committed
    • [Ada] Make Max_Sensible_Delay uniform across all Posix targets · 5865218e
      For instance: 6 months where Duration is 64bits.  Heretofore LynxOS was unique
      in having an approximately 12 days max delay. By experimentation the actual
      maximum was determined and all relevant delay and sleep procedures rewritten to
      incrementally wait if necessary.
      
      2018-05-25  Doug Rupp  <rupp@adacore.com>
      
      gcc/ada/
      
      	* libgnarl/s-osinte__aix.ads, libgnarl/s-osinte__android.ads,
      	libgnarl/s-osinte__darwin.ads, libgnarl/s-osinte__freebsd.ads,
      	libgnarl/s-osinte__hpux.ads, libgnarl/s-osinte__kfreebsd-gnu.ads,
      	libgnarl/s-osinte__linux.ads, libgnarl/s-osinte__lynxos178e.ads,
      	libgnarl/s-osinte__qnx.ads, libgnarl/s-osinte__rtems.ads
      	(Relative_Timed_Wait): Remove.
      	* libgnarl/s-tpopmo.adb (Timed_Sleep, Timed_Delay): Rewrite to allow
      	for incremental looping. Remove references to Rel_Time and
      	Relative_Timed_Wait.
      	* libgnat/s-osprim__posix.adb, libgnat/s-osprim__posix2008.adb
      	(Timed_Delay): Make separate.
      	* libgnat/s-optide.adb: New separate procedure.
      	* libgnat/s-osprim.ads (Max_System_Delay): New constant.
      	* libgnat/s-osprim__lynxos.ads (Max_Sensible_Delay): Set to 6 months.
      	(Max_System_Delay): New constant.
      
      From-SVN: r260724
      Doug Rupp committed
    • [Ada] Checks on instantiations with formal derived types with interfaces · a036d1de
      This patch implements the rule stated in RM 12.5.5 : the actual shall be
      a descendant of very progenitor of the formal type.
      
      2018-05-25  Ed Schonberg  <schonberg@adacore.com>
      
      gcc/ada/
      
      	* sem_ch12.adb (Validate_Derived_Type_Instance): Verify that the actual
      	for a formal derived type implements all the interfaces declared for
      	the formal.
      
      gcc/testsuite/
      
      	* gnat.dg/interface6.adb: New testcase.
      
      From-SVN: r260723
      Ed Schonberg committed
    • [Ada] Fix handling of Loop_Entry for CodePeer/SPARK · 1f233db3
      When the applicable Assertion_Policy is Ignore for a pragma containing
      an occurrence of attribute Loop_Entry, CodePeer and SPARK should still be
      able to analyze the corresponding pragma. GNAT frontend was wrongly
      translating X'Loop_Entry as X in the AST, as a side-effect of an
      optimization only valid for compilation and not for static analysis.
      
      This has no effect on compilation.
      
      2018-05-25  Yannick Moy  <moy@adacore.com>
      
      gcc/ada/
      
      	* sem_prag.adb (Check_Applicable_Policy): Deal specially with CodePeer
      	and GNATprove modes when applicable policy is Ignore.
      
      From-SVN: r260722
      Yannick Moy committed
    • [Ada] Support for C99 and C++ standard boolean types · 0d0cd281
      This change the type Interfaces.C.Extensions.bool to be fully compatible
      with the C99 and C++ standard boolean types by making it a fully-fledged
      boolean type with convention C.
      
      The following C+Ada program must compile quietly in LTO mode:
      
      bool b;
      
      struct S {};
      
      bool foo (struct S *s) { return true; }
      
      pragma Ada_2005;
      pragma Style_Checks (Off);
      
      with Interfaces.C; use Interfaces.C;
      with Interfaces.C.Extensions;
      
      package t_c is
      
         b : aliased Extensions.bool;  -- t.c:3
         pragma Import (C, b, "b");
      
         type S is record
            null;
         end record;
         pragma Convention (C_Pass_By_Copy, S);  -- t.c:5
      
         function foo (the_s : access S) return Extensions.bool;  -- t.c:7
         pragma Import (C, foo, "foo");
      
      end t_c;
      
      with t_c; use t_c;
      
      procedure P_C is
      
        Dummy : aliased S;
      
      begin
        b := foo (Dummy'Access);
      end;
      
      2018-05-25  Eric Botcazou  <ebotcazou@adacore.com>
      
      gcc/ada/
      
      	* freeze.adb (Freeze_Enumeration_Type): Do not give integer size to a
      	boolean type with convention C.
      	* libgnat/i-cexten.ads (bool): Change to boolean with convention C.
      	* gcc-interface/decl.c (gnat_to_gnu_entity): Add new local variable
      	FOREIGN and use it throughout the function.
      	<E_Enumeration_Type>: Set precision 1 on boolean types with foreign
      	convention.
      	<E_Enumeration_Subtype>: Likewise for subtypes.
      	<E_Record_Type>: Force the size of a storage unit on empty classes.
      	* gcc-interface/utils.c (make_type_from_size) <BOOLEAN_TYPE>: Skip
      	boolean types with precision 1 if the size is the expected one.
      
      From-SVN: r260721
      Eric Botcazou committed
    • [Ada] Do not print non ASCII characters in debug routines · 28e33720
      2018-05-25  Arnaud Charlet  <charlet@adacore.com>
      
      gcc/ada/
      
      	* pprint.adb (Expression_Name): Do not print non ASCII characters.
      
      From-SVN: r260720
      Arnaud Charlet committed
    • [Ada] Unbounded strings: inline Initialize and Adjust · 5a7aacd1
      Procedures Initialize and Adjust in the Ada.[Wide_[Wide_]]Strings.Unbounded
      package are now inlined for nondispatching calls. No test available (efficiency
      issue only).
      
      2018-05-25  Bob Duff  <duff@adacore.com>
      
      gcc/ada/
      
      	* libgnat/a-strunb__shared.ads, libgnat/a-stwiun__shared.ads,
      	libgnat/a-stzunb__shared.ads: (Initialize, Adjust): Add pragma Inline.
      
      From-SVN: r260719
      Bob Duff committed
    • [Ada] Minor comment fix · 6b5eb7d7
      2018-05-25  Bob Duff  <duff@adacore.com>
      
      gcc/ada/
      
      	* sem_util.ads: Minor comment fix.
      
      From-SVN: r260718
      Bob Duff committed
    • [Ada] Refine checks for uplevel references · 5fe0b8c3
      2018-05-25  Ed Schonberg  <schonberg@adacore.com>
      
      gcc/ada/
      
      	* exp_unst.adb (Visit_Node): Restrict check for uplevel references in
      	prefixes of array attributes, to prefixes that are entity names whose
      	type is constrained.
      	(Note_Uplevel_Bound): Verify that the bound is declared in an enclosing
      	subprogram, as itype created for loops in pre/postcondition may appear
      	in loops at the library level.
      
      From-SVN: r260717
      Ed Schonberg committed
    • [Ada] Compiler loop on expression function and predicate in generic unit · 8218cfde
      This patch fixes an infinite loop in the compiler when analyzing an
      expression function whose expression mentions a subtype with a static
      predicate, and the context is a generic unit.
      
      2018-05-25  Ed Schonberg  <schonberg@adacore.com>
      
      gcc/ada/
      
      	* sem_ch13.adb (Build_Predicate_Functions): The predicate function
      	declaration is inserted into the tree and analyzed at that point, so
      	should not be reinserted when the body is constructed. Inside a
      	generic, ensure that the body is not inserted twice in the tree.
      
      gcc/testsuite/
      
      	* gnat.dg/static_pred1.adb, gnat.dg/static_pred1.ads: New testcase.
      
      From-SVN: r260716
      Ed Schonberg committed
    • [Ada] Detect misplaced assertions between loop invariants · 56ce7e4a
      Loop invariants and loop variants should all be colocated, as defined in
      SPARK RM 5.5.3(8). The code checking that rule was incorrectly accepting
      pragma Assert between two loop invariants. Now fixed.
      
      2018-05-25  Yannick Moy  <moy@adacore.com>
      
      gcc/ada/
      
      	* sem_prag.adb (Check_Grouping): Modify test to ignore statements and
      	declarations not coming from source.
      
      From-SVN: r260715
      Yannick Moy committed
    • [Ada] Document new switch --copy-environment for gnattest · 5c737a56
      2018-05-25  Fedor Rybin  <frybin@adacore.com>
      
      gcc/ada/
      
      	* doc/gnat_ugn/gnat_utility_programs.rst: Document new switch
      	--copy-environment for gnattest.
      
      From-SVN: r260714
      Fedor Rybin committed
    • Add IFN_COND_{MUL,DIV,MOD,RDIV} · 6c4fd4a9
      This patch adds support for conditional multiplication and division.
      It's mostly mechanical, but a few notes:
      
      * The *_optab name and the .md names are the same as the unconditional
        forms, just with "cond_" added to the front.  This means we still
        have the awkward difference between sdiv and div, etc.
      
      * It was easier to retain the difference between integer and FP
        division in the function names, given that they map to different
        tree codes (TRUNC_DIV_EXPR and RDIV_EXPR).
      
      * SVE has no direct support for IFN_COND_MOD, but it seemed more
        consistent to add it anyway.
      
      * Adding IFN_COND_MUL enables an extra fully-masked reduction
        in gcc.dg/vect/pr53773.c.
      
      * In practice we don't actually use the integer division forms without
        if-conversion support (added by a later patch).
      
      2018-05-25  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/
      	* doc/sourcebuild.texi (vect_double_cond_arith): Include
      	multiplication and division.
      	* doc/md.texi (cond_mul@var{m}, cond_div@var{m}, cond_mod@var{m})
      	(cond_udiv@var{m}, cond_umod@var{m}): Document.
      	* optabs.def (cond_smul_optab, cond_sdiv_optab, cond_smod_optab)
      	(cond_udiv_optab, cond_umod_optab): New optabs.
      	* internal-fn.def (IFN_COND_MUL, IFN_COND_DIV, IFN_COND_MOD)
      	(IFN_COND_RDIV): New internal functions.
      	* internal-fn.c (get_conditional_internal_fn): Handle TRUNC_DIV_EXPR,
      	TRUNC_MOD_EXPR and RDIV_EXPR.
      	* match.pd (UNCOND_BINARY, COND_BINARY): Handle them.
      	* config/aarch64/iterators.md (UNSPEC_COND_MUL, UNSPEC_COND_DIV):
      	New unspecs.
      	(SVE_INT_BINARY): Include mult.
      	(SVE_COND_FP_BINARY): Include UNSPEC_MUL and UNSPEC_DIV.
      	(optab, sve_int_op): Handle mult.
      	(optab, sve_fp_op, commutative): Handle UNSPEC_COND_MUL and
      	UNSPEC_COND_DIV.
      	* config/aarch64/aarch64-sve.md (cond_<optab><mode>): New pattern
      	for SVE_INT_BINARY_SD.
      
      gcc/testsuite/
      	* lib/target-supports.exp
      	(check_effective_target_vect_double_cond_arith): Include
      	multiplication and division.
      	* gcc.dg/vect/pr53773.c: Do not expect a scalar tail when using
      	fully-masked loops with a fixed vector length.
      	* gcc.dg/vect/vect-cond-arith-1.c: Add multiplication and division
      	tests.
      	* gcc.target/aarch64/sve/vcond_8.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_9.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_12.c: Add multiplication tests.
      
      From-SVN: r260713
      Richard Sandiford committed
    • [AArch64] Add SVE support for integer division · c38f7319
      After the previous patch to prevent pessimisation of divisions
      by constants, this patch adds support for the SVE integer division
      instructions.
      
      2018-05-25  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/
      	* config/aarch64/iterators.md (SVE_INT_BINARY_SD): New code iterator.
      	(optab, sve_int_op): Handle div and udiv.
      	* config/aarch64/aarch64-sve.md (<optab><mode>3): New expander
      	for SVE_INT_BINARY_SD.
      	(*<optab><mode>3): New insn for the same.
      
      gcc/testsuite/
      	* gcc.target/aarch64/sve/div_1.c: New test.
      	* gcc.target/aarch64/sve/div_1_run.c: Likewise.
      	* gcc.target/aarch64/sve/mul_highpart_2.c: Likewise.
      	* gcc.target/aarch64/sve/mul_highpart_2_run.c: Likewise.
      
      From-SVN: r260712
      Richard Sandiford committed
    • Prefer open-coding vector integer division · 8f76f377
      vect_recog_divmod_pattern currently bails out if the target has
      native support for integer division, but I think in practice
      it's always going to be better to open-code it anyway, just as
      we usually open-code scalar divisions by constants.
      
      I think the only currently affected targets are MIPS MSA and
      powerpcspe (which is currently marked obsolete).  For:
      
        void
        foo (int *x)
        {
          for (int i = 0; i < 100; ++i)
            x[i] /= 2;
        }
      
      the MSA port previously preferred to use division for powers of 2:
      
              .set    noreorder
              bnz.w   $w1,1f
              div_s.w $w0,$w0,$w1
              break   7
              .set    reorder
      1:
      
      (or just the div_s.w for -mno-check-zero-division), but after the patch
      it open-codes them using shifts:
      
              clt_s.w $w1,$w0,$w2
              subv.w  $w0,$w0,$w1
              srai.w  $w0,$w0,1
      
      MSA doesn't define a high-part pattern, so it still uses a division
      instruction for the non-power-of-2 case.
      
      Richard B pointed out that this would disable SLP of division by
      different amounts, but I think in practice that's a price worth paying,
      since the current cost model can't really tell whether using a general
      vector division is better than using open-coded scalar divisions.
      The fix would be either to support SLP of mixed open-coded divisions
      or to improve the cost model and try SLP again without the patterns.
      The patch adds an XFAILed test for this.
      
      2018-05-23  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/
      	* tree-vect-patterns.c: Include predict.h.
      	(vect_recog_divmod_pattern): Restrict check for division support
      	to when optimizing for size.
      
      gcc/testsuite/
      	* gcc.dg/vect/bb-slp-div-1.c: New XFAILed test.
      
      From-SVN: r260711
      Richard Sandiford committed
    • Fold VEC_COND_EXPRs to IFN_COND_* where possible · 0d2b3bca
      This patch adds the folds:
      
        (vec_cond COND (foo A B) C) -> (IFN_COND_FOO COND A B C)
        (vec_cond COND C (foo A B)) -> (IFN_COND_FOO (!COND) A B C)
      
      with the usual implicit restriction that the target must support
      the produced IFN_COND_FOO.
      
      The results of these folds don't have identical semantics, since
      the reverse transform would be invalid if (FOO A[i] B[i]) faults when
      COND[i] is false.  But this direction is OK since we're simply dropping
      faults for operations whose results aren't needed.
      
      The new gimple_resimplify4 doesn't try to do any constant folding
      on the IFN_COND_*s.  This is because a later patch will handle it
      by folding the associated unconditional operation.
      
      Doing this in gimple is better than doing it in .md patterns,
      since the second form (with the inverted condition) is much more
      common than the first, and it's better to fold away the inversion
      in gimple and optimise the result before entering expand.
      
      2018-05-24  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/
      	* doc/sourcebuild.texi (vect_double_cond_arith: Document.
      	* gimple-match.h (gimple_match_op::MAX_NUM_OPS): Bump to 4.
      	(gimple_match_op::gimple_match_op): Add an overload for 4 operands.
      	(gimple_match_op::set_op): Likewise.
      	(gimple_resimplify4): Declare.
      	* genmatch.c (get_operand_type): Handle CFN_COND_* functions.
      	(expr::gen_transform): Likewise.
      	(decision_tree::gen): Generate a simplification routine for 4 operands.
      	* gimple-match-head.c (gimple_simplify): Add an overload for
      	4 operands.  In the top-level function, handle up to 4 call
      	arguments and call gimple_resimplify4.
      	(gimple_resimplify4): New function.
      	(build_call_internal): Pass a fourth operand.
      	(maybe_push_to_seq): Likewise.
      	* match.pd (UNCOND_BINARY, COND_BINARY): New operator lists.
      	Fold VEC_COND_EXPRs of an operation and a default value into
      	an IFN_COND_* function if possible.
      	* config/aarch64/iterators.md (UNSPEC_COND_MAX, UNSPEC_COND_MIN):
      	New unspecs.
      	(SVE_COND_FP_BINARY): Include them.
      	(optab, sve_fp_op): Handle them.
      	(SVE_INT_BINARY_REV): New code iterator.
      	(SVE_COND_FP_BINARY_REV): New int iterator.
      	(commutative): New int attribute.
      	* config/aarch64/aarch64-protos.h (aarch64_sve_prepare_conditional_op):
      	Declare.
      	* config/aarch64/aarch64.c (aarch64_sve_prepare_conditional_op): New
      	function.
      	* config/aarch64/aarch64-sve.md (cond_<optab><mode>): Use it.
      	(*cond_<optab><mode>): New patterns for reversed operands.
      
      gcc/testsuite/
      	* lib/target-supports.exp
      	(check_effective_target_vect_double_cond_arith): New proc.
      	* gcc.dg/vect/vect-cond-arith-1.c: New test.
      	* gcc.target/aarch64/sve/vcond_8.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_8_run.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_9.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_9_run.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_12.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_12_run.c: Likewise.
      
      From-SVN: r260710
      Richard Sandiford committed
    • tree-vectorizer.h (STMT_VINFO_GROUP_*, GROUP_*): Remove. · 2c53b149
      2018-05-25  Richard Biener  <rguenther@suse.de>
      
      	* tree-vectorizer.h (STMT_VINFO_GROUP_*, GROUP_*): Remove.
      	(DR_GROUP_*): New, assert we have non-NULL ->data_ref_info.
      	(REDUC_GROUP_*): New, assert we have NULL ->data_ref_info.
      	(STMT_VINFO_GROUPED_ACCESS): Adjust.
      	* tree-vect-data-refs.c (everywhere): Adjust users.
      	* tree-vect-loop.c (everywhere): Likewise.
      	* tree-vect-slp.c (everywhere): Likewise.
      	* tree-vect-stmts.c (everywhere): Likewise.
      	* tree-vect-patterns.c (vect_reassociating_reduction_p): Likewise.
      
      From-SVN: r260709
      Richard Biener committed
    • Support SHF_EXCLUDE on non-x86 and with Solaris as · f8d70404
      	* configure.ac (gcc_cv_as_section_has_e): Move to common section.
      	Rename to...
      	(gcc_cv_as_section_exclude): ... this.
      	Try Solaris as #exclude syntax.
      	* configure: Regenerate.
      	* config.in: Regenerate.
      	* config/i386/i386.c (i386_solaris_elf_named_section): Handle
      	SECTION_EXCLUDE.
      	* config/sparc/sparc.c (sparc_solaris_elf_asm_named_section)
      	[HAVE_GAS_SECTION_EXCLUDE]: Handle SECTION_EXCLUDE.
      
      	* varasm.c (default_elf_asm_named_section): Don't check if
      	HAVE_GAS_SECTION_EXCLUDE is defined.
      
      From-SVN: r260708
      Rainer Orth committed
    • Add an "else" argument to IFN_COND_* functions · 9d4ac06e
      As suggested by Richard B, this patch changes the IFN_COND_*
      functions so that they take the else value of the ?: operation
      as a final argument, rather than always using argument 1.
      
      All current callers will still use the equivalent of argument 1,
      so this patch makes the SVE code assert that for now.  Later patches
      add the general case.
      
      2018-05-25  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/
      	* doc/md.texi: Update the documentation of the cond_* optabs
      	to mention the new final operand.  Fix GET_MODE_NUNITS call.
      	Describe the scalar case too.
      	* internal-fn.def (IFN_EXTRACT_LAST): Change type to fold_left.
      	* internal-fn.c (expand_cond_unary_optab_fn): Expect 3 operands
      	instead of 2.
      	(expand_cond_binary_optab_fn): Expect 4 operands instead of 3.
      	(get_conditional_internal_fn): Update comment.
      	* tree-vect-loop.c (vectorizable_reduction): Pass the original
      	accumulator value as a final argument to conditional functions.
      	* config/aarch64/aarch64-sve.md (cond_<optab><mode>): Turn into
      	a define_expand and add an "else" operand.  Assert for now that
      	the else operand is equal to operand 2.  Use SVE_INT_BINARY and
      	SVE_COND_FP_BINARY instead of SVE_COND_INT_OP and SVE_COND_FP_OP.
      	(*cond_<optab><mode>): New patterns.
      	* config/aarch64/iterators.md (UNSPEC_COND_SMAX, UNSPEC_COND_UMAX)
      	(UNSPEC_COND_SMIN, UNSPEC_COND_UMIN, UNSPEC_COND_AND, UNSPEC_COND_ORR)
      	(UNSPEC_COND_EOR): Delete.
      	(optab): Remove associated mappings.
      	(SVE_INT_BINARY): New code iterator.
      	(sve_int_op): Remove int attribute and add "minus" to the code
      	attribute.
      	(SVE_COND_INT_OP): Delete.
      	(SVE_COND_FP_OP): Rename to...
      	(SVE_COND_FP_BINARY): ...this.
      
      From-SVN: r260707
      Richard Sandiford committed
    • Try harder to preserve operand ties in maybe_legitimize_operands · b883fc9b
      maybe_legitimize_operands normally goes through each operand in turn
      and legitimises it in isolation.  For example, if two operands to
      an instruction initially have constant value C, and the instruction
      requires both operands to be registers, the function ends up forcing
      C into a register twice and passing two different registers to the
      instruction.
      
      I think we should try a bit harder to preserve the rtx_equal_p
      property, if it's easy to do.  Some targets can optimise that
      case better than they would the general case of all operands
      being different.  This is particularly true for SVE after the
      upcoming changes to the IFN_COND_* routines.
      
      This is hard to test on its own, but is covered by the upcoming
      IFN_COND_* patches.
      
      2018-05-25  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/
      	* optabs.c (can_reuse_operands_p): New function.
      	(maybe_legitimize_operands): Try to reuse the results for
      	earlier operands.
      
      From-SVN: r260706
      Richard Sandiford committed
    • re PR fortran/85839 ([F2018] warn for obsolescent features) · 9143aa52
      2018-05-25  Janus Weil  <janus@gcc.gnu.org>
      
      	PR fortran/85839
      	* match.c (gfc_match_block_data): Call gfc_notify_std to warn about
      	an obsolescent feature in Fortran 2018.
      	(gfc_match_equivalence): Ditto.
      	* resolve.c (resolve_common_blocks): Ditto.
      	(gfc_resolve_forall): Ditto.
      	* symbol.c (gfc_define_st_label): Ditto.
      
      
      2018-05-25  Janus Weil  <janus@gcc.gnu.org>
      
      	PR fortran/85839
      	* gfortran.dg/f2018_obs.f90: New test case.
      
      From-SVN: r260705
      Janus Weil committed
    • re PR fortran/85543 (ICE in update_current_proc_array_outer_dependency, at fortran/resolve.c:3060) · 55157d5e
      2018-05-24  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/85543
      	* resolve.c (update_current_proc_array_outer_dependency): Avoid NULL
      	pointer dereference.
      
      
      2018-05-24  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/85543
      	* gfortran.dg/pr85543.f90: New test.
      
      From-SVN: r260704
      Steven G. Kargl committed
    • Daily bump. · afb4d6a8
      From-SVN: r260703
      GCC Administrator committed
  2. 24 May, 2018 2 commits