Skip to content
Snippets Groups Projects
  1. Oct 28, 2022
    • Andre Vieira's avatar
      vect: Reject non-byte offsets for gather/scatters [PR107346] · 95decac3
      Andre Vieira authored
      The ada failure reported in the PR was being caused by vect_check_gather_scatter
      failing to deal with bit offsets that weren't multiples of BITS_PER_UNIT. This
      patch makes vect_check_gather_scatter reject memory accesses with such offsets.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/107346
      	* tree-vect-data-refs.cc (vect_check_gather_scatter): Reject offsets
      	that aren't multiples of BITS_PER_UNIT.
      95decac3
    • Richard Biener's avatar
      tree-optimization/107407 - wrong code with DSE · 031a400e
      Richard Biener authored
      So what happens is that we elide processing of this check with
      
                /* In addition to kills we can remove defs whose only use
                   is another def in defs.  That can only ever be PHIs of which
                   we track two for simplicity reasons, the first and last in
                   {first,last}_phi_def (we fail for multiple PHIs anyways).
                   We can also ignore defs that feed only into
                   already visited PHIs.  */
                else if (single_imm_use (vdef, &use_p, &use_stmt)
                         && (use_stmt == first_phi_def
                             || use_stmt == last_phi_def
                             || (gimple_code (use_stmt) == GIMPLE_PHI
                                 && bitmap_bit_p (visited,
                                                  SSA_NAME_VERSION
                                                    (PHI_RESULT (use_stmt))))))
      
      where we have the last PHI being the outer loop virtual PHI and the first
      PHI being the loop exit PHI of the outer loop and we've already processed
      the single immediate use of the outer loop PHI, the inner loop PHI.  But
      we still have to perform the above check!
      
      It's easiest to perform the check when we visit the PHI node instead of
      delaying it to the actual processing loop.
      
      	PR tree-optimization/107407
      	* tree-ssa-dse.cc (dse_classify_store): Perform backedge
      	varying index check when collecting PHI uses rather than
      	after optimizing processing of the candidate defs.
      
      	* gcc.dg/torture/pr107407.c: New testcase.
      031a400e
    • Richard Biener's avatar
      tree-optimization/107447 - avoid hoisting returns-twice calls in LIM · 1add3635
      Richard Biener authored
      The following makes sure to not hoist returns-twice calls in LIM
      since we have no way to move the abnormal edge associated with it
      and we are prone having stray abnormal edges in the IL which will
      then cause IL verification failures even when the actual call
      does not return twice.
      
      	PR tree-optimization/107447
      	* tree-ssa-loop-im.cc (determine_max_movement): Do not
      	hoist returns-twice calls.
      
      	* gcc.dg/torture/pr107447.c: New testcase.
      1add3635
    • Richard Biener's avatar
      tree-optimization/107435 - ICE with recurrence vectorization · 08412858
      Richard Biener authored
      This implements the missed conversion from pointer to integer.
      
      	PR tree-optimization/107435
      	* tree-vect-loop.cc (vectorizable_recurr): Convert initial
      	value to vector component type.
      
      	* gcc.dg/torture/pr107435.c: New testcase.
      08412858
    • Jakub Jelinek's avatar
      openmp: Allow optional comma after directive-specifier in C/C++ · 89999f23
      Jakub Jelinek authored
      Previously we've been allowing that comma only in C++ when in attribute
      form (which was the reason why it has been allowed), but 5.1 allows that
      even in pragma form in C/C++ (with clarifications in 5.2) and 5.2
      also in Fortran (which this patch doesn't implement).
      
      Note, for directives which take an argument (== unnamed clause),
      comma is not allowed in between the directive name and the argument,
      like the directive-1.c testcase shows.
      
      2022-10-28  Jakub Jelinek  <jakub@redhat.com>
      
      gcc/c/
      	* c-parser.cc (c_parser_omp_all_clauses): Allow optional
      	comma before the first clause.
      	(c_parser_omp_allocate, c_parser_omp_atomic, c_parser_omp_depobj,
      	c_parser_omp_flush, c_parser_omp_scan_loop_body,
      	c_parser_omp_ordered, c_finish_omp_declare_variant,
      	c_parser_omp_declare_target, c_parser_omp_declare_reduction,
      	c_parser_omp_requires, c_parser_omp_error,
      	c_parser_omp_assumption_clauses): Likewise.
      gcc/cp/
      	* parser.cc (cp_parser_omp_all_clauses): Allow optional comma
      	before the first clause even in pragma syntax.
      	(cp_parser_omp_allocate, cp_parser_omp_atomic, cp_parser_omp_depobj,
      	cp_parser_omp_flush, cp_parser_omp_scan_loop_body,
      	cp_parser_omp_ordered, cp_parser_omp_assumption_clauses,
      	cp_finish_omp_declare_variant, cp_parser_omp_declare_target,
      	cp_parser_omp_declare_reduction_exprs, cp_parser_omp_requires,
      	cp_parser_omp_error): Likewise.
      gcc/testsuite/
      	* c-c++-common/gomp/directive-1.c: New test.
      	* c-c++-common/gomp/clauses-6.c: New test.
      	* c-c++-common/gomp/declare-variant-2.c (f75a): Declare.
      	(f75): Use f75a as variant instead of f1 and don't expect error.
      	* g++.dg/gomp/clause-4.C (foo): Don't expect error on comma
      	before first clause.
      	* gcc.dg/gomp/clause-2.c (foo): Likewise.
      89999f23
    • Richard Biener's avatar
      Adjust gcc.dg/vect/pr100756.c for V8SI and V16SI · 826df6d0
      Richard Biener authored
      The following adjusts the testcase to require no epilogue also
      for larger vectors than V4SI.
      
      	* gcc.dg/vect/pr100756.c: Adjust for larger vectors.
      826df6d0
    • Julian Brown's avatar
      OpenACC: Don't gang-privatize artificial variables [PR90115] · 11e811d8
      Julian Brown authored
      
      This patch prevents compiler-generated artificial variables from being
      treated as privatization candidates for OpenACC.
      
      The rationale is that e.g. "gang-private" variables actually must be
      shared by each worker and vector spawned within a particular gang, but
      that sharing is not necessary for any compiler-generated variable (at
      least at present, but no such need is anticipated either).  Variables on
      the stack (and machine registers) are already private per-"thread"
      (gang, worker and/or vector), and that's fine for artificial variables.
      
      We're restricting this to blocks, as we still need to understand what it
      means for a 'DECL_ARTIFICIAL' to appear in a 'private' clause.
      
      Several tests need their scan output patterns adjusted to compensate.
      
      2022-10-14  Julian Brown  <julian@codesourcery.com>
      
      	PR middle-end/90115
      gcc/
      	* omp-low.cc (oacc_privatization_candidate_p): Artificial vars are not
      	privatization candidates.
      
      libgomp/
      	* testsuite/libgomp.oacc-fortran/declare-1.f90: Adjust scan output.
      	* testsuite/libgomp.oacc-fortran/host_data-5.F90: Likewise.
      	* testsuite/libgomp.oacc-fortran/if-1.f90: Likewise.
      	* testsuite/libgomp.oacc-fortran/print-1.f90: Likewise.
      	* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Likewise.
      
      Co-authored-by: default avatarThomas Schwinge <thomas@codesourcery.com>
      11e811d8
    • Thomas Schwinge's avatar
      Fix target selector syntax in 'gcc.dg/vect/bb-slp-cond-1.c' · 06073077
      Thomas Schwinge authored
      ... to restore testing lost in recent
      commit r13-3225-gbd9a05594d227cde79a67dc715bd9d82e9c464e9
      "amdgcn: vector testsuite tweaks" (for example, x86_64-pc-linux-gnu):
      
          PASS: gcc.dg/vect/bb-slp-cond-1.c (test for excess errors)
          PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects  scan-tree-dump vect "(no need for alias check [^\\n]* when VF is 1|no alias between [^\\n]* when [^\\n]* is outside \\(-16, 16\\))"
          [-PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects  scan-tree-dump-times vect "loop vectorized" 1-]
          PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects (test for excess errors)
          PASS: gcc.dg/vect/bb-slp-cond-1.c -flto -ffat-lto-objects execution test
          PASS: gcc.dg/vect/bb-slp-cond-1.c execution test
          PASS: gcc.dg/vect/bb-slp-cond-1.c scan-tree-dump vect "(no need for alias check [^\\n]* when VF is 1|no alias between [^\\n]* when [^\\n]* is outside \\(-16, 16\\))"
          [-PASS: gcc.dg/vect/bb-slp-cond-1.c scan-tree-dump-times vect "loop vectorized" 1-]
      
      	gcc/testsuite/
      	* gcc.dg/vect/bb-slp-cond-1.c: Fix target selector syntax.
      06073077
    • Martin Liska's avatar
      docs: document sanitizers can trigger warnings · 3f9c0713
      Martin Liska authored
      	PR sanitizer/107298
      
      gcc/ChangeLog:
      
      	* doc/invoke.texi: Document sanitizers can trigger warnings.
      3f9c0713
    • Martin Liska's avatar
      lto-dump: modernize a bit · bd891730
      Martin Liska authored
      gcc/lto/ChangeLog:
      
      	* lto-dump.cc (dump_list): Remove trailing return.
      	(dump_symbol): Likewise.
      	(dump_body): Filter name based on mangled name.
      	(dump_tool_help): Use GIMPLE wording.
      	(lto_main): Update wording.
      bd891730
    • Thomas Schwinge's avatar
      Document 'distclean-stage[N]' · 0c112651
      Thomas Schwinge authored
      Refer to 'Makefile.tpl':
      
          # Rules to wipe a stage and all the following ones, also used for cleanstrap
          [+ IF prev +]distclean-stage[+prev+]:: distclean-stage[+id+] [+ ENDIF prev +]
          .PHONY: distclean-stage[+id+]
          distclean-stage[+id+]::
          	@: $(MAKE); $(stage)
          	@test "`cat stage_last`" != stage[+id+] || rm -f stage_last
          	rm -rf stage[+id+]-* [+
          	  IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
      
      	gcc/
      	* doc/makefile.texi (Makefile Targets): Document
      	'distclean-stage[N]'.
      0c112651
    • Aldy Hernandez's avatar
      Change remaining flag_finite_math_only use in value-range.cc. · c6567d2c
      Aldy Hernandez authored
      gcc/ChangeLog:
      
      	* value-range.cc (range_tests_floats): Use HONOR_INFINITIES.
      c6567d2c
    • Kewen Lin's avatar
      testsuite: Adjust vect-bitfield-read-* with vect_shift and vect_long_long [PR107240] · 225f9c88
      Kewen Lin authored
      The test cases vect-bitfield-read-* requires vector shift
      target support, they need one explicit vect_shift effective
      target requirement checking.  Besides, the vectype for struct
      in test cases vect-bitfield-read-{2,4} is vector of long long,
      we need to check effective target vect_long_long for them.
      This patch can help to fix all remaining vect-bitfield-{read,
      write}-* test failures on powerpc.
      
      	PR testsuite/107240
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/vect/vect-bitfield-read-1.c: Add effective target checking
      	vect_shift.
      	* gcc.dg/vect/vect-bitfield-read-3.c: Likewise.
      	* gcc.dg/vect/vect-bitfield-read-5.c: Likewise.
      	* gcc.dg/vect/vect-bitfield-read-6.c: Likewise.
      	* gcc.dg/vect/vect-bitfield-read-7.c: Likewise.
      	* gcc.dg/vect/vect-bitfield-read-2.c: Add effective target checking
      	vect_shift and replace vect_int with vect_long_long.
      	* gcc.dg/vect/vect-bitfield-read-4.c: Likewise.
      225f9c88
    • Joseph Myers's avatar
      c: C2x enums with fixed underlying type [PR61469] · e0997c14
      Joseph Myers authored
      C2x adds support for enums with a fixed underlying type specified
      ("enum e : long long;" and similar).  Implement this in the C front
      end.  The same representation is used for these types as in C++, with
      two macros moved from cp-tree.h to c-common.h.
      
      Such enums can have bool as the underlying type, and various C
      front-end code checking for boolean types is adjusted to use a new
      C_BOOLEAN_TYPE_P to handle such enums the same way as bool.  (Note
      that for C++ we have bug 96496 that enums with underlying type bool
      don't work correctly there.)
      
      There are various issues with the wording for such enums in the
      current C2x working draft (including but not limited to wording in the
      accepted paper that failed to make it into the working draft), which I
      intend to raise in NB comments.  I think what I've implemented and
      added tests for matches the intent.
      
      Bootstrapped with no regressions for x86_64-pc-linux-gnu.
      
      	PR c/61469
      
      gcc/c-family/
      	* c-common.h (ENUM_UNDERLYING_TYPE, ENUM_FIXED_UNDERLYING_TYPE_P):
      	New.  Moved from cp/cp-tree.h.
      	* c-warn.cc (warnings_for_convert_and_check): Do not consider
      	conversions to enum with underlying type bool to overflow.
      
      gcc/c/
      	* c-convert.cc (c_convert): Handle enums with underlying boolean
      	type like bool.
      	* c-decl.cc (shadow_tag_warned): Allow shadowing declarations for
      	enums with enum type specifier, but give errors for storage class
      	specifiers, qualifiers or alignment specifiers in non-definition
      	declarations of such enums.
      	(grokdeclarator): Give error for non-definition use of type
      	specifier with an enum type specifier.
      	(parser_xref_tag): Add argument has_enum_type_specifier.  Pass it
      	to lookup_tag and use it to set ENUM_FIXED_UNDERLYING_TYPE_P.
      	(xref_tag): Update call to parser_xref_tag.
      	(start_enum): Add argument fixed_underlying_type.  Complete enum
      	type with a fixed underlying type given in the definition.  Give
      	error for defining without a fixed underlying type in the
      	definition if one was given in a prior declaration.  Do not mark
      	enums with fixed underlying type as packed for -fshort-enums.
      	Store the enum type in the_enum.
      	(finish_enum): Do not adjust types of values or check their range
      	for an enum with a fixed underlying type.  Set underlying type of
      	enum and variants.
      	(build_enumerator): Check enumeration constants for enum with
      	fixed underlying type against that type and convert to that type.
      	Increment in the underlying integer type, with handling for bool.
      	(c_simulate_enum_decl): Update call to start_enum.
      	(declspecs_add_type): Set specs->enum_type_specifier_ref_p.
      	* c-objc-common.cc (c_get_alias_set): Use ENUM_UNDERLYING_TYPE
      	rather than recomputing an underlying type based on size.
      	* c-parser.cc (c_parser_declspecs)
      	(c_parser_struct_or_union_specifier, c_parser_typeof_specifier):
      	Set has_enum_type_specifier for type specifiers.
      	(c_parser_enum_specifier): Handle enum type specifiers.
      	(c_parser_struct_or_union_specifier): Update call to
      	parser_xref_tag.
      	(c_parser_omp_atomic): Check for boolean increment or decrement
      	using C_BOOLEAN_TYPE_P.
      	* c-tree.h (C_BOOLEAN_TYPE_P): New.
      	(struct c_typespec): Add has_enum_type_specifier.
      	(struct c_declspecs): Add enum_type_specifier_ref_p.
      	(struct c_enum_contents): Add enum_type.
      	(start_enum, parser_xref_tag): Update prototypes.
      	* c-typeck.cc (composite_type): Allow for enumerated types
      	compatible with bool.
      	(common_type, comptypes_internal, perform_integral_promotions):
      	Use ENUM_UNDERLYING_TYPE.
      	(parser_build_binary_op, build_unary_op, convert_for_assignment)
      	(c_finish_return, c_start_switch, build_binary_op): Check for
      	boolean types using C_BOOLEAN_TYPE_P.
      
      gcc/cp/
      	* cp-tree.h (ENUM_FIXED_UNDERLYING_TYPE_P, ENUM_UNDERLYING_TYPE):
      	Remove.  Moved to c-common.h.
      
      gcc/testsuite/
      	* gcc.dg/c11-enum-4.c, gcc.dg/c11-enum-5.c, gcc.dg/c11-enum-6.c,
      	gcc.dg/c2x-enum-6.c, gcc.dg/c2x-enum-7.c, gcc.dg/c2x-enum-8.c,
      	gcc.dg/gnu2x-enum-1.c: New tests.
      e0997c14
    • GCC Administrator's avatar
      Daily bump. · 96069d84
      GCC Administrator authored
      96069d84
    • Ian Lance Taylor's avatar
      runtime: use _libgo_off_t_type when calling C mmap · 0a2984dd
      Ian Lance Taylor authored
      The last argument to the C mmap function is type off_t, not uintptr.
      On some 32-bit systems, off_t is larger than uintptr.
      
      Based on patch by Sören Tempel.
      
      Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/445735
      0a2984dd
  2. Oct 27, 2022
    • Eric Botcazou's avatar
      Aarch64: Do not define DONT_USE_BUILTIN_SETJMP · fc01cfa9
      Eric Botcazou authored
      The setting looks obsolete at this point.
      
      gcc/
      	* config/aarch64/aarch64.h (DONT_USE_BUILTIN_SETJMP): Delete.
      fc01cfa9
    • H.J. Lu's avatar
      x86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns · 0e36a9c6
      H.J. Lu authored
      In i386.md, neg patterns which set MODE_CC register like
      
      (set (reg:CCC FLAGS_REG)
           (ne:CCC (match_operand:SWI48 1 "general_reg_operand") (const_int 0)))
      
      can lead to errors when operand 1 is a constant value.  If FLAGS_REG in
      
      (set (reg:CCC FLAGS_REG)
           (ne:CCC (const_int 2) (const_int 0)))
      
      is set to 1, RTX simplifiers may simplify
      
      (set (reg:SI 93)
           (neg:SI (ltu:SI (reg:CCC 17 flags) (const_int 0 [0]))))
      
      as
      
      (set (reg:SI 93)
           (neg:SI (ltu:SI (const_int 1) (const_int 0 [0]))))
      
      which leads to incorrect results since LTU on MODE_CC register isn't the
      same as "unsigned less than" in x86 backend.  To prevent RTL optimizers
      from setting MODE_CC register to a constant, use UNSPEC_CC_NE to replace
      ne:CCC/ne:CCO when setting FLAGS_REG in neg patterns.
      
      gcc/
      
      	PR target/107172
      	* config/i386/i386.md (UNSPEC_CC_NE): New.
      	Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns.
      
      gcc/testsuite/
      
      	PR target/107172
      	* gcc.target/i386/pr107172.c: New test.
      0e36a9c6
    • Andrew Pinski's avatar
      Use simple_dce_from_worklist with match_simplify_replacement. · 1c2b53ce
      Andrew Pinski authored
      This is a simple patch to do some DCE after a successful
      match and simplify replacement in PHI-OPT. match and simplify
      likes to generate some extra statements which should be cleaned
      up.
      
      OK? Bootstrapped and tested on x86_64-linux with no regressions.
      
      Thanks,
      Andrew Pinski
      
      gcc/ChangeLog:
      
      	* tree-ssa-phiopt.cc: Include tree-ssa-dce.h
      	(replace_phi_edge_with_variable):
      	New argument, dce_ssa_names. Call simple_dce_from_worklist.
      	(match_simplify_replacement): If we inserted a sequence,
      	mark the lhs of the new sequence to be possible dce.
      	Always move the statement and mark the lhs (if it is a name)
      	as possible to remove.
      1c2b53ce
    • Jakub Jelinek's avatar
      c++: Fix ICE on g++.dg/modules/adl-3_c.C [PR107379] · a33d623d
      Jakub Jelinek authored
      As mentioned in the PR, apparently my r13-2887 P1467R9 changes
      regressed these tests on powerpc64le-linux with IEEE quad by default.
      
      I believe my changes just uncovered a latent bug.
      The problem is that push_namespace calls find_namespace_slot,
      which does:
        tree *slot = DECL_NAMESPACE_BINDINGS (ns)
          ->find_slot_with_hash (name, name ? IDENTIFIER_HASH_VALUE (name) : 0,
                                 create_p ? INSERT : NO_INSERT);
      In the <identifier_node 0x7fffe9f55ac0 details> ns case, slot is non-NULL
      above with a binding_vector in it.
      Then pushdecl is called and this does:
                        slot = find_namespace_slot (ns, name, ns == current_namespace);
      where ns == current_namespace (ns is :: and name is details) is true.
      So this again calls
                tree *slot = DECL_NAMESPACE_BINDINGS (ns)
                  ->find_slot_with_hash (name, name ? IDENTIFIER_HASH_VALUE (name) : 0,
                                         create_p ? INSERT : NO_INSERT);
      but this time with create_p and so INSERT.
      At this point we reach
                if (insert == INSERT && m_size * 3 <= m_n_elements * 4)
                  expand ();
      and when we are unlucky and the occupancy of the hash table just reached 3/4,
      expand () is called and the hash table is reallocated.  But when that happens,
      it means the slot pointer in the pushdecl caller (push_namespace) points to
      freed memory and so any accesses to it in make_namespace_finish will be UB.
      
      The following patch fixes it by calling find_namespace_slot again even if it
      was non-NULL, just doesn't assert it is *slot == ns in that case (because
      it often is not).
      
      2022-10-27  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c++/107379
      	* name-lookup.cc (push_namespace): Call find_namespace_slot again
      	after pushdecl as the hash table might be expanded during pushdecl.
      a33d623d
    • Nathan Sidwell's avatar
      c++: Templated lambda mangling · f7d1d777
      Nathan Sidwell authored
      (Explicitly) Templated lambdas have a different signature to
      implicitly templated lambdas -- '[]<template T> (T) {}' is not the
      same as '[](auto) {}'.  This should be reflected in the mangling.  The
      ABI captures this as
      https://github.com/itanium-cxx-abi/cxx-abi/issues/31, and clang has
      implemented such additions.
      
      It's relatively straight forwards to write out the non-synthetic
      template parms, and note if we need to issue an ABI warning.
      
      	gcc/cp/
      	* mangle.cc (write_closure_template_head): New.
      	(write_closure_type_name): Call it.
      	gcc/testsuite/
      	* g++.dg/abi/lambda-ctx1-18.C: Adjust.
      	* g++.dg/abi/lambda-ctx1-18vs17.C: Adjust.
      	* g++.dg/abi/lambda-tpl1-17.C: New.
      	* g++.dg/abi/lambda-tpl1-18.C: New.
      	* g++.dg/abi/lambda-tpl1-18vs17.C: New.
      	* g++.dg/abi/lambda-tpl1.h: New.
      f7d1d777
    • Richard Sandiford's avatar
      aarch64: Reinstate some uses of CONSTEXPR · f95d3d5d
      Richard Sandiford authored
      In 9482a5e4 I'd replaced uses
      of CONSTEXPR with direct uses of constexpr.  However, it turns
      out that we still have CONSTEXPR for a reason: GCC 4.8 doesn't
      implement constexpr properly, and for example rejects things like:
      
        extern const int x;
        constexpr int x = 1;
      
      This patch partially reverts the previous one.  To make things
      more complicated, there are still some things that need to be
      constexpr rather than CONSTEXPR, since they are used to initialise
      scalar constants.  The patch therefore doesn't change anything
      in aarch64-feature-deps.h.
      
      gcc/
      	* config/aarch64/aarch64-protos.h: Replace constexpr with
      	CONSTEXPR.
      	* config/aarch64/aarch64-sve-builtins-base.cc: Likewise.
      	* config/aarch64/aarch64-sve-builtins-functions.h: Likewise.
      	* config/aarch64/aarch64-sve-builtins-shapes.cc: Likewise.
      	* config/aarch64/aarch64-sve-builtins-sve2.cc: Likewise.
      	* config/aarch64/aarch64-sve-builtins.cc: Likewise.
      	* config/aarch64/aarch64.cc: Likewise.
      	* config/aarch64/driver-aarch64.cc: Likewise
      f95d3d5d
    • Aldy Hernandez's avatar
      [PR tree-optimization/107394] Canonicalize global franges as they are read back. · 2b1fb720
      Aldy Hernandez authored
      The problem here is that we're inlining a global range with NANs into
      a function that has been tagged with __attribute__((optimize
      ("-ffinite-math-only"))).  As the global range is copied from
      SSA_NAME_RANGE_INFO, its NAN bits are copied, which then cause
      frange::verify_range() to fail a sanity check making sure no NANs
      creep in when !HONOR_NANS.
      
      I think what we should do is nuke the NAN bits as we're restoring the
      global range.  For that matter, if we use the frange constructor,
      everything except that NAN sign will be done automatically, including
      dropping INFs to the min/max representable range when appropriate.
      
      	PR tree-optimization/107394
      
      gcc/ChangeLog:
      
      	* value-range-storage.cc (frange_storage_slot::get_frange): Use
      	frange constructor.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-ssa/pr107394.c: New test.
      2b1fb720
    • Thomas Schwinge's avatar
      options: Clarify 'Init' option property usage for streaming optimization · 9119431b
      Thomas Schwinge authored
      This clarifies commit 95db7e9a
      "options, lto: Optimize streaming of optimization nodes".
      
      No functional change; no change in generated files.
      
      	gcc/
      	* optc-save-gen.awk: Clarify 'Init' option property usage for
      	streaming optimization.
      9119431b
    • Martin Liska's avatar
      lto: do not load LTO stream for aliases [PR107418] · be6c7554
      Martin Liska authored
      	PR lto/107418
      
      gcc/lto/ChangeLog:
      
      	* lto-dump.cc (lto_main): Do not load LTO stream for aliases.
      be6c7554
    • Jakub Jelinek's avatar
      c++: Fix excess precision related ICE on invalid binop [PR107382, PR107383] · bfb7994a
      Jakub Jelinek authored
      The following tests ICE in the gcc_assert (common); in cp_build_binary_op.
      I've missed that while for * common is set always, while for +, - and /
      it is in some cases not.
      If it is not, then
        if (!result_type
            && arithmetic_types_p
            && (shorten || common || short_compare))
      condition is false, then the following
        if (may_need_excess_precision
            && (orig_type0 != type0 || orig_type1 != type1)
            && build_type == NULL_TREE)
      would fail the assertion there and if there wouldn't be excess precision,
        if (code == SPACESHIP_EXPR)
      would be false (for SPACESHIP_EXPR we always have build_type set like for
      other comparisons) and then trigger
        if (!result_type)
          {
            if (complain & tf_error)
              {
                binary_op_rich_location richloc (location,
                                                 orig_op0, orig_op1, true);
                error_at (&richloc,
                          "invalid operands of types %qT and %qT to binary %qO",
                          TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code);
              }
            return error_mark_node;
          }
      So, if result_type is NULL, we don't really need to compute
      semantic_result_type because nothing will use it anyway and can get
      fall through into the error/return error_mark_node; case.
      
      2022-10-27  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c++/107382
      	PR c++/107383
      	* typeck.cc (cp_build_binary_op): Don't compute semantic_result_type
      	if result_type is NULL.
      
      	* g++.dg/diagnostic/bad-binary-ops2.C: New test.
      bfb7994a
    • Torbjörn SVENSSON's avatar
      IRA: Make sure array is big enough · 4e1d7042
      Torbjörn SVENSSON authored
      
      In commit 081c9662, the call to resize_reg_info() was moved before
      the call to remove_scratches() and the latter one can increase the
      number of regs and that would cause an out of bounds usage on the
      reg_renumber global array.
      
      Without this patch, the following testcase randomly fails with:
      during RTL pass: ira
      In file included from /src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c:13:
      /src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c: In function 'checkgSf13':
      /src/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-y.h:28:1: internal compiler error: Segmentation fault
      /src/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c:22:1: note: in expansion of macro 'TEST'
      
      gcc/ChangeLog:
      
      	* ira.cc: Resize array after reg number increased.
      
      Co-Authored-By: default avatarYvan ROUX <yvan.roux@foss.st.com>
      Signed-off-by: default avatarTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
      4e1d7042
    • Jiawei's avatar
      RISC-V: Add zhinx/zhinxmin testcases. · 27065374
      Jiawei authored
      Test zhinx/zhinxmin support, same like with zfh/zfhmin testcases
      but use gprs and don't use fmv instruction.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/_Float16-zhinx-1.c: New test.
      	* gcc.target/riscv/_Float16-zhinx-2.c: New test.
      	* gcc.target/riscv/_Float16-zhinx-3.c: New test.
      	* gcc.target/riscv/_Float16-zhinxmin-1.c: New test.
      	* gcc.target/riscv/_Float16-zhinxmin-2.c: New test.
      	* gcc.target/riscv/_Float16-zhinxmin-3.c: New test.
      27065374
    • Jiawei's avatar
      RISC-V: Limit regs use for z*inx extension. · 6b252dc9
      Jiawei authored
      
      Limit z*inx abi support with 'ilp32','ilp32e','lp64' only.
      Use GPR instead FPR when 'zfinx' enable, Only use even registers
      in RV32 when 'zdinx' enable.
      Enable FLOAT16 when Zhinx/Zhinxmin enabled.
      
      Co-Authored-By: default avatarSinan Lin <sinan@isrc.iscas.ac.cn>
      
      gcc/ChangeLog:
      
      	* config/riscv/constraints.md (TARGET_ZFINX ? GR_REGS): Set GPRS
      	use while Zfinx is enable.
      	* config/riscv/riscv.cc (riscv_hard_regno_mode_ok): Limit odd
      	registers use when Zdinx enable in RV32 cases.
      	(riscv_option_override): New target enable MASK_FDIV.
      	(riscv_libgcc_floating_mode_supported_p): New error info when
      	use incompatible arch&abi.
      	(riscv_excess_precision): New target enable FLOAT16.
      6b252dc9
    • Jiawei's avatar
      RISC-V: Target support for z*inx extension. · ac96e906
      Jiawei authored
      Support 'TARGET_ZFINX' with float instruction pattern and builtin function.
      Reuse 'TARGET_HADR_FLOAT',  'TARGET_DOUBLE_FLOAT' and 'TARGET_ZHINX' patterns.
      
      gcc/ChangeLog:
      
      	* config/riscv/iterators.md (TARGET_ZFINX):New target.
      	(TARGET_ZDINX): Ditto.
      	(TARGET_ZHINX): Ditto.
      	* config/riscv/riscv-builtins.cc (AVAIL): Ditto.
      	(riscv_atomic_assign_expand_fenv): Ditto.
      	* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Ditto.
      	* config/riscv/riscv.md: Ditto.
      ac96e906
    • Jiawei's avatar
      RISC-V: Minimal support of z*inx extension. · e0933572
      Jiawei authored
      
      Minimal support of z*inx extension, include 'zfinx', 'zdinx' and 'zhinx/zhinxmin'
      corresponding to 'f', 'd' and 'zfh/zfhmin', the 'zdinx' will imply 'zfinx'
      same as 'd' imply 'f', 'zhinx' will aslo imply 'zfinx', all zfinx extension imply 'zicsr'.
      
      Co-Authored-By: default avatarSinan Lin <sinan@isrc.iscas.ac.cn>
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc: New extensions.
      	* config/riscv/arch-canonicalize: New imply relations.
      	* config/riscv/riscv-opts.h (MASK_ZFINX): New mask.
      	(MASK_ZDINX): Ditto.
      	(MASK_ZHINX): Ditto.
      	(MASK_ZHINXMIN): Ditto.
      	(TARGET_ZFINX): New target.
      	(TARGET_ZDINX): Ditto.
      	(TARGET_ZHINX): Ditto.
      	(TARGET_ZHINXMIN): Ditto.
      	* config/riscv/riscv.opt: New target variable.
      e0933572
    • GCC Administrator's avatar
      Daily bump. · 486a5037
      GCC Administrator authored
      486a5037
  3. Oct 26, 2022
    • David Malcolm's avatar
      analyzer: fixes to file-descriptor handling · 57bbf3a4
      David Malcolm authored
      
      gcc/analyzer/ChangeLog:
      	* sm-fd.cc (fd_state_machine::on_open): Transition to "unchecked"
      	when the mode is symbolic, rather than just on integer constants.
      	(fd_state_machine::check_for_open_fd): Don't complain about
      	unchecked values in the start state.
      
      gcc/testsuite/ChangeLog:
      	* gcc.dg/analyzer/fd-3.c (test_5): Expect "opened here" message
      	even when flags are symbolic.
      	(test_read_from_symbolic_fd): New.
      	(test_write_to_symbolic_fd): New.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      57bbf3a4
    • David Malcolm's avatar
      analyzer: add sm-fd.dot · 593254ae
      David Malcolm authored
      
      Add a .dot file to document the file descriptor state machine.
      
      gcc/analyzer/ChangeLog:
      	* sm-fd.dot: New file.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      593254ae
    • Harald Anlauf's avatar
      Fortran: BOZ literal constants are not compatible to any type [PR103413] · f7d28818
      Harald Anlauf authored
      gcc/fortran/ChangeLog:
      
      	PR fortran/103413
      	* symbol.cc (gfc_type_compatible): A boz-literal-constant has no type
      	and thus is not considered compatible to any type.
      
      gcc/testsuite/ChangeLog:
      
      	PR fortran/103413
      	* gfortran.dg/illegal_boz_arg_4.f90: New test.
      f7d28818
    • David Faust's avatar
      bpf: add preserve_field_info builtin · 068baae1
      David Faust authored
      Add BPF __builtin_preserve_field_info. This builtin is used to extract
      information to facilitate struct and union relocations performed by the
      BPF loader, especially for bitfields.
      
      The builtin has the following signature:
      
        unsigned int __builtin_preserve_field_info (EXPR, unsigned int KIND);
      
      Where EXPR is an expression accessing a field of a struct or union.
      Depending on KIND, different information is returned to the program. The
      supported values for KIND are as follows:
      
        enum {
          FIELD_BYTE_OFFSET = 0,
          FIELD_BYTE_SIZE,
          FIELD_EXISTENCE,
          FIELD_SIGNEDNESS,
          FIELD_LSHIFT_U64,
          FIELD_RSHIFT_U64
        };
      
      If -mco-re is in effect (explicitly or implicitly specified), a CO-RE
      relocation is added for the access in EXPR recording the relevant
      information according to KIND.
      
      gcc/
      
      	* config/bpf/bpf.cc: Support __builtin_preserve_field_info.
      	(enum bpf_builtins): Add new builtin.
      	(bpf_init_builtins): Likewise.
      	(bpf_core_field_info): New function.
      	(bpf_expand_builtin): Accomodate new builtin. Refactor adding new
      	relocation to...
      	(maybe_make_core_relo): ... here. New function.
      	(bpf_resolve_overloaded_builtin): Accomodate new builtin.
      	(bpf_core_newdecl): Likewise.
      	(bpf_core_walk): Likewise.
      	(bpf_core_is_maybe_aggregate_access): Improve logic.
      	(struct core_walk_data): New.
      	* config/bpf/coreout.cc (bpf_core_reloc_add): Allow adding different
      	relocation kinds.
      	* config/bpf/coreout.h: Analogous change.
      	* doc/extend.texi: Document BPF __builtin_preserve_field_info.
      
      gcc/testsuite/
      
      	* gcc.target/bpf/core-builtin-fieldinfo-errors-1.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-errors-2.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-existence-1.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-be.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-lshift-1-le.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-lshift-2.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-rshift-1.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-rshift-2.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-sign-1.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-sign-2.c: New test.
      	* gcc.target/bpf/core-builtin-fieldinfo-size-1.c: New test.
      068baae1
    • Marek Polacek's avatar
      c++: Implement -Wdangling-reference [PR106393] · d2249cd9
      Marek Polacek authored
      This patch implements a new experimental warning (enabled by -Wall) to
      detect references bound to temporaries whose lifetime has ended.  The
      primary motivation is the Note in
      <https://en.cppreference.com/w/cpp/algorithm/max>:
      
        Capturing the result of std::max by reference produces a dangling reference
        if one of the parameters is a temporary and that parameter is returned:
      
        int n = 1;
        const int& r = std::max(n-1, n+1); // r is dangling
      
      That's because both temporaries for n-1 and n+1 are destroyed at the end
      of the full expression.  With this warning enabled, you'll get:
      
      g.C:3:12: warning: possibly dangling reference to a temporary [-Wdangling-reference]
          3 | const int& r = std::max(n-1, n+1);
            |            ^
      g.C:3:24: note: the temporary was destroyed at the end of the full expression 'std::max<int>((n - 1), (n + 1))'
          3 | const int& r = std::max(n-1, n+1);
            |                ~~~~~~~~^~~~~~~~~~
      
      The warning works by checking if a reference is initialized with a function
      that returns a reference, and at least one parameter of the function is
      a reference that is bound to a temporary.  It assumes that such a function
      actually returns one of its arguments!  (I added code to check_return_expr
      to suppress the warning when we've seen the definition of the function
      and we can say that it can return a variable with static storage
      duration.)
      
      It warns when the function in question is a member function, but only if
      the function is invoked on a temporary object, otherwise the warning
      would emit loads of warnings for valid code like obj.emplace<T>({0}, 0).
      It does detect the dangling reference in:
      
        struct S {
          const S& self () { return *this; }
        };
        const S& s = S().self();
      
      It warns in member initializer lists as well:
      
        const int& f(const int& i) { return i; }
        struct S {
          const int &r;
          S() : r(f(10)) { }
        };
      
      I've run the testsuite/bootstrap with the warning enabled by default.
      There were just a few FAILs, all of which look like genuine bugs.
      A bootstrap with the warning enabled by default passed as well.
      
      When testing a previous version of the patch, there were many FAILs in
      libstdc++'s 22_locale/; all of them because the warning triggered on
      
        const test_type& obj = std::use_facet<test_type>(std::locale());
      
      but this code looks valid -- std::use_facet doesn't return a reference
      to its parameter.  Therefore I added a #pragma and code to suppress the
      warning.
      
      	PR c++/106393
      
      gcc/c-family/ChangeLog:
      
      	* c.opt (Wdangling-reference): New.
      
      gcc/cp/ChangeLog:
      
      	* call.cc (expr_represents_temporary_p): New, factored out of...
      	(conv_binds_ref_to_temporary): ...here.  Don't return false just
      	because a ck_base is missing.  Use expr_represents_temporary_p.
      	(do_warn_dangling_reference): New.
      	(maybe_warn_dangling_reference): New.
      	(extend_ref_init_temps): Call maybe_warn_dangling_reference.
      	* cp-tree.h: Adjust comment.
      	* typeck.cc (check_return_expr): Suppress -Wdangling-reference
      	warnings.
      
      gcc/ChangeLog:
      
      	* doc/invoke.texi: Document -Wdangling-reference.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/locale_classes.tcc: Add #pragma to disable
      	-Wdangling-reference with std::use_facet.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp23/elision4.C: Use -Wdangling-reference, add dg-warning.
      	* g++.dg/cpp23/elision7.C: Likewise.
      	* g++.dg/warn/Wdangling-pointer-2.C: Use -Wno-dangling-reference.
      	* g++.dg/warn/Wdangling-reference1.C: New test.
      	* g++.dg/warn/Wdangling-reference2.C: New test.
      	* g++.dg/warn/Wdangling-reference3.C: New test.
      d2249cd9
    • Takayuki 'January June' Suwa's avatar
      xtensa: Fix out-of-bounds array access in the movdi pattern · f896c134
      Takayuki 'January June' Suwa authored
      The following new warnings were introduced in the commit
      4f3f0296 ("xtensa: Prepare the transition from Reload to LRA"):
      
      gcc/config/xtensa/xtensa.md:945:26: error: array subscript 3 is above
      	array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
        945 |           emit_move_insn (operands[2], operands[3]);
      gcc/config/xtensa/xtensa.md:945:26: error: array subscript 2 is above
      	array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
        945 |           emit_move_insn (operands[2], operands[3]);
      
      From gcc/insn-emit.cc (generated by building):
      
      > /* ../../gcc/config/xtensa/xtensa.md:932 */
      > rtx
      > gen_movdi (rtx operand0,
      > 	rtx operand1)
      > {
      >   rtx_insn *_val = 0;
      >   start_sequence ();
      >   {
      >     rtx operands[2];					// only 2 elements
      >     operands[0] = operand0;
      >     operands[1] = operand1;
      > #define FAIL return (end_sequence (), _val)
      > #define DONE return (_val = get_insns (), end_sequence (), _val)
      > #line 936 "../../gcc/config/xtensa/xtensa.md"
      > {
      >   if (CONSTANT_P (operands[1]))
      >     {
      >       /* Split in halves if 64-bit Const-to-Reg moves
      > 	 because of offering further optimization opportunities.  */
      >       if (register_operand (operands[0], DImode))
      > 	{
      > 	  xtensa_split_DI_reg_imm (operands);		// out-of-bounds!
      > 	  emit_move_insn (operands[0], operands[1]);
      > 	  emit_move_insn (operands[2], operands[3]);	// out-of-bounds!
      > 	  DONE;
      > 	}
      
      gcc/ChangeLog:
      
      	* config/xtensa/xtensa.md (movdi):
      	Copy operands[0...1] to ops[0...3] and then use the latter before
      	calling xtensa_split_DI_reg_imm() and emitting insns.
      f896c134
    • Alexander Monakov's avatar
      ipa-visibility: remove assert in TLS optimization [PR107353] · 82e629c2
      Alexander Monakov authored
      When upgrading TLS access model based on optimized symbol visibility
      status, we attempted to assert that recomputing the model would not
      weaken it. It turns out that C, C++, and Fortran front-ends all can
      (unintentionally) assign a stronger model than what can be derived
      from the declaration.
      
      Let's act conservatively instead of asserting, at least as long as
      such pre-existing issues remain.
      
      gcc/ChangeLog:
      
      	PR other/107353
      	* ipa-visibility.cc (function_and_variable_visibility):
      	Conditionally upgrade TLS model instead of asserting.
      82e629c2
    • Andrew MacLeod's avatar
      Check if varying may also be non-negative. · a87819b8
      Andrew MacLeod authored
      When using strict enums, we can sometimes turn varying into a better
      range.
      
      	* gimple-range-fold.cc (fold_using_range::fold_stmt): Check if
      	stmt is non-negative and adjust the range.
      a87819b8
Loading