Skip to content
Snippets Groups Projects
  1. Feb 02, 2024
    • Ian Lance Taylor's avatar
      compiler: export the type "any" as a builtin · e52d3180
      Ian Lance Taylor authored
      Otherwise we can't tell the difference between builtin type "any" and
      a locally defined type "any".
      
      This will require updates to the gccgo export data parsers in the main
      Go repo and the x/tools repo.  These updates are https://go.dev/cl/537195
      and https://go.dev/cl/537215.
      
      Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536715
      e52d3180
    • Jakub Jelinek's avatar
      libgcc: Fix up _BitInt division [PR113604] · fbb56931
      Jakub Jelinek authored
      The following testcase ends up with SIGFPE in __divmodbitint4.
      The problem is a thinko in my attempt to implement Knuth's algorithm.
      
      The algorithm does (where b is 65536, i.e. one larger than what
      fits in their unsigned short word):
              // Compute estimate qhat of q[j].
              qhat = (un[j+n]*b + un[j+n-1])/vn[n-1];
              rhat = (un[j+n]*b + un[j+n-1]) - qhat*vn[n-1];
            again:
              if (qhat >= b || qhat*vn[n-2] > b*rhat + un[j+n-2])
              { qhat = qhat - 1;
                rhat = rhat + vn[n-1];
                if (rhat < b) goto again;
              }
      The problem is that it uses a double-word / word -> double-word
      division (and modulo), while all we have is udiv_qrnnd unless
      we'd want to do further library calls, and udiv_qrnnd is a
      double-word / word -> word division and modulo.
      Now, as the algorithm description says, it can produce at most
      word bits + 1 bit quotient.  And I believe that actually the
      highest qhat the original algorithm can produce is
      (1 << word_bits) + 1.  The algorithm performs earlier canonicalization
      where both the divisor and dividend are shifted left such that divisor
      has msb set.  If it has msb set already before, no shifting occurs but
      we start with added 0 limb, so in the first uv1:uv0 double-word uv1
      is 0 and so we can't get too high qhat, if shifting occurs, the first
      limb of dividend is shifted right by UWtype bits - shift count into
      a new limb, so again in the first iteration in the uv1:uv0 double-word
      uv1 doesn't have msb set while vv1 does and qhat has to fit into word.
      In the following iterations, previous iteration should guarantee that
      the previous quotient digit is correct.  Even if the divisor was the
      maximal possible vv1:all_ones_in_all_lower_limbs, if the old uv0:lower_limbs
      would be larger or equal to the divisor, the previous quotient digit
      would increase and another divisor would be subtracted, which I think
      implies that in the next iteration in uv1:uv0 double-word uv1 <= vv1,
      but uv0 could be up to all ones, e.g. in case of all lower limbs
      of divisor being all ones and at least one dividend limb below uv0
      being not all ones.  So, we can e.g. for 64-bit UWtype see
      uv1:uv0 / vv1 0x8000000000000000UL:0xffffffffffffffffUL / 0x8000000000000000UL
      or 0xffffffffffffffffUL:0xffffffffffffffffUL / 0xffffffffffffffffUL
      In all these cases (when uv1 == vv1 && uv0 >= uv1), qhat is
      0x10000000000000001UL, i.e. 2 more than fits into UWtype result,
      if uv1 == vv1 && uv0 < uv1 it would be 0x10000000000000000UL, i.e.
      1 more than fits into UWtype result.
      Because we only have udiv_qrnnd which can't deal with those too large
      cases (SIGFPEs or otherwise invokes undefined behavior on those), I've
      tried to handle the uv1 >= vv1 case separately, but for one thing
      I thought it would be at most 1 larger than what fits, and for two
      have actually subtracted vv1:vv1 from uv1:uv0 instead of subtracting
      0:vv1 from uv1:uv0.
      For the uv1 < vv1 case, the implementation already performs roughly
      what the algorithm does.
      Now, let's see what happens with the two possible extra cases in
      the original algorithm.
      If uv1 == vv1 && uv0 < uv1, qhat above would be b, so we take
      if (qhat >= b, decrement qhat by 1 (it becomes b - 1), add
      vn[n-1] aka vv1 to rhat and goto again if rhat < b (but because
      qhat already fits we can goto to the again label in the uv1 < vv1
      code).  rhat in this case is uv0 and rhat + vv1 can but doesn't
      have to overflow, say for uv0 42UL and vv1 0x8000000000000000UL
      it will not (and so we should goto again), while for uv0
      0x8000000000000000UL and vv1 0x8000000000000001UL it will (and
      we shouldn't goto again).
      If uv1 == vv1 && uv0 >= uv1, qhat above would be b + 1, so we
      take if (qhat >= b, decrement qhat by 1 (it becomes b), add
      vn[n-1] aka vv1 to rhat. But because vv1 has msb set and
      rhat in this case is uv0 - vv1, the rhat + vv1 addition
      certainly doesn't overflow, because (uv0 - vv1) + vv1 is uv0,
      so in the algorithm we goto again, again take if (qhat >= b and
      decrement qhat so it finally becomes b - 1, and add vn[n-1]
      aka vv1 to rhat again.  But this time I believe it must always
      overflow, simply because we added (uv0 - vv1) + vv1 + vv1 and
      vv1 has msb set, so already vv1 + vv1 must overflow.  And
      because it overflowed, it will not goto again.
      So, I believe the following patch implements this correctly, by
      subtracting vv1 from uv1:uv0 double-word once, then comparing
      again if uv1 >= vv1.  If that is true, subtract vv1 from uv1:uv0
      again and add 2 * vv1 to rhat, no __builtin_add_overflow is needed
      as we know it always overflowed and so won't goto again.
      If after the first subtraction uv1 < vv1, use __builtin_add_overflow
      when adding vv1 to rhat, because it can but doesn't have to overflow.
      
      I've added an extra testcase which tests the behavior of all the changed
      cases, so it has a case where uv1:uv0 / vv1 is 1:1, where it is
      1:0 and rhat + vv1 overflows and where it is 1:0 and rhat + vv1 does not
      overflow, and includes tests also from Zdenek's other failing tests.
      
      2024-02-02  Jakub Jelinek  <jakub@redhat.com>
      
      	PR libgcc/113604
      	* libgcc2.c (__divmodbitint4): If uv1 >= vv1, subtract
      	vv1 from uv1:uv0 once or twice as needed, rather than
      	subtracting vv1:vv1.
      
      	* gcc.dg/torture/bitint-53.c: New test.
      	* gcc.dg/torture/bitint-55.c: New test.
      fbb56931
    • Antoni Boucher's avatar
      libgccjit: Implement sizeof operator · 5d534a21
      Antoni Boucher authored
      gcc/jit/ChangeLog:
      
      	* docs/topics/compatibility.rst (LIBGCCJIT_ABI_27): New ABI tag.
      	* docs/topics/expressions.rst: Document gcc_jit_context_new_sizeof.
      	* jit-playback.cc (new_sizeof): New method.
      	* jit-playback.h (new_sizeof): New method.
      	* jit-recording.cc (recording::context::new_sizeof,
      	recording::memento_of_sizeof::replay_into,
      	recording::memento_of_sizeof::make_debug_string,
      	recording::memento_of_sizeof::write_reproducer): New methods.
      	* jit-recording.h (class memento_of_sizeof): New class.
      	* libgccjit.cc (gcc_jit_context_new_sizeof): New function.
      	* libgccjit.h (gcc_jit_context_new_sizeof): New function.
      	* libgccjit.map: New function.
      
      gcc/testsuite/ChangeLog:
      
      	* jit.dg/all-non-failing-tests.h: New test.
      	* jit.dg/test-sizeof.c: New test.
      5d534a21
    • Jason Merrill's avatar
      c++: op== defaulted outside class [PR110084] · e17a122d
      Jason Merrill authored
      defaulted_late_check is for checks that need to happen after the class is
      complete; we shouldn't call it sooner.
      
      	PR c++/110084
      
      gcc/cp/ChangeLog:
      
      	* pt.cc (tsubst_function_decl): Only check a function defaulted
      	outside the class if the class is complete.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp2a/spaceship-synth-neg3.C: Check error message.
      	* g++.dg/cpp2a/spaceship-eq16.C: New test.
      e17a122d
    • John David Anglin's avatar
      hppa: Implement TARGET_ATOMIC_ASSIGN_EXPAND_FENV · 1c3cfb5a
      John David Anglin authored
      This change implements __builtin_get_fpsr() and __builtin_set_fpsr(x)
      to get and set the floating-point status register.  They are used to
      implement pa_atomic_assign_expand_fenv().
      
      2024-02-02  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/ChangeLog:
      
      	PR target/59778
      	* config/pa/pa.cc (enum pa_builtins): Add PA_BUILTIN_GET_FPSR
      	and PA_BUILTIN_SET_FPSR builtins.
      	* (pa_builtins_icode): Declare.
      	* (def_builtin, pa_fpu_init_builtins): New.
      	* (pa_init_builtins): Initialize FPU builtins.
      	* (pa_builtin_decl, pa_expand_builtin_1): New.
      	* (pa_expand_builtin): Handle PA_BUILTIN_GET_FPSR and
      	PA_BUILTIN_SET_FPSR builtins.
      	* (pa_atomic_assign_expand_fenv): New.
      	* config/pa/pa.md (UNSPECV_GET_FPSR, UNSPECV_SET_FPSR): New
      	UNSPECV constants.
      	(get_fpsr, put_fpsr): New expanders.
      	(get_fpsr_32, get_fpsr_64, set_fpsr_32, set_fpsr_64): New
      	insn patterns.
      1c3cfb5a
    • Juzhe-Zhong's avatar
      RISC-V: Expand VLMAX scalar move in reduction · 922e4599
      Juzhe-Zhong authored
      This patch fixes the following:
      
              vsetvli a5,a1,e32,m1,tu,ma
              slli    a4,a5,2
              sub     a1,a1,a5
              vle32.v v2,0(a0)
              add     a0,a0,a4
              vadd.vv v1,v2,v1
              bne     a1,zero,.L3
              vsetivli        zero,1,e32,m1,ta,ma
              vmv.s.x v2,zero
              vsetvli a5,zero,e32,m1,ta,ma              ---> Redundant vsetvl.
              vredsum.vs      v1,v1,v2
              vmv.x.s a0,v1
              ret
      
      VSETVL PASS is able to fuse avl = 1 of scalar move and VLMAX avl of reduction.
      
      However, this following RTL blocks the fusion in dependence analysis in VSETVL PASS:
      
      (insn 49 24 50 5 (set (reg:RVVM1SI 98 v2 [148])
              (if_then_else:RVVM1SI (unspec:RVVMF32BI [
                          (const_vector:RVVMF32BI [
                                  (const_int 1 [0x1])
                                  repeat [
                                      (const_int 0 [0])
                                  ]
                              ])
                          (const_int 1 [0x1])
                          (const_int 2 [0x2]) repeated x2
                          (const_int 0 [0])
                          (reg:SI 66 vl)
                          (reg:SI 67 vtype)
                      ] UNSPEC_VPREDICATE)
                  (const_vector:RVVM1SI repeat [
                          (const_int 0 [0])
                      ])
                  (unspec:RVVM1SI [
                          (reg:DI 0 zero)
                      ] UNSPEC_VUNDEF))) 3813 {*pred_broadcastrvvm1si_zero}
           (nil))
      (insn 50 49 51 5 (set (reg:DI 15 a5 [151])                          ---->  It set a5, blocks the following VLMAX into the scalar move above.
              (unspec:DI [
                      (const_int 32 [0x20])
                  ] UNSPEC_VLMAX)) 2566 {vlmax_avldi}
           (expr_list:REG_EQUIV (unspec:DI [
                      (const_int 32 [0x20])
                  ] UNSPEC_VLMAX)
              (nil)))
      (insn 51 50 52 5 (set (reg:RVVM1SI 97 v1 [150])
              (unspec:RVVM1SI [
                      (unspec:RVVMF32BI [
                              (const_vector:RVVMF32BI repeat [
                                      (const_int 1 [0x1])
                                  ])
                              (reg:DI 15 a5 [151])
                              (const_int 2 [0x2])
                              (const_int 1 [0x1])
                              (reg:SI 66 vl)
                              (reg:SI 67 vtype)
                          ] UNSPEC_VPREDICATE)
                      (unspec:RVVM1SI [
                              (reg:RVVM1SI 97 v1 [orig:134 vect_result_14.6 ] [134])
                              (reg:RVVM1SI 98 v2 [148])
                          ] UNSPEC_REDUC_SUM)
                      (unspec:RVVM1SI [
                              (reg:DI 0 zero)
                          ] UNSPEC_VUNDEF)
                  ] UNSPEC_REDUC)) 17541 {pred_redsumrvvm1si}
           (expr_list:REG_DEAD (reg:RVVM1SI 98 v2 [148])
              (expr_list:REG_DEAD (reg:SI 66 vl)
                  (expr_list:REG_DEAD (reg:DI 15 a5 [151])
                      (expr_list:REG_DEAD (reg:DI 0 zero)
                          (nil))))))
      
      Such situation can only happen on auto-vectorization, never happen on intrinsic codes.
      Since the reduction is passed VLMAX AVL, it should be more natural to pass VLMAX to the scalar move which initial the value of the reduction.
      
      After this patch:
      
      	vsetvli	a5,a1,e32,m1,tu,ma
      	slli	a4,a5,2
      	sub	a1,a1,a5
      	vle32.v	v2,0(a0)
      	add	a0,a0,a4
      	vadd.vv	v1,v2,v1
      	bne	a1,zero,.L3
      	vsetvli	a5,zero,e32,m1,ta,ma
      	vmv.s.x	v2,zero
      	vredsum.vs	v1,v1,v2
      	vmv.x.s	a0,v1
              ret
      
      Tested on both RV32/RV64 no regression.
      
      	PR target/113697
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-v.cc (expand_reduction): Pass VLMAX avl to scalar move.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/pr113697.c: New test.
      922e4599
    • Iain Sandoe's avatar
      testsuite, Darwin: Allow for undefined symbols in shared test. · 639bd5e9
      Iain Sandoe authored
      Darwin's linker defaults to error on undefined (which makes it look as
      if we do not support shared, leading to tests being marked incorrectly
      as unsupported).
      
      This fixes the issue by allowing the symbols used in the target
      supports test to be undefined.
      
      gcc/testsuite/ChangeLog:
      
      	* lib/target-supports.exp (check_effective_target_shared):
      	Allow the external symbols referenced in the test to be undefined.
      639bd5e9
    • Iain Sandoe's avatar
      testsuite, ubsan: Add libstdc++ deps where required. · ae061a17
      Iain Sandoe authored
      We use the ubsan tests from both C, C++, D and Fortran.
      thee sanitizer libraries link to libstdc++.
      
      When we are using the C/gdc/gfortran driver, and the target might
      require a path to the libstdc++ (e.g. for handing -static-xxxx or
      for embedded runpaths), we need to add a suitable option (or we get
      fails at execution time because of the missing paths).
      
      Conversely, we do not want to add multiple instances of these
      paths (since that leads to failures on tools that report warnings
      for duplicate runpaths).
      
      This patch modifies the _init function to allow a sigle parameter
      that determines whether the *asan_init should add a path for
      libstdc++ (yes for C driver, no for C++ driver).
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/ubsan/ubsan.exp:Add a parameter to init to say that
      	we expect the C++ driver to provide paths for libstdc++.
      	* gcc.dg/ubsan/ubsan.exp: Add a parameter to init to say that
      	we need a path added for libstdc++.
      	* gdc.dg/ubsan/ubsan.exp: Likewise.
      	* gfortran.dg/ubsan/ubsan.exp: Likewise.
      	* lib/ubsan-dg.exp: Handle a single parameter to init that
      	requests addition of a path to libstdc++ to link flags.
      ae061a17
    • Iain Sandoe's avatar
      testsuite, asan, hwsan: Add libstdc++ deps where required. · a6afa0d0
      Iain Sandoe authored
      We use the shared asan/hwasan rom both C,C++,D and Fortran.
      The sanitizer libraries link to libstdc++.
      
      When we are using the C/gdc/gfortran driver, and the target might
      require a path to the libstdc++ (e.g. for handing -static-xxxx or
      for embedded runpaths), we need to add a suitable option (or we get
      fails at execution time because of the missing paths).
      
      Conversely, we do not want to add multiple instances of these
      paths (since that leads to failures on tools that report warnings
      for duplicate runpaths).
      
      This patch modifies the _init function to allow a single parameter
      that determines whether the *asan_init should add a path for
      libstdc++ (yes for C driver, no for C++ driver).
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/asan/asan.exp: Add a parameter to init to say that
      	we expect the C++ driver to provide paths for libstdc++.
      	* g++.dg/hwasan/hwasan.exp: Likewise
      	* gcc.dg/asan/asan.exp: Add a parameter to init to say that
      	we need a path added for libstdc++.
      	* gcc.dg/hwasan/hwasan.exp: Likewise.
      	* gdc.dg/asan/asan.exp: Likewise.
      	* gfortran.dg/asan/asan.exp: Likewise.
      	* lib/asan-dg.exp: Handle a single parameter to init that
      	requests addition of a path to libstdc++ to link flags.
      	* lib/hwasan-dg.exp: Likewise.
      a6afa0d0
    • Khem Raj's avatar
      [PATCH] libgcc: Include stdlib.h for abort() on mingw32 · 2c27aa8d
      Khem Raj authored
      libgcc/
      	* config/i386/enable-execute-stack-mingw32.c: Include
      	stdlib.h for abort() definition.
      2c27aa8d
    • Jonathan Wakely's avatar
      libstdc++: Make std::function deduction guide support explicit object functions [PR113335] · 6f751494
      Jonathan Wakely authored
      This makes the deduction guides for std::function and std::packaged_task
      work for explicit object member functions, i.e. "deducing this", as per
      LWG 3617.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/113335
      	* include/bits/std_function.h (__function_guide_helper): Add
      	partial specialization for explicit object member functions, as
      	per LWG 3617.
      	* testsuite/20_util/function/cons/deduction_c++23.cc: Check
      	explicit object member functions.
      	* testsuite/30_threads/packaged_task/cons/deduction_c++23.cc:
      	Likewise.
      6f751494
    • Jonathan Wakely's avatar
      libstdc++: Fix experimental/names.cc failure on AIX · f9292935
      Jonathan Wakely authored
      This fails due to "u" being used in a system header.
      
      FAIL: experimental/names.cc  -std=gnu++17 (test for excess errors)
      Excess errors:
      /usr/include/sys/poll.h:77: error: expected unqualified-id before ';' token
      /usr/include/sys/poll.h:77: error: expected ')' before ';' token
      
      FAIL: experimental/names.cc  -std=gnu++17 (test for excess errors)
      Excess errors:
      /usr/include/sys/poll.h:102: error: expected unqualified-id before ';' token
      /usr/include/sys/poll.h:102: error: expected ')' before ';' token
      
      libstdc++-v3/ChangeLog:
      
      	* testsuite/17_intro/names.cc [_AIX]: Undefine "u".
      f9292935
    • Jakub Jelinek's avatar
      libgcc: Export XF, TF, HF and BFmode specific _BitInt symbols from libgcc_s.so.1 [PR113700] · 9f5caef5
      Jakub Jelinek authored
      Rainer pointed out that __PFX__ and __FIXPTPFX__ prefix replacement is done
      solely for libgcc-std.ver.in and not for the *.ver files in config.
      I've used the __PFX__ prefix even in config/i386/libgcc-glibc.ver because it
      was used for similar symbols in libgcc-std.ver.in, and that results in those
      symbols being STB_LOCAL in libgcc_s.so.1.  Tests still work because gcc by
      default uses -static-libgcc when linking (unlike g++ etc.), but would
      have failed when using -shared-libgcc (but I see nothing in the testsuite
      actually testing with -shared-libgcc, so am not adding tests).
      
      With the patch, libgcc_s.so.1 now exports
      __fixtfbitint@@GCC_14.0.0 FUNC GLOBAL DEFAULT
      __fixxfbitint@@GCC_14.0.0 FUNC GLOBAL DEFAULT
      __floatbitintbf@@GCC_14.0.0 FUNC GLOBAL DEFAULT
      __floatbitinthf@@GCC_14.0.0 FUNC GLOBAL DEFAULT
      __floatbitinttf@@GCC_14.0.0 FUNC GLOBAL DEFAULT
      __floatbitintxf@@GCC_14.0.0 FUNC GLOBAL DEFAULT
      on x86_64-linux which it wasn't before.
      
      2024-02-02  Jakub Jelinek  <jakub@redhat.com>
      
      	PR target/113700
      	* config/i386/libgcc-glibc.ver (GCC_14.0.0): Remove __PFX prefixes
      	from symbol names.
      9f5caef5
    • Jonathan Wakely's avatar
      doc: Fix typo in description of hardbool attribute · cc13e60b
      Jonathan Wakely authored
      gcc/ChangeLog:
      
      	* doc/extend.texi (Common Type Attributes): Fix typo in
      	description of hardbool.
      cc13e60b
    • Jakub Jelinek's avatar
      testsuite: Add another bitint testcase [PR113691] · a049acab
      Jakub Jelinek authored
      This is fixed by the PR113692 patch.
      
      2024-02-02  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/113691
      	* gcc.dg/bitint-83.c: New test.
      a049acab
    • Jakub Jelinek's avatar
      lower-bitint: Handle casts from large/huge _BitInt to pointer/reference types [PR113692] · fb28d5cd
      Jakub Jelinek authored
      I thought one needs to cast first to pointer-sized integer before casting to
      pointer, but apparently that is not the case.
      So the following patch arranges for the large/huge _BitInt to
      pointer/reference conversions to use the same code as for conversions
      of them to small integral types.
      
      2024-02-02  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/113692
      	* gimple-lower-bitint.cc (bitint_large_huge::lower_stmt): Handle casts
      	from large/huge BITINT_TYPEs to POINTER_TYPE/REFERENCE_TYPE as
      	final_cast_p.
      
      	* gcc.dg/bitint-82.c: New test.
      fb28d5cd
    • Jakub Jelinek's avatar
      lower-bitint: Handle uninitialized large/huge SSA_NAMEs as inline asm inputs [PR113699] · 49e75666
      Jakub Jelinek authored
      Similar problem to calls with uninitialized large/huge _BitInt SSA_NAME
      arguments, var_to_partition will not work for those, but unlike calls
      where we just create a new uninitialized SSA_NAME here we need to change
      the inline asm input to be an uninitialized VAR_DECL.
      
      2024-02-02  Jakub Jelinek  <jakub@redhat.com>
      
      	PR middle-end/113699
      	* gimple-lower-bitint.cc (bitint_large_huge::lower_asm): Handle
      	uninitialized large/huge _BitInt SSA_NAME inputs.
      
      	* gcc.dg/bitint-81.c: New test.
      49e75666
    • Jonathan Wakely's avatar
      libstdc++: Implement some missing functions for net::ip::network_v6 · 5b069117
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	* include/experimental/internet (network_v6::network): Define.
      	(network_v6::hosts): Finish implementing.
      	(network_v6::to_string): Do not concatenate std::string to
      	arbitrary std::basic_string specialization.
      	* testsuite/experimental/net/internet/network/v6/cons.cc: New
      	test.
      5b069117
    • Jonathan Wakely's avatar
      libstdc++: Fix invalid order in PSTL inplace_merge test [PR90276] · a6286584
      Jonathan Wakely authored
      This looks like a typo in the upstream test that causes a failure in
      debug mode. It has been reported upstream.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/90276
      	* testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: Fix
      	comparison function to use less-than instead of equality.
      a6286584
    • Jonathan Wakely's avatar
      libstdc++: Avoid reusing moved-from iterators in PSTL tests [PR90276] · 723a7c1a
      Jonathan Wakely authored
      The reverse_invoker utility for PSTL tests uses forwarding references for
      all parameters, but some of those parameters get forwarded to move
      constructors which then leave the objects in a moved-from state. When
      the parameters are forwarded a second time that results in making new
      copies of moved-from iterators.  For libstdc++ debug mode iterators, the
      moved-from state is singular, which means copying them will abort at
      runtime.
      
      The fix is to make copies of iterator arguments instead of forwarding
      them.
      
      The callers of reverse_invoker::operator() also forward the iterators
      multiple times, but that's OK because reverse_invoker accepts them by
      forwarding reference but then breaks the chain of forwarding and copies
      them as lvalues.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/90276
      	* testsuite/util/pstl/test_utils.h (reverse_invoker): Do not use
      	perfect forwarding for iterator arguments.
      723a7c1a
    • Jakub Jelinek's avatar
      tree-ssa-math-opts: Fix is_widening_mult_rhs_p - unbreak bootstrap [PR113705] · a8f335cc
      Jakub Jelinek authored
      On Tue, Jan 30, 2024 at 07:33:10AM -0000, Roger Sayle wrote:
      +             wide_int bits = wide_int::from (tree_nonzero_bits (rhs),
      +                                             prec,
      +                                             TYPE_SIGN (TREE_TYPE (rhs)));
      ...
      > +               if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR
      > +                   && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST
      > +                   && wi::to_wide (gimple_assign_rhs2 (stmt))
      > +                      == wi::mask (hprec, false, prec))
      
      This change broke bootstrap on aarch64-linux.
      The problem can be seen even on the reduced testcase.
      
      The IL on the unreduced testcase before widening_mul has:
        # val_583 = PHI <val_26(13), val_164(40)>
      ...
        pretmp_266 = MEM[(const struct wide_int_storage *)&D.160657].len;
        _264 = pretmp_266 & 65535;
      ...
        _176 = (sizetype) val_583;
        _439 = (sizetype) _264;
        _284 = _439 * 8;
        _115 = _176 + _284;
      where 583/266/264 have unsigned int type and 176/439/284/115 have sizetype.
      widening_mul first turns that into:
        # val_583 = PHI <val_26(13), val_164(40)>
      ...
        pretmp_266 = MEM[(const struct wide_int_storage *)&D.160657].len;
        _264 = pretmp_266 & 65535;
      ...
        _176 = (sizetype) val_583;
        _439 = (sizetype) _264;
        _284 = _264 w* 8;
        _115 = _176 + _284;
      and then is_widening_mult_rhs_p is called, with type sizetype (64-bit),
      rhs _264, hprec 32 and prec 64.  Now tree_nonzero_bits (rhs) is
      65535, so bits is 64-bit wide_int 65535, stmt is BIT_AND_EXPR,
      but we ICE on the
      wi::to_wide (gimple_assign_rhs2 (stmt)) == wi::mask (hprec, false, prec)
      comparison because wi::to_wide on gimple_assign_rhs2 (stmt) - unsigned int
      65535 gives 32-bit wide_int 65535, while wi::mask (hprec, false, prec)
      gives 64-bit wide_int 0xffffffff and comparison between different precision
      wide_ints is forbidden.
      
      The following patch fixes it the same way how bits is computed earlier,
      by calling wide_int::from on the wi::to_wide (gimple_assign_rhs2 (stmt)),
      so we compare 64-bit 65535 with 64-bit 0xffffffff.
      
      2024-02-02  Jakub Jelinek  <jakub@redhat.com>
      
      	PR middle-end/113705
      	* tree-ssa-math-opts.cc (is_widening_mult_rhs_p): Use wide_int_from
      	around wi::to_wide in order to compare value in prec precision.
      
      	* g++.dg/opt/pr113705.C: New test.
      a8f335cc
    • Rainer Orth's avatar
      testsuite: i386: Fix gcc.target/i386/pr71321.c on Solaris/x86 · e5b14d95
      Rainer Orth authored
      gcc.target/i386/pr71321.c FAILs on 64-bit Solaris/x86 with the native
      assembler:
      
      FAIL: gcc.target/i386/pr71321.c scan-assembler-not lea.*0
      
      The problem is that /bin/as doesn't fully support cfi directives, so the
      .eh_frame section is specified explicitly, which includes ".long 0".
      The regular expression above includes ".*", which does multiline
      matches.  AFAICS those aren't needed here.
      
      This patch changes the RE not to use multiline patches.
      
      Tested on i386-pc-solaris2.11 (as and gas) and i686-pc-linux-gnu.
      
      2024-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	gcc/testsuite:
      	* gcc.target/i386/pr71321.c (scan-assembler-not): Avoid multiline
      	matches.
      e5b14d95
    • Jonathan Wakely's avatar
      libstdc++: Allow explicit conversion of string views with different traits · f60d7e1c
      Jonathan Wakely authored
      This was changed by LWG 3857.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/string_view (basic_string_view(R&&)): Remove
      	constraint that traits_type must be the same, as per LWG 3857.
      	* testsuite/21_strings/basic_string_view/cons/char/range_c++20.cc:
      	Explicit conversion between different specializations should be
      	allowed.
      	* testsuite/21_strings/basic_string_view/cons/wchar_t/range_c++20.cc:
      	Likewise.
      f60d7e1c
    • Jonathan Wakely's avatar
      libstdc++: Remove noexcept from std::osyncstream::operator= · 67f5a8c8
      Jonathan Wakely authored
      This should not be noexcept because its _M_syncbuf member has a
      potentially-throwing move assignment operator. The noexcept was removed
      by LWG 3867.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/syncstream (basic_osyncstream::operator=): Remove
      	noexcept, as per LWG 3867.
      67f5a8c8
    • Jonathan Wakely's avatar
      libstdc++: Remove noexcept from std::generator::promise_type::yield_value · 91adf218
      Jonathan Wakely authored
      This overload of std::generator::promise_type::yield_value calls things
      which might throw, so should not be noexcept. The noexcept was remove by
      LWG 3894.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/generator (promise_type::yield_value): Remove
      	noexcept from fourth overload, as per LWG 3894.
      91adf218
    • Rainer Orth's avatar
      testsuite: i386: Fix gcc.target/i386/sse2-stv-1.c on Solaris/x86 · a9e3818f
      Rainer Orth authored
      gcc.target/i386/sse2-stv-1.c FAILs on 32-bit Solaris/x86:
      
      FAIL: gcc.target/i386/sse2-stv-1.c scan-assembler-not %[er]sp
      FAIL: gcc.target/i386/sse2-stv-1.c scan-assembler-not shldl
      
      The test assumes the Linux/x86 default of -mno-stackrealign, while
      32-bit Solaris/x86 default to -mstackrealign.
      
      Fixed by explicitly specifying -mno-stackrealign.
      
      Tested on i386-pc-solaris2.11 and i686-pc-linux-gnu.
      
      2024-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	gcc/testsuite:
      	* gcc.target/i386/sse2-stv-1.c (dg-options): Add -mno-stackrealign.
      a9e3818f
    • Rainer Orth's avatar
      testsuite: i386: Restrict gcc.target/i386/pr80569.c to gas · 5487daff
      Rainer Orth authored
      gcc.target/i386/pr80569.c FAILs on Solaris/x86 with the native
      assembler:
      
      FAIL: gcc.target/i386/pr80569.c (test for excess errors)
      
      Excess errors:
      Assembler: pr80569.c
              "/var/tmp//ccm4_iqb.s", line 2 : Illegal mnemonic
              Near line: "    .code16gcc"
              "/var/tmp//ccm4_iqb.s", line 2 : Syntax error
              Near line: "    .code16gcc"
      
      .code16gcc is a gas extension, so restrict the test to gas.
      
      Tested on i386-pc-solaris2.11 (as and gas) and i686-pc-linux-gnu.
      
      2024-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	gcc/testsuite:
      	* gcc.target/i386/pr80569.c: Require gas.
      5487daff
    • Lehua Ding's avatar
      3e0b4953
    • Iain Sandoe's avatar
      testsuite, libphobos: Update link flags [PR112864]. · f4aa644d
      Iain Sandoe authored
      The regressions here are primarily from duplicated '-B' additions.
      
      We remove the duplicate on the link line.
      We also make sure that platforms with extensions other than .so for
      shared libs will have the correct paths.
      
      	PR target/112864
      
      libphobos/ChangeLog:
      
      	* testsuite/lib/libphobos.exp: Use ${shlib_ext} instead of
      	hard-wiring '.so'.
      	* testsuite/testsuite_flags.in: Remove duplicate -B option
      	for spec file path.
      f4aa644d
    • Iain Sandoe's avatar
      testsuite, Objective-C++: Update link flags [PR112863]. · bec71004
      Iain Sandoe authored
      These regressions are caused by missing or duplicate runpaths which
      now fire linker warnings.
      
      We need to add options to locate libobjc (and on Darwin libobjc-gnu)
      along with libstdc++.
      Usually '-L' options are added to point to the relevant directories for
      the uninstalled libraries.
      
      In cases where libraries are available as both shared and convenience
      some additional checks are made.
      
      For some targets -static-xxxx options are handled by specs substitution
      and need a '-B' option rather than '-L'.  For Darwin, when embedded
      runpaths are in use (the default for all versions after macOS 10.11),
      '-B' is also needed to provide the runpath.
      
      When '-B' is used, this results in a '-L' for each path that exists (so
      that appending a '-L' as well is a needless duplicate).  There are also
      cases where tools warn for duplicates, leading to spurious fails.
      
      	PR target/112863
      
      gcc/testsuite/ChangeLog:
      
      	* lib/obj-c++.exp: Decide on whether to present -B or -L to
      	reference the paths to uninstalled libobjc/libobjc-gnu and
      	libstdc++ and use that to generate the link flags.
      bec71004
    • Iain Sandoe's avatar
      testsuite, gfortran: Update link flags [PR112862]. · e439c782
      Iain Sandoe authored
      The regressions here are caused by two issues:
      1. In some cases there is no generated runpath for libatomic
      2. In other cases there are duplicate paths.
      
      This patch simplifies the addition of the options in the main
      gfortran exp and removes the duplicates elewhere.
      
      We need to add options to locate libgfortran and the dependent libs
      libquadmath (supporting REAL*16) and libatomic (supporting operations
      used by coarrays).  Usually '-L' options are added to point to the
      relevant directories for the uninstalled libraries.
      
      In cases where libraries are available as both shared and convenience
      some additional checks are made.
      
      For some targets -static-xxxx options are handled by specs substitution
      and need a '-B' option rather than '-L'.  For Darwin, when embedded
      runpaths are in use (the default for all versions after macOS 10.11),
      '-B' is also needed to provide the runpath.
      
      When '-B' is used, this results in a '-L' for each path that exists (so
      that appending a '-L' as well is a needless duplicate).  There are also
      cases where tools warn for duplicates, leading to spurious fails.
      
      	PR target/112862
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/coarray/caf.exp: Remove duplicate additions of
      	libatomic handling.
      	* gfortran.dg/dg.exp: Likewise.
      	* lib/gfortran.exp: Decide on whether to present -B or -L to
      	reference the paths to uninstalled libgfortran, libqadmath and
      	libatomic and use that to generate the link flags.
      e439c782
    • Juzhe-Zhong's avatar
      RISC-V: Allow LICM hoist POLY_INT configuration code sequence · 74489c19
      Juzhe-Zhong authored
      Realize in recent benchmark evaluation (coremark-pro zip-test):
      
              vid.v   v2
              vmv.v.i v5,0
      .L9:
              vle16.v v3,0(a4)
              vrsub.vx        v4,v2,a6   ---> LICM failed to hoist it outside the loop.
      
      The root cause is:
      
      (insn 56 47 57 4 (set (subreg:DI (reg:HI 220) 0)
              (reg:DI 223)) "rvv.c":11:9 208 {*movdi_64bit}  -> Its result used by the following vrsub.vx then supress the hoist of the vrsub.vx
           (nil))
      
      (insn 57 56 59 4 (set (reg:RVVMF2HI 216)
              (if_then_else:RVVMF2HI (unspec:RVVMF32BI [
                          (const_vector:RVVMF32BI repeat [
                                  (const_int 1 [0x1])
                              ])
                          (reg:DI 350)
                          (const_int 2 [0x2]) repeated x2
                          (const_int 1 [0x1])
                          (reg:SI 66 vl)
                          (reg:SI 67 vtype)
                      ] UNSPEC_VPREDICATE)
                  (minus:RVVMF2HI (vec_duplicate:RVVMF2HI (reg:HI 220))
                      (reg:RVVMF2HI 217))
                  (unspec:RVVMF2HI [
                          (reg:DI 0 zero)
                      ] UNSPEC_VUNDEF))) "rvv.c":11:9 6938 {pred_subrvvmf2hi_reverse_scalar}
           (expr_list:REG_DEAD (reg:HI 220)
              (nil)))
      
      This patch fixes it generate (set (reg:HI) (subreg:HI (reg:DI))) instead of (set (subreg:DI (reg:DI)) (reg:DI)).
      
      After this patch:
      
      	vid.v	v2
      	vrsub.vx	v2,v2,a7
      	vmv.v.i	v4,0
      .L3:
      	vle16.v	v3,0(a4)
      
      Tested on both RV32 and RV64 no regression.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv.cc (riscv_legitimize_move): Fix poly_int dest generation.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/poly_licm-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/poly_licm-2.c: New test.
      74489c19
    • Rainer Orth's avatar
      testsuite: i386: Fix gcc.target/i386/pieces-memcpy-7.c etc. on Solaris/x86 · 8939854a
      Rainer Orth authored
      gcc.target/i386/pieces-memcpy-7.c etc. FAIL on 32-bit Solaris/x86:
      
      FAIL: gcc.target/i386/pieces-memcpy-7.c scan-assembler-not %[re]bp
      FAIL: gcc.target/i386/pieces-memcpy-8.c scan-assembler-not %[re]bp
      FAIL: gcc.target/i386/pieces-memcpy-9.c scan-assembler-not %[re]bp
      FAIL: gcc.target/i386/pieces-memset-36.c scan-assembler-not %[re]bp
      FAIL: gcc.target/i386/pieces-memset-40.c scan-assembler-not %[re]bp
      FAIL: gcc.target/i386/pieces-memset-9.c scan-assembler-not %[re]bp
      
      The problem is that the tests assume -mno-stackrealign while 32-bit
      Solaris/x86 defaults to -mstackrealign.
      
      Fixed by explicitly specifying -mno-stackrealign.
      
      Tested on i386-pc-solaris2.11 and i686-pc-linux-gnu.
      
      2024-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	gcc/testsuite:
      	* gcc.target/i386/pieces-memcpy-7.c (dg-additional-options): Add
      	-mno-stackrealign.
      	* gcc.target/i386/pieces-memcpy-8.c: Likewise.
      	* gcc.target/i386/pieces-memcpy-9.c: Likewise.
      	* gcc.target/i386/pieces-memset-36.c: Likewise.
      	* gcc.target/i386/pieces-memset-40.c: Likewise.
      	* gcc.target/i386/pieces-memset-9.c: Likewise.
      8939854a
    • Rainer Orth's avatar
      testsuite: i386: Fix gcc.target/i386/apx-ndd-cmov.c on Solaris/x86 · 63f0907b
      Rainer Orth authored
      gcc.target/i386/apx-ndd-cmov.c FAILs on 64-bit Solaris/x86 with the
      native assembler:
      
      FAIL: gcc.target/i386/apx-ndd-cmov.c scan-assembler-times cmove[^\\n\\r]*, %eax 1
      FAIL: gcc.target/i386/apx-ndd-cmov.c scan-assembler-times cmovge[^\\n\\r]*, %eax 1
      
      The gas vs. as difference is
      
      -       cmove   c+4(%rip), %esi, %eax
      +       cmovl.e c+4(%rip), %esi, %eax
      
      -       cmovge  %ecx, %edx, %eax
      +       cmovl.ge        %ecx, %edx, %eax
      
      This patch accounts for both forms.
      
      Tested on i386-pc-solaris2.11 (as and gas) and i686-pc-linux-gnu.
      
      2024-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	gcc/testsuite:
      	* gcc.target/i386/apx-ndd-cmov.c (scan-assembler-times): Allow for
      	cmovl.e, cmovl.ge.
      63f0907b
    • Sandra Loosemore's avatar
      MAINTAINERS: Update my e-mail address. · 56891a20
      Sandra Loosemore authored
      ChangeLog/
      	* MAINTAINERS: Update my e-mail address.
      56891a20
    • Jason Merrill's avatar
      c++: no_unique_address and constexpr [PR112439] · f4998609
      Jason Merrill authored
      Here, because we don't build a CONSTRUCTOR for an empty base, we were
      wrongly marking the Foo CONSTRUCTOR as complete after initializing the Empty
      member.  Fixed by checking empty_base here as well.
      
      	PR c++/112439
      
      gcc/cp/ChangeLog:
      
      	* constexpr.cc (cxx_eval_store_expression): Check empty_base
      	before marking a CONSTRUCTOR readonly.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp2a/no_unique_address15.C: New test.
      f4998609
    • Jason Merrill's avatar
      c++: variable template array of unknown bound [PR113638] · 0b786ff3
      Jason Merrill authored
      When we added variable templates, we didn't extend the VAR_HAD_UNKNOWN_BOUND
      handling for class template static data members to handle them as well.
      
      	PR c++/113638
      
      gcc/cp/ChangeLog:
      
      	* cp-tree.h: Adjust comment.
      	* pt.cc (instantiate_template): Set VAR_HAD_UNKNOWN_BOUND for
      	variable template.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp1y/var-templ-array1.C: New test.
      0b786ff3
    • Pan Li's avatar
      RISC-V: Cleanup the comments for the psabi · e0701f8f
      Pan Li authored
      
      This patch would like to cleanup some comments which are out of date or incorrect.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv.cc (riscv_get_arg_info): Cleanup comments.
      	(riscv_pass_by_reference): Ditto.
      	(riscv_fntype_abi): Ditto.
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      e0701f8f
    • Juzhe-Zhong's avatar
      RISC-V: Remove vsetvl_pre bogus instructions in VSETVL PASS · 22622a5a
      Juzhe-Zhong authored
      I realize there is a RTL regression between GCC-14 and GCC-13.
      https://godbolt.org/z/Ga7K6MqaT
      
      GCC-14:
      (insn 9 13 31 2 (set (reg:DI 15 a5 [138])
              (unspec:DI [
                      (const_int 64 [0x40])
                  ] UNSPEC_VLMAX)) "/app/example.c":5:15 2566 {vlmax_avldi}
           (expr_list:REG_EQUIV (unspec:DI [
                      (const_int 64 [0x40])
                  ] UNSPEC_VLMAX)
              (nil)))
      (insn 31 9 10 2 (parallel [
                  (set (reg:DI 15 a5 [138])
                      (unspec:DI [
                              (reg:DI 0 zero)
                              (const_int 32 [0x20])
                              (const_int 7 [0x7])
                              (const_int 1 [0x1]) repeated x2
                          ] UNSPEC_VSETVL))
                  (set (reg:SI 66 vl)
                      (unspec:SI [
                              (reg:DI 0 zero)
                              (const_int 32 [0x20])
                              (const_int 7 [0x7])
                          ] UNSPEC_VSETVL))
                  (set (reg:SI 67 vtype)
                      (unspec:SI [
                              (const_int 32 [0x20])
                              (const_int 7 [0x7])
                              (const_int 1 [0x1]) repeated x2
                          ] UNSPEC_VSETVL))
              ]) "/app/example.c":5:15 3281 {vsetvldi}
           (nil))
      
      GCC-13:
      (insn 10 7 26 2 (set (reg/f:DI 11 a1 [139])
              (plus:DI (reg:DI 11 a1 [142])
                  (const_int 800 [0x320]))) "/app/example.c":6:32 5 {adddi3}
           (nil))
      (insn 26 10 9 2 (parallel [
                  (set (reg:DI 15 a5)
                      (unspec:DI [
                              (reg:DI 0 zero)
                              (const_int 32 [0x20])
                              (const_int 7 [0x7])
                              (const_int 1 [0x1]) repeated x2
                          ] UNSPEC_VSETVL))
                  (set (reg:SI 66 vl)
                      (unspec:SI [
                              (reg:DI 0 zero)
                              (const_int 32 [0x20])
                              (const_int 7 [0x7])
                          ] UNSPEC_VSETVL))
                  (set (reg:SI 67 vtype)
                      (unspec:SI [
                              (const_int 32 [0x20])
                              (const_int 7 [0x7])
                              (const_int 1 [0x1]) repeated x2
                          ] UNSPEC_VSETVL))
              ]) "/app/example.c":5:15 792 {vsetvldi}
           (nil))
      
      GCC-13 doesn't have:
      (insn 9 13 31 2 (set (reg:DI 15 a5 [138])
              (unspec:DI [
                      (const_int 64 [0x40])
                  ] UNSPEC_VLMAX)) "/app/example.c":5:15 2566 {vlmax_avldi}
           (expr_list:REG_EQUIV (unspec:DI [
                      (const_int 64 [0x40])
                  ] UNSPEC_VLMAX)
              (nil)))
      
      vsetvl_pre doesn't emit any assembler which is just used for occupying scalar register.
      It should be removed in VSETVL PASS.
      
      Tested on both RV32 and RV64 no regression.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vsetvl.cc (vsetvl_pre_insn_p): New function.
      	(pre_vsetvl::cleaup): Remove vsetvl_pre.
      	(pre_vsetvl::remove_vsetvl_pre_insns): New function.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/vsetvl/vsetvl_pre-1.c: New test.
      22622a5a
    • Jiahao Xu's avatar
      LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions · 92acc92e
      Jiahao Xu authored
      gcc/ChangeLog:
      
      	* config/loongarch/larchintrin.h
      	(__frecipe_s): Update function return type.
      	(__frecipe_d): Ditto.
      	(__frsqrte_s): Ditto.
      	(__frsqrte_d): Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/loongarch/larch-frecipe-intrinsic.c: New test.
      92acc92e
Loading