Skip to content
Snippets Groups Projects
  1. Jun 01, 2022
    • Steve Baird's avatar
      [Ada] Missing discriminant checks when accessing variant field · eb1091dd
      Steve Baird authored
      In some cases, the compiler would incorrectly fail to generate
      discriminant checks when accessing fields declared in a variant part.
      Correct some such cases; detect the remaining cases and flag them as
      unsupported. The formerly-problematic cases that are now handled
      correctly involve component references occurring in a predicate
      expression (e.g., the expression of a Dynamic_Predicate aspect
      specification) for a type declaration (not for a subtype declaration).
      The cases which are now flagged as unsupported involve expression
      functions declared before the discriminated type in question has been
      frozen.
      
      gcc/ada/
      
      	* exp_ch3.ads: Replace visible Build_Discr_Checking_Funcs (which
      	did not need to be visible - it was not referenced outside this
      	package) with Build_Or_Copy_Discr_Checking_Funcs.
      	* exp_ch3.adb: Refactor existing code into 3 procedures -
      	Build_Discr_Checking_Funcs, Copy_Discr_Checking_Funcs, and
      	Build_Or_Copy_Discr_Checking_Funcs. This refactoring is intended
      	to be semantics-preserving.
      	* exp_ch4.adb (Expand_N_Selected_Component): Detect case where a
      	call should be generated to the Discriminant_Checking_Func for
      	the component in question, but that subprogram does not yet
      	exist.
      	* sem_ch13.adb (Freeze_Entity_Checks): Immediately before
      	calling Build_Predicate_Function, add a call to
      	Exp_Ch3.Build_Or_Copy_Discr_Checking_Funcs in order to ensure
      	that Discriminant_Checking_Func attributes are already set when
      	Build_Predicate_Function is called.
      	* sem_ch6.adb (Analyze_Expression_Function): If the expression
      	of a static expression function has been transformed into an
      	N_Raise_xxx_Error node, then we need to copy the original
      	expression in order to check the requirement that the expression
      	must be a potentially static expression. We also want to set
      	aside a copy the untransformed expression for later use in
      	checking calls to the expression function via
      	Inline_Static_Function_Call.  So introduce a new function,
      	Make_Expr_Copy, for use in these situations.
      	* sem_res.adb (Preanalyze_And_Resolve): When analyzing certain
      	expressions (e.g., a default parameter expression in a
      	subprogram declaration) we want to suppress checks. However, we
      	do not want to suppress checks for the expression of an
      	expression function.
      eb1091dd
    • Bob Duff's avatar
      [Ada] Fix search for "for ... of" loop subprograms · 3c2674cc
      Bob Duff authored
      This patch makes the search for Get_Element_Access, Step (Next/Prev),
      Reference_Control_Type, and Pseudo_Reference (for optimized "for ... of"
      loops) more robust.  In particular, we have a new Next procedure in Ada
      2022, and we need to pick the right one.
      
      We have not yet added the new Next and other subprograms.
      
      gcc/ada/
      
      	* exp_ch5.adb (Expand_Iterator_Loop_Over_Container): For each
      	subprogram found, assert that the variable is Empty, so we can
      	detect bugs where we find two or more things with the same name.
      	Without this patch, that bug would happen when we add the new
      	Next procedure.  For Step, make sure we pick the right one, by
      	checking name and number of parameters.  For Get_Element_Access,
      	check that we're picking a function.  That's not really
      	necessary, because there is no procedure with that name, but it
      	seems cleaner this way.
      	* rtsfind.ads: Minor comment improvement. It seems kind of odd
      	to say "under no circumstances", and then immediately contradict
      	that with "The one exception is...".
      3c2674cc
    • Doug Rupp's avatar
      [Ada] arm-qnx-7.1: unwind goes wrong after regs restore · c97f3a7d
      Doug Rupp authored
      The usual increment of the pc to pc+2 for ARM is needed.
      
      gcc/ada/
      
      	* init.c (QNX): __gnat_adjust_context_for_raise: New
      	implementation for arm-qnx.
      c97f3a7d
    • Julien Bortolussi's avatar
      [Ada] Add reference counting in functional containers · f3949a2e
      Julien Bortolussi authored
      This patch adds reference counting to dynamically allocated pointers
      on arrays and elements used by the functional container. This is done
      by making both the arrays and the elements controlled.
      
      gcc/ada/
      
      	* libgnat/a-cofuba.ads, libgnat/a-cofuba.adb: Add reference
      	counting.
      f3949a2e
    • Yannick Moy's avatar
      [Ada] Issue a warning on entity hidden in use_clause with -gnatwh · e1379eee
      Yannick Moy authored
      Augment the warnings issued with switch -gnatwh, so that a warning is
      also issued when an entity from the package of a use_clause ends up
      hidden due to an existing visible homonym.
      
      gcc/ada/
      
      	* sem_ch8.adb (Use_One_Package): Possibly warn.
      	* sem_util.adb (Enter_Name): Factor out warning on hidden entity.
      	(Warn_On_Hiding_Entity): Extract warning logic from Enter_Name and
      	generalize it to be applied also on use_clause.
      	* sem_util.ads (Warn_On_Hiding_Entity): Add new procedure.
      e1379eee
    • Yannick Moy's avatar
      [Ada] Issue better error message for out-of-order keywords in record def · 94e416d2
      Yannick Moy authored
      Various cases of out-of-order keywords in the definition of a record
      were already detected. This adds a similar detection after NULL and
      RECORD keywords.
      
      gcc/ada/
      
      	* par-ch3.adb (P_Known_Discriminant_Part_Opt): Reword error
      	message to benefit from existing codefix.
      	(P_Record_Definition): Detect out-of-order keywords in record
      	definition and issue appropriate messages. Other cases are
      	already caught at appropriate places.
      94e416d2
    • Eric Botcazou's avatar
      [Ada] Use Actions field of freeze nodes for subprograms (continued) · 73514ab7
      Eric Botcazou authored
      This case was missed in the previous change.
      
      gcc/ada/
      
      	* exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Put
      	the actions into the Actions field of the freeze node instead of
      	inserting them after it.
      73514ab7
    • Marc Poulhiès's avatar
      [Ada] Add inline documentation for Is_{Parenthesis,Enum_Array}_Aggregate · 64f72fae
      Marc Poulhiès authored
      Both flags were added when square brackets for array/container
      aggregates have been enabled with -gnat2022 without their corresponding
      inline documentation. This change adds the missing documention.
      
      gcc/ada/
      
      	* sinfo.ads: Add inline documention for Is_Parenthesis_Aggregate
      	and Is_Enum_Array_Aggregate.
      64f72fae
    • Bob Duff's avatar
      [Ada] Incorrect code for anonymous access-to-function with convention C · 5512eabc
      Bob Duff authored
      This patch fixes a bug where the compiler generates incorrect code for a
      call via an object with convention C, whose type is an anonymous
      access-to-function type.
      
      gcc/ada/
      
      	* einfo-utils.adb (Set_Convention): Call Set_Convention
      	recursively, so that Set_Can_Use_Internal_Rep is called (if
      	appropriate) on the anonymous access type of the object, and its
      	designated subprogram type.
      	* sem_ch3.adb (Access_Definition): Remove redundant call to
      	Set_Can_Use_Internal_Rep.
      5512eabc
    • Bob Duff's avatar
      [Ada] Suppress warnings on membership test of ranges · 3cd52053
      Bob Duff authored
      For a membership test "X in A .. B", the compiler used to warn if it
      could prove that X is within one of the bounds.  For example, if we know
      at compile time that X >= A, then the above could be replaced by "X <=
      B".
      
      This patch suppresses that warning, because there is really
      nothing wrong with the membership test, and programmers sometimes
      find it annoying.
      
      gcc/ada/
      
      	* exp_ch4.adb (Expand_N_In): Do not warn in the above-mentioned
      	cases.
      	* fe.h (Assume_No_Invalid_Values): Remove from fe.h, because
      	this is not used in gigi.
      	* opt.ads (Assume_No_Invalid_Values): Improve the comment. We
      	don't need to "clearly prove"; we can just "prove". Remove the
      	comment about fe.h, which is no longer true.
      3cd52053
    • Richard Biener's avatar
      tree-optimization/105763 - avoid abnormals with ranger queries · ae575e93
      Richard Biener authored
      In unswitching we use ranger to simplify switch statements so we
      have to avoid doing anything for abnormals.
      
      2022-05-30  Richard Biener  <rguenther@suse.de>
      
      	PR tree-optimization/105763
      	* tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb):
      	Check gimple_range_ssa_p.
      
      	* gcc.dg/pr105763.c: New testcase.
      ae575e93
    • GCC Administrator's avatar
      Daily bump. · 820ead45
      GCC Administrator authored
      820ead45
  2. May 31, 2022
    • Patrick Palka's avatar
      c++: non-dep call with empty TYPE_BINFO [PR105758] · 4f84f120
      Patrick Palka authored
      Here the out-of-line definition of Z<T>::z causes duplicate_decls to
      change z's type from using the primary template type Z<T> (which is also
      the type of the injected class name) to the implicit instantiation Z<T>,
      and this latter type lacks a TYPE_BINFO (although its TYPE_CANONICAL was
      set by a special case in lookup_template_class to point to the former).
      
      Later, when processing the non-dependent call z->foo(0), build_over_call
      relies on the object argument's TYPE_BINFO to build the templated form
      for this call, which fails because the object argument type has empty
      TYPE_BINFO due to the above.
      
      It seems weird that the implicit instantiation Z<T> doesn't have the
      same TYPE_BINFO as the primary template type Z<T>, despite them being
      proclaimed equivalent via TYPE_CANONICAL.  So I tried also setting
      TYPE_BINFO in the special case in lookup_template_class, but that led to
      some problems with constrained partial specializations of the form Z<T>.
      I'm not sure what, if anything, we ought to do about the subtle
      differences between these two versions of the same type.
      
      Fortunately it seems we don't need to rely on TYPE_BINFO at all in
      build_over_call here -- the z_candidate struct already contains the
      exact binfos we need to rebuild the BASELINK for the templated form.
      
      	PR c++/105758
      
      gcc/cp/ChangeLog:
      
      	* call.cc (build_over_call): Use z_candidate::conversion_path
      	and ::access_path instead of TYPE_BINFO when building the
      	BASELINK for the templated form.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/template/non-dependent24.C: New test.
      4f84f120
    • Patrick Palka's avatar
      c++: use auto_timevar instead of timevar_push/pop · 3f7daf7e
      Patrick Palka authored
      r12-5487-g9bf69a8558638c replaced uses of timevar_cond_push/pop with
      auto_cond_timevar and removed now unnecessary wrapper functions.  This
      patch does the same with timevar_push/pop and auto_timevar.
      
      gcc/cp/ChangeLog:
      
      	* parser.cc: Use auto_timevar instead of timevar_push/pop.
      	Remove wrapper functions.
      	* pt.cc: Likewise.
      3f7daf7e
    • Patrick Palka's avatar
      c++: squash cp_build_qualified_type/_real · 6013fc25
      Patrick Palka authored
      This combines the two differently named versions of the same function
      into a single function utilizing a default argument.
      
      gcc/cp/ChangeLog:
      
      	* cp-tree.h (cp_build_qualified_type_real): Rename to ...
      	(cp_build_qualified_type): ... this.  Give its last parameter
      	a default argument.  Remove macro of the same name.
      	* decl.cc (grokdeclarator): Adjust accordingly.
      	* pt.cc (tsubst_aggr_type): Likewise.
      	(rebuild_function_or_method_type): Likewise.
      	(tsubst): Likewise.
      	(maybe_dependent_member_ref): Likewise.
      	(unify): Likewise.
      	* tree.cc (cp_build_qualified_type_real): Rename to ...
      	(cp_build_qualified_type): ... this.  Adjust accordingly.
      6013fc25
    • Jason Merrill's avatar
      build: TAGS and .cc transition · a8b5d635
      Jason Merrill authored
      A few globs missed in the .c -> .cc transition.  Some targets were looking
      at both *.c and *.cc, but there are no longer any .c files to scan.
      
      gcc/ChangeLog:
      
      	* Makefile.in (TAGS): Look at libcpp/*.cc.
      
      gcc/c/ChangeLog:
      
      	* Make-lang.in (c.tags): Look at *.cc.
      
      gcc/cp/ChangeLog:
      
      	* Make-lang.in (c++.tags): Just look at *.cc.
      
      gcc/d/ChangeLog:
      
      	* Make-lang.in (d.tags): Just look at *.cc.
      
      gcc/fortran/ChangeLog:
      
      	* Make-lang.in (fortran.tags): Look at *.cc.
      
      gcc/go/ChangeLog:
      
      	* Make-lang.in (go.tags): Look at *.cc.
      
      gcc/objc/ChangeLog:
      
      	* Make-lang.in (objc.tags): Look at *.cc.
      
      gcc/objcp/ChangeLog:
      
      	* Make-lang.in (obj-c++.tags): Look at *.cc.
      a8b5d635
    • Iain Buclaw's avatar
      d: Fix D lexer sometimes fails to compile code read from stdin · a0bc7fd4
      Iain Buclaw authored
      As of gdc-12, the lexer expects there 4 bytes of zero padding at the end
      of the source buffer to mark the end of input.  Sometimes when reading
      from stdin, the data at the end of input is garbage rather than zeroes.
      Fix that by explicitly calling memset past the end of the buffer.
      
      	PR d/105544
      
      gcc/d/ChangeLog:
      
      	* d-lang.cc (d_parse_file): Zero padding past the end of the stdin
      	buffer so the D lexer has a sentinel to stop parsing at.
      a0bc7fd4
    • Christophe Lyon's avatar
      aarch64: Fix build with gcc-4.8 · 67d399d5
      Christophe Lyon authored
      My r13-680-g0dc8e1e7026d9b commit to add support for Decimal Floating
      Point introduced:
            case SDmode:
            case DDmode:
            case TDmode:
      which are rejected by gcc-4.8 as build compiler.
      
      This patch replaces them with E_SDmode, E_DDmode and E_TD_mode.
      
      Committed as obvious.
      
      	* config/aarch64/aarch64.cc (aarch64_gimplify_va_arg_expr):
      	Prefix mode names with E_.
      67d399d5
    • Alan Modra's avatar
      Correct spelling of DW_AT_namelist_item · 6c3c8f08
      Alan Modra authored
      include/
      	* dwarf2.def: Correct spelling of DW_AT_namelist_item.
      gcc/
      	* dwarf2out.cc (gen_namelist_decl): Adjust to suit correct
      	spelling of DW_AT_namelist_item.
      6c3c8f08
    • Patrick Palka's avatar
      c++: document comp_template_args's default args · da8a18df
      Patrick Palka authored
      In passing, use bool for its return type.
      
      gcc/cp/ChangeLog:
      
      	* cp-tree.h (comp_template_args): Change return type to bool.
      	* pt.cc (comp_template_args): Document default arguments.
      	Change return type to bool and adjust returns accordingly.
      da8a18df
    • Patrick Palka's avatar
      c++: use current_template_constraints more · b5cf960e
      Patrick Palka authored
      gcc/cp/ChangeLog:
      
      	* decl.cc (grokvardecl): Use current_template_constraints.
      	(grokdeclarator): Likewise.
      	(xref_tag): Likewise.
      	* semantics.cc (finish_template_template_parm): Likewise.
      b5cf960e
    • Jakub Jelinek's avatar
      openmp: Add support for firstprivate and allocate clauses on scope construct · f38b20d6
      Jakub Jelinek authored
      OpenMP 5.2 adds support for firstprivate and allocate clauses on the scope
      construct and this patch adds that support to GCC.
      5.2 unfortunately (IMNSHO mistakenly) marked scope construct as worksharing,
      which implies that it isn't possible to nest inside of it other scope,
      worksharing loop, sections, explicit barriers, single etc. which would
      make scope far less useful.  I'm not implementing that part, keeping the
      5.1 behavior here, and will file an issue to revert that for OpenMP 6.0.
      But, for firstprivate it keeps the restriction that is now implied from
      worksharing construct that listed var can't be private in outer context,
      where for reduction 5.1 had similar restriction explicit even for scope
      and 5.2 has it implicitly through worksharing construct.
      
      2022-05-31  Jakub Jelinek  <jakub@redhat.com>
      
      gcc/
      	* omp-low.cc (build_outer_var_ref): For code == OMP_CLAUSE_ALLOCATE
      	allow var to be private in the outer context.
      	(lower_private_allocate): Pass OMP_CLAUSE_ALLOCATE as last argument
      	to build_outer_var_ref.
      gcc/c/
      	* c-parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate
      	clauses.
      gcc/cp/
      	* parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate
      	clauses.
      gcc/testsuite/
      	* c-c++-common/gomp/scope-5.c: New test.
      	* c-c++-common/gomp/scope-6.c: New test.
      	* g++.dg/gomp/attrs-1.C (bar): Add firstprivate and allocate clauses
      	to scope construct.
      	* g++.dg/gomp/attrs-2.C (bar): Likewise.
      libgomp/
      	* testsuite/libgomp.c-c++-common/allocate-1.c (foo): Add testcase for
      	scope construct with allocate clause.
      	* testsuite/libgomp.c-c++-common/allocate-3.c (foo): Likewise.
      	* testsuite/libgomp.c-c++-common/scope-2.c: New test.
      f38b20d6
    • GCC Administrator's avatar
      Daily bump. · 0f4df800
      GCC Administrator authored
      0f4df800
  3. May 30, 2022
    • Marek Polacek's avatar
      c++: Add !TYPE_P assert to type_dependent_expression_p [PR99080] · ff91735a
      Marek Polacek authored
      As discussed here:
      <https://gcc.gnu.org/pipermail/gcc-patches/2021-February/564629.html>,
      type_dependent_expression_p should not be called with a type argument.
      
      I promised I'd add an assert so here it is.  One place needed adjusting.
      
      	PR c++/99080
      
      gcc/cp/ChangeLog:
      
      	* pt.cc (type_dependent_expression_p): Assert !TYPE_P.
      	* semantics.cc (finish_id_expression_1): Handle UNBOUND_CLASS_TEMPLATE
      	specifically.
      ff91735a
    • Roger Sayle's avatar
      Allow SCmode and DImode to be tieable with TARGET_64BIT on x86_64. · 1ad584d5
      Roger Sayle authored
      This patch is a form of insurance policy in case my patch for PR 7061 runs
      into problems on non-x86 targets; the middle-end can add an extra check
      that the backend is happy placing SCmode and DImode values in the same
      register, before creating a SUBREG.  Unfortunately, ix86_modes_tieable_p
      currently claims this is not allowed(?), even though the default target
      hook for modes_tieable_p is to always return true [i.e. false can be
      used to specifically prohibit bad combinations], and the x86_64 ABI
      passes SCmode values in DImode registers!.  This makes the backend's
      modes_tiable_p hook a little more forgiving, and additionally enables
      interconversion between SCmode and V2SFmode, and between DCmode and
      VD2Fmode, which opens interesting opporutunities in the future.
      
      2022-05-30  Roger Sayle  <roger@nextmovesoftware.com>
      
      gcc/ChangeLog
      	* config/i386/i386.cc (ix86_modes_tieable_p): Allow SCmode to be
      	tieable with DImode on TARGET_64BIT, and SCmode tieable with
      	V2SFmode, and DCmode with V2DFmode.
      1ad584d5
    • Harald Anlauf's avatar
      Fortran: improve runtime error message with ALLOCATE and ERRMSG= [PR91300] · 871dbb61
      Harald Anlauf authored
      ALLOCATE: generate different STAT,ERRMSG results for failures from
      allocation of already allocated objects or insufficient virtual memory.
      
      gcc/fortran/ChangeLog:
      
      	PR fortran/91300
      	* libgfortran.h: Define new error code LIBERROR_NO_MEMORY.
      	* trans-stmt.cc (gfc_trans_allocate): Generate code for setting
      	ERRMSG depending on result of STAT result of ALLOCATE.
      	* trans.cc (gfc_allocate_using_malloc): Use STAT value of
      	LIBERROR_NO_MEMORY in case of failed malloc.
      
      gcc/testsuite/ChangeLog:
      
      	PR fortran/91300
      	* gfortran.dg/allocate_alloc_opt_15.f90: New test.
      871dbb61
    • Roger Sayle's avatar
      PR rtl-optimization/101617: Use neg/sbb in ix86_expand_int_movcc. · f1652e33
      Roger Sayle authored
      This patch resolves PR rtl-optimization/101617 where we should generate
      the exact same code for (X ? -1 : 1) as we do for ((X ? -1 : 0) | 1).
      The cause of the current difference on x86_64 is actually in
      ix86_expand_int_movcc that doesn't know that negl;sbbl can be used
      to create a -1/0 result depending on whether the input is zero/nonzero.
      
      So for Andrew Pinski's test case:
      
      int f1(int i)
      {
        return i ? -1 : 1;
      }
      
      GCC currently generates:
      
      f1:     cmpl    $1, %edi
              sbbl    %eax, %eax	// x ? 0 : -1
              andl    $2, %eax	// x ? 0 : 2
              subl    $1, %eax	// x ? -1 : 1
              ret
      
      but with the attached patch, now generates:
      
      f1:	negl    %edi
              sbbl    %eax, %eax	// x ? -1 : 0
              orl     $1, %eax	// x ? -1 : 1
              ret
      
      To implement this I needed to add two expanders to i386.md to generate
      the required instructions (in both SImode and DImode) matching the
      pre-existing define_insns of the same name.
      
      2022-05-30  Roger Sayle  <roger@nextmovesoftware.com>
      
      gcc/ChangeLog
      	PR rtl-optimization/101617
      	* config/i386/i386-expand.cc (ix86_expand_int_movcc): Add a
      	special case (indicated by negate_cc_compare_p) to generate a
      	-1/0 mask using neg;sbb.
      	* config/i386/i386.md (x86_neg<mode>_ccc): New define_expand
      	to generate an *x86_neg<mode>_ccc instruction.
      	(x86_mov<mode>cc_0_m1_neg): Likewise, a new define_expand to
      	generate a *x86_mov<mode>cc_0_m1_neg instruction.
      
      gcc/testsuite/ChangeLog
      	PR rtl-optimization/101617
      	* gcc.target/i386/pr101617.c: New test case.
      f1652e33
    • Roger Sayle's avatar
      Make the default rtx_costs of MULT/DIV variants consistent. · 2a12adfa
      Roger Sayle authored
      GCC's middle-end provides a default cost model for RTL expressions, for
      backends that don't specify their own instruction timings, that can be
      summarized as multiplications are COSTS_N_INSNS(4), divisions are
      COSTS_N_INSNS(7) and all other operations are COSTS_N_INSNS(1).
      This patch tweaks the above definition so that fused-multiply-add
      (FMA) and high-part multiplications cost the same as regular multiplications,
      or more importantly aren't (by default) considered less expensive.  Likewise
      the saturating forms of multiplication and division cost the same as the
      regular variants.  These values can always be changed by the target, but
      the goal is to avoid RTL expansion substituting a suitable operation with
      its saturating equivalent because it (accidentally) looks much cheaper.
      For example, PR 89845 is about implementing division/modulus via highpart
      multiply, which may accidentally look extremely cheap.
      
      2022-05-30  Roger Sayle  <roger@nextmovesoftware.com>
      
      gcc/ChangeLog
      	* rtlanal.cc (rtx_cost) <MULT>: Treat FMA, SS_MULT, US_MULT,
      	SMUL_HIGHPART and UMUL_HIGHPART as having the same cost as MULT.
      	<DIV>: Likewise, SS_DIV and US_DIV have the same default as DIV.
      2a12adfa
    • Roger Sayle's avatar
      PR target/70321: Split double word equality/inequality after STV on x86. · 43201f2c
      Roger Sayle authored
      This patch resolves the last piece of PR target/70321 a code quality
      (P2 regression) affecting mainline.  Currently, for HJ's testcase:
      
      void foo (long long ixi)
      {
        if (ixi != 14348907)
          __builtin_abort ();
      }
      
      GCC with -m32 -O2 generates four instructions for the comparison:
      
              movl    16(%esp), %eax
              movl    20(%esp), %edx
              xorl    $14348907, %eax
              orl     %eax, %edx
      
      but with this patch it now requires only three, making better use of
      x86's addressing modes:
      
              movl    16(%esp), %eax
              xorl    $14348907, %eax
              orl     20(%esp), %eax
      
      The solution is to expand "doubleword" equality/inequality expressions
      using flag setting COMPARE instructions for the early RTL passes, and
      then split them during split1, after STV and before reload.
      Hence on x86_64, we now see/allow things like:
      
      (insn 11 8 12 2 (set (reg:CCZ 17 flags)
              (compare:CCZ (reg/v:TI 84 [ x ])
                  (reg:TI 96))) "cmpti.c":2:43 30 {*cmpti_doubleword}
      
      This allows the STV pass to decide whether it's preferrable to perform
      this comparison using vector operations, i.e. a pxor/ptest sequence,
      or as scalar integer operations, i.e. a xor/xor/or sequence.  Alas
      this required tweaking of the STV pass to recognize the "new" form of
      these comparisons and split out the pxor operation itself.  To confirm
      this still works as expected I've added a new STV test case:
      
      long long a[1024];
      long long b[1024];
      
      int foo()
      {
        for (int i=0; i<1024; i++)
        {
          long long t = (a[i]<<8) | (b[i]<<24);
          if (t == 0)
            return 1;
        }
        return 0;
      }
      
      where with -m32 -O2 -msse4.1 the above comparison with zero should look
      like:
      
              punpcklqdq      %xmm0, %xmm0
              ptest   %xmm0, %xmm0
      
      Although this patch includes one or two minor tweaks to provide all the
      necessary infrastructure to support conversion of TImode comparisons to
      V1TImode (and SImode comparisons to V4SImode), STV doesn't yet implement
      these transformations, but this is something that can be considered after
      stage 4.  Indeed the new convert_compare functionality is split out
      into a method to simplify its potential reuse by the timode_scalar_chain
      class.
      
      2022-05-30  Roger Sayle  <roger@nextmovesoftware.com>
      
      gcc/ChangeLog
      	PR target/70321
      	* config/i386/i386-expand.cc (ix86_expand_branch): Don't decompose
      	DI mode equality/inequality using XOR here.  Instead generate a
      	COMPARE for doubleword modes (DImode on !TARGET_64BIT or TImode).
      	* config/i386/i386-features.cc (gen_gpr_to_xmm_move_src): Use
      	gen_rtx_SUBREG when NUNITS is 1, i.e. for TImode to V1TImode.
      	(general_scalar_chain::convert_compare): New function to convert
      	scalar equality/inequality comparison into vector operations.
      	(general_scalar_chain::convert_insn) [COMPARE]: Refactor. Call
      	new convert_compare helper method.
      	(convertible_comparion_p): Update to match doubleword COMPARE
      	of two register, memory or integer constant operands.
      	* config/i386/i386-features.h (general_scalar_chain::convert_compare):
      	Prototype/declare member function here.
      	* config/i386/i386.md (cstore<mode>4): Change mode to SDWIM, but
      	only allow new doubleword modes for EQ and NE operators.
      	(*cmp<dwi>_doubleword): New define_insn_and_split, to split a
      	doubleword comparison into a pair of XORs followed by an IOR to
      	set the (zero) flags register, optimizing the XORs if possible.
      	* config/i386/sse.md (V_AVX): Include V1TI and V2TI in mode
      	iterator; V_AVX is (currently) only used by ptest.
      	(sse4_1 mode attribute): Update to support V1TI and V2TI.
      
      gcc/testsuite/ChangeLog
      	PR target/70321
      	* gcc.target/i386/pr70321.c: New test case.
      	* gcc.target/i386/sse4_1-stv-1.c: New test case.
      43201f2c
    • Uros Bizjak's avatar
      i386: Remove constraints when used with constant integer predicates, take 2 · 3595231d
      Uros Bizjak authored
      const_int_operand and other const*_operand predicates do not need
      constraints when the constraint is inherited from the range of
      constant integer predicate.  Remove the constraint in case all
      alternatives use the same inherited constraint.
      
      However, when there are operands, commitative with a non-constant
      operand, the operand effectively matches e.g.
      nonimmediate_operand|const_int_operand rather than just
      const_int_operand.  We should keep the constraint for
      const_int_operand that are in a % pair. See PR 105624.
      
      2022-05-30  Uroš Bizjak  <ubizjak@gmail.com>
      
      gcc/ChangeLog:
      
      	* config/i386/i386.md: Remove constraints when used with
      	const_int_operand, const0_operand, const_1_operand, constm1_operand,
      	const8_operand, const128_operand, const248_operand, const123_operand,
      	const2367_operand, const1248_operand, const359_operand,
      	const_4_or_8_to_11_operand, const48_operand, const_0_to_1_operand,
      	const_0_to_3_operand, const_0_to_4_operand, const_0_to_5_operand,
      	const_0_to_7_operand, const_0_to_15_operand, const_0_to_31_operand,
      	const_0_to_63_operand, const_0_to_127_operand, const_0_to_255_operand,
      	const_0_to_255_mul_8_operand, const_1_to_31_operand,
      	const_1_to_63_operand, const_2_to_3_operand, const_4_to_5_operand,
      	const_4_to_7_operand, const_6_to_7_operand, const_8_to_9_operand,
      	const_8_to_11_operand, const_8_to_15_operand, const_10_to_11_operand,
      	const_12_to_13_operand, const_12_to_15_operand, const_14_to_15_operand,
      	const_16_to_19_operand, const_16_to_31_operand, const_20_to_23_operand,
      	const_24_to_27_operand and const_28_to_31_operand.
      	* config/i386/mmx.md: Ditto.
      	* config/i386/sse.md: Ditto.
      	* config/i386/subst.md: Ditto.
      	* config/i386/sync.md: Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/i386/pr105624.c: New test.
      3595231d
    • Jan Beulich's avatar
      x86: correct bmi2_umul<mode><dwi>3_1's MEM_P() uses · c8929840
      Jan Beulich authored
      It's pretty clear that the operand numbers in the MEM_P() checks are
      off by one, perhaps due to a copy-and-paste oversight (unlike in most
      other places here we're dealing with two outputs).
      
      gcc/
      
      	* config/i386/i386.md (bmi2_umul<mode><dwi>3_1): Correct MEM_P()
      	arguments.
      c8929840
    • Ghjuvan Lacambre's avatar
      [Ada] Fix spurious options being inserted in -fdiagnostics-format=json output · 1b88c61e
      Ghjuvan Lacambre authored
      Without this patch, gnat would use `-gnatw?` as the default option for
      some of the default warnings.
      
      gcc/ada/
      
      	* erroutc.adb (Get_Warning_Option): Don't consider `?` as a
      	valid option switch.
      1b88c61e
    • Ghjuvan Lacambre's avatar
      [Ada] Add "option" field to GNAT's -fdiagnostics-format=json output · a4db870e
      Ghjuvan Lacambre authored
      This enables better integration with tools that handle GNAT's output.
      
      gcc/ada/
      
      	* erroutc.ads (Get_Warning_Option): New function returning the
      	option responsible for a warning if it exists.
      	* erroutc.adb (Get_Warning_Option): Likewise.
      	(Get_Warning_Tag): Rely on Get_Warning_Option when possible.
      	* errout.adb (Output_JSON_Message): Emit option field.
      a4db870e
    • Julien Bortolussi's avatar
      [Ada] Remove contract duplication in formal doubly linked lists · 8244b803
      Julien Bortolussi authored
      Remove a minor duplication in Post of a function of formal doubly linked
      lists.
      
      gcc/ada/
      
      	* libgnat/a-cfdlli.ads (Insert): Remove the duplication.
      8244b803
    • Piotr Trojanek's avatar
      [Ada] Fix expansion of structural subprogram variants · 576b7778
      Piotr Trojanek authored
      When implementing structural subprogram variants we ignored them in
      expansion of the pragma itself, but not in expansion of a recursive
      subprogram call. Now fixed.
      
      gcc/ada/
      
      	* exp_ch6.adb (Check_Subprogram_Variant): Ignore structural
      	variants.
      576b7778
    • Piotr Trojanek's avatar
      [Ada] Simplify construction of a path to file · 263cb16b
      Piotr Trojanek authored
      Code cleanup; semantics is unaffected.
      
      gcc/ada/
      
      	* osint.adb (Locate_File): Change variable to constant and
      	initialize it by concatenation of directory, file name and NUL.
      263cb16b
    • Piotr Trojanek's avatar
      [Ada] Remove repeated description of support for Address clauses · 0f29dfce
      Piotr Trojanek authored
      The GNAT behaviour regarding the Ada RM requirement to support Address
      clauses for imported subprograms was documented twice: in section about
      packed types (which was a mistake) and in section about address clauses
      (where it belongs).
      
      Cleanup related to the use of packed arrays for bitset operations to
      detect uses of uninitialized scalars in GNAT.
      
      gcc/ada/
      
      	* doc/gnat_rm/implementation_advice.rst (Packed Types): Remove
      	duplicated and wrongly placed paragraph.
      	* gnat_rm.texi: Regenerate.
      0f29dfce
    • Ghjuvan Lacambre's avatar
      [Ada] Add insertion character to Ineffective_Inline_Warnings messages · 9baae569
      Ghjuvan Lacambre authored
      This enables tools that ingest GNAT's output to properly classify these
      messages.
      
      gcc/ada/
      
      	* inline.adb (Check_Package_Body_For_Inlining): Add insertion
      	character.
      9baae569
    • Ghjuvan Lacambre's avatar
      [Ada] Add insertion character for overlay modification warnings · 94cf3d1f
      Ghjuvan Lacambre authored
      This enables tools that ingest GNAT's output to properly classify these
      messages.
      
      gcc/ada/
      
      	* freeze.adb (Warn_Overlay): Add 'o' insertion character.
      	* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Likewise.
      	* sem_util.adb (Note_Possible_Modifications): Likewise.
      94cf3d1f
    • Ghjuvan Lacambre's avatar
      [Ada] Fix Warn_On_All_Unread_Out_Parameters not being properly tagged · 67481ef5
      Ghjuvan Lacambre authored
      This caused tools ingesting GNAT's output to mislabel these messages.
      
      gcc/ada/
      
      	* sem_warn.adb (Warn_On_Useless_Assignment): Fix insertion
      	character.
      67481ef5
Loading