Skip to content
Snippets Groups Projects
  1. Oct 27, 2022
    • 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
  2. 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
    • Martin Liska's avatar
      i386: add reset_cpu_feature · d80b7744
      Martin Liska authored
      gcc/ChangeLog:
      
      	* common/config/i386/cpuinfo.h (has_cpu_feature): Add comment.
      	(reset_cpu_feature): New.
      	(get_zhaoxin_cpu): Use reset_cpu_feature.
      d80b7744
    • Ju-Zhe Zhong's avatar
      RISC-V: Fix epilogue generation for barrier. · 4329d111
      Ju-Zhe Zhong authored
       I noticed that I have made a mistake in previous patch:
       https://patchwork.sourceware.org/project/gcc/patch/20220817071950.271762-1-juzhe.zhong@rivai.ai/
      
       The previous statement before this patch:
       bool need_barrier_p = (get_frame_size () + cfun->machine->frame.arg_pointer_offset) != 0;
      
       However, I changed it in the previous patch:
       bool need_barrier_p = known_ne (get_frame_size (), cfun->machine->frame.arg_pointer_offset);
       This is incorrect.
      
       Now, I correct this statement in this patch.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv.cc (riscv_expand_epilogue): Fix statement.
      4329d111
    • Ju-Zhe Zhong's avatar
      RISC-V: ADJUST_NUNITS according to -march. · 7e924ba3
      Ju-Zhe Zhong authored
      This patch fixed PR107357: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107357
      
      gcc/ChangeLog:
      
      	PR target/107357
      	* config/riscv/riscv-modes.def (VECTOR_BOOL_MODE): Set to minimum size.
      	(ADJUST_NUNITS): Adjust according to -march.
      	(ADJUST_BYTESIZE): Ditto.
      	* config/riscv/riscv-protos.h (riscv_v_ext_enabled_vector_mode_p):
      	Remove.
      	(riscv_v_ext_vector_mode_p): Change function implementation.
      	* config/riscv/riscv-vector-builtins.cc (rvv_switcher::rvv_switcher):
      	Change to riscv_v_ext_vector_mode_p.
      	(register_builtin_type): Ditto.
      	* config/riscv/riscv.cc (riscv_v_ext_vector_mode_p): Change to enabled
      	modes.
      	(ENTRY): Ditto.
      	(riscv_v_ext_enabled_vector_mode_p): Remove.
      	(riscv_v_adjust_nunits): New function.
      	(riscv_vector_mode_supported_p): Use riscv_v_ext_vector_mode_p instead.
      	* config/riscv/riscv.h (riscv_v_adjust_nunits): New function.
      7e924ba3
    • Ju-Zhe Zhong's avatar
      RISC-V: Support load/store in mov<mode> pattern for RVV modes. · f556cd8b
      Ju-Zhe Zhong authored
      gcc/ChangeLog:
      
      	* config.gcc (riscv*): Add riscv-v.o to extra_objs.
      	* config/riscv/constraints.md (vu): New constraint.
      	(vi): Ditto.
      	(Wc0): Ditto.
      	(Wc1): Ditto.
      	* config/riscv/predicates.md (vector_length_operand): New.
      	(reg_or_mem_operand): Ditto.
      	(vector_move_operand): Ditto.
      	(vector_mask_operand): Ditto.
      	(vector_merge_operand): Ditto.
      	* config/riscv/riscv-protos.h (riscv_regmode_natural_size) New.
      	(riscv_vector::const_vec_all_same_in_range_p): Ditto.
      	(riscv_vector::legitimize_move): Ditto.
      	(tail_policy): Ditto.
      	(mask_policy): Ditto.
      	* config/riscv/riscv-v.cc: New.
      	* config/riscv/riscv-vector-builtins-bases.cc
      	(vsetvl::expand): Refactor how LMUL encoding.
      	* config/riscv/riscv.cc (riscv_print_operand): Update how LMUL
      	print and mask operand print.
      	(riscv_regmode_natural_size): New.
      	* config/riscv/riscv.h (REGMODE_NATURAL_SIZE): New.
      	* config/riscv/riscv.md (mode): Add vector modes.
      	* config/riscv/t-riscv (riscv-v.o) New.
      	* config/riscv/vector-iterators.md: New.
      	* config/riscv/vector.md (vundefined<mode>): New.
      	(mov<mode>): New.
      	(*mov<mode>): New.
      	(@vsetvl<mode>_no_side_effects): New.
      	(@pred_mov<mode>): New.
      
      gcc/testsuite/ChangeLog:
      	* gcc.target/riscv/rvv/base/mov-1.c: New.
      	* gcc.target/riscv/rvv/base/mov-10.c: New.
      	* gcc.target/riscv/rvv/base/mov-11.c: New.
      	* gcc.target/riscv/rvv/base/mov-12.c: New.
      	* gcc.target/riscv/rvv/base/mov-13.c: New.
      	* gcc.target/riscv/rvv/base/mov-2.c: New.
      	* gcc.target/riscv/rvv/base/mov-3.c: New.
      	* gcc.target/riscv/rvv/base/mov-4.c: New.
      	* gcc.target/riscv/rvv/base/mov-5.c: New.
      	* gcc.target/riscv/rvv/base/mov-6.c: New.
      	* gcc.target/riscv/rvv/base/mov-7.c: New.
      	* gcc.target/riscv/rvv/base/mov-8.c: New.
      	* gcc.target/riscv/rvv/base/mov-9.c: New.
      f556cd8b
    • Monk Chiang's avatar
      RISC-V: Recognized Svinval and Svnapot extensions · 86654b2c
      Monk Chiang authored
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
      	Add svinval and svnapot extension.
      	(riscv_ext_flag_table): Ditto.
      	* config/riscv/riscv-opts.h (MASK_SVINVAL): New.
      	(MASK_SVNAPOT): Ditto.
      	(TARGET_SVINVAL): Ditto.
      	(TARGET_SVNAPOT): Ditto.
      	* config/riscv/riscv.opt (riscv_sv_subext): New.
      
      gcc/testsuite/ChangeLog:
      	* gcc.target/riscv/predef-24.c:New.
      	* gcc.target/riscv/predef-25.c:New.
      86654b2c
    • Ju-Zhe Zhong's avatar
      RISC-V: Adjust table indentation in commnet for riscv-modes.def · 0ef04aa8
      Ju-Zhe Zhong authored
      gcc/ChangeLog:
      
      	* config/riscv/riscv-modes.def: Adjust table indentation in commnet.
      0ef04aa8
    • Martin Liska's avatar
      gcc/configure: regenerate · ba2030b0
      Martin Liska authored
      gcc/ChangeLog:
      
      	* configure: Regenerate.
      ba2030b0
    • Aldy Hernandez's avatar
      Convert flag_finite_math_only uses in frange to HONOR_*. · 82866f43
      Aldy Hernandez authored
      As mentioned earlier, we should be using HONOR_* on types rather than
      flag_finite_math_only.
      
      gcc/ChangeLog:
      
      	* value-range.cc (frange::set): Use HONOR_*.
      	(frange::verify_range): Same.
      	* value-range.h (frange_val_min): Same.
      	(frange_val_max): Same.
      82866f43
    • Jiufu Guo's avatar
      rs6000: cannot_force_const_mem for HIGH code rtx[PR106460] · 978ec482
      Jiufu Guo authored
      As the issue in PR106460, a rtx 'high:DI (symbol_ref:DI ("var_48")' is tried
      to store into constant pool and ICE occur.  But actually, this rtx represents
      partial incomplete address and can not be put into a .rodata section.
      
      This patch updates rs6000_cannot_force_const_mem to return true for rtx(s) with
      HIGH code, because these rtx(s) indicate part of address and are not ok for
      constant pool.
      
      Below are some examples:
      (high:DI (const:DI (plus:DI (symbol_ref:DI ("xx") (const_int 12 [0xc])))))
      (high:DI (symbol_ref:DI ("var_1")..)))
      
      	PR target/106460
      
      gcc/ChangeLog:
      
      	* config/rs6000/rs6000.cc (rs6000_cannot_force_const_mem): Return true
      	for HIGH code rtx.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/powerpc/pr106460.c: New test.
      978ec482
    • Kito Cheng's avatar
      RISC-V: Add h extension support · 0cd11d30
      Kito Cheng authored
      `h` was the prefix of multi-letter extension name, but it become a
      extension in later RISC-V isa spec.
      
      Fortunately we don't have any extension really defined is prefixed
      with `h`, so we can just change that.
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
      	Add `h`.
      	(riscv_supported_std_ext): Ditto.
      	(multi_letter_subset_rank): Remove `h`.
      	(riscv_subset_list::parse_std_ext): Handle `h` as single letter
      	extension.
      	(riscv_subset_list::parse): Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/arch-18.c: New.
      	* gcc.target/riscv/arch-5.c: Remove test for prefixed
      	with `h`.
      	* gcc.target/riscv/predef-23.c: New.
      0cd11d30
    • Eugene Rozenfeld's avatar
      Don't force DWARF4 for AutoFDO tests · a9f339d8
      Eugene Rozenfeld authored
      Support for DWARF5 was added to create_gcov in
      https://github.com/google/autofdo so we no longer need
      to force DWARF4 for AutoFDO tests.
      
      Tested on x86_64-pc-linux-gnu.
      
      gcc/testsuite/ChangeLog:
      	* lib/profopt.exp: Don't force DWARF4 for AutoFDO tests
      a9f339d8
    • GCC Administrator's avatar
      Daily bump. · e73ca788
      GCC Administrator authored
      e73ca788
  3. Oct 25, 2022
    • Eugene Rozenfeld's avatar
      Start using discriminators in AutoFDO. · 65f5fa23
      Eugene Rozenfeld authored
      Tested on x86_64-pc-linux-gnu.
      
      gcc/ChangeLog:
      
      	* auto-profile.cc (get_combined_location): Include discriminator in the
      	returned combined location.
      	(read_function_instance): Read discriminators from profiles.
      65f5fa23
    • Nathan Sidwell's avatar
      c++: Adjust synthetic template parm creation · 43e654af
      Nathan Sidwell authored
      We intend to mark synthetic template parameters (coming from use of auto
      parms), as DECL_VIRTUAL_P.  The API of process_template_parm is
      awkwardly confusing, and we were marking the previous template parm
      (unless this was the first parm).  process_template_parm returns the list
      of parms, when most (all?) users really want the newly-added final node.
      That's a bigger change, so let's not do it right now.  With this, we
      correctly mark such synthetic parms DECL_VIRTUAL_P.
      
      	gcc/cp/
      	* parser.cc (synthesize_implicit_template_parm): Fix thinko about
      	mark the new parm DECL_VIRTUAL_P.  Avoid unneccessary tree_last call.
      43e654af
    • Patrick Palka's avatar
      c++: remove use_default_args parm of coerce_template_parms · fe1e1ae0
      Patrick Palka authored
      The parameter use_default_args of coerce_template_parms, introduced way
      back in r110693, is effectively unused ever since r7-5536-g3c75aaa3d884ef
      removed the last 'coerce_template_parms (..., true, false)' call.  So
      this patch aims to simplify this function's API by getting rid of this
      parameter.
      
      In passing, I noticed we currently define wrapper overloads of
      coerce_template_parms that act as defacto default arguments for complain
      and require_all_args.  It seems cleaner however to just specify real
      default arguments for the main overload instead.  And I suppose we
      should also give c_innermost_t_p the same defaults.
      
      But I'm not sure about defaulting complain to tf_none, which is
      inconsistent with how we default it in other places to either tf_error
      or tf_warning_or_error (as a convenience for non-SFINAE callers).  And
      since in general it's probably better to not default complain as that's
      a source of SFINAE bugs, and only a handful of callers use this defacto
      complain=tf_none default, this patch gets rid of this complain default
      (but keeps the require_all_args default).
      
      gcc/cp/ChangeLog:
      
      	* constraint.cc (resolve_function_concept_overload): Explicitly
      	pass complain=tf_none to coerce_template_parms.
      	(resolve_concept_check): Likewise.
      	(normalize_concept_check): Likewise.
      	* cp-tree.h (coerce_template_parms): Declare the main overload
      	and default its last parameter to true.  Remove wrapper overloads.
      	* pt.cc (determine_specialization): Adjust calls to
      	coerce_template_parms and coerce_innermost_template_parms after
      	removing their last parameter.
      	(coerce_template_args_for_ttp): Likewise.
      	(coerce_ttp_args_for_tta): Likewise.
      	(coerce_template_template_parms): Likewise.
      	(coerce_template_parms): Remove use_default_args parameter and
      	adjust function comment.  Document default argument.  Remove
      	wrapper overloads.  No longer static.
      	(coerce_innermost_template_parms): Remove use_default_args
      	parameter.  Default require_all_args to true.
      	(lookup_template_class): As with determine_specialization.
      	(finish_template_variable): Likewise.
      	(tsubst_decl): Likewise.
      	(instantiate_alias_template): Likewise.
      	(fn_type_unification): Likewise.
      	(resolve_overloaded_unification): Likewise.
      	(resolve_nondeduced_context): Likewise.
      	(get_partial_spec_bindings): Likewise.
      fe1e1ae0
    • Jason Merrill's avatar
      c++: correct fold_operand change · 4a54873d
      Jason Merrill authored
      Still want the conversion to bool.
      
      gcc/cp/ChangeLog:
      
      	* constexpr.cc (find_failing_clause_r): Re-add the call to
      	contextual_conv_bool.
      4a54873d
    • Patrick Palka's avatar
      c++ modules: enum TYPE_MIN/MAX_VALUE streaming [PR106848] · 15d67c11
      Patrick Palka authored
      In the frontend, the TYPE_MIN/MAX_VALUE of ENUMERAL_TYPE is the same as
      that of the enum's underlying type (see start_enum).  And the underlying
      type of an enum is always known, even for an opaque enum that lacks a
      definition.
      
      But currently, we stream TYPE_MIN/MAX_VALUE of an enum only as part of
      its definition.  So if the enum is declared but never defined, the
      ENUMERAL_TYPE we stream in will have empty TYPE_MIN/MAX_VALUE fields
      despite these fields being non-empty on stream out.
      
      And even if the enum is defined, read_enum_def updates these fields only
      on the main variant of the enum type, so for other variants (that we may
      have streamed in earlier) these fields remain empty.  That these fields
      are unexpectedly empty for some ENUMERAL_TYPEs is ultimately the cause
      of the below two PRs.
      
      This patch fixes this by making us stream TYPE_MIN/MAX_VALUE directly
      for each ENUMERAL_TYPE rather than as part of the enum's definition, so
      that we naturally also stream these fields for opaque enums (and each
      enum type variant).
      
      	PR c++/106848
      	PR c++/102600
      
      gcc/cp/ChangeLog:
      
      	* module.cc (trees_out::core_vals): Stream TYPE_MAX_VALUE and
      	TYPE_MIN_VALUE of ENUMERAL_TYPE.
      	(trees_in::core_vals): Likewise.
      	(trees_out::write_enum_def): Don't stream them here.
      	(trees_in::read_enum_def): Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/modules/enum-9_a.H: New test.
      	* g++.dg/modules/enum-9_b.C: New test.
      	* g++.dg/modules/enum-10_a.H: New test.
      	* g++.dg/modules/enum-10_b.C: New test.
      	* g++.dg/modules/enum-11_a.H: New test.
      	* g++.dg/modules/enum-11_b.C: New test.
      15d67c11
    • H.J. Lu's avatar
      Always use TYPE_MODE instead of DECL_MODE for vector field · 1c64aba8
      H.J. Lu authored
      e034c5c8 re PR target/78643 (ICE in convert_move, at expr.c:230)
      
      fixed the case where DECL_MODE of a vector field is BLKmode and its
      TYPE_MODE is a vector mode because of target attribute.  Remove the
      BLKmode check for the case where DECL_MODE of a vector field is a vector
      mode and its TYPE_MODE isn't a vector mode because of target attribute.
      
      gcc/
      
      	PR target/107304
      	* expr.cc (get_inner_reference): Always use TYPE_MODE for vector
      	field with vector raw mode.
      
      gcc/testsuite/
      
      	PR target/107304
      	* gcc.target/i386/pr107304.c: New test.
      1c64aba8
    • Jason Merrill's avatar
      c++: constexpr-evaluate more assumes · e6a29aab
      Jason Merrill authored
      The initial [[assume]] support avoided evaluating assumes with
      TREE_SIDE_EFFECTS set, such as calls, because we don't want any side-effects
      that change the constexpr state.  This patch allows us to evaluate
      expressions with that flag set by tracking which variables the evaluation is
      allowed to modify, and giving up if it tries to touch any others.
      
      I considered allowing changes to other variables and then rolling them back,
      but that seems like a rare enough situation that it doesn't seem worth
      working to handle nicely at this point.
      
      gcc/cp/ChangeLog:
      
      	* constexpr.cc (class constexpr_global_ctx): Add modifiable field,
      	get_value, get_value_ptr, put_value, remove_value, flush_modifiable
      	member functions.
      	(class modifiable_tracker): New.
      	(cxx_eval_internal_function): Use it.
      	(diagnose_failing_condition): Strip CLEANUP_POINT_EXPR.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp23/attr-assume9.C: New test.
      	* g++.dg/cpp23/attr-assume10.C: New test.
      e6a29aab
    • Jason Merrill's avatar
      c++: improve failed constexpr assume diagnostic · ac8f92c1
      Jason Merrill authored
      I noticed that we were printing "the comparison reduces to (x == 42)" when
      we should be able to give the value of x.  Fixed by doing the same
      evaluation in diagnose_failing_condition that we already do in
      find_failing_clause.
      
      gcc/cp/ChangeLog:
      
      	* constexpr.cc (fold_operand): New function.
      	(find_failing_clause_r): Add const.
      	(find_failing_clause): Add const.
      	(diagnose_failing_condition): Add ctx parameter.
      	(cxx_eval_internal_function): Pass it.
      	* semantics.cc (diagnose_failing_condition): Move to constexpr.cc.
      	* cp-tree.h: Adjust.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp23/attr-assume2.C: Expect constant values.
      ac8f92c1
    • Segher Boessenkool's avatar
      rs6000: Add CCANY; replace <un>signed by <mode:CCANY> · 4ba3902e
      Segher Boessenkool authored
      This is in preparation for adding CCFP, and maybe CCEQ, and whatever
      other CC mode we may want later.  CCANY is used for CC mode consumers
      that actually can take any of the four CR field bits.
      
      2022-10-25  Segher Boessenkool  <segher@kernel.crashing.org>
      
      	* config/rs6000/rs6000.md (CCEITHER): Delete.
      	(CCANY): New.
      	(un): Delete.
      	(isel_<un>signed_<GPR:mode>): Rename to...
      	(isel_<CCANY:mode>_<GPR:mode>): ... this.  Adjust.
      	(*isel_reversed_<un>signed_<GPR:mode>): Rename to...
      	(*isel_reversed_<CCANY:mode>_<GPR:mode>): ... this.  Adjust.
      	(setbc_<un>signed_<GPR:mode>): Rename to...
      	(setbc_<CCANY:mode>_<GPR:mode>C): ... this.  Adjust."
      	(*setbcr_<un>signed_<GPR:mode>): Rename to ...
      	(*setbcr_<CCANY:mode>_<GPR:mode>): ... this.  Adjust.
      	(*setnbc_<un>signed_<GPR:mode>): Rename to ...
      	(*setnbc_<CCANY:mode>_<GPR:mode>): ... this.  Adjust.
      	(*setnbcr_<un>signed_<GPR:mode>): Rename to ...
      	(*setnbcr_<CCANY:mode>_<GPR:mode>): ... this.  Adjust.
      	(eq<mode>3 for GPR): Adjust.
      	(ne<mode>3 for GPR): Adjust.
      	* config/rs6000/rs6000-string.cc (do_isel): Adjust.
      	* config/rs6000/rs6000.cc (rs6000_emit_int_cmove): Adjust.
      4ba3902e
    • Richard Biener's avatar
      tree-optimization/107176 - SCEV analysis association issue · 4c5b1160
      Richard Biener authored
      The following fixes a wrong-code issue caused by SCEV analysis
      associating an addition due trying to use tail-recursion in
      follow_ssa_edge_expr.  That causes us to apply a conversion at
      the wrong point and thus miscompute the scalar evolution of
      an induction variable.  This reverts the PR66375 fix and
      revisits the PR42512 fix by keeping the evolution symbolic
      up to the point we process the first linear function when
      we then can check for the supported cases and substitute the
      whole symbolic expression with the built chrec substituting
      the proper initial value.
      
      To simplify passing around things and to clarify scoping of
      the involved functions this change wraps the SCEV DFS walking
      code into a class.
      
      	PR tree-optimization/107176
      	PR tree-optimization/66375
      	PR tree-optimization/42512
      	* tree-scalar-evolution.cc (follow_ssa_edge_expr): Revert
      	the PR66375 fix, do not not associate PLUS_EXPR to be able
      	to use tail-recursion.
      	(follow_ssa_edge_binary): Likewise.
      	(interpret_loop_phi): Revert PR42512 fix, do not throw
      	away analyze_evolution_in_loop result after the fact.
      	(follow_ssa_edge_expr): When reaching halting_phi initalize
      	the evolution to the symbolic value of the PHI result.
      	(add_to_evolution_1): When adding the first evolution verify
      	we can handle the expression wrapping the symbolic evolution
      	and replace that in full using the initial condition.
      	(class scev_dfs): New, contains ...
      	(follow_ssa_edge_expr, follow_ssa_edge_binary,
      	follow_ssa_edge_in_condition_phi_branch,
      	follow_ssa_edge_in_condition_phi,
      	follow_ssa_edge_inner_loop_phi,
      	add_to_evolution, add_to_evolution_1): ... these with
      	loop and halting_phi arguments in class data.
      	(scev_dfs::get_ev): New toplevel DFS entry, start with
      	a chrec_dont_know evolution.
      	(analyze_evolution_in_loop): Use scev_dfs.
      
      	* gcc.dg/torture/pr107176.c: New testcase.
      4c5b1160
    • Eric Botcazou's avatar
      Relax assertion in profiler · cb21297f
      Eric Botcazou authored
      This assertion in branch_prob:
      
        if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
          {
            location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
            gcc_checking_assert (!RESERVED_LOCATION_P (loc));
      
      had been correct until the fix for PR debug/101598 was installed.
      
      gcc/
      	* profile.cc (branch_prob): Be prepared for ignored functions with
      	DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.
      
      gcc/testsuite:
      	* gnat.dg/specs/coverage1.ads: New test.
      	* gnat.dg/specs/variant_part.ads: Minor tweak.
      	* gnat.dg/specs/weak1.ads: Add dg directive.
      cb21297f
    • Richard Biener's avatar
      Move NOP stripping in SCEV analysis · 3ee67572
      Richard Biener authored
      The following moves a pair of STRIP_USELESS_TYPE_CONVERSIONS to
      where it belongs and adds a comment on why we handle GENERIC
      there at all.
      
      	* tree-scalar-evolution.cc (follow_ssa_edge_expr): Move
      	STRIP_USELESS_TYPE_CONVERSIONS to where it matters.
      3ee67572
    • Tejas Joshi's avatar
      Remove znver4 instruction reservations · d9317150
      Tejas Joshi authored
      This reverts the changes made to znver.md in:
      commit bf3b532b
      
      2022-10-21  Tejas Joshi <TejasSanjay.Joshi@amd.com>
      
      gcc/ChangeLog:
      
      	* common/config/i386/i386-common.cc (processor_alias_table): Use
      	CPU_ZNVER3 for znver4.
      	* config/i386/znver.md: Remove znver4 reservations.
      d9317150
    • Jakub Jelinek's avatar
      gimplify: Fix comment typos · 619e4ca9
      Jakub Jelinek authored
      While looking at gimple_boolify for PR107368, I've noticed 2 comment
      typos.
      
      2022-10-25  Jakub Jelinek  <jakub@redhat.com>
      
      	* gimplify.cc (gimple_boolify): Fix comment typos, prduce -> produce
      	and There -> These.
      619e4ca9
    • Jakub Jelinek's avatar
      gimplify: Call gimple_boolify on IFN_ASSUME argument [PR107368] · 44e18da4
      Jakub Jelinek authored
      The following testcase ICEs in C, because assume attribute condition
      has int type rather than bool and the gimplification into GIMPLE_ASSUME
      assigns it into a bool variable.
      
      Fixed by calling gimple_boolify.
      
      2022-10-25  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/107368
      	* gimplify.cc (gimplify_call_expr): For complex IFN_ASSUME
      	conditions call gimple_boolify on the condition.
      
      	* gcc.dg/attr-assume-5.c: New test.
      44e18da4
    • YunQiang Su's avatar
      MIPS: add builtime option for -mcompact-branches · 59363205
      YunQiang Su authored
      For R6+ target, it allows to configure gcc to use compact branches only
      if avaiable.
      
      gcc/ChangeLog:
      	* config.gcc: add -with-compact-branches=policy build option.
      	* doc/install.texi: Likewise.
      	* config/mips/mips.h: Likewise.
      59363205
    • YunQiang Su's avatar
      MIPS: Not trigger error for pre-R6 and -mcompact-branches=always · 4479f1dc
      YunQiang Su authored
      For MIPSr6, we may wish to use compact-branches only.
      Currently, we have to use `always' option, while it is mark as conflict
      with pre-R6.
        cc1: error: unsupported combination: ‘mips32r2’ -mcompact-branches=always
      Just ignore -mcompact-branches=always for pre-R6.
      
      This patch also defines
          __mips_compact_branches_never
          __mips_compact_branches_always
          __mips_compact_branches_optimal
      predefined macros
      
      gcc/ChangeLog:
      	* config/mips/mips.cc (mips_option_override): not trigger error
      	for compact-branches=always for pre-R6.
      	* config/mips/mips.h (TARGET_RTP_PIC): not trigger error for
      	compact-branches=always for pre-R6.
      	(TARGET_CB_NEVER): Likewise.
      	(TARGET_CB_ALWAYS): Likewise.
      	(struct mips_cpu_info): define macros for compact branch policy.
      	* doc/invoke.texi: Document "always" with pre-R6.
      
      gcc/testsuite/ChangeLog:
      	* gcc.target/mips/compact-branches-1.c: add isa_rev>=6.
      	* gcc.target/mips/mips.exp: don't add -mipsXXr6 option for
      	-mcompact-branches=always. It is usable for pre-R6 now.
      	* gcc.target/mips/compact-branches-8.c: New test.
      	* gcc.target/mips/compact-branches-9.c: New test.
      4479f1dc
    • Jakub Jelinek's avatar
      gimplify: Don't add GIMPLE_ASSUME if errors were seen [PR107369] · 7d888535
      Jakub Jelinek authored
      The FEs emit errors about jumps into assume attribute conditions,
      but when we add GIMPLE_ASSUME for the condition which is reachable
      through those jumps, we can run into cfg verification diagnostics.
      
      Fixed by throwing the IFN_ASSUME away during gimplification if
      seen_error () - like we already do for -O0.  GIMPLE_ASSUME in the middle-end
      is a pure optimization thing and if errors were reported, the optimizations
      will not be beneficial for anything.
      
      2022-10-25  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/107369
      	* gimplify.cc (gimplify_call_expr): If seen_error, handle complex
      	IFN_ASSUME the same as for -O0.
      
      	* gcc.dg/attr-assume-4.c: New test.
      	* g++.dg/cpp23/attr-assume8.C: New test.
      7d888535
Loading