]> gcc.gnu.org Git - gcc.git/log
gcc.git
13 months agoRISC-V: Update Types for RISC-V Instructions
Edwin Lu [Mon, 11 Sep 2023 16:57:37 +0000 (09:57 -0700)]
RISC-V: Update Types for RISC-V Instructions

Adds types to riscv instructions that were added or were
missed by the original patch
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628996.html

gcc/ChangeLog:

* config/riscv/riscv.md: Update types

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
13 months agoRISC-V: Add Types to Un-Typed Zicond Instructions
Edwin Lu [Mon, 11 Sep 2023 16:56:06 +0000 (09:56 -0700)]
RISC-V: Add Types to Un-Typed Zicond Instructions

Creates a new "zicond" type and updates all zicond instructions
with that type.

gcc/ChangeLog:

* config/riscv/riscv.md: Add "zicond" type
* config/riscv/zicond.md: Update types

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
13 months agoRISC-V: Add Types for Un-Typed zc Instructions
Edwin Lu [Mon, 11 Sep 2023 16:52:04 +0000 (09:52 -0700)]
RISC-V: Add Types for Un-Typed zc Instructions

Adds types to the untyped zc instructions. Creates a new
types "pushpop" and "mvpair" for now

gcc/ChangeLog:

* config/riscv/riscv.md: Add "pushpop" and "mvpair" types
* config/riscv/zc.md: Update types

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
13 months agoRISC-V: Update Types for Vector Instructions
Edwin Lu [Mon, 11 Sep 2023 16:47:02 +0000 (09:47 -0700)]
RISC-V: Update Types for Vector Instructions

Adds types to vector instructions that were added after or were
missed by the original patch
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628594.html

gcc/ChangeLog:

* config/riscv/autovec-opt.md: Update types
* config/riscv/autovec.md: likewise

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
13 months agos390: Fix some builtin definitions
Stefan Schulze Frielinghaus [Mon, 11 Sep 2023 16:11:39 +0000 (18:11 +0200)]
s390: Fix some builtin definitions

gcc/ChangeLog:

* config/s390/s390-builtins.def (s390_vec_signed_flt): Fix
builtin flag.
(s390_vec_unsigned_flt): Ditto.
(s390_vec_revb_flt): Ditto.
(s390_vec_reve_flt): Ditto.
(s390_vclfnhs): Fix operand flags.
(s390_vclfnls): Ditto.
(s390_vcrnfs): Ditto.
(s390_vcfn): Ditto.
(s390_vcnf): Ditto.

13 months agos390: Fix builtins vec_rli and verll
Stefan Schulze Frielinghaus [Mon, 11 Sep 2023 16:11:31 +0000 (18:11 +0200)]
s390: Fix builtins vec_rli and verll

The second argument of these builtins is an unsigned immediate.  For
vec_rli the API allows immediates up to 64 bits whereas the instruction
verll only allows immediates up to 32 bits.  Since the shift count
equals the immediate modulo vector element size, truncating those
immediates is fine.

Passing a non-immediate argument to vec_rli already results in an error
message without this patch:

t.c: In function ‘foo’:
t.c:7:10: error: invalid argument 2 for builtin ‘__builtin_s390_verllf’
    7 |   return __builtin_s390_vec_rli (v, x);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Whereas with this patch

t.c: In function 'foo':
t.c:7:10: error: constant value required for builtin '__builtin_s390_verllf' argument 2
    7 |   return __builtin_s390_vec_rli (v, x);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the error message, generated by s390_const_operand_ok, clearly speaks
about a constant argument value.

gcc/ChangeLog:

* config/s390/s390-builtins.def (O_U64): New.
(O1_U64): Ditto.
(O2_U64): Ditto.
(O3_U64): Ditto.
(O4_U64): Ditto.
(O_M12): Change bit position.
(O_S2): Ditto.
(O_S3): Ditto.
(O_S4): Ditto.
(O_S5): Ditto.
(O_S8): Ditto.
(O_S12): Ditto.
(O_S16): Ditto.
(O_S32): Ditto.
(O_ELEM): Ditto.
(O_LIT): Ditto.
(OB_DEF_VAR): Add operand constraints.
(B_DEF): Ditto.
* config/s390/s390.cc (s390_const_operand_ok): Honour 64 bit
operands.

13 months agolibstdc++: Remove unconditional use of atomics in Debug Mode
Jonathan Wakely [Mon, 11 Sep 2023 15:42:54 +0000 (16:42 +0100)]
libstdc++: Remove unconditional use of atomics in Debug Mode

The fix for PR 91910 (r10-3426-gf7a3a382279585) introduced unconditional
uses of atomics into src/c++11/debug.cc, which causes linker errors for
arm4t where GCC emits an unresolved reference to __sync_synchronize.

By making the uses of atomics depend on _GLIBCXX_HAS_GTHREADS we can
avoid those unconditional references to __sync_synchronize for targets
where the atomics are unnecessary. As a minor performance optimization
we can also check the __gnu_cxx::__is_single_threaded function to avoid
atomics for single-threaded programs even where they don't cause linker
errors.

libstdc++-v3/ChangeLog:

* src/c++11/debug.cc (acquire_sequence_ptr_for_lock): New
function.
(reset_sequence_ptr): New function.
(_Safe_iterator_base::_M_detach)
(_Safe_local_iterator_base::_M_detach): Replace bare atomic_load
with acquire_sequence_ptr_for_lock.
(_Safe_iterator_base::_M_reset): Replace bare atomic_store with
reset_sequence_ptr.

13 months agolibstdc++: Move __glibcxx_assert_fail to its own file
Jonathan Wakely [Mon, 11 Sep 2023 14:58:48 +0000 (15:58 +0100)]
libstdc++: Move __glibcxx_assert_fail to its own file

This avoids a dependency on the other symbols in src/c++11/debug.o when
linking statically to libstdc++.a without using -Wl,--gc-sections.

libstdc++-v3/ChangeLog:

* src/c++11/Makefile.am: Add new file.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/debug.cc (__glibcxx_assert_fail): Move to ...
* src/c++11/assert_fail.cc: New file.

13 months agolibstdc++: Define _GLIBCXX_USE_BUILTIN_TRAIT
Ken Matsui [Tue, 18 Jul 2023 22:24:50 +0000 (15:24 -0700)]
libstdc++: Define _GLIBCXX_USE_BUILTIN_TRAIT

This patch defines _GLIBCXX_USE_BUILTIN_TRAIT macro, which will be used
as a flag 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/bits/c++config (_GLIBCXX_HAS_BUILTIN): Do not undef.
(_GLIBCXX_USE_BUILTIN_TRAIT): Define.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
13 months agogccrs: move functions from rust-gcc-diagnostics to rust-diagnostics.cc
Parthib [Tue, 31 Jan 2023 13:15:01 +0000 (18:45 +0530)]
gccrs: move functions from rust-gcc-diagnostics to rust-diagnostics.cc

gcc/rust/ChangeLog:

* Make-lang.in: Removed rust-gcc-diagnostics object file.
* rust-diagnostics.cc (rust_be_get_quotechars): Added from original file.
(rust_be_internal_error_at): Likewise.
(rust_be_error_at): Likewise.
(class rust_error_code_rule): Likewise.
(rust_be_warning_at): Likewise.
(rust_be_fatal_error): Likewise.
(rust_be_inform): Likewise.
(rust_be_debug_p): Likewise.

* rust-gcc-diagnostics.cc: Removed.

Signed-off-by: Parthib Datta <parthibdutta02@gmail.com>
13 months agoMATCH: [PR111349] add missing :c to cmp in the `(a CMP CST1) ? max<a,CST2> : a` pattern
Andrew Pinski [Mon, 11 Sep 2023 04:58:12 +0000 (21:58 -0700)]
MATCH: [PR111349] add missing :c to cmp in the `(a CMP CST1) ? max<a,CST2> : a` pattern

When I added this pattern in r14-1411-g17cca3c43e2f49, I had missed the :c on the cmp
part of the pattern meaning there might be some missing optimizations happening.
The testcase shows an example of the missed optmization.

Committed as obvious after a bootstrap/test on x86_64-linux-gnu.

PR tree-optimization/111349

gcc/ChangeLog:

* match.pd (`(a CMP CST1) ? max<a,CST2> : a`): Add :c on
the cmp part of the pattern.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/minmax-25.c: New test.

13 months agolibstdc++: Formatting std::thread::id and std::stacktrace (P2693R1)
Jonathan Wakely [Wed, 16 Aug 2023 16:10:51 +0000 (17:10 +0100)]
libstdc++: Formatting std::thread::id and std::stacktrace (P2693R1)

New std::formatter specializations for C++23.

libstdc++-v3/ChangeLog:

* include/bits/version.def (__cpp_lib_formatters): Define.
* include/bits/version.h: Regenerate.
* include/std/stacktrace (formatter<stacktrace_entry>)
(formatter<basic_stacktrace<Alloc>>): Define.
* include/std/thread (formatter<thread::id, charT>): Define.
* testsuite/19_diagnostics/stacktrace/output.cc: New test.
* testsuite/19_diagnostics/stacktrace/synopsis.cc: Add
std::formatter specializations.
* testsuite/19_diagnostics/stacktrace/version.cc: Check
__cpp_lib_formatters macro.
* testsuite/30_threads/thread/id/hash.cc: Remove gthreads
dependency.
* testsuite/30_threads/thread/id/operators.cc: Likewise.
* testsuite/30_threads/thread/id/operators_c++20.cc: Likewise.
* testsuite/30_threads/thread/id/output.cc: New test.

13 months agoRISC-V: Enable RVV scalable vectorization by default[PR111311]
Juzhe-Zhong [Thu, 7 Sep 2023 07:28:31 +0000 (15:28 +0800)]
RISC-V: Enable RVV scalable vectorization by default[PR111311]

This patch is not ready but they all will be fixed very soon.

gcc/ChangeLog:

PR target/111311
* config/riscv/riscv.opt: Set default as scalable vectorization.

13 months agolibstdc++: Fix -Wunused-parameter warnings
Pekka Seppänen [Thu, 7 Sep 2023 19:30:00 +0000 (22:30 +0300)]
libstdc++: Fix -Wunused-parameter warnings

Fix -Wunused-parameter warnings when _GLIBCXX_USE_WCHAR_T is not
defined.

libstdc++-v3/ChangeLog:

* src/c++11/cow-locale_init.cc: Add [[maybe_unused]] attribute.
* src/c++17/fs_path.cc (path::_S_convert_loc): Likewise.
* src/filesystem/path.cc (path::_S_convert_loc): Likewise.

Signed-off-by: Pekka Seppänen <pexu@gcc.mail.kapsi.fi>
13 months agocontrib: Check if getent is available in git setup script [PR111359]
Jonathan Wakely [Mon, 11 Sep 2023 10:36:04 +0000 (11:36 +0100)]
contrib: Check if getent is available in git setup script [PR111359]

contrib/ChangeLog:

PR other/111359
* gcc-git-customization.sh: Check for getent before using it.
Use id on macOS.

13 months agoRISC-V: Remove redundant functions
Juzhe-Zhong [Mon, 11 Sep 2023 09:19:30 +0000 (17:19 +0800)]
RISC-V: Remove redundant functions

I just finished V2 version of LMUL cost model.
Turns out we don't these redundant functions.

Remove them.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (get_all_predecessors): Remove.
(get_all_successors): Ditto.
* config/riscv/riscv-v.cc (get_all_predecessors): Ditto.
(get_all_successors): Ditto.

13 months agopretty-print: Fix up pp_wide_int [PR111329]
Jakub Jelinek [Mon, 11 Sep 2023 09:08:41 +0000 (11:08 +0200)]
pretty-print: Fix up pp_wide_int [PR111329]

The recent pp_wide_int changes for _BitInt support (because not all
wide_ints fit into the small fixed size digit_buffer anymore) apparently
broke
+FAIL: gcc.dg/analyzer/out-of-bounds-diagram-1-debug.c (test for excess errors)
+FAIL: gcc.dg/analyzer/out-of-bounds-diagram-1-debug.c 2 blank line(s) in output
+FAIL: gcc.dg/analyzer/out-of-bounds-diagram-1-debug.c expected multiline pattern lines 17-39
(and I couldn't reproduce that in bisect seed (which is -O0 compiled) and
thought it would be some analyzer diagnostic bug).

The problem is that analyzer uses pp_wide_int with a function call in the
second argument.  Previously, when pp_wide_int macro just did
  print_dec (W, pp_buffer (PP)->digit_buffer, SGN);
  pp_string (PP, pp_buffer (PP)->digit_buffer);
it worked, because the const wide_int_ref & first argument to print_dec
bound to a temporary, which was only destructed at the end of the full
statement after print_dec was called.
But with my changes where I need to first compare the precision of the
const wide_int_ref & to decide whether to use digit_buffer or XALLOCAVEC
something larger, this means that pp_wide_int_ref binds to a temporary
which is destroyed at the end of full statement which is the
  const wide_int_ref &pp_wide_int_ref = (W);
declaration, so then invokes UB accessing a destructed temporary.

The following patch fixes it by rewriting pp_wide_int into an inline
function, so that the end of the full statement is the end of the inline
function call.  As functions using alloca aren't normally inlined, I've
also split that part into a separate out of line function.  Putting that
into pretty-print.cc didn't work, e.g. the gm2 binary doesn't link,
because pretty-print.o is in libcommon.a, but wide-print-print.o which
defines print_dec is not.  So I've put that out of line function into
wide-int-print.cc instead.

2023-09-11  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/111329
* pretty-print.h (pp_wide_int): Rewrite from macro into inline
function.  For printing values which don't fit into digit_buffer
use out-of-line function.
* wide-int-print.h (pp_wide_int_large): Declare.
* wide-int-print.cc: Include pretty-print.h.
(pp_wide_int_large): Define.

13 months agoRISC-V: Use dominance analysis in global vsetvl elimination
Juzhe-Zhong [Mon, 11 Sep 2023 03:33:59 +0000 (11:33 +0800)]
RISC-V: Use dominance analysis in global vsetvl elimination

I found that it's more reasonable to use existing dominance analysis.

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (pass_vsetvl::global_eliminate_vsetvl_insn):
Use dominance analysis.
(pass_vsetvl::init): Ditto.
(pass_vsetvl::done): Ditto.

13 months agoRISC-V: Add VLS modes VEC_PERM support[PR111311]
Juzhe-Zhong [Mon, 11 Sep 2023 03:25:02 +0000 (11:25 +0800)]
RISC-V: Add VLS modes VEC_PERM support[PR111311]

This patch add VLS modes VEC_PERM support which fix these following
FAILs in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111311:

FAIL: gcc.dg/tree-ssa/forwprop-40.c scan-tree-dump-times optimized "BIT_FIELD_REF" 0
FAIL: gcc.dg/tree-ssa/forwprop-40.c scan-tree-dump-times optimized "BIT_INSERT_EXPR" 0
FAIL: gcc.dg/tree-ssa/forwprop-41.c scan-tree-dump-times optimized "BIT_FIELD_REF" 0
FAIL: gcc.dg/tree-ssa/forwprop-41.c scan-tree-dump-times optimized "BIT_INSERT_EXPR" 1

These FAILs are fixed after this patch.

PR target/111311

gcc/ChangeLog:

* config/riscv/autovec.md: Add VLS modes.
* config/riscv/riscv-protos.h (cmp_lmul_le_one): New function.
(cmp_lmul_gt_one): Ditto.
* config/riscv/riscv-v.cc (cmp_lmul_le_one): Ditto.
(cmp_lmul_gt_one): Ditto.
* config/riscv/riscv.cc (riscv_print_operand): Add VLS modes.
(riscv_vectorize_vec_perm_const): Ditto.
* config/riscv/vector-iterators.md: Ditto.
* config/riscv/vector.md: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/slp-1.c: Adapt test.
* gcc.target/riscv/rvv/autovec/partial/slp-16.c: Ditto.
* gcc.target/riscv/rvv/autovec/partial/slp-17.c: Ditto.
* gcc.target/riscv/rvv/autovec/partial/slp-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/partial/slp-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/compress-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/compress-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/compress-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/compress-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/compress-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/compress-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/merge-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/merge-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/merge-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/merge-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/merge-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/merge-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/merge-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls/perm-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/perm-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/perm-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/perm-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/perm-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/perm-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/perm-7.c: New test.

13 months agoRISC-V: Add missing VLS mask bool mode reg -> reg patterns
Juzhe-Zhong [Mon, 11 Sep 2023 03:22:26 +0000 (11:22 +0800)]
RISC-V: Add missing VLS mask bool mode reg -> reg patterns

Committed.

gcc/ChangeLog:

* config/riscv/autovec-vls.md (*mov<mode>_vls): New pattern.
* config/riscv/vector-iterators.md: New iterator

13 months agoMATCH: [PR111346] `X CMP MINMAX` pattern missing :c on CMP
Andrew Pinski [Sun, 10 Sep 2023 22:59:41 +0000 (15:59 -0700)]
MATCH: [PR111346] `X CMP MINMAX` pattern missing :c on CMP

I noticed this while working on other MINMAX optimizations. It was
hard to find a simplified testcase though because it was dependent on
the ssa name versions. Adding the `:c` to cmp allows the pattern to
be match for the case where minmax as the first operand of the comparison
rather than the second.

Committed as obvious after a bootstrap/test on x86_64-linux-gnu.

PR tree-optimization/111346

gcc/ChangeLog:

* match.pd (`X CMP MINMAX`): Add `:c` on the cmp part
of the pattern

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/minmaxcmp-1.c: New test.

13 months agoRemove constraint modifier % for fcmaddcph/fmaddcph/fcmulcph since there're not commu...
liuhongt [Fri, 8 Sep 2023 01:22:43 +0000 (09:22 +0800)]
Remove constraint modifier % for fcmaddcph/fmaddcph/fcmulcph since there're not commutative.

gcc/ChangeLog:

PR target/111306
PR target/111335
* config/i386/sse.md (int_comm): New int_attr.
(fma_<complexopname>_<mode><sdc_maskz_name><round_name>):
Remove % for Complex conjugate operations since they're not
commutative.
(fma_<complexpairopname>_<mode>_pair): Ditto.
(<avx512>_<complexopname>_<mode>_mask<round_name>): Ditto.
(cmul<conj_op><mode>3): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr111306.c: New test.

13 months agoDaily bump.
GCC Administrator [Mon, 11 Sep 2023 00:16:59 +0000 (00:16 +0000)]
Daily bump.

13 months agoRISC-V: Expand fixed-vlmax/vls vector permutation in targethook
Juzhe-Zhong [Sun, 10 Sep 2023 02:33:04 +0000 (10:33 +0800)]
RISC-V: Expand fixed-vlmax/vls vector permutation in targethook

When debugging FAIL: gcc.dg/pr92301.c execution test.
Realize a vls vector permutation situation failed to vectorize since early return false:

-  /* For constant size indices, we dont't need to handle it here.
-     Just leave it to vec_perm<mode>.  */
-  if (d->perm.length ().is_constant ())
-    return false;

To avoid more potential failed vectorization case. Now expand it in targethook.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_generic_patterns): Expand
fixed-vlmax/vls vector permutation.

13 months agoRISC-V: Avoid unnecessary slideup in compress pattern of vec_perm
Juzhe-Zhong [Sun, 10 Sep 2023 14:07:10 +0000 (22:07 +0800)]
RISC-V: Avoid unnecessary slideup in compress pattern of vec_perm

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_compress_patterns): Avoid unnecessary slideup.

13 months agoFix PR 111331: wrong code for `a > 28 ? MIN<a, 28> : 29`
Andrew Pinski [Fri, 8 Sep 2023 05:13:31 +0000 (22:13 -0700)]
Fix PR 111331: wrong code for `a > 28 ? MIN<a, 28> : 29`

The problem here is after r6-7425-ga9fee7cdc3c62d0e51730,
the comparison to see if the transformation could be done was using the
wrong value. Instead of see if the inner was LE (for MIN and GE for MAX)
the outer value, it was comparing the inner to the value used in the comparison
which was wrong.
The match pattern copied the same logic mistake when they were added in
r14-1411-g17cca3c43e2f49 .

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR tree-optimization/111331
* match.pd (`(a CMP CST1) ? max<a,CST2> : a`):
Fix the LE/GE comparison to the correct value.
* tree-ssa-phiopt.cc (minmax_replacement):
Fix the LE/GE comparison for the
`(a CMP CST1) ? max<a,CST2> : a` optimization.

gcc/testsuite/ChangeLog:

PR tree-optimization/111331
* gcc.c-torture/execute/pr111331-1.c: New test.
* gcc.c-torture/execute/pr111331-2.c: New test.
* gcc.c-torture/execute/pr111331-3.c: New test.

13 months agoDarwin: Partial reversion of r14-3648 (Inits Section).
Iain Sandoe [Sun, 10 Sep 2023 13:48:42 +0000 (14:48 +0100)]
Darwin: Partial reversion of r14-3648 (Inits Section).

Although the Darwin ABI places both hot and cold partitions in the same
section (the linker can partition by name), this does not work with the
current dwarf2out implementation.

Since we do see global initialization code getting hot/cold splits, this
patch places the cold parts into text_cold, and keeps the hot part in
the correct Init section per ABI.

TODO: figure out a way to allow us to match the ABI fully.

gcc/ChangeLog:

* config/darwin.cc (darwin_function_section): Place unlikely
executed global init code into the standard cold section.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
13 months agoRISC-V: Fix dump FILE of VSETVL PASS[PR111311]
Juzhe-Zhong [Sat, 9 Sep 2023 23:57:44 +0000 (07:57 +0800)]
RISC-V: Fix dump FILE of VSETVL PASS[PR111311]

To make the dump FILE not too big, add TDF_DETAILS.

This patch fix these following FAILs in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111311

FAIL: gcc.c-torture/unsorted/dump-noaddr.c.*r.vsetvl,  -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  comparison
FAIL: gcc.c-torture/unsorted/dump-noaddr.c.*r.vsetvl,  -O3 -g  comparison

gcc/ChangeLog:

PR target/111311
* config/riscv/riscv-vsetvl.cc (pass_vsetvl::vsetvl_fusion): Add TDF_DETAILS.
(pass_vsetvl::pre_vsetvl): Ditto.
(pass_vsetvl::init): Ditto.
(pass_vsetvl::lazy_vsetvl): Ditto.

13 months agoDaily bump.
GCC Administrator [Sun, 10 Sep 2023 00:16:34 +0000 (00:16 +0000)]
Daily bump.

13 months agoanalyzer: Move gcc.dg/analyzer tests to c-c++-common (2) [PR96395]
benjamin priour [Sat, 9 Sep 2023 16:03:56 +0000 (18:03 +0200)]
analyzer: Move gcc.dg/analyzer tests to c-c++-common (2) [PR96395]

Second batch of moving tests from under gcc.dg/analyzer into
c-c++-common/analyzer.

Prior to this patch the analyzer was not unwrapping ordering
binop_svalue, such as LT_EXPR, when evaluating conditions.

Therefore when an ordering conditional was stored, the analyzer
was missing out on some constraints, which led to false positives.

gcc/analyzer/ChangeLog:

PR analyzer/96395
* region-model.cc
(region_model::add_constraints_from_binop): binop_svalues around
LT_EXPR, LE_EXPR, GT_EXPR, GE_EXPR are now unwrapped.

gcc/testsuite/ChangeLog:

PR analyzer/96395
* gcc.dg/analyzer/allocation-size-1.c: Moved to...
* c-c++-common/analyzer/allocation-size-1.c: ...here.
* gcc.dg/analyzer/allocation-size-2.c: Moved to...
* c-c++-common/analyzer/allocation-size-2.c: ...here.
* gcc.dg/analyzer/allocation-size-3.c: Moved to...
* c-c++-common/analyzer/allocation-size-3.c: ...here.
* gcc.dg/analyzer/allocation-size-4.c: Moved to...
* c-c++-common/analyzer/allocation-size-4.c: ...here.
* gcc.dg/analyzer/analyzer-verbosity-0.c: Moved to...
* c-c++-common/analyzer/analyzer-verbosity-0.c: ...here.
* gcc.dg/analyzer/analyzer-verbosity-1.c: Moved to...
* c-c++-common/analyzer/analyzer-verbosity-1.c: ...here.
* gcc.dg/analyzer/analyzer-verbosity-2.c: Moved to...
* c-c++-common/analyzer/analyzer-verbosity-2.c: ...here.
* gcc.dg/analyzer/analyzer-verbosity-3.c: Moved to...
* c-c++-common/analyzer/analyzer-verbosity-3.c: ...here.
* gcc.dg/analyzer/attr-alloc_size-1.c: Moved to...
* c-c++-common/analyzer/attr-alloc_size-1.c: ...here.
* gcc.dg/analyzer/attr-alloc_size-2.c: Moved to...
* c-c++-common/analyzer/attr-alloc_size-2.c: ...here.
* gcc.dg/analyzer/call-summaries-malloc.c: Moved to...
* c-c++-common/analyzer/call-summaries-malloc.c: ...here.
* gcc.dg/analyzer/call-summaries-pr107158-2.c: Moved to...
* c-c++-common/analyzer/call-summaries-pr107158-2.c: ...here.
* gcc.dg/analyzer/capacity-1.c: Moved to...
* c-c++-common/analyzer/capacity-1.c: ...here.
* gcc.dg/analyzer/dot-output.c: Moved to...
* c-c++-common/analyzer/dot-output.c: ...here.
* gcc.dg/analyzer/escaping-1.c: Moved to...
* c-c++-common/analyzer/escaping-1.c: ...here.
* gcc.dg/analyzer/expect-1.c: Moved to...
* c-c++-common/analyzer/expect-1.c: ...here.
* gcc.dg/analyzer/fgets-1.c: Moved to...
* c-c++-common/analyzer/fgets-1.c: ...here.
* gcc.dg/analyzer/file-uninit-1.c: Moved to...
* c-c++-common/analyzer/file-uninit-1.c: ...here.
* gcc.dg/analyzer/fileno-1.c: Moved to...
* c-c++-common/analyzer/fileno-1.c: ...here.
* gcc.dg/analyzer/first-field-1.c: Moved to...
* c-c++-common/analyzer/first-field-1.c: ...here.
* gcc.dg/analyzer/first-field-2.c: Moved to...
* c-c++-common/analyzer/first-field-2.c: ...here.
* gcc.dg/analyzer/flex-with-call-summaries.c: Moved to...
* c-c++-common/analyzer/flex-with-call-summaries.c: ...here.
* gcc.dg/analyzer/flex-without-call-summaries.c: Moved to...
* c-c++-common/analyzer/flex-without-call-summaries.c: ...here.
* gcc.dg/analyzer/flexible-array-member-1.c: Moved to...
* c-c++-common/analyzer/flexible-array-member-1.c: ...here.
* gcc.dg/analyzer/fold-string-to-char.c: Moved to...
* c-c++-common/analyzer/fold-string-to-char.c: ...here.
* gcc.dg/analyzer/fread-1.c: Moved to...
* c-c++-common/analyzer/fread-1.c: ...here.
* gcc.dg/analyzer/fread-2.c: Moved to...
* c-c++-common/analyzer/fread-2.c: ...here.
* gcc.dg/analyzer/fread-pr108661.c: Moved to...
* c-c++-common/analyzer/fread-pr108661.c: ...here.
* gcc.dg/analyzer/function-ptr-1.c: Moved to...
* c-c++-common/analyzer/function-ptr-1.c: ...here.
* gcc.dg/analyzer/function-ptr-2.c: Moved to...
* c-c++-common/analyzer/function-ptr-2.c: ...here.
* gcc.dg/analyzer/function-ptr-3.c: Moved to...
* c-c++-common/analyzer/function-ptr-3.c: ...here.
* gcc.dg/analyzer/function-ptr-4.c: Moved to...
* c-c++-common/analyzer/function-ptr-4.c: ...here.
* gcc.dg/analyzer/getc-1.c: Moved to...
* c-c++-common/analyzer/getc-1.c: ...here.
* gcc.dg/analyzer/getchar-1.c: Moved to...
* c-c++-common/analyzer/getchar-1.c: ...here.
* gcc.dg/analyzer/gzio-2.c: Moved to...
* c-c++-common/analyzer/gzio-2.c: ...here.
* gcc.dg/analyzer/gzio-3.c: Moved to...
* c-c++-common/analyzer/gzio-3.c: ...here.
* gcc.dg/analyzer/gzio-3a.c: Moved to...
* c-c++-common/analyzer/gzio-3a.c: ...here.
* gcc.dg/analyzer/gzio.c: Moved to...
* c-c++-common/analyzer/gzio.c: ...here.
* gcc.dg/analyzer/imprecise-floating-point-1.c: Moved to...
* c-c++-common/analyzer/imprecise-floating-point-1.c: ...here.
* gcc.dg/analyzer/infinite-recursion-2.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-2.c: ...here.
* gcc.dg/analyzer/infinite-recursion-3.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-3.c: ...here.
* gcc.dg/analyzer/infinite-recursion-4-limited-buggy.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-4-limited-buggy.c: ...here.
* gcc.dg/analyzer/infinite-recursion-4-limited.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-4-limited.c: ...here.
* gcc.dg/analyzer/infinite-recursion-4-unlimited-buggy.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-4-unlimited-buggy.c: ...here.
* gcc.dg/analyzer/infinite-recursion-4-unlimited.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-4-unlimited.c: ...here.
* gcc.dg/analyzer/infinite-recursion-5.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-5.c: ...here.
* gcc.dg/analyzer/infinite-recursion-alloca.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-alloca.c: ...here.
* gcc.dg/analyzer/infinite-recursion-inlining.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-inlining.c: ...here.
* gcc.dg/analyzer/infinite-recursion-multiline-1.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-multiline-1.c: ...here.
* gcc.dg/analyzer/infinite-recursion-multiline-2.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-multiline-2.c: ...here.
* gcc.dg/analyzer/infinite-recursion-pr108935-1.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-pr108935-1.c: ...here.
* gcc.dg/analyzer/infinite-recursion-pr108935-1a.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-pr108935-1a.c: ...here.
* gcc.dg/analyzer/infinite-recursion-pr108935-2.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-pr108935-2.c: ...here.
* gcc.dg/analyzer/infinite-recursion-variadic.c: Moved to...
* c-c++-common/analyzer/infinite-recursion-variadic.c: ...here.
* gcc.dg/analyzer/infinite-recursion.c: Moved to...
* c-c++-common/analyzer/infinite-recursion.c: ...here.
* gcc.dg/analyzer/inlining-1-multiline.c: Moved to...
* c-c++-common/analyzer/inlining-1-multiline.c: ...here.
* gcc.dg/analyzer/inlining-1-no-undo.c: Moved to...
* c-c++-common/analyzer/inlining-1-no-undo.c: ...here.
* gcc.dg/analyzer/inlining-2-multiline.c: Moved to...
* c-c++-common/analyzer/inlining-2-multiline.c: ...here.
* gcc.dg/analyzer/inlining-5-multiline.c: Moved to...
* c-c++-common/analyzer/inlining-5-multiline.c: ...here.
* gcc.dg/analyzer/inlining-6-multiline.c: Moved to...
* c-c++-common/analyzer/inlining-6-multiline.c: ...here.
* gcc.dg/analyzer/inlining-6.c: Moved to...
* c-c++-common/analyzer/inlining-6.c: ...here.
* gcc.dg/analyzer/inlining-7-multiline.c: Moved to...
* c-c++-common/analyzer/inlining-7-multiline.c: ...here.
* gcc.dg/analyzer/invalid-shift-1.c: Moved to...
* c-c++-common/analyzer/invalid-shift-1.c: ...here.
* gcc.dg/analyzer/isatty-1.c: Moved to...
* c-c++-common/analyzer/isatty-1.c: ...here.
* gcc.dg/analyzer/leak-2.c: Moved to...
* c-c++-common/analyzer/leak-2.c: ...here.
* gcc.dg/analyzer/leak-3.c: Moved to...
* c-c++-common/analyzer/leak-3.c: ...here.
* gcc.dg/analyzer/leak-4.c: Moved to...
* c-c++-common/analyzer/leak-4.c: ...here.
* gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c: Moved to...
* c-c++-common/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c: ...here.
* gcc.dg/analyzer/loop-0-up-to-n-by-1.c: Moved to...
* c-c++-common/analyzer/loop-0-up-to-n-by-1.c: ...here.
* gcc.dg/analyzer/loop-2.c: Moved to...
* c-c++-common/analyzer/loop-2.c: ...here.
* gcc.dg/analyzer/loop-2a.c: Moved to...
* c-c++-common/analyzer/loop-2a.c: ...here.
* gcc.dg/analyzer/loop-3.c: Moved to...
* c-c++-common/analyzer/loop-3.c: ...here.
* gcc.dg/analyzer/loop-4.c: Moved to...
* c-c++-common/analyzer/loop-4.c: ...here.
* gcc.dg/analyzer/loop-n-down-to-1-by-1.c: Moved to...
* c-c++-common/analyzer/loop-n-down-to-1-by-1.c: ...here.
* gcc.dg/analyzer/loop-start-down-to-end-by-1.c: Moved to...
* c-c++-common/analyzer/loop-start-down-to-end-by-1.c: ...here.
* gcc.dg/analyzer/loop-start-down-to-end-by-step.c: Moved to...
* c-c++-common/analyzer/loop-start-down-to-end-by-step.c: ...here.
* gcc.dg/analyzer/loop-start-to-end-by-step.c: Moved to...
* c-c++-common/analyzer/loop-start-to-end-by-step.c: ...here.
* gcc.dg/analyzer/loop-start-up-to-end-by-1.c: Moved to...
* c-c++-common/analyzer/loop-start-up-to-end-by-1.c: ...here.
* gcc.dg/analyzer/loop.c: Moved to...
* c-c++-common/analyzer/loop.c: ...here.
* gcc.dg/analyzer/malloc-3.c: Moved to...
* c-c++-common/analyzer/malloc-3.c: ...here.
* gcc.dg/analyzer/malloc-5.c: Moved to...
* c-c++-common/analyzer/malloc-5.c: ...here.
* gcc.dg/analyzer/malloc-CWE-401-example.c: Moved to...
* c-c++-common/analyzer/malloc-CWE-401-example.c: ...here.
* gcc.dg/analyzer/malloc-CWE-415-examples.c: Moved to...
* c-c++-common/analyzer/malloc-CWE-415-examples.c: ...here.
* gcc.dg/analyzer/malloc-CWE-416-examples.c: Moved to...
* c-c++-common/analyzer/malloc-CWE-416-examples.c: ...here.
* gcc.dg/analyzer/malloc-CWE-590-examples.c: Moved to...
* c-c++-common/analyzer/malloc-CWE-590-examples.c: ...here.
* gcc.dg/analyzer/malloc-callbacks.c: Moved to...
* c-c++-common/analyzer/malloc-callbacks.c: ...here.
* gcc.dg/analyzer/malloc-dce.c: Moved to...
* c-c++-common/analyzer/malloc-dce.c: ...here.
* gcc.dg/analyzer/malloc-dedupe-1.c: Moved to...
* c-c++-common/analyzer/malloc-dedupe-1.c: ...here.
* gcc.dg/analyzer/malloc-in-loop.c: Moved to...
* c-c++-common/analyzer/malloc-in-loop.c: ...here.
* gcc.dg/analyzer/malloc-ipa-1.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-1.c: ...here.
* gcc.dg/analyzer/malloc-ipa-11.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-11.c: ...here.
* gcc.dg/analyzer/malloc-ipa-2.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-2.c: ...here.
* gcc.dg/analyzer/malloc-ipa-3.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-3.c: ...here.
* gcc.dg/analyzer/malloc-ipa-4.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-4.c: ...here.
* gcc.dg/analyzer/malloc-ipa-5.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-5.c: ...here.
* gcc.dg/analyzer/malloc-ipa-6.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-6.c: ...here.
* gcc.dg/analyzer/malloc-ipa-7.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-7.c: ...here.
* gcc.dg/analyzer/malloc-ipa-8-unchecked.c: Moved to...
* c-c++-common/analyzer/malloc-ipa-8-unchecked.c: ...here.
* gcc.dg/analyzer/malloc-macro-inline-events.c: Moved to...
* c-c++-common/analyzer/malloc-macro-inline-events.c: ...here.
* gcc.dg/analyzer/malloc-macro-separate-events.c: Moved to...
* c-c++-common/analyzer/malloc-macro-separate-events.c: ...here.
* gcc.dg/analyzer/malloc-macro.h: Moved to...
* c-c++-common/analyzer/malloc-macro.h: ...here.
* gcc.dg/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c: Moved to...
* c-c++-common/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c: ...here.
* gcc.dg/analyzer/out-of-bounds-1.c: Moved to...
* c-c++-common/analyzer/out-of-bounds-1.c: ...here.
* gcc.dg/analyzer/out-of-bounds-2.c: Moved to...
* c-c++-common/analyzer/out-of-bounds-2.c: ...here.
* gcc.dg/analyzer/out-of-bounds-5.c: Moved to...
* c-c++-common/analyzer/out-of-bounds-5.c: ...here.
* gcc.dg/analyzer/out-of-bounds-diagram-11.c: Moved to...
* c-c++-common/analyzer/out-of-bounds-diagram-11.c: ...here.
* gcc.dg/analyzer/out-of-bounds-diagram-3.c: Moved to...
* c-c++-common/analyzer/out-of-bounds-diagram-3.c: ...here.
* gcc.dg/analyzer/out-of-bounds-diagram-8.c: Moved to...
* c-c++-common/analyzer/out-of-bounds-diagram-8.c: ...here.
* gcc.dg/analyzer/phi-1.c: Moved to...
* c-c++-common/analyzer/phi-1.c: ...here.
* gcc.dg/analyzer/pr100615.c: Moved to...
* c-c++-common/analyzer/pr100615.c: ...here.
* gcc.dg/analyzer/pr103526.c: Moved to...
* c-c++-common/analyzer/pr103526.c: ...here.
* gcc.dg/analyzer/pr94362-1.c: Moved to...
* c-c++-common/analyzer/pr94362-1.c: ...here.
* gcc.dg/analyzer/pr97074.c: Moved to...
* c-c++-common/analyzer/pr97074.c: ...here.
* c-c++-common/analyzer/pr99193-2.c: Added include.
* c-c++-common/analyzer/realloc-1.c: Added include.
* gcc.dg/analyzer/scope-1.c: Moved to...
* c-c++-common/analyzer/scope-1.c: ...here.
* gcc.dg/analyzer/setjmp-2.c: Moved to...
* c-c++-common/analyzer/setjmp-2.c: ...here.
* gcc.dg/analyzer/setjmp-5.c: Moved to...
* c-c++-common/analyzer/setjmp-5.c: ...here.
* gcc.dg/analyzer/setjmp-9.c: Moved to...
* c-c++-common/analyzer/setjmp-9.c: ...here.
* gcc.dg/analyzer/signal-4a.c: Moved to...
* c-c++-common/analyzer/signal-4a.c: ...here.
* gcc.dg/analyzer/signal-4b.c: Moved to...
* c-c++-common/analyzer/signal-4b.c: ...here.
* gcc.dg/analyzer/file-pr58237.c: C only.
* gcc.dg/analyzer/fopen-1.c: C only.
* gcc.dg/analyzer/malloc-4.c: C only.
* gcc.dg/analyzer/malloc-paths-9.c: C only.
* gcc.dg/analyzer/pr103892.c: C only.
* gcc.dg/analyzer/pr109577.c: C only.
* gcc.dg/analyzer/pr93355-localealias-feasibility.c: C only.
* gcc.dg/analyzer/pr99193-1.c: C only.
* gcc.dg/analyzer/compound-assignment-1.c: Removed.
* gcc.dg/analyzer/inlining-1.c: Removed.
* gcc.dg/analyzer/inlining-2.c: Removed.
* gcc.dg/analyzer/inlining-5.c: Removed.
* gcc.dg/analyzer/inlining-7.c: Removed.
* c-c++-common/analyzer/compound-assignment-1.c: New test.
* c-c++-common/analyzer/file-pr58237-noexcept.c: Duplicate of
gcc.dg/analyzer/file-pr58237.c with exceptions disabled.
* c-c++-common/analyzer/fopen-2.c: C++ compatible parts from
gcc.dg/analyzer/fopen-1.c.
* c-c++-common/analyzer/inlining-1.c: New test.
* c-c++-common/analyzer/inlining-2.c: New test.
* c-c++-common/analyzer/inlining-5.c: New test.
* c-c++-common/analyzer/inlining-7.c: New test.
* c-c++-common/analyzer/malloc-paths-9-noexcept.c: Duplicate of
gcc.dg/analyzer/malloc-paths-9.c with exceptions disabled.
* c-c++-common/analyzer/pr109577-noexcept.c: Duplicate of
gcc.dg/analyzer/pr109577.c with exceptions disabled.
* c-c++-common/analyzer/pr93355-localealias-feasibility-noexcept.c:
Duplicate of gcc.dg/analyzer/pr93355-localealias-feasibility.c with
exceptions disabled.
* c-c++-common/analyzer/pr99193-1-noexcept.c: Duplicate of
gcc.dg/analyzer/pr99193-1.c with exceptions disabled.

Signed-off-by: benjamin priour <vultkayn@gcc.gnu.org>
13 months agofortran: Remove redundant tree walk to delete element
Mikael Morin [Sat, 9 Sep 2023 09:45:11 +0000 (11:45 +0200)]
fortran: Remove redundant tree walk to delete element

Remove preliminary walk of the symbol tree when we are about to remove an
element.  This preliminary walk was necessary because the deletion function
updated the tree without reporting back to the caller the element it had
removed.  But knowing that element is necessary to free its memory, so one
had to first get that element before it was removed from the tree.

This change updates the main deletion function delete_treap and its public
wrapper gfc_delete_bbt so that the removed element can be known by the
caller.  This makes the preliminary walk in gfc_delete_symtree redundant,
permitting its removal.

gcc/fortran/ChangeLog:

* bbt.cc (delete_treap): Add argument REMOVED, set it to the removed
element from the tree.  Change NULL to nullptr.
(gfc_delete_bbt): Return the removed element from the tree.
* gfortran.h (gfc_delete_symtree): Remove prototype.
(gfc_delete_bbt): Set return type to pointer.
* symbol.cc (gfc_delete_symtree): Make static.  Get the element to be
freed from the result of gfc_delete_bbt.  Remove the preliminary walk to
get it.

13 months agoLoongArch: Fix up memcpy-vec-3.c test case
Xi Ruoyao [Sat, 9 Sep 2023 08:18:06 +0000 (16:18 +0800)]
LoongArch: Fix up memcpy-vec-3.c test case

The generic code will split 16-byte copy into two 8-byte copies, so the
vector code wouldn't be used even if -mno-strict-align.  This
contradicted with the purpose of this test case.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/memcpy-vec-3.c: Increase the amount of
copied bytes to 32.

13 months agoLoongArch: Optimized multiply instruction generation.
Lulu Cheng [Tue, 5 Sep 2023 03:09:03 +0000 (11:09 +0800)]
LoongArch: Optimized multiply instruction generation.

1. Can generate mulh.w[u] instruction.
2. Can generate mulw.d.wu instruction.

gcc/ChangeLog:

* config/loongarch/loongarch.md (mulsidi3_64bit):
Field unsigned extension support.
(<u>muldi3_highpart): Modify template name.
(<u>mulsi3_highpart): Likewise.
(<u>mulsidi3_64bit): Field unsigned extension support.
(<su>muldi3_highpart): Modify muldi3_highpart to
smuldi3_highpart.
(<su>mulsi3_highpart): Modify mulsi3_highpart to
smulsi3_highpart.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/mulw_d_wu.c: New test.
* gcc.target/loongarch/smuldi3_highpart.c: New test.
* gcc.target/loongarch/smulsi3_highpart.c: New test.
* gcc.target/loongarch/umulsi3_highpart.c: New test.

13 months agoLoongArch: Slightly simplify loongarch_block_move_straight
Xi Ruoyao [Thu, 7 Sep 2023 16:29:57 +0000 (00:29 +0800)]
LoongArch: Slightly simplify loongarch_block_move_straight

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_block_move_straight):
Check precondition (delta must be a power of 2) and use
popcount_hwi instead of a homebrew loop.

13 months agoLoongArch: Use LSX and LASX for block move
Xi Ruoyao [Tue, 5 Sep 2023 13:02:38 +0000 (21:02 +0800)]
LoongArch: Use LSX and LASX for block move

gcc/ChangeLog:

* config/loongarch/loongarch.h (LARCH_MAX_MOVE_PER_INSN):
Define to the maximum amount of bytes able to be loaded or
stored with one machine instruction.
* config/loongarch/loongarch.cc (loongarch_mode_for_move_size):
New static function.
(loongarch_block_move_straight): Call
loongarch_mode_for_move_size for machine_mode to be moved.
(loongarch_expand_block_move): Use LARCH_MAX_MOVE_PER_INSN
instead of UNITS_PER_WORD.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/memcpy-vec-1.c: New test.
* gcc.target/loongarch/memcpy-vec-2.c: New test.
* gcc.target/loongarch/memcpy-vec-3.c: New test.

13 months agoRISC-V: Fix VLS floating-point operations predicate
Juzhe-Zhong [Sat, 9 Sep 2023 04:30:26 +0000 (12:30 +0800)]
RISC-V: Fix VLS floating-point operations predicate

VLS vfadd should depend on ZVFH instead of ZVFHMIN.
Obvious fix and committed.

gcc/ChangeLog:

* config/riscv/vector-iterators.md: Fix floating-point operations predicate.

13 months agoSupport folding min(poly,poly) to const
Lehua Ding [Fri, 8 Sep 2023 08:54:19 +0000 (16:54 +0800)]
Support folding min(poly,poly) to const

This patch adds support that tries to fold `MIN (poly, poly)` to
a constant. Consider the following C Code:

```
void foo2 (int* restrict a, int* restrict b, int n)
{
    for (int i = 0; i < 3; i += 1)
      a[i] += b[i];
}
```

Before this patch:

```
void foo2 (int * restrict a, int * restrict b, int n)
{
  vector([4,4]) int vect__7.27;
  vector([4,4]) int vect__6.26;
  vector([4,4]) int vect__4.23;
  unsigned long _32;

  <bb 2> [local count: 268435456]:
  _32 = MIN_EXPR <3, POLY_INT_CST [4, 4]>;
  vect__4.23_20 = .MASK_LEN_LOAD (a_11(D), 32B, { -1, ... }, _32, 0);
  vect__6.26_15 = .MASK_LEN_LOAD (b_12(D), 32B, { -1, ... }, _32, 0);
  vect__7.27_9 = vect__6.26_15 + vect__4.23_20;
  .MASK_LEN_STORE (a_11(D), 32B, { -1, ... }, _32, 0, vect__7.27_9); [tail call]
  return;

}
```

After this patch:

```
void foo2 (int * restrict a, int * restrict b, int n)
{
  vector([4,4]) int vect__7.27;
  vector([4,4]) int vect__6.26;
  vector([4,4]) int vect__4.23;

  <bb 2> [local count: 268435456]:
  vect__4.23_20 = .MASK_LEN_LOAD (a_11(D), 32B, { -1, ... }, 3, 0);
  vect__6.26_15 = .MASK_LEN_LOAD (b_12(D), 32B, { -1, ... }, 3, 0);
  vect__7.27_9 = vect__6.26_15 + vect__4.23_20;
  .MASK_LEN_STORE (a_11(D), 32B, { -1, ... }, 3, 0, vect__7.27_9); [tail call]
  return;

}
```

For RISC-V RVV, csrr and branch instructions can be reduced:

Before this patch:

```
foo2:
        csrr    a4,vlenb
        srli    a4,a4,2
        li      a5,3
        bleu    a5,a4,.L5
        mv      a5,a4
.L5:
        vsetvli zero,a5,e32,m1,ta,ma
        ...
```

After this patch.

```
foo2:
vsetivli zero,3,e32,m1,ta,ma
        ...
```

gcc/ChangeLog:

* fold-const.cc (can_min_p): New function.
(poly_int_binop): Try fold MIN_EXPR.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/div-1.c: Adjust.
* gcc.target/riscv/rvv/autovec/vls/shift-3.c: Adjust.
* gcc.target/riscv/rvv/autovec/fold-min-poly.c: New test.

13 months agoDaily bump.
GCC Administrator [Sat, 9 Sep 2023 00:16:40 +0000 (00:16 +0000)]
Daily bump.

13 months ago[frange] Revert relation handling in LTGT_EXPR.
Aldy Hernandez [Fri, 8 Sep 2023 00:27:35 +0000 (20:27 -0400)]
[frange] Revert relation handling in LTGT_EXPR.

In trying to come up with a missing testcase for commit 979e0fbf53cd,
I've realized the patch doesn't catch anything.

A relation of VREL_EQ in foperator_ltgt::fold_range() is either both
arguments the same (x LTGT_EXPR x), which we should never emit, or two
arguments that are actually the same, in which case !NAN applies, and the
whole thing can be handled as NE_EXPR further down.

gcc/ChangeLog:

* range-op-float.cc (foperator_ltgt::fold_range): Do not special
case VREL_EQ nor call frelop_early_resolve.

13 months agotestsuite: adjust for darwin linker warning
Francois-Xavier Coudert [Fri, 8 Sep 2023 19:55:56 +0000 (21:55 +0200)]
testsuite: adjust for darwin linker warning

On recent macOS versions, no_pie is deprecated and the linker complains
about it: "-no_pie is deprecated when targeting new OS versions"

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-segaddr.c: Adjust for darwin linker warning.
* gcc.dg/pie-7.c: Likewise.

13 months agolibstdc++: Add Filesystem TS and std::stacktrace symbols to libstdc++exp.a
Jonathan Wakely [Thu, 7 Sep 2023 09:24:56 +0000 (10:24 +0100)]
libstdc++: Add Filesystem TS and std::stacktrace symbols to libstdc++exp.a

This consolidates the three static archives for extensions into one, so
that -lstdc++exp can be used to provide the definitions of all unstable
library features.

The libstdc++_libbacktrace.a archive is now just a "noinst" convenience
library that is only used during the build, not installed. Its contents
are added to libstdc++exp.a, along with the new non-inline definitions
of std::stacktrace symbols.

The libstdc++fs.a archive is still installed, but its contents are
duplicated in libstdc++exp.a now. This means -lstdc++exp can be used
instead of -lstdc++fs. For targets using the GNU linker we should
consider replacing libstdc++fs.a with a linker script that does
INPUT(libstdc++exp.a).

The tests for <experimental/filesystem> could be changed to use
-lstdc++exp instead of -lstdc++fs, which would allow removing
src/filesystem/.libs from the LDFLAGS in scripts/testsuite_flags.in,
but that can be done at a later date.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++23 directory.
* configure: Regenerate.
* doc/html/manual/*: Regenerate.
* doc/xml/manual/using.xml: Update documentation on linking.
* include/std/stacktrace: Remove declarations of libbacktrace
APIs.
(stacktrace_entry::_S_err_handler, stacktrace_entry::_S_init):
Remove.
(stacktrace_entry::_Info): New class.
(stacktrace_entry::_M_get_info): Use _Info.
(__stacktrace_impl): New class.
(basic_stacktrace): Derive from __stacktrace_impl.
(basic_stacktrace::current): Use __stacktrace_impl::_S_current.
* scripts/testsuite_flags.in: Adjust LDFLAGS to find
libstdc++exp instead of libstdc++_libbacktrace.
* src/Makefile.am (SUBDIRS): Add c++23 directory.
* src/Makefile.in: Regenerate.
* src/c++20/Makefile.am: Fix comment.
* src/c++20/Makefile.in: Regenerate.
* src/c++23/Makefile.am: New file.
* src/c++23/Makefile.in: New file.
* src/c++23/stacktrace.cc: New file with definitions of
stacktrace_entry::_Info and __stacktrace_impl members.
* src/experimental/Makefile.am: Use LIBADD to include other
libraries.
* src/experimental/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.am: Use noinst_LTLIBRARIES.
* src/libbacktrace/Makefile.in: Regenerate.
* testsuite/19_diagnostics/stacktrace/current.cc: Adjust
dg-options to use -lstdc++exp.
* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
* testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc:
Likewise.

13 months agolibstdc++: Fix unconditional -Werror in libbacktrace directory
Alexey Lapshin [Fri, 8 Sep 2023 10:23:16 +0000 (11:23 +0100)]
libstdc++: Fix unconditional -Werror in libbacktrace directory

The -Werror flag should depend on the --enable-werror configure option.

libstdc++-v3/ChangeLog:

* src/libbacktrace/Makefile.am: Remove -Werror.
* src/libbacktrace/Makefile.in: Regenerate.

13 months agolibstdc++: Reduce output of 'make check'
Jonathan Wakely [Thu, 7 Sep 2023 13:26:38 +0000 (14:26 +0100)]
libstdc++: Reduce output of 'make check'

This removes the 39 lines of shell commands that get echoed when
starting the testsuite. The fact that near the end of that output it
prints `echo "WARNING: could not find \`runtest'" 1>&2; :;` makes it
look like that warning is actually being shown to the user.

Suppress echoing the recipe, so that users only see the actual output
from the testsuite, not the makefile recipe as well.

libstdc++-v3/ChangeLog:

* testsuite/Makefile.am (check-DEJAGNU): Use @ in recipe.
* testsuite/Makefile.in: Regenerate.

13 months agoc++: refine CWG 2369 satisfaction vs non-dep convs [PR99599]
Patrick Palka [Fri, 8 Sep 2023 16:02:20 +0000 (12:02 -0400)]
c++: refine CWG 2369 satisfaction vs non-dep convs [PR99599]

As described in detail in the PR, the CWG 2369 resolution has the
surprising consequence of introducing constraint recursion in seemingly
valid and innocent code.

This patch attempts to fix this surpising behavior for the majority of
problematic cases.  Rather than checking satisfaction before _all_
non-dependent conversions, as specified by the CWG resolution, this patch
makes us first check "safe" non-dependent conversions, then satisfaction,
then followed by other non-dependent conversions.  A conversion is
considered "safe" if computing it is guaranteed to not induce template
instantiation, and we conservatively determine this by checking for
user-declared constructors (resp. conversion functions) in the parm
(resp. arg) class type, roughly.

PR c++/99599

gcc/cp/ChangeLog:

* pt.cc (check_non_deducible_conversions): Add bool parameter
passed down to check_non_deducible_conversion.
(fn_type_unification): Call check_non_deducible_conversions
an extra time before satisfaction with noninst_only_p=true.
(conversion_may_instantiate_p): Define.
(check_non_deducible_conversion): Add bool parameter controlling
whether to compute only conversions that are guaranteed to
not induce template instantiation.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-recursive-sat4.C: Make 'Int' non-aggregate
in order to preserve intent of the testcase.
* g++.dg/cpp2a/concepts-nondep4.C: New test.

13 months agoriscv: xtheadbb: Fix extendqi<SUPERQI> insn
Christoph Müllner [Fri, 8 Sep 2023 05:45:24 +0000 (07:45 +0200)]
riscv: xtheadbb: Fix extendqi<SUPERQI> insn

Recently three SPEC CPU 2017 benchmarks broke when using xtheadbb:
* 500.perlbench_r
* 525.x264_r
* 557.xz_r

Tracing the issue down revealed, that we emit a 'th.ext xN,xN,15,0'
for a extendqi<SUPERQI> insn, which is obviously wrong.
This patch splits the common 'extend<SHORT:mode><SUPERQI:mode>2_th_ext'
insn into two 'extendqi<SUPERQI>' and 'extendhi<SUPERQI>' insns,
which emit the right extension instruction.
Additionally, this patch adds test cases for these insns.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/ChangeLog:

* config/riscv/thead.md (*extend<SHORT:mode><SUPERQI:mode>2_th_ext):
Remove broken INSN.
(*extendhi<SUPERQI:mode>2_th_ext): New INSN.
(*extendqi<SUPERQI:mode>2_th_ext): New INSN.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadbb-ext-2.c: New test.
* gcc.target/riscv/xtheadbb-ext-3.c: New test.

13 months agoriscv: thead: Fix mode attribute for extension patterns
Christoph Müllner [Fri, 8 Sep 2023 06:03:23 +0000 (08:03 +0200)]
riscv: thead: Fix mode attribute for extension patterns

The mode attribute of an extension pattern is usually set to the target type.
Let's follow this convention consistently for xtheadbb.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/ChangeLog:

* config/riscv/thead.md: Use more appropriate mode attributes
for extensions.

13 months agoUpdate contrib + libgomp ChangeLogs for failed reject-commit testing
Tobias Burnus [Fri, 8 Sep 2023 10:02:02 +0000 (12:02 +0200)]
Update contrib + libgomp ChangeLogs for failed reject-commit testing

The following commit should have enabled checking for invalid revert hashes;
it worked locally - but did work as pre-commit hook on sourceware
as it wasn't copied to the hook directory:
r14-3777-gff20bce9f58 contrib/gcc-changelog: Check whether revert-commit exists

Hence, the following revert commit was wrongly applied:
r14-3778-gfbbd9001e9b Revert "contrib/gcc-changelog: Check whether revert-commit exists"
(In this commit: contrib/ChangeLog update for the revert.)

r14-3779-g69e83181ebc contrib/gcc-changelog: Check whether revert-commit exists
Re-applied the commit with a commit-log typo fixed but missing a late commit.

r14-3780-g1b0934b7276 Revert "contrib/gcc-changelog: Check whether revert-commit exists"
This commit still came through but re-instated the late wording fix in
contrib/gcc-changelog/git_commit.py.
(In this commit: contrib/ChangeLog update for the wording change.)

r14-3781-gd22cd7745ff Revert: "Another revert test with a bogus hash"
Another attempt to get a reject, but it still came through.
It removed tailing whitespace in libgomp/target.c
(In this commit: libgomp/ChangeLog was for the whitespace removal.)

13 months agoLoongArch: Enable -fsched-pressure by default at -O1 and higher.
Guo Jie [Fri, 8 Sep 2023 02:00:21 +0000 (10:00 +0800)]
LoongArch: Enable -fsched-pressure by default at -O1 and higher.

gcc/ChangeLog:

* common/config/loongarch/loongarch-common.cc:
(default_options loongarch_option_optimization_table):
Default to -fsched-pressure.

13 months agoLoongArch: Fix unintentional bash-ism in r14-3665.
Yang Yujie [Wed, 6 Sep 2023 09:57:47 +0000 (17:57 +0800)]
LoongArch: Fix unintentional bash-ism in r14-3665.

gcc/ChangeLog:

* config.gcc: remove non-POSIX syntax "<<<".

13 months agoLoongArch: Adjust C++ multilib header layout.
Yang Yujie [Thu, 7 Sep 2023 06:50:10 +0000 (14:50 +0800)]
LoongArch: Adjust C++ multilib header layout.

For LoongArch, the toplevel library build is always aliased to
one of the multilib variants.  This patch installs it with the
actual MULTISUBDIR (instead of ".") so that the headers can be
reached by the compiler.

This patch is an update of
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/629435.html

libstdc++-v3/ChangeLog:

* configure.host: Register t-loongarch in tmake_file.
* config/cpu/loongarch/t-loongarch: New file.  Manually refresh
MULTISUBDIR with $(shell $(CXX) --print-multi-directory).

13 months agoDaily bump.
GCC Administrator [Fri, 8 Sep 2023 09:41:34 +0000 (09:41 +0000)]
Daily bump.

13 months agoriscv: bitmanip: Remove duplicate zero_extendhi<GPR:mode>2 pattern
Christoph Müllner [Fri, 8 Sep 2023 06:19:32 +0000 (08:19 +0200)]
riscv: bitmanip: Remove duplicate zero_extendhi<GPR:mode>2 pattern

We currently have two identical zero_extendhi<GPR:mode>2 patterns:
* '*zero_extendhi<GPR:mode>2_zbb'
* '*zero_extendhi<GPR:mode>2_bitmanip'

This patch removes the *_zbb pattern and ensures that all sign- and
zero-extensions use the postfix '_bitmanip'.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/ChangeLog:

* config/riscv/bitmanip.md (*extend<SHORT:mode><SUPERQI:mode>2_zbb):
Rename postfix to _bitmanip.
(*extend<SHORT:mode><SUPERQI:mode>2_bitmanip): Renamed pattern.
(*zero_extendhi<GPR:mode>2_zbb): Remove duplicated pattern.

13 months agoRevert "libstdc++: Use GLIBCXX_CHECK_LINKER_FEATURES for cross-builds (PR111238)"
Christophe Lyon [Fri, 8 Sep 2023 08:13:32 +0000 (08:13 +0000)]
Revert "libstdc++: Use GLIBCXX_CHECK_LINKER_FEATURES for cross-builds (PR111238)"

13 months agoRISC-V: Suppress bogus warning for VLS types
Juzhe-Zhong [Fri, 8 Sep 2023 08:20:27 +0000 (16:20 +0800)]
RISC-V: Suppress bogus warning for VLS types

This patch fixes over 100+ bogus FAILs due to experimental vector ABI warning.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_pass_in_vector_p): Only allow RVV type.

13 months agoRISC-V: Fix incorrect nregs calculation for VLS modes
Juzhe-Zhong [Fri, 8 Sep 2023 07:52:03 +0000 (15:52 +0800)]
RISC-V: Fix incorrect nregs calculation for VLS modes

This patch fixes obvious bug: TARGET_MIN_VLEN is bitsize.

All these following bugs are fixed with this patch:
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O0  (internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1176)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O0  (test for excess errors)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O1  (internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1176)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O1  (test for excess errors)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O2  (internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1176)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O2  (test for excess errors)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1176)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1176)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O3 -g  (internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1176)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -O3 -g  (test for excess errors)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -Os  (internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1176)
FAIL: gcc.target/riscv/zero-scratch-regs-3.c   -Os  (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/mov-13.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/mov-13.c (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/spill-1.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/spill-1.c (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/spill-2.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/spill-2.c (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/spill-3.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/spill-3.c (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/spill-4.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/spill-4.c (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/spill-5.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/spill-5.c (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/spill-6.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/spill-6.c (test for excess errors)
FAIL: gcc.target/riscv/rvv/base/spill-sp-adjust.c (internal compiler error: in partial_subreg_p, at rtl.h:3186)
FAIL: gcc.target/riscv/rvv/base/spill-sp-adjust.c (test for excess errors)

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_hard_regno_nregs): Fix bug.

13 months agoSupport vpermw/vpermi2w/vpermt2w instructions for vector HF/BFmodes.
liuhongt [Tue, 5 Sep 2023 05:07:04 +0000 (13:07 +0800)]
Support vpermw/vpermi2w/vpermt2w instructions for vector HF/BFmodes.

gcc/ChangeLog:

* config/i386/sse.md
(<avx512>_vpermt2var<mode>3<sd_maskz_name>): New define_insn.
(VHFBF_AVX512VL): New mode iterator.
(VI2HFBF_AVX512VL): New mode iterator.

13 months agoanalyzer: basic support for computed gotos (PR analyzer/110529)
David Malcolm [Thu, 7 Sep 2023 22:43:05 +0000 (18:43 -0400)]
analyzer: basic support for computed gotos (PR analyzer/110529)

PR analyzer/110529 notes that -fanalyzer was giving up on execution
paths that follow a computed goto, due to ignoring CFG edges with the
flag EDGE_ABNORMAL set.

This patch implements enough handling for them to allow analysis of
such execution paths to continue.

gcc/analyzer/ChangeLog:
PR analyzer/110529
* program-point.cc (program_point::on_edge): Don't reject
EDGE_ABNORMAL for computed gotos.
* region-model.cc (region_model::maybe_update_for_edge): Handle
computed goto statements.
(region_model::apply_constraints_for_ggoto): New.
* region-model.h (region_model::apply_constraints_for_ggoto): New decl.
* supergraph.cc (supernode::get_label): New.
* supergraph.h (supernode::get_label): New decl.

gcc/testsuite/ChangeLog:
PR analyzer/110529
* c-c++-common/analyzer/computed-goto-1.c: New test.
* gcc.dg/analyzer/computed-goto-pr110529.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
13 months ago[irange] Fix typo in contains_zero_p.
Aldy Hernandez [Thu, 7 Sep 2023 19:54:20 +0000 (15:54 -0400)]
[irange] Fix typo in contains_zero_p.

In the conversion of iranges to wide_int (commit cb779afeff204f), I
mistakenly made contains_zero_p() return TRUE for undefined ranges.
This means the rest of the patch was adjusted for this stupidity.

For example, we ended up doing the following, to make up for the fact
that contains_zero_p was broken:

-  if (!lhs.contains_p (build_zero_cst (lhs.type ())))
+  if (lhs.undefined_p () || !contains_zero_p (lhs))

This patch fixes the thinko and adjusts all callers.

In places where a caller is not checking undefined_p(), it is because
either the caller has already handled undefined ranges in the
preceeding code, or the check is superfluous.

gcc/ChangeLog:

* value-range.h (contains_zero_p): Return false for undefined ranges.
* range-op-float.cc (operator_gt::op1_op2_relation): Adjust for
contains_zero_p change above.
(operator_ge::op1_op2_relation): Same.
(operator_equal::op1_op2_relation): Same.
(operator_not_equal::op1_op2_relation): Same.
(operator_lt::op1_op2_relation): Same.
(operator_le::op1_op2_relation): Same.
(operator_ge::op1_op2_relation): Same.
* range-op.cc (operator_equal::op1_op2_relation): Same.
(operator_not_equal::op1_op2_relation): Same.
(operator_lt::op1_op2_relation): Same.
(operator_le::op1_op2_relation): Same.
(operator_cast::op1_range): Same.
(set_nonzero_range_from_mask): Same.
(operator_bitwise_xor::op1_range): Same.
(operator_addr_expr::fold_range): Same.
(operator_addr_expr::op1_range): Same.

13 months agoanalyzer: Call off a superseding when diagnostics are unrelated [PR110830]
benjamin priour [Fri, 1 Sep 2023 18:21:41 +0000 (20:21 +0200)]
analyzer: Call off a superseding when diagnostics are unrelated [PR110830]

Before this patch, a saved_diagnostic would supersede another at
the same statement if and only its vfunc supercedes_p returned true
for the other diagnostic's kind.
That both warning were unrelated - i.e. resolving one would not fix
the other - was not considered in making the above choice.

This patch makes it so that two saved_diagnostics taking a different
outcome of at least one common conditional branching cannot supersede
each other.

Signed-off-by: Benjamin Priour <vultkayn@gcc.gnu.org>
Co-authored-by: David Malcolm <dmalcolm@redhat.com>
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/ChangeLog:

PR analyzer/110830
* diagnostic-manager.cc
(compatible_epaths_p): New function.
(saved_diagnostic::supercedes_p): Now calls the above
to determine if the diagnostics do overlap and the superseding
may proceed.

gcc/testsuite/ChangeLog:

PR analyzer/110830
* c-c++-common/analyzer/pr110830.c: New test.

13 months agoanalyzer: fix -Wunused-parameter warnings
David Malcolm [Thu, 7 Sep 2023 20:17:56 +0000 (16:17 -0400)]
analyzer: fix -Wunused-parameter warnings

gcc/analyzer/ChangeLog:
* region-model.h: fix -Wunused-parameter warnings

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
13 months agoSome ssa-names get incorrectly marked as always_current.
Andrew MacLeod [Thu, 7 Sep 2023 15:15:50 +0000 (11:15 -0400)]
Some ssa-names get incorrectly marked as always_current.

When range_of_stmt invokes prefill_name to evaluate unvisited dependencies
it should not mark already visited names as always_current.

PR tree-optimization/110875
gcc/
* gimple-range.cc (gimple_ranger::prefill_name): Only invoke
cache-prefilling routine when the ssa-name has no global value.

gcc/testsuite/
* gcc.dg/pr110875.c: New.

13 months agoOpenMP: Fix ICE in fixup_blocks_walker [PR111274]
Sandra Loosemore [Thu, 7 Sep 2023 16:12:20 +0000 (16:12 +0000)]
OpenMP: Fix ICE in fixup_blocks_walker [PR111274]

This ICE was caused by an invalid assumption that all BIND_EXPRs have
a non-null BIND_EXPR_BLOCK.  In C++ these do exist and are used for
temporaries introduced in expressions that are not full-expressions.
Since they have no block to fix up, the traversal can just ignore
these tree nodes.

gcc/cp/ChangeLog
PR c++/111274
* parser.cc (fixup_blocks_walker): Check for null BIND_EXPR_BLOCK.

gcc/testsuite/ChangeLog
PR c++/111274
* g++.dg/gomp/pr111274.C: New test case.

13 months agolibstdc++: Update docbook xsl URI
Bruno Victal [Mon, 21 Aug 2023 20:34:03 +0000 (21:34 +0100)]
libstdc++: Update docbook xsl URI

The URI for namespaced docbook-xsl was updated to reflect the current
DocBook upstream at <https://cdn.docbook.org/>.

libstdc++-v3/Changelog:

* acinclude.m4: Update docbook xsl URI.
* configure: Regenerate.

13 months agolibstdc++: Fix 'doc-install-info' rule
Bruno Victal [Mon, 21 Aug 2023 20:34:02 +0000 (21:34 +0100)]
libstdc++: Fix 'doc-install-info' rule

The info manual isn't moved to the expected location after
generation which causes the install rule for it to fail.

libstdc++-v3/Changelog:

* doc/Makefile.am: Fix 'doc-install-info' rule.
Fix typo in commment.
* doc/Makefile.in: Regenerate.

13 months agolibstdc++: Simplify dejagnu target selector
Jonathan Wakely [Thu, 7 Sep 2023 13:20:56 +0000 (14:20 +0100)]
libstdc++: Simplify dejagnu target selector

A target selector allows multiple target triplets, it's not necessary to
use the || operator in a logical expression.

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/path/concat/94063.cc: Simplify
dg-do target selector.

13 months agolibstdc++: Remove trailing whitespace from dejagnu files
Jonathan Wakely [Thu, 7 Sep 2023 09:22:00 +0000 (10:22 +0100)]
libstdc++: Remove trailing whitespace from dejagnu files

Also fix the name of a source file used by an effective target check.

libstdc++-v3/ChangeLog:

* testsuite/config/default.exp: Remove trailing whitespace.
* testsuite/lib/dg-options.exp: Likewise.
* testsuite/lib/prune.exp: Likewise.
* testsuite/libstdc++-abi/abi.exp: Likewise.
* testsuite/libstdc++-dg/conformance.exp: Likewise.
* testsuite/libstdc++-prettyprinters/prettyprinters.exp:
Likewise.
* testsuite/libstdc++-xmethods/xmethods.exp: Likewise.
* testsuite/lib/libstdc++.exp: Likewise.
(check_v3_target_c_std): Fix filename for temporary source file.

13 months agolibstdc++: Add autoconf checks for mkdir, chmod, chdir, and getcwd
Jonathan Wakely [Thu, 7 Sep 2023 16:03:40 +0000 (17:03 +0100)]
libstdc++: Add autoconf checks for mkdir, chmod, chdir, and getcwd

The filesystem code was using these functions without checking for their
existence, assuming that any UNIX-like libc with <unistd.h> would always
provide them. That's not true for some newlib targets like arm-eabi.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for mkdir,
chmod, chdir, and getcwd.
* config.h.in: Regenerate.
* configure: Regenerate.
* src/c++17/fs_ops.cc (create_dir): Use USE_MKDIR macro.
(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
(fs::permissions): Use USE_CHMOD macro.
* src/filesystem/ops-common.h [FILESYSTEM_IS_WINDOWS]
(chmod, mkdir, getcwd, chdir): Define new macros.
[FILESYSTEM_IS_WINDOWS] (chmod, mkdir, getcwd, chdir): Use
new macros.
* src/filesystem/ops.cc (create_dir): Use USE_MKDIR macro.
(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
(fs::permissions): Use USE_CHMOD macro.

13 months agolibstdc++: Disable <stacktrace> support by default for avr
Jonathan Wakely [Tue, 5 Sep 2023 10:14:02 +0000 (11:14 +0100)]
libstdc++: Disable <stacktrace> support by default for avr

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Disable by default
for avr.
* configure: Regenerate.

13 months agolibgomp.texi: Fix ICV var name, document some memory management routines
Tobias Burnus [Thu, 7 Sep 2023 14:44:09 +0000 (16:44 +0200)]
libgomp.texi: Fix ICV var name, document some memory management routines

libgomp/

* libgomp.texi (Memory Management Routines): New; add documentation for
omp_init_allocator, omp_destroy_allocator, omp_set_default_allocator,
omp_get_default_allocator.
(OMP_ALLOCATOR): Fix ICV var name; add see-also references.

13 months ago[LRA]: Don't reuse chosen insn alternative with special memory constraint
Vladimir N. Makarov [Thu, 7 Sep 2023 13:59:10 +0000 (09:59 -0400)]
[LRA]: Don't reuse chosen insn alternative with special memory constraint

To speed up GCC, LRA reuses chosen alternative from previous
constraint subpass.  A spilled pseudo is considered ok for any memory
constraint although stack slot assigned to the pseudo later might not
satisfy the chosen alternative constraint.  As we don't consider all insn
alternatives on the subsequent LRA sub-passes, it might result in LRA failure
to generate the correct insn.  This patch solves the problem.

gcc/ChangeLog:

PR target/111225
* lra-constraints.cc (goal_reuse_alt_p): New global flag.
(process_alt_operands): Set up the flag.  Clear flag for chosen
alternative with special memory constraints.
(process_alt_operands): Set up used insn alternative depending on the flag.

gcc/testsuite/ChangeLog:

PR target/111225
* gcc.target/i386/pr111225.c: New test.

13 months agoRISC-V: Add VLS mask modes mov patterns
Juzhe-Zhong [Thu, 7 Sep 2023 11:47:44 +0000 (19:47 +0800)]
RISC-V: Add VLS mask modes mov patterns

This patterns fix these following ICE FAILs when running the whole GCC testsuite
with enabling scalable vector by default.

All of these FAILs are fixed:
FAIL: c-c++-common/opaque-vector.c  -std=c++14 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/opaque-vector.c  -std=c++14 (test for excess errors)
FAIL: c-c++-common/opaque-vector.c  -std=c++17 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/opaque-vector.c  -std=c++17 (test for excess errors)
FAIL: c-c++-common/opaque-vector.c  -std=c++20 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/opaque-vector.c  -std=c++20 (test for excess errors)
FAIL: c-c++-common/opaque-vector.c  -std=c++98 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/opaque-vector.c  -std=c++98 (test for excess errors)
FAIL: c-c++-common/pr105998.c  -std=c++14 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/pr105998.c  -std=c++14 (test for excess errors)
FAIL: c-c++-common/pr105998.c  -std=c++17 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/pr105998.c  -std=c++17 (test for excess errors)
FAIL: c-c++-common/pr105998.c  -std=c++20 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/pr105998.c  -std=c++20 (test for excess errors)
FAIL: c-c++-common/pr105998.c  -std=c++98 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/pr105998.c  -std=c++98 (test for excess errors)
FAIL: c-c++-common/vector-scalar.c  -std=c++14 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/vector-scalar.c  -std=c++14 (test for excess errors)
FAIL: c-c++-common/vector-scalar.c  -std=c++17 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/vector-scalar.c  -std=c++17 (test for excess errors)
FAIL: c-c++-common/vector-scalar.c  -std=c++20 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/vector-scalar.c  -std=c++20 (test for excess errors)
FAIL: c-c++-common/vector-scalar.c  -std=c++98 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/vector-scalar.c  -std=c++98 (test for excess errors)
FAIL: g++.dg/ext/vector36.C  -std=gnu++14 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/ext/vector36.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/ext/vector36.C  -std=gnu++17 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/ext/vector36.C  -std=gnu++17 (test for excess errors)
FAIL: g++.dg/ext/vector36.C  -std=gnu++20 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/ext/vector36.C  -std=gnu++20 (test for excess errors)
FAIL: g++.dg/ext/vector36.C  -std=gnu++98 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/ext/vector36.C  -std=gnu++98 (test for excess errors)
FAIL: g++.dg/pr58950.C  -std=gnu++14 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/pr58950.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/pr58950.C  -std=gnu++17 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/pr58950.C  -std=gnu++17 (test for excess errors)
FAIL: g++.dg/pr58950.C  -std=gnu++20 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/pr58950.C  -std=gnu++20 (test for excess errors)
FAIL: g++.dg/pr58950.C  -std=gnu++98 (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/pr58950.C  -std=gnu++98 (test for excess errors)
FAIL: c-c++-common/torture/builtin-shufflevector-2.c   -O0  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/torture/vector-compare-2.c   -O0  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/torture/vector-compare-2.c   -O0  (test for excess errors)
FAIL: g++.dg/torture/pr104450.C   -O0  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: g++.dg/torture/pr104450.C   -O0  (test for excess errors)

FAIL: gcc.dg/analyzer/pr96713.c (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: gcc.dg/analyzer/pr96713.c (test for excess errors)
FAIL: c-c++-common/opaque-vector.c  -Wc++-compat  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/opaque-vector.c  -Wc++-compat  (test for excess errors)
FAIL: c-c++-common/pr105998.c  -Wc++-compat  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/pr105998.c  -Wc++-compat  (test for excess errors)
FAIL: c-c++-common/vector-scalar.c  -Wc++-compat  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: c-c++-common/vector-scalar.c  -Wc++-compat  (test for excess errors)
FAIL: gcc.dg/pr100239.c (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: gcc.dg/pr100239.c (test for excess errors)
FAIL: gcc.dg/pr97238.c (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: gcc.dg/pr97238.c (test for excess errors)
FAIL: c-c++-common/torture/builtin-shufflevector-2.c   -O0  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: gcc.dg/torture/pr70310.c   -O0  (internal compiler error: in emit_move_multi_word, at expr.cc:4079)
FAIL: gcc.dg/torture/pr70310.c   -O0  (test for excess errors)

gcc/ChangeLog:

* config/riscv/autovec-vls.md: Add VLS mask modes mov patterns.
* config/riscv/riscv.md: Ditto.
* config/riscv/vector-iterators.md: Ditto.
* config/riscv/vector.md: Ditto.

13 months agoRevert: "Another revert test with a bogus hash"
Tobias Burnus [Thu, 7 Sep 2023 11:33:35 +0000 (13:33 +0200)]
Revert: "Another revert test with a bogus hash"

This reverts commit ffffffffffffffffffffffffffffffffffffffff.

This should get rejected because of the invalid hash.
If it still is accepted, it does something sensible:
It removes tailing white space from a line in libgomp/target.c.

13 months agoRevert "contrib/gcc-changelog: Check whether revert-commit exists"
Tobias Burnus [Thu, 7 Sep 2023 11:00:55 +0000 (13:00 +0200)]
Revert "contrib/gcc-changelog: Check whether revert-commit exists"

This reverts commit ffffffffffffffffffffffffffffffffffffffff.

This checks whether the pre-commit hook of the mentioned commit
triggers and rejects this commit due to the bogus commit hash.

This commit actually does not revert that patch but fixes that
patch as 'technically' was accidently re-added in the second
commit.

13 months agocontrib/gcc-changelog: Check whether revert-commit exists
Tobias Burnus [Thu, 7 Sep 2023 10:52:37 +0000 (12:52 +0200)]
contrib/gcc-changelog: Check whether revert-commit exists

This is the identical (except for a ChangeLog typo) to
  commit r14-3777-gff20bce9f5879878f352f1fcd6ade023a2067598

It reverts the test revert in commit
  r14-3778-gfbbd9001e9b6f2c59b542cc53a8f9183514091ce
which has a bogus commit hash and should have been rejected,
but we missed that - before testing - the script had to be
manually copied to the right place on sourceware to be
affective as pre-commit hook.

Thus, the r14-3777 commit had to be reinstate by this commit ...

contrib/ChangeLog:

* gcc-changelog/git_commit.py (GitCommit.__init__):
Handle commit_to_info_hook = None; otherwise, if None,
regard it as error.
(to_changelog_entries): Handle commit_to_info_hook = None;
if info is None, create a warning for it.
* gcc-changelog/git_email.py (GitEmail.__init__):
call super() with commit_to_info_hook=None instead
of a lambda function.

13 months agoRevert "contrib/gcc-changelog: Check whether revert-commit exists"
Tobias Burnus [Thu, 7 Sep 2023 10:40:57 +0000 (12:40 +0200)]
Revert "contrib/gcc-changelog: Check whether revert-commit exists"

This reverts commit ffffffffffffffffffffffffffffffffffffffff.

13 months agocontrib/gcc-changelog: Check whether revert-commit exists
Tobias Burnus [Thu, 7 Sep 2023 10:35:02 +0000 (12:35 +0200)]
contrib/gcc-changelog: Check whether revert-commit exists

contrib/ChangeLog:

* gcc-changelog/git_commit.py (GitCommit.__init__):
Handle commit_to_info_hook = None; otherwise, if None,
regard it as error.
(to_changelog_entries): Handle commit_to_info_hook = None;
if info is None, create a warning for it.
* gcc-changelog/git_email.py (GitEmail.__init__):
call super() with commit_to_info_hook=None instead
of a lamda function.

13 months agogccrs: Experiment with adding an error code to an error
David Malcolm [Thu, 7 Sep 2023 09:33:39 +0000 (11:33 +0200)]
gccrs: Experiment with adding an error code to an error

gcc/rust/ChangeLog:

* rust-diagnostics.cc (rust_error_at): New overload.
* rust-diagnostics.h (struct ErrorCode): New struct.
(rust_error_at): New.
(rust_be_error_at): Likewise.
* rust-gcc-diagnostics.cc (class rust_error_code_rule): New class.
(rust_be_error_at): New function.
* typecheck/rust-casts.cc (TypeCastRules::emit_cast_error): Emit E0054
when reporting invalid cast error.

gcc/testsuite/ChangeLog:

* rust/compile/bad_as_bool_char.rs: Add error code to testcase.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
13 months agodiagnostics: add error_meta
David Malcolm [Thu, 21 Jul 2022 22:35:01 +0000 (18:35 -0400)]
diagnostics: add error_meta

gcc/ChangeLog:

* diagnostic-core.h (error_meta): New decl.
* diagnostic.cc (error_meta): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
13 months agomiddle-end: Avoid calling targetm.c.bitint_type_info inside of gcc_assert [PR102989]
Jakub Jelinek [Thu, 7 Sep 2023 09:17:04 +0000 (11:17 +0200)]
middle-end: Avoid calling targetm.c.bitint_type_info inside of gcc_assert [PR102989]

On Thu, Sep 07, 2023 at 10:36:02AM +0200, Thomas Schwinge wrote:
> Minor comment/question: are we doing away with the property that
> 'assert'-like "calls" must not have side effects?  Per 'gcc/system.h',
> this is "OK" for 'gcc_assert' for '#if ENABLE_ASSERT_CHECKING' or
> '#elif (GCC_VERSION >= 4005)' -- that is, GCC 4.5, which is always-true,
> thus the "offending" '#else' is never active.  However, it's different
> for standard 'assert' and 'gcc_checking_assert', so I'm not sure if
> that's a good property for 'gcc_assert' only?  For example, see also
> <https://gcc.gnu.org/PR6906> "warn about asserts with side effects", or
> recent <https://gcc.gnu.org/PR111144>
> "RFE: could -fanalyzer warn about assertions that have side effects?".

You're right, the
  #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
fallback definition is incompatible with the way I've used it, so for
--disable-checking built by non-GCC it would not work properly.

2023-09-07  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
* expr.cc (expand_expr_real_1): Don't call targetm.c.bitint_type_info
inside gcc_assert, as later code relies on it filling info variable.
* gimple-fold.cc (clear_padding_bitint_needs_padding_p,
clear_padding_type): Likewise.
* varasm.cc (output_constant): Likewise.
* fold-const.cc (native_encode_int, native_interpret_int): Likewise.
* stor-layout.cc (finish_bitfield_representative, layout_type):
Likewise.
* gimple-lower-bitint.cc (bitint_precision_kind): Likewise.

13 months agoLoongArch: Use bstrins instruction for (a & ~mask) and (a & mask) | (b & ~mask) ...
Xi Ruoyao [Tue, 5 Sep 2023 11:42:30 +0000 (19:42 +0800)]
LoongArch: Use bstrins instruction for (a & ~mask) and (a & mask) | (b & ~mask) [PR111252]

If mask is a constant with value ((1 << N) - 1) << M we can perform this
optimization.

gcc/ChangeLog:

PR target/111252
* config/loongarch/loongarch-protos.h
(loongarch_pre_reload_split): Declare new function.
(loongarch_use_bstrins_for_ior_with_mask): Likewise.
* config/loongarch/loongarch.cc
(loongarch_pre_reload_split): Implement.
(loongarch_use_bstrins_for_ior_with_mask): Likewise.
* config/loongarch/predicates.md (ins_zero_bitmask_operand):
New predicate.
* config/loongarch/loongarch.md (bstrins_<mode>_for_mask):
New define_insn_and_split.
(bstrins_<mode>_for_ior_mask): Likewise.
(define_peephole2): Further optimize code sequence produced by
bstrins_<mode>_for_ior_mask if possible.

gcc/testsuite/ChangeLog:

* g++.target/loongarch/bstrins-compile.C: New test.
* g++.target/loongarch/bstrins-run.C: New test.

13 months agolibstdc++: Fix missing/misplaced { dg-options "-std=gnu++20" } in tests
Jonathan Wakely [Wed, 6 Sep 2023 23:21:37 +0000 (00:21 +0100)]
libstdc++: Fix missing/misplaced { dg-options "-std=gnu++20" } in tests

These tests do not run by default, because the c++20 effective target
selector isn't matched.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/unordered_map/operations/1.cc: Add
dg-options for C++20 mode.
* testsuite/23_containers/unordered_multimap/operations/1.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/operations/1.cc:
Likewise.
* testsuite/23_containers/unordered_set/operations/1.cc:
Likewise.
* testsuite/std/time/parse.cc: Move dg-options before dg-do.

13 months agolibstdc++: Fix <ranges> tests that fail in C++23
Jonathan Wakely [Wed, 6 Sep 2023 13:13:18 +0000 (14:13 +0100)]
libstdc++: Fix <ranges> tests that fail in C++23

The tests for the std::ranges access CPOs (ranges::begin etc) use
pathological types with ridiculous overload sets for begin/end/data
members, to exercise all the corner cases in the specification.

Since P2278R4 "cbegin should always return a constant iterator" was
implemented for C++23 mode, some of the range access CPOs now require
the argument to satisfy the range concept, which was not previously
required. The behaviour of the CPO also changes for corner cases where
the type is a range R for which constant_range<R> is satisfied in
addition to constant_range<const R> (meaning there's no need to wrap its
iterators in const_iterator). Adjust the expected results for those
pathological types that changed meaning in C++23, and add some new types
to verify other corner cases.

Some other range adaptor tests fail for C++20 because they assert that
ranges::end and ranges::cend return different types, which is not true
when the type satisfies constant_range.

This fixes the tests to PASS for both C++20 and C++23 (and later).

libstdc++-v3/ChangeLog:

* testsuite/std/ranges/access/cbegin.cc: Adjust for C++23
compatibility.
* testsuite/std/ranges/access/cdata.cc: Likewise.
* testsuite/std/ranges/access/cend.cc: Likewise.
* testsuite/std/ranges/access/crbegin.cc: Likewise.
* testsuite/std/ranges/access/crend.cc: Likewise.
* testsuite/std/ranges/adaptors/take.cc: Likewise.
* testsuite/std/ranges/adaptors/take_while.cc: Likewise.
* testsuite/std/ranges/adaptors/transform.cc: Likewise.

13 months agolibstdc++: Simplify C++20 poison pill overloads (P2602R2)
Jonathan Wakely [Wed, 6 Sep 2023 12:36:02 +0000 (13:36 +0100)]
libstdc++: Simplify C++20 poison pill overloads (P2602R2)

This implements the C++23 change "Poison Pills are Too Toxic". This
makes sense to do unconditionally for C++20, as the corner cases that it
fixes are considered to be defects in the C++20 design (e.g. LWG3480 was
needed to fix directory iterators because of these pills being too
toxic).

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (__imove::iter_move): Define
poison pill as deleted for consistency.
(__access::begin): Replace with a single declaration.
* include/bits/ranges_base.h (__access::end, __access::rbegin)
(__access::rend, __access::size): Likewise.
* include/bits/version.def (ranges): Update value for C++23.
* include/bits/version.h: Regenerate.
* libsupc++/compare (__compare): Add missing poison pill
overloads.
* testsuite/std/ranges/version_c++23.cc: Adjust expected value
of __cpp_lib_ranges.
* testsuite/std/ranges/access/p2602.cc: New test.

13 months agolibstdc++: Rename C++20 Customization Point Objects
Jonathan Wakely [Wed, 6 Sep 2023 12:21:57 +0000 (13:21 +0100)]
libstdc++: Rename C++20 Customization Point Objects

This makes the naming of the CPO types and namespaces simpler and more
consistent. With this change the string "cust" won't appear in
diagnostics related to these CPOs, which avoids confusion about what it
means (customization? customer?). Users don't really need to care that
these are called "customization point objects", so don't show them the
string "cust". Names like "__imove::_IterMove" are preferable to names
like "__cust_imove::_IMove" as the former is more obviously related to
the public API "ranges::iter_move".

Instead of a plethora of inline namespaces for all the different CPO
objects, define them all in an inline namespace called _Cpo (which isn't
shown to users anyway, unlike the types of those objects).

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (ranges::__cust_imove):
Rename to ranges::__imove.
(_IMove): Rename to _IterMove.
(ranges::__cust_iswap): Rename to ranges::__iswap.
(ranges::__cust): Rename to ranges::_Cpo.
(ranges::__cust_access): Rename to ranges::__access.
* include/bits/ranges_base.h (ranges::__cust_access): Rename to
ranges::__access.
(ranges::__cust): Rename to ranges::_Cpo.
* include/std/concepts (ranges::__cust_swap):  Rename to
ranges::__swap.
(ranges::__cust): Rename to ranges::_Cpo.
* libsupc++/compare (__cmp_cust): Rename to __compare.
(__cmp_algo): Rename to _Cpo.

13 months agolibstdc++: Relax range adaptors for move-only types (P2494R2)
Jonathan Wakely [Tue, 5 Sep 2023 21:07:22 +0000 (22:07 +0100)]
libstdc++: Relax range adaptors for move-only types (P2494R2)

This is a C++23 feature that relaxes the constraints on some range
adaptors, to support move-only types.

libstdc++-v3/ChangeLog:

* include/bits/version.def (ranges): Update value.
* include/bits/version.h: Regenerate.
* include/std/ranges (__detail::__boxable): Use
move_constructible instead of copy_constructible for C++23.
(__detail::__box<T>): Adjust constraints for partial
specialization.
(single_view, transform_view): Use __box_constructible instead
of copy_constructible in constraints.
(zip_transform_view, adjacent_transform_view, repeat_view): Use
move_constructible instead of copy_constructible in constraints.
* testsuite/std/ranges/adaptors/adjacent_transform/1.cc: Check
construction from move-only argument.
* testsuite/std/ranges/adaptors/transform.cc: Likewise.
* testsuite/std/ranges/repeat/1.cc: Likewise.
* testsuite/std/ranges/single_view.cc: Likewise.
* testsuite/std/ranges/zip_transform/1.cc: Likewise.
* testsuite/std/ranges/version_c++23.cc: Adjust expected value
of __cpp_lib_ranges.

13 months agolibstdc++: Avoid -Wunused-parameter warning in testsuite helper
Jonathan Wakely [Tue, 5 Sep 2023 10:24:09 +0000 (11:24 +0100)]
libstdc++: Avoid -Wunused-parameter warning in testsuite helper

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_iterators.h (is_customization_point_object):
Remove parameter name.

13 months agolra: Avoid unfolded plus-0
Richard Sandiford [Thu, 7 Sep 2023 06:28:50 +0000 (07:28 +0100)]
lra: Avoid unfolded plus-0

While backporting another patch to an earlier release, I hit a
situation in which lra_eliminate_regs_1 would eliminate an address to:

    (plus (reg:P R) (const_int 0))

This address compared not-equal to plain:

    (reg:P R)

which caused an ICE in a later peephole2.  (The ICE showed up in
gfortran.fortran-torture/compile/pr80464.f90 on the branch but seems
to be latent on trunk.)

These unfolded PLUSes shouldn't occur in the insn stream, and later code
in the same function tried to avoid them.

gcc/
* lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary
rather than gen_rtx_PLUS.

13 months agoRISC-V: Remove incorrect earliest vsetvl post optimization[PR111313]
Juzhe-Zhong [Thu, 7 Sep 2023 03:35:53 +0000 (11:35 +0800)]
RISC-V: Remove incorrect earliest vsetvl post optimization[PR111313]

This patch removes the incorrect earliest poset vsetvl optimization,
such bug was found in vect-double-reduc-5.c which is runtime(execution fail) and also in PR111313.

For VLMAX intrinsics, we always emit a bogus patter which is vlmax_avl (see vector.md) to
occupy a scalar register which is used by the following RVV instruction which is VLMAX AVL.

Then for O2, O3, Ofast, earliest LCM works so well.
However, for O1, the vlmax_avl is not well optimized in the before pass which confused LCM earliest
so that we will end up with some redundant vsetvli zero,zero instructions in O1. (Note that O2 O3 Ofast are all good).

To elide those redundant vsetvli zero,zero, I added cleanup_earliest_vsetvls to elide those redundant vsetvls.

Now, after I review the implementation of this post optimizaiton again, I found it is incorrect and it is hard to
do the post optimizations for vsetvls that earliest LCM failed to eliminate.

Besides, such performance issues only happen in O1 or O0, such issues may not be serious.
So remove it and we may will find another way (E.g. adjust vlmax_avl pattern COST)
to optimize it if we really need to care about performance for O1.

PR target/111313

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (pass_vsetvl::cleanup_earliest_vsetvls): Remove.
(pass_vsetvl::df_post_optimization): Remove incorrect function.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/avl_single-13.c: Adapt test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-17.c: Skip check for O1.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-19.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-20.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-1.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-10.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-13.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-14.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-16.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-17.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-19.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-2.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-20.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-21.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-22.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-23.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-24.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-25.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-26.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-27.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-28.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-3.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-4.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-5.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-6.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-7.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-8.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-9.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/pr111313.c: New test.

13 months agoRISC-V: Add support for 'XVentanaCondOps' reusing 'Zicond' support
Tsukasa OI [Wed, 30 Aug 2023 02:34:35 +0000 (02:34 +0000)]
RISC-V: Add support for 'XVentanaCondOps' reusing 'Zicond' support

'XVentanaCondOps' is a vendor extension from Ventana Micro Systems
containing two instructions for conditional move and will be supported on
their Veyron V1 CPU.

And most notably (for historical reasons), 'XVentanaCondOps' and the
standard 'Zicond' extension are functionally equivalent (only encodings and
instruction names are different).

*   czero.eqz == vt.maskc
*   czero.nez == vt.maskcn

This commit adds support for the 'XVentanaCondOps' extension by extending
'Zicond' extension support.  With this, we can now reuse the optimization
using the 'Zicond' extension for the 'XVentanaCondOps' extension.

The specification for the 'XVentanaCondOps' extension is based on:
<https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.1/ventana-custom-extensions-v1.0.1.pdf>

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_ext_flag_table):
Parse 'XVentanaCondOps' extension.
* config/riscv/riscv-opts.h (MASK_XVENTANACONDOPS): New.
(TARGET_XVENTANACONDOPS): Ditto.
(TARGET_ZICOND_LIKE): New to represent targets with conditional
moves like 'Zicond'.  It includes RV64 + 'XVentanaCondOps'.
* config/riscv/riscv.cc (riscv_rtx_costs): Replace TARGET_ZICOND
with TARGET_ZICOND_LIKE.
(riscv_expand_conditional_move): Ditto.
* config/riscv/riscv.md (mov<mode>cc): Replace TARGET_ZICOND with
TARGET_ZICOND_LIKE.
* config/riscv/riscv.opt: Add new riscv_xventana_subext.
* config/riscv/zicond.md: Modify description.
(eqz_ventana): New to match corresponding czero instructions.
(nez_ventana): Ditto.
(*czero.<eqz>.<GPR><X>): Emit a 'XVentanaCondOps' instruction if
'Zicond' is not available but 'XVentanaCondOps' + RV64 is.
(*czero.<eqz>.<GPR><X>): Ditto.
(*czero.eqz.<GPR><X>.opt1): Ditto.
(*czero.nez.<GPR><X>.opt2): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xventanacondops-primitiveSemantics.c: New test,
* gcc.target/riscv/xventanacondops-primitiveSemantics-rv32.c: New
test to make sure that XVentanaCondOps instructions are disabled
on RV32.
* gcc.target/riscv/xventanacondops-xor-01.c: New test,

13 months agoDaily bump.
GCC Administrator [Thu, 7 Sep 2023 00:17:36 +0000 (00:17 +0000)]
Daily bump.

13 months ago-fgo-dump-spec: support _BitInt
Ian Lance Taylor [Wed, 6 Sep 2023 22:09:31 +0000 (15:09 -0700)]
-fgo-dump-spec: support _BitInt

gcc/
PR go/111310
* godump.cc (go_format_type): Handle BITINT_TYPE.

gcc/testsuite/
PR go/111310
* gcc.misc-tests/godump-1.c: Add _BitInt test cases.

13 months agolibstdc++: Disable <stacktrace> support by default for freestanding
Jonathan Wakely [Tue, 5 Sep 2023 10:14:02 +0000 (11:14 +0100)]
libstdc++: Disable <stacktrace> support by default for freestanding

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Disable by default
for freestanding.
* configure: Regenerate.

13 months agocmd/go: permit $AR to include options
Ian Lance Taylor [Wed, 6 Sep 2023 18:21:11 +0000 (11:21 -0700)]
cmd/go: permit $AR to include options

Handle the AR environment variable, used by gccgo,
the same way we handle the CC environment variable.

This ports https://go.dev/cl/526275 to the gofrontend repo.

This is needed for gccgo testing because the top-level GCC Makefile
now passes a --plugin option to ar if it supports one.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/526295

13 months agoAdditional _BitInt test coverage [PR102989]
Jakub Jelinek [Wed, 6 Sep 2023 15:52:24 +0000 (17:52 +0200)]
Additional _BitInt test coverage [PR102989]

On Tue, Sep 05, 2023 at 10:40:26PM +0000, Joseph Myers wrote:
> Additional tests I think should be added (for things I expect should
> already work):
>
> * Tests for BITINT_MAXWIDTH in <limits.h>.  Test that it's defined for
> C2x, but not defined for C11/C17 (the latter independent of whether the
> target has _BitInt support).  Test the value as well: _BitInt
> (BITINT_MAXWIDTH) should be OK (both signed and unsigned) but _BitInt
> (BITINT_MAXWIDTH + 1) should not be OK.  Also test that BITINT_MAXWIDTH >=
> ULLONG_MAX.
>
> * Test _BitInt (N) where N is a constexpr variable or enum constant (I
> expect these should work - the required call to convert_lvalue_to_rvalue
> for constexpr to work is present - but I don't see such tests in the
> testsuite).
>
> * Test that -funsigned-bitfields does not affect the signedness of _BitInt
> (N) bit-fields (the standard wording isn't entirely clear, but that's
> what's implemented in the patches).
>
> * Test the errors for _Sat used with _BitInt (though such a test might not
> actually run at present because no target supports both features).

The following patch does that plus for most of the new changes in the
C _BitInt support patch requested in patch review it also does testsuite
coverage.

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
* gcc.dg/bitint-2.c (foo): Add tests for constexpr var or enumerator
arguments of _BitInt.
* gcc.dg/bitint-31.c: Remove forgotten 0 &&.
* gcc.dg/bitint-32.c: New test.
* gcc.dg/bitint-33.c: New test.
* gcc.dg/bitint-34.c: New test.
* gcc.dg/bitint-35.c: New test.
* gcc.dg/bitint-36.c: New test.
* gcc.dg/fixed-point/bitint-1.c: New test.

13 months agoHandle BITINT_TYPE in build_{,minus_}one_cst [PR102989]
Jakub Jelinek [Wed, 6 Sep 2023 15:50:49 +0000 (17:50 +0200)]
Handle BITINT_TYPE in build_{,minus_}one_cst [PR102989]

Recent match.pd changes trigger ICE in build_minus_one_cst, apparently
I forgot to handle BITINT_TYPE in these (while I've handled it in
build_zero_cst).

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
* tree.cc (build_one_cst, build_minus_one_cst): Handle BITINT_TYPE
like INTEGER_TYPE.

13 months ago_BitInt profile fixes [PR102989]
Jakub Jelinek [Wed, 6 Sep 2023 15:49:44 +0000 (17:49 +0200)]
_BitInt profile fixes [PR102989]

On Thu, Aug 24, 2023 at 03:14:32PM +0200, Jan Hubicka via Gcc-patches wrote:
> this patch extends verifier to check that all probabilities and counts are
> initialized if profile is supposed to be present.  This is a bit complicated
> by the posibility that we inline !flag_guess_branch_probability function
> into function with profile defined and in this case we need to stop
> verification.  For this reason I added flag to cfg structure tracking this.

This patch broke a couple of _BitInt tests (in the admittedly still
uncommitted series - still waiting for review of the C FE bits).

Here is a minimal patch to make it work again, though I'm not sure
if in the if_then_else and if_then_if_then_else cases I shouldn't scale
count of the other bbs as well.  if_then method creates
if (COND) new_bb1;
in a middle of some pre-existing bb (with PROB that COND is true), if_then_else
if (COND) new_bb1; else new_bb2;
and if_then_if_then_else
if (COND1) { if (COND2) new_bb2; else new_bb1; }
with PROB1 and PROB2 probabilities that COND1 and COND2 are true.
The lowering happens shortly after IPA.

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
* gimple-lower-bitint.cc (bitint_large_huge::if_then_else,
bitint_large_huge::if_then_if_then_else): Use make_single_succ_edge
rather than make_edge, initialize bb->count.

13 months agoAdd further _BitInt <-> floating point tests [PR102989]
Jakub Jelinek [Wed, 6 Sep 2023 15:47:49 +0000 (17:47 +0200)]
Add further _BitInt <-> floating point tests [PR102989]

Here are just the testsuite additions from libgcc _BitInt patch review.

On Fri, Sep 01, 2023 at 09:48:22PM +0000, Joseph Myers wrote:
> 1. Test overflowing conversions to integers (including from inf or NaN)
> raise FE_INVALID.  (Note: it's not specified in the standard whether
> inexact conversions to integers raise FE_INEXACT or not, so testing that
> seems less important.)

This is in gcc.dg/bitint-28.c (FE_INVALID) and gcc.dg/bitint-29.c
(FE_INEXACT) for binary and dfp/bitint-8.c new tests.

> 2. Test conversions from integers to floating point raise FE_INEXACT when
> inexact, together with FE_OVERFLOW when overflowing (while exact
> conversions don't raise exceptions).

This is in gcc.dg/bitint-30.c new test.

> 3. Test conversions from integers to floating point respect the rounding
> mode.

This is in gcc.dg/bitint-31.c new test.

> 4. Test converting floating-point values in the range (-1.0, 0.0] to both
> unsigned and signed _BitInt; I didn't see such tests for binary floating
> types, only for decimal types, and the decimal tests didn't include tests
> of negative zero itself as the value converted to _BitInt.

This is done as incremental changes to existing tests.

> 5. Test conversions of noncanonical BID zero to integers (these tests
> would be specific to BID).  See below for a bug in this area.

This is done in dfp/bitint-7.c test.

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
* gcc.dg/torture/bitint-21.c (main): Add tests for -1 for signed only,
-1 + epsilon, another (-1, 0) range value and -0.
* gcc.dg/torture/bitint-22.c (main): Likewise.
* gcc.dg/bitint-28.c: New test.
* gcc.dg/bitint-29.c: New test.
* gcc.dg/bitint-30.c: New test.
* gcc.dg/bitint-31.c: New test.
* gcc.dg/dfp/bitint-1.c (main): Add tests for -1 for signed only,
-1 + epsilon and -0.
* gcc.dg/dfp/bitint-2.c (main): Likewise.
* gcc.dg/dfp/bitint-3.c (main): Likewise.
* gcc.dg/dfp/bitint-7.c: New test.
* gcc.dg/dfp/bitint-8.c: New test.

13 months agolibgcc _BitInt helper documentation [PR102989]
Jakub Jelinek [Wed, 6 Sep 2023 15:42:37 +0000 (17:42 +0200)]
libgcc _BitInt helper documentation [PR102989]

On Mon, Aug 21, 2023 at 05:32:04PM +0000, Joseph Myers wrote:
> I think the libgcc functions (i.e. those exported by libgcc, to which
> references are generated by the compiler) need documenting in libgcc.texi.
> Internal functions or macros in the libgcc patch need appropriate comments
> specifying their semantics; especially FP_TO_BITINT and FP_FROM_BITINT
> which have a lot of arguments and no comments saying what the semantics of
> the macros and their arguments are supposed to me.

Here is an incremental patch which does that.

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
gcc/
* doc/libgcc.texi (Bit-precise integer arithmetic functions):
Document general rules for _BitInt support library functions
and document __mulbitint3 and __divmodbitint4.
(Conversion functions): Document __fix{s,d,x,t}fbitint,
__floatbitint{s,d,x,t,h,b}f, __bid_fix{s,d,t}dbitint and
__bid_floatbitint{s,d,t}d.
libgcc/
* libgcc2.c (bitint_negate): Add function comment.
* soft-fp/bitint.h (bitint_negate): Add function comment.
(FP_TO_BITINT, FP_FROM_BITINT): Add comment explaining the macros.

13 months agoC _BitInt incremental fixes [PR102989]
Jakub Jelinek [Wed, 6 Sep 2023 15:39:15 +0000 (17:39 +0200)]
C _BitInt incremental fixes [PR102989]

On Wed, Aug 09, 2023 at 09:17:57PM +0000, Joseph Myers wrote:
> > - _Complex _BitInt(N) isn't supported; again mainly because none of the psABIs
> >   mention how those should be passed/returned; in a limited way they are
> >   supported internally because the internal functions into which
> >   __builtin_{add,sub,mul}_overflow{,_p} is lowered return COMPLEX_TYPE as a
> >   hack to return 2 values without using references/pointers
>
> What happens when the usual arithmetic conversions are applied to
> operands, one of which is a complex integer type and the other of which is
> a wider _BitInt type?  I don't see anything in the code to disallow this
> case (which would produce an expression with a _Complex _BitInt type), or
> any testcases for it.

I've added a sorry for that case (+ return the narrower COMPLEX_TYPE).
Also added testcase to verify we don't create VECTOR_TYPEs of BITINT_TYPE
even if they have mode precision and suitable size (others were rejected
already before).

> Other testcases I think should be present (along with any corresponding
> changes needed to the code itself):
>
> * Verifying that the new integer constant suffix is rejected for C++.

Done.

> * Verifying appropriate pedwarn-if-pedantic for the new constant suffix
> for versions of C before C2x (and probably for use of _BitInt type
> specifiers before C2x as well) - along with the expected -Wc11-c2x-compat
> handling (in C2x mode) / -pedantic -Wno-c11-c2x-compat in older modes.

Done.

Here is an incremental patch which does that.

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
gcc/c/
* c-decl.cc (finish_declspecs): Emit pedwarn_c11 on _BitInt.
* c-typeck.cc (c_common_type): Emit sorry for common type between
_Complex integer and larger _BitInt and return the _Complex integer.
gcc/c-family/
* c-attribs.cc (type_valid_for_vector_size): Reject vector types
with BITINT_TYPE elements even if they have mode precision and
suitable size.
gcc/testsuite/
* gcc.dg/bitint-19.c: New test.
* gcc.dg/bitint-20.c: New test.
* gcc.dg/bitint-21.c: New test.
* gcc.dg/bitint-22.c: New test.
* gcc.dg/bitint-23.c: New test.
* gcc.dg/bitint-24.c: New test.
* gcc.dg/bitint-25.c: New test.
* gcc.dg/bitint-26.c: New test.
* gcc.dg/bitint-27.c: New test.
* g++.dg/ext/bitint1.C: New test.
* g++.dg/ext/bitint2.C: New test.
* g++.dg/ext/bitint3.C: New test.
* g++.dg/ext/bitint4.C: New test.
libcpp/
* expr.cc (cpp_classify_number): Diagnose wb literal suffixes
for -pedantic* before C2X or -Wc11-c2x-compat.

13 months agotestsuite part 2 for _BitInt support [PR102989]
Jakub Jelinek [Wed, 6 Sep 2023 15:37:53 +0000 (17:37 +0200)]
testsuite part 2 for _BitInt support [PR102989]

This is second part of the testcase additions in order to fit into
mailing lists limits.  Most of these tests are for the floating
point conversions, atomics, __builtin_*_overflow and -fsanitize=undefined.

2023-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/102989
gcc/testsuite/
* gcc.dg/torture/bitint-20.c: New test.
* gcc.dg/torture/bitint-21.c: New test.
* gcc.dg/torture/bitint-22.c: New test.
* gcc.dg/torture/bitint-23.c: New test.
* gcc.dg/torture/bitint-24.c: New test.
* gcc.dg/torture/bitint-25.c: New test.
* gcc.dg/torture/bitint-26.c: New test.
* gcc.dg/torture/bitint-27.c: New test.
* gcc.dg/torture/bitint-28.c: New test.
* gcc.dg/torture/bitint-29.c: New test.
* gcc.dg/torture/bitint-30.c: New test.
* gcc.dg/torture/bitint-31.c: New test.
* gcc.dg/torture/bitint-32.c: New test.
* gcc.dg/torture/bitint-33.c: New test.
* gcc.dg/torture/bitint-34.c: New test.
* gcc.dg/torture/bitint-35.c: New test.
* gcc.dg/torture/bitint-36.c: New test.
* gcc.dg/torture/bitint-37.c: New test.
* gcc.dg/torture/bitint-38.c: New test.
* gcc.dg/torture/bitint-39.c: New test.
* gcc.dg/torture/bitint-40.c: New test.
* gcc.dg/torture/bitint-41.c: New test.
* gcc.dg/torture/bitint-42.c: New test.
* gcc.dg/atomic/stdatomic-bitint-1.c: New test.
* gcc.dg/atomic/stdatomic-bitint-2.c: New test.
* gcc.dg/dfp/bitint-1.c: New test.
* gcc.dg/dfp/bitint-2.c: New test.
* gcc.dg/dfp/bitint-3.c: New test.
* gcc.dg/dfp/bitint-4.c: New test.
* gcc.dg/dfp/bitint-5.c: New test.
* gcc.dg/dfp/bitint-6.c: New test.
* gcc.dg/ubsan/bitint-1.c: New test.
* gcc.dg/ubsan/bitint-2.c: New test.
* gcc.dg/ubsan/bitint-3.c: New test.

This page took 0.126832 seconds and 5 git commands to generate.