platform/upstream/gcc.git
18 months agolibstdc++: Add GDB printers for <chrono> types
Jonathan Wakely [Thu, 22 Dec 2022 01:15:55 +0000 (01:15 +0000)]
libstdc++: Add GDB printers for <chrono> types

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (StdChronoDurationPrinter)
(StdChronoTimePointPrinter, StdChronoZonedTimePrinter)
(StdChronoCalendarPrinter, StdChronoTimeZonePrinter)
(StdChronoLeapSecondPrinter, StdChronoTzdbPrinter)
(StdChronoTimeZoneRulePrinter): New printers.

18 months agolibstdc++: Implement C++20 time zone support in <chrono>
Jonathan Wakely [Thu, 22 Dec 2022 00:37:54 +0000 (00:37 +0000)]
libstdc++: Implement C++20 time zone support in <chrono>

This is the largest missing piece of C++20 support. Only the cxx11 ABI
is supported, due to the use of std::string in the API for time zones.
For the old gcc4 ABI, utc_clock and leap seconds are supported, but only
using a hardcoded list of leap seconds, no up-to-date tzdb::leap_seconds
information is available, and no time zones or zoned_time conversions.

The implementation currently depends on a tzdata.zi file being provided
by the OS or the user. The expected location is /usr/share/zoneinfo but
that can be changed using --with-libstdcxx-zoneinfo-dir=PATH. On targets
that support it there is also a weak symbol that users can override in
their own program (which also helps with testing):

extern "C++" const char* __gnu_cxx::zoneinfo_dir_override();

If no file is found, a fallback tzdb object will be created which only
contains the "Etc/UTC" and "Etc/GMT" time zones.

A leapseconds file is also expected in the same directory, but if that
isn't present then a hardcoded list of leapseconds is used, which is
correct at least as far as 2023-06-28 (and it currently looks like no
leap second will be inserted for a few years).

The tzdata.zi and leapseconds files from https://www.iana.org/time-zones
are in the public domain, so shipping copies of them with GCC would be
an option. However, the tzdata.zi file will rapidly become outdated, so
users should really provide it themselves (or convince their OS vendor
to do so). It would also be possible to implement an alternative parser
for the compiled tzdata files (one per time zone) under
/usr/share/zoneinfo. Those files are present on more operating systems,
but do not contain all the information present in tzdata.zi.
Specifically, the "links" are not present, so that e.g. "UTC" and
"Universal" are distinct time zones, rather than both being links to the
canonical "Etc/UTC" zone. For some platforms those files are hard links
to the same file, but there's no indication which zone is the canonical
name and which is a link. Other platforms just store them in different
inodes anyway. I do not plan to add such an alternative parser for the
compiled files. That would need to be contributed by maintainers or
users of targets that require it, if making tzdata.zi available is not
an option. The library ABI would not need to change for a new tzdb
implementation, because everything in tzdb_list, tzdb and time_zone is
implemented as a pimpl (except for the shared_ptr links between nodes,
described below). That means the new exported symbols added by this
commit should be stable even if the implementation is completely
rewritten.

The information from tzdata.zi is parsed and stored in data structures
that closely model the info in the file. This is a space-efficient
representation that uses less memory that storing every transition for
every time zone.  It also avoids spending time expanding that
information into time zone transitions that might never be needed by the
program.  When a conversion to/from a local time to UTC is requested the
information will be processed to determine the time zone transitions
close to the time being converted.

There is a bug in some time zone transitions. When generating a sys_info
object immediately after one that was previously generated, we need to
find the previous rule that was in effect and note its offset and
letters. This is so that the start time and abbreviation of the new
sys_info will be correct. This only affects time zones that use a format
like "C%sT" where the LETTERS replacing %s are non-empty for standard
time, e.g. "Asia/Shanghai" which uses "CST" for standard time and "CDT"
for daylight time.

The tzdb_list structure maintains a linked list of tzdb nodes using
shared_ptr links. This allows the iterators into the list to share
ownership with the list itself. This offers a non-portable solution to a
lifetime issue in the API. Because tzdb objects can be erased from the
list using tzdb_list::erase_after, separate modules/libraries in a large
program cannot guarantee that any const tzdb& or const time_zone*
remains valid indefinitely. Holding onto a tzdb_list::const_iterator
will extend the tzdb object's lifetime, even if it's erased from the
list. An alternative design would be for the list iterator to hold a
weak_ptr. This would allow users to test whether the tzdb still exists
when the iterator is dereferenced, which is better than just having a
dangling raw pointer. That doesn't actually extend the tzdb's lifetime
though, and every use of it would need to be preceded by checking the
weak_ptr. Using shared_ptr adds a little bit of overhead but allows
users to solve the lifetime issue if they rely on the libstdc++-specific
iterator property.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ZONEINFO_DIR): New macro.
* config.h.in: Regenerate.
* config/abi/pre/gnu.ver: Export new symbols.
* configure: Regenerate.
* configure.ac (GLIBCXX_ZONEINFO_DIR): Use new macro.
* include/std/chrono (utc_clock::from_sys): Correct handling
of leap seconds.
(nonexistent_local_time::_M_make_what_str): Define.
(ambiguous_local_time::_M_make_what_str): Define.
(__throw_bad_local_time): Define new function.
(time_zone, tzdb_list, tzdb): Implement all members.
(remote_version, zoned_time, get_leap_second_info): Define.
* include/std/version: Add comment for __cpp_lib_chrono.
* src/c++20/Makefile.am: Add new file.
* src/c++20/Makefile.in: Regenerate.
* src/c++20/tzdb.cc: New file.
* testsuite/lib/libstdc++.exp: Define effective target tzdb.
* testsuite/std/time/clock/file/members.cc: Check file_time
alias and file_clock::now() member.
* testsuite/std/time/clock/gps/1.cc: Likewise for gps_clock.
* testsuite/std/time/clock/tai/1.cc: Likewise for tai_clock.
* testsuite/std/time/syn_c++20.cc: Uncomment everything except
parse.
* testsuite/std/time/clock/utc/leap_second_info.cc: New test.
* testsuite/std/time/exceptions.cc: New test.
* testsuite/std/time/time_zone/get_info_local.cc: New test.
* testsuite/std/time/time_zone/get_info_sys.cc: New test.
* testsuite/std/time/time_zone/requirements.cc: New test.
* testsuite/std/time/tzdb/1.cc: New test.
* testsuite/std/time/tzdb/leap_seconds.cc: New test.
* testsuite/std/time/tzdb_list/1.cc: New test.
* testsuite/std/time/tzdb_list/requirements.cc: New test.
* testsuite/std/time/zoned_time/1.cc: New test.
* testsuite/std/time/zoned_time/custom.cc: New test.
* testsuite/std/time/zoned_time/deduction.cc: New test.
* testsuite/std/time/zoned_time/req_neg.cc: New test.
* testsuite/std/time/zoned_time/requirements.cc: New test.
* testsuite/std/time/zoned_traits.cc: New test.

18 months agocompiler: remove unused fields
Ian Lance Taylor [Wed, 21 Dec 2022 20:00:13 +0000 (12:00 -0800)]
compiler: remove unused fields

This avoids clang warnings:

gcc/go/gofrontend/escape.cc:1290:17: warning: private field 'fn_' is not used [-Wunused-private-field]
gcc/go/gofrontend/escape.cc:3478:19: warning: private field 'context_' is not used [-Wunused-private-field]
gcc/go/gofrontend/lex.h:564:15: warning: private field 'input_file_name_' is not used [-Wunused-private-field]
gcc/go/gofrontend/types.cc:5788:20: warning: private field 'call_' is not used [-Wunused-private-field]
gcc/go/gofrontend/wb.cc:206:9: warning: private field 'gogo_' is not used [-Wunused-private-field]

Path by Martin Liška.

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

18 months agoFortran: check for invalid uses of statement functions arguments [PR69604]
Harald Anlauf [Thu, 22 Dec 2022 21:03:31 +0000 (22:03 +0100)]
Fortran: check for invalid uses of statement functions arguments [PR69604]

gcc/fortran/ChangeLog:

PR fortran/69604
* match.cc (chk_stmt_fcn_body): New function.  Check for invalid uses
of statement functions arguments.
(gfc_match_st_function): Use above.

gcc/testsuite/ChangeLog:

PR fortran/69604
* gfortran.dg/statement_function_4.f90: New test.

18 months agodocs: Fix peephole paragraph ordering
Andrew Carlotti [Sun, 18 Dec 2022 02:52:02 +0000 (02:52 +0000)]
docs: Fix peephole paragraph ordering

The documentation for the DONE and FAIL macros was incorrectly inserted
between example code, and a remark attached to that example.

gcc/ChangeLog:

* doc/md.texi: Move example code remark next to it's code block.

18 months agodocs: Fix inconsistent example predicate name
Andrew Carlotti [Fri, 16 Dec 2022 15:14:35 +0000 (15:14 +0000)]
docs: Fix inconsistent example predicate name

It is unclear why the example C function was renamed to
`commutative_integer_operator` as part of ec8e098d in 2004, while the
text and the example md were both left as `commutative_operator`. The
latter name appears to be more accurate, so revert the 2004 change.

gcc/ChangeLog:

* doc/md.texi: Fix inconsistent example name.

18 months agodocs: Link to correct section for constraint modifiers
Andrew Carlotti [Fri, 16 Dec 2022 15:11:18 +0000 (15:11 +0000)]
docs: Link to correct section for constraint modifiers

gcc/ChangeLog:

* doc/md.texi: Fix incorrect pxref.

18 months agobootstrap/106482 - document minimal GCC version
Richard Biener [Thu, 22 Dec 2022 14:51:46 +0000 (15:51 +0100)]
bootstrap/106482 - document minimal GCC version

There's no explicit mention of what GCC compiler supports C++11
and the cross compiler build requirement mentions GCC 4.8 but not
GCC 4.8.3 which is the earliest known version to not run into
C++11 implementation bugs.  The following adds explicit wording.

PR bootstrap/106482
* doc/install.texi (ISO C++11 Compiler): Document GCC version
known to work.

18 months agotestsuite/107809 - fix vect-recurr testcases
Richard Biener [Thu, 22 Dec 2022 13:20:40 +0000 (14:20 +0100)]
testsuite/107809 - fix vect-recurr testcases

This adds a missing effective target check for the permute
recurrence vectorization requires.

PR testsuite/107809
* gcc.dg/vect/vect-recurr-1.c: Require vect_perm.
* gcc.dg/vect/vect-recurr-2.c: Likewise.
* gcc.dg/vect/vect-recurr-3.c: Likewise.
* gcc.dg/vect/vect-recurr-4.c: Likewise.
* gcc.dg/vect/vect-recurr-5.c: Likewise.
* gcc.dg/vect/vect-recurr-6.c: Likewise.

18 months agophiopt: Drop SSA_NAME_RANGE_INFO in maybe equal case [PR108166]
Jakub Jelinek [Thu, 22 Dec 2022 11:52:48 +0000 (12:52 +0100)]
phiopt: Drop SSA_NAME_RANGE_INFO in maybe equal case [PR108166]

The following place in value_replacement is after proving that
x == cst1 ? cst2 : x
phi result is only used in a comparison with constant which doesn't
care if it compares cst1 or cst2 and replaces it with x.
The testcase is miscompiled because we have after the replacement
incorrect range info for the phi result, we would need to
effectively union the phi result range with cst1 (oarg in the code)
because previously that constant might be missing in the range, but
newly it can appear (we've just verified that the single use stmt
of the phi result doesn't care about that value in particular).

The following patch just resets the info, bootstrapped/regtested
on x86_64-linux and i686-linux, ok for trunk?

Aldy/Andrew, how would one instead union the SSA_NAME_RANGE_INFO
with some INTEGER_CST and store it back into SSA_NAME_RANGE_INFO
(including adjusting non-zero bits and the like)?

2022-12-22  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/108166
* tree-ssa-phiopt.cc (value_replacement): For the maybe_equal_p
case turned into equal_p reset SSA_NAME_RANGE_INFO of phi result.

* g++.dg/torture/pr108166.C: New test.

18 months agocse: Fix up CSE const_anchor handling [PR108193]
Jakub Jelinek [Thu, 22 Dec 2022 11:44:13 +0000 (12:44 +0100)]
cse: Fix up CSE const_anchor handling [PR108193]

The following testcase ICEs on aarch64, because insert_const_anchor
inserts invalid CONST_INT into the CSE tables - 0x80000000 for SImode.
The second hunk of the patch fixes that, the first one is to avoid
triggering undefined behavior at compile time during compute_const_anchors
computations - performing those additions and subtractions in
HOST_WIDE_INT means it can overflow for certain constants.

2022-12-22  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/108193
* cse.cc (compute_const_anchors): Change n type to
unsigned HOST_WIDE_INT, adjust comparison against it to avoid
warnings.  Formatting fix.
(insert_const_anchor): Use gen_int_mode instead of GEN_INT.

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

18 months agotree-optimization/107451 - SLP load vectorization issue
Richard Biener [Thu, 22 Dec 2022 08:36:17 +0000 (09:36 +0100)]
tree-optimization/107451 - SLP load vectorization issue

When vectorizing SLP loads with permutations we can access excess
elements when the load vector type is bigger than the group size
and the vectorization factor covers less groups than necessary
to fill it.  Since we know the code will only access up to
group_size * VF elements in the unpermuted vector we can simply
fill the rest of the vector with whatever we want.  For simplicity
this patch chooses to repeat the last group.

PR tree-optimization/107451
* tree-vect-stmts.cc (vectorizable_load): Avoid loading
SLP group members from group numbers in excess of the
vectorization factor.

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

18 months agoaarch64: Fix plugin header install
Jakub Jelinek [Thu, 22 Dec 2022 10:15:47 +0000 (11:15 +0100)]
aarch64: Fix plugin header install

The r13-2943-g11a113d501ff64 made aarch64.h include
aarch64-option-extensions.def, but that file isn't installed
for building plugins.

On Wed, Dec 21, 2022 at 09:56:33AM +0000, Richard Sandiford wrote:
> Should this (and aarch64-fusion-pairs.def and aarch64-tuning-flags.def)
> be in TM_H instead?  The first two OPTIONS_H_EXTRA entries seem to be
> for aarch64-opt.h (included via aarch64.opt).
>
> I guess TM_H should also have aarch64-arches.def, since it's included
> for aarch64_feature.

gcc/Makefile.in has
TM_H      = $(GTM_H) insn-flags.h $(OPTIONS_H)
and
OPTIONS_H = options.h flag-types.h $(OPTIONS_H_EXTRA)
which means that adding something into TM_H when it is already in
OPTIONS_H_EXTRA is a unnecessary.
It is true that aarch64-fusion-pairs.def (included by aarch64-protos.h)
and aarch64-tuning-flags.def (ditto) and aarch64-option-extensions.def
(included by aarch64.h) aren't needed for options.h, so I think the
right patch would be following.

2022-12-22  Jakub Jelinek  <jakub@redhat.com>

* config/aarch64/t-aarch64 (TM_H): Don't add aarch64-cores.def,
add aarch64-fusion-pairs.def, aarch64-tuning-flags.def and
aarch64-option-extensions.def.
(OPTIONS_H_EXTRA): Don't add aarch64-fusion-pairs.def nor
aarch64-tuning-flags.def.

18 months agolibstdc++: Define and use variable templates in <chrono>
Jonathan Wakely [Thu, 22 Dec 2022 00:23:19 +0000 (00:23 +0000)]
libstdc++: Define and use variable templates in <chrono>

Thi defines a variable template for the internal __is_duration helper
trait, defines a new __is_time_point_v variable template (to be used in
a subsequent commit), and adds explicit specializations of the standard
chrono::treat_as_floating_point trait for common types.

A fast path is added to chrono::duration_cast for the no-op case where
no conversion is needed.

Finally, some SFINAE constraints are simplified by using the
__enable_if_t alias, or by using variable templates.

libstdc++-v3/ChangeLog:

* include/bits/chrono.h (__is_duration_v, __is_time_point_v):
New variable templates.
(duration_cast): Add simplified definition for noconv case.
(treat_as_floating_point_v): Add explicit specializations.
(duration::operator%=, floor, ceil, round): Simplify SFINAE
constraints.

18 months agolibstdc++: Add [[nodiscard]] in <chrono>
Jonathan Wakely [Thu, 22 Dec 2022 00:19:45 +0000 (00:19 +0000)]
libstdc++: Add [[nodiscard]] in <chrono>

libstdc++-v3/ChangeLog:

* include/std/chrono: Use nodiscard attribute.

18 months agoZen4 tuning part 2
Jan Hubicka [Thu, 22 Dec 2022 09:55:46 +0000 (10:55 +0100)]
Zen4 tuning part 2

Adds tunes needed for zen4 microarchitecture.  I added two new knobs.
TARGET_AVX512_SPLIT_REGS which is used to specify that internally 512 vectors
are split to 256 vectors.  This affects vectorization costs and reassociation
width. It probably should also affect RTX costs however I doubt it is very useful
since RTL optimizers are usually not judging between 256 and 512 vectors.

I also added X86_TUNE_AVOID_256FMA_CHAINS. Since fma has improved in zen4 this
flag may not be a win except for very specific benchmarks. I am still doing some
more detailed testing here.

Oherwise I disabled gathers on zen4 for 2 parts nad 4 parts. We can open code them
and since the latencies has only increased since zen3 opencoding is better than
actual instrucction.  This shows at 4 tsvc benchmarks.

I ended up setting AVX256_OPTIMAL. This is a compromise.  There are some tsvc
benchmarks that increase noticeably (up to 250%) however there are also few
regressions.  Most of these can be solved by incrasing vec_perm cost in the
vectorizer.  However this does not cure about 14% regression on x264 that is
quite important.  Here we produce vectorized loops for avx512 that probably
would be faster if the loops in question had high enough iteration count.
We hit this problem with avx256 too: since the loop iterates few times, only
prologues/epilogues are used.  Adding another round of prologue/epilogue
code does not make it better.

Finally I enabled avx stores for constnat sized memcpy and memset.  I am not
sure why this is an opt-in feature.  I think for most hardware this is a win.

gcc/ChangeLog:

2022-12-22  Jan Hubicka  <hubicka@ucw.cz>

* config/i386/i386-expand.cc (ix86_expand_set_or_cpymem): Add
TARGET_AVX512_SPLIT_REGS
* config/i386/i386-options.cc (ix86_option_override_internal):
Honor x86_TONE_AVOID_256FMA_CHAINS.
* config/i386/i386.cc (ix86_vec_cost): Honor TARGET_AVX512_SPLIT_REGS.
(ix86_reassociation_width): Likewise.
* config/i386/i386.h (TARGET_AVX512_SPLIT_REGS): New tune.
* config/i386/x86-tune.def (X86_TUNE_USE_GATHER_2PARTS): Disable
for znver4.
(X86_TUNE_USE_GATHER_4PARTS): Likewise.
(X86_TUNE_AVOID_256FMA_CHAINS): Set for znver4.
(X86_TUNE_AVOID_512FMA_CHAINS): New utne; set for znver4.
(X86_TUNE_AVX256_OPTIMAL): Add znver4.
(X86_TUNE_AVX512_SPLIT_REGS): New tune.
(X86_TUNE_AVX256_MOVE_BY_PIECES): Add znver1-3.
(X86_TUNE_AVX256_STORE_BY_PIECES): Add znver1-3.
(X86_TUNE_AVX512_MOVE_BY_PIECES): Add znver4.
(X86_TUNE_AVX512_STORE_BY_PIECES): Add znver4.

18 months agoCompare DECL_NOT_FLEXARRAY for LTO tree merging
Richard Biener [Thu, 22 Dec 2022 07:08:12 +0000 (08:08 +0100)]
Compare DECL_NOT_FLEXARRAY for LTO tree merging

This was missing.

gcc/lto/
* lto-common.cc (compare_tree_sccs_1): Compare DECL_NOT_FLEXARRAY.

18 months agoUpdate znver4 costs
Jan Hubicka [Thu, 22 Dec 2022 01:16:24 +0000 (02:16 +0100)]
Update znver4 costs

Update cost of znver4 mostly based on data measued by Agner Fog.
Compared to previous generations x87 became bit slower which is probably not
big deal (and we have minimal benchmarking coverage for it).  One interesting
improvement is reducation of FMA cost.  I also updated costs of AVX256
loads/stores  based on latencies (not throughput which is twice of avx256).
Overall AVX512 vectorization seems to improve noticeably some of TSVC
benchmarks but since internally 512 vectors are split to 256 vectors it is
somewhat risky and does not win in SPEC scores (mostly by regressing benchmarks
with loop that have small trip count like x264 and exchange), so for now I am
going to set AVX256_OPTIMAL tune but I am still playing with it.  We improved
since ZNVER1 on choosing vectorization size and also have vectorized
prologues/epilogues so it may be possible to make avx512 small win overall.

2022-12-22  Jan Hubicka  <hubicka@ucw.cz>

* config/i386/x86-tune-costs.h (znver4_cost): Upate costs of FP and SSE
moves, division multiplication, gathers, L2 cache size, and more
complex FP instrutions.

18 months agoDaily bump.
GCC Administrator [Thu, 22 Dec 2022 00:17:29 +0000 (00:17 +0000)]
Daily bump.

18 months agotestsuite: Fix pr55569.c excess errors on LLP64
Jonathan Yong [Tue, 20 Dec 2022 09:16:16 +0000 (09:16 +0000)]
testsuite: Fix pr55569.c excess errors on LLP64

This fixes the following on LLP64 mingw-w64 target:

Excess errors:
gcc/testsuite/gcc.c-torture/compile/pr55569.c:13:12: warning: overflow in conversion from 'long long unsigned int' to 'long int' changes value from '4611686018427387903' to '-1' [-Woverflow]
gcc/testsuite/gcc.c-torture/compile/pr55569.c:13:34: warning: iteration 2147483647 invokes undefined behavior [-Waggressive-loop-optimizations]

gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/pr55569.c: fix excess errors.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
18 months agoFix PR 105532: match.pd patterns calling tree_nonzero_bits with vector types
Andrew Pinski [Wed, 2 Nov 2022 15:56:31 +0000 (15:56 +0000)]
Fix PR 105532: match.pd patterns calling tree_nonzero_bits with vector types

Even though this PR was reported with an ubsan issue, the problem is
tree_nonzero_bits is being called with an expression which is a vector type.
This fixes three patterns I noticed which does that.
And adds a testcase for one of the patterns.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions

gcc/ChangeLog:

PR tree-optimization/105532
* match.pd (~(X >> Y) -> ~X >> Y): Check if it is an integral
type before calling tree_nonzero_bits.
(popcount(X) + popcount(Y)): Likewise.
(popcount(X&C1)): Likewise.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/vector-shift-1.c: New test.

19 months ago[PATCH] Use toplevel configure for GMP and MPFR for gdb
Andrew Pinski [Wed, 21 Dec 2022 16:58:40 +0000 (16:58 +0000)]
[PATCH] Use toplevel configure for GMP and MPFR for gdb

[Sync'ed from the binutils-gdb repo]
This patch uses the toplevel configure parts for GMP/MPFR for
gdb. The only thing is that gdb now requires MPFR for building.
Before it was a recommended but not required library.
Also this allows building of GMP and MPFR with the toplevel
directory just like how it is done for GCC.
We now error out in the toplevel configure of the version
of GMP and MPFR that is wrong.

OK after GDB 13 branches? Build gdb 3 ways:
with GMP and MPFR in the toplevel (static library used at that point for both)
With only MPFR in the toplevel (GMP distro library used and MPFR built from source)
With neither GMP and MPFR in the toplevel (distro libraries used)

Changes from v1:
* Updated gdb/README and gdb/doc/gdb.texinfo.
* Regenerated using unmodified autoconf-2.69

Thanks,
Andrew Pinski

ChangeLog:
* Makefile.def: Add configure-gdb dependencies
on all-gmp and all-mpfr.
* configure.ac: Split out MPC checking from MPFR.
Require GMP and MPFR if the gdb directory exist.
* Makefile.in: Regenerate.
* configure: Regenerate.

19 months agonvptx: reimplement libgomp barriers [PR99555]
Chung-Lin Tang [Wed, 21 Dec 2022 13:57:45 +0000 (05:57 -0800)]
nvptx: reimplement libgomp barriers [PR99555]

Instead of trying to have the GPU do CPU-with-OS-like things, this new barriers
implementation for NVPTX uses simplistic bar.* synchronization instructions.
Tasks are processed after threads have joined, and only if team->task_count != 0

It is noted that: there might be a little bit of performance forfeited for
cases where earlier arriving threads could've been used to process tasks ahead
of other threads, but that has the requirement of implementing complex
futex-wait/wake like behavior, which is what we're try to avoid with this patch.
It is deemed that task processing is not what GPU target offloading is usually
used for.

Implementation highlight notes:
1. gomp_team_barrier_wake() is now an empty function (threads never "wake" in
   the usual manner)
2. gomp_team_barrier_cancel() now uses the "exit" PTX instruction.
3. gomp_barrier_wait_last() now is implemented using "bar.arrive"

4. gomp_team_barrier_wait_end()/gomp_team_barrier_wait_cancel_end():
   The main synchronization is done using a 'bar.red' instruction. This reduces
   across all threads the condition (team->task_count != 0), to enable the task
   processing down below if any thread created a task.
   (this bar.red usage means that this patch is dependent on the prior NVPTX
   bar.red GCC patch)

PR target/99555

libgomp/ChangeLog:

* config/nvptx/bar.c (generation_to_barrier): Remove.
(futex_wait,futex_wake,do_spin,do_wait): Remove.
(GOMP_WAIT_H): Remove.
(#include "../linux/bar.c"): Remove.
(gomp_barrier_wait_end): New function.
(gomp_barrier_wait): Likewise.
(gomp_barrier_wait_last): Likewise.
(gomp_team_barrier_wait_end): Likewise.
(gomp_team_barrier_wait): Likewise.
(gomp_team_barrier_wait_final): Likewise.
(gomp_team_barrier_wait_cancel_end): Likewise.
(gomp_team_barrier_wait_cancel): Likewise.
(gomp_team_barrier_cancel): Likewise.
* config/nvptx/bar.h (gomp_barrier_t): Remove waiters, lock fields.
(gomp_barrier_init): Remove init of waiters, lock fields.
(gomp_team_barrier_wake): Remove prototype, add new static inline
function.

19 months agonvptx: support bar.red instruction
Chung-Lin Tang [Wed, 21 Dec 2022 13:26:06 +0000 (05:26 -0800)]
nvptx: support bar.red instruction

This patch adds support for the PTX 'bar.red' (i.e. "barrier reduction")
instruction, in the form of nvptx-specific __builtin_nvptx_bar_red_[and/or/popc]
built-in functions.

gcc/ChangeLog:

* config/nvptx/nvptx.cc (nvptx_print_operand): Add 'p' case, adjust
comments.
(enum nvptx_builtins): Add NVPTX_BUILTIN_BAR_RED_AND,
NVPTX_BUILTIN_BAR_RED_OR, and NVPTX_BUILTIN_BAR_RED_POPC.
(nvptx_expand_bar_red): New function.
(nvptx_init_builtins):
Add DEFs of __builtin_nvptx_bar_red_[and/or/popc].
(nvptx_expand_builtin): Use nvptx_expand_bar_red to expand
NVPTX_BUILTIN_BAR_RED_[AND/OR/POPC] cases.

* config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
UNSPECV_BARRED_AND, UNSPECV_BARRED_OR, and UNSPECV_BARRED_POPC.
(BARRED): New int iterator.
(barred_op,barred_mode,barred_ptxtype): New int attrs.
(nvptx_barred_<barred_op>): New define_insn.

19 months agolibffi: Update LOCAL_PATCHES.
Iain Sandoe [Wed, 21 Dec 2022 13:10:16 +0000 (13:10 +0000)]
libffi: Update LOCAL_PATCHES.

Add the patch that fixes i686 Darwin build.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libffi/ChangeLog:

* LOCAL_PATCHES: Add patch to fix i686 darwin build.

19 months agolibffi: Fix X86 32b Darwin build and EH frames.
Iain Sandoe [Sun, 18 Dec 2022 11:24:43 +0000 (11:24 +0000)]
libffi: Fix X86 32b Darwin build and EH frames.

This addresses a number of issues in the X86 Darwin 32b port for libffi.

1. The pic symbol stubs are weak definitions; the correct section placement
   for these depends on the linker version in use.  We do not have access
   to that information, but we can use the target OS version (assumes that
   the user has installed the latest version of xcode available).
   When a coalesced section is in use (OS versions earlier than Darwin12 /
   OSX 10.8), its name must differ from  __TEXT,__text since otherwise that
   would correspond to altering the attributes of the .text section (which
   produces a diagnostic from the assembler).
   Here we use __TEXT, __textcoal_nt for this which is what GCC emits for
   these stubs.
   For later versions than Darwin 12 (OS X 10.8) we can place the stubs in
   the .text section (if we do not we get a diagnostic from clang -cc1as
   saying that the use of coalesced sections for this is deprecated).

2. The EH frame is specified manually, since there is no support for .cfi_
   directives in 'cctools' assemblers.  The implementation needs to provide
   offsets for CFA advance, code size and to the CIE as signed values
   rather than relocations. However the cctools assembler will produce a
   relocation for expressions like ' .long Lxx-Lyy' which then leads to a
   link-time error.  We correct this by forming the offset values using
   ' .set' directives and then assigning the results of them.

3. The register numbering used by m32 X86 Darwin EH frames is not the same
   as the DWARF debug numbering (the Frame and Stack pointer numbers are
   swapped).

4. The FDE address encoding used by the system tools is '0x10' (PCrel + abs)
   where the value provided was PCrel + sdata4.

5. GCC does not use compact unwind at present, and it was not implemented
   until Darwin10 / OSX 10.6.  There were some issues with function location
   in 10.6 so that the solution here suppresses emitting the compact unwind
   section until Darwin11 / OSX 10.7.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libffi/ChangeLog:

* src/x86/sysv.S (COMDAT): Amend section use for Darwin, accounting
cases where coalesced is needed. (eh_frame): Rework to avoid relocs
that cause builf fails on earlier Darwin.  Adjust register numbers
to account for X86 m32 Darwin differences between EH and debug.

19 months agomiddle-end/107994 - ICE after error with comparison gimplification
Richard Biener [Wed, 21 Dec 2022 11:27:58 +0000 (12:27 +0100)]
middle-end/107994 - ICE after error with comparison gimplification

The following avoids passing down error_mark_node to fold_convert.

PR middle-end/107994
* gimplify.cc (gimplify_expr): Catch errorneous comparison
operand.

19 months agoSkip -fwhole-program when merging LTO options.
Jan Hubicka [Wed, 21 Dec 2022 11:45:56 +0000 (12:45 +0100)]
Skip -fwhole-program when merging LTO options.

gcc/ChangeLog:

2022-12-21  Jan Hubicka  <hubicka@ucw.cz>

* lto-opts.cc (lto_write_options): Also skip -fwhole-program.

19 months agoWhen doing WPA in incremental link pass down resolution info.
Jan Hubicka [Wed, 21 Dec 2022 11:44:11 +0000 (12:44 +0100)]
When doing WPA in incremental link pass down resolution info.

* lto-cgraph.cc (lto_output_node): When doing WPA in incremental link
pass down resolution info.

19 months agoMake -fwhole-program to work with incremental LTO linking
Jan Hubicka [Wed, 21 Dec 2022 11:41:25 +0000 (12:41 +0100)]
Make -fwhole-program to work with incremental LTO linking

Update documentation of -fwhole-program which was wrongly
claiming that it is useless with LTO whole it is useful for LTO without plugin
and extends -fwhole-program to also work with incremental linking.
This is useful when building kernel where the incremental link is de-facto fina
binary and only some explicitly marked symbols needs to remain.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

2022-12-21  Jan Hubicka  <hubicka@ucw.cz>

* doc/invoke.texi: Fix documentation of -fwhole-program with LTO
and document behaviour for incremental linking.

gcc/lto/ChangeLog:

2022-12-21  Jan Hubicka  <hubicka@ucw.cz>

* lto-common.cc (lto_resolution_read): With incremental linking
and whole program ignore turn LDPR_PREVAILING_DEF_IRONLY to
LDPR_PREVAILING_DEF_IRONLY_EXP
* lto-lang.cc (lto_post_options): Do not clear flag_whole_program
for incremental link

19 months agomodula2: Fix lto profiledbootstrap on powerpc64le-linux and s390x-linux [PR108153]
Jakub Jelinek [Wed, 21 Dec 2022 08:10:35 +0000 (09:10 +0100)]
modula2: Fix lto profiledbootstrap on powerpc64le-linux and s390x-linux [PR108153]

Lto profiledbootstrap was failing for me on {powerpc64le,s390x}-linux with
modula 2 enabled, with:
cc1gm2: internal compiler error: the location value is corrupt
0x11a3d2d m2assert_AssertLocation(unsigned int)
../../gcc/m2/gm2-gcc/m2assert.cc:40
0x11a3d2d m2statement_BuildAssignmentTree
../../gcc/m2/gm2-gcc/m2statement.cc:177
ICE.  The problem was that caller (m2assert_AssertLocation used
location_t M2Options_OverrideLocation (location_t);
prototype with the libcpp/line-map.h
typedef unsigned int location_t;
typedef, but the callee defined in Modula 2 was using:
TYPE
   location_t = INTEGER ;
and
PROCEDURE OverrideLocation (location: location_t) : location_t ;
Now, on powerpc64le-linux unsigned int is returned and passed zero extended
into 64-bits, while signed int is returned and passed sign-extended into 64-bits
and Modula 2 INTEGER is signed 32-bit type, so when the caller then compared
M2Options_OverrideLocation (location) != location
and powerpc64le-linux performed the comparison as 64-bit compare, there
was a mismatch for location_t of 0x8000007 or others with the MSB set.

Fixed by making Modula 2 location_t a CARDINAL, which is 32-bit unsigned type.

2022-12-21  Jakub Jelinek  <jakub@redhat.com>

PR modula2/108153
* gm2-gcc/m2linemap.def (location_t): Use CARDINAL instead of INTEGER.

19 months agocontrib: simplify filter-clang-warnings.py
Martin Liska [Wed, 21 Dec 2022 08:10:07 +0000 (09:10 +0100)]
contrib: simplify filter-clang-warnings.py

contrib/ChangeLog:

* filter-clang-warnings.py: Simplify.

19 months agoopenmp: Don't try to destruct DECL_OMP_PRIVATIZED_MEMBER vars [PR108180]
Jakub Jelinek [Wed, 21 Dec 2022 08:05:27 +0000 (09:05 +0100)]
openmp: Don't try to destruct DECL_OMP_PRIVATIZED_MEMBER vars [PR108180]

DECL_OMP_PRIVATIZED_MEMBER vars are artificial vars with DECL_VALUE_EXPR
of this->field used just during gimplification and omp lowering/expansion
to privatize individual fields in methods when needed.
As the following testcase shows, when not in templates, they were handled
right, but in templates we actually called cp_finish_decl on them and
that can result in their destruction, which is obviously undesirable,
we should only destruct the privatized copies of them created in omp
lowering.

Fixed thusly.

2022-12-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/108180
* pt.cc (tsubst_expr): Don't call cp_finish_decl on
DECL_OMP_PRIVATIZED_MEMBER vars.

* testsuite/libgomp.c++/pr108180.C: New test.

19 months agocontrib: filter out more unrelated warnings
Martin Liska [Wed, 21 Dec 2022 08:08:24 +0000 (09:08 +0100)]
contrib: filter out more unrelated warnings

contrib/ChangeLog:

* filter-clang-warnings.py: Skip Makefile and libffi warnings.

19 months agolibgccjit: silent 2 Clang warnings
Martin Liska [Wed, 21 Dec 2022 07:52:35 +0000 (08:52 +0100)]
libgccjit: silent 2 Clang warnings

The make silent the following 2 warnings:

jit/jit-playback.h:785:16: warning: private field 'm_source_file' is not used [-Wunused-private-field]
jit/jit-playback.h:804:16: warning: private field 'm_line' is not used [-Wunused-private-field]

gcc/jit/ChangeLog:

* jit-playback.h: Use unused attribute.

19 months agolibstdc++: Don't call 4-5 argument to_chars with chars_format{}
Jakub Jelinek [Wed, 21 Dec 2022 08:04:06 +0000 (09:04 +0100)]
libstdc++: Don't call 4-5 argument to_chars with chars_format{}

In Fedora build libstdc++.so is built with assertions enabled and
FAIL: 20_util/to_chars/float128_c++23.cc execution test
was failing on all arches.  The problem is that it called 5 argument version
of to_chars with chars_format{}, which C++ says is invalid:
http://eel.is/c++draft/charconv.to.chars#12
Preconditions: fmt has the value of one of the enumerators of chars_format.

The following patch fixes it by skipping the second part of the test
which needs the 5 argument to_chars for chars_format{}, but because
it is strictly speaking invalid also for 4 argument to_chars, it uses
3 argument to_chars instead of 4 argument to_chars with last argument
chars_format{}.

2022-12-21  Jakub Jelinek  <jakub@redhat.com>

* testsuite/20_util/to_chars/float16_c++23.cc (test): Use 3 argument
std::to_chars if fmt is std::chars_format{}, rather than 4 argument.
* testsuite/20_util/to_chars/float128_c++23.cc (test): Likewise, and
skip second part of testing that requires 5 argument std::to_chars.

19 months agogfortran.dg/read_dir.f90: Make PASS on Windows
Tobias Burnus [Wed, 21 Dec 2022 07:06:29 +0000 (08:06 +0100)]
gfortran.dg/read_dir.f90: Make PASS on Windows

On non-Cygwin Windows, use '.' and expect the documented fail when opening
a directory (EACCESS).  As gfortran does not set __WIN32__ this check is
done on the C side. (On __CYGWIN__, __WIN32__ is not set - but to make it
clear, !__CYGWIN__ is used in #if.)

On non-Windows, replace the 'call system' shell call by the POSIX functions
stat/mkdir/rmdir for better compatibility, especially on embedded systems;
additionally add some more checks. In particular, confirm that 'close' with
status='delete' indeed deleted the directory.

gcc/testsuite/ChangeLog:

* gfortran.dg/read_dir-aux.c: New; provides my_mkdir, my_rmdir,
my_verify_not_exists and expect_open_to_fail.
* gfortran.dg/read_dir.f90: Call those; expect that opening a
directory fails on Windows.

19 months agolibgo: check for makecontext in -lucontext
Ian Lance Taylor [Mon, 19 Dec 2022 18:37:06 +0000 (10:37 -0800)]
libgo: check for makecontext in -lucontext

Patch from Sören Tempel.

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

19 months agors6000: Fix the wrong location of OPTION_MASK_P10_FUSION setting hunk
Kewen Lin [Wed, 21 Dec 2022 03:06:15 +0000 (21:06 -0600)]
rs6000: Fix the wrong location of OPTION_MASK_P10_FUSION setting hunk

The hunk for setting flag OPTION_MASK_P10_FUSION locates wrongly
between the if and else if block for OPTION_MASK_MMA.  This is
to fix this oversight accordingly.

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_option_override_internal): Fix the
location for OPTION_MASK_P10_FUSION flag setting.

19 months agofold-const: Treat fp conversion to a type with same mode as copy
Kewen Lin [Wed, 21 Dec 2022 03:04:54 +0000 (21:04 -0600)]
fold-const: Treat fp conversion to a type with same mode as copy

In function fold_convert_const_real_from_real, when the modes of
two types involved in fp conversion are the same, we can simply
take it as copy, rebuild with the exactly same TREE_REAL_CST and
the target type.  It is more efficient and helps to avoid possible
unexpected signalling bit clearing in [1].

[1] https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608533.html

gcc/ChangeLog:

* fold-const.cc (fold_convert_const_real_from_real): Treat floating
point conversion to a type with same mode as copy instead of normal
convertFormat.

19 months agors6000: Raise error for __vector_{quad,pair} uses without MMA enabled [PR106736]
Kewen Lin [Wed, 21 Dec 2022 03:02:08 +0000 (21:02 -0600)]
rs6000: Raise error for __vector_{quad,pair} uses without MMA enabled [PR106736]

As PR106736 shows, it's unexpected to use __vector_quad and
__vector_pair types without MMA support, it would cause ICE
when expanding the corresponding assignment.  We can't guard
these built-in types registering under MMA support as Peter
pointed out in that PR, because the registering is global,
it doesn't work for target pragma/attribute support with MMA
enabled.  The existing verify_type_context mentioned in [2]
can help to make the diagnostics invalid built-in type uses
better, but as Richard pointed out in [4], it can't deal with
all cases.  As the discussions in [1][3], this patch is to
check the invalid use of built-in types __vector_quad and
__vector_pair in mov pattern of OOmode and XOmode, on the
currently being expanded gimple assignment statement.  It
still puts an assertion in else arm rather than just makes
it go through, it's to ensure we can catch any other possible
unexpected cases in time if there are.

[1] https://gcc.gnu.org/pipermail/gcc/2022-December/240218.html
[2] https://gcc.gnu.org/pipermail/gcc/2022-December/240220.html
[3] https://gcc.gnu.org/pipermail/gcc/2022-December/240223.html
[4] https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608083.html

PR target/106736

gcc/ChangeLog:

* config/rs6000/mma.md (define_expand movoo): Call function
rs6000_opaque_type_invalid_use_p to check and emit error message for
the invalid use of opaque type.
(define_expand movxo): Likewise.
* config/rs6000/rs6000-protos.h
(rs6000_opaque_type_invalid_use_p): New function declaration.
(currently_expanding_gimple_stmt): New extern declaration.
* config/rs6000/rs6000.cc (rs6000_opaque_type_invalid_use_p): New
function.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr106736-1.c: New test.
* gcc.target/powerpc/pr106736-2.c: Likewise.
* gcc.target/powerpc/pr106736-3.c: Likewise.
* gcc.target/powerpc/pr106736-4.c: Likewise.
* gcc.target/powerpc/pr106736-5.c: Likewise.

19 months agofold: fix use of protected_set_expr_location_unshare
Jason Merrill [Wed, 21 Dec 2022 02:06:09 +0000 (21:06 -0500)]
fold: fix use of protected_set_expr_location_unshare

Unlike protected_set_expr_location, this variant can return
a different tree.

gcc/ChangeLog:

* fold-const.cc (fold_convert_loc): Check return value of
protected_set_expr_location_unshare.

19 months agoc++: source position of lambda captures [PR84471]
Jason Merrill [Fri, 2 Dec 2022 03:58:28 +0000 (22:58 -0500)]
c++: source position of lambda captures [PR84471]

If the DECL_VALUE_EXPR of a VAR_DECL has EXPR_LOCATION set, then any use of
that variable looks like it has that location, which leads to the debugger
jumping back and forth for both lambdas and structured bindings.

Rather than fix all the uses, it seems simplest to remove any EXPR_LOCATION
when setting DECL_VALUE_EXPR.  So the cp/ hunks aren't necessary, but they
avoid the need to unshare to remove the location.

PR c++/84471
PR c++/107504

gcc/cp/ChangeLog:

* coroutines.cc (transform_local_var_uses): Don't
specify a location for DECL_VALUE_EXPR.
* decl.cc (cp_finish_decomp): Likewise.

gcc/ChangeLog:

* fold-const.cc (protected_set_expr_location_unshare): Not static.
* tree.h: Declare it.
* tree.cc (decl_value_expr_insert): Use it.

include/ChangeLog:

* ansidecl.h (ATTRIBUTE_WARN_UNUSED_RESULT): Add __.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/value-expr1.C: New test.
* g++.dg/tree-ssa/value-expr2.C: New test.
* g++.dg/analyzer/pr93212.C: Move warning.

19 months agoDaily bump.
GCC Administrator [Wed, 21 Dec 2022 00:17:15 +0000 (00:17 +0000)]
Daily bump.

19 months agoc++, tree: walk TREE_VEC (and VECTOR_CST) in natural order [PR101886]
Patrick Palka [Tue, 20 Dec 2022 22:02:37 +0000 (17:02 -0500)]
c++, tree: walk TREE_VEC (and VECTOR_CST) in natural order [PR101886]

Unfortunately the extract_autos_r fix in r13-4799-ga7c8036b26082d is
derailed by the fact that walk_tree_1 currently walks the elements of a
TREE_VEC in reverse, which means for A<auto, auto> in the below testcase
extract_autos_r ends up adjusting the TEMPLATE_TYPE_IDX of the first
auto instead of the second one, and the first auto is the canonical auto
of level 2 (and index 0), so we rightfully trigger the sanity check
added in that commit.

It seems TREE_VEC and VECTOR_CST are the only trees we walk in reverse,
and this has been the case since r21884 whence the original version of
walk_tree_1 was introduced.  But that's arguably unnatural and not
consistent with how we walk all other compound trees such as CONSTRUCTORs
and EXPR_P trees in forward order.

So this patch makes walk_tree_1 walk TREE_VEC (and VECTOR_CST) in
forward order as well, which fixes the testcase.  Doing so revealed that
keep_template_parm grows the list of found template parameters from the
front, which previously compensated for the TREE_VEC behavior, so now we
should grow it from the back.

PR c++/101886

gcc/cp/ChangeLog:

* pt.cc (find_template_parameter_info::parm_list_tail):
New data member.
(keep_template_parm): Use parm_list_tail to append rather
than prepend to parm_list.

gcc/ChangeLog:

* tree.cc (walk_tree_1) <case TREE_VEC>: Walk the elements
in forward instead of reverse order.
<case VECTOR_CST>: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/diagnostic12.C: Adjust expected order of
template parameters within pretty printed parameter mapping.
* g++.dg/concepts/auto6.C: New test.

19 months agoFortran: a C interoperable function cannot have the CLASS attribute [PR95375]
Harald Anlauf [Tue, 20 Dec 2022 20:17:08 +0000 (21:17 +0100)]
Fortran: a C interoperable function cannot have the CLASS attribute [PR95375]

gcc/fortran/ChangeLog:

PR fortran/95375
* decl.cc (verify_bind_c_sym): Extend interoperability check to
CLASS variables.

gcc/testsuite/ChangeLog:

PR fortran/95375
* gfortran.dg/bind_c_procs_4.f90: New test.

19 months agocoroutines: Accept 'extern "C"' coroutines.
Iain Sandoe [Sat, 10 Dec 2022 11:31:26 +0000 (11:31 +0000)]
coroutines: Accept 'extern "C"' coroutines.

'extern "C"' coroutines are permitted by the standard and expected to work
(although constructing useful cases could be challenging). In order to
permit this we need to arrange for the outlined helper functions to be
named properly, even when no mangling is required.  To do this, we append
the actor and destroy suffixes in all cases.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/ChangeLog:

* mangle.cc (write_mangled_name): Append the helper function
suffixes here...
(write_encoding): ... rather than here.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/extern-c-coroutine.C: New test.

19 months agoc++: NTTP object wrapper substitution fixes [PR103346, ...]
Patrick Palka [Tue, 20 Dec 2022 16:09:11 +0000 (11:09 -0500)]
c++: NTTP object wrapper substitution fixes [PR103346, ...]

This patch fixes some issues with substitution into a C++20 template
parameter object wrapper:

* The first testcase demonstrates a situation where the same_type_p
  assert in relevant case of tsubst_copy doesn't hold, because (partial)
  substitution of {int,} into the wrapper's TREE_TYPE yields A<int> but
  substitution into the underlying TEMPLATE_PARM_INDEX is a nop due to
  tsubst's level==1/tf_partial early exit tests, hence TREE_TYPE in the
  latter case remains A<T>.  So this patch just gets rid of the assert;
  the type mismatch doesn't seem to be a problem in practice.

* In the second testcase, dependent substitution into the underlying
  TEMPLATE_PARM_INDEX yields a CALL_EXPR with empty TREE_TYPE, which
  tsubst_copy doesn't expect.  This patch fixes this by handling empty
  TREE_TYPE the same way as a non-const TREE_TYPE.  Moreover, after
  this substitution we're left with a VIEW_CONVERT_EXPR wrapping a
  CALL_EXPR instead of a TEMPLATE_PARM_INDEX, which during the subsequent
  non-dependent substitution tsubst_copy doesn't expect either.  So
  this patch also relaxes tsubst_copy to accept such VIEW_CONVERT_EXPR
  too.

* In the third testcase, we end up never resolving the call to
  f.modify() because tsubst_copy doesn't do overload resolution.
  This patch fixes this by moving the handling of these
  VIEW_CONVERT_EXPR wrappers from tsubst_copy to tsubst_copy_and_build.
  For good measure tsubst_copy_and_build should also handle
  REF_PARENTHESIZED_P wrappers instead of delegating to tsubst_copy.

PR c++/103346
PR c++/104278
PR c++/102553

gcc/cp/ChangeLog:

* pt.cc (tsubst_copy) <case VIEW_CONVERT_EXPR>: Move the
handling of C++20 template parameter object wrappers to ...
(tsubst_copy_and_build) <case VIEW_CONVERT_EXPR>: ... here.
Accept non-TEMPLATE_PARM_INDEX inner operand.  Handle empty
TREE_TYPE on substituted inner operand.  Remove same_type_p
assert.  Also handle REF_PARENTHESIZED_P VIEW_CONVERT_EXPRs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class52a.C: New test.
* g++.dg/cpp2a/nontype-class53.C: New test.
* g++.dg/cpp2a/nontype-class54.C: New test.
* g++.dg/cpp2a/nontype-class55.C: New test.

19 months agoDon't use PHI equivalences in range-on-entry.
Andrew MacLeod [Fri, 16 Dec 2022 21:53:31 +0000 (16:53 -0500)]
Don't use PHI equivalences in range-on-entry.

If there is only one argument to a PHI which is defined, an equivalency is
created between the def and the argument.  It is safe to consider the def
equal to the argument, but it is dangerous to assume the argument is also
equivalent to the def as there may be branches which change the range on the
path to the PHI on that argument

This patch avoid using that relation in range-on-entry calculations.

PR tree-optimization/108139
gcc/
* gimple-range-cache.cc (ranger_cache::fill_block_cache): Do not
use equivalences originating from PHIS.

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

19 months agod/104749 - document host GDC version requirement
Richard Biener [Tue, 20 Dec 2022 13:34:01 +0000 (14:34 +0100)]
d/104749 - document host GDC version requirement

This documents that GDC 9.4 or later is required to build the D
language rather than GDC 9.1 which suffers from PR94240.

PR d/104749
* doc/install.texi (GDC): Document GDC 9.4 or later is required
to build the D language frontend.

19 months agorust: fix link serialization [PR108113]
Marc Poulhiès [Wed, 14 Dec 2022 20:29:13 +0000 (21:29 +0100)]
rust: fix link serialization [PR108113]

The Make-lang.in was missing the link serialization support.

PR rust/108113

gcc/rust
* Make-lang.in (rust.serial): New variable.
(rust1$(exeext)): Depend on $(rust.prev). Call LINK_PROGRESS.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
19 months agors6000: Optimize cmp on rotated 16bits constant
Jiufu Guo [Tue, 20 Dec 2022 03:43:57 +0000 (11:43 +0800)]
rs6000: Optimize cmp on rotated 16bits constant

Hi,

When checking eq/ne with a constant which has only 16bits, it can be
optimized to check the rotated data.  By this, the constant building
is optimized.

As the example in PR103743:
For "in == 0x8000000000000000LL", this patch generates:
        rotldi 3,3,1 ; cmpldi 0,3,1
instead of:
        li 9,-1 ; rldicr 9,9,0,0 ; cmpd 0,3,9

Compare with previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600475.html.
This patch refactor the code according to review comments.
e.g. updating function names/comments/code.

This patch pass bootstrap and regtest on ppc64 and ppc64le.
Is it ok for trunk?  Thanks for comments!

BR,
Jeff(Jiufu)

PR target/103743

gcc/ChangeLog:

* config/rs6000/rs6000-protos.h (can_be_rotated_to_lowbits): New.
(can_be_rotated_to_positive_16bits): New.
(can_be_rotated_to_negative_15bits): New.
* config/rs6000/rs6000.cc (can_be_rotated_to_lowbits): New definition.
(can_be_rotated_to_positive_16bits): New definition.
(can_be_rotated_to_negative_15bits): New definition.
* config/rs6000/rs6000.md (*rotate_on_cmpdi): New define_insn_and_split.
(eqne): Move earlier.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr103743.c: New test.
* gcc.target/powerpc/pr103743_1.c: New test.

19 months agoDaily bump.
GCC Administrator [Tue, 20 Dec 2022 00:17:00 +0000 (00:17 +0000)]
Daily bump.

19 months agobuild: avoid -Wconditionally-supported on qsort check
Jason Merrill [Mon, 19 Dec 2022 20:41:36 +0000 (15:41 -0500)]
build: avoid -Wconditionally-supported on qsort check

It's OK to rely on conditionally-supported features in #if CHECKING_P, since
that isn't defined in stage 1.

gcc/ChangeLog:

* sort.cc: Disable -Wconditionally-supported in
CHECKING_P code.

19 months agoc++: modules and std::source_location::current() def arg [PR100881]
Patrick Palka [Mon, 19 Dec 2022 20:35:51 +0000 (15:35 -0500)]
c++: modules and std::source_location::current() def arg [PR100881]

We currently declare __builtin_source_location with a const void* return
type instead of the actual type const std::source_location::__impl*, and
later when folding this builtin we obtain the actual type via name lookup.

But the below testcase demonstrates this approach seems to interact
poorly with modules, since we may import an entity that uses
std::source_location::current() in its default argument (or DMI) without
necessarily importing <source_location>, and thus the name lookup for
std::source_location will fail at the call site (when using the default
argument) unless we also import <source_location>.

This patch fixes this by instead initially declaring the builtin with an
auto return type and updating it appropriately upon its first use (in
standard code the first/only use would be in the definition of
std::source_location).  Thus when folding calls to this builtin we can
get at its return type through the type of the CALL_EXPR and avoid
needing to do a name lookup.

PR c++/100881

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_builtin_function_call): Adjust calls
to fold_builtin_source_location.
* cp-gimplify.cc (cp_gimplify_expr): Likewise.
(cp_fold): Likewise.
(get_source_location_impl_type): Remove location_t parameter and
adjust accordingly.  No longer static.
(fold_builtin_source_location): Take a CALL_EXPR tree instead of a
location and obtain the impl type from its return type.
* cp-tree.h (enum cp_tree_index): Remove CPTI_SOURCE_LOCATION_IMPL
enumerator.
(source_location_impl): Remove.
(fold_builtin_source_location): Adjust parameter type.
(get_source_location_impl_type): Declare.
* decl.cc (cxx_init_decl_processing): Declare
__builtin_source_location with auto return type instead of
const void*.
(require_deduced_type): Update the return type of
__builtin_source_location.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/srcloc3.C: Adjust expected note s/evaluating/using.
* g++.dg/cpp2a/srcloc4.C: Likewise.
* g++.dg/cpp2a/srcloc5.C: Likewise.
* g++.dg/cpp2a/srcloc6.C: Likewise.
* g++.dg/cpp2a/srcloc7.C: Likewise.
* g++.dg/cpp2a/srcloc8.C: Likewise.
* g++.dg/cpp2a/srcloc9.C: Likewise.
* g++.dg/cpp2a/srcloc10.C: Likewise.
* g++.dg/cpp2a/srcloc11.C: Likewise.
* g++.dg/cpp2a/srcloc12.C: Likewise.
* g++.dg/cpp2a/srcloc13.C: Likewise.
* g++.dg/modules/pr100881_a.C: New test.
* g++.dg/modules/pr100881_b.C: New test.

19 months agoc++: ICE with concepts TS multiple auto deduction [PR101886]
Patrick Palka [Mon, 19 Dec 2022 19:59:43 +0000 (14:59 -0500)]
c++: ICE with concepts TS multiple auto deduction [PR101886]

In extract_autos_r, we need to recompute TYPE_CANONICAL for the template
type parameter after adjusting its index, otherwise we end up with a
comptypes ICE for the below testcase.  Note that such in-place type
adjustment isn't generally safe to do since the type could be the
TYPE_CANONICAL of another (unadjusted) type, but in this case the
canonical auto (of some level and 0 index) is the first auto (of that
level) that's created, and so any auto that we do end up adjusting can't
be the canonical one.

PR c++/101886

gcc/cp/ChangeLog:

* pt.cc (extract_autos_r): Recompute TYPE_CANONICAL after
adjusting the template type parameter's index.  Simplify
by using TEMPLATE_TYPE_IDX.  Add some sanity checks.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/auto5.C: New test.

19 months agocontracts: Lowercase {MAYBE,NEVER}_CONTINUE
Arsen Arsenović [Sat, 10 Dec 2022 09:43:00 +0000 (10:43 +0100)]
contracts: Lowercase {MAYBE,NEVER}_CONTINUE

The lowercase constants are more consistent with the standard, and it is
unlikely that the uppercase versions would've been accepted.

gcc/cp/ChangeLog:

* contracts.cc: Rename references to
contract_violation_continuation_mode constants to be lowercase.

libstdc++-v3/ChangeLog:

* include/experimental/contract: Lowercase the constants in
contract_violation_continuation_mode.

19 months agoc: Diagnose compound literals with function type [PR108043]
Jakub Jelinek [Mon, 19 Dec 2022 19:55:56 +0000 (20:55 +0100)]
c: Diagnose compound literals with function type [PR108043]

Both C99 and latest C2X say that compound literal shall have an object type
(complete object type in the latter case) or array of unknown bound,
so complit with function type is invalid.  When the initializer had to be
non-empty for such case, we used to diagnose it as incorrect initializer,
but with (fntype){} now allowed we just ICE on it.

The following patch diagnoses that.

2022-12-19  Jakub Jelinek  <jakub@redhat.com>

PR c/108043
* c-parser.cc (c_parser_postfix_expression_after_paren_type): Diagnose
compound literals with function type.

* gcc.dg/pr108043.c: New test.
* gcc.dg/c99-complit-2.c (foo): Adjust expected diagnostics for
complit with function type.

19 months agoc-family: Fix ICE with -Wsuggest-attribute [PR98487]
Marek Polacek [Fri, 16 Dec 2022 17:28:43 +0000 (12:28 -0500)]
c-family: Fix ICE with -Wsuggest-attribute [PR98487]

Here we crash because check_function_format was using TREE_PURPOSE
directly rather than using get_attribute_name.

PR c/98487

gcc/c-family/ChangeLog:

* c-format.cc (check_function_format): Use get_attribute_name.

gcc/testsuite/ChangeLog:

* c-c++-common/Wsuggest-attribute-1.c: New test.

19 months agobuild: add -Wconditionally-supported to strict_warn [PR64867]
Jason Merrill [Mon, 5 Dec 2022 15:00:31 +0000 (10:00 -0500)]
build: add -Wconditionally-supported to strict_warn [PR64867]

The PR (which isn't resolved by this commit) pointed out to me that GCC
should build with -Wconditionally-supported to support bootstrapping with a
C++11 compiler that makes different choices.

PR c++/64867

gcc/ChangeLog:

* configure.ac (strict_warn): Add -Wconditionally-supported.
* configure: Regenerate.

19 months agotree-optimization/108164 - undefined overflow with IV vectorization
Richard Biener [Mon, 19 Dec 2022 13:55:45 +0000 (14:55 +0100)]
tree-optimization/108164 - undefined overflow with IV vectorization

vect_update_ivs_after_vectorizer can end up emitting a signed
IV update when the loop body performed an unsigned computation.
The following makes sure to perform that update in the type
of the loop update type to avoid undefined behavior on overflow.

PR tree-optimization/108164
* tree-vect-loop-manip.cc (vect_update_ivs_after_vectorizer):
Perform vect_step_op_add update in the appropriate type.

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

19 months agoarm: correctly define __ARM_FEATURE_CLZ
Richard Earnshaw [Mon, 19 Dec 2022 15:01:49 +0000 (15:01 +0000)]
arm: correctly define __ARM_FEATURE_CLZ

The ACLE requires that __ARM_FEATURE_CLZ be defined if the hardware
supports it; it's also clear that this doesn't mean the current ISA,
so we must define this even when compiling for Thumb1 if the target
supports CLZ in A32.

This brings GCC into alignment with Clang.

gcc/ChangeLog:

* config/arm/arm-c.cc (__ARM_FEATURE_CLZ): Fix definition of
preprocessor macro when target has CLZ in another ISA.

19 months agoRISC-V: Remove unit-stride store from ta attribute
Ju-Zhe Zhong [Wed, 14 Dec 2022 11:36:41 +0000 (19:36 +0800)]
RISC-V: Remove unit-stride store from ta attribute

Since store instructions doesn't care about tail policy, we remove
vste from "ta" attribute. Hence, we could have more fusion chances
and better optimization.

gcc/ChangeLog:

* config/riscv/vector.md: Remove vste.

19 months agoRISC-V: Add testcases for VSETVL PASS 5
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:25:58 +0000 (16:25 +0800)]
RISC-V: Add testcases for VSETVL PASS 5

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-20.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-21.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-22.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-23.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-27.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-28.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-29.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-30.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-31.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-32.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-33.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-34.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-35.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-37.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-38.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-39.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-40.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-41.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-42.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-43.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-44.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-45.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-46.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-9.c: New test.

19 months agoRISC-V: Add testcases for VSETVL PASS 4
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:19:35 +0000 (16:19 +0800)]
RISC-V: Add testcases for VSETVL PASS 4

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-20.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-21.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-22.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-23.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-24.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-25.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-26.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-27.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-28.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-9.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_complex_loop-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_complex_loop-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-9.c: New test.

19 months agoRISC-V: Add testcases for VSETVL PASS 3
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:15:48 +0000 (16:15 +0800)]
RISC-V: Add testcases for VSETVL PASS 3

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-20.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-21.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-22.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-23.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-24.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-25.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-26.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-27.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-28.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-9.c: New test.

19 months agoRISC-V: Add testcases for VSETVL PASS 2
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:13:01 +0000 (16:13 +0800)]
RISC-V: Add testcases for VSETVL PASS 2

gcc/testsuite/ChangeLog:

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

19 months agoRISC-V: Add testcases for VSETVL PASS
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:09:31 +0000 (16:09 +0800)]
RISC-V: Add testcases for VSETVL PASS

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/rvv.exp: Adjust to enable tests for VSETVL PASS.
* gcc.target/riscv/rvv/vsetvl/dump-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-9.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-8.c: New test.

19 months agoRISC-V: Simplify ASM checks in gcc.target/riscv/rvv/base/.
Kito Cheng [Mon, 19 Dec 2022 13:55:15 +0000 (21:55 +0800)]
RISC-V: Simplify ASM checks in gcc.target/riscv/rvv/base/.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/mov-1.c: Simplify operand check.
* gcc.target/riscv/rvv/base/mov-10.c: Ditto.
* gcc.target/riscv/rvv/base/mov-11.c: Ditto.
* gcc.target/riscv/rvv/base/mov-12.c: Ditto.
* gcc.target/riscv/rvv/base/mov-2.c: Ditto.
* gcc.target/riscv/rvv/base/mov-3.c: Ditto.
* gcc.target/riscv/rvv/base/mov-4.c: Ditto.
* gcc.target/riscv/rvv/base/mov-5.c: Ditto.
* gcc.target/riscv/rvv/base/mov-6.c: Ditto.
* gcc.target/riscv/rvv/base/mov-8.c: Ditto.
* gcc.target/riscv/rvv/base/mov-9.c: Ditto.
* gcc.target/riscv/rvv/base/vread_csr.c: Ditto.
* gcc.target/riscv/rvv/base/vsetvl-1.c: Ditto.
* gcc.target/riscv/rvv/base/vwrite_csr.c: Ditto.

19 months agoRISC-V: Support VSETVL PASS for RVV support
Ju-Zhe Zhong [Wed, 14 Dec 2022 07:31:11 +0000 (15:31 +0800)]
RISC-V: Support VSETVL PASS for RVV support

This patch is to support VSETVL PASS for RVV support.
1.The optimization and performance is guaranteed LCM (Lazy code motion).
2.Base on RTL_SSA framework to gain better optimization chances.
3.Also we do VL/VTYPE, demand information backward propagation across
  blocks by RTL_SSA reverse order in CFG.
4.It has been well and fully tested by about 200+ testcases for VLMAX
  AVL situation (Only for VLMAX since we don't have an intrinsics to
  test non-VLMAX).
5.Will support AVL model in the next patch.

gcc/ChangeLog:

* config.gcc: Add riscv-vsetvl.o.
* config/riscv/riscv-passes.def (INSERT_PASS_BEFORE): Add VSETVL PASS
location.
* config/riscv/riscv-protos.h (make_pass_vsetvl): New function.
(enum avl_type): New enum.
(get_ta): New function.
(get_ma): Ditto.
(get_avl_type): Ditto.
(calculate_ratio): Ditto.
(enum tail_policy): New enum.
(enum mask_policy): Ditto.
* config/riscv/riscv-v.cc (calculate_ratio): New function.
(emit_pred_op): change the VLMAX mov codgen.
(get_ta): New function.
(get_ma): Ditto.
(enum tail_policy): Change enum.
(get_prefer_tail_policy): New function.
(enum mask_policy): Change enum.
(get_prefer_mask_policy): New function.
* config/riscv/t-riscv: Add riscv-vsetvl.o
* config/riscv/vector.md: Adjust attribute and pattern for VSETVL
PASS.
(@vlmax_avl<mode>): Ditto.
(@vsetvl<mode>_no_side_effects): Delete.
(vsetvl_vtype_change_only): New MD pattern.
(@vsetvl_discard_result<mode>): Ditto.
* config/riscv/riscv-vsetvl.cc: New file.
* config/riscv/riscv-vsetvl.h: New file.

19 months agoRISC-V: Fix RVV machine mode attribute configuration
Ju-Zhe Zhong [Wed, 14 Dec 2022 07:01:56 +0000 (15:01 +0800)]
RISC-V: Fix RVV machine mode attribute configuration

The attribute configuration of each machine mode are support in the previous patch.
I noticed some of them are not correct during VSETVL PASS testsing.
Correct them in the single patch now.

gcc/ChangeLog:

* config/riscv/riscv-vector-switch.def (ENTRY): Correct attributes.

19 months agotestsuite: Fix up pr64536.c for LLP64 targets [PR108151]
Jakub Jelinek [Mon, 19 Dec 2022 14:05:16 +0000 (15:05 +0100)]
testsuite: Fix up pr64536.c for LLP64 targets [PR108151]

Apparently llp64 had 2 further warnings, fixed thusly.

2022-12-19  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/108151
* gcc.dg/pr64536.c (bar): Cast long to __INTPTR_TYPE__
before casting to long *.

19 months agomodula2: Don't treat % in Modula 2 messages specially
Jakub Jelinek [Mon, 19 Dec 2022 14:00:47 +0000 (15:00 +0100)]
modula2: Don't treat % in Modula 2 messages specially

On top of the just posted patch, this patch makes sure that
any % chars in message strings aren't treated as format chars.
None of these functions take variable number of arguments, so for
most of format specifiers there is nowhere to take arguments from,
it is true that a couple of format specifiers don't take any
arguments - %%, %m, %<, %>, %' - so it is actually possible
to use them, but one needs to verify that no other are emitted and
that what should be printed as % is really emitted as %%.
If the FE does that, then please ignore this patch, otherwise I think
it is safer to do this.

2022-12-19  Jakub Jelinek  <jakub@redhat.com>

* gm2-gcc/m2linemap.cc (m2linemap_ErrorAt, m2linemap_ErrorAtf,
m2linemap_WarningAtf, m2linemap_NoteAtf, m2linemap_internal_error):
Call functions with "%s", message rather than just message, so that
% chars in message aren't treated as format specifiers.

19 months agomodula2: Fix up bootstrap on powerpc64le-linux [PR108147]
Jakub Jelinek [Mon, 19 Dec 2022 13:20:36 +0000 (14:20 +0100)]
modula2: Fix up bootstrap on powerpc64le-linux [PR108147]

As mentioned in the PR, bootstrap with m2 enabled currently fails
on powerpc64le-linux, we get weird ICE after printing some diagnostics.
The problem is that mc creates from *.def prototypes like
extern void m2linemap_WarningAtf (m2linemap_location_t location, void * message);
but the actual function definitions use
void m2linemap_WarningAtf (m2linemap_location_t location, void * message,
...) { code }
and on powerpc64le-linux such lying about the prototype results in
wrong-code, on the caller side we assume the function isn't varargs
and so don't reserve 64 bytes in the frame for it, while the callee
relies on the area being reserved and stores into it.

Fixed by adding non-stdarg wrappers around stdarg functions (because
we want va_list and pass it to diagnostics functions).

2022-12-19  Jakub Jelinek  <jakub@redhat.com>

PR modula2/108147
* gm2-gcc/m2linemap.def (ErrorAtf, WarningAtf, NoteAtf):
Comment out prototypes with varargs.
* gm2-gcc/m2linemap.h (m2linemap_ErrorAtf, m2linemap_WarningAtf,
m2linemap_NoteAtf): No longer varargs.
* gm2-gcc/m2linemap.cc (m2linemap_ErrorAtf): Turned into a
non-varargs wrapper around ...
(m2linemap_ErrorAtf_1): ... this.  New static function.
(m2linemap_WarningAtf): Turned into a non-varargs wrapper around ...
(m2linemap_WarningAtf_1): ... this.  New static function.
(m2linemap_NoteAtf): Turned into a non-varargs wrapper around ...
(m2linemap_NoteAtf_1): ... this.  New static function.

19 months agogcc-changelog: support digits in PR's component in subject
Martin Liska [Mon, 19 Dec 2022 13:55:39 +0000 (14:55 +0100)]
gcc-changelog: support digits in PR's component in subject

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Support digits in PR's
component in subject.

19 months agogcc-changelog: allow digit in component name
Martin Liska [Mon, 19 Dec 2022 13:34:18 +0000 (14:34 +0100)]
gcc-changelog: allow digit in component name

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Allow digit in component name.

contrib/ChangeLog:

* gcc-changelog/test_email.py: Add new test.
* gcc-changelog/test_patches.txt: Add new patch.

19 months agotestsuite: Fix up pr64536.c for LLP64 targets [PR108151]
Jakub Jelinek [Mon, 19 Dec 2022 12:49:52 +0000 (13:49 +0100)]
testsuite: Fix up pr64536.c for LLP64 targets [PR108151]

The test casts a pointer to long, which is ok for ilp32 and lp64
targets but not for llp64 targets.  Nothing reads the values later,
it is a link test, so all we care about is that it is the same
cast on s390x-linux where it used to fail before the PR64536 fix,
and that we don't warn about it.

2022-12-19  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/108151
* gcc.dg/pr64536.c (bar): Use casts to __INTPTR_TYPE__ rather than
long when casting pointer to integral type.

19 months agoaarch64: PR target/108140 Handle NULL target in data intrinsic expansion
Kyrylo Tkachov [Mon, 19 Dec 2022 11:16:47 +0000 (11:16 +0000)]
aarch64: PR target/108140 Handle NULL target in data intrinsic expansion

In this PR we ICE when expanding the __rbit builtin with a NULL target rtx.
I *think* that only happens when the result is unused and hence maybe we shouldn't be expanding
any RTL at all, but the ICE here is easily fixed by deriving the mode from the type of the expression
rather than the target.

This patch does that.
Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

PR target/108140
* config/aarch64/aarch64-builtins.cc
(aarch64_expand_builtin_data_intrinsic): Handle NULL target.

gcc/testsuite/ChangeLog:

PR target/108140
* gcc.target/aarch64/acle/pr108140.c: New test.

19 months agogcc-changelog: Add warning for auto-added files
Tobias Burnus [Mon, 19 Dec 2022 11:12:16 +0000 (12:12 +0100)]
gcc-changelog: Add warning for auto-added files

git_email.py prints now a warning for files added automatically.
git_check_commit.py does likewise but only with --verbose.
It prints one line per ChangeLog file, either stating the file
or if more than one the number of files.

contrib/ChangeLog:

* gcc-changelog/git_check_commit.py (__main__): With -v print a
warning for the auto-added files.
* gcc-changelog/git_commit.py (GitCommit.__init__): Add self.warnings.
(GitCommit.check_mentioned_files): Add warning for auto-added files.
(GitCommit.print_warnings): New function.
* gcc-changelog/git_email.py (__main__): Remove bogus argument to
GitEmail constructor; print auto-added-files warning.
* gcc-changelog/test_email.py (test_auto_add_file_1,
test_auto_add_file_2): New tests.
* gcc-changelog/test_patches.txt: Add two test cases.

19 months agotestsuite: Fix up pr107397.f90 test [PR107397]
Jakub Jelinek [Mon, 19 Dec 2022 10:24:55 +0000 (11:24 +0100)]
testsuite: Fix up pr107397.f90 test [PR107397]

The pr107397.f90 test FAILs for me, one problem was that the
added diagnostics has an indefinite article before BOZ, but
the test dg-error didn't.  The other problem was that on the
other dg-error there was no space between the string and closing
}, so it was completely ignored and the error was an excess
error.

2022-12-19  Jakub Jelinek  <jakub@redhat.com>

PR fortran/107397
* gfortran.dg/pr107397.f90: Adjust expected diagnostic wording and
add space between dg-error string and closing }.

19 months agohwasan: Add libhwasan_preinit.o
Jakub Jelinek [Mon, 19 Dec 2022 10:14:55 +0000 (11:14 +0100)]
hwasan: Add libhwasan_preinit.o

I've noticed an inconsistency with the other sanitizers.
For -fsanitize={address,thread,leak} we link into binaries
lib*san_preinit.o such that the -lasan, -ltsan or -llsan libraries
are initialized as early as possible through .preinit_array.
The hwasan library has the same thing, but we strangely compiled
it into the library (where it apparently didn't do anything,
.preinit_array doesn't seem to be created for shared libraries),
rather than installing it like in the other 3 cases.

The following patch handles it for hwasan similarly to asan, tsan and lsan.

I don't have any hw with hwasan support, so I've just checked it
builds and installs as expected and that
gcc -fsanitize=hwaddress -o a a.c -mlam=u57
on trivial main results in .preinit_array section in the binary.

2022-12-19  Jakub Jelinek  <jakub@redhat.com>

* config/gnu-user.h (LIBHWASAN_EARLY_SPEC): Add libhwasan_preinit.o
to link spec if not -shared.

* hwasan/Makefile.am (nodist_toolexeclib_HEADERS): Set to
libhwasan_preinit.o.
(hwasan_files): Remove hwasan_preinit.cpp.
(libhwasan_preinit.o): Copy from hwasan_preinit.o.
* hwasan/Makefile.in: Regenerated.

19 months agoRISC-V: Change vlmul printing rule
Ju-Zhe Zhong [Wed, 14 Dec 2022 06:57:44 +0000 (14:57 +0800)]
RISC-V: Change vlmul printing rule

This patch is preparing patch for the following patch (VSETVL PASS)
support since the current vlmul printing rule is not appropriate
information for VSETVL PASS. I split this fix in a single patch.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (emit_vlmax_vsetvl): Pass through VLMUL enum
instead of machine mode.
* config/riscv/riscv-vector-builtins-bases.cc: Ditto.
* config/riscv/riscv.cc (riscv_print_operand): Print LMUL by enum vlmul
instead of machine mode.

19 months agoRISC-V: Fix vwrite_csr.c and vread_csr.c
Kito Cheng [Mon, 19 Dec 2022 09:28:25 +0000 (17:28 +0800)]
RISC-V: Fix vwrite_csr.c and vread_csr.c

gcc/testsuite:

* gcc.target/riscv/rvv/base/vread_csr.c: Use specific option
instead.
* gcc.target/riscv/rvv/base/vwrite_csr.c: Ditto.

19 months agors6000: use li;x?oris to build constant
Jiufu Guo [Mon, 19 Dec 2022 08:40:01 +0000 (16:40 +0800)]
rs6000: use li;x?oris to build constant

For constant C:
If '(c & 0xFFFFFFFF00008000ULL) == 0xFFFFFFFF00008000ULL' or say:
32(1) || 16(x) || 1(1) || 15(x), using "li; xoris" would be ok.

If '(c & 0xFFFFFFFF80008000ULL) == 0x80000000ULL' or say:
32(0) || 1(1) || 15(x) || 1(0) || 15(x), we could use "li; oris" to
build constant 'C'.

Here N(M) means N continuous bit M, x for M means it is ok for either
1 or 0; '||' means concatenation.

This patch update rs6000_emit_set_long_const to support those constants.

PR target/106708

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add using
"li; x?oris" to build constant.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr106708.c: New test.

19 months agogcc-changelog: stop using --flake8
Martin Liska [Mon, 19 Dec 2022 09:01:42 +0000 (10:01 +0100)]
gcc-changelog: stop using --flake8

The flake8 pytest plug-in is broken and we should not use it.

contrib/ChangeLog:

* gcc-changelog/setup.cfg: Do not use flake8 pytest plug-in.

19 months agox86: Don't add crtfastmath.o for -shared
liuhongt [Thu, 15 Dec 2022 01:38:08 +0000 (09:38 +0800)]
x86: Don't add crtfastmath.o for -shared

Don't add crtfastmath.o for -shared to avoid changing the MXCSR register
when loading a shared library.  crtfastmath.o will be used only when
building executables.

PR target/55522
* config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC):
Don't add crtfastmath.o for -shared.
* doc/invoke.texi (-shared): Add related documentation.

19 months agoRISC-V: Fix RVV related testsuite
Kito Cheng [Sun, 6 Nov 2022 00:01:02 +0000 (17:01 -0700)]
RISC-V: Fix RVV related testsuite

Use wrapper of riscv_vector.h for RVV related testcases,
more detail see https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603140.html

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/mov-1.c: Use double quotes to
include riscv_vector.h rather than angle brackets.
* gcc.target/riscv/rvv/base/mov-10.c: Ditto.
* gcc.target/riscv/rvv/base/mov-11.c: Ditto.
* gcc.target/riscv/rvv/base/mov-12.c: Ditto.
* gcc.target/riscv/rvv/base/mov-13.c: Ditto.
* gcc.target/riscv/rvv/base/mov-2.c: Ditto.
* gcc.target/riscv/rvv/base/mov-3.c: Ditto.
* gcc.target/riscv/rvv/base/mov-4.c: Ditto.
* gcc.target/riscv/rvv/base/mov-5.c: Ditto.
* gcc.target/riscv/rvv/base/mov-6.c: Ditto.
* gcc.target/riscv/rvv/base/mov-7.c: Ditto.
* gcc.target/riscv/rvv/base/mov-8.c: Ditto.
* gcc.target/riscv/rvv/base/mov-9.c: Ditto.
* gcc.target/riscv/rvv/base/vread_csr.c: Ditto.
* gcc.target/riscv/rvv/base/vsetvl-1.c: Ditto.
* gcc.target/riscv/rvv/base/vwrite_csr.c: Ditto.

19 months agoDaily bump.
GCC Administrator [Mon, 19 Dec 2022 00:16:53 +0000 (00:16 +0000)]
Daily bump.

19 months agobuild: doc: Obsolete Solaris 11.3 support
Rainer Orth [Sun, 18 Dec 2022 19:39:14 +0000 (20:39 +0100)]
build: doc: Obsolete Solaris 11.3 support

This patch implements the Solaris 11.[0-3] obsoletion just announced in

https://gcc.gnu.org/pipermail/gcc/2022-December/240322.html

Bootstrapped without regressions on Solaris 11.3 (i386-pc-solaris2.11,
sparc-sun-solaris2.11 without and with --enable-obsolete) and 11.4.

2022-12-09  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* config.gcc: Determine Solaris minor version.
Obsolete *-*-solaris2.11.[0-3]*.
* doc/install.texi (Specific, *-*-solaris2*): Document it.

19 months agoPR-108122 Reduce sleep times in gm2/pimcoroutines/run/pass/testtime.mod
Gaius Mulley [Sun, 18 Dec 2022 10:04:02 +0000 (10:04 +0000)]
PR-108122 Reduce sleep times in gm2/pimcoroutines/run/pass/testtime.mod

Change time unit to 1 jiffy (with respect to TimerHandler.def) rather
than a second.

gcc/testsuite/ChangeLog:

* gm2/pimcoroutines/run/pass/testtime.mod: Reduce sleep times in
the test by a factor of 25.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoAdd a check for invalid use of BOZ with a derived type.
Steve Kargl [Sun, 18 Dec 2022 03:15:43 +0000 (19:15 -0800)]
Add a check for invalid use of BOZ with a derived type.

PR fortran/107397

gcc/fortran/ChangeLog:

* decl.cc (add_init_expr_to_sym): Add check with new error message.

gcc/testsuite/ChangeLog:

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

19 months agoDaily bump.
GCC Administrator [Sun, 18 Dec 2022 00:16:57 +0000 (00:16 +0000)]
Daily bump.

19 months agors6000: Add Rust support to traceback table
Segher Boessenkool [Sat, 17 Dec 2022 20:48:54 +0000 (20:48 +0000)]
rs6000: Add Rust support to traceback table

Use 0 for the "lang" identifier for Rust, just like we do for all other
source languages without assigned language code (0 means "C").

Tested on powerpc64-linux.  Without this patch there are ICEs galore in
the gm2 testsuite for 64-bit Linux targets, and with the ptch there are
just a few FAILs.

2022-12-17  Segher Boessenkool  <segher@kernel.crashing.org>

* config/rs6000/rs6000-logue.cc (rs6000_output_function_epilogue):
Handle GNU Rust for the tbtab lang field.

19 months agoc++: constantness of non-dependent NTTP argument [PR107437]
Patrick Palka [Sat, 17 Dec 2022 16:24:44 +0000 (11:24 -0500)]
c++: constantness of non-dependent NTTP argument [PR107437]

Here we're rejecting the use of the lambda capture of 't' (of empty
type) as a template argument ultimately because convert_nontype_argument
checks constantness using is_constant_expression, which returns false
for lambda captures since want_rval=false.  But in this case I believe
an lvalue-to-rvalue conversion of the argument is implied, so we should
be using is_rvalue_constant_expression instead (which would return true
here).

However, it doesn't seem necessary to consider constantness at all
when deciding whether to instantiate a non-dependent argument in
convert_nontype_argument.  So this patch gets rid of the problematic
constantness test altogether, which incidentally also fixes the similar
dg-ice'd testcase from PR87765.  This is in line with a similar
change we made to finish_decltype_type in r12-7564-gec0f53a3a542e7.

PR c++/107437
PR c++/87765

gcc/cp/ChangeLog:

* pt.cc (convert_nontype_argument): Relax is_nondep_const_expr
test to !inst_dep_expr_p.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-generic-107437.C: New test.
* g++.dg/cpp1z/constexpr-lambda26.C: Remove dg-ice.

19 months agolibbacktrace: unpack literals into output buffer
Ian Lance Taylor [Sat, 17 Dec 2022 02:46:06 +0000 (18:46 -0800)]
libbacktrace: unpack literals into output buffer

* elf.c (elf_fetch_backward_init): New static function.
(ZSTD_TABLE_SIZE): Use huffman scratch space size rather than
literal size.
(ZSTD_TABLE_WORK_LIT_SIZE): Don't define.
(elf_zstd_read_huff): Use elf_fetch_backward_init.
(elf_zstd_read_literals): New static function.
(ZSTD_LIT_RAW, ZSTD_LIT_RLE, ZSTD_LIT_HUFF): Don't define.
(struct elf_zstd_literals): Don't define.
(elf_zstd_literal_output): Remove static function.
(elf_zstd_decompress): Use elf_fetch_backward_init and
elf_zstd_read_literals.  Rewrite literal copying.<

19 months agoDaily bump.
GCC Administrator [Sat, 17 Dec 2022 00:17:56 +0000 (00:17 +0000)]
Daily bump.

19 months agoinitialize fde objects lazily
Thomas Neumann [Fri, 9 Dec 2022 17:23:44 +0000 (18:23 +0100)]
initialize fde objects lazily

When registering an unwind frame with __register_frame_info_bases
we currently initialize that fde object eagerly. This has the
advantage that it is immutable afterwards and we can safely
access it from multiple threads, but it has the disadvantage
that we pay the initialization cost even if the application
never throws an exception.

This commit changes the logic to initialize the objects lazily.
The objects themselves are inserted into the b-tree when
registering the frame, but the sorted fde_vector is
not constructed yet. Only on the first time that an
exception tries to pass through the registered code the
object is initialized. We notice that with a double checking,
first doing a relaxed load of the sorted bit and then re-checking
under a mutex when the object was not initialized yet.

Note that the check must implicitly be safe concering a concurrent
frame deregistration, as trying the deregister a frame that is
on the unwinding path of a concurrent exception is inherently racy.

libgcc/ChangeLog:
* unwind-dw2-fde.c: Initialize fde object lazily when
the first exception tries to pass through.

19 months agospeed up end_fde_sort using radix sort
Thomas Neumann [Tue, 22 Nov 2022 07:41:54 +0000 (08:41 +0100)]
speed up end_fde_sort using radix sort

When registering a dynamic unwinding frame the fde list is sorted.
Previously, we split the list into a sorted and an unsorted part,
sorted the later using heap sort, and merged both. That can be
quite slow due to the large number of (expensive) comparisons.

This patch replaces that logic with a radix sort instead. The
radix sort uses the same amount of memory as the old logic,
using the second list as auxiliary space, and it includes two
techniques to speed up sorting: First, it computes the pointer
addresses for blocks of values, reducing the decoding overhead.
And it recognizes when the data has reached a sorted state,
allowing for early termination. When running out of memory
we fall back to pure heap sort, as before.

For this test program

\#include <cstdio>
int main(int argc, char** argv) {
     return 0;
}

compiled with g++ -O -o hello -static hello.c we get with
perf stat -r 200 on a 5950X the following performance numbers:

old logic:

              0,20 msec task-clock
           930.834      cycles
         3.079.765      instructions
        0,00030478 +- 0,00000237 seconds time elapsed

new logic:

              0,10 msec task-clock
           473.269      cycles
         1.239.077      instructions
        0,00021119 +- 0,00000168 seconds time elapsed

libgcc/ChangeLog:
* unwind-dw2-fde.c: Use radix sort instead of split+sort+merge.

19 months agoUpdate baseline symbols for hppa-linux.
John David Anglin [Fri, 16 Dec 2022 22:23:16 +0000 (22:23 +0000)]
Update baseline symbols for hppa-linux.

2022-12-16  John David Anglin  <danglin@gcc.gnu.org>

libstdc++-v3/ChangeLog:

* config/abi/post/hppa-linux-gnu/baseline_symbols.txt: Update.

19 months agoSuppress -fstack-protector warning on hppa.
John David Anglin [Fri, 16 Dec 2022 21:44:40 +0000 (21:44 +0000)]
Suppress -fstack-protector warning on hppa.

Some package builds enable -fstack-protector and -Werror. Since
-fstack-protector is not supported on hppa because the stack grows
up, these packages must check for the warning generated by
-fstack-protector and suppress it on hppa. This is problematic
since hppa is the only significant architecture where the stack
grows up.

2022-12-16  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.cc (pa_option_override): Disable -fstack-protector.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_static): Return 0
on hppa*-*-*.