Skip to content
Snippets Groups Projects
  1. Jan 06, 2024
  2. Jan 05, 2024
    • Gaius Mulley's avatar
      modula2: libm2iso/RTco.cc tidyup use bool instead of int · bae3b791
      Gaius Mulley authored
      
      A missing bool/int detected in the global variable initialized.
      The majority of ints were replaced by bool but this one was missed.
      
      libgm2/ChangeLog:
      
      	* libm2iso/RTco.cc (initialized): Use bool instead of int.
      
      Signed-off-by: default avatarGaius Mulley <gaiusmod2@gmail.com>
      bae3b791
    • Richard Sandiford's avatar
      aarch64: Extend VECT_COMPARE_COSTS to !SVE [PR113104] · 7328faf8
      Richard Sandiford authored
      When SVE is enabled, we try vectorising with multiple different SVE and
      Advanced SIMD approaches and use the cost model to pick the best one.
      Until now, we've not done that for Advanced SIMD, since "the first mode
      that works should always be the best".
      
      The testcase is a counterexample.  Each iteration of the scalar loop
      vectorises naturally with 64-bit input vectors and 128-bit output
      vectors.  We do try that for SVE, and choose it as the best approach.
      But the first approach we try is instead to use:
      
      - a vectorisation factor of 2
      - 1 128-bit vector for the inputs
      - 2 128-bit vectors for the outputs
      
      But since the stride is variable, the cost of marshalling the input
      vector from two iterations outweighs the benefit of doing two iterations
      at once.
      
      This patch therefore generalises aarch64-sve-compare-costs to
      aarch64-vect-compare-costs and applies it to non-SVE compilations.
      
      gcc/
      	PR target/113104
      	* doc/invoke.texi (aarch64-sve-compare-costs): Replace with...
      	(aarch64-vect-compare-costs): ...this.
      	* config/aarch64/aarch64.opt (-param=aarch64-sve-compare-costs=):
      	Replace with...
      	(-param=aarch64-vect-compare-costs=): ...this new param.
      	* config/aarch64/aarch64.cc (aarch64_override_options_internal):
      	Don't disable it when vectorizing for Advanced SIMD only.
      	(aarch64_autovectorize_vector_modes): Apply VECT_COMPARE_COSTS
      	whenever aarch64_vect_compare_costs is true.
      
      gcc/testsuite/
      	PR target/113104
      	* gcc.target/aarch64/pr113104.c: New test.
      	* gcc.target/aarch64/sve/cond_arith_1.c: Update for new parameter
      	names.
      	* gcc.target/aarch64/sve/cond_arith_1_run.c: Likewise.
      	* gcc.target/aarch64/sve/cond_arith_3.c: Likewise.
      	* gcc.target/aarch64/sve/cond_arith_3_run.c: Likewise.
      	* gcc.target/aarch64/sve/gather_load_6.c: Likewise.
      	* gcc.target/aarch64/sve/gather_load_7.c: Likewise.
      	* gcc.target/aarch64/sve/load_const_offset_2.c: Likewise.
      	* gcc.target/aarch64/sve/load_const_offset_3.c: Likewise.
      	* gcc.target/aarch64/sve/mask_gather_load_6.c: Likewise.
      	* gcc.target/aarch64/sve/mask_gather_load_7.c: Likewise.
      	* gcc.target/aarch64/sve/mask_load_slp_1.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_load_1.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_load_2.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_load_3.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_load_4.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_store_1.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_store_1_run.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_store_2.c: Likewise.
      	* gcc.target/aarch64/sve/mask_struct_store_2_run.c: Likewise.
      	* gcc.target/aarch64/sve/pack_1.c: Likewise.
      	* gcc.target/aarch64/sve/reduc_4.c: Likewise.
      	* gcc.target/aarch64/sve/scatter_store_6.c: Likewise.
      	* gcc.target/aarch64/sve/scatter_store_7.c: Likewise.
      	* gcc.target/aarch64/sve/strided_load_3.c: Likewise.
      	* gcc.target/aarch64/sve/strided_store_3.c: Likewise.
      	* gcc.target/aarch64/sve/unpack_fcvt_signed_1.c: Likewise.
      	* gcc.target/aarch64/sve/unpack_fcvt_unsigned_1.c: Likewise.
      	* gcc.target/aarch64/sve/unpack_signed_1.c: Likewise.
      	* gcc.target/aarch64/sve/unpack_unsigned_1.c: Likewise.
      	* gcc.target/aarch64/sve/unpack_unsigned_1_run.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_11.c: Likewise.
      	* gcc.target/aarch64/sve/vcond_11_run.c: Likewise.
      7328faf8
    • Jonathan Wakely's avatar
      libstdc++: Avoid overflow when appending to std::filesystem::path · d4cd871d
      Jonathan Wakely authored
      This prevents a std::filesystem::path from exceeding INT_MAX/4
      components (which is unlikely to ever be a problem except on 16-bit
      targets). That limit ensures that the capacity*1.5 calculation doesn't
      overflow. We should also check that we don't exceed SIZE_MAX when
      calculating how many bytes to allocate. That only needs to be checked
      when int is at least as large as size_t, because otherwise we know that
      the product INT_MAX/4 * sizeof(value_type) will fit in SIZE_MAX. For
      targets where size_t is twice as wide as int this obviously holds. For
      msp430-elf we have 16-bit int and 20-bit size_t, so the condition holds
      as long as sizeof(value_type) fits in 7 bits, which it does.
      
      We can also remove some floating-point arithmetic in operator/= which
      ensures exponential growth of the buffer. That's redundant because
      path::_List::reserve does that anyway (and does so more efficiently
      since the commit immediately before this one).
      
      libstdc++-v3/ChangeLog:
      
      	* src/c++17/fs_path.cc (path::_List::reserve): Limit maximum
      	size and check for overflows in arithmetic.
      	(path::operator/=(const path&)): Remove redundant exponential
      	growth calculation.
      d4cd871d
    • Martin Küttler's avatar
      libstdc++: Remove unneeded double operation in src/c++17/fs_path.cc · a3fee5ef
      Martin Küttler authored
      libstdc++-v3/ChangeLog:
      
      	* src/c++17/fs_path.cc (path::_List::reserve): Avoid
      	floating-point arithmetic.
      a3fee5ef
    • Jonathan Wakely's avatar
      libstdc++: Do not use __is_convertible unconditionally [PR113241] · 57fa5b60
      Jonathan Wakely authored
      The new __is_convertible built-in should only be used after checking
      that it's supported.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/113241
      	* include/std/type_traits (is_convertible_v): Guard use of
      	built-in with preprocessor check.
      57fa5b60
    • Jonathan Wakely's avatar
      contrib: Remove C-style comments from Python files · 29abd09a
      Jonathan Wakely authored
      These Python scripts have "*/" at the end of the license header comment
      blocks, presumably copy&pasted from C files.
      
      contrib/ChangeLog:
      
      	* analyze_brprob.py: Remove stray text at end of comment.
      	* analyze_brprob_spec.py: Likewise.
      	* check-params-in-docs.py: Likewise.
      	* check_GNU_style.py: Likewise.
      	* check_GNU_style_lib.py: Likewise.
      	* filter-clang-warnings.py: Likewise.
      	* gcc-changelog/git_check_commit.py: Likewise.
      	* gcc-changelog/git_commit.py: Likewise.
      	* gcc-changelog/git_email.py: Likewise.
      	* gcc-changelog/git_repository.py: Likewise.
      	* gcc-changelog/git_update_version.py: Likewise.
      	* gcc-changelog/test_email.py: Likewise.
      	* gen_autofdo_event.py: Likewise.
      	* mark_spam.py: Likewise.
      	* unicode/gen-box-drawing-chars.py: Likewise.
      	* unicode/gen-combining-chars.py: Likewise.
      	* unicode/gen-printable-chars.py: Likewise.
      	* unicode/gen_wcwidth.py: Likewise.
      29abd09a
    • Jonathan Wakely's avatar
      contrib: Add script name to usage error in gen_wcwidth.py · 1bc9eddb
      Jonathan Wakely authored
      contrib/ChangeLog:
      
      	* unicode/gen_wcwidth.py: Add sys.argv[0] to usage error.
      1bc9eddb
    • Lulu Cheng's avatar
      LoongArch: Fixed the problem of incorrect judgment of the immediate field of... · 03c7df97
      Lulu Cheng authored
      LoongArch: Fixed the problem of incorrect judgment of the immediate field of the [x]vld/[x]vst instruction.
      
      The [x]vld/[x]vst directive is defined as follows:
        [x]vld/[x]vst {x/v}d, rj, si12
      
      When not modified, the immediate field of [x]vld/[x]vst is between 10 and
      14 bits depending on the type. However, in loongarch_valid_offset_p, the
      immediate field is restricted first, so there is no error. However, in
      some cases redundant instructions will be generated, see test cases.
      Now modify it according to the description in the instruction manual.
      
      gcc/ChangeLog:
      
      	* config/loongarch/lasx.md (lasx_mxld_<lasxfmt_f>):
      	Modify the method of determining the memory offset of [x]vld/[x]vst.
      	(lasx_mxst_<lasxfmt_f>): Likewise.
      	* config/loongarch/loongarch.cc (loongarch_valid_offset_p): Delete.
      	(loongarch_address_insns): Likewise.
      	* config/loongarch/lsx.md (lsx_ld_<lsxfmt_f>): Likewise.
      	(lsx_st_<lsxfmt_f>): Likewise.
      	* config/loongarch/predicates.md (aq10b_operand): Likewise.
      	(aq10h_operand): Likewise.
      	(aq10w_operand): Likewise.
      	(aq10d_operand): Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/loongarch/vect-ld-st-imm12.c: New test.
      03c7df97
    • chenxiaolong's avatar
      LoongArch: testsuite:Give up the detection of the gcc.dg/fma-{3, 4, 6, 7}.c file. · f8e4412b
      chenxiaolong authored
      On the LoongArch architecture, the above four test cases need to be waived
      during testing. There are two situations:
      
      1. The function of fma-{3,6}.c test is to find the value of c-a*b, but on
      the LoongArch architecture, the function of the existing fnmsub instruction
      is to find the value of -(a*b - c);
      
      2. The function of fma-{4,7}.c test is to find the value of -(a*b)-c, but on
      the LoongArch architecture, the function of the existing fnmadd instruction
      is to find the value of -(a*b + c);
      
      Through the analysis of the above two cases, there will be positive and
      negative zero inequality.
      
      gcc/testsuite/ChangeLog
      
      	* gcc.dg/fma-3.c: The intermediate file corresponding to the
      	function does not produce the corresponding FNMA symbol, so the test
      	rules should be skipped when testing.
      	* gcc.dg/fma-4.c: The intermediate file corresponding to the
      	function does not produce the corresponding FNMS symbol, so skip the
      	test rules when testing.
      	* gcc.dg/fma-6.c: The cause is the same as fma-3.c.
      	* gcc.dg/fma-7.c: The cause is the same as fma-4.c
      f8e4412b
    • chenxiaolong's avatar
      LoongArch: testsuite:Added additional vectorization "-mlasx" compilation option. · b2de0b84
      chenxiaolong authored
      In the LoongArch architecture, the reason for not adding the 128-bit
      vector-width-*hi* instruction template in the GCC back end is that it causes
      program performance loss, so we can only add the "-mlasx" compilation option
      to use 256-bit vectorization functions in test files.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/vect/bb-slp-pattern-1.c: If you are testing on the
      	LoongArch architecture, you need to add the "-mlasx" compilation
      	option to generate vectorized code.
      	* gcc.dg/vect/slp-widen-mult-half.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-const-s16.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-const-u16.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-half-u8.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-half.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-u16.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-u8-s16-s32.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-u8-u32.c: Dito.
      	* gcc.dg/vect/vect-widen-mult-u8.c: Dito.
      b2de0b84
    • chenxiaolong's avatar
      LoongArch: testsuite:Delete the default run behavior in pr60510.f. · 70069fd2
      chenxiaolong authored
      When binutils does not support vector instruction sets, the test program fails
      because it does not recognize vectorization at the assembly stage. Therefore,
      the default run behavior of the program is deleted, so that the behavior of
      the program depends on whether the software supports vectorization.
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/vect/pr60510.f: Delete the default behavior of the
      	program.
      70069fd2
    • chenxiaolong's avatar
      LoongArch: testsuite:Fix FAIL in file bind_c_array_params_2.f90. · 4ae1ab1f
      chenxiaolong authored
      On the LoongArch architecture, an error was found in the
      bind_c_array_params_2.f90 file because there was no proper assembly code
      for the regular expression detection function call, such as bl %plt(myBindC).
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/bind_c_array_params_2.f90: Add code test rules to
      	support testing of the loongArch architecture.
      4ae1ab1f
    • chenxiaolong's avatar
      LoongArch: testsuite:Added detection support for LoongArch architecture in vect-{82, 83}.c. · 12ad10af
      chenxiaolong authored
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/vect/vect-82.c: Add the LoongArch architecture to the
      	object detection framework.
      	* gcc.dg/vect/vect-83.c: Dito.
      12ad10af
    • chenxiaolong's avatar
      LoongArch: testsuite:Modify the test behavior of the vect-bic-bitmask-{12, 23}.c file. · 0eba9cae
      chenxiaolong authored
      Before modifying the test behavior of the program, dg-do is set to assemble in
      vect-bic-bitmask-{12,23}.c. However, when the binutils library does not support
      the vector instruction set, it will FAIL to recognize the vector instruction
      and fail item will appear in the assembly stage. So set the program's dg-do to
      compile.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/vect/vect-bic-bitmask-12.c: Change the default
      	setting of assembly to compile.
      	* gcc.dg/vect/vect-bic-bitmask-23.c: Dito.
      0eba9cae
    • chenxiaolong's avatar
      LoongArch: testsuite:Added support for vector object detection. · 8a2ca066
      chenxiaolong authored
      - Change the default vectorization "-mlasx" option to "-mlsx" because there
      are many non-aligned memory accesses when using 256-bit vectorization.
      
      - The following detection procedure is added to the target-supports.exp file:
      
      1.check_effective_target_scalar_all_fma
      2.check_effective_target_vect_int
      3.check_effective_target_vect_intfloat_cvt
      4.check_effective_target_vect_doubleint_cvt
      5.check_effective_target_vect_intdouble_cvt
      6.check_effective_target_vect_uintfloat_cvt
      7.check_effective_target_vect_floatint_cvt
      8.check_effective_target_vect_floatuint_cvt
      9.check_effective_target_vect_shift
      10.check_effective_target_vect_var_shift
      11.check_effective_target_whole_vector_shift
      12.check_effective_target_vect_bswap
      13.check_effective_target_vect_bool_cmp
      14.check_effective_target_vect_char_add
      15.check_effective_target_vect_shift_char
      16.check_effective_target_vect_long
      17.check_effective_target_vect_float
      18.check_effective_target_vect_double
      19.check_effective_target_vect_long_long
      20.check_effective_target_vect_perm
      21.check_effective_target_vect_perm_byte
      22.check_effective_target_vect_perm_short
      23.check_effective_target_vect_widen_sum_hi_to_si
      24.check_effective_target_vect_widen_sum_qi_to_hi
      25.check_effective_target_vect_widen_sum_qi_to_hi
      26.check_effective_target_vect_widen_mult_qi_to_hi
      27.check_effective_target_vect_widen_mult_hi_to_si
      28.check_effective_target_vect_widen_mult_qi_to_hi_pattern
      29.check_effective_target_vect_widen_mult_hi_to_si_pattern
      30.check_effective_target_vect_widen_mult_si_to_di_pattern
      31.check_effective_target_vect_sdot_qi
      32.check_effective_target_vect_udot_qi
      33.check_effective_target_vect_sdot_hi
      34.check_effective_target_vect_udot_hi
      35.check_effective_target_vect_usad_char
      36.check_effective_target_vect_avg_qi
      37.check_effective_target_vect_pack_trunc
      38.check_effective_target_vect_unpack
      39.check_effective_target_vect_hw_misalign
      40.check_effective_target_vect_gather_load_ifn
      40.check_effective_target_vect_condition
      42.check_effective_target_vect_cond_mixed
      43.check_effective_target_vect_char_mult
      44.check_effective_target_vect_short_mult
      45.check_effective_target_vect_int_mult
      46.check_effective_target_vect_long_mult
      47.check_effective_target_vect_int_mod
      48.check_effective_target_vect_extract_even_odd
      49.check_effective_target_vect_interleave
      50.check_effective_target_vect_call_copysignf
      51.check_effective_target_vect_call_sqrtf
      52.check_effective_target_vect_call_lrint
      53.check_effective_target_vect_call_btrunc
      54.check_effective_target_vect_call_btruncf
      55.check_effective_target_vect_call_ceil
      56.check_effective_target_vect_call_ceilf
      57.check_effective_target_vect_call_floor
      58.check_effective_target_vect_call_floorf
      59.check_effective_target_vect_call_lceil
      60.check_effective_target_vect_call_lfloor
      61.check_effective_target_vect_logical_reduc
      62.check_effective_target_section_anchors
      63.check_vect_support_and_set_flags
      64.check_effective_target_vect_max_reduc
      65.check_effective_target_loongarch_sx
      66.check_effective_target_loongarch_sx_hw
      
      gcc/testsuite/ChangeLog:
      
      	* lib/target-supports.exp: Add LoongArch to the list of supported
      	targets.
      8a2ca066
    • Alex Coplan's avatar
      aarch64: Further fix for throwing insns in ldp/stp pass [PR113217] · 4b67ec7f
      Alex Coplan authored
      As the PR shows, the fix in
      r14-6916-g057dc349021660c40699fb5c98fd9cac8e168653 was not complete.
      That fix was enough to stop us trying to move throwing accesses above
      nondebug insns, but due to this code in try_fuse_pair:
      
        // Placement strategy: push loads down and pull stores up, this should
        // help register pressure by reducing live ranges.
        if (load_p)
          range.first = range.last;
        else
          range.last = range.first;
      
      we would still try to move stores up above any debug insns that occurred
      immediately after the previous nondebug insn.  This patch fixes that by
      narrowing the move range in the case that the second access is throwing
      to exactly the range of that insn.
      
      Note that we still need the fix to latest_hazard_before mentioned above
      so as to ensure we select a suitable base and reject pairs if it isn't
      viable to form the pair at the end of the BB.
      
      gcc/ChangeLog:
      
      	PR target/113217
      	* config/aarch64/aarch64-ldp-fusion.cc
      	(ldp_bb_info::try_fuse_pair): If the second access can throw,
      	narrow the move range to exactly that insn.
      
      gcc/testsuite/ChangeLog:
      
      	PR target/113217
      	* g++.dg/pr113217.C: New test.
      4b67ec7f
    • Ilya Leoshkevich's avatar
      asan: Align .LASANPC on function boundary · e66dc37b
      Ilya Leoshkevich authored
      GCC can emit code between the function label and the .LASANPC label,
      making the latter unaligned.  Some architectures cannot load unaligned
      labels directly and require literal pool entries, which is inefficient.
      
      Move the invocation of asan_function_start to
      ASM_OUTPUT_FUNCTION_LABEL, which guarantees that no additional code is
      emitted.  This allows setting the .LASANPC label alignment to the
      respective function alignment.
      
      Link: https://inbox.sourceware.org/gcc-patches/20240102194511.3171559-3-iii@linux.ibm.com/
      
      
      Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      
      gcc/ChangeLog:
      
      	* asan.cc (asan_function_start): Drop switch_to_section ().
      	(asan_emit_stack_protection): Set .LASANPC alignment.
      	* config/i386/i386.cc: Use assemble_function_label_raw ()
      	instead of ASM_OUTPUT_LABEL ().
      	* config/s390/s390.cc (s390_asm_output_function_label):
      	Likewise.
      	* defaults.h (ASM_OUTPUT_FUNCTION_LABEL): Likewise.
      	* final.cc (final_start_function_1): Drop
      	asan_function_start ().
      	* output.h (assemble_function_label_raw): New function.
      	* varasm.cc (assemble_function_label_raw): Likewise.
      e66dc37b
    • Ilya Leoshkevich's avatar
      Implement ASM_DECLARE_FUNCTION_NAME using ASM_OUTPUT_FUNCTION_LABEL · c659dd8b
      Ilya Leoshkevich authored
      gccint recommends using ASM_OUTPUT_FUNCTION_LABEL in
      ASM_DECLARE_FUNCTION_NAME, but many implementations use
      ASM_OUTPUT_LABEL instead.  It's inconsistent and prevents changes to
      ASM_OUTPUT_FUNCTION_LABEL from affecting the respective targets.
      
      Link: https://inbox.sourceware.org/gcc-patches/20240102194511.3171559-2-iii@linux.ibm.com/
      
      
      Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64.cc (aarch64_declare_function_name):
      	Use ASM_OUTPUT_FUNCTION_LABEL ().
      	* config/alpha/alpha.cc (alpha_start_function): Likewise.
      	* config/arm/aout.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
      	* config/arm/arm.cc (arm_asm_declare_function_name): Likewise.
      	* config/bfin/bfin.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
      	* config/c6x/c6x.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
      	* config/gcn/gcn.cc (gcn_hsa_declare_function_name): Likewise.
      	* config/h8300/h8300.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
      	* config/ia64/ia64.cc (ia64_start_function): Likewise.
      	* config/mcore/mcore-elf.h (ASM_DECLARE_FUNCTION_NAME):
      	Likewise.
      	* config/microblaze/microblaze.cc (microblaze_function_prologue):
      	Likewise.
      	* config/mips/mips.cc (mips_start_unique_function): Return the
      	tree.
      	(mips_start_function_definition): Use
      	ASM_OUTPUT_FUNCTION_LABEL ().
      	(mips_finish_stub): Pass the tree to
      	mips_start_function_definition ().
      	(mips16_build_function_stub): Likewise.
      	(mips16_build_call_stub): Likewise.
      	(mips_output_function_prologue): Likewise.
      	* config/pa/pa.cc (pa_output_function_label): Use
      	ASM_OUTPUT_FUNCTION_LABEL ().
      	* config/riscv/riscv.cc (riscv_declare_function_name): Likewise.
      	* config/rs6000/rs6000.cc (rs6000_elf_declare_function_name):
      	Likewise.
      	(rs6000_xcoff_declare_function_name): Likewise.
      c659dd8b
    • Jonathan Wakely's avatar
      libstdc++: Fix std::char_traits<C>::move [PR113200] · 15cc2918
      Jonathan Wakely authored
      The current constexpr implementation of std::char_traits<C>::move relies
      on being able to compare the pointer parameters, which is not allowed
      for unrelated pointers. We can use __builtin_constant_p to determine
      whether it's safe to compare the pointers directly. If not, then we know
      the ranges must be disjoint and so we can use char_traits<C>::copy to
      copy forwards from the first character to the last. If the pointers can
      be compared directly, then we can simplify the condition for copying
      backwards to just two pointer comparisons.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/113200
      	* include/bits/char_traits.h (__gnu_cxx::char_traits::move): Use
      	__builtin_constant_p to check for unrelated pointers that cannot
      	be compared during constant evaluation.
      	* testsuite/21_strings/char_traits/requirements/113200.cc: New
      	test.
      15cc2918
    • Cassio Neri's avatar
      libstdc++: Remove UB from month and weekday additions and subtractions. · 2cb3d42d
      Cassio Neri authored
      The following invoke signed integer overflow (UB) [1]:
      
        month   + months{MAX} // where MAX is the maximum value of months::rep
        month   + months{MIN} // where MIN is the maximum value of months::rep
        month   - months{MIN} // where MIN is the minimum value of months::rep
        weekday + days  {MAX} // where MAX is the maximum value of days::rep
        weekday - days  {MIN} // where MIN is the minimum value of days::rep
      
      For the additions to MAX, the crux of the problem is that, in libstdc++,
      months::rep and days::rep are int64_t. Other implementations use int32_t, cast
      operands to int64_t and perform arithmetic operations without risk of
      overflowing.
      
      For month + months{MIN}, the implementation follows the Standard's "returns
      clause" and evaluates:
      
         modulo(static_cast<long long>(unsigned{__x}) + (__y.count() - 1), 12);
      
      Overflow occurs when MIN - 1 is evaluated. Casting to a larger type could help
      but, unfortunately again, this is not possible for libstdc++.
      
      For the subtraction of MIN, the problem is that -MIN is not representable.
      
      It's fair to say that the intention is for these additions/subtractions to
      be performed in modulus (12 or 7) arithmetic so that no overflow is expected.
      
      To fix these UB, this patch implements:
      
        template <unsigned __d, typename _T>
        unsigned __add_modulo(unsigned __x, _T __y);
      
        template <unsigned __d, typename _T>
        unsigned __sub_modulo(unsigned __x, _T __y);
      
      which respectively, returns the remainder of Euclidean division of, __x + __y
      and __x - __y by __d without overflowing. These functions replace
      
        constexpr unsigned __modulo(long long __n, unsigned __d);
      
      which also calculates the reminder of __n, where __n is the result of the
      addition or subtraction. Hence, these operations might invoke UB before __modulo
      is called and thus, __modulo can't do anything to remediate the issue.
      
      In addition to solve the UB issues, __add_modulo and __sub_modulo allow better
      codegen (shorter and branchless) on x86-64 and ARM [2].
      
      [1] https://godbolt.org/z/a9YfWdn57
      [2] https://godbolt.org/z/Gh36cr7E4
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/chrono: Fix + and - for months and weekdays.
      	* testsuite/std/time/month/1.cc: Add constexpr tests against overflow.
      	* testsuite/std/time/month/2.cc: New test for extreme values.
      	* testsuite/std/time/weekday/1.cc: Add constexpr tests against overflow.
      	* testsuite/std/time/weekday/2.cc: New test for extreme values.
      2cb3d42d
    • Jonathan Wakely's avatar
      libstdc++: Use if-constexpr in std::__try_use_facet [PR113099] · 9f3eb93e
      Jonathan Wakely authored
      As noted in the PR, we can use if-constexpr for the explicit
      instantantiation definitions that are compiled with -std=gnu++11. We
      just need to disable the -Wc++17-extensions diagnostics.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/113099
      	* include/bits/locale_classes.tcc (__try_use_facet): Use
      	if-constexpr for C++11 and up.
      9f3eb93e
    • Jakub Jelinek's avatar
      scev: Avoid ICE on results used in abnormal PHI args [PR113201] · b8faf1fc
      Jakub Jelinek authored
      The following testcase ICEs when rslt is SSA_NAME_OCCURS_IN_ABNORMAL_PHI
      and we call replace_uses_by with a INTEGER_CST def, where it ICEs on:
                    if (e->flags & EDGE_ABNORMAL
                        && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (val))
      because val is not an SSA_NAME.  One way would be to add
                        && TREE_CODE (val) == SSA_NAME
      check in between the above 2 lines in replace_uses_by.
      
      And/or the following patch just punts propagating constants to
      SSA_NAME_OCCURS_IN_ABNORMAL_PHI rslt uses.
      
      Or we could punt somewhere earlier in final value replacement (but dunno
      where).
      
      2024-01-05  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/113201
      	* tree-scalar-evolution.cc (final_value_replacement_loop): Don't call
      	replace_uses_by on SSA_NAME_OCCURS_IN_ABNORMAL_PHI rslt.
      
      	* gcc.c-torture/compile/pr113201.c: New test.
      b8faf1fc
    • Jakub Jelinek's avatar
      Improve __builtin_popcount* (x) == 1 generation if x is known != 0 [PR90693] · 0152637c
      Jakub Jelinek authored
      We expand __builtin_popcount* (x) == 1 as
      x ^ (x - 1) > x - 1, either unconditionally in tree-ssa-math-opts.cc
      if we don't have a direct optab support for popcount, or during
      expansion where we compare the costs of comparison of the popcount
      against one vs. the above expression.
      As mentioned in the PR, if we know from ranger that the argument is
      not zero, we can emit x & (x - 1) == 0 test which is same number of
      GIMPLE statements, but on many targets cheaper (e.g. whenever an AND
      instruction can also set flags on whether result was zero or not).
      
      The following patch does that.
      
      2024-01-05  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/90693
      	* tree-ssa-math-opts.cc (match_single_bit_test): If
      	tree_expr_nonzero_p (arg), remember it in the second argument to
      	IFN_POPCOUNT or lower it as arg & (arg - 1) == 0 rather than
      	arg ^ (arg - 1) > arg - 1.
      	* internal-fn.cc (expand_POPCOUNT): If second argument to
      	IFN_POPCOUNT suggests arg is non-zero, try to expand it as
      	arg & (arg - 1) == 0 rather than arg ^ (arg - 1) > arg - 1.
      
      	* gcc.target/i386/pr90693-2.c: New test.
      0152637c
    • Kito Cheng's avatar
      RISC-V: Fix wrong fix in last clean up · 397bdd1a
      Kito Cheng authored
      I just replace the wrong logic in last clean up...
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/partial/single_rgroup-2.h:
      	Fix the check condition.
      397bdd1a
    • Kito Cheng's avatar
      RISC-V: Clean up testsuite for multi-lib testing [NFC] · 085585e9
      Kito Cheng authored
      - Drop unnecessary including for stdlib.h and math.h
      - Drop assert.h / assert, use __builtin_abort instead.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/binop/shift-scalar-template.h:
      	Use __builtin_abort instead of assert.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-1.c: Drop math.h.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-2.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-3.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-4.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-1.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-2.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-3.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-4.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-1.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-2.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-3.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-4.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-1.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-2.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-3.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-4.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/partial/single_rgroup-2.h: Use
      	__builtin_abort instead of assert.
      	* gcc.target/riscv/rvv/autovec/pr112694-1.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/partial/single_rgroup-3.h: Ditto.
      	* gcc.target/riscv/rvv/autovec/unop/abs-template.h: Drop stdlib.h.
      	* gcc.target/riscv/rvv/autovec/unop/vneg-template.h: Ditto.
      	* gcc.target/riscv/rvv/autovec/unop/vnot-template.h: Ditto.
      085585e9
    • Kito Cheng's avatar
      RISC-V: Clean up unused variable [NFC] · 05415dba
      Kito Cheng authored
      gcc/ChangeLog:
      
      	* config/riscv/riscv-v.cc (expand_load_store):
      	Remove `value`.
      	(expand_cond_len_op): Ditto.
      	(expand_gather_scatter): Ditto.
      	(expand_lanes_load_store): Ditto.
      	(expand_fold_extract_last): Ditto.
      05415dba
    • Jakub Jelinek's avatar
      Update copyright years. · 1ccad1f1
      Jakub Jelinek authored
      1ccad1f1
    • Jakub Jelinek's avatar
      Update copyright years. · 219a688b
      Jakub Jelinek authored
      219a688b
    • Pan Li's avatar
      Revert "RISC-V: Add crypto vector api-testing cases." · fc75b733
      Pan Li authored
      This reverts commit b3ec98d4.
      fc75b733
    • Pan Li's avatar
      Revert "RISC-V: Add crypto vector builtin function." · fd946ecb
      Pan Li authored
      This reverts commit 960c2620.
      fd946ecb
    • Feng Wang's avatar
      RISC-V: Add crypto vector api-testing cases. · b3ec98d4
      Feng Wang authored
      This patch add crypto vector api-testing cases based on
      https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/eopc/vector-crypto/auto-generated/vector-crypto
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/base/zvbb-intrinsic.c: New test.
      	* gcc.target/riscv/rvv/base/zvbb_vandn_vx_constraint.c: New test.
      	* gcc.target/riscv/rvv/base/zvbc-intrinsic.c: New test.
      	* gcc.target/riscv/rvv/base/zvbc_vx_constraint-1.c: New test.
      	* gcc.target/riscv/rvv/base/zvbc_vx_constraint-2.c: New test.
      	* gcc.target/riscv/rvv/base/zvkg-intrinsic.c: New test.
      	* gcc.target/riscv/rvv/base/zvkned-intrinsic.c: New test.
      	* gcc.target/riscv/rvv/base/zvknha-intrinsic.c: New test.
      	* gcc.target/riscv/rvv/base/zvknhb-intrinsic.c: New test.
      	* gcc.target/riscv/rvv/base/zvksed-intrinsic.c: New test.
      	* gcc.target/riscv/rvv/base/zvksh-intrinsic.c: New test.
      	* gcc.target/riscv/zvkb.c: New test.
      b3ec98d4
    • Feng Wang's avatar
      RISC-V: Add crypto vector builtin function. · 960c2620
      Feng Wang authored
      This patch add the intrinsic funtions of crypto vector based on the
      intrinsic doc(https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob
      /eopc/vector-crypto/auto-generated/vector-crypto/intrinsic_funcs.md).
      
      Co-Authored by: Songhe Zhu <zhusonghe@eswincomputing.com>
      Co-Authored by: Ciyan Pan <panciyan@eswincomputing.com>
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-builtins-bases.cc (class vandn):
      				Add new function_base for crypto vector.
      	(class bitmanip): Ditto.
      	(class b_reverse):Ditto.
      	(class vwsll):   Ditto.
      	(class clmul):   Ditto.
      	(class vg_nhab):  Ditto.
      	(class crypto_vv):Ditto.
      	(class crypto_vi):Ditto.
      	(class vaeskf2_vsm3c):Ditto.
      	(class vsm3me): Ditto.
      	(BASE): Add BASE declaration for crypto vector.
      	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
      	* config/riscv/riscv-vector-builtins-functions.def (REQUIRED_EXTENSIONS):
      				Add crypto vector intrinsic definition.
      	(vbrev): Ditto.
      	(vclz): Ditto.
      	(vctz): Ditto.
      	(vwsll): Ditto.
      	(vandn): Ditto.
      	(vbrev8): Ditto.
      	(vrev8): Ditto.
      	(vrol): Ditto.
      	(vror): Ditto.
      	(vclmul): Ditto.
      	(vclmulh): Ditto.
      	(vghsh): Ditto.
      	(vgmul): Ditto.
      	(vaesef): Ditto.
      	(vaesem): Ditto.
      	(vaesdf): Ditto.
      	(vaesdm): Ditto.
      	(vaesz): Ditto.
      	(vaeskf1): Ditto.
      	(vaeskf2): Ditto.
      	(vsha2ms): Ditto.
      	(vsha2ch): Ditto.
      	(vsha2cl): Ditto.
      	(vsm4k): Ditto.
      	(vsm4r): Ditto.
      	(vsm3me): Ditto.
      	(vsm3c): Ditto.
      	* config/riscv/riscv-vector-builtins-shapes.cc (struct crypto_vv_def):
      				Add new function_shape for crypto vector.
      	(struct crypto_vi_def): Ditto.
      	(struct crypto_vv_no_op_type_def): Ditto.
      	(SHAPE): Add SHAPE declaration of crypto vector.
      	* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
      	* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_CRYPTO_SEW32_OPS):
      				Add new data type for crypto vector.
      	(DEF_RVV_CRYPTO_SEW64_OPS): Ditto.
      	(vuint32mf2_t): Ditto.
      	(vuint32m1_t): Ditto.
      	(vuint32m2_t): Ditto.
      	(vuint32m4_t): Ditto.
      	(vuint32m8_t): Ditto.
      	(vuint64m1_t): Ditto.
      	(vuint64m2_t): Ditto.
      	(vuint64m4_t): Ditto.
      	(vuint64m8_t): Ditto.
      	* config/riscv/riscv-vector-builtins.cc (DEF_RVV_CRYPTO_SEW32_OPS):
      				Add new data struct for crypto vector.
      	(DEF_RVV_CRYPTO_SEW64_OPS): Ditto.
      	(registered_function::overloaded_hash): Processing size_t uimm for C overloaded func.
      	* config/riscv/riscv-vector-builtins.def (vi): Add vi OP_TYPE.
      960c2620
    • GCC Administrator's avatar
      Daily bump. · 81d1a6e9
      GCC Administrator authored
      81d1a6e9
    • Ken Matsui's avatar
      libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT · f151db0f
      Ken Matsui authored
      
      This patch uses _GLIBCXX_USE_BUILTIN_TRAIT macro instead of __has_builtin
      in the type_traits header for traits that have a corresponding fallback
      non-built-in implementation.  This macro supports to toggle the use of
      built-in traits in the type_traits header through
      _GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS macro, without needing to modify the
      source code.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/type_traits: Use _GLIBCXX_USE_BUILTIN_TRAIT.
      
      Signed-off-by: default avatarKen Matsui <kmatsui@gcc.gnu.org>
      Reviewed-by: default avatarPatrick Palka <ppalka@redhat.com>
      Reviewed-by: default avatarJonathan Wakely <jwakely@redhat.com>
      f151db0f
  3. Jan 04, 2024
    • Juzhe-Zhong's avatar
      RISC-V: Make liveness estimation be aware of .vi variant · 3ab4c381
      Juzhe-Zhong authored
      Consider this following case:
      
      void
      f (int *restrict a, int *restrict b, int *restrict c, int *restrict d, int n)
      {
        for (int i = 0; i < n; i++)
          {
            int tmp = b[i] + 15;
            int tmp2 = tmp + b[i];
            c[i] = tmp2 + b[i];
            d[i] = tmp + tmp2 + b[i];
          }
      }
      
      Current dynamic LMUL cost model choose LMUL = 4 because we count the "15" as
      consuming 1 vector register group which is not accurate.
      
      We teach the dynamic LMUL cost model be aware of the potential vi variant instructions
      transformation, so that we can choose LMUL = 8 according to more accurate cost model.
      
      After this patch:
      
      f:
      	ble	a4,zero,.L5
      .L3:
      	vsetvli	a5,a4,e32,m8,ta,ma
      	slli	a0,a5,2
      	vle32.v	v16,0(a1)
      	vadd.vi	v24,v16,15
      	vadd.vv	v8,v24,v16
      	vadd.vv	v0,v8,v16
      	vse32.v	v0,0(a2)
      	vadd.vv	v8,v8,v24
      	vadd.vv	v8,v8,v16
      	vse32.v	v8,0(a3)
      	add	a1,a1,a0
      	add	a2,a2,a0
      	add	a3,a3,a0
      	sub	a4,a4,a5
      	bne	a4,zero,.L3
      .L5:
      	ret
      
      Tested on both RV32 and RV64 no regression.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-costs.cc (variable_vectorized_p): Teach vi variant.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-13.c: New test.
      3ab4c381
    • Andrew Pinski's avatar
      Match: Improve inverted_equal_p for bool and `^` and `==` [PR113186] · 97def769
      Andrew Pinski authored
      
      For boolean types, `a ^ b` is a valid form for `a != b`. This means for
      gimple_bitwise_inverted_equal_p, we catch some inverted value forms. This
      patch extends inverted_equal_p to allow matching of `^` with the
      corresponding `==`. Note in the testcase provided we used to optimize
      in GCC 12 to just `return 0` where `a == b` was used,
      this allows us to do that again.
      
      Bootstrapped and tested on x86_64-linux-gnu with no regressions.
      
      	PR tree-optimization/113186
      
      gcc/ChangeLog:
      
      	* gimple-match-head.cc (gimple_bitwise_inverted_equal_p):
      	Match `^` with the `==` for 1bit integral types.
      	* match.pd (maybe_cmp): Allow for bit_xor for 1bit
      	integral types.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-ssa/bitops-bool-1.c: New test.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      97def769
    • Arsen Arsenović's avatar
      libstdc++: fix typo in <generator> · 589781c1
      Arsen Arsenović authored
      libstdc++-v3/ChangeLog:
      
      	* include/std/generator (_Subyield_state::_M_jump_in): Fix typo
      	reported by Will Hawkins <hawkinsw@obs.cr>.
      589781c1
    • Arsen Arsenović's avatar
      libstdc++: rename _A badname in <generator> · 29ad18f0
      Arsen Arsenović authored
      libstdc++-v3/ChangeLog:
      
      	* include/std/generator (_Stateless_alloc): Rename typename _A
      	to _All.
      29ad18f0
    • Raiki Tamura's avatar
      libcpp: add function to check XID properties · 00dea7e8
      Raiki Tamura authored
      
      This commit adds a new function intended for checking the XID properties
      of a possibly unicode character, as well as the accompanying enum
      describing the possible properties.
      
      libcpp/ChangeLog:
      
      	* charset.cc (cpp_check_xid_property): New.
      	* include/cpplib.h
      	(cpp_check_xid_property): New.
      	(enum cpp_xid_property): New.
      
      Signed-off-by: default avatarRaiki Tamura <tamaron1203@gmail.com>
      00dea7e8
Loading