]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
10 months agolibstdc++: Populate std::time_get::get's %c format for C locale
Jonathan Wakely [Tue, 24 Sep 2024 22:20:56 +0000 (23:20 +0100)] 
libstdc++: Populate std::time_get::get's %c format for C locale

We were using the empty string "" for D_T_FMT and ERA_D_T_FMT in the C
locale, instead of "%a %b %e %T %Y" as the C standard requires. Set it
correctly for each locale implementation that defines time_members.cc.

We can also explicitly set the _M_era_xxx pointers to the same values as
the corresponding _M_xxx ones, rather than setting them to point to
identical string literals. This doesn't rely on the compiler merging
string literals, and makes it more explicit that they're the same in the
C locale.

libstdc++-v3/ChangeLog:

* config/locale/dragonfly/time_members.cc
(__timepunct<char>::_M_initialize_timepunc)
(__timepunct<wchar_t>::_M_initialize_timepunc): Set
_M_date_time_format for C locale. Set %Ex formats to the same
values as the %x formats.
* config/locale/generic/time_members.cc: Likewise.
* config/locale/gnu/time_members.cc: Likewise.
* testsuite/22_locale/time_get/get/char/5.cc: New test.
* testsuite/22_locale/time_get/get/wchar_t/5.cc: New test.

10 months agolibstdc++: Fix rounding in chrono::parse
Jonathan Wakely [Fri, 6 Sep 2024 20:41:47 +0000 (21:41 +0100)] 
libstdc++: Fix rounding in chrono::parse

I noticed that chrono::parse was using duration_cast and time_point_cast
to convert the parsed value to the result. Those functions truncate
towards zero, which is not generally what you want. Especially for
negative times before the epoch, where truncating towards zero rounds
"up" towards the next duration/time_point. Using chrono::round is
typically better, as that rounds to nearest.

However, while testing the fix I realised that rounding to the nearest
can give surprising results in some cases. For example if we parse a
chrono::sys_days using chrono::parse("F %T", "2024-09-22 18:34:56", tp)
then we will round up to the next day, i.e. sys_days(2024y/09/23). That
seems surprising, and I think 2024-09-22 is what most users would
expect.

This change attempts to provide a hybrid rounding heuristic where we use
chrono::round for the general case, but when the result has a period
that is one of minutes, hours, days, weeks, or years then we truncate
towards negative infinity using chrono::floor. This means that we
truncate "2024-09-22 18:34:56" to the start of the current
minute/hour/day/week/year, instead of rounding up to 2024-09-23, or to
18:35, or 17:00. For a period of months chrono::round is used, because
the months duration is defined as a twelfth of a year, which is not
actually the length of any calendar month. We don't want to truncate to
a whole number of "months" if that can actually go from e.g. 2023-03-01
to 2023-01-31, because February is shorter than chrono::months(1).

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__detail::__use_floor): New
function.
(__detail::__round): New function.
(from_stream): Use __detail::__round.
* testsuite/std/time/clock/file/io.cc: Check for expected
rounding in parse.
* testsuite/std/time/clock/gps/io.cc: Likewise.

10 months agolibstdc++: Fix -Wlong-long warning in <bits/postypes.h>
Jonathan Wakely [Tue, 1 Oct 2024 09:43:43 +0000 (10:43 +0100)] 
libstdc++: Fix -Wlong-long warning in <bits/postypes.h>

For 32-bit targets __INT64_TYPE__ expands to long long, which gives a
pedwarn for C++98 mode, causing:

FAIL: 17_intro/headers/c++1998/all_pedantic_errors.cc  -std=gnu++98 (test for excess errors)
Excess errors:
.../bits/postypes.h:64: error: ISO C++ 1998 does not support 'long long' [-Wlong-long]

libstdc++-v3/ChangeLog:

* include/bits/postypes.h: Fix -Wlong-long warning.

10 months agotestsuite/116660 - adjust testcases unexpectedly failing on 32bit sparc
Richard Biener [Wed, 2 Oct 2024 09:27:09 +0000 (11:27 +0200)] 
testsuite/116660 - adjust testcases unexpectedly failing on 32bit sparc

Both testcases miss some effective target requires.

PR testsuite/116660
* gcc.dg/vect/no-scevccp-outer-12.c: Add vect_pack_trunc.
* gcc.dg/vect/vect-multitypes-6.c: Add vect_char_add, remove
explicit 32bit sparc XFAIL.

10 months agotree-optimization/116566 - single lane SLP for VLA inductions
Richard Biener [Mon, 30 Sep 2024 15:06:24 +0000 (17:06 +0200)] 
tree-optimization/116566 - single lane SLP for VLA inductions

The following adds SLP support for vectorizing single-lane inductions
with variable length vectors.

PR tree-optimization/116566
* tree-vect-loop.cc (vectorizable_induction): Handle single-lane
SLP for VLA vectors.

* gcc.dg/tree-ssa/reassoc-46.c: When using partial vectors
the dump-scan doesn't look for the required .COND_ADD so
skip for partial vectors.

10 months agodoc: Drop h8300-hms reference to binaries downloads
Gerald Pfeifer [Wed, 2 Oct 2024 09:10:33 +0000 (17:10 +0800)] 
doc: Drop h8300-hms reference to binaries downloads

gcc:
PR target/69374
* doc/install.texi (Specific) <h8300-hms>: Drop obsolete
reference to binaries download docs.

10 months agolibcpp: Implement clang -Wheader-guard warning [PR96842]
Jakub Jelinek [Wed, 2 Oct 2024 08:53:35 +0000 (10:53 +0200)] 
libcpp: Implement clang -Wheader-guard warning [PR96842]

The following patch implements the clang -Wheader-guard warning, which warns
if a valid multiple inclusion header guard's #ifndef/#if !defined directive
is immediately (no other non-line directives nor other (non-comment)
tokens in between) followed by #define directive for some different macro,
which in get_suggestion rules is close enough to the actual header guard
macro (i.e. likely misspelling), the #define is object-like with empty
definition (I've followed what clang implements) and the macro isn't defined
later on (at least not on the final #endif at the end of a header).

In this case it emits a warning, so that
  #ifndef STDIO_H
  #define STDOI_H
  ...
  #endif
or similar misspellings can be caught.

clang enables this warning by default, but I've put it into -Wall instead
as it still seems to be a style warning, nothing more severe; if a header
doesn't survive multiple inclusion because of the misspelling, users will
get different diagnostics.

2024-10-02  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/96842
libcpp/
* include/cpplib.h (struct cpp_options): Add warn_header_guard member.
(enum cpp_warning_reason): Add CPP_W_HEADER_GUARD enumerator.
* internal.h (struct cpp_reader): Add mi_def_cmacro, mi_loc and
mi_def_loc members.
(_cpp_defined_macro_p): Constify type pointed by argument type.
Formatting fix.
* init.cc (cpp_create_reader): Clear
CPP_OPTION (pfile, warn_header_guard).
* directives.cc (struct if_stack): Add def_loc and mi_def_cmacro
members.
(DIRECTIVE_TABLE): Add IF_COND flag to define.
(do_define): Set ifs->mi_def_cmacro on a define immediately following
#ifndef directive for the guard.  Clear pfile->mi_valid.  Formatting
fix.
(do_endif): Copy over pfile->mi_def_cmacro and pfile->mi_def_loc
if ifs->mi_def_cmacro is set and pfile->mi_cmacro isn't a defined
macro.
(push_conditional): Clear mi_def_cmacro and mi_def_loc members.
* files.cc (_cpp_pop_file_buffer): Emit -Wheader-guard diagnostics.
gcc/
* doc/invoke.texi (Wheader-guard): Document.
gcc/c-family/
* c.opt (Wheader-guard): New option.
* c.opt.urls: Regenerated.
* c-ppoutput.cc (init_pp_output): Initialize also cb->get_suggestion.
gcc/testsuite/
* c-c++-common/cpp/Wheader-guard-1.c: New test.
* c-c++-common/cpp/Wheader-guard-1-1.h: New test.
* c-c++-common/cpp/Wheader-guard-1-2.h: New test.
* c-c++-common/cpp/Wheader-guard-1-3.h: New test.
* c-c++-common/cpp/Wheader-guard-1-4.h: New test.
* c-c++-common/cpp/Wheader-guard-1-5.h: New test.
* c-c++-common/cpp/Wheader-guard-1-6.h: New test.
* c-c++-common/cpp/Wheader-guard-1-7.h: New test.
* c-c++-common/cpp/Wheader-guard-1-8.h: New test.
* c-c++-common/cpp/Wheader-guard-1-9.h: New test.
* c-c++-common/cpp/Wheader-guard-1-10.h: New test.
* c-c++-common/cpp/Wheader-guard-1-11.h: New test.
* c-c++-common/cpp/Wheader-guard-1-12.h: New test.
* c-c++-common/cpp/Wheader-guard-2.c: New test.
* c-c++-common/cpp/Wheader-guard-2.h: New test.
* c-c++-common/cpp/Wheader-guard-3.c: New test.
* c-c++-common/cpp/Wheader-guard-3.h: New test.

10 months agoopts: Fix up regenerate-opt-urls dependencies
Jakub Jelinek [Wed, 2 Oct 2024 08:14:50 +0000 (10:14 +0200)] 
opts: Fix up regenerate-opt-urls dependencies

It seems that we currently require
1) enabling at least c,c++,fortran,d in --enable-languages
2) first doing make html
before one can successfully regenerate-opt-urls, otherwise without 2)
one gets
make regenerate-opt-urls
make: *** No rule to make target '/home/jakub/src/gcc/obj12x/gcc/HTML/gcc-15.0.0/gcc/Option-Index.html', needed by 'regenerate-opt-urls'.  Stop.
or say if not configuring d after make html one still gets
make regenerate-opt-urls
make: *** No rule to make target '/home/jakub/src/gcc/obj12x/gcc/HTML/gcc-15.0.0/gdc/Option-Index.html', needed by 'regenerate-opt-urls'.  Stop.

Now, I believe neither 1) nor 2) is really necessary.
The regenerate-opt-urls goal has dependency on 3 Option-Index.html files,
but those files don't have dependencies how to generate them.
make html has dependency on $(HTMLS_BUILD) which adds
$(build_htmldir)/gcc/index.html and lang.html among other things, where
the former actually builds not just index.html but also Option-Index.html
and tons of other files, and lang.html is filled in by configure depending
on configured languages, so sometimes will include gfortran.html and
sometimes d.html.

The following patch adds dependencies of the Option-Index.html on their
corresponding index.html files and that is all that seems to be needed,
make regenerate-opt-urls then works even without prior make html and
even if just a subset of c/c++, fortran and d is enabled.

2024-10-02  Jakub Jelinek  <jakub@redhat.com>

* Makefile.in ($(OPT_URLS_HTML_DEPS)): Add dependencies of the
Option-Index.html files on the corresponding index.html files.
Don't mention the requirement that all languages that have their own
HTML manuals to be enabled.

10 months agobackprop: Fix deleting of a phi node [PR116922]
Andrew Pinski [Tue, 1 Oct 2024 21:48:19 +0000 (14:48 -0700)] 
backprop: Fix deleting of a phi node [PR116922]

The problem here is remove_unused_var is called on a name that is
defined by a phi node but it deletes it like removing a normal statement.
remove_phi_node should be called rather than gsi_remove for phinodes.

Note there is a possibility of using simple_dce_from_worklist instead
but that is for another day.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116922

gcc/ChangeLog:

* gimple-ssa-backprop.cc (remove_unused_var): Handle phi
nodes correctly.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116922.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
10 months agoFix gcc.dg/pr116905.c
Richard Biener [Wed, 2 Oct 2024 06:49:06 +0000 (08:49 +0200)] 
Fix gcc.dg/pr116905.c

I missed { dg-add-options float16 }.

* gcc.dg/pr116905.c: Add float16 options.

10 months agotestsuite/116654 - adjust gcc.target/powerpc/p9-vec-length-full-8.c
Richard Biener [Wed, 2 Oct 2024 06:41:30 +0000 (08:41 +0200)] 
testsuite/116654 - adjust gcc.target/powerpc/p9-vec-length-full-8.c

gcc.target/powerpc/p9-vec-length-full-8.c was expecting all loops to
use -with-len fully masked vectorization to avoid epilogues because
the loops needed peeling for gaps.  With SLP we have improved things
here and the loops using V2D[IF]mode no longer need peeling for gaps
since the target can compose those vectors from two scalars and
in turn we generate better code and not need an epilogue either
(the iteration count divides by the VF).

PR testsuite/116654
* gcc.target/powerpc/p9-vec-length-full-8.c: Adjust.

10 months agotestsuite/116654 - adjust gcc.dg/vect/costmodel/ppc/costmodel-slp-12.c
Richard Biener [Wed, 2 Oct 2024 06:25:00 +0000 (08:25 +0200)] 
testsuite/116654 - adjust gcc.dg/vect/costmodel/ppc/costmodel-slp-12.c

As we now SLP non-grouped stores we have to adjust the expected
count.

PR testsuite/116654
* gcc.dg/vect/costmodel/ppc/costmodel-slp-12.c: Adjust.

10 months agotree-optimization/116654 - missed dr_explicit_realign[_optimized] with SLP
Richard Biener [Tue, 1 Oct 2024 13:17:18 +0000 (15:17 +0200)] 
tree-optimization/116654 - missed dr_explicit_realign[_optimized] with SLP

With single-lane SLP we miss to use the power realing loads causing
some testsuite FAILs.  r14-2430-g4736ddd11874fe exempted SLP of
non-grouped accesses because that could have been only splats
where the scheme isn't used anyway, but now with single-lane SLP
it can be contiguous accesses.

PR tree-optimization/116654
* tree-vect-data-refs.cc (vect_supportable_dr_alignment):
Treat non-grouped accesses like non-SLP.

10 months agoRISC-V: Add testcases for form 2 of scalar signed SAT_SUB
Pan Li [Thu, 26 Sep 2024 12:21:10 +0000 (20:21 +0800)] 
RISC-V: Add testcases for form 2 of scalar signed SAT_SUB

Form 2:
  #define DEF_SAT_S_SUB_FMT_2(T, UT, MIN, MAX) \
  T __attribute__((noinline))                  \
  sat_s_sub_##T##_fmt_1 (T x, T y)             \
  {                                            \
    T minus = (UT)x - (UT)y;                   \
    if ((x ^ y) >= 0 || (minus ^ x) >= 0)      \
      return minus;                            \
    return x < 0 ? MIN : MAX;                  \
  }

DEF_SAT_S_SUB_FMT_2(int8_t, uint8_t, INT8_MIN, INT8_MAX)

The below test are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat_s_sub-2-i16.c: New test.
* gcc.target/riscv/sat_s_sub-2-i32.c: New test.
* gcc.target/riscv/sat_s_sub-2-i64.c: New test.
* gcc.target/riscv/sat_s_sub-2-i8.c: New test.
* gcc.target/riscv/sat_s_sub-run-2-i16.c: New test.
* gcc.target/riscv/sat_s_sub-run-2-i32.c: New test.
* gcc.target/riscv/sat_s_sub-run-2-i64.c: New test.
* gcc.target/riscv/sat_s_sub-run-2-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoMatch: Support form 2 for scalar signed integer SAT_SUB
Pan Li [Thu, 26 Sep 2024 12:12:33 +0000 (20:12 +0800)] 
Match: Support form 2 for scalar signed integer SAT_SUB

This patch would like to support the form 2 of the scalar signed
integer SAT_SUB.  Aka below example:

Form 2:
  #define DEF_SAT_S_SUB_FMT_2(T, UT, MIN, MAX) \
  T __attribute__((noinline))                  \
  sat_s_sub_##T##_fmt_1 (T x, T y)             \
  {                                            \
    T minus = (UT)x - (UT)y;                   \
    if ((x ^ y) >= 0 || (minus ^ x) >= 0)      \
      return minus;                            \
    return x < 0 ? MIN : MAX;                  \
  }

DEF_SAT_S_SUB_FMT_2(int8_t, uint8_t, INT8_MIN, INT8_MAX)

Before this patch:
   4   │ __attribute__((noinline))
   5   │ int8_t sat_s_sub_int8_t_fmt_2 (int8_t x, int8_t y)
   6   │ {
   7   │   int8_t minus;
   8   │   unsigned char x.0_1;
   9   │   unsigned char y.1_2;
  10   │   unsigned char _3;
  11   │   signed char _4;
  12   │   signed char _5;
  13   │   int8_t _6;
  14   │   _Bool _11;
  15   │   signed char _12;
  16   │   signed char _13;
  17   │   signed char _14;
  18   │   signed char _15;
  19   │
  20   │ ;;   basic block 2, loop depth 0
  21   │ ;;    pred:       ENTRY
  22   │   x.0_1 = (unsigned char) x_7(D);
  23   │   y.1_2 = (unsigned char) y_8(D);
  24   │   _3 = x.0_1 - y.1_2;
  25   │   minus_9 = (int8_t) _3;
  26   │   _4 = x_7(D) ^ y_8(D);
  27   │   _5 = x_7(D) ^ minus_9;
  28   │   _15 = _4 & _5;
  29   │   if (_15 >= 0)
  30   │     goto <bb 4>; [42.57%]
  31   │   else
  32   │     goto <bb 3>; [57.43%]
  33   │ ;;    succ:       4
  34   │ ;;                3
  35   │
  36   │ ;;   basic block 3, loop depth 0
  37   │ ;;    pred:       2
  38   │   _11 = x_7(D) < 0;
  39   │   _12 = (signed char) _11;
  40   │   _13 = -_12;
  41   │   _14 = _13 ^ 127;
  42   │ ;;    succ:       4
  43   │
  44   │ ;;   basic block 4, loop depth 0
  45   │ ;;    pred:       2
  46   │ ;;                3
  47   │   # _6 = PHI <minus_9(2), _14(3)>
  48   │   return _6;
  49   │ ;;    succ:       EXIT
  50   │
  51   │ }

After this patch:
   4   │ __attribute__((noinline))
   5   │ int8_t sat_s_sub_int8_t_fmt_2 (int8_t x, int8_t y)
   6   │ {
   7   │   int8_t _6;
   8   │
   9   │ ;;   basic block 2, loop depth 0
  10   │ ;;    pred:       ENTRY
  11   │   _6 = .SAT_SUB (x_7(D), y_8(D)); [tail call]
  12   │   return _6;
  13   │ ;;    succ:       EXIT
  14   │
  15   │ }

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Add case 2 matching pattern for signed SAT_SUB.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoDaily bump.
GCC Administrator [Wed, 2 Oct 2024 00:17:48 +0000 (00:17 +0000)] 
Daily bump.

10 months agoc++: don't advertise C++20 concepts in C++14
Jason Merrill [Tue, 1 Oct 2024 14:58:35 +0000 (10:58 -0400)] 
c++: don't advertise C++20 concepts in C++14

There have been various problems with -std=c++14 -fconcepts; let's stop
defining the feature test macro in that case.

gcc/c-family/ChangeLog:

* c-cppbuiltin.cc (c_cpp_builtins): Don't define __cpp_concepts
before C++17.

10 months agoAVR: avr.cc - Drop a superfluous sub-condition in avr_out_compare.
Georg-Johann Lay [Tue, 1 Oct 2024 18:36:22 +0000 (20:36 +0200)] 
AVR: avr.cc - Drop a superfluous sub-condition in avr_out_compare.

In avr.cc::avr_out_compare() there is this condition:

  if (n_bytes == 4
      && eqne_p
      && AVR_HAVE_ADIW
      && REGNO (xreg) >= REG_22
      && (xval == const0_rtx
  || (IN_RANGE (avr_int16 (xval, 2), 0, 63)
      && eqne_p
      && reg_unused_after (insn, xreg))))

where the 2nd sub-expression "&& eqne_p" is superfluous.

gcc/
* config/avr/avr.cc (avr_out_compare): Drop superfluous sub-condition.

10 months agoAVR: avr-passes.cc - Fix a build warning.
Georg-Johann Lay [Tue, 1 Oct 2024 18:25:26 +0000 (20:25 +0200)] 
AVR: avr-passes.cc - Fix a build warning.

gcc/
* config/avr/avr-passes.cc (avr_split_fake_addressing_move): Fix
a build warning.

10 months agoaarch64: Introduce new unspecs for smax/smin
Saurabh Jha [Mon, 30 Sep 2024 10:37:16 +0000 (10:37 +0000)] 
aarch64: Introduce new unspecs for smax/smin

Introduce two new unspecs, UNSPEC_COND_SMAX and UNSPEC_COND_SMIN,
corresponding to rtl operators smax and smin. UNSPEC_COND_SMAX is used
to generate fmaxnm instruction and UNSPEC_COND_SMIN is used to generate
fminnm instruction.

With these new unspecs, we can generate SVE2 max/min instructions using
existing generic unpredicated and predicated instruction patterns that
use optab attribute. Thus, we have removed specialised instruction
patterns for max/min instructions that were using
SVE_COND_FP_MAXMIN_PUBLIC iterator.

No new test cases as the existing test cases should be enough to test
this refactoring.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md
(<fmaxmin><mode>3): Remove this instruction pattern.
(cond_<fmaxmin><mode>): Remove this instruction pattern.
* config/aarch64/iterators.md: New unspecs and changes to
iterators and attrs to use the new unspecs

10 months agoImplement MAXVAL and MINVAL for UNSIGNED.
Thomas Koenig [Sun, 29 Sep 2024 14:52:51 +0000 (16:52 +0200)] 
Implement MAXVAL and MINVAL for UNSIGNED.

gcc/fortran/ChangeLog:

* check.cc (int_or_real_or_char_or_unsigned_check_f2003): New function.
(gfc_check_minval_maxval): Use it.
* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxval): Handle
initial values for UNSIGNED.
* gfortran.texi: Document MINVAL and MAXVAL for unsigned.

libgfortran/ChangeLog:

* Makefile.am: Add minval and maxval files.
* Makefile.in: Regenerated.
* gfortran.map: Add new functions.
* generated/maxval_m1.c: New file.
* generated/maxval_m16.c: New file.
* generated/maxval_m2.c: New file.
* generated/maxval_m4.c: New file.
* generated/maxval_m8.c: New file.
* generated/minval_m1.c: New file.
* generated/minval_m16.c: New file.
* generated/minval_m2.c: New file.
* generated/minval_m4.c: New file.
* generated/minval_m8.c: New file.

gcc/testsuite/ChangeLog:

* gfortran.dg/unsigned_34.f90: New test.

10 months agoFix wrong code out of NRV + RSO + inlining
Eric Botcazou [Tue, 1 Oct 2024 15:54:00 +0000 (17:54 +0200)] 
Fix wrong code out of NRV + RSO + inlining

The testcase is miscompiled with -O -flto beccause the three optimizations
NRV + RSO + inlining are applied to the same call: when the LHS of the call
is marked write-only before inlining, it will keep the mark after inlining
although it may be read in GIMPLE from that point on.

The fix is to apply the removal of the store, that would have been applied
later if the call was not inlined, right before inlining, which will prevent
the problematic references to the LHS from being generated during inlining.

gcc/
* tree-inline.cc (expand_call_inline): Remove the store to the
return slot if it is a global variable that is only written to.

gcc/testsuite/
* gnat.dg/lto28.adb: New test.
* gnat.dg/lto28_pkg1.ads: New helper.
* gnat.dg/lto28_pkg2.ads: Likewise.
* gnat.dg/lto28_pkg2.adb: Likewise.
* gnat.dg/lto28_pkg3.ads: Likewise.

10 months ago[PATCH] RISC-V/libgcc: Fix incorrect and missing .cfi_offset for __riscv_save_[0...
Tsung Chun Lin [Tue, 1 Oct 2024 15:10:29 +0000 (09:10 -0600)] 
[PATCH] RISC-V/libgcc: Fix incorrect and missing .cfi_offset for __riscv_save_[0-3] on RV32.

0001-RISC-V-libgcc-Fix-incorrect-and-missing-.cfi_offset-.patch

From 06a370a0a2329dd4da0ffcab7c35ea7df2353baf Mon Sep 17 00:00:00 2001
From: Jim Lin <jim@andestech.com>
Date: Tue, 1 Oct 2024 14:42:56 +0800
Subject: [PATCH] RISC-V/libgcc: Fix incorrect and missing .cfi_offset for
 __riscv_save_[0-3] on RV32.

libgcc/ChangeLog:

* config/riscv/save-restore.S: Fix .cfi_offset for
__riscv_save_[0-3] on RV32.

10 months agoc++: introduce __builtin_is_virtual_base_of
Giuseppe D'Angelo [Tue, 1 Oct 2024 11:31:00 +0000 (13:31 +0200)] 
c++: introduce __builtin_is_virtual_base_of

P2985R0 (C++26) introduces std::is_virtual_base_of; this is the compiler
builtin that will back up the library trait (which strictly requires
compiler support).

The name has been chosen to match LLVM/MSVC's, as per the discussion
here:

https://github.com/llvm/llvm-project/issues/98310

The actual user-facing type trait in libstdc++ will be added later.

gcc/cp/ChangeLog:

* constraint.cc (diagnose_trait_expr): New diagnostic.
* cp-trait.def (IS_VIRTUAL_BASE_OF): New builtin.
* cp-tree.h (enum base_access_flags): Add a new flag to be
able to request a search for a virtual base class.
* cxx-pretty-print.cc (pp_cxx_userdef_literal): Update the
list of GNU extensions to the grammar.
* search.cc (struct lookup_base_data_s): Add a field to
request searching for a virtual base class.
(dfs_lookup_base): Add the ability to look for a virtual
base class.
(lookup_base): Forward the flag to dfs_lookup_base.
* semantics.cc (trait_expr_value): Implement the builtin
by calling lookup_base with the new flag.
(finish_trait_expr): Handle the new builtin.

gcc/ChangeLog:

* doc/extend.texi: Document the new
__builtin_is_virtual_base_of builtin; amend the docs for
__is_base_of.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_virtual_base_of.C: New test.
* g++.dg/ext/is_virtual_base_of_diagnostic.C: New test.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agophi-opt: Improve factor heurstic with constants and conversions from bool [PR116890]
Andrew Pinski [Mon, 30 Sep 2024 16:44:44 +0000 (16:44 +0000)] 
phi-opt: Improve factor heurstic with constants and conversions from bool [PR116890]

Take:
```
  if (t_3(D) != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>
  _8 = c_4(D) != 0;
  _9 = (int) _8;

  <bb 4>
  # e_2 = PHI <_9(3), 0(2)>
```

We should factor out the conversion here as that will allow a simplfication to
`(t_3 != 0) & (c_4 != 0)`. Unlike most other types; `a ? b : CST` will simplify
for boolean result type to either `a | b` or `a & b` so allowing this conversion
for all operations will be always profitable.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Note on the phi-opt-7.c testcase change, we are now able to optimize this
and remove the if due to the factoring out now so this is an improvement.

PR tree-optimization/116890

gcc/ChangeLog:

* tree-ssa-phiopt.cc (factor_out_conditional_operation): Conversions
from bool is also should be considered as wanting to happen.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/phi-opt-7.c: Update testcase for no ifs left.
* gcc.dg/tree-ssa/phi-opt-42.c: New test.
* gcc.dg/tree-ssa/phi-opt-43.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
10 months agomodula2: Add FindIndice to library module gm2-libs/Indexing
Gaius Mulley [Tue, 1 Oct 2024 14:06:54 +0000 (15:06 +0100)] 
modula2: Add FindIndice to library module gm2-libs/Indexing

This patch introduces the procedure function FindIndice to library
module Indexing.

gcc/m2/ChangeLog:

* gm2-libs/Indexing.def (FindIndice): New procedure
function.
* gm2-libs/Indexing.mod (FindIndice): Implement new
procedure function.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
10 months agoPR modula2/116918 -fswig correct syntax
Gaius Mulley [Tue, 1 Oct 2024 13:26:31 +0000 (14:26 +0100)] 
PR modula2/116918 -fswig correct syntax

This patch fixes the syntax for the generated swig interface file.
The % characters in fprintf require escaping.

gcc/m2/ChangeLog:

PR modula2/116918
* gm2-compiler/M2Swig.mod (AnnotateProcedure): Capitalize
the generated comment, split comment into multiple lines and
terminate the comment with ".  */".
(DoCheckUnbounded): Escape the % character with %%.
(DoWriteFile): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
10 months agoaarch64: Add fp8 scalar types
Claudio Bantaloukas [Tue, 1 Oct 2024 12:45:11 +0000 (12:45 +0000)] 
aarch64: Add fp8 scalar types

The ACLE defines a new scalar type, __mfp8. This is an opaque 8bit types that
can only be used by fp8 intrinsics. Additionally, the mfloat8_t type is made
available in arm_neon.h and arm_sve.h as an alias of the same.

This implementation uses an unsigned INTEGER_TYPE, with precision 8 to
represent __mfp8. Conversions to int and other types are disabled via the
TARGET_INVALID_CONVERSION hook.
Additionally, operations that are typically available to integer types are
disabled via TARGET_INVALID_UNARY_OP and TARGET_INVALID_BINARY_OP hooks.

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc (aarch64_mfp8_type_node): Add node
for __mfp8 type.
(aarch64_mfp8_ptr_type_node): Add node for __mfp8 pointer type.
(aarch64_init_fp8_types): New function to initialise fp8 types and
register with language backends.
* config/aarch64/aarch64.cc (aarch64_mangle_type): Add ABI mangling for
new type.
(aarch64_invalid_conversion): Add function implementing
TARGET_INVALID_CONVERSION hook that blocks conversion to and from the
__mfp8 type.
(aarch64_invalid_unary_op): Add function implementing TARGET_UNARY_OP
hook that blocks operations on __mfp8 other than &.
(aarch64_invalid_binary_op): Extend TARGET_BINARY_OP hook to disallow
operations on __mfp8 type.
(TARGET_INVALID_CONVERSION): Add define.
(TARGET_INVALID_UNARY_OP): Likewise.
* config/aarch64/aarch64.h (aarch64_mfp8_type_node): Add node for __mfp8
type.
(aarch64_mfp8_ptr_type_node): Add node for __mfp8 pointer type.
* config/aarch64/arm_private_fp8.h (mfloat8_t): Add typedef.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/fp8_mangling.C: New tests exercising mangling.
* g++.target/aarch64/fp8_scalar_typecheck_2.C: New tests in C++.
* gcc.target/aarch64/fp8_scalar_1.c: New tests in C.
* gcc.target/aarch64/fp8_scalar_typecheck_1.c: Likewise.

10 months agotree-optimization/116902 - vectorizer load hosting breaks UID order #2
Richard Biener [Tue, 1 Oct 2024 11:35:58 +0000 (13:35 +0200)] 
tree-optimization/116902 - vectorizer load hosting breaks UID order #2

This is another case of load hoisting breaking UID order in the
preheader, this time between two hoistings.  The easiest way out is
to do what we do for the main stmt - copy instead of move.

PR tree-optimization/116902
PR tree-optimization/116842
* tree-vect-stmts.cc (sort_after_uid): Remove again.
(hoist_defs_of_uses): Copy defs instead of hoisting them so
we can zero their UID.
(vectorizable_load): Separate analysis and transform call,
do transform on the stmt copy.

* g++.dg/torture/pr116902.C: New testcase.

10 months agotree-optimization/116905 - ICE with bogus range ops
Richard Biener [Tue, 1 Oct 2024 09:22:17 +0000 (11:22 +0200)] 
tree-optimization/116905 - ICE with bogus range ops

The following avoids querying ranges of vector entities.

PR tree-optimization/116905
* tree-vect-stmts.cc (supportable_indirect_convert_operation):
Fix guard for vect_get_range_info.

* gcc.dg/pr116905.c: New testcase.

10 months agotree-optimization/116906 - unsafe PRE with never executed edges
Richard Biener [Tue, 1 Oct 2024 08:37:16 +0000 (10:37 +0200)] 
tree-optimization/116906 - unsafe PRE with never executed edges

When we're computing ANTIC for PRE we treat edges to not yet visited
blocks as having a maximum ANTIC solution to get at an optimistic
solution in the iteration.  That assumes the edges visted eventually
execute.  This is a wrong assumption that can lead to wrong code
(and not only non-optimality) when possibly trapping expressions
are involved as the testcases in the PR show.  The following mitigates
this by pruning trapping expressions from ANTIC computed when
maximum sets are involved.

PR tree-optimization/116906
* tree-ssa-pre.cc (prune_clobbered_mems): Add clean_traps
argument.
(compute_antic_aux): Direct prune_clobbered_mems to prune
all traps when any MAX solution was involved in the ANTIC
computation.
(compute_partial_antic_aux): Adjust.

* gcc.dg/pr116906-1.c: New testcase.
* gcc.dg/pr116906-2.c: Likewise.

10 months agorange-cache: Fix ranger ICE if number of bbs increases [PR116899]
Jakub Jelinek [Tue, 1 Oct 2024 07:52:20 +0000 (09:52 +0200)] 
range-cache: Fix ranger ICE if number of bbs increases [PR116899]

Ranger cache during initialization reserves number of basic block slots
in the m_workback vector (in an inefficient way by doing create (0)
and safe_grow_cleared (n) and truncate (0) rather than say create (n)
or reserve (n) after create).  The problem is that some passes split bbs and/or
create new basic blocks and so when one is unlucky, the quick_push into that
vector can ICE.

The following patch replaces those 4 quick_push calls with safe_push.

I've also gathered some statistics from compiling 63 gcc sources (picked those
that dependent on gimple-range-cache.h just because I had to rebuild them once
for the instrumentation), and that showed that in 81% of cases nothing has
been pushed into the vector at all (and note, not everything was small, there
were even cases with 10000+ basic blocks), another 18.5% of cases had just 1-4
elements in the vector at most, 0.08% had 5-8 and 19 out of 305386 cases
had at most 9-11 elements, nothing more.  So, IMHO reserving number of basic
block in the vector is a waste of compile time memory and with the safe_push
calls, the patch just initializes the vector to vNULL.

2024-10-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/116899
* gimple-range-cache.cc (ranger_cache::ranger_cache): Set m_workback
to vNULL instead of creating it, growing and then truncating.
(ranger_cache::fill_block_cache): Use safe_push rather than quick_push
on m_workback.
(ranger_cache::range_from_dom): Likewise.

* gcc.dg/bitint-111.c: New test.

10 months agorange-cache: Fix ICE on SSA_NAME with def_stmt not yet in the IL [PR116898]
Jakub Jelinek [Tue, 1 Oct 2024 07:49:49 +0000 (09:49 +0200)] 
range-cache: Fix ICE on SSA_NAME with def_stmt not yet in the IL [PR116898]

Some passes like the bitint lowering queue some statements on edges and only
commit them at the end of the pass.  If they use ranger at the same time,
the ranger might see such SSA_NAMEs and ICE on those.  The following patch
instead just punts on them.

2024-10-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/116898
* gimple-range-cache.cc (ranger_cache::block_range): If a SSA_NAME
with NULL def_bb isn't SSA_NAME_IS_DEFAULT_DEF, return false instead
of failing assertion.  Formatting fix.

* gcc.dg/bitint-110.c: New test.

10 months agoDaily bump.
GCC Administrator [Tue, 1 Oct 2024 00:20:07 +0000 (00:20 +0000)] 
Daily bump.

10 months agolibstdc++-v3: Fix signed-overflow warning for newlib/ctype_base.h, PR116895
Hans-Peter Nilsson [Sun, 29 Sep 2024 03:47:03 +0000 (05:47 +0200)] 
libstdc++-v3: Fix signed-overflow warning for newlib/ctype_base.h, PR116895

There are 100+ regressions when running the g++ testsuite for newlib
targets (probably excepting ARM-based ones) e.g cris-elf after commit
r15-3859-g63a598deb0c9fc "libstdc++: #ifdef out #pragma GCC
system_header", which effectively no longer silences warnings for
gcc-installed system headers.  Some of these regressions are fixed by
r15-3928.  For the remaining ones, there's in g++.log:

FAIL: g++.old-deja/g++.robertl/eb79.C  -std=c++26 (test for excess errors)
Excess errors:
/gccobj/cris-elf/libstdc++-v3/include/cris-elf/bits/ctype_base.h:50:53: \
 warning: overflow in conversion from 'int' to 'std::ctype_base::mask' \
 {aka 'char'} changes value from '151' to '-105' [-Woverflow]

This is because the _B macro in newlib's ctype.h (from where the
"_<letter>" macros come) is bit 7, the sign-bit of 8-bit types:

#define _B 0200

Using it in an int-expression that is then truncated to 8 bits will
"change" the value to negative for a default-signed char.  If this
code was created from scratch, it should have been an unsigned type,
however it's not advisable to change the type of mask as this affects
the API.  The least ugly option seems to be to silence the warning by
explict casts in the initializer, and for consistency, doing it for
all members.

PR libstdc++/116895
* config/os/newlib/ctype_base.h: Avoid signed-overflow warnings by
explicitly casting initializer expressions to mask.

10 months ago[testcase] Fix-absfloat16.c-testcase
Kugan Vivekanandarajah [Mon, 30 Sep 2024 22:49:07 +0000 (08:49 +1000)] 
[testcase] Fix-absfloat16.c-testcase

gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/absfloat16.c: Fix testcase.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
10 months agoc++: concept in default argument [PR109859]
Marek Polacek [Wed, 18 Sep 2024 19:44:31 +0000 (15:44 -0400)] 
c++: concept in default argument [PR109859]

1) We're hitting the assert in cp_parser_placeholder_type_specifier.
It says that if it turns out to be false, we should do error() instead.
Do so, then.

2) lambda-targ8.C should compile fine, though.  The problem was that
local_variables_forbidden_p wasn't cleared when we're about to parse
the optional template-parameter-list for a lambda in a default argument.

PR c++/109859

gcc/cp/ChangeLog:

* parser.cc (cp_parser_lambda_declarator_opt): Temporarily clear
local_variables_forbidden_p.
(cp_parser_placeholder_type_specifier): Turn an assert into an
error.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-defarg3.C: New test.
* g++.dg/cpp2a/lambda-targ8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoFix internal error during inlining after ICF pass
Eric Botcazou [Mon, 30 Sep 2024 19:04:18 +0000 (21:04 +0200)] 
Fix internal error during inlining after ICF pass

The problem is that the ICF pass identifies two functions, one of which has
a static chain while the other does not.  The fix is simply to prevent this
identification from occurring.

gcc/
PR ipa/113996
* ipa-icf.cc (sem_function::get_hash): Hash DECL_STATIC_CHAIN.
(sem_function::equals_wpa): Compare it.
(sem_function::equals_private): Likewise.

gcc/testsuite/
* gnat.dg/lto27.adb: New test.

10 months agodiagnostics: return text buffer from test_show_locus [PR116613]
David Malcolm [Mon, 30 Sep 2024 15:48:30 +0000 (11:48 -0400)] 
diagnostics: return text buffer from test_show_locus [PR116613]

As work towards supporting multiple diagnostic outputs (where each
output has its own pretty_printer), avoid referencing dc.m_printer
throughout the selftests of diagnostic-show-locus.cc.  Instead
have test_diagnostic_context::test_show_locus return the result
buffer, hiding the specifics of which printer is in use in such
test cases.

No functional change intended.

gcc/ChangeLog:
PR other/116613
* diagnostic-show-locus.cc
(selftest::test_diagnostic_show_locus_unknown_location): Move call
to dc.test_show_locus into ASSERT_STREQ, and compare against its
result, rather than explicitly using dc.m_printer.
(selftest::test_one_liner_simple_caret): Likewise.
(selftest::test_one_liner_no_column): Likewise.
(selftest::test_one_liner_caret_and_range): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges): Likewise.
(selftest::test_one_liner_fixit_insert_before): Likewise.
(selftest::test_one_liner_fixit_insert_after): Likewise.
(selftest::test_one_liner_fixit_remove): Likewise.
(selftest::test_one_liner_fixit_replace): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations):
Likewise.
(selftest::test_one_liner_many_fixits_1): Likewise.
(selftest::test_one_liner_many_fixits_2): Likewise.
(selftest::test_one_liner_labels): Likewise.
(selftest::test_one_liner_simple_caret_utf8): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges_utf8):
Likewise.
(selftest::test_one_liner_fixit_insert_before_utf8): Likewise.
(selftest::test_one_liner_fixit_insert_after_utf8): Likewise.
(selftest::test_one_liner_fixit_remove_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations_utf8):
Likewise.
(selftest::test_one_liner_many_fixits_1_utf8): Likewise.
(selftest::test_one_liner_many_fixits_2_utf8): Likewise.
(selftest::test_one_liner_labels_utf8): Likewise.
(selftest::test_one_liner_colorized_utf8): Likewise.
(selftest::test_add_location_if_nearby): Likewise.
(selftest::test_diagnostic_show_locus_fixit_lines): Likewise.
(selftest::test_overlapped_fixit_printing): Likewise.
(selftest::test_overlapped_fixit_printing_utf8): Likewise.
(selftest::test_overlapped_fixit_printing_utf8): Likewise.
(selftest::test_overlapped_fixit_printing_2): Likewise.
(selftest::test_fixit_insert_containing_newline): Likewise.
(selftest::test_fixit_insert_containing_newline_2): Likewise.
(selftest::test_fixit_replace_containing_newline): Likewise.
(selftest::test_fixit_deletion_affecting_newline): Likewise.
(selftest::test_tab_expansion): Likewise.
(selftest::test_escaping_bytes_1): Likewise.
(selftest::test_escaping_bytes_2): Likewise.
(selftest::test_line_numbers_multiline_range): Likewise.
* selftest-diagnostic.cc
(selftest::test_diagnostic_context::test_show_locus): Return the
formatted text of m_printer.
* selftest-diagnostic.h
(selftest::test_diagnostic_context::test_show_locus): Convert
return type from void to const char *.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agodiagnostics: require callers of diagnostic_show_locus to be explicit about the printe...
David Malcolm [Mon, 30 Sep 2024 15:48:30 +0000 (11:48 -0400)] 
diagnostics: require callers of diagnostic_show_locus to be explicit about the printer [PR116613]

As work towards supporting multiple diagnostic outputs (where each
output has its own pretty_printer), update diagnostic_show_locus
so that the pretty_printer must always be explicitly passed in.

No functional change intended.

gcc/c-family/ChangeLog:
PR other/116613
* c-format.cc (selftest::test_type_mismatch_range_labels):
Explicitly pass in dc.m_printer to diagnostic_show_locus.

gcc/ChangeLog:
PR other/116613
* diagnostic-show-locus.cc (diagnostic_context::maybe_show_locus):
Convert param "pp" from * to &.  Drop logic for using the
context's m_printer when the param is null.
* diagnostic.h (diagnostic_context::maybe_show_locus): Convert
param "pp" from * to &.
(diagnostic_show_locus): Drop default "nullptr" value for pp
param.  Assert that it and context are nonnull.  Pass pp by
reference to maybe_show_locus.

gcc/testsuite/ChangeLog:
PR other/116613
* gcc.dg/plugin/expensive_selftests_plugin.c (test_richloc):
Explicitly pass in dc.m_printer to diagnostic_show_locus.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agodiagnostics: isolate diagnostic_context with interface classes [PR116613]
David Malcolm [Mon, 30 Sep 2024 15:48:29 +0000 (11:48 -0400)] 
diagnostics: isolate diagnostic_context with interface classes [PR116613]

As work towards supporting multiple diagnostic outputs (where each
output has its own pretty_printer), avoid passing around
diagnostic_context to the various printing routines, so that we
can be more explicit about which pretty_printer is in use.

Introduce a set of "policy" classes that capture the parts of
diagnostic_context that are needed, and use these rather than
diagnostic_context *.  Pass around pretty_printer & rather than
taking value from context.  Split out the pretty_printer-using code
from class layout into a new class layout_printer, separating the
responsibilities of determining layout when quoting source versus
actually printing the source.

No functional change intended.

gcc/analyzer/ChangeLog:
PR other/116613
* program-point.cc (function_point::print_source_line): Replace
call to diagnostic_show_locus with a call to
diagnostic_source_print_policy::print.

gcc/ChangeLog:
PR other/116613
* diagnostic-format-json.cc (json_from_expanded_location): Replace
call to diagnostic_context::converted_column with call to
diagnostic_column_policy::converted_column.
* diagnostic-format-sarif.cc
(sarif_builder::make_location_object): Replace call to
diagnostic_show_locus with call to
diagnostic_source_print_policy::print.
* diagnostic-format-text.cc (get_location_text): Replace call to
diagnostic_context::get_location_text with call to
diagnostic_column_policy::get_location_text.
(diagnostic_text_output_format::report_current_module): Replace call
to diagnostic_context::converted_column with call to
diagnostic_column_policy::converted_column.
* diagnostic-format-text.h
(diagnostic_text_output_format::diagnostic_output_format):
Initialize m_column_policy.
(diagnostic_text_output_format::get_column_policy): New.
(diagnostic_text_output_format::m_column_policy): New.
* diagnostic-path.cc (class path_print_policy): New.
(event_range::maybe_add_event): Replace diagnostic_context param
with path_print_policy.
(event_range::print): Convert "pp" from * to &.  Convert first
param of start_span callback from diagnostic_context to
diagnostic_location_print_policy.
(path_summary::path_summary): Convert first param from
diagnostic_text_output_format to path_print_policy.  Add
colorize param.  Update for changes to
event_range::maybe_add_event.
(thread_event_printer::print_swimlane_for_event_range): Assert
that pp is non-null.  Update for change to event_range::print.
(diagnostic_text_output_format::print_path): Pass
path_print_policy to path_summary's ctor.
(selftest::test_empty_path): Likewise.
(selftest::test_intraprocedural_path): Likewise.
(selftest::test_interprocedural_path_1): Likewise.
(selftest::test_interprocedural_path_2): Likewise.
(selftest::test_recursion): Likewise.
(selftest::test_control_flow_1): Likewise.
(selftest::test_control_flow_2): Likewise.
(selftest::test_control_flow_3): Likewise.
(selftest::assert_cfg_edge_path_streq): Likewise.
(selftest::test_control_flow_5): Likewise.
(selftest::test_control_flow_6): Likewise.
* diagnostic-show-locus.cc (colorizer::set_range): Update for
change to m_pp.
(colorizer::m_pp): Convert from * to &.
(class layout): Add friend class layout_printer and move various
decls to it.
(layout::m_pp): Drop field.
(layout::m_policy): Rename to...
(layout::m_char_policy): ...this.
(layout::m_colorizer): Move field to class layout_printer.
(layout::m_diagnostic_path_p): Drop field.
(class layout_printer): New class, by refactoring class layout.
(colorizer::colorizer): Convert "pp" param from * to &.
(colorizer::set_named_color): Update for above change.
(colorizer::begin_state): Likewise.
(colorizer::finish_state): Likewise.
(make_policy): Rename to...
(make_char_policy): ...this, and update param from
diagnostic_context to diagnostic_source_print_policy.
(layout::layout): Update param from diagnostic_context to
diagnostic_source_print_policy.  Drop params "diagnostic_kind" and
"pp", moving these and other material to class layout_printer.
(layout::maybe_add_location_range): Update for renamed field.
(layout::print_gap_in_line_numbering): Convert to...
(layout_printer::print_gap_in_line_numbering): ...this.
(layout::calculate_x_offset_display): Update for renamed field.
(layout::print_source_line): Convert to...
(layout_printer::print_source_line): ...this.
(layout::print_leftmost_column): Convert to...
(layout_printer::print_leftmost_column): ...this.
(layout::start_annotation_line): Convert to...
(layout_printer::start_annotation_line): ...this.
(layout::print_annotation_line): Convert to...
(layout_printer::print_annotation_line): ...this.
(layout::print_any_labels): Convert to...
(layout_printer::print_any_labels): ...this.
(layout::print_leading_fixits): Convert to...
(layout_printer::print_leading_fixits): ...this.
(layout::print_trailing_fixits): Convert to...
(layout_printer::print_trailing_fixits): ...this.
(layout::print_newline): Convert to...
(layout_printer::print_newline): ...this.
(layout::get_state_at_point): Make const.
(layout::get_x_bound_for_row): Make const.
(layout::move_to_column): Convert to...
(layout_printer::move_to_column): ...this.
(layout::show_ruler): Convert to...
(layout_printer::show_ruler): ...this.
(layout::print_line): Convert to...
(layout_printer::print_line): ...this.
(layout::print_any_right_to_left_edge_lines): Convert to...
(layout_printer::print_any_right_to_left_edge_lines): ...this.
(layout::print_any_right_to_left_edge_lines): Likewise.
(layout_printer::layout_printer): New.
(layout::update_any_effects): Delete, moving logic to
layout_printer::print.
(gcc_rich_location::add_location_if_nearby): Update param from
diagnostic_context to diagnostic_source_print_policy.  Add
overload taking a diagnostic_context.
(diagnostic_context::maybe_show_locus): Move handling of null
pretty_printer here, from layout ctor.  Convert call to
diagnostic_context::show_locus to
diagnostic_source_print_policy::print.
(diagnostic_source_print_policy::diagnostic_source_print_policy):
New.
(diagnostic_context::show_locus): Convert to...
(diagnostic_source_print_policy::print): ...this.  Convert pp
from * to &.
(layout_printer::print): New, based on material in
diagnostic_context::show_locus.
(selftest::make_char_policy): New.
(selftest::test_display_widths): Update for above changes.
(selftest::test_offset_impl): Likewise.
(selftest::test_layout_x_offset_display_utf8): Likewise.
(selftest::test_layout_x_offset_display_tab): Likewise.
(selftest::test_diagnostic_show_locus_unknown_location): Use
test_diagnostic_context::test_show_locus rather than
diagnostic_show_locus.
(selftest::test_one_liner_no_column): Likewise.
(selftest::test_one_liner_caret_and_range): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges): Likewise.
(selftest::test_one_liner_fixit_insert_before): Likewise.
(selftest::test_one_liner_fixit_insert_after): Likewise.
(selftest::test_one_liner_fixit_remove): Likewise.
(selftest::test_one_liner_fixit_replace): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations):
Likewise.
(selftest::test_one_liner_many_fixits_1): Likewise.
(selftest::test_one_liner_many_fixits_2): Likewise.
(selftest::test_one_liner_labels): Likewise.
(selftest::test_one_liner_simple_caret_utf8): Likewise.
(selftest::test_one_liner_caret_and_range_utf8): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges_utf8):
Likewise.
(selftest::test_one_liner_fixit_insert_before_utf8): Likewise.
(selftest::test_one_liner_fixit_insert_after_utf8): Likewise.
(selftest::test_one_liner_fixit_remove_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations_utf8):
Likewise.
(selftest::test_one_liner_many_fixits_1_utf8): Likewise.
(selftest::test_one_liner_many_fixits_2_utf8): Likewise.
(selftest::test_one_liner_labels_utf8): Likewise.
(selftest::test_one_liner_colorized_utf8): Likewise.
(selftest::test_add_location_if_nearby): Likewise.
(selftest::test_diagnostic_show_locus_fixit_lines): Likewise.
(selftest::test_overlapped_fixit_printing): Likewise.
(selftest::test_overlapped_fixit_printing_utf8): Likewise.
(selftest::test_overlapped_fixit_printing_2): Likewise.
(selftest::test_fixit_insert_containing_newline): Likewise.
(selftest::test_fixit_insert_containing_newline_2): Likewise.
(selftest::test_fixit_replace_containing_newline): Likewise.
(selftest::test_fixit_deletion_affecting_newline): Likewise.
(selftest::test_tab_expansion): Likewise.
(selftest::test_escaping_bytes_1): Likewise.
(selftest::test_escaping_bytes_2): Likewise.
(selftest::test_line_numbers_multiline_range): Likewise.
* diagnostic.cc
(diagnostic_column_policy::diagnostic_column_policy): New.
(diagnostic_context::converted_column): Convert to...
(diagnostic_column_policy::converted_column): ...this.
(diagnostic_context::get_location_text): Convert to...
(diagnostic_column_policy::get_location_text): ...this, adding
"show_column" param.
(diagnostic_location_print_policy::diagnostic_location_print_policy):
New ctors.
(default_diagnostic_start_span_fn): Convert param from
diagnostic_context * to const diagnostic_location_print_policy &.
Add "pp" param.
(selftest::assert_location_text): Update for above changes.
(selftest::test_diagnostic_get_location_text): Rename to...
(selftest::test_get_location_text): ...this.
(selftest::c_diagnostic_cc_tests): Update for renaming.
* diagnostic.h (class diagnostic_location_print_policy): New
forward decl.
(class diagnostic_source_print_policy): New forward decl.
(diagnostic_start_span_fn): Convert first param from
diagnostic_context * to const diagnostic_location_print_policy &
and add pretty_printer * param.
(class diagnostic_column_policy): New.
(class diagnostic_location_print_policy): New.
(class diagnostic_source_print_policy): New.
(class diagnostic_context): Add friend class
diagnostic_source_print_policy.
(diagnostic_context::converted_column): Drop decl in favor of
diagnostic_column_policy::converted_column.
(diagnostic_context::get_location_text): Drop decl in favor of
diagnostic_column_policy::get_location_text.
(diagnostic_context::show_locus): Drop decl in favor of
diagnostic_source_print_policy::print.
(default_diagnostic_start_span_fn): Update for change to
diagnostic_start_span_fn.
* gcc-rich-location.h (class diagnostic_source_print_policy): New
forward decl.
(gcc_rich_location::add_location_if_nearby): Convert first param
from diagnostic_context to diagnostic_source_print_policy.  Add
overload taking diagnostic_context.
* selftest-diagnostic.cc
(selftest::test_diagnostic_context::test_diagnostic_context): Turn
off colorization.
(selftest::test_diagnostic_context::start_span_cb): Update for
change to callback type.
(test_diagnostic_context::test_show_locus): New.
* selftest-diagnostic.h
(selftest::test_diagnostic_context::start_span_cb): Update for
change to callback type.
(test_diagnostic_context::test_show_locus): New decl.

gcc/fortran/ChangeLog:
PR other/116613
* error.cc (gfc_diagnostic_build_locus_prefix): Convert first
param from diagnostic_context * to
const diagnostic_location_print_policy &.  Add colorize param.
Likewise for the "two expanded_locations" overload.
(gfc_diagnostic_text_starter): Update for above changes.
(gfc_diagnostic_start_span): Update for change to callback type.

gcc/testsuite/ChangeLog:
PR other/116613
* gcc.dg/plugin/diagnostic_group_plugin.c
(test_diagnostic_start_span_fn): Update for change to callback
type.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agodiagnostics: avoid using diagnostic_context's m_printer [PR116613]
David Malcolm [Mon, 30 Sep 2024 15:48:29 +0000 (11:48 -0400)] 
diagnostics: avoid using diagnostic_context's m_printer [PR116613]

As work towards supporting multiple diagnostic outputs (where each
output has its own pretty_printer), avoid using diagnostic_context's
m_printer field.  Instead, use the output format's printer.  Currently
this *is* the dc's printer, but eventually it might not be.

No functional change intended.

gcc/ChangeLog:
PR other/116613
* diagnostic-format-json.cc (diagnostic_output_format_init_json):
Pass in the format.  Use the format's printer when disabling
colorization.  Move the call to set_output_format into here.
(diagnostic_output_format_init_json_stderr): Update for above
change.
(diagnostic_output_format_init_json_file): Likewise.
* diagnostic-format-sarif.cc
(diagnostic_output_format_init_sarif): Use the format's printer
when disabling colorization.
* diagnostic-path.cc (selftest::test_empty_path): Use the
text_output's printer.
(selftest::test_intraprocedural_path): Likewise.
(selftest::test_interprocedural_path_1): Likewise.
(selftest::test_interprocedural_path_2): Likewise.
(selftest::test_recursion): Likewise.
(selftest::test_control_flow_1): Likewise.
(selftest::test_control_flow_2): Likewise.
(selftest::test_control_flow_3): Likewise.
(selftest::assert_cfg_edge_path_streq): Likewise.
(selftest::test_control_flow_5): Likewise.
(selftest::test_control_flow_6): Likewise.

gcc/testsuite/ChangeLog:
PR other/116613
* gcc.dg/plugin/diagnostic_group_plugin.c
(test_output_format::on_begin_group): Use get_printer () rather
than accessing m_context.m_printer.
(test_output_format::on_end_group): Likewise.
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c
(xhtml_builder::m_printer): New field.
(xhtml_builder::xhtml_builder): Add "pp" param and use it to
initialize m_printer.
(xhtml_builder::on_report_diagnostic): Drop "context" param.
(xhtml_builder::make_element_for_diagnostic): Likewise.  Use
this->m_printer rather than the context's m_printer.  Pass
m_printer to call to diagnostic_show_locus.
(xhtml_builder::emit_diagram): Drop "context" param.
(xhtml_output_format::on_report_diagnostic): Drop context param
from call to m_builder.
(xhtml_output_format::on_diagram): Likewise.
(xhtml_output_format::xhtml_output_format): Pass result of
get_printer as printer for builder.
(diagnostic_output_format_init_xhtml): Use the fmt's printer
rather than the context's.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agodiagnostics: use "%e" to avoid intermediate strings [PR116613]
David Malcolm [Mon, 30 Sep 2024 15:48:29 +0000 (11:48 -0400)] 
diagnostics: use "%e" to avoid intermediate strings [PR116613]

Various diagnostics build an intermediate string, potentially with
colorization, and then use this in a diagnostic message.

This won't work if we have multiple diagnostic sinks, where some might
be colorized and some not.

This patch reworks such places using "%e" and pp_element subclasses, so
that any colorization happens within report_diagnostic's call to
pp_format.

gcc/analyzer/ChangeLog:
PR other/116613
* kf-analyzer.cc: Include "pretty-print-markup.h".
(kf_analyzer_dump_escaped::impl_call_pre): Defer colorization
choices by eliminating the construction of a intermediate string,
replacing it with a new pp_element subclass via "%e".

gcc/ChangeLog:
PR other/116613
* attribs.cc: Include "pretty-print-markup.h".
(decls_mismatched_attributes): Defer colorization choices by
replacing printing to a pretty_printer * param with appending
to a vec of strings.
(maybe_diag_alias_attributes): As above, replacing pretty_printer
with usage of pp_markup::comma_separated_quoted_strings and "%e"
in two places.
* attribs.h (decls_mismatched_attributes): Update decl.
* gimple-ssa-warn-access.cc: Include "pretty-print-markup.h".
(pass_waccess::maybe_warn_memmodel): Defer colorization choices by
replacing printing to a pretty_printer * param with use of
pp_markup::comma_separated_quoted_strings and "%e".
(pass_waccess::maybe_warn_memmodel): Likewise, replacing printing
to a temporary buffer.
* pretty-print-markup.h
(class pp_markup::comma_separated_quoted_strings): New.
* pretty-print.cc
(pp_markup::comma_separated_quoted_strings::add_to_phase_2): New.
(selftest::test_pp_printf_within_pp_element): New.
(selftest::test_comma_separated_quoted_strings): New.
(selftest::pretty_print_cc_tests): Call the new tests.

gcc/cp/ChangeLog:
PR other/116613
* pt.cc: Include "pretty-print-markup.h".
(warn_spec_missing_attributes): Defer colorization choices by
replacing printing to a pretty_printer * param with appending
to a vec of strings.  Replace pretty_printer with usage of
pp_markup::comma_separated_quoted_strings and "%e".

gcc/testsuite/ChangeLog:
PR other/116613
* c-c++-common/analyzer/escaping-1.c: Update expected results to
remove type information from C++ results.  Previously we were
using %qD with default_tree_printer, which used
lang_hooks.decl_printable_name, whereas now we're using %qD with
a clone of the cxx_pretty_printer.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agodiagnostics: add "dump" to pretty_printer and output_buffer
David Malcolm [Mon, 30 Sep 2024 15:48:28 +0000 (11:48 -0400)] 
diagnostics: add "dump" to pretty_printer and output_buffer

No functional change intended.

gcc/ChangeLog:
* pretty-print.cc (output_buffer::dump): New.
(pretty_printer::dump): New.
* pretty-print.h (output_buffer::dump): New decls.
(pretty_printer::dump): New decls.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agodiagnostics: fix typo in XHTML output [PR116792]
David Malcolm [Mon, 30 Sep 2024 15:48:28 +0000 (11:48 -0400)] 
diagnostics: fix typo in XHTML output [PR116792]

gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Fix stray
reference to JSON.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agodiagnostics: fix memory leak in SARIF selftests
David Malcolm [Mon, 30 Sep 2024 15:48:28 +0000 (11:48 -0400)] 
diagnostics: fix memory leak in SARIF selftests

"make selftest-valgrind" was complaining about leaks of artifact objects
in SARIF's selftest::test_make_location_object:

-fself-test: 7638695 pass(es) in 89.999249 seconds
==3306525==
==3306525== HEAP SUMMARY:
==3306525==     in use at exit: 1,215,639 bytes in 2,808 blocks
==3306525==   total heap usage: 2,860,898 allocs, 2,858,090 frees, 1,336,446,579 bytes allocated
==3306525==
==3306525== 11,728 (1,536 direct, 10,192 indirect) bytes in 16 blocks are definitely lost in loss record 353 of 375
==3306525==    at 0x514FE7D: operator new(unsigned long) (vg_replace_malloc.c:342)
==3306525==    by 0x36E5FD2: sarif_builder::get_or_create_artifact(char const*, diagnostic_artifact_role, bool) (diagnostic-format-sarif.cc:2884)
==3306525==    by 0x36E3D57: sarif_builder::maybe_make_physical_location_object(unsigned int, diagnostic_artifact_role, int, content_renderer const*) (diagnostic-format-sarif.cc:2097)
==3306525==    by 0x36E34CE: sarif_builder::make_location_object(sarif_location_manager&, rich_location const&, logical_location const*, diagnostic_artifact_role) (diagnostic-format-sarif.cc:1922)
==3306525==    by 0x36E72C6: selftest::test_make_location_object(selftest::line_table_case const&) (diagnostic-format-sarif.cc:3500)
==3306525==    by 0x375609B: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.cc:3898)
==3306525==    by 0x36E9668: selftest::diagnostic_format_sarif_cc_tests() (diagnostic-format-sarif.cc:3910)
==3306525==    by 0x3592A11: selftest::run_tests() (selftest-run-tests.cc:100)
==3306525==    by 0x17DBEF3: toplev::run_self_tests() (toplev.cc:2268)
==3306525==    by 0x17DC2BF: toplev::main(int, char**) (toplev.cc:2376)
==3306525==    by 0x36A1919: main (main.cc:39)
==3306525==
==3306525== 12,400 (1,536 direct, 10,864 indirect) bytes in 16 blocks are definitely lost in loss record 355 of 375
==3306525==    at 0x514FE7D: operator new(unsigned long) (vg_replace_malloc.c:342)
==3306525==    by 0x36E5FD2: sarif_builder::get_or_create_artifact(char const*, diagnostic_artifact_role, bool) (diagnostic-format-sarif.cc:2884)
==3306525==    by 0x36E2323: sarif_builder::sarif_builder(diagnostic_context&, line_maps const*, char const*, bool) (diagnostic-format-sarif.cc:1500)
==3306525==    by 0x36E70AA: selftest::test_make_location_object(selftest::line_table_case const&) (diagnostic-format-sarif.cc:3469)
==3306525==    by 0x375609B: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.cc:3898)
==3306525==    by 0x36E9668: selftest::diagnostic_format_sarif_cc_tests() (diagnostic-format-sarif.cc:3910)
==3306525==    by 0x3592A11: selftest::run_tests() (selftest-run-tests.cc:100)
==3306525==    by 0x17DBEF3: toplev::run_self_tests() (toplev.cc:2268)
==3306525==    by 0x17DC2BF: toplev::main(int, char**) (toplev.cc:2376)
==3306525==    by 0x36A1919: main (main.cc:39)
==3306525==
==3306525== LEAK SUMMARY:
==3306525==    definitely lost: 3,072 bytes in 32 blocks
==3306525==    indirectly lost: 21,056 bytes in 368 blocks
==3306525==      possibly lost: 0 bytes in 0 blocks
==3306525==    still reachable: 1,191,511 bytes in 2,408 blocks
==3306525==         suppressed: 0 bytes in 0 blocks
==3306525== Reachable blocks (those to which a pointer was found) are not shown.
==3306525== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3306525==
==3306525== For lists of detected and suppressed errors, rerun with: -s
==3306525== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Fixed thusly.

gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_builder::~sarif_builder): New,
deleting any remaining artifact objects.
(sarif_builder::make_run_object): Empty the artifact map.
* ordered-hash-map.h (ordered_hash_map::empty): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 months agoautovectorizer: Test autovectorization of different dot-prod modes.
Victor Do Nascimento [Fri, 5 Jul 2024 14:18:32 +0000 (15:18 +0100)] 
autovectorizer: Test autovectorization of different dot-prod modes.

Given the novel treatment of the dot product optab as a conversion, we
are now able to target different relationships between output modes and
input modes.

This is made clearer by way of example. Previously, on AArch64, the
following loop was vectorizable:

uint32_t udot4(int n, uint8_t* data) {
  uint32_t sum = 0;
  for (int i=0; i<n; i+=1)
    sum += data[i] * data[i];
  return sum;
}

while the following was not:

uint32_t udot2(int n, uint16_t* data) {
  uint32_t sum = 0;
  for (int i=0; i<n; i+=1)
    sum += data[i] * data[i];
  return sum;
}

Under the new treatment of the dot product optab, they are both now
vectorizable.

This adds the relevant target-agnostic check to ensure this behavior
in the autovectorizer, gated behind the new check_effective_target
`vect_dotprod_hisi' as well a runtime check targeting aarch64.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_vect_dotprod_hisi):
New.
* gcc.dg/vect/vect-dotprod-conv-optab.c: Likewise.
* gcc.target/aarch64/vect-dotprod-twoway-hisi.c: Likewise.

10 months agoc6x: Adjust dot-product backend patterns
Victor Do Nascimento [Wed, 5 Jun 2024 09:55:06 +0000 (10:55 +0100)] 
c6x:  Adjust dot-product backend patterns

Following the migration of the dot_prod optab from a direct to a
conversion-type optab, ensure all back-end patterns incorporate the
second machine mode into pattern names.

gcc/ChangeLog:

* config/c6x/c6x.md (sdot_prodv2hi): Renamed to...
(sdot_prodsiv2hi): ...this.

10 months agors6000: Adjust altivec dot-product backend patterns
Victor Do Nascimento [Wed, 5 Jun 2024 09:51:29 +0000 (10:51 +0100)] 
rs6000: Adjust altivec dot-product backend patterns

Following the migration of the dot_prod optab from a direct to a
conversion-type optab, ensure all back-end patterns incorporate the
second machine mode into pattern names.

gcc/ChangeLog:

* config/rs6000/altivec.md (udot_prod<mode>): Renamed to...
(udot_prodv4si<mode>): ...this.
(sdot_prodv8hi): Renamed to...
(sdot_prodv4siv8hi): ...this.

10 months agomips: Adjust dot-product backend patterns
Victor Do Nascimento [Wed, 5 Jun 2024 09:45:32 +0000 (10:45 +0100)] 
mips:  Adjust dot-product backend patterns

Following the migration of the dot_prod optab from a direct to a
conversion-type optab, ensure all back-end patterns incorporate the
second machine mode into pattern names.

gcc/ChangeLog:

* config/mips/loongson-mmi.md (sdot_prodv4hi): Renamed to...
(sdot_prodv2siv4hi): ...this.

10 months agoarc: Adjust dot-product backend patterns
Victor Do Nascimento [Wed, 5 Jun 2024 09:35:50 +0000 (10:35 +0100)] 
arc: Adjust dot-product backend patterns

Following the migration of the dot_prod optab from a direct to a
conversion-type optab, ensure all back-end patterns incorporate the
second machine mode into pattern names.

gcc/ChangeLog:

* config/arc/simdext.md (sdot_prodv2hi): Renamed to...
(sdot_prodsiv2hi): ...this.
(udot_prodv2hi): Renamed to...
(udot_prodsiv2hi): ...this.
(sdot_prodv4hi): Renamed to...
(sdot_prodv2siv4hi): ...this.
(udot_prodv4hi): Renamed to...
(udot_prodv2siv4hi): ...this.

10 months agoi386: Fix dot_prod backend patterns for mmx and sse targets
Victor Do Nascimento [Tue, 4 Jun 2024 16:11:07 +0000 (17:11 +0100)] 
i386: Fix dot_prod backend patterns for mmx and sse targets

Following the migration of the dot_prod optab from a direct to a
conversion-type optab, ensure all back-end patterns incorporate the
second machine mode into pattern names.

gcc/ChangeLog:

* config/i386/mmx.md (usdot_prodv8qi): Renamed to...
(usdot_prodv2siv8qi): ...this.
(sdot_prodv8qi): Renamed to...
(sdot_prodv2siv8qi): ...this.
(udot_prodv8qi): Renamed to...
(udot_prodv2siv8qi): ...this.
(usdot_prodv4hi): Renamed to...
(usdot_prodv2siv4hi): ...this.
(udot_prodv4hi): Renamed to...
(udot_prodv2siv4hi): ...this.
(sdot_prodv4hi): Renamed to...
(sdot_prodv2siv4hi): ...this.
* config/i386/sse.md (sdot_prod<mode>): Renamed to...
(sdot_prod<sseunpackmodelower><mode>): ...this.
(sdot_prodv4si): Renamed to...
(sdot_prodv2div4si): ...this.
(usdot_prod<mode>): Renamed to...
(usdot_prod<ssedvecmodelower><mode>): ...this.
(sdot_prod<mode>): Renamed to...
(sdot_prod<ssedvecmodelower><mode>): ...this.
(sdot_prodv64qi): Renamed to...
(sdot_prodv16siv64qi): ...this.
(udot_prod<mode>): Renamed to...
(udot_prod<ssedvecmodelower><mode>): ...this.
(udot_prodv64qi): Renamed to...
(udot_prodv16qiv64qi): ...this.
(usdot_prod<mode>): Renamed to...
(usdot_prod<sseunpackmodelower><mode>): ...this.
(udot_prod<mode>): Renamed to...
(udot_prod<sseunpackmodelower><mode>): ...this.

10 months agoarm: Fix arm backend-use of (u|s|us)dot_prod patterns
Victor Do Nascimento [Wed, 5 Jun 2024 10:11:06 +0000 (11:11 +0100)] 
arm: Fix arm backend-use of (u|s|us)dot_prod patterns

Given recent changes to the dot_prod standard pattern name, this patch
fixes the arm back-end by implementing the following changes:

1. Add 2nd mode to all patterns relating to the dot-product in .md
files.
2. redirect the single-mode CODE_FOR_neon_(u|s|us)dot<mode> values
generated from `arm_neon_builtins.def' to their new 2-mode
equivalents via means of simple aliases, as per the following example:

  constexpr insn_code CODE_FOR_neon_sdotv8qi
    = CODE_FOR_neon_sdotv2siv8qi;

gcc/ChangeLog:

* config/arm/neon.md (<sup>dot_prod<vsi2qi>): Renamed to...
(<sup>dot_prod<mode><vsi2qi>): ...this.
(neon_<sup>dot<vsi2qi>): Renamed to...
(neon_<sup>dot<mode><vsi2qi>): ...this.
(neon_usdot<vsi2qi>): Renamed to...
(neon_usdot<mode><vsi2qi>): ...this.
(usdot_prod<vsi2qi>): Renamed to...
(usdot_prod<mode><vsi2qi>): ...this.
* config/arm/arm-builtins.cc
(CODE_FOR_neon_sdotv8qi): Definie as alias to
new CODE_FOR_neon_sdotv2siv8qi.
(CODE_FOR_neon_udotv8qi): Definie as alias to
new CODE_FOR_neon_udotv2siv8qi.
(CODE_FOR_neon_usdotv8qi): Definie as alias to
new CODE_FOR_neon_usdotv2siv8qi.
(CODE_FOR_neon_sdotv16qi): Definie as alias to
new CODE_FOR_neon_sdotv4siv16qi.
(CODE_FOR_neon_udotv16qi): Definie as alias to
new CODE_FOR_neon_udotv4siv16qi.
(CODE_FOR_neon_usdotv16qi): Definie as alias to
new CODE_FOR_neon_usdotv4siv16qi.

10 months agoaarch64: Fix aarch64 backend-use of (u|s|us)dot_prod patterns
Victor Do Nascimento [Tue, 21 May 2024 16:13:03 +0000 (17:13 +0100)] 
aarch64: Fix aarch64 backend-use of (u|s|us)dot_prod patterns

Given recent changes to the dot_prod standard pattern name, this patch
fixes the aarch64 back-end by implementing the following changes:

1. Add 2nd mode to all (u|s|us)dot_prod patterns in .md files.
2. Rewrite initialization and function expansion mechanism for simd
builtins.
3. Fix all direct calls to back-end `dot_prod' patterns in SVE
builtins.

Finally, given that it is now possible for the compiler to
differentiate between the two- and four-way dot product, we add a test
to ensure that autovectorization picks up on dot-product patterns
where the result is twice the width of the operands.

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md
(<sur>dot_prod<vsi2qi><vczle><vczbe>): Renamed to...
(<sur>dot_prod<mode><vsi2qi><vczle><vczbe>): ...this.
(usdot_prod<vsi2qi><vczle><vczbe>): Renamed to...
(usdot_prod<mode><vsi2qi><vczle><vczbe>): ...this.
(<su>sadv16qi): Adjust call to gen_udot_prod take second mode.
(popcount<mode2>): fix use of `udot_prod_optab'.
* config/aarch64/aarch64-sve.md
(<sur>dot_prod<vsi2qi>): Renamed to...
(<sur>dot_prod<mode><vsi2qi>): ...this.
(@<sur>dot_prod<vsi2qi>): Renamed to...
(@<sur>dot_prod<mode><vsi2qi>): ...this.
(<su>sad<vsi2qi>): Adjust call to gen_udot_prod take second mode.
* config/aarch64/aarch64-sve2.md
(@aarch64_sve_<sur>dotvnx4sivnx8hi): Renamed to...
(<sur>dot_prodvnx4sivnx8hi): ...this.
* config/aarch64/aarch64-simd-builtins.def: Modify macro
expansion-based initialization and expansion
of (u|s|us)dot_prod builtins.
* config/aarch64/aarch64-builtins.cc
(CODE_FOR_aarch64_sdot_prodv8qi): Define as alias to
new CODE_FOR_sdot_prodv2siv8qi.
(CODE_FOR_aarch64_udot_prodv8qi): Define as alias to
new CODE_FOR_udot_prodv2siv8qi.
(CODE_FOR_aarch64_usdot_prodv8qi): Define as alias to
new CODE_FOR_usdot_prodv2siv8qi.
(CODE_FOR_aarch64_sdot_prodv16qi): Define as alias to
new CODE_FOR_sdot_prodv4siv16qi.
(CODE_FOR_aarch64_udot_prodv16qi): Define as alias to
new CODE_FOR_udot_prodv4siv16qi.
(CODE_FOR_aarch64_usdot_prodv16qi): Define as alias to
new CODE_FOR_usdot_prodv4siv16qi.
* config/aarch64/aarch64-sve-builtins-base.cc
(svdot_impl::expand): s/direct/convert/ in
`convert_optab_handler_for_sign' function call.
(svusdot_impl::expand): add second mode argument in call to
`code_for_dot_prod'.
* config/aarch64/aarch64-sve-builtins.cc
(function_expander::convert_optab_handler_for_sign): New class
method.
* config/aarch64/aarch64-sve-builtins.h
(class function_expander): Add prototype for new
`convert_optab_handler_for_sign' method.

gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sme/vect-dotprod-twoway.c (udot2): New.

10 months agoautovectorizer: Add basic support for convert optabs
Victor Do Nascimento [Wed, 22 May 2024 09:06:57 +0000 (10:06 +0100)] 
autovectorizer: Add basic support for convert optabs

Given the shift from modeling dot products as direct optabs to
treating them as conversion optabs, we make necessary changes to the
autovectorizer code to ensure that given the relevant tree code,
together with the input and output data modes, we can retrieve the
relevant optab and subsequently the insn_code for it.

gcc/ChangeLog:

* gimple-match-exports.cc (directly_supported_p): Add overload
for conversion-type optabs.
* gimple-match.h (directly_supported_p): Add new function
prototype.
* optabs.cc (expand_widen_pattern_expr): Make the
DOT_PROD_EXPR tree code use `find_widening_optab_handler' to
retrieve icode.
* tree-vect-loop.cc (vect_is_emulated_mixed_dot_prod): make it
call conversion-type overloaded `directly_supported_p'.
* tree-vect-patterns.cc (vect_supportable_conv_optab_p): New.
(vect_recog_dot_prod_pattern): s/direct/conv/ in call to
`vect_supportable_direct_optab_p'.

10 months agooptabs: Make all `*dot_prod_optab's modeled as conversions
Victor Do Nascimento [Tue, 21 May 2024 10:17:45 +0000 (11:17 +0100)] 
optabs: Make all `*dot_prod_optab's modeled as conversions

Given the specification in the GCC internals manual defines the
{u|s}dot_prod<m> standard name as taking "two signed elements of the
same mode, adding them to a third operand of wider mode", there is
currently ambiguity in the relationship between the mode of the first
two arguments and that of the third.

This vagueness means that, in theory, different modes may be
supportable in the third argument.  This flexibility would allow for a
given backend to add to the accumulator a different number of
vectorized products, e.g. A backend may provide instructions for both:

  accum += a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]

and

  accum += a[0] * b[0] + a[1] * b[1],

as is now seen in the SVE2.1 extension to AArch64.  In spite of the
aforementioned flexibility, modeling the dot-product operation as a
direct optab means that we have no way to encode both input and the
accumulator data modes into the backend pattern name, which prevents
us from harnessing this flexibility.

We therefore make all dot_prod optabs conversions, allowing, for
example, for the encoding of both 2-way and 4-way dot product backend
patterns.

gcc/ChangeLog:

* optabs.def (sdot_prod_optab): Convert from OPTAB_D to
OPTAB_CD.
(udot_prod_optab): Likewise.
(usdot_prod_optab): Likewise.
* doc/md.texi (Standard Names): update entries for u,s and us
dot_prod names.

10 months agotree-optimization/116879 - failure to recognize non-empty latch
Richard Biener [Mon, 30 Sep 2024 11:38:28 +0000 (13:38 +0200)] 
tree-optimization/116879 - failure to recognize non-empty latch

When we relaxed the vectorizers constraint on loop structure verifying
the emptiness of the latch became too lose as can be seen in the case
for PR116879 where the latch effectively contains two basic-blocks
which one being an unmerged forwarder that's not empty.

PR tree-optimization/116879
* tree-vect-loop.cc (vect_analyze_loop_form): Scan all
blocks that form the latch.

* gcc.dg/pr116879.c: New testcase.

10 months agomiddle-end: check explicitly for external or constants when checking for loop invaria...
Tamar Christina [Mon, 30 Sep 2024 12:06:24 +0000 (13:06 +0100)] 
middle-end: check explicitly for external or constants when checking for loop invariant [PR116817]

The previous check if a value was external was checking
!vect_get_internal_def (vinfo, var) but this of course isn't completely right
as they could reductions etc.

This changes the check to just explicitly look at externals and constants.
Note that reductions remain unhandled here, but we don't support codegen of
boolean reductions today anyway.

So at the time we do then this would have the be handled as well in lowering.

gcc/ChangeLog:

PR tree-optimization/116817
* tree-vect-patterns.cc (vect_recog_bool_pattern): Check for const or
externals.

gcc/testsuite/ChangeLog:

PR tree-optimization/116817
* g++.dg/vect/pr116817.cc: New test.

10 months agoEnsure coarrays in calls use a descriptor [PR81265]
Andre Vehreschild [Fri, 27 Sep 2024 12:18:42 +0000 (14:18 +0200)] 
Ensure coarrays in calls use a descriptor [PR81265]

gcc/fortran/ChangeLog:

PR fortran/81265

* trans-expr.cc (gfc_conv_procedure_call): Ensure coarrays use a
descriptor when passed.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/pr81265.f90: New test.

10 months agotree-optimization/116842 - vectorizer load hosting breaks UID order
Richard Biener [Sat, 28 Sep 2024 12:02:18 +0000 (14:02 +0200)] 
tree-optimization/116842 - vectorizer load hosting breaks UID order

The following fixes the case when vectorizing a load hoists an invariant
load and dependent stmts, thereby breaking UID order of said stmts.
While we duplicate the load we just move the dependences.

PR tree-optimization/116842
* tree-vect-stmts.cc (hoist_defs_of_uses): Sort stmts to hoist
after UID to avoid breaking vect_stmt_dominates_stmt_p.

* g++.dg/torture/pr116842.C: New testcase.

10 months agotree-optimization/116785 - relax volatile handling in PTA
Richard Biener [Fri, 27 Sep 2024 11:50:31 +0000 (13:50 +0200)] 
tree-optimization/116785 - relax volatile handling in PTA

When there's volatile qualified stores we do not have to treat the
destination as pointing to ANYTHING.  It's only when reading from
it that we want to treat the resulting pointers as pointing to ANYTHING.

PR tree-optimization/116785
* tree-ssa-structalias.cc (get_constraint_for_1): Only
volatile qualified reads produce ANYTHING.

10 months agotree-optimization/116850 - corrupt post-dom info
Richard Biener [Thu, 26 Sep 2024 13:41:59 +0000 (15:41 +0200)] 
tree-optimization/116850 - corrupt post-dom info

Path isolation computes post-dominators on demand but can end up
splitting blocks after that, wrecking it.  We can delay splitting
of blocks until we no longer need the post-dom info which is what
the following patch does to solve the issue.

PR tree-optimization/116850
* gimple-ssa-isolate-paths.cc (bb_split_points): New global.
(insert_trap): Delay BB splitting if post-doms are computed.
(find_explicit_erroneous_behavior): Process delayed BB
splitting after releasing post dominators.
(gimple_ssa_isolate_erroneous_paths): Do not free post-dom
info here.

* gcc.dg/pr116850.c: New testcase.

10 months agoMatch: Support form 1 for scalar signed integer SAT_SUB
Pan Li [Wed, 25 Sep 2024 01:26:07 +0000 (09:26 +0800)] 
Match: Support form 1 for scalar signed integer SAT_SUB

This patch would like to support the form 1 of the scalar signed
integer SAT_SUB.  Aka below example:

Form 1:
  #define DEF_SAT_S_SUB_FMT_1(T, UT, MIN, MAX) \
  T __attribute__((noinline))                  \
  sat_s_sub_##T##_fmt_1 (T x, T y)             \
  {                                            \
    T minus = (UT)x - (UT)y;                   \
    return (x ^ y) >= 0                        \
      ? minus                                  \
      : (minus ^ x) >= 0                       \
        ? minus                                \
        : x < 0 ? MIN : MAX;                   \
  }

DEF_SAT_S_SUB_FMT_1(int8_t, uint8_t, INT8_MIN, INT8_MAX)

Before this patch:
   4   │ __attribute__((noinline))
   5   │ int8_t sat_s_sub_int8_t_fmt_1 (int8_t x, int8_t y)
   6   │ {
   7   │   int8_t minus;
   8   │   unsigned char x.0_1;
   9   │   unsigned char y.1_2;
  10   │   unsigned char _3;
  11   │   signed char _4;
  12   │   signed char _5;
  13   │   int8_t _6;
  14   │   _Bool _11;
  15   │   signed char _12;
  16   │   signed char _13;
  17   │   signed char _14;
  18   │   signed char _15;
  19   │
  20   │ ;;   basic block 2, loop depth 0
  21   │ ;;    pred:       ENTRY
  22   │   x.0_1 = (unsigned char) x_7(D);
  23   │   y.1_2 = (unsigned char) y_8(D);
  24   │   _3 = x.0_1 - y.1_2;
  25   │   minus_9 = (int8_t) _3;
  26   │   _4 = x_7(D) ^ y_8(D);
  27   │   _5 = x_7(D) ^ minus_9;
  28   │   _15 = _4 & _5;
  29   │   if (_15 < 0)
  30   │     goto <bb 3>; [41.00%]
  31   │   else
  32   │     goto <bb 4>; [59.00%]
  33   │ ;;    succ:       3
  34   │ ;;                4
  35   │
  36   │ ;;   basic block 3, loop depth 0
  37   │ ;;    pred:       2
  38   │   _11 = x_7(D) < 0;
  39   │   _12 = (signed char) _11;
  40   │   _13 = -_12;
  41   │   _14 = _13 ^ 127;
  42   │ ;;    succ:       4
  43   │
  44   │ ;;   basic block 4, loop depth 0
  45   │ ;;    pred:       2
  46   │ ;;                3
  47   │   # _6 = PHI <minus_9(2), _14(3)>
  48   │   return _6;
  49   │ ;;    succ:       EXIT
  50   │
  51   │ }

After this patch:
   4   │ __attribute__((noinline))
   5   │ int8_t sat_s_sub_int8_t_fmt_1 (int8_t x, int8_t y)
   6   │ {
   7   │   int8_t _6;
   8   │
   9   │ ;;   basic block 2, loop depth 0
  10   │ ;;    pred:       ENTRY
  11   │   _6 = .SAT_SUB (x_7(D), y_8(D)); [tail call]
  12   │   return _6;
  13   │ ;;    succ:       EXIT
  14   │
  15   │ }

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Add case 1 matching pattern for signed SAT_SUB.
* tree-ssa-math-opts.cc (gimple_signed_integer_sat_sub): Add new
decl for generated SAT_SUB matching func.
(match_unsigned_saturation_sub): Rename from...
(match_saturation_sub): ...Rename to and add signed SAT_SUB matching.
(math_opts_dom_walker::after_dom_children): Leverage the named
match func for both the unsigned and signed SAT_SUB.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoDaily bump.
GCC Administrator [Mon, 30 Sep 2024 00:17:25 +0000 (00:17 +0000)] 
Daily bump.

10 months agoRISC-V: Add testcases for form 1 of scalar signed SAT_SUB
Pan Li [Wed, 25 Sep 2024 01:42:31 +0000 (09:42 +0800)] 
RISC-V: Add testcases for form 1 of scalar signed SAT_SUB

Form 1:
  #define DEF_SAT_S_SUB_FMT_1(T, UT, MIN, MAX) \
  T __attribute__((noinline))                  \
  sat_s_sub_##T##_fmt_1 (T x, T y)             \
  {                                            \
    T minus = (UT)x - (UT)y;                   \
    return (x ^ y) >= 0                        \
      ? minus                                  \
      : (minus ^ x) >= 0                       \
        ? minus                                \
        : x < 0 ? MIN : MAX;                   \
  }

DEF_SAT_S_SUB_FMT_1(int8_t, uint8_t, INT8_MIN, INT8_MAX)

The below test are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat_arith_data.h: Add test data for SAT_SUB.
* gcc.target/riscv/sat_s_sub-1-i16.c: New test.
* gcc.target/riscv/sat_s_sub-1-i32.c: New test.
* gcc.target/riscv/sat_s_sub-1-i64.c: New test.
* gcc.target/riscv/sat_s_sub-1-i8.c: New test.
* gcc.target/riscv/sat_s_sub-run-1-i16.c: New test.
* gcc.target/riscv/sat_s_sub-run-1-i32.c: New test.
* gcc.target/riscv/sat_s_sub-run-1-i64.c: New test.
* gcc.target/riscv/sat_s_sub-run-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Implement scalar SAT_SUB for signed integer
Pan Li [Wed, 25 Sep 2024 01:36:05 +0000 (09:36 +0800)] 
RISC-V: Implement scalar SAT_SUB for signed integer

This patch would like to implement the sssub form 1.  Aka:

Form 1:
  #define DEF_SAT_S_SUB_FMT_1(T, UT, MIN, MAX) \
  T __attribute__((noinline))                  \
  sat_s_sub_##T##_fmt_1 (T x, T y)             \
  {                                            \
    T minus = (UT)x - (UT)y;                   \
    return (x ^ y) >= 0                        \
      ? minus                                  \
      : (minus ^ x) >= 0                       \
        ? minus                                \
        : x < 0 ? MIN : MAX;                   \
  }

DEF_SAT_S_SUB_FMT_1(int8_t, uint8_t, INT8_MIN, INT8_MAX)

Before this patch:
  10   │ sat_s_sub_int8_t_fmt_1:
  11   │     subw    a5,a0,a1
  12   │     slliw   a5,a5,24
  13   │     sraiw   a5,a5,24
  14   │     xor a1,a0,a1
  15   │     xor a4,a0,a5
  16   │     and a1,a1,a4
  17   │     blt a1,zero,.L4
  18   │     mv  a0,a5
  19   │     ret
  20   │ .L4:
  21   │     srai    a0,a0,63
  22   │     xori    a5,a0,127
  23   │     mv  a0,a5
  24   │     ret

After this patch:
  10   │ sat_s_sub_int8_t_fmt_1:
  11   │     sub a4,a0,a1
  12   │     xor a5,a0,a4
  13   │     xor a1,a0,a1
  14   │     and a5,a5,a1
  15   │     srli    a5,a5,7
  16   │     andi    a5,a5,1
  17   │     srai    a0,a0,63
  18   │     xori    a3,a0,127
  19   │     neg a0,a5
  20   │     addi    a5,a5,-1
  21   │     and a3,a3,a0
  22   │     and a0,a4,a5
  23   │     or  a0,a0,a3
  24   │     slliw   a0,a0,24
  25   │     sraiw   a0,a0,24
  26   │     ret

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (riscv_expand_sssub): Add new func
decl for expanding signed SAT_SUB.
* config/riscv/riscv.cc (riscv_expand_sssub): Add new func impl
for expanding signed SAT_SUB.
* config/riscv/riscv.md (sssub<mode>3): Add new pattern sssub
for scalar signed integer.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agocselib: Discard useless locs of preserved VALUEs [PR116627]
Jakub Jelinek [Sun, 29 Sep 2024 19:52:32 +0000 (21:52 +0200)] 
cselib: Discard useless locs of preserved VALUEs [PR116627]

remove_useless_values iteratively discards useless locs (locs of
cselib_val which refer to non-preserved VALUEs with no locations),
which in turn can make further values useless until no further VALUEs
are made useless and then discards the useless VALUEs.

Preserved VALUEs (something done during var-tracking only I think)
live in a different hash table, cselib_preserved_hash_table rather
than cselib_hash_table.  cselib_find_slot first looks up slot in
cselib_preserved_hash_table and only if not found looks it up in
cselib_hash_table (and INSERTs only into the latter), whereas preservation
of a VALUE results in move of a cselib_val from the latter to the former
hash table.

The testcase in the PR (apparently too fragile, it only reproduces on 14
branch with various flags on a single arch, not on trunk) ICEs, because
we have a preserved VALUE (QImode with (const_int 0) as one of the locs).
In a different BB SImode r2 is looked up, a non-preserved VALUE is created
for it, and the r13-2916 added code attempts to lookup also SUBREGs of that
in narrower modes, among those QImode, so adds to that SImode r2
non-preserve VALUE a new loc of (subreg:QI (value:SI) 0).  That SImode
value is considered useless, so remove_useless_value discards it, but
nothing discarded it from the preserved VALUE's loc_list, so when looking
something up in the hash table we ICE trying to derevence CSELIB_VAL
of the discarded VALUE.

I think we need to discuard useless locs even from the preserved VALUEs.
That IMHO shouldn't create any further useless VALUEs, the preserved
VALUEs are never useless, so we don't need to iterate with it, can do it
just once, but IMHO it needs to be done because actually
discard_useless_values.

The following patch does that.

2024-09-29  Jakub Jelinek  <jakub@redhat.com>

PR target/116627
* cselib.cc (remove_useless_values): Discard useless locs
even from preserved cselib_vals in cselib_preserved_hash_table
hash table.

10 months agotestsuite: XFAIL gfortran.dg/initialization_25.f90 properly (again)
Sam James [Sun, 29 Sep 2024 17:44:20 +0000 (18:44 +0100)] 
testsuite: XFAIL gfortran.dg/initialization_25.f90 properly (again)

dg-error needs an argument for "why" / a comment.

gcc/testsuite/ChangeLog:
PR fortran/116858

* gfortran.dg/initialization_25.f90: Fix dg-error arguments.

10 months ago[PATCH] SH: Document extended asm operand modifers
Pietro Monteiro [Sun, 29 Sep 2024 16:39:05 +0000 (10:39 -0600)] 
[PATCH] SH: Document extended asm operand modifers

From: Pietro Monteiro <pietro@sociotechnical.xyz>

SH: Document extended asm operand modifers

Tested by running "make info pdf html" and looking at the pdf and html output. I used the comment on "gcc/config/sh.cc:sh_print_operand()", SH's TARGET_PRINT_OPERAND function, as a guide.

gcc/ChangeLog:
* doc/extend.texi (SH Operand Modifiers): New.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
10 months ago[PATCH] [PATCH] Avoid integer overflow in gcc.dg/cpp/charconst-3.c (PR testsuite...
Mikael Pettersson [Sun, 29 Sep 2024 16:15:55 +0000 (10:15 -0600)] 
[PATCH] [PATCH] Avoid integer overflow in gcc.dg/cpp/charconst-3.c (PR testsuite/116806)

The intermediate expression (unsigned char) '\234' * scale overflows
int on int16 targets, causing the test case to fail there.  Fixed by
performing the arithmetic in unsigned type, as suggested by Andrew Pinski.

Regression tested on x86_64-pc-linux-gnu, and on an out-of-tree 16-bit
target with simulator.  Manually checked the generated code for pdp11
and xstormy16.

Ok for trunk? (I don't have commit rights so I'd need help committing it.)

gcc/testsuite/

PR testsuite/116806
* gcc.dg/cpp/charconst-3.c: Perform arithmetic in unsigned
type to avoid integer overflow.

10 months ago[PATCH v2] RISC-V: Improve code generation for select of consecutive constants
Jovan Vukic [Sun, 29 Sep 2024 16:06:43 +0000 (10:06 -0600)] 
[PATCH v2] RISC-V: Improve code generation for select of consecutive constants

Based on the valuable feedback I received, I decided to implement the patch
in the RTL pipeline. Since a similar optimization already exists in
simplify_binary_operation_1, I chose to generalize my original approach
and place it directly below that code.

The expression (X xor C1) + C2 is simplified to X xor (C1 xor C2) under
the conditions described in the patch. This is a more general optimization,
but it still applies to the RISC-V case, which was my initial goal:

long f1(long x, long y) {
    return (x > y) ? 2 : 3;
}

Before the patch, the generated assembly is:

f1(long, long):
        sgt     a0,a0,a1
        xori    a0,a0,1
        addi    a0,a0,2
        ret

After the patch, the generated assembly is:

f1(long, long):
        sgt     a0,a0,a1
        xori    a0,a0,3
        ret

The patch optimizes cases like x LT/GT y ? 2 : 3 (and x GE/LE y ? 3 : 2),
as initially intended. Since this optimization is more general, I noticed
it also optimizes cases like x < CONST ? 3 : 2 when CONST < 0. I’ve added
tests for these cases as well.

A bit of logic behind the patch: The equality A + B == A ^ B + 2 * (A & B)
always holds true. This can be simplified to A ^ B if 2 * (A & B) == 0.
In our case, we have A == X ^ C1, B == C2 and X is either 0 or 1.

PR target/108038

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): New
simplification.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/slt-1.c: New test.

10 months agodoc: Document struct-layout-1.exp for ABI checks
Dimitar Dimitrov [Fri, 6 Sep 2024 19:49:50 +0000 (22:49 +0300)] 
doc: Document struct-layout-1.exp for ABI checks

This test helped discover PR116621, so it is worth being documented.

gcc/ChangeLog:

* doc/sourcebuild.texi: Document struct-layout-1.exp.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
10 months agoDaily bump.
GCC Administrator [Sun, 29 Sep 2024 00:17:27 +0000 (00:17 +0000)] 
Daily bump.

10 months agoImplement FINDLOC for UNSIGNED.
Thomas Koenig [Sat, 28 Sep 2024 20:29:56 +0000 (22:29 +0200)] 
Implement FINDLOC for UNSIGNED.

gcc/fortran/ChangeLog:

* check.cc (intrinsic_type_check): Handle unsigned.
(gfc_check_findloc): Likewise.
* gfortran.texi: Include FINDLOC in unsigned documentation.
* iresolve.cc (gfc_resolve_findloc): Use INTEGER version
for UNSIGNED.

gcc/testsuite/ChangeLog:

* gfortran.dg/unsigned_33.f90: New test.

10 months agoImplement CSHIFT and EOSHIFT for unsigned.
Thomas Koenig [Sat, 28 Sep 2024 20:28:59 +0000 (22:28 +0200)] 
Implement CSHIFT and EOSHIFT for unsigned.

gcc/fortran/ChangeLog:

* check.cc (gfc_check_eoshift): Handle BT_UNSIGNED.
* simplify.cc (gfc_simplify_eoshift): Likewise.
* gfortran.texi: Document CSHIFT and EOSHIFT for UNSIGNED.

gcc/testsuite/ChangeLog:

* gfortran.dg/unsigned_31.f90: New test.
* gfortran.dg/unsigned_32.f90: New test.

10 months agodoc: Remove i?86-*-linux* installation note from 2003
Gerald Pfeifer [Sat, 28 Sep 2024 01:20:31 +0000 (09:20 +0800)] 
doc: Remove i?86-*-linux* installation note from 2003

gcc:
PR target/69374
* doc/install.texi (Specific) <i?86-*-linux*>: Remove note
from 2003.

10 months agoDaily bump.
GCC Administrator [Sat, 28 Sep 2024 00:19:05 +0000 (00:19 +0000)] 
Daily bump.

10 months agoc++: Implement resolution for DR 36 [PR116160]
Nathaniel Shead [Thu, 19 Sep 2024 14:47:12 +0000 (00:47 +1000)] 
c++: Implement resolution for DR 36 [PR116160]

This implements part of P1787 to no longer complain about redeclaring an
entity via using-decl other than in a class scope.

PR c++/116160

gcc/cp/ChangeLog:

* name-lookup.cc (supplement_binding): Allow redeclaration via
USING_DECL if not in class scope.
(do_nonmember_using_decl): Remove function-scope exemption.
(push_using_decl_bindings): Remove outdated comment.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/using-enum-3.C: No longer expect an error.
* g++.dg/lookup/using53.C: Remove XFAIL.
* g++.dg/cpp2a/using-enum-11.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoc++: Don't strip USING_DECLs when updating local bindings [PR116748]
Nathaniel Shead [Thu, 19 Sep 2024 14:05:04 +0000 (00:05 +1000)] 
c++: Don't strip USING_DECLs when updating local bindings [PR116748]

Currently update_binding strips USING_DECLs too eagerly, leading to ICEs
in pop_local_decl as it can't find the decl it's popping in the binding
list.  Let's rather try to keep the original USING_DECL around.

This also means that using59.C can point to the location of the
using-decl rather than the underlying object directly; this is in the
direction required to fix PR c++/106851 (though more work is needed to
emit properly helpful diagnostics here).

PR c++/116748

gcc/cp/ChangeLog:

* name-lookup.cc (update_binding): Maintain USING_DECLs in the
binding slots.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/using59.C: Update location.
* g++.dg/lookup/using69.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoc++/modules: Propagate purview/import for templates in duplicate_decls [PR116803]
Nathaniel Shead [Fri, 27 Sep 2024 08:58:27 +0000 (18:58 +1000)] 
c++/modules: Propagate purview/import for templates in duplicate_decls [PR116803]

We need to ensure that for a declaration in the module purview, that the
resulting declaration has PURVIEW_P set and IMPORT_P cleared so that we
understand it might be something requiring exporting.  This is normally
handled for a declaration by set_instantiating_module, but when this
declaration is a redeclaration duplicate_decls needs to propagate this
to olddecl.

This patch only changes the logic for template declarations, because in
the non-template case the whole contents of olddecl's DECL_LANG_SPECIFIC
is replaced with newdecl's (which includes these flags), so there's
nothing to do.

PR c++/116803

gcc/cp/ChangeLog:

* decl.cc (duplicate_decls): Propagate DECL_MODULE_PURVIEW_P and
DECL_MODULE_IMPORT_P for template redeclarations.

gcc/testsuite/ChangeLog:

* g++.dg/modules/merge-18_a.H: New test.
* g++.dg/modules/merge-18_b.H: New test.
* g++.dg/modules/merge-18_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agolibstdc++: Fix more pedwarns in headers for C++98
Jonathan Wakely [Fri, 27 Sep 2024 20:01:46 +0000 (21:01 +0100)] 
libstdc++: Fix more pedwarns in headers for C++98

Some tests e.g.  17_intro/headers/c++1998/all_pedantic_errors.cc FAIL
with GLIBCXX_TESTSUITE_STDS=98 due to numerous C++11 extensions still in
use in the library headers. The recent changes to not make them system
headers means we get warnings now.

This change adds more diagnostic pragmas to suppress those warnings.

libstdc++-v3/ChangeLog:

* include/bits/istream.tcc: Add diagnostic pragmas around uses
of long long and extern template.
* include/bits/locale_facets.h: Likewise.
* include/bits/locale_facets.tcc: Likewise.
* include/bits/locale_facets_nonio.tcc: Likewise.
* include/bits/ostream.tcc: Likewise.
* include/bits/stl_algobase.h: Likewise.
* include/c_global/cstdlib: Likewise.
* include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:
Likewise.
* include/ext/pointer.h: Likewise.
* include/ext/stdio_sync_filebuf.h: Likewise.
* include/std/istream: Likewise.
* include/std/ostream: Likewise.
* include/tr1/cmath: Likewise.
* include/tr1/type_traits: Likewise.
* include/tr1/functional_hash.h: Likewise. Remove semi-colons
at namespace scope that aren't needed after macro expansion.
* include/tr1/tuple: Remove semi-colon at namespace scope.
* include/bits/vector.tcc: Change LL suffix to just L.

10 months agolibstdc++: Refactor experimental::filesystem::path string conversions
Jonathan Wakely [Fri, 27 Sep 2024 14:53:04 +0000 (15:53 +0100)] 
libstdc++: Refactor experimental::filesystem::path string conversions

I noticed a -Wc++17-extensions warning due to use of if-constexpr in
std::experimental::filesystem::path, which was not protected by
diagnostic pragmas to disable the warning.

While adding the pragmas I noticed that other places in the same file
use tag dispatching and multiple overloads instead of if-constexpr.
Since we're already using it in that file, we might as well just use it
everywhere.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_path.h (path::_Cvt): Refactor to
use if-constexpr.
(path::string(const Allocator&)): Likewise.

10 months agolibstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite
Jonathan Wakely [Fri, 27 Sep 2024 14:51:56 +0000 (15:51 +0100)] 
libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite

libstdc++-v3/ChangeLog:

* include/bits/basic_string.tcc (resize_for_overwrite): Fix
-Wsign-compare warning.
* include/bits/cow_string.h (resize_for_overwrite): Likewise.

10 months agoc++: ICE with structured bindings and m-d array [PR102594]
Marek Polacek [Thu, 5 Sep 2024 20:45:32 +0000 (16:45 -0400)] 
c++: ICE with structured bindings and m-d array [PR102594]

We ICE in decay_conversion with this test:

  struct S {
    S() {}
  };
  S arr[1][1];
  auto [m](arr3);

But not when the last line is:

  auto [n] = arr3;

Therefore the difference is between copy- and direct-init.  In
particular, in build_vec_init we have:

  if (direct_init)
    from = build_tree_list (NULL_TREE, from);

and then we call build_vec_init again with init==from.  Then
decay_conversion gets the TREE_LIST and it crashes.

build_aggr_init has:

              /* Wrap the initializer in a CONSTRUCTOR so that build_vec_init
                 recognizes it as direct-initialization.  */
              init = build_constructor_single (init_list_type_node,
                                               NULL_TREE, init);
              CONSTRUCTOR_IS_DIRECT_INIT (init) = true;

so I propose to do the same in build_vec_init.

PR c++/102594

gcc/cp/ChangeLog:

* init.cc (build_vec_init): Build up a CONSTRUCTOR to signal
direct-initialization rather than a TREE_LIST.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/decomp61.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agolibstdc++: Fix test FAILs due to -Wreturn-local-addr
Jonathan Wakely [Thu, 26 Sep 2024 22:43:20 +0000 (23:43 +0100)] 
libstdc++: Fix test FAILs due to -Wreturn-local-addr

This fixes two FAILs due to -Wpointer-arith warnings when testing with
c++11 or c++14 dialects.

libstdc++-v3/ChangeLog:

* testsuite/20_util/bind/dangling_ref.cc: Add an additional
dg-warning for -Wreturn-local-addr warning.
* testsuite/30_threads/packaged_task/cons/dangling_ref.cc:
Likewise.

10 months agolibstdc++: Fix test FAIL due to -Wpointer-arith
Jonathan Wakely [Thu, 26 Sep 2024 22:38:41 +0000 (23:38 +0100)] 
libstdc++: Fix test FAIL due to -Wpointer-arith

This fixes a FAIL due to a -Wpointer-arith warning when testing with
c++11 or c++14 dialects. As an extension our std::atomic<void*> supports
pointer arithmetic in C++11 and C++14, but due to the system header
changes there is now a warning about it. The warning seems reasonable,
so rather than suppress it we should make the test expect it.

While looking into this I decided to simplify some of the code related
to atomic<T*> arithmetic.

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (__atomic_base<T*>::_M_type_size):
Replace overloaded functions with static _S_type_size.
* include/std/atomic (atomic<T*>): Use is_object_v instead of
is_object.
* testsuite/29_atomics/atomic/operators/pointer_partial_void.cc:
Add dg-warning for -Wpointer-arith warning.

10 months agoaarch64: fix build failure on aarch64-none-elf
Matthieu Longo [Thu, 26 Sep 2024 17:14:23 +0000 (18:14 +0100)] 
aarch64: fix build failure on aarch64-none-elf

A previous patch ([1]) introduced a build regression on aarch64-none-elf
target. The changes were primarilly tested on aarch64-unknown-linux-gnu,
so the issue was missed during development.
The includes are slighly different between the two targets, and due to some
include rules ([2]), "aarch64-unwind-def.h" was not found.

[1]: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=bdf41d627c13bc5f0dc676991f4513daa9d9ae36

[2]: https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
> include "file"
> ...  It searches for a file named file first in the directory
> containing the current file, ...

libgcc/ChangeLog:

* config/aarch64/aarch64-unwind.h: Fix header path.

10 months agodiagnostic: Save/restore diagnostic context history and push/pop state for PCH [PR116847]
Jakub Jelinek [Fri, 27 Sep 2024 14:07:40 +0000 (16:07 +0200)] 
diagnostic: Save/restore diagnostic context history and push/pop state for PCH [PR116847]

The following patch on top of the just posted cleanup patch
saves/restores the m_classification_history and m_push_list
vectors for PCH.  Without that as the testcase shows during parsing
of the templates we don't report ignored diagnostics, but after loading
PCH header when instantiating those templates those warnings can be
emitted.  This doesn't show up on x86_64-linux build because configure
injects there -fcf-protection -mshstk flags during library build (and so
also during PCH header creation), but make check doesn't use those flags
and so the PCH header is ignored.

2024-09-26  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/116847
gcc/
* diagnostic.h (diagnostic_option_classifier): Add pch_save and
pch_restore method declarations.
(diagnostic_context): Add pch_save and pch_restore inline method
definitions.
* diagnostic.cc (diagnostic_option_classifier::pch_save): New method.
(diagnostic_option_classifier::pch_restore): Likewise.
gcc/c-family/
* c-pch.cc: Include diagnostic.h.
(c_common_write_pch): Call global_dc->pch_save.
(c_common_read_pch): Call global_dc->pch_restore.
gcc/testsuite/
* g++.dg/pch/pr116847.C: New test.
* g++.dg/pch/pr116847.Hs: New test.

10 months agodiagnostic: Use vec instead of custom array reallocations for m_classification_histor...
Jakub Jelinek [Fri, 27 Sep 2024 14:06:29 +0000 (16:06 +0200)] 
diagnostic: Use vec instead of custom array reallocations for m_classification_history/m_push_list [PR116847]

diagnostic.h already relies on vec.h, it uses auto_vec in one spot.

The following patch converts m_classification_history and m_push_list
hand-managed arrays to vec templates.
The main advantage is exponential rather than linear reallocation,
e.g. with current libstdc++ headers if one includes all the standard
headers there could be ~ 300 reallocations of the m_classification_history
array (sure, not all of them will result in actually copying the data, but
still).
In addition to that it fixes some formatting issues in the code.

2024-09-26  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/116847
* diagnostic.h (diagnostic_option_classifier): Change type
of m_classification_history from diagnostic_classification_change_t *
to vec<diagnostic_classification_change_t>.  Change type of
m_push_list from int * to vec<int>.  Remove m_n_classification_history
and m_n_push members.
* diagnostic.cc (diagnostic_option_classifier::init): Set m_push_list
to vNULL rather than nullptr.  Don't initialize m_n_push.  Initialize
m_classification_history to vNULL.
(diagnostic_option_classifier::fini): Call release () method on
m_push_list instead of free on it.  Call release () on
m_classification_history.  Don't clear m_n_push.
(diagnostic_option_classifier::push): Adjust for m_push_list and
m_classification_history being vectors rather than custom allocated
arrays with counter.
(diagnostic_option_classifier::pop): Likewise.
(classify_diagnostic): Adjust for m_classification_history being
vector rather than custom allocated array with counter.
(update_effective_level_from_pragmas): Likewise.

10 months agoi386: Modernize AMD processor types
Uros Bizjak [Fri, 27 Sep 2024 13:58:17 +0000 (15:58 +0200)] 
i386: Modernize AMD processor types

Use iterative PTA definitions for members of the same AMD processor family.

Also, fix a couple of related M_CPU_TYPE/M_CPU_SUBTYPE inconsistencies.

No functional changes intended.

gcc/ChangeLog:

* config/i386/i386.h: Add PTA_BDVER1, PTA_BDVER2, PTA_BDVER3,
PTA_BDVER4, PTA_BTVER1 and PTA_BTVER2.
* common/config/i386/i386-common.cc (processor_alias_table)
<"bdver1">: Use PTA_BDVER1.
<"bdver2">: Use PTA_BDVER2.
<"bdver3">: Use PTA_BDVER3.
<"bdver4">: Use PTA_BDVER4.
<"btver1">: Use PTA_BTVER1.  Use M_CPU_TYPE (AMD_BTVER1).
<"btver2">: Use PTA_BTVER2.
<"shanghai>: Use M_CPU_SUBTYPE (AMDFAM10H_SHANGHAI).
<"istanbul>: Use M_CPU_SUBTYPE (AMDFAM10H_ISTANBUL).

10 months agoWidening-Mul: Fix one ICE when iterate on phi node
Pan Li [Fri, 27 Sep 2024 03:03:51 +0000 (11:03 +0800)] 
Widening-Mul: Fix one ICE when iterate on phi node

We iterate all phi node of bb to try to match the SAT_* pattern
for scalar integer.  We also remove the phi mode when the relevant
pattern matched.

Unfortunately the iterator may have no idea the phi node is removed
and continue leverage the free data and then ICE similar as below.

[0] psi ptr 0x75216340c000
[0] psi ptr 0x75216340c400
[1] psi ptr 0xa5a5a5a5a5a5a5a5 <=== GC freed pointer.

during GIMPLE pass: widening_mul
tmp.c: In function ‘f’:
tmp.c:45:6: internal compiler error: Segmentation fault
   45 | void f(int rows, int cols) {
      |      ^
0x36e2788 internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:517
0x18005f0 crash_signal
        ../../gcc/toplev.cc:321
0x752163c4531f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x103ae0e bool is_a_helper<gphi*>::test<gimple>(gimple*)
../../gcc/gimple.h:1256
0x103f9a5 bool is_a<gphi*, gimple>(gimple*)
        ../../gcc/is-a.h:232
0x103dc78 gphi* as_a<gphi*, gimple>(gimple*)
../../gcc/is-a.h:255
0x104f12e gphi_iterator::phi() const
        ../../gcc/gimple-iterator.h:47
0x1a57bef after_dom_children
        ../../gcc/tree-ssa-math-opts.cc:6140
0x3344482 dom_walker::walk(basic_block_def*)
        ../../gcc/domwalk.cc:354
0x1a58601 execute
        ../../gcc/tree-ssa-math-opts.cc:6312

This patch would like to fix the iterate on modified collection problem
by backup the next phi in advance.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

PR middle-end/116861

gcc/ChangeLog:

* tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Backup
the next psi iterator before remove the phi node.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116861-1.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoFix sorting in Contributors.html
Richard Biener [Fri, 27 Sep 2024 12:54:07 +0000 (14:54 +0200)] 
Fix sorting in Contributors.html

The following moves my entry to where it belongs alphabetically
(it wasn't moved when s/Guenther/Biener/).

* doc/contrib.texi (Richard Biener): Move entry.

10 months agolibgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14 [PR116809]
Mark Mentovai [Tue, 24 Sep 2024 20:11:14 +0000 (16:11 -0400)] 
libgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14 [PR116809]

d9cafa0c4f0a stopped building libgcc_s.1 on macOS >= 15, in part because
that is required to bootstrap the compiler using the macOS 15 SDK. The
macOS 15 SDK ships in Xcode 16, which also runs on macOS 14. libgcc_s.1
can no longer be built on macOS 14 using Xcode 16 by the same logic that
the previous change disabled it for macOS 15.

PR target/116809

libgcc/ChangeLog:

* config.host: Don't build legacy libgcc_s.1 on macOS 14.

Signed-off-by: Mark Mentovai <mark@mentovai.com>
10 months agoc++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793]
Arsen Arsenović [Tue, 24 Sep 2024 16:16:01 +0000 (18:16 +0200)] 
c++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793]

If we reach a CLEANUP_POINT_EXPR while trying to walk statements, we
actually care about the statement or statement list contained within it.

Indeed, such a construction started happening with
r15-3513-g964577c31df206, after temporary promotion.  In the test case
presented in PR116793, the compiler generated:

  <<cleanup_point {
    struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3];
    int T002 [value-expr: frame_ptr->T002_2_3];

      int T002 [value-expr: frame_ptr->T002_2_3];
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (T002 = TARGET_EXPR <D.20994, 3>) >>>>>;
      struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3];
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (Aw0 = TARGET_EXPR <D.20995, func ((int &) &T002)>) >>>>>;
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (D.22450 = <<< Unknown tree: co_await
        TARGET_EXPR <D.20995, func ((int &) &T002)>
        Aw0

        {_cleanup_task::await_ready (&Aw0), _cleanup_task::await_suspend<_task1::promise_type> (&Aw0, TARGET_EXPR <D.21078, _Coro_self_handle>), <<< Unknown tree: aggr_init_expr
          4
          await_resume
          D.22443
          &Aw0 >>>}
        0 >>>) >>>>>;
    <<cleanup_point <<< Unknown tree: expr_stmt
      (void) (D.20991 = (struct tuple &) &D.22450) >>>>>;
  }
  D.22467 = 1;
  int & i [value-expr: frame_ptr->i_1_2];
  <<cleanup_point <<< Unknown tree: expr_stmt
    (void) (i = std::get<0, int&> (NON_LVALUE_EXPR <D.20991>)) >>>>>;>>;

... i.e. a statement list within a cleanup point.  In such a case, we
don't actually care about the cleanup point, but we do care about the
statement inside, so, we can just walk down into the CLEANUP_POINT_EXPR.

PR c++/116793

gcc/cp/ChangeLog:

* coroutines.cc (await_statement_expander): Just process
subtrees if encountering a CLEANUP_POINT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr116793-1.C: New test.

10 months agoc++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void
Arsen Arsenović [Fri, 20 Sep 2024 11:13:02 +0000 (13:13 +0200)] 
c++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void

convert_to_void has, so far, when converting a co_await expression to
void altered the await_resume expression of a co_await so that it is
also converted to void.  This meant that the type of the await_resume
expression, which is also supposed to be the type of the whole co_await
expression, was not the same as the type of the CO_AWAIT_EXPR tree.

While this has not caused problems so far, it is unexpected, I think.

Also, convert_to_void had a special case when an INDIRECT_REF wrapped a
CALL_EXPR.  In this case, we also diagnosed maybe_warn_nodiscard.  This
was a duplication of logic related to converting call expressions to
void.

Instead, we can generalize a bit, and rather discard the expression that
was implicitly dereferenced instead.

This patch changes the diagnostic of:

  void f(struct S* x) { static_cast<volatile S&>(*x); }

... from:

  warning: indirection will not access object of incomplete type
           'volatile S' in statement

... to:

  warning: implicit dereference will not access object of type
           ‘volatile S’ in statement

... but should have no impact in other cases.

gcc/cp/ChangeLog:

* coroutines.cc (co_await_get_resume_call): Return a tree
directly, rather than a tree pointer.
* cp-tree.h (co_await_get_resume_call): Adjust signature
accordingly.
* cvt.cc (convert_to_void): Do not alter CO_AWAIT_EXPRs when
discarding them.  Simplify handling implicit INDIRECT_REFs.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/nodiscard-1.C: New test.

10 months agoc++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502]
Arsen Arsenović [Wed, 28 Aug 2024 19:59:18 +0000 (21:59 +0200)] 
c++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502]

If such a diagnostic is necessary, it has already been emitted,
otherwise, it is not correct and emitting it here is inactionable by the
user, and bogus.

PR c++/116502

gcc/cp/ChangeLog:

* coroutines.cc (maybe_promote_temps): Convert temporary
initializers to void without complaining.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/maybe-unused-1.C: New test.
* g++.dg/coroutines/pr116502.C: New test.

10 months ago[MAINTAINERS]: Add myself as MVE Reviewer for the AArch32 (arm) port
Christophe Lyon [Fri, 27 Sep 2024 08:37:01 +0000 (10:37 +0200)] 
[MAINTAINERS]: Add myself as MVE Reviewer for the AArch32 (arm) port

ChangeLog:
* MAINTAINERS: Add myself as MVE Reviewer for the AArch32 (arm)
port.

10 months agolibgomp.texi: Remove now duplicate TR13 item
Tobias Burnus [Fri, 27 Sep 2024 10:06:17 +0000 (12:06 +0200)] 
libgomp.texi: Remove now duplicate TR13 item

Remove an item under "Other new TR 13 features" that since the last commit
(r15-3917-g6b7eaec20b046e) to this file is is covered by the added
  "New @code{storage} map-type modifier; context-dependent @code{alloc} and
   @code{release} are aliases"
  "Update of the map-type decay for mapping and @code{declare_mapper}"

libgomp/
* libgomp.texi (TR13 status): Update semi-duplicated, semi-obsoleted
item; remove left-over half-sentence.

10 months agoRISC-V/libgcc: Save/Restore routines for E goes with ABI.
Jim Lin [Fri, 27 Sep 2024 06:44:12 +0000 (14:44 +0800)] 
RISC-V/libgcc: Save/Restore routines for E goes with ABI.

That Save/Restore routines for E can be used for RVI with ILP32E ABI.

libgcc/ChangeLog:

* config/riscv/save-restore.S: Check with __riscv_abi_rve rather than
__riscv_32e.

10 months agolibgomp.texi: fix formatting; add post-TR13 OpenMP impl. status items
Tobias Burnus [Fri, 27 Sep 2024 08:48:09 +0000 (10:48 +0200)] 
libgomp.texi: fix formatting; add post-TR13 OpenMP impl. status items

libgomp/
* libgomp.texi (OpenMP Technical Report 13): Change @emph to @code;
add two post-TR13 OpenMP 6.0 items.