]> gcc.gnu.org Git - gcc.git/log
gcc.git
10 months agoAdd ChangeLog.vsubreg and update REVISION.
Michael Meissner [Fri, 17 Nov 2023 17:31:38 +0000 (12:31 -0500)]
Add ChangeLog.vsubreg and update REVISION.

2023-11-17  Michael Meissner  <meissner@linux.ibm.com>

gcc/

* ChangeLog.vsubreg: New file for branch.
* REVISION: Update.

10 months agoAdd ChangeLog.meissner and REVISION.
Michael Meissner [Fri, 17 Nov 2023 17:28:13 +0000 (12:28 -0500)]
Add ChangeLog.meissner and REVISION.

2023-11-17  Michael Meissner  <meissner@linux.ibm.com>

gcc/

* REVISION: New file for branch.
* ChangeLog.meissner: New file.

gcc/c-family/

* ChangeLog.meissner: New file.

gcc/c/

* ChangeLog.meissner: New file.

gcc/cp/

* ChangeLog.meissner: New file.

gcc/fortran/

* ChangeLog.meissner: New file.

gcc/testsuite/

* ChangeLog.meissner: New file.

libgcc/

* ChangeLog.meissner: New file.

10 months agolibstdc++: Regenerate config.h.in
Jonathan Wakely [Fri, 17 Nov 2023 14:38:56 +0000 (14:38 +0000)]
libstdc++: Regenerate config.h.in

libstdc++-v3/ChangeLog:

* config.h.in: Regenerate.

10 months agolibstdc++: Define C++26 saturation arithmetic functions (P0543R3)
Jonathan Wakely [Fri, 17 Nov 2023 13:01:17 +0000 (13:01 +0000)]
libstdc++: Define C++26 saturation arithmetic functions (P0543R3)

This was approved for C++26 last week at the WG21 meeting in Kona.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/version.def (saturation_arithmetic): Define.
* include/bits/version.h: Regenerate.
* include/std/numeric: Include new header.
* include/bits/sat_arith.h: New file.
* testsuite/26_numerics/saturation/add.cc: New test.
* testsuite/26_numerics/saturation/cast.cc: New test.
* testsuite/26_numerics/saturation/div.cc: New test.
* testsuite/26_numerics/saturation/mul.cc: New test.
* testsuite/26_numerics/saturation/sub.cc: New test.
* testsuite/26_numerics/saturation/version.cc: New test.

10 months agoc++: Implement C++ DR 2406 - [[fallthrough]] attribute and iteration statements
Jakub Jelinek [Fri, 17 Nov 2023 14:43:31 +0000 (15:43 +0100)]
c++: Implement C++ DR 2406 - [[fallthrough]] attribute and iteration statements

The following patch implements
CWG 2406 - [[fallthrough]] attribute and iteration statements
The genericization of some loops leaves nothing at all or just a label
after a body of a loop, so if the loop is later followed by
case or default label in a switch, the fallthrough statement isn't
diagnosed.

The following patch implements it by marking the IFN_FALLTHROUGH call
in such a case, such that during gimplification it can be pedantically
diagnosed even if it is followed by case or default label or some normal
labels followed by case/default labels.

While looking into this, I've discovered other problems.
expand_FALLTHROUGH_r is removing the IFN_FALLTHROUGH calls from the IL,
but wasn't telling that to walk_gimple_stmt/walk_gimple_seq_mod, so
the callers would then skip the next statement after it, and it would
return non-NULL if the removed stmt was last in the sequence.  This could
lead to wi->callback_result being set even if it didn't appear at the very
end of switch sequence.
The patch makes use of wi->removed_stmt such that the callers properly
know what happened, and use different way to handle the end of switch
sequence case.

That change discovered a bug in the gimple-walk handling of
wi->removed_stmt.  If that flag is set, the callback is telling the callers
that the current statement has been removed and so the innermost
walk_gimple_seq_mod shouldn't gsi_next.  The problem is that
wi->removed_stmt is only reset at the start of a walk_gimple_stmt, but that
can be too late for some cases.  If we have two nested gimple sequences,
say GIMPLE_BIND as the last stmt of some gimple seq, we remove the last
statement inside of that GIMPLE_BIND, set wi->removed_stmt there, don't
do gsi_next correctly because already gsi_remove moved us to the next stmt,
there is no next stmt, so we return back to the caller, but wi->removed_stmt
is still set and so we don't do gsi_next even in the outer sequence, despite
the GIMPLE_BIND (etc.) not being removed.  That means we walk the
GIMPLE_BIND with its whole sequence again.
The patch fixes that by resetting wi->removed_stmt after we've used that
flag in walk_gimple_seq_mod.  Nothing really uses that flag after the
outermost walk_gimple_seq_mod, it is just a private notification that
the stmt callback has removed a stmt.

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

PR c++/107571
gcc/
* gimplify.cc (expand_FALLTHROUGH_r): Use wi->removed_stmt after
gsi_remove, change the way of passing fallthrough stmt at the end
of sequence to expand_FALLTHROUGH.  Diagnose IFN_FALLTHROUGH
with GF_CALL_NOTHROW flag.
(expand_FALLTHROUGH): Change loc into array of 2 location_t elts,
don't test wi.callback_result, instead check whether first
elt is not UNKNOWN_LOCATION and in that case pedwarn with the
second location.
* gimple-walk.cc (walk_gimple_seq_mod): Clear wi->removed_stmt
after the flag has been used.
* internal-fn.def (FALLTHROUGH): Mention in comment the special
meaning of the TREE_NOTHROW/GF_CALL_NOTHROW flag on the calls.
gcc/c-family/
* c-gimplify.cc (genericize_c_loop): For C++ mark IFN_FALLTHROUGH
call at the end of loop body as TREE_NOTHROW.
gcc/testsuite/
* g++.dg/DRs/dr2406.C: New test.

10 months agolibstdc++: Adjust std::in_range template parameter name
Jonathan Wakely [Fri, 17 Nov 2023 12:18:17 +0000 (12:18 +0000)]
libstdc++: Adjust std::in_range template parameter name

This is more consistent with the specification in the standard.

libstdc++-v3/ChangeLog:

* include/std/utility (in_range): Rename _Up parameter to _Res.

10 months agolibstdc++: Add more Doxygen comments and another test for std::out_ptr
Jonathan Wakely [Fri, 17 Nov 2023 12:52:45 +0000 (12:52 +0000)]
libstdc++: Add more Doxygen comments and another test for std::out_ptr

Improve Doxygen comments for std::out_ptr etc. and add a test for the
feature test macro.  Also remove a redundant preprocessor condition.

Ideally the docs for std::out_ptr and std::inout_ptr would show examples
of how to use them and what they do, but that would take some effort.
I'll aim to do that before GCC 14 is released.

libstdc++-v3/ChangeLog:

* include/bits/out_ptr.h: Add Doxygen comments. Remove a
redundant preprocessor condition.
* testsuite/20_util/smartptr.adapt/version.cc: New test.

10 months agolibstdc++: Fix Doxygen markup
Jonathan Wakely [Fri, 17 Nov 2023 12:24:03 +0000 (12:24 +0000)]
libstdc++: Fix Doxygen markup

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h: Fix Doxygen markup.

10 months agomatch.pd: Optimize ctz/popcount/parity/ffs on extended argument [PR112566]
Jakub Jelinek [Fri, 17 Nov 2023 14:10:51 +0000 (15:10 +0100)]
match.pd: Optimize ctz/popcount/parity/ffs on extended argument [PR112566]

ctz(ext(X)) is the same as ctz(X) in the UB on zero case (or could be also
in the 2 argument case on large BITINT_TYPE by preserving the argument, not
implemented in this patch),
popcount(zext(X)) is the same as popcount(X),
parity(zext(X)) is the same as parity(X),
parity(sext(X)) is the same as parity(X) provided the bit difference between
the extended and unextended types is even,
ffs(ext(X)) is the same as ffs(X).

The following patch optimizes those in match.pd if those are beneficial
(always in the large BITINT_TYPE case, or if the narrower type has optab
and the wider doesn't, or the wider is larger than word and narrower is
one of the standard argument sizes (tested just int and long long, as
long is on most targets same bitsize as one of those two).

Joseph in the PR mentioned that ctz(narrow(X)) is the same as ctz(X)
if UB on 0, but that can be handled incrementally (and would need different
decisions when it is profitable).
And clz(zext(X)) is clz(X) + bit_difference, but not sure we want to change
that in match.pd at all, perhaps during insn selection?

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

PR tree-optimization/112566
PR tree-optimization/83171
* match.pd (ctz(ext(X)) -> ctz(X), popcount(zext(X)) -> popcount(X),
parity(ext(X)) -> parity(X), ffs(ext(X)) -> ffs(X)): New
simplifications.
( __builtin_ffs (X) == 0 -> X == 0): Use FFS rather than
BUILT_IN_FFS BUILT_IN_FFSL BUILT_IN_FFSLL BUILT_IN_FFSIMAX.

* gcc.dg/pr112566-1.c: New test.
* gcc.dg/pr112566-2.c: New test.
* gcc.target/i386/pr78057.c (foo): Pass another long long argument
and use it in __builtin_ia32_*zcnt_u64 instead of the int one.

10 months agovect: Fix check_reduction_path [PR112374]
Jakub Jelinek [Fri, 17 Nov 2023 14:09:44 +0000 (15:09 +0100)]
vect: Fix check_reduction_path [PR112374]

As mentioned in the PR, the intent of the r14-5076 changes was that
it doesn't count one of the uses on the use_stmt, but what actually
got implemented is that it does this processing on any op_use_stmt,
even if it is not the use_stmt statement, which means that it
can increase count even on debug stmts (-fcompare-debug failures),
or if there would be some other use stmt with 2+ uses it could count
that as a single use.  Though, because it fails whenever cnt != 1
and I believe use_stmt must be one of the uses, it would probably
fail in the latter case anyway.

The following patch fixes that by doing this extra processing only when
op_use_stmt is use_stmt, and using the normal processing otherwise
(so ignore debug stmts, and increase on any uses on the stmt).

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

PR tree-optimization/112374
* tree-vect-loop.cc (check_reduction_path): Perform the cond_fn_p
special case only if op_use_stmt == use_stmt, use as_a rather than
dyn_cast in that case.

* gcc.dg/pr112374-1.c: New test.
* gcc.dg/pr112374-2.c: New test.
* g++.dg/opt/pr112374.C: New test.

10 months agotree-optimization/112585 - new testcase
Richard Biener [Fri, 17 Nov 2023 13:49:06 +0000 (14:49 +0100)]
tree-optimization/112585 - new testcase

The offending commit r14-5444-g5ea2965b499f9e was reverted.  The
following adds a testcase.

PR tree-optimization/112585
* gcc.dg/torture/pr112585.c: New testcase.

10 months agoRevert "tree-optimization/112281 - loop distribution and zero dependence distances"
Richard Biener [Fri, 17 Nov 2023 13:47:07 +0000 (14:47 +0100)]
Revert "tree-optimization/112281 - loop distribution and zero dependence distances"

This reverts commit 5ea2965b499f9e491e45db19fedbccfccb75076a.

10 months agoFortran: Accept -std=f2023, update line-length for Fortran 2023
Tobias Burnus [Fri, 17 Nov 2023 12:34:55 +0000 (13:34 +0100)]
Fortran: Accept -std=f2023, update line-length for Fortran 2023

This patch accepts -std=f2023, uses it by default and bumps for the
free-source form the line length to 10,000 and the statement length
alias number of continuation lines to unlimited.

gcc/fortran/ChangeLog:

* gfortran.texi (_gfortran_set_options): Document GFC_STD_F2023.
* invoke.texi (std,pedantic,Wampersand,Wtabs): Add -std=2023.
* lang.opt (std=f2023): Add.
* libgfortran.h (GFC_STD_F2023, GFC_STD_OPT_F23): Add.
* options.cc (set_default_std_flags): Add GFC_STD_F2023.
(gfc_init_options): Set max_continue_free to 1,000,000.
(gfc_post_options): Set flag_free_line_length if unset.
(gfc_handle_option): Add OPT_std_f2023, set max_continue_free = 255
for -std=f2003, f2008 and f2018.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/warn_truncated.f90: Add -std=f2018 option.
* gfortran.dg/gomp/warn_truncated.f90: Likewise.
* gfortran.dg/line_length_10.f90: Likewise.
* gfortran.dg/line_length_11.f90: Likewise.
* gfortran.dg/line_length_2.f90: Likewise.
* gfortran.dg/line_length_5.f90: Likewise.
* gfortran.dg/line_length_6.f90: Likewise.
* gfortran.dg/line_length_7.f90: Likewise.
* gfortran.dg/line_length_8.f90: Likewise.
* gfortran.dg/line_length_9.f90: Likewise.
* gfortran.dg/continuation_17.f90: New test.
* gfortran.dg/continuation_18.f90: New test.
* gfortran.dg/continuation_19.f: New test.
* gfortran.dg/line_length_12.f90: New test.
* gfortran.dg/line_length_13.f90: New test.

10 months agoPR target/53372: Don't ignore section attribute with address-space.
Georg-Johann Lay [Fri, 17 Nov 2023 11:51:16 +0000 (12:51 +0100)]
PR target/53372: Don't ignore section attribute with address-space.

gcc/
PR target/53372
* config/avr/avr.cc (avr_asm_named_section) [AVR_SECTION_PROGMEM]:
Only return some .progmem*.data section if the user did not
specify a section attribute.
(avr_section_type_flags) [avr_progmem_p]: Unset SECTION_NOTYPE
in returned section flags.

gcc/testsuite/
PR target/53372
* gcc.target/avr/pr53372-1.c: New test.
* gcc.target/avr/pr53372-2.c: New test.

10 months agoTestsuite: silence some noise in output
Francois-Xavier Coudert [Wed, 15 Nov 2023 10:22:37 +0000 (11:22 +0100)]
Testsuite: silence some noise in output

We introduced in commit a0673ec5f9236dca6ada23f28343c591ccd575e4
some noisy messages, which clutter output with things like:

  dg set al ...
  revised FFLAGS ...

and are not really useful information. Let's remove them.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/caf.exp: Remove some output.
* gfortran.dg/dg.exp: Remove some output.

10 months agoLoongArch: Handle vectorized copysign (x, -1) expansion efficiently
Xi Ruoyao [Mon, 13 Nov 2023 16:17:19 +0000 (00:17 +0800)]
LoongArch: Handle vectorized copysign (x, -1) expansion efficiently

With LSX or LASX, copysign (x[i], -1) (or any negative constant) can be
vectorized using [x]vbitseti.{w/d} instructions to directly set the
signbits.

Inspired by Tamar Christina's "AArch64: Handle copysign (x, -1) expansion
efficiently" (r14-5289).

gcc/ChangeLog:

* config/loongarch/lsx.md (copysign<mode>3): Allow operand[2] to
be an reg_or_vector_same_val_operand.  If it's a const vector
with same negative elements, expand the copysign with a bitset
instruction.  Otherwise, force it into an register.
* config/loongarch/lasx.md (copysign<mode>3): Likewise.

gcc/testsuite/ChangeLog:

* g++.target/loongarch/vect-copysign-negconst.C: New test.
* g++.target/loongarch/vect-copysign-negconst-run.C: New test.

10 months agors6000: Fix regression cases caused 16-byte by pieces move
Haochen Gui [Fri, 17 Nov 2023 09:17:59 +0000 (17:17 +0800)]
rs6000: Fix regression cases caused 16-byte by pieces move

The previous patch enables 16-byte by pieces move. Originally 16-byte
move is implemented via pattern.  expand_block_move does an optimization
on P8 LE to leverage V2DI reversed load/store for memory to memory move.
Now 16-byte move is implemented via by pieces move and finally split to
two DI load/store.  This patch creates an insn_and_split pattern to
retake the optimization.

gcc/
PR target/111449
* config/rs6000/vsx.md (*vsx_le_mem_to_mem_mov_ti): New.

gcc/testsuite/
PR target/111449
* gcc.target/powerpc/pr111449-2.c: New.

10 months agors6000: Enable vector mode for by pieces equality compare
Haochen Gui [Fri, 17 Nov 2023 09:12:32 +0000 (17:12 +0800)]
rs6000: Enable vector mode for by pieces equality compare

This patch adds a new expand pattern - cbranchv16qi4 to enable vector
mode by pieces equality compare on rs6000.  The macro MOVE_MAX_PIECES
(COMPARE_MAX_PIECES) is set to 16 bytes when EFFICIENT_UNALIGNED_VSX
is enabled, otherwise keeps unchanged.  The macro STORE_MAX_PIECES is
set to the same value as MOVE_MAX_PIECES by default, so now it's
explicitly defined and keeps unchanged.

gcc/
PR target/111449
* config/rs6000/altivec.md (cbranchv16qi4): New expand pattern.
* config/rs6000/rs6000.cc (rs6000_generate_compare): Generate
insn sequence for V16QImode equality compare.
* config/rs6000/rs6000.h (MOVE_MAX_PIECES): Define.
(STORE_MAX_PIECES): Define.

gcc/testsuite/
PR target/111449
* gcc.target/powerpc/pr111449-1.c: New.
* gcc.dg/tree-ssa/sra-17.c: Add additional options for 32-bit powerpc.
* gcc.dg/tree-ssa/sra-18.c: Likewise.

10 months agoLoongArch: Implement C[LT]Z_DEFINED_VALUE_AT_ZERO
Li Wei [Fri, 17 Nov 2023 02:38:02 +0000 (10:38 +0800)]
LoongArch: Implement C[LT]Z_DEFINED_VALUE_AT_ZERO

The LoongArch has defined ctz and clz on the backend, but if we want GCC
do CTZ transformation optimization in forwprop2 pass, GCC need to know
the value of c[lt]z at zero, which may be beneficial for some test cases
(like spec2017 deepsjeng_r).

After implementing the macro, we test dynamic instruction count on
deepsjeng_r:
- before 1688423249186
- after  1660311215745 (1.66% reduction)

gcc/ChangeLog:

* config/loongarch/loongarch.h (CLZ_DEFINED_VALUE_AT_ZERO):
Implement.
(CTZ_DEFINED_VALUE_AT_ZERO): Same.

gcc/testsuite/ChangeLog:

* gcc.dg/pr90838.c: add clz/ctz test support on LoongArch.

10 months agoAssert we don't create recursive DW_AT_{abstract_origin,specification}
Richard Biener [Mon, 30 Oct 2023 12:17:11 +0000 (13:17 +0100)]
Assert we don't create recursive DW_AT_{abstract_origin,specification}

We have a support case that shows GCC 7 sometimes creates
DW_TAG_label refering to itself via a DW_AT_abstract_origin
when using LTO.  This for example triggers the sanity check
added below during LTO bootstrap.

Making this check cover more than just DW_AT_abstract_origin
breaks bootstrap on trunk for

      /* GNU extension: Record what type our vtable lives in.  */
      if (TYPE_VFIELD (type))
        {
          tree vtype = DECL_FCONTEXT (TYPE_VFIELD (type));

          gen_type_die (vtype, context_die);
          add_AT_die_ref (type_die, DW_AT_containing_type,
                          lookup_type_die (vtype));

so the check is for now restricted to DW_AT_abstract_origin
and DW_AT_specification both of which we follow within get_AT.

* dwarf2out.cc (add_AT_die_ref): Assert we do not add
a self-ref DW_AT_abstract_origin or DW_AT_specification.

10 months agoLoongArch: Increase cost of vector aligned store/load.
Jiahao Xu [Thu, 16 Nov 2023 08:44:36 +0000 (16:44 +0800)]
LoongArch: Increase cost of vector aligned store/load.

Based on SPEC2017 performance evaluation results, it's better to make them equal
to the cost of unaligned store/load so as to avoid odd alignment peeling.

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_builtin_vectorization_cost): Adjust.

10 months agoLoongArch: Fix scan-assembler-times of lasx/lsx test case.
Jiahao Xu [Thu, 16 Nov 2023 12:31:09 +0000 (20:31 +0800)]
LoongArch: Fix scan-assembler-times of lasx/lsx test case.

These tests fail when they are first added,this patch adjusts the scan-assembler-times
to fix them.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vector/lasx/lasx-vcond-1.c: Adjust assembler times.
* gcc.target/loongarch/vector/lasx/lasx-vcond-2.c: Ditto.
* gcc.target/loongarch/vector/lsx/lsx-vcond-1.c: Ditto.
* gcc.target/loongarch/vector/lsx/lsx-vcond-2.c: Ditto.

10 months agoDaily bump.
GCC Administrator [Fri, 17 Nov 2023 00:17:33 +0000 (00:17 +0000)]
Daily bump.

10 months agoOnly allow (copysign x, NEG_CONST) -> (fneg (fabs x)) simplification for constant...
Andrew Pinski [Mon, 13 Nov 2023 20:18:34 +0000 (20:18 +0000)]
Only allow (copysign x, NEG_CONST) -> (fneg (fabs x)) simplification for constant folding [PR112483]

On targets with native copysign instructions, (copysign x, -1) is
usually more efficient than (fneg (fabs x)).  Since r14-5284, in the
middle end we always optimize (fneg (fabs x)) to (copysign x, -1), not
vice versa.  If the target does not support native fcopysign,
expand_COPYSIGN will expand it as (fneg (fabs x)) anyway.

gcc/ChangeLog:

PR rtl-optimization/112483
* simplify-rtx.cc (simplify_binary_operation_1) <case COPYSIGN>:
Call simplify_unary_operation for NEG instead of
simplify_gen_unary.

10 months agoFix warning on new Ada testcase
Eric Botcazou [Thu, 16 Nov 2023 21:41:53 +0000 (22:41 +0100)]
Fix warning on new Ada testcase

gcc/testsuite/
* gnat.dg/varsize4.adb (Func): Initialize Byte_Read parameter.

10 months agoRISC-V: Change unaligned fast/slow/avoid macros to misaligned [PR111557]
Edwin Lu [Wed, 15 Nov 2023 21:22:11 +0000 (13:22 -0800)]
RISC-V: Change unaligned fast/slow/avoid macros to misaligned [PR111557]

Fix __riscv_unaligned_fast/slow/avoid macro name to
__riscv_misaligned_fast/slow/avoid to be consistent with the RISC-V API Spec

PR target/111557

gcc/ChangeLog:

* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): update macro name

gcc/testsuite/ChangeLog:

* gcc.target/riscv/attribute-1.c: update macro name
* gcc.target/riscv/attribute-4.c: ditto
* gcc.target/riscv/attribute-5.c: ditto
* gcc.target/riscv/predef-align-1.c: ditto
* gcc.target/riscv/predef-align-2.c: ditto
* gcc.target/riscv/predef-align-3.c: ditto
* gcc.target/riscv/predef-align-4.c: ditto
* gcc.target/riscv/predef-align-5.c: ditto
* gcc.target/riscv/predef-align-6.c: ditto

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
10 months agoi386: Optimize QImode insn with high input registers
Uros Bizjak [Thu, 16 Nov 2023 17:07:36 +0000 (18:07 +0100)]
i386: Optimize QImode insn with high input registers

Sometimes the compiler emits the following code with <insn>qi_ext<mode>_0:

        shrl    $8, %eax
        addb    %bh, %al

Patch introduces new low part QImode insn patterns with both of
their input arguments extracted from high register.  This invalid
insn is split after reload to a move from the high register
and <insn>qi_ext<mode>_0 instruction.  The combine pass is able to
convert shift to zero/sign-extract sub-RTX, which we split to the
optimal:

        movzbl  %bh, %edx
        addb    %ah, %dl

PR target/78904

gcc/ChangeLog:

* config/i386/i386.md (*addqi_ext2<mode>_0):
New define_insn_and_split pattern.
(*subqi_ext2<mode>_0): Ditto.
(*<code>qi_ext2<mode>_0): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr78904-10.c: New test.
* gcc.target/i386/pr78904-10a.c: New test.
* gcc.target/i386/pr78904-10b.c: New test.

10 months agohppa: Revise REG+D address support to allow long displacements before reload
John David Anglin [Thu, 16 Nov 2023 17:42:26 +0000 (17:42 +0000)]
hppa: Revise REG+D address support to allow long displacements before reload

In analyzing PR rtl-optimization/112415, I realized that restricting
REG+D offsets to 5-bits before reload results in very poor code and
complexities in optimizing these instructions after reload.  The
general problem is long displacements are not allowed for floating
point accesses when generating PA 1.1 code.  Even with PA 2.0, there
is a ELF linker bug that prevents using long displacements for
floating point loads and stores.

In the past, enabling long displacements before reload caused issues
in reload.  However, there have been fixes in the handling of reloads
for floating-point accesses.  This change allows long displacements
before reload and corrects a couple of issues in the constraint
handling for integer and floating-point accesses.

2023-11-16  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

PR rtl-optimization/112415
* config/pa/pa.cc (pa_legitimate_address_p): Allow 14-bit
displacements before reload.  Simplify logic flow.  Revise
comments.
* config/pa/pa.h (TARGET_ELF64): New define.
(INT14_OK_STRICT): Update define and comment.
* config/pa/pa64-linux.h (TARGET_ELF64): Define.
* config/pa/predicates.md (base14_operand): Don't check
alignment of short displacements.
(integer_store_memory_operand): Don't return true when
reload_in_progress is true.  Remove INT_5_BITS check.
(floating_point_store_memory_operand): Don't return true when
reload_in_progress is true.  Use INT14_OK_STRICT to check
whether long displacements are always okay.

10 months agoFix internal error on function returning dynamically-sized type
Eric Botcazou [Thu, 16 Nov 2023 17:36:44 +0000 (18:36 +0100)]
Fix internal error on function returning dynamically-sized type

This is a tree sharing issue for the internal return type synthesized for
a function returning a dynamically-sized type and taking an Out or In/Out
parameter passed by copy.

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Also create a
TYPE_DECL for the return type built for the CI/CO mechanism.

gcc/testsuite/
* gnat.dg/varsize4.ads, gnat.dg/varsize4.adb: New test.
* gnat.dg/varsize4_pkg.ads: New helper.

10 months agolibstdc++: Fix aligned formatting of stacktrace_entry and thread::id [PR112564]
Jonathan Wakely [Thu, 16 Nov 2023 16:11:18 +0000 (16:11 +0000)]
libstdc++: Fix aligned formatting of stacktrace_entry and thread::id [PR112564]

The formatter for std::thread::id should default to right-align, and the
formatter for std::stacktrace_entry should not just ignore the
fill-and-align and width from the format-spec!

libstdc++-v3/ChangeLog:

PR libstdc++/112564
* include/std/stacktrace (formatter::format): Format according
to format-spec.
* include/std/thread (formatter::format): Use _Align_right as
default.
* testsuite/19_diagnostics/stacktrace/output.cc: Check
fill-and-align handling. Change compile test to run.
* testsuite/30_threads/thread/id/output.cc: Check fill-and-align
handling.

10 months agoAdd myself to write after approval
Michal Jires [Thu, 16 Nov 2023 16:33:30 +0000 (17:33 +0100)]
Add myself to write after approval

ChangeLog:

* MAINTAINERS: Add myself.

10 months agoc++: Fix error recovery ICE [PR112365]
Jakub Jelinek [Thu, 16 Nov 2023 16:42:22 +0000 (17:42 +0100)]
c++: Fix error recovery ICE [PR112365]

check_field_decls for DECL_C_BIT_FIELD FIELD_DECLs with error_mark_node
TREE_TYPE continues early and doesn't call check_bitfield_decl which would
either set DECL_BIT_FIELD, or clear DECL_C_BIT_FIELD.  So, the following
testcase ICEs after emitting tons of errors, because
SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD asserts DECL_BIT_FIELD.

The patch skips that for FIELD_DECLs with error_mark_node, another
option would be to check DECL_BIT_FIELD in addition to DECL_C_BIT_FIELD.

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

PR c++/112365
* class.cc (layout_class_type): Don't
SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD on FIELD_DECLs with
error_mark_node type.

* g++.dg/cpp0x/pr112365.C: New test.

10 months agoi386: Fix invalid RTX in split2 pass [PR112567]
Uros Bizjak [Thu, 16 Nov 2023 15:48:07 +0000 (16:48 +0100)]
i386: Fix invalid RTX in split2 pass [PR112567]

Also fix some indentitation inconsistencies.

PR target/112567

gcc/ChangeLog:

* config/i386/i386.md (*<any_logic:code>qi_ext<mode>_1_slp):
Fix generation of invalid RTX in split pattern.

10 months agoc++: add fixed testcases [PR98614, PR104802]
Patrick Palka [Thu, 16 Nov 2023 15:49:17 +0000 (10:49 -0500)]
c++: add fixed testcases [PR98614, PR104802]

Both of these PRs are fixed by r12-1403-gc4e50e500da7692a.

PR c++/98614
PR c++/104802

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/nontype-auto22.C: New test.
* g++.dg/cpp2a/concepts-partial-spec14.C: New test.

10 months agoc++: constantness of call to function pointer [PR111703]
Patrick Palka [Thu, 16 Nov 2023 14:32:07 +0000 (09:32 -0500)]
c++: constantness of call to function pointer [PR111703]

potential_constant_expression for CALL_EXPR tests FUNCTION_POINTER_TYPE_P
on the callee rather than on the type of the callee, which means we
always pass want_rval=any when recursing and so may fail to identify a
non-constant function pointer callee as such.  Fixing this turns out to
further work around PR111703.

PR c++/111703
PR c++/107939

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1) <case CALL_EXPR>:
Fix FUNCTION_POINTER_TYPE_P test.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-fn8.C: Extend test.
* g++.dg/diagnostic/constexpr4.C: New test.

10 months agodiagnostics: make m_lang_mask private
David Malcolm [Thu, 16 Nov 2023 13:29:19 +0000 (08:29 -0500)]
diagnostics: make m_lang_mask private

No functional change intended.

gcc/ChangeLog:
* diagnostic.cc (diagnostic_context::set_option_hooks): Add
"lang_mask" param.
* diagnostic.h (diagnostic_context::option_enabled_p): Update for
move of m_lang_mask.
(diagnostic_context::set_option_hooks): Add "lang_mask" param.
(diagnostic_context::get_lang_mask): New.
(diagnostic_context::m_lang_mask): Move into m_option_callbacks,
thus making private.
* lto-wrapper.cc (main): Update for new lang_mask param of
set_option_hooks.
* toplev.cc (init_asm_output): Use get_lang_mask.
(general_init): Move initialization of global_dc's lang_mask to
new lang_mask param of set_option_hooks.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agomiddle-end: skip checking loop exits if loop malformed [PR111878]
Tamar Christina [Thu, 16 Nov 2023 12:11:22 +0000 (12:11 +0000)]
middle-end: skip checking loop exits if loop malformed [PR111878]

Before my refactoring if the loop->latch was incorrect then find_loop_location
skipped checking the edges and would eventually return a dummy location.

It turns out that a loop can have
loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS) but also not have a latch
in which case get_loop_exit_edges traps.

This restores the old behavior.

gcc/ChangeLog:

PR tree-optimization/111878
* tree-vect-loop-manip.cc (find_loop_location): Skip edges check if
latch incorrect.

gcc/testsuite/ChangeLog:

PR tree-optimization/111878
* gcc.dg/graphite/pr111878.c: New test.

10 months agogcc.c-torture/execute/931004-13.c: Fix declaration of main
Florian Weimer [Thu, 16 Nov 2023 11:09:19 +0000 (12:09 +0100)]
gcc.c-torture/execute/931004-13.c: Fix declaration of main

gcc/testsuite/

* gcc.c-torture/execute/931004-13.c (main): Fix mistakenly swapped
int/void types.

10 months agoRISC-V: Implement target attribute
Kito Cheng [Tue, 10 Oct 2023 04:13:05 +0000 (21:13 -0700)]
RISC-V: Implement target attribute

The target attribute which proposed in [1], target attribute allow user
to specify a local setting per-function basis.

The syntax of target attribute is `__attribute__((target("<ATTR-STRING>")))`.

and the syntax of `<ATTR-STRING>` describes below:
```
ATTR-STRING := ATTR-STRING ';' ATTR
             | ATTR

ATTR        := ARCH-ATTR
             | CPU-ATTR
             | TUNE-ATTR

ARCH-ATTR   := 'arch=' EXTENSIONS-OR-FULLARCH

EXTENSIONS-OR-FULLARCH := <EXTENSIONS>
                        | <FULLARCHSTR>

EXTENSIONS             := <EXTENSION> ',' <EXTENSIONS>
                        | <EXTENSION>

FULLARCHSTR            := <full-arch-string>

EXTENSION              := <OP> <EXTENSION-NAME> <VERSION>

OP                     := '+'

VERSION                := [0-9]+ 'p' [0-9]+
                        | [1-9][0-9]*
                        |

EXTENSION-NAME         := Naming rule is defined in RISC-V ISA manual

CPU-ATTR    := 'cpu=' <valid-cpu-name>
TUNE-ATTR   := 'tune=' <valid-tune-name>
```

Changes since v1:
- Use std::unique_ptr rather than alloca to prevent memory issue.
- Error rather than warning when attribute duplicated.

[1] https://github.com/riscv-non-isa/riscv-c-api-doc/pull/35

gcc/ChangeLog:

* config.gcc (riscv): Add riscv-target-attr.o.
* config/riscv/riscv-protos.h (riscv_declare_function_size) New.
(riscv_option_valid_attribute_p): New.
(riscv_override_options_internal): New.
(struct riscv_tune_info): New.
(riscv_parse_tune): New.
* config/riscv/riscv-target-attr.cc
(class riscv_target_attr_parser): New.
(struct riscv_attribute_info): New.
(riscv_attributes): New.
(riscv_target_attr_parser::parse_arch): New.
(riscv_target_attr_parser::handle_arch): New.
(riscv_target_attr_parser::handle_cpu): New.
(riscv_target_attr_parser::handle_tune): New.
(riscv_target_attr_parser::update_settings): New.
(riscv_process_one_target_attr): New.
(num_occurences_in_str): New.
(riscv_process_target_attr): New.
(riscv_option_valid_attribute_p): New.
* config/riscv/riscv.cc: Include target-globals.h and
riscv-subset.h.
(struct riscv_tune_info): Move to riscv-protos.h.
(get_tune_str): New.
(riscv_parse_tune): New parameter null_p.
(riscv_declare_function_size): New.
(riscv_option_override): Build target_option_default_node and
target_option_current_node.
(riscv_save_restore_target_globals): New.
(riscv_option_restore): New.
(riscv_previous_fndecl): New.
(riscv_set_current_function): Apply the target attribute.
(TARGET_OPTION_RESTORE): Define.
(TARGET_OPTION_VALID_ATTRIBUTE_P): Ditto.
* config/riscv/riscv.h (SWITCHABLE_TARGET): Define to 1.
(ASM_DECLARE_FUNCTION_SIZE) Define.
* config/riscv/riscv.opt (mtune=): Add Save attribute.
(mcpu=): Ditto.
(mcmodel=): Ditto.
* config/riscv/t-riscv: Add build rule for riscv-target-attr.o
* doc/extend.texi: Add doc for target attribute.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/target-attr-01.c: New.
* gcc.target/riscv/target-attr-02.c: Ditto.
* gcc.target/riscv/target-attr-03.c: Ditto.
* gcc.target/riscv/target-attr-04.c: Ditto.
* gcc.target/riscv/target-attr-05.c: Ditto.
* gcc.target/riscv/target-attr-06.c: Ditto.
* gcc.target/riscv/target-attr-07.c: Ditto.
* gcc.target/riscv/target-attr-bad-01.c: Ditto.
* gcc.target/riscv/target-attr-bad-02.c: Ditto.
* gcc.target/riscv/target-attr-bad-03.c: Ditto.
* gcc.target/riscv/target-attr-bad-04.c: Ditto.
* gcc.target/riscv/target-attr-bad-05.c: Ditto.
* gcc.target/riscv/target-attr-bad-06.c: Ditto.
* gcc.target/riscv/target-attr-bad-07.c: Ditto.
* gcc.target/riscv/target-attr-bad-08.c: Ditto.
* gcc.target/riscv/target-attr-bad-09.c: Ditto.
* gcc.target/riscv/target-attr-bad-10.c: Ditto.

Reviewed-by: Christoph Müllner <christoph.muellner@vrull.eu>
10 months agoRISC-V: Save/restore ra register correctly [PR112478]
Kito Cheng [Tue, 14 Nov 2023 03:17:45 +0000 (11:17 +0800)]
RISC-V: Save/restore ra register correctly [PR112478]

We set ra to fixed register now, but we still need to save/restore that at
prologue/epilogue if that has used.

gcc/ChangeLog:

PR target/112478
* config/riscv/riscv.cc (riscv_save_return_addr_reg_p): Check ra
is ever lived.

gcc/testsuite/ChangeLog:

PR target/112478
* gcc.target/riscv/pr112478.c: New.

Reviewed-by: Christoph Müllner <christoph.muellner@vrull.eu>
Tested-by: Christoph Müllner <christoph.muellner@vrull.eu>
10 months agoFix ICE of unrecognizable insn.
liuhongt [Wed, 15 Nov 2023 08:50:44 +0000 (16:50 +0800)]
Fix ICE of unrecognizable insn.

The new added splitter will generate

(insn 58 56 59 2 (set (reg:V4HI 20 xmm0 [129])
        (vec_duplicate:V4HI (reg:HI 22 xmm2 [123]))) "testcase.c":16:21 -1

But we only have

(define_insn "*vec_dupv4hi"
  [(set (match_operand:V4HI 0 "register_operand" "=y,Yw")
(vec_duplicate:V4HI
  (truncate:HI
    (match_operand:SI 1 "register_operand" "0,Yw"))))]

The patch add patterns for V4HI and V2HI.

gcc/ChangeLog:

PR target/112532
* config/i386/mmx.md (*vec_dup<mode>): Extend for V4HI and
V2HI.

gcc/testsuite/ChangeLog:

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

10 months agolibstdc++: Implement std::out_ptr and std::inout_ptr for C++23 [PR111667]
Jonathan Wakely [Wed, 15 Nov 2023 23:02:34 +0000 (23:02 +0000)]
libstdc++: Implement std::out_ptr and std::inout_ptr for C++23 [PR111667]

This implements that changes from P1132R8, including optimized paths for
std::shared_ptr and std::unique_ptr.

For std::shared_ptr we pre-allocate a new control block in the
std::out_ptr_t constructor so that the destructor is non-throwing. This
requires some care because unlike the shared_ptr(Y*, D, A) constructor,
we don't want to invoke the deleter if allocating the control block
throws, because we don't own any pointer yet. In order to avoid the
unwanted deleter invocation, we create the control block manually. We
also want to avoid invoking the deleter on a null pointer on
destruction, so we destroy the control block manually if there is no
pointer to take ownership of.

For std::unique_ptr and for raw pointers, the out_ptr_t object hands out
direct access to the pointer, so that we don't have anything to do
(except possibly assign a new deleter) in the ~out_ptr_t destructor.

These optimizations avoid requiring additional temporary storage for the
pointer (and optional arguments), and avoid additional instructions to
copy that pointer into the smart pointer at the end.

libstdc++-v3/ChangeLog:

PR libstdc++/111667
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/out_ptr.h: New file.
* include/bits/shared_ptr.h (__is_shared_ptr): Move definition
to here ...
* include/bits/shared_ptr_atomic.h (__is_shared_ptr): ... from
here.
* include/bits/shared_ptr_base.h (__shared_count): Declare
out_ptr_t as a friend.
(_Sp_counted_deleter, __shared_ptr): Likewise.
* include/bits/unique_ptr.h (unique_ptr, unique_ptr<T[], D>):
Declare out_ptr_t and inout_ptr_t as friends.
(__is_unique_ptr): Define new variable template.
* include/bits/version.def (out_ptr): Define.
* include/bits/version.h: Regenerate.
* include/std/memory: Include new header.
* testsuite/20_util/smartptr.adapt/inout_ptr/1.cc: New test.
* testsuite/20_util/smartptr.adapt/inout_ptr/2.cc: New test.
* testsuite/20_util/smartptr.adapt/inout_ptr/shared_ptr_neg.cc:
New test.
* testsuite/20_util/smartptr.adapt/inout_ptr/void_ptr.cc: New
test.
* testsuite/20_util/smartptr.adapt/out_ptr/1.cc: New test.
* testsuite/20_util/smartptr.adapt/out_ptr/2.cc: New test.
* testsuite/20_util/smartptr.adapt/out_ptr/shared_ptr_neg.cc:
New test.
* testsuite/20_util/smartptr.adapt/out_ptr/void_ptr.cc: New
test.

10 months agolibstdc++: Only declare feature test macros in standard headers
Jonathan Wakely [Tue, 19 Sep 2023 16:46:32 +0000 (17:46 +0100)]
libstdc++: Only declare feature test macros in standard headers

This change moves the definitions of feature test macros (or strictly
speaking, the requests for <bits/version.h> to define them) so that only
standard headers define them. For example, <bits/shared_ptr.h> will no
longer define macros related to std::shared_ptr, only <memory> and
<version> will define them. This means that __cpp_lib_shared_ptr_arrays
will not be defined by <future> or by other headers that include
<bits/shared_ptr.h>. It will only be defined when <memory> has been
included. This will discourage users from relying on transitive
includes.

As a result, internal headers that need to query the macros should use
the internal macros like __glibcxx_shared_ptr_arrays instead of
__cpp_lib_shared_ptr_arrays, as those internal macros are defined by the
internal headers after icluding <bits/version.h>. There are some
exceptions to this rule, because __cpp_lib_is_constant_evaluated is
defined by bits/c++config.h and so is available everywhere, and
__cpp_lib_three_way_comparison is defined by <compare> which several
headers are explicitly specified to include, so its macro is guaranteed
to be usable too.

N.B. not many internal headers actually need an explicit include of
<bits/version.h>, because most of them include <type_traits> and so get
all the __glibcxx_foo internal macros from there.

libstdc++-v3/ChangeLog:

* include/bits/algorithmfwd.h: Do not define standard feature
test macro here.
* include/bits/align.h: Likewise. Test internal macros instead
of standard macros.
* include/bits/alloc_traits.h: Likewise.
* include/bits/allocator.h: Likewise.
* include/bits/atomic_base.h: Likewise.
* include/bits/atomic_timed_wait.h: Likewise.
* include/bits/atomic_wait.h: Likewise.
* include/bits/basic_string.h: Likewise.
* include/bits/basic_string.tcc: Likewise.
* include/bits/char_traits.h: Likewise.
* include/bits/chrono.h: Likewise.
* include/bits/cow_string.h: Likewise.
* include/bits/forward_list.h: Likewise.
* include/bits/hashtable.h: Likewise.
* include/bits/ios_base.h: Likewise.
* include/bits/memory_resource.h: Likewise.
* include/bits/move.h: Likewise.
* include/bits/move_only_function.h: Likewise.
* include/bits/node_handle.h: Likewise.
* include/bits/ptr_traits.h: Likewise.
* include/bits/range_access.h: Likewise.
* include/bits/ranges_algo.h: Likewise.
* include/bits/ranges_cmp.h: Likewise.
* include/bits/ranges_util.h: Likewise.
* include/bits/semaphore_base.h: Likewise.
* include/bits/shared_ptr.h: Likewise.
* include/bits/shared_ptr_atomic.h: Likewise.
* include/bits/shared_ptr_base.h: Likewise.
* include/bits/stl_algo.h: Likewise.
* include/bits/stl_algobase.h: Likewise.
* include/bits/stl_function.h: Likewise.
* include/bits/stl_iterator.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/stl_map.h: Likewise.
* include/bits/stl_pair.h: Likewise.
* include/bits/stl_queue.h: Likewise.
* include/bits/stl_stack.h: Likewise.
* include/bits/stl_tree.h: Likewise.
* include/bits/stl_uninitialized.h: Likewise.
* include/bits/stl_vector.h: Likewise.
* include/bits/unique_ptr.h: Likewise.
* include/bits/unordered_map.h: Likewise.
* include/bits/uses_allocator_args.h: Likewise.
* include/bits/utility.h: Likewise.
* include/bits/erase_if.h: Add comment.
* include/std/algorithm: Define standard feature test macros
here.
* include/std/atomic: Likewise.
* include/std/array: Likewise.
* include/std/chrono: Likewise.
* include/std/condition_variable: Likewise.
* include/std/deque: Likewise.
* include/std/format: Likewise.
* include/std/functional: Likewise.
* include/std/forward_list: Likewise.
* include/std/ios: Likewise.
* include/std/iterator: Likewise.
* include/std/list: Likewise.
* include/std/map: Likewise.
* include/std/memory: Likewise.
* include/std/numeric: Likewise.
* include/std/queue: Likewise.
* include/std/ranges: Likewise.
* include/std/regex: Likewise.
* include/std/set: Likewise.
* include/std/stack: Likewise.
* include/std/stop_token: Likewise.
* include/std/string: Likewise.
* include/std/string_view:
* include/std/tuple: Likewise.
* include/std/unordered_map:
* include/std/unordered_set:
* include/std/utility: Likewise.
* include/std/vector: Likewise.
* include/std/scoped_allocator: Query internal macros instead of
standard macros.

10 months agolibstdc++: Test for feature test macros more accurately
Jonathan Wakely [Tue, 19 Sep 2023 16:46:32 +0000 (17:46 +0100)]
libstdc++: Test for feature test macros more accurately

Tests which check for feature test macros should use the no_pch option,
so that we're really testing for the definition being in the intended
header, and not just testing that it's present in <bits/stdc++.h> (which
includes all the standard headers and so defines all the macros).

libstdc++-v3/ChangeLog:

* testsuite/18_support/byte/requirements.cc: Disable PCH.
* testsuite/18_support/destroying_delete.cc: Likewise.
* testsuite/18_support/source_location/1.cc: Likewise.
* testsuite/18_support/source_location/version.cc: Likewise.
* testsuite/18_support/type_info/constexpr.cc: Likewise.
* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc:
Likewise.
* testsuite/19_diagnostics/stacktrace/output.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/synopsis.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/version.cc: Likewise.
* testsuite/20_util/addressof/requirements/constexpr.cc:
Likewise.
* testsuite/20_util/allocator_traits/header-2.cc: Likewise.
* testsuite/20_util/allocator_traits/header.cc: Likewise.
* testsuite/20_util/as_const/1.cc: Likewise. Likewise.
* testsuite/20_util/bitset/cons/constexpr_c++23.cc: Likewise.
* testsuite/20_util/bitset/version.cc: Likewise.
* testsuite/20_util/duration/arithmetic/constexpr_c++17.cc:
Likewise.
* testsuite/20_util/duration_cast/rounding.cc: Likewise.
* testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
Likewise.
* testsuite/20_util/exchange/constexpr.cc: Likewise.
* testsuite/20_util/expected/synopsis.cc: Likewise.
* testsuite/20_util/expected/version.cc: Likewise.
* testsuite/20_util/function_objects/bind_front/1.cc: Likewise.
* testsuite/20_util/function_objects/bind_front/2.cc: Likewise.
* testsuite/20_util/function_objects/invoke/3.cc: Likewise.
* testsuite/20_util/function_objects/invoke/4.cc: Likewise.
* testsuite/20_util/function_objects/invoke/constexpr.cc:
Likewise.
* testsuite/20_util/function_objects/invoke/version.cc:
Likewise.
* testsuite/20_util/function_objects/searchers.cc: Likewise.
* testsuite/20_util/integer_comparisons/1.cc: Likewise.
* testsuite/20_util/integer_comparisons/2.cc: Likewise.
* testsuite/20_util/is_bounded_array/value.cc: Likewise.
* testsuite/20_util/is_layout_compatible/value.cc: Likewise.
* testsuite/20_util/is_layout_compatible/version.cc: Likewise.
* testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc:
Likewise.
* testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_nothrow_swappable/value.cc: Likewise.
* testsuite/20_util/is_nothrow_swappable/value.h: Likewise.
* testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc:
Remove redundant checks already tested elsewhere.
* testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_nothrow_swappable_with/value.cc: Disable
PCH.
* testsuite/20_util/is_pointer_interconvertible/value.cc:
Likewise.
* testsuite/20_util/is_pointer_interconvertible/version.cc:
Likewise.
* testsuite/20_util/is_scoped_enum/value.cc: Likewise.
* testsuite/20_util/is_scoped_enum/version.cc: Likewise.
* testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc:
Remove redundant checks already tested elsewhere.
* testsuite/20_util/is_swappable/requirements/typedefs.cc:
Remove redundant checks already tested elsewhere.
* testsuite/20_util/is_swappable/value.cc: Disable PCH.
* testsuite/20_util/is_swappable/value.h: Reorder headers.
* testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc:
Remove redundant checks already tested elsewhere.
* testsuite/20_util/is_swappable_with/requirements/typedefs.cc:
Remove redundant checks already tested elsewhere.
* testsuite/20_util/is_swappable_with/value.cc: Disable PCH.
* testsuite/20_util/is_unbounded_array/value.cc: Likewise.
* testsuite/20_util/move_only_function/cons.cc: Likewise.
* testsuite/20_util/move_only_function/version.cc: Likewise.
* testsuite/20_util/optional/monadic/and_then.cc: Likewise.
* testsuite/20_util/optional/requirements.cc: Likewise.
* testsuite/20_util/optional/version.cc: Likewise.
* testsuite/20_util/owner_less/void.cc: Likewise.
* testsuite/20_util/reference_from_temporary/value.cc: Likewise.
* testsuite/20_util/reference_from_temporary/version.cc:
Likewise.
* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc:
Likewise.
* testsuite/20_util/shared_ptr/creation/array.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/overwrite.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/version.cc: Likewise.
* testsuite/20_util/time_point_cast/rounding.cc: Likewise.
* testsuite/20_util/to_chars/constexpr.cc: Likewise.
* testsuite/20_util/to_chars/result.cc: Likewise.
* testsuite/20_util/to_chars/version.cc: Likewise.
* testsuite/20_util/to_underlying/1.cc: Likewise.
* testsuite/20_util/to_underlying/version.cc: Likewise.
* testsuite/20_util/tuple/apply/1.cc: Likewise.
* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:
Likewise.
* testsuite/20_util/tuple/make_from_tuple/1.cc: Likewise.
* testsuite/20_util/tuple/p2321r2.cc: Likewise.
* testsuite/20_util/tuple/tuple_element_t.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc:
Likewise.
* testsuite/20_util/unique_ptr/creation/for_overwrite.cc:
Likewise.
* testsuite/20_util/unreachable/1.cc: Likewise.
* testsuite/20_util/unreachable/version.cc: Likewise.
* testsuite/20_util/unwrap_reference/1.cc: Likewise.
* testsuite/20_util/unwrap_reference/3.cc: Likewise.
* testsuite/20_util/variant/constexpr.cc: Likewise.
* testsuite/20_util/variant/version.cc: Likewise.
* testsuite/20_util/variant/visit_inherited.cc: Likewise.
* testsuite/20_util/void_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
Likewise.
* testsuite/21_strings/basic_string/cons/char/constexpr.cc:
Likewise.
* testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc:
Likewise.
* testsuite/21_strings/basic_string/erasure.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/to_string_float.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/version.cc:
Likewise.
* testsuite/21_strings/basic_string/version.cc: Likewise.
* testsuite/21_strings/basic_string_view/operations/contains/char.cc:
Likewise.
* testsuite/21_strings/basic_string_view/operations/contains/char/2.cc:
Likewise.
* testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc:
Likewise.
* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
Likewise.
* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
Likewise.
* testsuite/21_strings/char_traits/requirements/version.cc:
Likewise.
* testsuite/23_containers/array/comparison_operators/constexpr.cc:
Likewise.
* testsuite/23_containers/array/creation/1.cc: Likewise.
* testsuite/23_containers/array/creation/2.cc: Likewise.
* testsuite/23_containers/array/element_access/constexpr_c++17.cc:
Likewise.
* testsuite/23_containers/array/requirements/constexpr_fill.cc:
Likewise.
* testsuite/23_containers/array/requirements/constexpr_iter.cc:
Likewise.
* testsuite/23_containers/deque/erasure.cc: Likewise.
* testsuite/23_containers/forward_list/erasure.cc: Likewise.
* testsuite/23_containers/list/erasure.cc: Likewise.
* testsuite/23_containers/map/erasure.cc: Likewise.
* testsuite/23_containers/queue/cons_from_iters.cc: Likewise.
* testsuite/23_containers/set/erasure.cc: Likewise.
* testsuite/23_containers/span/1.cc: Likewise.
* testsuite/23_containers/span/2.cc: Likewise.
* testsuite/23_containers/stack/cons_from_iters.cc: Likewise.
* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
* testsuite/23_containers/unordered_map/operations/1.cc:
Likewise.
* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
* testsuite/23_containers/unordered_set/operations/1.cc:
Likewise.
* testsuite/23_containers/vector/cons/constexpr.cc: Likewise.
* testsuite/23_containers/vector/erasure.cc: Likewise.
* testsuite/23_containers/vector/requirements/version.cc:
Likewise.
* testsuite/24_iterators/insert_iterator/constexpr.cc: Likewise.
* testsuite/25_algorithms/clamp/constexpr.cc: Likewise.
* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/1.cc:
Remove redundant checks already tested elsewhere.
* testsuite/25_algorithms/constexpr_macro.cc: Likewise.
* testsuite/25_algorithms/cpp_lib_constexpr.cc: Likewise.
* testsuite/25_algorithms/fold_left/1.cc: Likewise.
* testsuite/25_algorithms/pstl/feature_test-2.cc: Likewise.
* testsuite/25_algorithms/pstl/feature_test-3.cc: Likewise.
* testsuite/25_algorithms/pstl/feature_test-4.cc: Likewise.
* testsuite/25_algorithms/pstl/feature_test-5.cc: Likewise.
* testsuite/25_algorithms/pstl/feature_test.cc: Likewise.
* testsuite/26_numerics/bit/bit.byteswap/byteswap.cc: Likewise.
* testsuite/26_numerics/bit/bit.byteswap/version.cc: Likewise.
* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: Likewise.
* testsuite/26_numerics/bit/bit.cast/version.cc: Likewise.
* testsuite/26_numerics/bit/header-2.cc: Likewise.
* testsuite/26_numerics/bit/header.cc: Likewise.
* testsuite/26_numerics/complex/1.cc: Likewise.
* testsuite/26_numerics/complex/2.cc: Likewise.
* testsuite/26_numerics/endian/2.cc: Likewise.
* testsuite/26_numerics/endian/3.cc: Likewise.
* testsuite/26_numerics/gcd/1.cc: Likewise.
* testsuite/26_numerics/lcm/1.cc: Likewise.
* testsuite/26_numerics/lerp/1.cc: Likewise.
* testsuite/26_numerics/lerp/version.cc: Likewise.
* testsuite/26_numerics/midpoint/integral.cc: Likewise.
* testsuite/26_numerics/midpoint/version.cc: Likewise.
* testsuite/26_numerics/numbers/1.cc: Likewise.
* testsuite/26_numerics/numbers/2.cc: Likewise.
* testsuite/27_io/basic_filebuf/native_handle/char/1.cc:
Likewise.
* testsuite/27_io/basic_filebuf/native_handle/version.cc:
Likewise.
* testsuite/27_io/basic_ofstream/open/char/noreplace.cc:
Likewise.
* testsuite/27_io/basic_ofstream/open/wchar_t/noreplace.cc:
Likewise.
* testsuite/27_io/basic_syncbuf/1.cc: Likewise.
* testsuite/27_io/basic_syncbuf/2.cc: Likewise.
* testsuite/27_io/basic_syncstream/1.cc: Likewise.
* testsuite/27_io/basic_syncstream/2.cc: Likewise.
* testsuite/27_io/spanstream/1.cc: Likewise.
* testsuite/27_io/spanstream/version.cc: Likewise.
* testsuite/29_atomics/atomic/cons/value_init.cc: Likewise.
* testsuite/29_atomics/atomic/lock_free_aliases.cc: Likewise.
* testsuite/29_atomics/atomic/wait_notify/1.cc: Likewise.
* testsuite/29_atomics/atomic/wait_notify/2.cc: Likewise.
* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc:
Likewise.
* testsuite/29_atomics/headers/stdatomic.h/version.cc: Likewise.
* testsuite/30_threads/barrier/1.cc: Likewise.
* testsuite/30_threads/barrier/2.cc: Likewise.
* testsuite/30_threads/condition_variable_any/stop_token/1.cc:
Likewise.
* testsuite/30_threads/condition_variable_any/stop_token/2.cc:
Likewise.
* testsuite/30_threads/jthread/1.cc: Likewise.
* testsuite/30_threads/jthread/version.cc: Likewise.
* testsuite/30_threads/latch/1.cc: Likewise.
* testsuite/30_threads/latch/2.cc: Likewise.
* testsuite/30_threads/scoped_lock/requirements/typedefs.cc:
Likewise.
* testsuite/30_threads/semaphore/1.cc: Likewise.
* testsuite/30_threads/semaphore/2.cc: Likewise.
* testsuite/30_threads/stop_token/1.cc: Likewise.
* testsuite/30_threads/stop_token/2.cc: Likewise.
* testsuite/experimental/feat-char8_t.cc: Likewise.
* testsuite/experimental/iterator/ostream_joiner.cc: Likewise.
* testsuite/experimental/numeric/gcd.cc: Likewise.
* testsuite/experimental/scopeguard/uniqueres.cc: Likewise.
* testsuite/std/concepts/1.cc: Likewise.
* testsuite/std/concepts/2.cc: Likewise.
* testsuite/std/ranges/adaptors/as_const/1.cc: Likewise.
* testsuite/std/ranges/adaptors/as_rvalue/1.cc: Likewise.
* testsuite/std/ranges/adaptors/chunk/1.cc: Likewise.
* testsuite/std/ranges/adaptors/chunk_by/1.cc: Likewise.
* testsuite/std/ranges/adaptors/enumerate/1.cc: Likewise.
* testsuite/std/ranges/adaptors/join_with/1.cc: Likewise.
* testsuite/std/ranges/adaptors/slide/1.cc: Likewise.
* testsuite/std/ranges/adaptors/stride/1.cc: Likewise.
* testsuite/std/ranges/cartesian_product/1.cc: Likewise.
* testsuite/std/ranges/headers/ranges/synopsis.cc: Likewise.
* testsuite/std/ranges/repeat/1.cc: Likewise.
* testsuite/std/ranges/version_c++23.cc: Likewise.
* testsuite/std/ranges/zip/1.cc: Likewise.
* testsuite/std/time/syn_c++20.cc: Likewise.
* testsuite/experimental/feat-cxx14.cc: Likewise. Include
<algorithm> and <iterator>.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.

10 months agolibstdc++: Use 202100L as feature test check for C++23
Jonathan Wakely [Tue, 14 Nov 2023 19:22:47 +0000 (19:22 +0000)]
libstdc++: Use 202100L as feature test check for C++23

I noticed that our C++23 features were not being defined when using
Clang 16 with -std=c++2b, because it only defines __cplusplus=202101L
but <bits/version.h> uses 202302L since my r14-3252-g0c316669b092fb
change.

This changes <bits/version.h> to use 202100 instead of the final 202302
value so that we support Clang 16's -std=c++2b mode.

libstdc++-v3/ChangeLog:

* include/bits/version.def (stds): Use >= 202100 for C++23
condition.
* include/bits/version.h: Regenerate.
* include/std/thread: Use > C++20 instead of >= C++23 for
__cplusplus condition.

10 months agolibstdc++: Adjust feature test in <istream> and <ostream>
Jonathan Wakely [Tue, 14 Nov 2023 15:48:03 +0000 (15:48 +0000)]
libstdc++: Adjust feature test in <istream> and <ostream>

We don't need any library concepts to define the constraints for rvalue
stream overloads, only compiler support. So change the test from using
__cpp_lib_concepts to __cpp_concepts >= 201907L.

libstdc++-v3/ChangeLog:

* include/std/istream (__rvalue_stream_extraction_t): Test
__cpp_concepts instead of __cpp_lib_concepts.
* include/std/ostream (__derived_from_ios_base): Likewise.
(__rvalue_stream_insertion_t): Likewise.

10 months agoi386: Fix mov imm,%rax; mov %rdi,%rdx; mulx %rax -> mov imm,%rdx; mulx %rdi peephole2...
Jakub Jelinek [Thu, 16 Nov 2023 07:33:18 +0000 (08:33 +0100)]
i386: Fix mov imm,%rax; mov %rdi,%rdx; mulx %rax -> mov imm,%rdx; mulx %rdi peephole2 [PR112526]

The following testcase is miscompiled on x86_64 since PR110551 r14-4968
commit.  That commit added 2 peephole2s, one for
mov imm,%rXX; mov %rYY,%rax; mulq %rXX -> mov imm,%rax; mulq %rYY
which I believe is ok, and another one for
mov imm,%rXX; mov %rYY,%rdx; mulx %rXX, %rZZ, %rWW -> mov imm,%rdx; mulx %rYY, %rZZ, %rWW
which is wrong.  Both peephole2s verify that %rXX above is dead at
the end of the pattern, by checking if %rXX is either one of the
registers overwritten in the multiplication (%rdx:%rax in the first
case, the 2 destination registers of mulx in the latter case), because
we no longer set %rXX to that immediate (we set %rax resp. %rdx to it
instead) when the peephole2 replaces it.  But, we also need to ensure
that the other register previously set to the value of %rYY and newly
to imm isn't used after the multiplication, and neither of the peephole2s
does that.  Now, for the first one (at least assuming in the % pattern
the matching operand (i.e. hardcoded %rax resp. %rdx) after RA will always go
first) I think it is always the case, because operands[2] if it must be %rax
register will be overwritten by mulq writing to %rdx:%rax.  But in the
second case, there is no reason why %rdx couldn't be used after the pattern,
and if it is (like in the testcase), we can't make those changes.
So, the patch checks similarly to operands[0] that operands[2] (which ought
to be %rdx if RA puts the % match_dup operand first and nothing swaps it
afterwards) is either the same register as one of the destination registers
of mulx or dies at the end of the multiplication.

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

PR target/112526
* config/i386/i386.md
(mov imm,%rax; mov %rdi,%rdx; mulx %rax -> mov imm,%rdx; mulx %rdi):
Verify in define_peephole2 that operands[2] dies or is overwritten
at the end of multiplication.

* gcc.target/i386/bmi2-pr112526.c: New test.

10 months agoslp: Fix handling of IFN_CLZ/CTZ [PR112536]
Jakub Jelinek [Thu, 16 Nov 2023 07:32:24 +0000 (08:32 +0100)]
slp: Fix handling of IFN_CLZ/CTZ [PR112536]

We ICE on the following testcase now that IFN_C[LT]Z calls can have one or
two arguments (where 2 mean it is well defined at zero).
The following patch makes us create child node only for the first argument
and compatible_calls_p ensures the other argument is the same, which
at least according to the testcase seems sufficient because of vect
patterns.

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

PR tree-optimization/112536
* tree-vect-slp.cc (arg0_map): New variable.
(vect_get_operand_map): For IFN_CLZ or IFN_CTZ, return arg0_map.

* gcc.dg/pr112536.c: New test.

10 months agotree-optimization/112282 - fix testcase
Richard Biener [Thu, 16 Nov 2023 07:03:55 +0000 (08:03 +0100)]
tree-optimization/112282 - fix testcase

Avoid requiring a glibc specific symbol.

PR tree-optimization/112282
* gcc.dg/torture/pr112282.c: Do not use __assert_fail.

10 months agoVECT: Clear LOOP_VINFO_USING_SELECT_VL_P when loop is not partial vectorized
Juzhe-Zhong [Thu, 16 Nov 2023 02:58:16 +0000 (10:58 +0800)]
VECT: Clear LOOP_VINFO_USING_SELECT_VL_P when loop is not partial vectorized

This patch fixes ICE:
https://godbolt.org/z/z8T6o6qov

<source>: In function 'b':
<source>:2:6: error: missing definition
    2 | void b() {
      |      ^
for SSA_NAME: loop_len_8 in statement:
_1 = -loop_len_8;
during GIMPLE pass: vect
<source>:2:6: internal compiler error: verify_ssa failed
0x7f1b56331082 __libc_start_main
???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

The root cause is we generate such IR in vectorization:

  _1 = -loop_len_8;
  vect_cst__11 = {_1, _1};
  _18 = vect_vec_iv_.6_14 + vect_cst__11;

loop_len_8 is uninitialized value.

The IR _18 = vect_vec_iv_.6_14 + vect_cst__11; is generated because of we are adding induction variable with
the result of SELECT_VL instead of VF.

The code is:

  else if (LOOP_VINFO_USING_SELECT_VL_P (loop_vinfo))
    {
      /* When we're using loop_len produced by SELEC_VL, the non-final
 iterations are not always processing VF elements.  So vectorize
 induction variable instead of

   _21 = vect_vec_iv_.6_22 + { VF, ... };

 We should generate:

   _35 = .SELECT_VL (ivtmp_33, VF);
   vect_cst__22 = [vec_duplicate_expr] _35;
   _21 = vect_vec_iv_.6_22 + vect_cst__22;  */
      gcc_assert (!slp_node);
      gimple_seq seq = NULL;
      vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo);
      tree len = vect_get_loop_len (loop_vinfo, NULL, lens, 1, vectype, 0, 0);
      expr = force_gimple_operand (fold_convert (TREE_TYPE (step_expr),
 unshare_expr (len)),
   &seq, true, NULL_TREE);
      new_name = gimple_build (&seq, MULT_EXPR, TREE_TYPE (step_expr), expr,
       step_expr);
      gsi_insert_seq_before (&si, seq, GSI_SAME_STMT);
      step_iv_si = &si;
    }

LOOP_VINFO_USING_SELECT_VL_P is set before loop vectorization analysis so we don't know whether it is partial
vectorization or not but the induction variable depends on SELECT_VL_P is true.

So update SELECT_VL_P as false when it is not partial vectorization.

PR middle-end/112554

gcc/ChangeLog:

* tree-vect-loop.cc (vect_determine_partial_vectors_and_peeling):
Clear SELECT_VL_P for non-partial vectorization.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr112554.c: New test.

10 months agoFix crash in libcc1
Tom Tromey [Wed, 15 Nov 2023 05:27:52 +0000 (22:27 -0700)]
Fix crash in libcc1

The gdb tests of the libcc1 plugin have been failing lately.  I
tracked this down to a crash trying to access an enum's underlying
type.  This patch fixes the crash by setting this type.

* libcc1plugin.cc (plugin_build_enum_type): Set
ENUM_UNDERLYING_TYPE.

10 months agoc++: fix parsing with auto(x) [PR112410]
Marek Polacek [Thu, 9 Nov 2023 17:25:25 +0000 (12:25 -0500)]
c++: fix parsing with auto(x) [PR112410]

Here we are wrongly parsing

  int y(auto(42));

which uses the C++23 cast-to-prvalue feature, and initializes y to 42.
However, we were treating the auto as an implicit template parameter.

Fixing the auto{42} case is easy, but when auto is followed by a (,
I found the fix to be much more involved.  For instance, we cannot
use cp_parser_expression, because that can give hard errors.  It's
also necessary to disambiguate 'auto(i)' as 'auto i', not a cast.
auto(), auto(int), auto(f)(int), auto(*), auto(i[]), auto(...), etc.
are all function declarations.

This patch rectifies that by undoing the implicit function template
modification.  In the test above, we should notice that the parameter
list is ill-formed, and since we've synthesized an implicit template
parameter, we undo it by calling abort_fully_implicit_template.  Then,
we'll parse the "(auto(42))" as an initializer.

PR c++/112410

gcc/cp/ChangeLog:

* parser.cc (cp_parser_direct_declarator): Maybe call
abort_fully_implicit_template if it turned out the parameter list was
ill-formed.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/auto-fncast13.C: New test.
* g++.dg/cpp23/auto-fncast14.C: New test.

10 months ago[i386] APX: Fix EGPR usage in several patterns.
Hongyu Wang [Thu, 9 Nov 2023 05:11:41 +0000 (13:11 +0800)]
[i386] APX: Fix EGPR usage in several patterns.

For vextract/insert{if}128 they cannot adopt EGPR in their memory operand, all
related pattern should be adjusted to disable EGPR usage on them.
Also fix a wrong gpr16 attr for insertps.

gcc/ChangeLog:

* config/i386/sse.md (vec_extract_hi_<mode>): Add noavx512vl
alternative with attr addr gpr16 and "jm" constraint.
(vec_extract_hi_<mode>): Likewise for SF vector modes.
(@vec_extract_hi_<mode>): Likewise.
(*vec_extractv2ti): Likewise.
(vec_set_hi_<mode><mask_name>): Likewise.
* config/i386/mmx.md (@sse4_1_insertps_<mode>): Correct gpr16 attr for
each alternative.

10 months agoDaily bump.
GCC Administrator [Thu, 16 Nov 2023 00:17:42 +0000 (00:17 +0000)]
Daily bump.

10 months agoi386: Optimize strict_low_part QImode insn with high input registers
Uros Bizjak [Wed, 15 Nov 2023 21:21:10 +0000 (22:21 +0100)]
i386: Optimize strict_low_part QImode insn with high input registers

Following testcase:

struct S1
{
  unsigned char val;
  unsigned char pad1;
  unsigned short pad2;
};

struct S2
{
  unsigned char pad1;
  unsigned char val;
  unsigned short pad2;
};

struct S1 test_add (struct S1 a, struct S2 b, struct S2 c)
{
  a.val = b.val + c.val;

  return a;
}

compiles with -O2 to:

        movl    %edi, %eax
        movzbl  %dh, %edx
        movl    %esi, %ecx
        movb    %dl, %al
        addb    %ch, %al

The insert to %al can go directly from %dh:

        movl    %edi, %eax
        movl    %esi, %ecx
        movb    %dh, %al
        addb    %ch, %al

Patch introduces strict_low_part QImode insn patterns with both of
their input arguments extracted from high register.  This invalid
insn is split after reload to a lowpart insert from the high register
and <insn>qi_ext<mode>_1_slp instruction.

PR target/78904

gcc/ChangeLog:

* config/i386/i386.md (*movstrictqi_ext<mode>_1): New insn pattern.
(*addqi_ext<mode>_2_slp): New define_insn_and_split pattern.
(*subqi_ext<mode>_2_slp): Ditto.
(*<any_logic:code>qi_ext<mode>_2_slp): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr78904-8.c: New test.
* gcc.target/i386/pr78904-8a.c: New test.
* gcc.target/i386/pr78904-8b.c: New test.
* gcc.target/i386/pr78904-9.c: New test.
* gcc.target/i386/pr78904-9a.c: New test.
* gcc.target/i386/pr78904-9b.c: New test.

10 months agoRegenerate libiberty/aclocal.m4 with aclocal 1.15.1
Mark Wielaard [Wed, 15 Nov 2023 19:27:08 +0000 (20:27 +0100)]
Regenerate libiberty/aclocal.m4 with aclocal 1.15.1

There is a new buildbot check that all autotool files are generated
with the correct versions (automake 1.15.1 and autoconf 2.69).
https://builder.sourceware.org/buildbot/#/builders/gcc-autoregen

Correct one file that was generated with the wrong version.

libiberty/
* aclocal.m4: Rebuild.

10 months agoRISC-V: Fix ICE in non-canonical march parsing
Patrick O'Neill [Tue, 14 Nov 2023 23:08:31 +0000 (15:08 -0800)]
RISC-V: Fix ICE in non-canonical march parsing

Passing in a base extension in non-canonical order (i, e, g) causes GCC
to ICE:
xgcc: error: '-march=rv64ge': ISA string is not in canonical order. 'e'
xgcc: internal compiler error: in add, at common/config/riscv/riscv-common.cc:671
...

This is fixed by skipping to the next extension when a non-canonical
order is detected.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(riscv_subset_list::parse_std_ext): Emit an error and skip to
the next extension when a non-canonical ordering is detected.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-27.c: New test.
* gcc.target/riscv/arch-28.c: New test.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
10 months agoc++, analyzer: Expand CAN_HAVE_LOCATION_P macro.
Bernhard Reutner-Fischer [Thu, 1 Jun 2023 17:44:19 +0000 (19:44 +0200)]
c++, analyzer: Expand CAN_HAVE_LOCATION_P macro.

r14-985-gca2007a9bb3074 used the collapsed macro definition
CAN_HAVE_LOCATION_P in gcc-rich-location.cc and r14-977-g8861c80733da5c
in c++'s build_cplus_array_type ().
However, although otherwise correct, the usage of CAN_HAVE_LOCATION_P
in these two spots is misleading, so this patch reverts aforementioned
two hunks.

gcc/cp/ChangeLog:

* tree.cc (build_cplus_array_type): Revert using the macro
CAN_HAVE_LOCATION_P.

gcc/ChangeLog:

* gcc-rich-location.cc (maybe_range_label_for_tree_type_mismatch::get_text):
Revert using the macro CAN_HAVE_LOCATION_P.

10 months agoRISC-V: fix vsetvli pass testsuite failure [PR/112447]
Juzhe-Zhong [Wed, 15 Nov 2023 03:23:19 +0000 (19:23 -0800)]
RISC-V: fix vsetvli pass testsuite failure [PR/112447]

Fixes: f0e28d8c1371 ("RISC-V: Fix failed hoist in LICM of vmv.v.x instruction")
Since above commit, we have following failure:

  FAIL: gcc.c-torture/execute/memset-3.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test
  FAIL: gcc.c-torture/execute/memset-3.c   -O3 -g  execution test

The issue was not the commit but rather it unravelled an issue in the
vsetvli pass.

Here's Juzhe's analysis:

We have 2 types of global vsetvls insertion.
One is earliest fusion of each end of the block.
The other is LCM suggested edge vsetvls.

So before this patch, insertion as follows:

|  (insn 2817 2820 2818 361 (set (reg:SI 67 vtype)
|        (unspec:SI [
|                (const_int 8 [0x8])
|                (const_int 7 [0x7])
|                (const_int 1 [0x1]) repeated x2
|            ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
|     (nil))
|  (insn 2818 2817 999 361 (set (reg:SI 67 vtype)
|        (unspec:SI [
|                (const_int 32 [0x20])
|                (const_int 1 [0x1]) repeated x3
|            ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
|     (nil))

After this patch:

|  (insn 2817 2820 2819 361 (set (reg:SI 67 vtype)
|        (unspec:SI [
|                (const_int 32 [0x20])
|                (const_int 1 [0x1]) repeated x3
|            ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
|     (nil))
|  (insn 2819 2817 999 361 (set (reg:SI 67 vtype)
|        (unspec:SI [
|                (const_int 8 [0x8])
|                (const_int 7 [0x7])
|                (const_int 1 [0x1]) repeated x2
|            ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
|     (nil))

The original insertion order is incorrect.

We should first insert earliest fusion since it is the vsetvls information
already there which was seen by later LCM. We just delay the insertion.
So it should be come before the LCM suggested insertion.

PR target/112447

gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (pre_vsetvl::emit_vsetvl): Insert
local vsetvl info before LCM suggested one.

Tested-by: Patrick O'Neill <patrick@rivosinc.com> # pre-commit-CI #679
Co-developed-by: Vineet Gupta <vineetg@rivosinc.com>
10 months agoRISC-V: elide unnecessary sign extend when expanding cmp_and_jump
Vineet Gupta [Wed, 25 Oct 2023 03:38:49 +0000 (20:38 -0700)]
RISC-V: elide unnecessary sign extend when expanding cmp_and_jump

RV64 compare and branch instructions only support 64-bit operands.
At Expand time, the backend conservatively zero/sign extends
its operands even if not needed, such as incoming function args
which ABI/ISA guarantee to be sign-extended already (this is true for
SI, HI, QI operands)

And subsequently REE fails to eliminate them as
   "missing defintion(s)" or "multiple definition(s)
since function args don't have explicit definition.

So during expand riscv_extend_comparands (), if an operand is a
subreg-promoted SI with inner DI, which is representative of a function
arg, just peel away the subreg to expose the DI, eliding the sign
extension. As Jeff noted this routine is also used in if-conversion so
potentially can also help there.

Note there's currently patches floating around to improve REE and also a
new pass to eliminate unneccesary extensions, but it is still beneficial
to not generate those extra extensions in first place. It is obviously
less work for post-reload passes such as REE, but even for earlier
passes, such as combine, having to deal with one less thing and ensuing
fewer combinations is a win too.

Way too many existing tests used to observe this issue.
e.g. gcc.c-torture/compile/20190827-1.c -O2 -march=rv64gc
It elimiates the SEXT.W

gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_sign_extend_if_not_subreg_prom): New.
* (riscv_extend_comparands): Call New function on operands.

Tested-by: Patrick O'Neill <patrick@rivosinc.com> # pre-commit-CI #676
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
10 months agoc++: direct enum init from type-dep elt [PR112515]
Patrick Palka [Wed, 15 Nov 2023 17:24:38 +0000 (12:24 -0500)]
c++: direct enum init from type-dep elt [PR112515]

The NON_DEPENDENT_EXPR removal exposed that is_direct_enum_init can be
called in a template context on a CONSTRUCTOR that isn't type-dependent
but whose element is.

PR c++/112515

gcc/cp/ChangeLog:

* decl.cc (is_direct_enum_init): Check type-dependence of the
single element.

gcc/testsuite/ChangeLog:

* g++.dg/template/non-dependent30.C: New test.

10 months agoc++: partially inst requires-expr in noexcept-spec [PR101043]
Patrick Palka [Wed, 15 Nov 2023 17:17:55 +0000 (12:17 -0500)]
c++: partially inst requires-expr in noexcept-spec [PR101043]

Here we're ICEing from strip_typedefs for the partially instantiated
requires-expression when walking its REQUIRES_EXPR_EXTRA_ARGS which
in this case is a TREE_LIST with non-empty TREE_PURPOSE (to hold the
captured local specialization 't' as per build_extra_args) which
strip_typedefs doesn't expect.

We can probably skip walking REQUIRES_EXPR_EXTRA_ARGS at all since it
shouldn't contain any typedefs in the first place, but it seems safer
and more generally useful to just teach strip_typedefs to handle non-empty
TREE_PURPOSE the obvious way.  (The code asserts TREE_PURPOSE was empty
even since since its inception i.e. r189298.)

PR c++/101043

gcc/cp/ChangeLog:

* tree.cc (strip_typedefs_expr) <case TREE_LIST>: Handle
non-empty TREE_PURPOSE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires37.C: New test.

10 months agoc++: non-dependent .* operand folding [PR112427]
Patrick Palka [Wed, 15 Nov 2023 17:10:16 +0000 (12:10 -0500)]
c++: non-dependent .* operand folding [PR112427]

Here when building up the non-dependent .* expression, we crash from
fold_convert on 'b.a' due to this (templated) COMPONENT_REF having an
IDENTIFIER_NODE instead of FIELD_DECL operand that middle-end routines
expect.  Like in r14-4899-gd80a26cca02587, this patch fixes this by
replacing the problematic piecemeal folding with a single call to
cp_fully_fold.  Also, don't bother building the POINTER_PLUS_EXPR in a
template context.  This means the returned non-dependent tree might not
have TREE_SIDE_EFFECTS set when it used to, so we need to compensate
by making build_min_non_dep propagate TREE_SIDE_EFFECTS from the original
arguments like buildN and build_min do.

PR c++/112427

gcc/cp/ChangeLog:

* tree.cc (build_min_non_dep): Propagate TREE_SIDE_EFFECTS from
the original arguments.
(build_min_non_dep_call_vec): Likewise.
* typeck2.cc (build_m_component_ref): Use cp_convert, build2 and
cp_fully_fold instead of fold_build_pointer_plus and fold_convert.
Don't build the POINTER_PLUS_EXPR in a template context.

gcc/testsuite/ChangeLog:

* g++.dg/template/non-dependent29.C: New test.

10 months agoc++: constantness of local var in constexpr fn [PR111703, PR112269]
Patrick Palka [Wed, 15 Nov 2023 17:03:16 +0000 (12:03 -0500)]
c++: constantness of local var in constexpr fn [PR111703, PR112269]

potential_constant_expression was incorrectly treating most local
variables from a constexpr function as constant because it wasn't
considering the 'now' parameter.  This patch fixes this by relaxing
its var_in_maybe_constexpr_fn checks accordingly, which turns out to
partially fix two recently reported regressions:

PR111703 is a regression caused by r11-550-gf65a3299a521a4 for restricting
constexpr evaluation during warning-dependent folding.  The mechanism is
intended to restrict only constant evaluation of the instantiated
non-dependent expression, but it also ends up restricting constant
evaluation occurring during instantiation of the expression, in particular
when instantiating the converted argument 'x' (a VIEW_CONVERT_EXPR) into
a copy constructor call.  This seems like a flaw in the mechanism, though
I don't know if we want to fix the mechanism or get rid of it completely
since the original testcases which motivated the mechanism are fixed more
simply by r13-1225-gb00b95198e6720.  In any case, this patch partially
fixes this by making us correctly treat 'x' as non-constant which prevents
the problematic warning-dependent folding from occurring at all.

PR112269 is caused by r14-4796-g3e3d73ed5e85e7 for merging tsubst_copy
into tsubst_copy_and_build.  tsubst_copy used to exit early when 'args'
was empty, behavior which that commit deliberately didn't preserve.
This early exit masked the fact that COMPLEX_EXPR wasn't handled by
tsubst at all, and is a tree code that apparently we could see during
warning-dependent folding on some targets.  A complete fix is to add
handling for this tree code in tsubst_expr, but this patch should fix
the reported testsuite failures since the COMPLEX_EXPRs that crop up
in <complex> are considered non-constant expressions after this patch.

PR c++/111703
PR c++/112269

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1) <case VAR_DECL>:
Only consider var_in_maybe_constexpr_fn if 'now' is false.
<case INDIRECT_REF>: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-fn8.C: New test.

10 months agoi386: Fix split condition of *<insn>qi_ext<mode>_1_slp patterns
Uros Bizjak [Wed, 15 Nov 2023 15:45:21 +0000 (16:45 +0100)]
i386: Fix split condition of *<insn>qi_ext<mode>_1_slp patterns

gcc/ChangeLog:

* config/i386/i386.md (*addqi_ext<mode>_1_slp):
Add "&& " before "reload_completed" in split condition.
(*subqi_ext<mode>_1_slp): Ditto.
(*<any_logic:code>qi_ext<mode>_1_slp): Ditto.

10 months agoi386: Fix strict_low_part QImode insn with high input register patterns [PR112540]
Uros Bizjak [Wed, 15 Nov 2023 15:11:30 +0000 (16:11 +0100)]
i386: Fix strict_low_part QImode insn with high input register patterns [PR112540]

PR target/112540

gcc/ChangeLog:

* config/i386/i386.md (*addqi_ext<mode>_1_slp):
Correct operand numbers in split pattern.  Replace !Q constraint
of operand 1 with !qm.  Add insn constrain.
(*subqi_ext<mode>_1_slp): Ditto.
(*<any_logic:code>qi_ext<mode>_1_slp): Ditto.

10 months agonvptx: Fix copy'n'paste-o in '__builtin_nvptx_brev' description
Thomas Schwinge [Mon, 4 Sep 2023 15:20:28 +0000 (17:20 +0200)]
nvptx: Fix copy'n'paste-o in '__builtin_nvptx_brev' description

Minor fix-up for commit c09471fbc7588db2480f036aa56a2403d3c03ae5
"nvptx: Add suppport for __builtin_nvptx_brev instrinsic".

gcc/
* doc/extend.texi (Nvidia PTX Built-in Functions): Fix
copy'n'paste-o in '__builtin_nvptx_brev' description.

10 months agoUpdate nvptx's bitrev<mode>2 pattern to use BITREVERSE rtx.
Roger Sayle [Wed, 7 Jun 2023 23:09:00 +0000 (00:09 +0100)]
Update nvptx's bitrev<mode>2 pattern to use BITREVERSE rtx.

This minor tweak to the nvptx backend switches the representation of
of the brev instruction from an UNSPEC to instead use the new BITREVERSE
rtx.  This allows various RTL optimizations including evaluation (constant
folding) of integer constant arguments at compile-time.

gcc/
* config/nvptx/nvptx.md (UNSPEC_BITREV): Delete.
(bitrev<mode>2): Represent using bitreverse.
gcc/testsuite/
* gcc.target/nvptx/brev-2-O2.c: Adjust.
* gcc.target/nvptx/brevll-2-O2.c: Likewise.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
10 months agonvptx: Extend 'brev' test cases
Thomas Schwinge [Mon, 4 Sep 2023 21:06:27 +0000 (23:06 +0200)]
nvptx: Extend 'brev' test cases

In order to observe effects of a later patch, extend the 'brev' test cases
added in commit c09471fbc7588db2480f036aa56a2403d3c03ae5
"nvptx: Add suppport for __builtin_nvptx_brev instrinsic".

gcc/testsuite/
* gcc.target/nvptx/brev-1.c: Extend.
* gcc.target/nvptx/brev-2.c: Rename to...
* gcc.target/nvptx/brev-2-O2.c: ... this, and extend.  Copy to...
* gcc.target/nvptx/brev-2-O0.c: ... this, and adapt for '-O0'.
* gcc.target/nvptx/brevll-1.c: Extend.
* gcc.target/nvptx/brevll-2.c: Rename to...
* gcc.target/nvptx/brevll-2-O2.c: ... this, and extend.  Copy to...
* gcc.target/nvptx/brevll-2-O0.c: ... this, and adapt for '-O0'.

10 months agoamdgcn: Add Accelerator VGPR registers
Andrew Stubbs [Tue, 3 Oct 2023 13:03:49 +0000 (14:03 +0100)]
amdgcn: Add Accelerator VGPR registers

Add the new CDNA register file.  We don't support any of the specialized
instructions that use these registers, but they're useful to relieve
register pressure without spilling to stack.

Co-authored-by: Andrew Jenner <andrew@codesourcery.com>
gcc/ChangeLog:

* config/gcn/constraints.md: Add "a" AVGPR constraint.
* config/gcn/gcn-valu.md (*mov<mode>): Add AVGPR alternatives.
(*mov<mode>_4reg): Likewise.
(@mov<mode>_sgprbase): Likewise.
(gather<mode>_insn_1offset<exec>): Likewise.
(gather<mode>_insn_1offset_ds<exec>): Likewise.
(gather<mode>_insn_2offsets<exec>): Likewise.
(scatter<mode>_expr<exec_scatter>): Likewise.
(scatter<mode>_insn_1offset_ds<exec_scatter>): Likewise.
(scatter<mode>_insn_2offsets<exec_scatter>): Likewise.
* config/gcn/gcn.cc (MAX_NORMAL_AVGPR_COUNT): Define.
(gcn_class_max_nregs): Handle AVGPR_REGS and ALL_VGPR_REGS.
(gcn_hard_regno_mode_ok): Likewise.
(gcn_regno_reg_class): Likewise.
(gcn_spill_class): Allow spilling to AVGPRs on TARGET_CDNA1_PLUS.
(gcn_sgpr_move_p): Handle AVGPRs.
(gcn_secondary_reload): Reload AVGPRs via VGPRs.
(gcn_conditional_register_usage): Handle AVGPRs.
(gcn_vgpr_equivalent_register_operand): New function.
(gcn_valid_move_p): Check for validity of AVGPR moves.
(gcn_compute_frame_offsets): Handle AVGPRs.
(gcn_memory_move_cost): Likewise.
(gcn_register_move_cost): Likewise.
(gcn_vmem_insn_p): Handle TYPE_VOP3P_MAI.
(gcn_md_reorg): Handle AVGPRs.
(gcn_hsa_declare_function_name): Likewise.
(print_reg): Likewise.
(gcn_dwarf_register_number): Likewise.
* config/gcn/gcn.h (FIRST_AVGPR_REG): Define.
(AVGPR_REGNO): Define.
(LAST_AVGPR_REG): Define.
(SOFT_ARG_REG): Update.
(FRAME_POINTER_REGNUM): Update.
(DWARF_LINK_REGISTER): Update.
(FIRST_PSEUDO_REGISTER): Update.
(AVGPR_REGNO_P): Define.
(enum reg_class): Add AVGPR_REGS and ALL_VGPR_REGS.
(REG_CLASS_CONTENTS): Add new register classes and add entries for
AVGPRs to all classes.
(REGISTER_NAMES): Add AVGPRs.
* config/gcn/gcn.md (FIRST_AVGPR_REG, LAST_AVGPR_REG): Define.
(AP_REGNUM, FP_REGNUM): Update.
(define_attr "type"): Add vop3p_mai.
(define_attr "unit"): Handle vop3p_mai.
(define_attr "gcn_version"): Add "cdna2".
(define_attr "enabled"): Handle cdna2.
(*mov<mode>_insn): Add AVGPR alternatives.
(*movti_insn): Likewise.
* config/gcn/mkoffload.cc (isa_has_combined_avgprs): New.
(process_asm): Process avgpr_count.
* config/gcn/predicates.md (gcn_avgpr_register_operand): New.
(gcn_avgpr_hard_register_operand): New.
* doc/md.texi: Document the "a" constraint.

gcc/testsuite/ChangeLog:

* gcc.target/gcn/avgpr-mem-double.c: New test.
* gcc.target/gcn/avgpr-mem-int.c: New test.
* gcc.target/gcn/avgpr-mem-long.c: New test.
* gcc.target/gcn/avgpr-mem-short.c: New test.
* gcc.target/gcn/avgpr-spill-double.c: New test.
* gcc.target/gcn/avgpr-spill-int.c: New test.
* gcc.target/gcn/avgpr-spill-long.c: New test.
* gcc.target/gcn/avgpr-spill-short.c: New test.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (max_isa_vgprs): New.
(run_kernel): CDNA2 devices have more VGPRs.

10 months agoamdgcn: simplify secondary reload patterns
Andrew Stubbs [Fri, 6 Oct 2023 10:14:05 +0000 (11:14 +0100)]
amdgcn: simplify secondary reload patterns

Remove some unnecessary complexity; no functional change is intended,
although LRA appears to use the constraints from the reload_in/out
patterns, so it's probably an improvement for it to see the real sgprbase
constraints.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (mov<mode>_sgprbase): Add @ modifier.
(reload_in<mode>): Delete.
(reload_out<mode>): Delete.
* config/gcn/gcn.cc (CODE_FOR): Delete.
(get_code_for_##PREFIX##vN##SUFFIX): Delete.
(CODE_FOR_OP): Delete.
(get_code_for_##PREFIX): Delete.
(gcn_secondary_reload): Replace "get_code_for" with "code_for".

10 months agos390: Fix generation of s390-gen-builtins.h
Stefan Schulze Frielinghaus [Wed, 15 Nov 2023 13:42:22 +0000 (14:42 +0100)]
s390: Fix generation of s390-gen-builtins.h

By default the preprocessed output includes linemarkers.  This leads to
an error if -pedantic is used as e.g. during bootstrap:

s390-gen-builtins.h:1:3: error: style of line directive is a GCC extension [-Werror]

Fixed by omitting linemarkers while generating s390-gen-builtins.h.

gcc/ChangeLog:

* config/s390/t-s390: Generate s390-gen-builtins.h without
linemarkers.

10 months agotree-optimization/112282 - wrong-code with ifcvt hoisting
Richard Biener [Wed, 15 Nov 2023 11:24:46 +0000 (12:24 +0100)]
tree-optimization/112282 - wrong-code with ifcvt hoisting

The following avoids hoisting of invariants from conditionally
executed parts of an if-converted loop.  That now makes a difference
since we perform bitfield lowering even when we do not actually
if-convert the loop.  if-conversion deals with resetting flow-sensitive
info when necessary already.

PR tree-optimization/112282
* tree-if-conv.cc (ifcvt_hoist_invariants): Only hoist from
the loop header.

* gcc.dg/torture/pr112282.c: New testcase.

10 months agoFix ICE with SLP and -fdbg-cnt
Richard Biener [Wed, 15 Nov 2023 08:49:31 +0000 (09:49 +0100)]
Fix ICE with SLP and -fdbg-cnt

We have to clear the visited flag on stmts.

* tree-vect-slp.cc (vect_slp_region): Also clear visited flag when
we skipped an instance due to -fdbg-cnt.

10 months agolibsanitizer: update LOCAL_PATCHES
Jakub Jelinek [Wed, 15 Nov 2023 11:53:53 +0000 (12:53 +0100)]
libsanitizer: update LOCAL_PATCHES

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

* LOCAL_PATCHES: Update revisions.

10 months agolibsanitizer: Readd __ubsan_handle_function_type_mismatch_v1{,_abort}
Jakub Jelinek [Wed, 15 Nov 2023 11:49:10 +0000 (12:49 +0100)]
libsanitizer: Readd __ubsan_handle_function_type_mismatch_v1{,_abort}

So that we don't have to bump libubsan.so.1 SONAME, the following patch
reverts part of the changes which removed two handlers.  While we don't
actually use them from GCC, we shouldn't remove supported entrypoints
unless SONAME is changed (removal of __interceptor_* or ___interceptor_*
is fine).  This is the only removal, other libraries just added some
symbols.

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

* ubsan/ubsan_handlers_cxx.h (FunctionTypeMismatchData): Forward
declare.
(__ubsan_handle_function_type_mismatch_v1,
__ubsan_handle_function_type_mismatch_v1_abort): Declare.
* ubsan/ubsan_handlers_cxx.cpp (handleFunctionTypeMismatch,
__ubsan_handle_function_type_mismatch_v1,
__ubsan_handle_function_type_mismatch_v1_abort): New functions readded
for backwards compatibility from older ubsan.
* ubsan/ubsan_interface.inc (__ubsan_handle_function_type_mismatch_v1,
__ubsan_handle_function_type_mismatch_v1_abort): Readd.

10 months agolibsanitizer: Adjust the asan/sanity-check-pure-c-1.c test
Jakub Jelinek [Wed, 15 Nov 2023 11:48:20 +0000 (12:48 +0100)]
libsanitizer: Adjust the asan/sanity-check-pure-c-1.c test

The updated libasan doesn't print __interceptor_free (or __interceptor_malloc)
but free (or malloc), the following patch adjusts the testcase so that it
accepts it.

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

* c-c++-common/asan/sanity-check-pure-c-1.c: Adjust for interceptor_
or wrap_ substrings possibly not being emitted in newer libasan.

10 months agolibsanitizer: Apply local patches
Jakub Jelinek [Wed, 15 Nov 2023 11:46:56 +0000 (12:46 +0100)]
libsanitizer: Apply local patches

This patch just reapplies local patches (will be noted in LOCAL_PATCHES).

10 months agolibsanitizer: merge from upstream (c425db2eb558c263)
Jakub Jelinek [Wed, 15 Nov 2023 11:45:58 +0000 (12:45 +0100)]
libsanitizer: merge from upstream (c425db2eb558c263)

The following patch is result of libsanitizer/merge.sh
from c425db2eb558c263 (yesterday evening).

Bootstrapped/regtested on x86_64-linux and i686-linux (together with
the follow-up 3 patches I'm about to post).

BTW, seems upstream has added riscv64 support for I think lsan/tsan,
so if anyone is willing to try it there, it would be a matter of
copying e.g. the s390*-*-linux* libsanitizer/configure.tgt entry
to riscv64-*-linux* with the obvious s/s390x/riscv64/ change in it.

10 months agoLoongArch: Remove redundant barrier instructions before LL-SC loops
Xi Ruoyao [Mon, 6 Nov 2023 08:06:08 +0000 (16:06 +0800)]
LoongArch: Remove redundant barrier instructions before LL-SC loops

This is isomorphic to the LLVM changes [1-2].

On LoongArch, the LL and SC instructions has memory barrier semantics:

- LL: <memory-barrier> + <load-exclusive>
- SC: <store-conditional> + <memory-barrier>

But the compare and swap operation is allowed to fail, and if it fails
the SC instruction is not executed, thus the guarantee of acquiring
semantics cannot be ensured. Therefore, an acquire barrier needs to be
generated when failure_memorder includes an acquire operation.

On CPUs implementing LoongArch v1.10 or later, "dbar 0b10100" is an
acquire barrier; on CPUs implementing LoongArch v1.00, it is a full
barrier.  So it's always enough for acquire semantics.  OTOH if an
acquire semantic is not needed, we still needs the "dbar 0x700" as the
load-load barrier like all LL-SC loops.

[1]:https://github.com/llvm/llvm-project/pull/67391
[2]:https://github.com/llvm/llvm-project/pull/69339

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_memmodel_needs_release_fence): Remove.
(loongarch_cas_failure_memorder_needs_acquire): New static
function.
(loongarch_print_operand): Redefine 'G' for the barrier on CAS
failure.
* config/loongarch/sync.md (atomic_cas_value_strong<mode>):
Remove the redundant barrier before the LL instruction, and
emit an acquire barrier on failure if needed by
failure_memorder.
(atomic_cas_value_cmp_and_7_<mode>): Likewise.
(atomic_cas_value_add_7_<mode>): Remove the unnecessary barrier
before the LL instruction.
(atomic_cas_value_sub_7_<mode>): Likewise.
(atomic_cas_value_and_7_<mode>): Likewise.
(atomic_cas_value_xor_7_<mode>): Likewise.
(atomic_cas_value_or_7_<mode>): Likewise.
(atomic_cas_value_nand_7_<mode>): Likewise.
(atomic_cas_value_exchange_7_<mode>): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/cas-acquire.c: New test.

10 months agolibstdc++: Fix std::deque::operator[] Xmethod [PR112491]
Jonathan Wakely [Tue, 14 Nov 2023 15:08:13 +0000 (15:08 +0000)]
libstdc++: Fix std::deque::operator[] Xmethod [PR112491]

The Xmethod for std::deque::operator[] has the same bug that I recently
fixed for the std::deque::size() Xmethod. The first node might have
unused capacity at the start, which needs to be accounted for when
indexing into the deque.

libstdc++-v3/ChangeLog:

PR libstdc++/112491
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.index):
Correctly handle unused capacity at the start of the first node.
* testsuite/libstdc++-xmethods/deque.cc: Check index operator
when elements have been removed from the front.

10 months agolibstdc++: std::stacktrace tweaks
Jonathan Wakely [Wed, 15 Nov 2023 09:17:49 +0000 (09:17 +0000)]
libstdc++: std::stacktrace tweaks

Fix a typo in a string literal and make the new hash.cc test gracefully
handle missing stacktrace data (see PR 112541).

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::at): Fix class name
in exception message.
* testsuite/19_diagnostics/stacktrace/hash.cc: Do not fail if
current() returns a non-empty stacktrace.

10 months agoarm: testsuite: fix test for armv6t2 hardware
Richard Earnshaw [Wed, 15 Nov 2023 10:30:15 +0000 (10:30 +0000)]
arm: testsuite: fix test for armv6t2 hardware

My previous patch series added a new function to check for armv6t2
compatible hardware.  But the test was not correctly implemented and
also did not follow the standard naming convention for Arm hw
compatibility tests.  Fix both of these issues.

gcc/testsuite:

* lib/target-supports.exp (check_effective_target_arm_arch_v6t2_hw_ok):
Rename to...
(check_effective_target_arm_arch_v6t2_hw): ... this.  Fix checks.
* gcc.target/arm/acle/data-intrinsics-armv6.c: Update pre-check.
* gcc.target/arm/acle/data-intrinsics-rbit.c: Likewise.

10 months agoRISC-V: Support trailing vec_init optimization
Juzhe-Zhong [Tue, 14 Nov 2023 11:38:03 +0000 (19:38 +0800)]
RISC-V: Support trailing vec_init optimization

Add optimization when trailing elements > leading elements.

Consider this following case:

#include <stdint.h>

typedef int64_t v16di __attribute__ ((vector_size (128)));

__attribute__ ((noipa)) void
f_v16di (int64_t a, int64_t b, int64_t c, int64_t d, int64_t *out)
{
  v16di v = {a, b, c, d, d, d, d, d, d, d, d, d, d, d, d, d};
  *(v16di *) out = v;
}

https://godbolt.org/z/vWTjbrWGf

Before this patch:

f_v16di:
        vsetivli        zero,16,e64,m8,ta,ma
        vmv.v.x v8,a0
        vslide1down.vx  v8,v8,a1
        vslide1down.vx  v8,v8,a2
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vse64.v v8,0(a4)
        ret

After this patch:

f_v16di:
vsetivli zero,16,e64,m8,ta,ma
vmv.v.x v16,a3
vslide1up.vx v8,v16,a2
vslide1up.vx v16,v8,a1
vslide1up.vx v8,v16,a0
vse64.v v8,0(a4)
ret

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vector_init_trailing_same_elem): New function.
(expand_vec_init): Add trailing optimization.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/def.h: Add trailing tests.
* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing_run-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing_run-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trailing-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trailing-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trailing-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trailing-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trailing-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trailing-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trailing-7.c: New test.

10 months agotestsuite: Adjust gcc.dg/cpp/if-2.c for 16-bit targets
Jakub Jelinek [Wed, 15 Nov 2023 07:55:16 +0000 (08:55 +0100)]
testsuite: Adjust gcc.dg/cpp/if-2.c for 16-bit targets

Jeff reported this testcase newly FAILs on 16-bit targets, the following
patch adjusts the expected diagnostics for that case.

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

* gcc.dg/cpp/if-2.c: Adjust expected diagnostics for 16-bit targets.

10 months agoRISC-V: Refine the mask generation for vec_init case 2
Pan Li [Wed, 15 Nov 2023 03:30:51 +0000 (11:30 +0800)]
RISC-V: Refine the mask generation for vec_init case 2

Update in v2:
1. Add more test cases for fixed-vlmax.
2, Add test cases for vls mode.

Original log:

We take vec_init element int mode when generate the mask for
case 2. But actually we don't need as many bits as the element.
The extra bigger mode may introduce some unnecessary insns.
For example as below code:

typedef int64_t v16di __attribute__ ((vector_size (16 * 8)));

void __attribute__ ((noinline, noclone))
  foo (int64_t *out, int64_t x, int64_t y)
{
  v16di v = {y, x, y, x, y, x, y, x, y, x, y, x, y, x, y, x};
  *(v16di *) out = v;
}

We will have VDImode when generate the 0b0101010101010101 mask but
actually VHImode is good enough here. This patch would like to
refine the mask generation to avoid:
1. Unnecessary scalar to generate big constant mask.
2. Unnecessary vector insn to v0 mask.

Before this patch:
foo:
  li      a5,-1431654400
  li      a4,-1431654400               <== unnecessary insn
  addi    a5,a5,-1365                  <== unnecessary insn
  addi    a4,a4,-1366
  slli    a5,a5,32                     <== unnecessary insn
  add     a5,a5,a4                     <== unnecessary insn
  vsetivli        zero,16,e64,m8,ta,ma
  vmv.v.x v8,a2
  vmv.s.x v16,a5
  vmv1r.v v0,v16                       <== unnecessary insn
  vmerge.vxm      v8,v8,a1,v0
  vse64.v v8,0(a0)
  ret

After this patch:
foo:
  li      a5,-20480
  addiw   a5,a5,-1366
  vsetivli        zero,16,e64,m8,ta,ma
  vmv.s.x v0,a5
  vmv.v.x v8,a2
  vmerge.vxm      v8,v8,a1,v0
  vs8r.v  v8,0(a0)
  ret

gcc/ChangeLog:

* config/riscv/riscv-v.cc (rvv_builder::get_merge_scalar_mask):
Add inner_mode mask arg for mask int mode.
(get_repeating_sequence_dup_machine_mode): Add mask_bit_mode arg
to get the good enough vector int mode on precision.
(expand_vector_init_merge_repeating_sequence): Pass required args
to above func.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-10.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-11.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-12.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-13.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-14.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-15.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-8.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-9.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Disallow RVV mode address for any load/store[PR112535]
Juzhe-Zhong [Wed, 15 Nov 2023 07:15:08 +0000 (15:15 +0800)]
RISC-V: Disallow RVV mode address for any load/store[PR112535]

This patch is quite obvious patch which disallow for load/store address register
with RVV mode.

PR target/112535

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_legitimate_address_p): Disallow RVV modes base address.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr112535.c: New test.

10 months agoc++: Implement C++26 P2864R2 - Remove Deprecated Arithmetic Conversion on Enumeration...
Jakub Jelinek [Wed, 15 Nov 2023 07:27:07 +0000 (08:27 +0100)]
c++: Implement C++26 P2864R2 - Remove Deprecated Arithmetic Conversion on Enumerations From C++26

The following patch implements C++26 P2864R2 by emitting pedwarn enabled by
the same options as the C++20 and later warnings (i.e. -Wenum-compare,
-Wdeprecated-enum-enum-conversion and -Wdeprecated-enum-float-conversion
which are all enabled by default).  I think we still want to allow users
some option workaround, so am not using directly error.  Additionally, for
cxx_dialect >= cxx26 && (complain & tf_warning_or_error) == 0 it causes for
these newly ill-formed constructs error_mark_node to be silently returned.

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

gcc/cp/
* typeck.cc: Implement C++26 P2864R2 - Remove Deprecated Arithmetic
Conversion on Enumerations From C++26.
(do_warn_enum_conversions): Return bool rather than void, add COMPLAIN
argument.  Use pedwarn rather than warning_at for C++26 and remove
" is deprecated" part of the diagnostics in that case.  For SFINAE
in C++26 return true on newly erroneous cases.
(cp_build_binary_op): For C++26 call do_warn_enum_conversions
unconditionally, pass complain argument to it and if it returns true,
return error_mark_node.
* call.cc (build_conditional_expr): Use pedwarn rather than warning_at
for C++26 and remove " is deprecated" part of the diagnostics in that
case and check for complain & tf_warning_or_error.  Use emit_diagnostic
with cxx_dialect >= cxx26 ? DK_PEDWARN : DK_WARNING.  For SFINAE in
C++26 return error_mark_node on newly erroneous cases.
(build_new_op): Use emit_diagnostic with cxx_dialect >= cxx26
? DK_PEDWARN : DK_WARNING and complain & tf_warning_or_error check
for C++26.  For SFINAE in C++26 return error_mark_node on newly
erroneous cases.
gcc/testsuite/
* g++.dg/cpp26/enum-conv1.C: New test.
* g++.dg/cpp2a/enum-conv1.C: Adjust expected diagnostics in C++26.
* g++.dg/diagnostic/enum3.C: Likewise.
* g++.dg/parse/attr3.C: Likewise.
* g++.dg/cpp0x/linkage2.C: Likewise.

10 months agoRevert "libstdc++: bvector: undef always_inline macro"
Alexandre Oliva [Wed, 15 Nov 2023 04:45:58 +0000 (01:45 -0300)]
Revert "libstdc++: bvector: undef always_inline macro"

This reverts commit a1ad62ee2fd070854d2137f35614af639c1a94f2.

10 months agotestsuite: tsan: add fallback overload for pthread_cond_clockwait
Alexandre Oliva [Wed, 15 Nov 2023 01:16:29 +0000 (22:16 -0300)]
testsuite: tsan: add fallback overload for pthread_cond_clockwait

LTS GNU/Linux distros from 2018, still in use, don't have
pthread_cond_clockwait.  There's no trivial way to detect it so as to
make the test conditional, but there's an easy enough way to silence
the fail due to lack of the function in libc, and that has nothing to
do with the false positive that this is testing against.

for  gcc/testsuite/ChangeLog

* g++.dg/tsan/pthread_cond_clockwait.C: Add fallback overload.

10 months agotestsuite: arg-pushing reqs -mno-accumulate-outgoing-args
Alexandre Oliva [Wed, 15 Nov 2023 01:15:32 +0000 (22:15 -0300)]
testsuite: arg-pushing reqs -mno-accumulate-outgoing-args

gcc.target/i386/pr95126-m32-[34].c expect push instructions that are
only present with -mno-accumulate-outgoing-args, so make that option
explicit rather than dependent on tuning.

for  gcc/testsuite/ChangeLog

* gcc.target/i386/pr95126-m32-3.c: Add
-mno-accumulate-outgoing-args.
* gcc.target/i386/pr95126-m32-4.c: Likewise.

10 months agolibstdc++: bvector: undef always_inline macro
Alexandre Oliva [Wed, 15 Nov 2023 01:15:29 +0000 (22:15 -0300)]
libstdc++: bvector: undef always_inline macro

It's customary to undefine temporary internal macros at the end of the
header that defines them, even such widely-usable ones as
_GLIBCXX_ALWAYS_INLINE, so do so in the header where the define was
recently introduced.

for  libstdc++-v3/ChangeLog

* include/bits/stl_bvector.h (_GLIBCXX_ALWAYS_INLINE): Undef.

10 months agojson.cc: use SELFTEST_LOCATION in selftests
David Malcolm [Wed, 15 Nov 2023 00:48:48 +0000 (19:48 -0500)]
json.cc: use SELFTEST_LOCATION in selftests

gcc/ChangeLog:
* json.cc (selftest::assert_print_eq): Add "loc" param and use
ASSERT_STREQ_AT.
(ASSERT_PRINT_EQ): New macro.
(selftest::test_writing_objects): Use ASSERT_PRINT_EQ to capture
source location of assertion.
(selftest::test_writing_arrays): Likewise.
(selftest::test_writing_float_numbers): Likewise.
(selftest::test_writing_integer_numbers): Likewise.
(selftest::test_writing_strings): Likewise.
(selftest::test_writing_literals): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agoDaily bump.
GCC Administrator [Wed, 15 Nov 2023 00:16:41 +0000 (00:16 +0000)]
Daily bump.

10 months agoc-family: Let libcpp know when the compilation is for a PCH [PR9471]
Lewis Hyatt [Fri, 10 Nov 2023 16:10:18 +0000 (11:10 -0500)]
c-family: Let libcpp know when the compilation is for a PCH [PR9471]

libcpp will generate diagnostics when it encounters things in the main file
that only belong in a header file, such as `#pragma once' or `#pragma GCC
system_header'. But sometimes the main file is a header file that is just
being compiled separately, e.g. to produce a C++ module or a PCH, in which
case such diagnostics should be suppressed. libcpp already has an interface
to request that, so make use of it in the C frontends to prevent libcpp from
issuing unwanted diagnostics when compiling a PCH.

gcc/c-family/ChangeLog:

PR pch/9471
PR pch/47857
* c-opts.cc (c_common_post_options): Set cpp_opts->main_search
so libcpp knows it is compiling a header file separately.

gcc/testsuite/ChangeLog:

PR pch/9471
PR pch/47857
* g++.dg/pch/main-file-warnings.C: New test.
* g++.dg/pch/main-file-warnings.Hs: New test.
* gcc.dg/pch/main-file-warnings.c: New test.
* gcc.dg/pch/main-file-warnings.hs: New test.

10 months agolibstdc++: Improve operator-(weekday x, weekday y)
Cassio Neri [Tue, 14 Nov 2023 00:27:39 +0000 (00:27 +0000)]
libstdc++: Improve operator-(weekday x, weekday y)

The current implementation calls __detail::__modulo which is relatively
expensive.

A better implementation is possible if we assume that x.ok() && y.ok() == true,
so that n = x.c_encoding() - y.c_encoding() is in [-6, 6]. In this case, it
suffices to return n >= 0 ? n : n + 7.

The above is allowed by [time.cal.wd.nonmembers]/5: the returned value is
unspecified when x.ok() || y.ok() == false.

The assembly emitted for x86-64 and ARM can be seen in:
https://godbolt.org/z/nMdc5vv9n.

libstdc++-v3/ChangeLog:

* include/std/chrono (operator-(const weekday&, const weekday&)):
Optimize.

10 months agolibstdc++: Fix UB in weekday::weekday(sys_days) and add test
Cassio Neri [Sun, 12 Nov 2023 01:33:52 +0000 (01:33 +0000)]
libstdc++: Fix UB in weekday::weekday(sys_days) and add test

The following has undefined behaviour (signed overflow) [1]:
    weekday max{sys_days{days{numeric_limits<days::rep>::max()}}};

The issue is in this line when __n is very large and __n + 4 overflows:
    return weekday(__n >= -4 ? (__n + 4) % 7 : (__n + 5) % 7 + 6);

In addition to fixing this bug, the new implementation makes the compiler emit
shorter and branchless code for x86-64 and ARM [2].

[1] https://godbolt.org/z/1s5bv7KfT
[2] https://godbolt.org/z/zKsabzrhs

libstdc++-v3/ChangeLog:

* include/std/chrono (weekday::_S_from_days): Fix UB.
* testsuite/std/time/weekday/1.cc: Add test for overflow.

10 months agolibstdc++: Simplify year::is_leap()
Cassio Neri [Sat, 11 Nov 2023 22:59:50 +0000 (22:59 +0000)]
libstdc++: Simplify year::is_leap()

The current implementation returns
    (_M_y & (__is_multiple_of_100 ? 15 : 3)) == 0;
where __is_multiple_of_100 is calculated using an obfuscated algorithm which
saves one ror instruction when compared to _M_y % 100 == 0 [1].

In leap years calculation, it's correct to replace the divisibility check by
100 with the one by 25. It turns out that _M_y % 25 == 0 also saves the ror
instruction [2]. Therefore, the obfuscation is not required.

[1] https://godbolt.org/z/5PaEv6a6b
[2] https://godbolt.org/z/55G8rn77e

libstdc++-v3/ChangeLog:

* include/std/chrono (year::is_leap): Clear code.

10 months agolibstdc++: Remove unnecessary "& 1" from year_month_day_last::day()
Cassio Neri [Sat, 11 Nov 2023 16:44:58 +0000 (16:44 +0000)]
libstdc++: Remove unnecessary "& 1" from year_month_day_last::day()

When year_month_day_last::day() was implemented, Dr. Matthias Kretz realised
that the operation "& 1" wasn't necessary but we did not patch it at that
time. This patch removes the unnecessary operation.

libstdc++-v3/ChangeLog:

* include/std/chrono (year_month_day_last::day): Remove &1.

10 months agolibstdc++: Fix <charconv> uses of signed types with <bit> functions
Jonathan Wakely [Tue, 14 Nov 2023 10:56:57 +0000 (10:56 +0000)]
libstdc++: Fix <charconv> uses of signed types with <bit> functions

In <charconv> we pass the int __base parameter to our internal versions
of <bit> functions, __bit_width and __countr_zero. Those functions are
only defined for unsigned types, so we need to convert the base to
unsigned. The base must be in the range [2,36] so we can mask off the
low bits and then convert that to unsigned, so that we don't need to
care about negative values becoming large unsigned values.

libstdc++-v3/ChangeLog:

* include/std/charconv (__from_chars_pow2_base): Convert base to
unsigned for call to __countr_zero.
(__from_chars_alnum): Likewise for call to __bit_width.

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