platform/upstream/gcc.git
2 years agomiddle-end/101292 - invalid memory access with warning control
Richard Biener [Mon, 17 Jan 2022 14:22:11 +0000 (15:22 +0100)]
middle-end/101292 - invalid memory access with warning control

The warning control falls into the C++ trap of using a reference
to old hashtable contents for a put operation which can end up
re-allocating that before reading from the old freed referenced to
source.  Fixed by introducing a temporary.

2022-01-17  Richard Biener  <rguenther@suse.de>

PR middle-end/101292
* diagnostic-spec.c (copy_warning): Make sure to not
reference old hashtable content on possible resize.
* warning-control.cc (copy_warning): Likewise.

2 years agoChange kind of integer literal to fix a testcase.
Hafiz Abid Qadeer [Mon, 17 Jan 2022 13:45:08 +0000 (13:45 +0000)]
Change kind of integer literal to fix a testcase.

As Thomas reported in
https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588448.html
a test added in my recent allocate clause patch fails on m32. It was due
to default kind for integer matching c_intptr_t for m32. I have now
changed it to 0_1 so that always integer with kind=1 is used.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/allocate-2.f90: Change 0 to 0_1.

2 years agoFix glitch in entry for vxworks_posix_open
Olivier Hainque [Mon, 17 Jan 2022 13:23:40 +0000 (13:23 +0000)]
Fix glitch in entry for vxworks_posix_open

Which was incorrectly referring to the hack name from
a previous change (vxworks_math_h_fp_c99).

2 years agowidening_mul, i386: Improve spaceship expansion on x86 [PR103973]
Jakub Jelinek [Mon, 17 Jan 2022 12:39:05 +0000 (13:39 +0100)]
widening_mul, i386: Improve spaceship expansion on x86 [PR103973]

C++20:
 #include <compare>
 auto cmp4way(double a, double b)
 {
   return a <=> b;
 }
expands to:
        ucomisd %xmm1, %xmm0
        jp      .L8
        movl    $0, %eax
        jne     .L8
.L2:
        ret
        .p2align 4,,10
        .p2align 3
.L8:
        comisd  %xmm0, %xmm1
        movl    $-1, %eax
        ja      .L2
        ucomisd %xmm1, %xmm0
        setbe   %al
        addl    $1, %eax
        ret
That is 3 comparisons of the same operands.
The following patch improves it to just one comparison:
        comisd  %xmm1, %xmm0
        jp      .L4
        seta    %al
        movl    $0, %edx
        leal    -1(%rax,%rax), %eax
        cmove   %edx, %eax
        ret
.L4:
        movl    $2, %eax
        ret
While a <=> b expands to a == b ? 0 : a < b ? -1 : a > b ? 1 : 2
where the first comparison is equality and this shouldn't raise
exceptions on qNaN operands, if the operands aren't equal (which
includes unordered cases), then it immediately performs < or >
comparison and that raises exceptions even on qNaNs, so we can just
perform a single comparison that raises exceptions on qNaN.
As the 4 different cases are encoded as
ZF CF PF
1  1  1  a unordered b
0  0  0  a > b
0  1  0  a < b
1  0  0  a == b
we can emit optimal sequence of comparions, first jp
for the unordered case, then je for the == case and finally jb
for the < case.

The patch pattern recognizes spaceship-like comparisons during
widening_mul if the spaceship optab is implemented, and replaces
those comparisons with comparisons of .SPACESHIP ifn which returns
-1/0/1/2 based on the comparison.  This seems to work well both for the
case of just returning the -1/0/1/2 (when we have just a common
successor with a PHI) or when the different cases are handled with
various other basic blocks.  The testcases cover both of those cases,
the latter with different function calls in those.

2022-01-17  Jakub Jelinek  <jakub@redhat.com>

PR target/103973
* tree-cfg.h (cond_only_block_p): Declare.
* tree-ssa-phiopt.c (cond_only_block_p): Move function to ...
* tree-cfg.c (cond_only_block_p): ... here.  No longer static.
* optabs.def (spaceship_optab): New optab.
* internal-fn.def (SPACESHIP): New internal function.
* internal-fn.h (expand_SPACESHIP): Declare.
* internal-fn.c (expand_PHI): Formatting fix.
(expand_SPACESHIP): New function.
* tree-ssa-math-opts.c (optimize_spaceship): New function.
(math_opts_dom_walker::after_dom_children): Use it.
* config/i386/i386.md (spaceship<mode>3): New define_expand.
* config/i386/i386-protos.h (ix86_expand_fp_spaceship): Declare.
* config/i386/i386-expand.c (ix86_expand_fp_spaceship): New function.
* doc/md.texi (spaceship@var{m}3): Document.

* gcc.target/i386/pr103973-1.c: New test.
* gcc.target/i386/pr103973-2.c: New test.
* gcc.target/i386/pr103973-3.c: New test.
* gcc.target/i386/pr103973-4.c: New test.
* gcc.target/i386/pr103973-5.c: New test.
* gcc.target/i386/pr103973-6.c: New test.
* gcc.target/i386/pr103973-7.c: New test.
* gcc.target/i386/pr103973-8.c: New test.
* gcc.target/i386/pr103973-9.c: New test.
* gcc.target/i386/pr103973-10.c: New test.
* gcc.target/i386/pr103973-11.c: New test.
* gcc.target/i386/pr103973-12.c: New test.
* gcc.target/i386/pr103973-13.c: New test.
* gcc.target/i386/pr103973-14.c: New test.
* gcc.target/i386/pr103973-15.c: New test.
* gcc.target/i386/pr103973-16.c: New test.
* gcc.target/i386/pr103973-17.c: New test.
* gcc.target/i386/pr103973-18.c: New test.
* gcc.target/i386/pr103973-19.c: New test.
* gcc.target/i386/pr103973-20.c: New test.
* g++.target/i386/pr103973-1.C: New test.
* g++.target/i386/pr103973-2.C: New test.
* g++.target/i386/pr103973-3.C: New test.
* g++.target/i386/pr103973-4.C: New test.
* g++.target/i386/pr103973-5.C: New test.
* g++.target/i386/pr103973-6.C: New test.
* g++.target/i386/pr103973-7.C: New test.
* g++.target/i386/pr103973-8.C: New test.
* g++.target/i386/pr103973-9.C: New test.
* g++.target/i386/pr103973-10.C: New test.
* g++.target/i386/pr103973-11.C: New test.
* g++.target/i386/pr103973-12.C: New test.
* g++.target/i386/pr103973-13.C: New test.
* g++.target/i386/pr103973-14.C: New test.
* g++.target/i386/pr103973-15.C: New test.
* g++.target/i386/pr103973-16.C: New test.
* g++.target/i386/pr103973-17.C: New test.
* g++.target/i386/pr103973-18.C: New test.
* g++.target/i386/pr103973-19.C: New test.
* g++.target/i386/pr103973-20.C: New test.

2 years agoBump gcc/BASE-VER to 12.0.1 now that we are in stage4.
Richard Biener [Mon, 17 Jan 2022 12:20:30 +0000 (13:20 +0100)]
Bump gcc/BASE-VER to 12.0.1 now that we are in stage4.

2021-01-17  Richard Biener  <rguenther@suse.de>

* BASE-VER: Bump to 12.0.1.

2 years agolibstdc++: Define <stacktrace> header for C++23
Jonathan Wakely [Mon, 15 Nov 2021 11:08:06 +0000 (11:08 +0000)]
libstdc++: Define <stacktrace> header for C++23

Add the <stacktrace> header and a new libstdc++_libbacktrace.a library
that provides the implementation. For now, the new library is only built
if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS,
the new library is only provided as a static archive.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro.
* configure.ac: Use GLIBCXX_ENABLE_BACKTRACE.
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/std/stacktrace: New header.
* include/std/version (__cpp_lib_stacktrace): Define.
* Makefile.in: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.am: Regenerate.
* src/Makefile.in: Regenerate.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.in: Regenerate.
* src/c++20/Makefile.in: Regenerate.
* src/c++98/Makefile.in: Regenerate.
* src/filesystem/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.am: New file.
* src/libbacktrace/Makefile.in: New file.
* src/libbacktrace/backtrace-rename.h: New file.
* src/libbacktrace/backtrace-supported.h.in: New file.
* src/libbacktrace/config.h.in: New file.
* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
New proc.
* testsuite/20_util/stacktrace/entry.cc: New test.
* testsuite/20_util/stacktrace/synopsis.cc: New test.
* testsuite/20_util/stacktrace/version.cc: New test.

2 years agolibstdc++: Document final option names for enabling C++20
Jonathan Wakely [Mon, 17 Jan 2022 11:26:21 +0000 (11:26 +0000)]
libstdc++: Document final option names for enabling C++20

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2020.xml: Use final C++20 option
names.
* doc/html/manual/status.html: Regenerate.

2 years agolibstdc++: Rename non-reserved macros in config header [PR103650]
Jonathan Wakely [Mon, 17 Jan 2022 11:24:35 +0000 (11:24 +0000)]
libstdc++: Rename non-reserved macros in config header [PR103650]

libstdc++-v3/ChangeLog:

PR libstdc++/103650
* include/Makefile.am: Rename LT_OBJDIR and STDC_HEADERS.
* include/Makefile.in: Regenerate.
* testsuite/17_intro/headers/c++1998/103650.cc: New test.

2 years agoFortran: remove new files introduced by mistake
Francois-Xavier Coudert [Mon, 17 Jan 2022 11:12:00 +0000 (12:12 +0100)]
Fortran: remove new files introduced by mistake

These two files were introduced by mistake in
86e3b476d5defaa79c94d40b76cbeec21cd02e5f

gcc/testsuite/ChangeLog:

* gfortran.dg/ieee/signaling_3.f90: Remove file.

libgfortran/ChangeLog:

* ieee/issignaling_fallback.h: Remove file.

2 years agoMake the tests working.
Martin Liska [Fri, 14 Jan 2022 12:52:50 +0000 (13:52 +0100)]
Make the tests working.

gcc/testsuite/ChangeLog:

* g++.dg/uninit-pred-loop-1_b.C: Fix invalid warnings.
* g++.dg/uninit-pred-loop-1_c.C: Likewise.

2 years agoRename test-cases that are not executed.
Martin Liska [Fri, 14 Jan 2022 12:40:58 +0000 (13:40 +0100)]
Rename test-cases that are not executed.

gcc/testsuite/ChangeLog:

* g++.dg/uninit-pred-loop-1_a.cc: Moved to...
* g++.dg/uninit-pred-loop-1_a.C: ...here.
* g++.dg/uninit-pred-loop-1_b.cc: Moved to...
* g++.dg/uninit-pred-loop-1_b.C: ...here.
* g++.dg/uninit-pred-loop-1_c.cc: Moved to...
* g++.dg/uninit-pred-loop-1_c.C: ...here.
* g++.dg/uninit-pred-loop_1.cc: Moved to...
* g++.dg/uninit-pred-loop_1.C: ...here.

2 years agoAdd check_effective_target_pytest3.
Martin Liska [Mon, 17 Jan 2022 10:27:59 +0000 (11:27 +0100)]
Add check_effective_target_pytest3.

gcc/testsuite/ChangeLog:

* lib/gcov.exp: Use check_effective_target_pytest3.
* lib/target-supports.exp: Add check_effective_target_pytest3.

2 years agolibstdc++: Don't fail if math_errhandling is not defined
Matthias Kretz [Mon, 17 Jan 2022 09:38:29 +0000 (10:38 +0100)]
libstdc++: Don't fail if math_errhandling is not defined

Older glibc does not define math_errhandling with -ffast-math, in which
case floating-point exceptions are not used.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd.h (__floating_point_flags): Do
not rely on the presence of the math_errhandling macro.

2 years agoStart using check-MAINTAINERS.py instead of legacy maintainers-verify.sh.
Martin Liska [Fri, 14 Jan 2022 09:25:50 +0000 (10:25 +0100)]
Start using check-MAINTAINERS.py instead of legacy maintainers-verify.sh.

contrib/ChangeLog:

* maintainers-verify.sh: Removed.

gcc/testsuite/ChangeLog:

* gcc.src/maintainers.exp: Start using check-MAINTAINERS.py.
* lib/target-supports.exp: Add check_effective_target_python3.

2 years agoFix test warnings.
Martin Liska [Mon, 17 Jan 2022 09:55:32 +0000 (10:55 +0100)]
Fix test warnings.

PR testsuite/104035

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr57993-2.C: Fix warnings.

2 years agolibstdc++: Add 'typename' to dependent types in atomic<shared_ptr<T>>
Jonathan Wakely [Mon, 17 Jan 2022 09:42:35 +0000 (09:42 +0000)]
libstdc++: Add 'typename' to dependent types in atomic<shared_ptr<T>>

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h (_Sp_atomic): Add typename
to qualified-id for dependent type.

2 years agoExtend test cases for references in OpenACC 'private' clauses
Thomas Schwinge [Tue, 24 Aug 2021 16:33:04 +0000 (18:33 +0200)]
Extend test cases for references in OpenACC 'private' clauses

libgomp/
* testsuite/libgomp.oacc-c++/privatized-ref-2.C: Extend.
* testsuite/libgomp.oacc-c++/privatized-ref-3.C: Likewise.
* testsuite/libgomp.oacc-fortran/privatized-ref-1.f95: Likewise.

2 years agoTest cases for references in OpenACC 'private' clauses
Julian Brown [Fri, 20 Sep 2019 20:53:10 +0000 (13:53 -0700)]
Test cases for references in OpenACC 'private' clauses

libgomp/
* testsuite/libgomp.oacc-fortran/privatized-ref-1.f95: New test.
* testsuite/libgomp.oacc-c++/privatized-ref-2.C: New test.
* testsuite/libgomp.oacc-c++/privatized-ref-3.C: New test.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2 years agoAllow for multiple defaults in endianness and r16 in GFORTRAN_CONVERT_UNIT.
Thomas Koenig [Sat, 15 Jan 2022 10:30:20 +0000 (11:30 +0100)]
Allow for multiple defaults in endianness and r16 in GFORTRAN_CONVERT_UNIT.

With this patch, it is possible to specify multiple defaults inthe
GFORTRAN_CONVERT_UNIT environment variable so that, for example, R16_IEEE
and BIG_ENDIAN can be specified together.

libgfortran/ChangeLog:

* runtime/environ.c: Allow for multiple default values so that
separate default specifications for IBM long double format and
endianness are possible.

2 years agors6000: Use known constant for GET_MODE_NUNITS and similar
Kewen Lin [Mon, 17 Jan 2022 04:55:42 +0000 (22:55 -0600)]
rs6000: Use known constant for GET_MODE_NUNITS and similar

This patch is to clean up some codes with GET_MODE_UNIT_SIZE or
GET_MODE_NUNITS, which can use known constants or just be removed.

Note that Carl Love helped to confirm altivec_vreveti2 introduced
in r12-1341 is useless and can be removed.

gcc/ChangeLog:

* config/rs6000/altivec.md (altivec_vreveti2): Remove.
* config/rs6000/vsx.md (*vsx_extract_si, *vsx_extract_si_<uns>float_df,
*vsx_extract_si_<uns>float_<mode>, *vsx_insert_extract_v4sf_p9): Use
known constant values to simplify code.

2 years agors6000: Split pattern for TI to V1TI move [PR103124]
Haochen Gui [Mon, 17 Jan 2022 03:24:20 +0000 (11:24 +0800)]
rs6000: Split pattern for TI to V1TI move [PR103124]

This patch defines a new split pattern for TI to V1TI move.  The pattern concatenates two subreg:DI of a TI to a V2DI.  With the pattern, the subreg pass can do register split for TI when there is a TI to V1TI move.

gcc/

PR target/103124
* config/rs6000/vsx.md (split pattern for TI to V1TI move): Defined.

gcc/testsuite/

PR target/103124
* gcc.target/powerpc/pr103124.c: New testcase.

2 years agoDaily bump.
GCC Administrator [Mon, 17 Jan 2022 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Update C++20 status table
Jonathan Wakely [Thu, 13 Jan 2022 22:18:13 +0000 (22:18 +0000)]
libstdc++: Update C++20 status table

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2020.xml: Update.
* doc/html/manual/status.html: Regenerate.

2 years agolibstdc++: Implement C++20 atomic<shared_ptr> and atomic<weak_ptr>
Jonathan Wakely [Sun, 16 Jan 2022 20:47:09 +0000 (20:47 +0000)]
libstdc++: Implement C++20 atomic<shared_ptr> and atomic<weak_ptr>

This adds another piece of C++20, the std::atomic specializations for
std::shared_ptr and std::weak_ptr.

The new _Sp_atomic type mimics the structure of shared_ptr<T> and
weak_ptr<T>, holding a T* pointer (the one returned by get() on a
shared_ptr/weak ptr) and a _Sp_counted_base<>* pointer to the
ref-counted control block. For _Sp_atomic the low bit of the control
block pointer is used as a lock bit, to ensure only one thread will
access the object at a time.  The pointer is actually stored as a
uintptr_t to avoid accidental dereferences of the pointer when unlocked
(which would be a race) or when locked (which would dereference the
wrong pointer value due to the low bit being set). To get a raw pointer
to the control block, the lock must be acquired. Converting between a
_Sp_atomic and a shared_ptr or weak_ptr requires manually adjusting the
T* and _Sp_counted_base<>* members of the shared/weak ptr, instead of
going through the public API. This must be done carefully to ensure that
any change in the number of owners is reflected in a ref-count update.

Co-authored-by: Thomas Rodgers <trodgers@redhat.com>
Signed-off-by: Thomas Rodgers <trodgers@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h (__cpp_lib_atomic_shared_ptr):
New macro.
(_Sp_atomic): New class template.
(atomic<shared_ptr<T>>, atomic<weak_ptr<T>>): New partial
specializations.
* include/bits/shared_ptr_base.h (__shared_count, __weak_count)
(__shared_ptr, __weak_ptr): Declare _Sp_atomic as a friend.
* include/std/version (__cpp_lib_atomic_shared_ptr): New macro.
* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc: New
test.
* testsuite/20_util/weak_ptr/atomic_weak_ptr.cc: New test.

2 years agoFortran: xfail signaling NaN testcases on x87
Francois-Xavier Coudert [Sun, 16 Jan 2022 23:00:18 +0000 (00:00 +0100)]
Fortran: xfail signaling NaN testcases on x87

The ABI for x87 and x86-32 is not suitable for passing around
signaling NaNs in the way IEEE expects. See for example discussion
in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484

gcc/testsuite/ChangeLog:

* gfortran.dg/ieee/signaling_1.f90: xfail on x87.
* gfortran.dg/ieee/signaling_2.f90: xfail on x87.

2 years agoFortran: allow IEEE_VALUE to correctly return signaling NaNs
Francois-Xavier Coudert [Mon, 10 Jan 2022 16:04:34 +0000 (17:04 +0100)]
Fortran: allow IEEE_VALUE to correctly return signaling NaNs

I moved the library implementation of IEEE_VALUE in libgfortran from
Fortran to C code, which gives us access to GCC's built-ins for NaN generation
(both quiet and signalling). It will be perform better than the current
Fortran implementation.

libgfortran/ChangeLog:

PR fortran/82207
* mk-kinds-h.sh: Add values for TINY.
* ieee/ieee_arithmetic.F90: Call C helper functions for
IEEE_VALUE.
* ieee/ieee_helper.c: New functions ieee_value_helper_N for each
floating-point type.

gcc/testsuite/ChangeLog:

PR fortran/82207
* gfortran.dg/ieee/ieee_10.f90: Do not create signaling NaNs.
* gfortran.dg/ieee/signaling_2.f90: New test.
* gfortran.dg/ieee/signaling_2_c.c: New file.

2 years agolibstdc++: Ignore deprecated warnings [PR104037]
Jonathan Wakely [Fri, 14 Jan 2022 22:08:16 +0000 (22:08 +0000)]
libstdc++: Ignore deprecated warnings [PR104037]

The std::pointer_to_binary_function utility was deprecated in C++11 and
removed in C++17. Libstdc++ has started to warn about using it, so
suppress the warnings for this test.

gcc/testsuite/ChangeLog:

PR testsuite/104037
* g++.old-deja/g++.robertl/eb43.C: Ad -Wno-deprecated.

2 years agotestsuite: Enrich tests with variants failing on the branch.
Mikael Morin [Sun, 16 Jan 2022 17:33:36 +0000 (18:33 +0100)]
testsuite: Enrich tests with variants failing on the branch.

Backporting the fix for pr103789 on the 11 branch revealed a lack of test
coverage for the tests provided with that fix.  Indeed, the tests use the KIND
argument of the respective intrinsics only with keyword arguments.
This adds variants with non-keyword arguments.

The tests enriched this way fail on the branch if the fix is cherry-picked
straightforwardly.  The fix will have to be tweaked slightly there.

PR fortran/103789
PR fortran/87711
PR fortran/97896

gcc/testsuite/ChangeLog:

* gfortran.dg/index_5.f90: Enrich test with usages of INDEX with
a non-keyword KIND argument.
* gfortran.dg/len_trim.f90: Same for LEN_TRIM.
* gfortran.dg/maskl_1.f90: Same for MASKL.
* gfortran.dg/maskr_1.f90: Same for MASKR.
* gfortran.dg/scan_3.f90: Same for SCAN.
* gfortran.dg/verify_3.f90: Same for VERIFY.

2 years agoamdgcn: Tune default OpenMP/OpenACC GPU utilization
Kwok Cheung Yeung [Thu, 29 Aug 2019 17:16:42 +0000 (10:16 -0700)]
amdgcn: Tune default OpenMP/OpenACC GPU utilization

libgomp/
* plugin/plugin-gcn.c (parse_target_attributes): Automatically set
the number of teams and threads if necessary.
(gcn_exec): Automatically set the number of gangs and workers if
necessary.

Co-Authored-By: Andrew Stubbs <ams@codesourcery.com>
2 years agoAdd VxWorks fixincludes hack, open posix API for C++
Olivier Hainque [Tue, 14 Jan 2020 10:46:42 +0000 (10:46 +0000)]
Add VxWorks fixincludes hack, open posix API for C++

When system headers expose a strict "open" prototype with
3 args, arrange to expose a C++ overload with only two.

2021-01-10  Olivier Hainque  <hainque@adacore.com>

* inclhack.def (vxworks_math_h_fp_c99): New hack.
* tests/base/fcntl.h: Update.
* fixincl.x: Regenerate.

2 years agoAdd VxWorks fixincludes hack, #include sysLib.h in time.h
Olivier Hainque [Thu, 6 Jan 2022 17:28:20 +0000 (17:28 +0000)]
Add VxWorks fixincludes hack, #include sysLib.h in time.h

Make sure there is a visible prototype of sysClkRateGet() when
CLOCKS_PER_SEC is #defined to that in time.h for VxWorks.  This
would typically be provided by sysLib.h.

2021-01-10  Olivier Hainque  <hainque@adacore.com>

* inclhack.def (vxworks_time_h_syslib): New hack.
* tests/base/time.h: Update.
* fixincl.x: Regenerate.

2 years agoAdd VxWorks fixincludes hack, C99 FP classification
Olivier Hainque [Mon, 10 Jan 2022 11:26:30 +0000 (11:26 +0000)]
Add VxWorks fixincludes hack, C99 FP classification

Arrange to provide missing defs for C99 FP classification functions
and constants queried by libstdc++ configure checks (C99 support for C++98)

2021-01-10  Olivier Hainque  <hainque@adacore.com>

* inclhack.def (vxworks_math_h_fp_c99): New hack.
* tests/base/math.h: Update.
* fixincl.x: Regenerate.

2 years ago[i386] GLC tuning: Break false dependency for dest register.
wwwhhhyyy [Mon, 30 Aug 2021 08:41:41 +0000 (16:41 +0800)]
[i386] GLC tuning: Break false dependency for dest register.

For GoldenCove micro-architecture, force insert zero-idiom in asm
template to break false dependency of dest register for several insns.

The related insns are:

VPERM/D/Q/PS/PD
VRANGEPD/PS/SD/SS
VGETMANTSS/SD/SH
VGETMANDPS/PD - mem version only
VPMULLQ
VFMULCSH/PH
VFCMULCSH/PH

gcc/ChangeLog:

* config/i386/i386.h (TARGET_DEST_FALSE_DEP_FOR_GLC): New macro.
* config/i386/sse.md (<avx512>_<complexopname>_<mode><maskc_name><round_name>):
Insert zero-idiom in output template when attr enabled, set new attribute to
true for non-mask/maskz insn.
(avx512fp16_<complexopname>sh_v8hf<mask_scalarc_name><round_scalarcz_name>):
Likewise.
(avx512dq_mul<mode>3<mask_name>): Likewise.
(<avx2_avx512>_permvar<mode><mask_name>): Likewise.
(avx2_perm<mode>_1<mask_name>): Likewise.
(avx512f_perm<mode>_1<mask_name>): Likewise.
(avx512dq_rangep<mode><mask_name><round_saeonly_name>): Likewise.
(avx512dq_ranges<mode><mask_scalar_name><round_saeonly_scalar_name>):
Likewise.
(<avx512>_getmant<mode><mask_name><round_saeonly_name>): Likewise.
(avx512f_vgetmant<mode><mask_scalar_name><round_saeonly_scalar_name>):
Likewise.
* config/i386/subst.md (mask3_dest_false_dep_for_glc_cond): New
subst_attr.
(mask4_dest_false_dep_for_glc_cond): Likewise.
(mask6_dest_false_dep_for_glc_cond): Likewise.
(mask10_dest_false_dep_for_glc_cond): Likewise.
(maskc_dest_false_dep_for_glc_cond): Likewise.
(mask_scalar4_dest_false_dep_for_glc_cond): Likewise.
(mask_scalarc_dest_false_dep_for_glc_cond): Likewise.
* config/i386/x86-tune.def (X86_TUNE_DEST_FALSE_DEP_FOR_GLC): New
DEF_TUNE enabled for m_SAPPHIRERAPIDS and m_ALDERLAKE

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx2-dest-false-dep-for-glc.c: New test.
* gcc.target/i386/avx512dq-dest-false-dep-for-glc.c: Ditto.
* gcc.target/i386/avx512f-dest-false-dep-for-glc.c: Ditto.
* gcc.target/i386/avx512fp16-dest-false-dep-for-glc.c: Ditto.
* gcc.target/i386/avx512fp16vl-dest-false-dep-for-glc.c: Ditto.
* gcc.target/i386/avx512vl-dest-false-dep-for-glc.c: Ditto.

2 years agoDaily bump.
GCC Administrator [Sun, 16 Jan 2022 00:16:26 +0000 (00:16 +0000)]
Daily bump.

2 years agoAdd -Wdangling-pointer [PR63272].
Martin Sebor [Sat, 15 Jan 2022 23:41:40 +0000 (16:41 -0700)]
Add -Wdangling-pointer [PR63272].

Resolves:
PR c/63272 - GCC should warn when using pointer to dead scoped variable with
in the same function

gcc/c-family/ChangeLog:

PR c/63272
* c.opt (-Wdangling-pointer): New option.

gcc/ChangeLog:

PR c/63272
* diagnostic-spec.c (nowarn_spec_t::nowarn_spec_t): Handle
-Wdangling-pointer.
* doc/invoke.texi (-Wdangling-pointer): Document new option.
* gimple-ssa-warn-access.cc (pass_waccess::clone): Set new member.
(pass_waccess::check_pointer_uses): New function.
(pass_waccess::gimple_call_return_arg): New function.
(pass_waccess::gimple_call_return_arg_ref): New function.
(pass_waccess::check_call_dangling): New function.
(pass_waccess::check_dangling_uses): New function overloads.
(pass_waccess::check_dangling_stores): New function.
(pass_waccess::check_dangling_stores): New function.
(pass_waccess::m_clobbers): New data member.
(pass_waccess::m_func): New data member.
(pass_waccess::m_run_number): New data member.
(pass_waccess::m_check_dangling_p): New data member.
(pass_waccess::check_alloca): Check m_early_checks_p.
(pass_waccess::check_alloc_size_call): Same.
(pass_waccess::check_strcat): Same.
(pass_waccess::check_strncat): Same.
(pass_waccess::check_stxcpy): Same.
(pass_waccess::check_stxncpy): Same.
(pass_waccess::check_strncmp): Same.
(pass_waccess::check_memop_access): Same.
(pass_waccess::check_read_access): Same.
(pass_waccess::check_builtin): Call check_pointer_uses.
(pass_waccess::warn_invalid_pointer): Add arguments.
(is_auto_decl): New function.
(pass_waccess::check_stmt): New function.
(pass_waccess::check_block): Call check_stmt.
(pass_waccess::execute): Call check_dangling_uses,
check_dangling_stores.  Empty m_clobbers.
* passes.def (pass_warn_access): Invoke pass two more times.

gcc/testsuite/ChangeLog:

PR c/63272
* g++.dg/warn/Wfree-nonheap-object-6.C: Disable valid warnings.
* g++.dg/warn/ref-temp1.C: Prune expected warning.
* gcc.dg/uninit-pr50476.c: Expect a new warning.
* c-c++-common/Wdangling-pointer-2.c: New test.
* c-c++-common/Wdangling-pointer-3.c: New test.
* c-c++-common/Wdangling-pointer-4.c: New test.
* c-c++-common/Wdangling-pointer-5.c: New test.
* c-c++-common/Wdangling-pointer-6.c: New test.
* c-c++-common/Wdangling-pointer.c: New test.
* g++.dg/warn/Wdangling-pointer-2.C: New test.
* g++.dg/warn/Wdangling-pointer.C: New test.
* gcc.dg/Wdangling-pointer-2.c: New test.
* gcc.dg/Wdangling-pointer.c: New test.

2 years agoAdd -Wuse-after-free [PR80532].
Martin Sebor [Sat, 15 Jan 2022 23:37:54 +0000 (16:37 -0700)]
Add -Wuse-after-free [PR80532].

gcc/c-family/ChangeLog

PR tree-optimization/80532
* c.opt (-Wuse-after-free): New options.

gcc/ChangeLog:

PR tree-optimization/80532
* common.opt (-Wuse-after-free): New options.
* diagnostic-spec.c (nowarn_spec_t::nowarn_spec_t): Handle
OPT_Wreturn_local_addr and OPT_Wuse_after_free_.
* diagnostic-spec.h (NW_DANGLING): New enumerator.
* doc/invoke.texi (-Wuse-after-free): Document new option.
* gimple-ssa-warn-access.cc (pass_waccess::check_call): Rename...
(pass_waccess::check_call_access): ...to this.
(pass_waccess::check): Rename...
(pass_waccess::check_block): ...to this.
(pass_waccess::check_pointer_uses): New function.
(pass_waccess::gimple_call_return_arg): New function.
(pass_waccess::warn_invalid_pointer): New function.
(pass_waccess::check_builtin): Handle free and realloc.
(gimple_use_after_inval_p): New function.
(get_realloc_lhs): New function.
(maybe_warn_mismatched_realloc): New function.
(pointers_related_p): New function.
(pass_waccess::check_call): Call check_pointer_uses.
(pass_waccess::execute): Compute and free dominance info.

libcpp/ChangeLog:

* files.c (_cpp_find_file): Substitute a valid pointer for
an invalid one to avoid -Wuse-after-free.

libiberty/ChangeLog:

* regex.c: Suppress -Wuse-after-free.

gcc/testsuite/ChangeLog:

PR tree-optimization/80532
* gcc.dg/Wmismatched-dealloc-2.c: Avoid -Wuse-after-free.
* gcc.dg/Wmismatched-dealloc-3.c: Same.
* gcc.dg/analyzer/file-1.c: Prune expected warning.
* gcc.dg/analyzer/file-2.c: Same.
* gcc.dg/attr-alloc_size-6.c: Disable -Wuse-after-free.
* gcc.dg/attr-alloc_size-7.c: Same.
* c-c++-common/Wuse-after-free-2.c: New test.
* c-c++-common/Wuse-after-free-3.c: New test.
* c-c++-common/Wuse-after-free-4.c: New test.
* c-c++-common/Wuse-after-free-5.c: New test.
* c-c++-common/Wuse-after-free-6.c: New test.
* c-c++-common/Wuse-after-free-7.c: New test.
* c-c++-common/Wuse-after-free.c: New test.
* g++.dg/warn/Wmismatched-dealloc-3.C: New test.
* g++.dg/warn/Wuse-after-free.C: New test.

2 years agoFortran: fix ICE and wrong code with TRANSFER and CHARACTER(kind=4)
Harald Anlauf [Tue, 11 Jan 2022 21:06:10 +0000 (22:06 +0100)]
Fortran: fix ICE and wrong code with TRANSFER and CHARACTER(kind=4)

gcc/fortran/ChangeLog:

PR fortran/83079
* target-memory.c (gfc_interpret_character): Result length is
in bytes and thus depends on the character kind.
* trans-intrinsic.c (gfc_conv_intrinsic_transfer): Compute correct
string length for the result of the TRANSFER intrinsic and for
temporaries for the different character kinds.

gcc/testsuite/ChangeLog:

PR fortran/83079
* gfortran.dg/transfer_char_kind4.f90: New test.

2 years agolibstdc++: Fix ODR issues with different -m flags
Matthias Kretz [Mon, 1 Feb 2021 09:58:03 +0000 (10:58 +0100)]
libstdc++: Fix ODR issues with different -m flags

Explicitly support use of the stdx::simd implementation in situations
where the user links TUs that were compiled with different -m flags. In
general, this is always a (quasi) ODR violation for inline functions
because at least codegen may differ in important ways. However, in the
resulting executable only one (unspecified which one) of them might be
used. For simd we want to support users to compile code multiple times,
with different -m flags and have a runtime dispatch to the TU matching
the target CPU. But if internal functions are not inlined this may lead
to unexpected performance loss or execution of illegal instructions.
Therefore, inline functions that are not marked as always_inline must
use an additional template parameter somewhere in their name, to
disambiguate between the different -m translations.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd.h: Move feature detection bools
and add __have_avx512bitalg, __have_avx512vbmi2,
__have_avx512vbmi, __have_avx512ifma, __have_avx512cd,
__have_avx512vnni, __have_avx512vpopcntdq.
(__detail::__machine_flags): New function which returns a unique
uint64 depending on relevant -m and -f flags.
(__detail::__odr_helper): New type alias for either an anonymous
type or a type specialized with the __machine_flags number.
(_SimdIntOperators): Change template parameters from _Impl to
_Tp, _Abi because _Impl now has an __odr_helper parameter which
may be _OdrEnforcer from the anonymous namespace, which makes
for a bad base class.
(many): Either add __odr_helper template parameter or mark as
always_inline.
* include/experimental/bits/simd_detail.h: Add defines for
AVX512BITALG, AVX512VBMI2, AVX512VBMI, AVX512IFMA, AVX512CD,
AVX512VNNI, AVX512VPOPCNTDQ, and AVX512VP2INTERSECT.
* include/experimental/bits/simd_builtin.h: Add __odr_helper
template parameter or mark as always_inline.
* include/experimental/bits/simd_fixed_size.h: Ditto.
* include/experimental/bits/simd_math.h: Ditto.
* include/experimental/bits/simd_scalar.h: Ditto.
* include/experimental/bits/simd_neon.h: Add __odr_helper
template parameter.
* include/experimental/bits/simd_ppc.h: Ditto.
* include/experimental/bits/simd_x86.h: Ditto.

2 years agoi386: Improve and optimize ix86_expand_sse_movcc
Uros Bizjak [Sat, 15 Jan 2022 19:59:07 +0000 (20:59 +0100)]
i386: Improve and optimize ix86_expand_sse_movcc

Modernize ix86_expand_sse_movcc to use expand_simple_{unop,binop}
infrastructure to avoid manual twiddling with output registers.
Also fix a couple of inconsistent vector_all_ones_operand usages,
break a couple of unnecessary else-if chains, eliminate common
subexpressions and do some general code simplifications.

2022-01-15  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

* config/i386/i386-expand.c (ix86_expand_sse_movcc): Use
expand_simple_unop and expand_simple_binop instead of manually
constructing NOT, AND and IOR RTXes.  Use vector_all_ones_operand
consistently.  Eliminate common subexpressions and simplify code.
* config/i386/sse.md (<any_logic:code><MODEF:mode>3): New expander.
(<any_logic:code><MODEF:mode>3): Make public.

2 years agolibgcc: Fix __gthr_i486_lock_cmp_xchg clobber for Windows
Jonathan Yong [Sat, 15 Jan 2022 13:24:33 +0000 (13:24 +0000)]
libgcc: Fix __gthr_i486_lock_cmp_xchg clobber for Windows

2022-01-14  David  <gccbugzilla@limegreensocks.com>

libgcc/
* config/i386/gthr-win32.c (__gthr_i486_lock_cmp_xchg):
Remove inlined version, Windows 95 is no longer relevant.
* config/i386/gthr-win32.h
(__GTHREAD_I486_INLINE_LOCK_PRIMITIVES): unset.

2 years agoDaily bump.
GCC Administrator [Sat, 15 Jan 2022 00:16:27 +0000 (00:16 +0000)]
Daily bump.

2 years agoada: Fix up handling of ghost units [PR104027]
Andrew Pinski [Fri, 14 Jan 2022 22:58:38 +0000 (23:58 +0100)]
ada: Fix up handling of ghost units [PR104027]

As reported, libgnat-12.so gets PT_GNU_STACK RWE, which means it doesn't
work in some SELinux configurations.
This is caused by the a-nbnbig.o file, which is a ghost unit and since
r12-5670 the FE emits an object file for it, but exits before compile_file
has a chance to finalize it e.g. with targetm.asm_out.file_end ()
that emits the .note.GNU-stack section on various linux targets.

Fixed by not existing but instead returning early to the caller.

2022-01-14  Andrew Pinski  <apinski@marvell.com>

PR ada/104027
* gnat1drv.adb (Gnat1drv): After Back_End.Gen_Or_Update_Object_File
goto End_Of_Program.

2 years agoanalyzer: fix ICE when combining taint states has_ub and has_lb
David Malcolm [Fri, 14 Jan 2022 20:22:18 +0000 (15:22 -0500)]
analyzer: fix ICE when combining taint states has_ub and has_lb

gcc/analyzer/ChangeLog:
* sm-taint.cc (taint_state_machine::combine_states): Handle combination
of has_ub and has_lb.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/taint-merger.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fix ICE in taint checker on unary ops [PR104029]
David Malcolm [Fri, 14 Jan 2022 14:49:59 +0000 (09:49 -0500)]
analyzer: fix ICE in taint checker on unary ops [PR104029]

gcc/analyzer/ChangeLog:
PR analyzer/104029
* sm-taint.cc (taint_state_machine::alt_get_inherited_state):
Remove gcc_unreachable from default case for unary ops.

gcc/testsuite/ChangeLog:
PR analyzer/104029
* gcc.dg/analyzer/pr104029.c: New test.
* gcc.dg/analyzer/taint-ops.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoFortran: always reject alternate return specifier as argument of intrinsics
Harald Anlauf [Fri, 14 Jan 2022 20:48:15 +0000 (21:48 +0100)]
Fortran: always reject alternate return specifier as argument of intrinsics

The intrinsics MOVE_ALLOC, C_F_POINTER, and C_F_PROCPOINTER require
deferred checks of part of their actual argument types which may be of
"any" type.  This however excludes alternate return specifiers which
therefore must be unconditionally rejected for all standard intrinsics.

gcc/fortran/ChangeLog:

PR fortran/99256
* intrinsic.c: Do not check formal argument type when checking
arguments of intrinsics for alternate return specifiers.

gcc/testsuite/ChangeLog:

PR fortran/99256
* gfortran.dg/altreturn_11.f90: New test.

2 years agoFix reverse scalar storage order issues in IPA-SRA
Eric Botcazou [Fri, 14 Jan 2022 18:49:21 +0000 (19:49 +0100)]
Fix reverse scalar storage order issues in IPA-SRA

The IPA-SRA pass introduced in GCC 10 does not always play nice with the
reverse scalar storage order that can be used in structures/records/unions.
Reading the code, the pass apparently correctly detects it but fails to
propagate the information to the rewriting phase in some cases and, in
particular, does not stream it for LTO.

gcc/
* ipa-param-manipulation.c (ipa_dump_adjusted_parameters): Dump
reverse flag as "reverse" for the sake of consistency.
* ipa-sra.c: Fix copyright year.
(ipa_sra_function_summaries::duplicate): Copy the reverse flag.
(dump_isra_access): Tweak dump line.
(isra_write_node_summary): Write the reverse flag.
(isra_read_node_info): Read it.
(pull_accesses_from_callee): Test its consistency and copy it.

gcc/testsuite/
* gnat.dg/lto25.adb: New test.
* gnat.dg/opt96.adb: Likewise.
* gnat.dg/opt96_pkg.ads, gnat.dg/opt96_pkg.adb: New helper.

2 years agovect: Fix uninitialised variable PR104026
Richard Sandiford [Fri, 14 Jan 2022 18:41:12 +0000 (18:41 +0000)]
vect: Fix uninitialised variable PR104026

As noted by Tobias in the PR, the loop_vec_info constructor wasn't
initializing the new partial_load_store_bias field.

gcc/
PR middle-end/104026
* tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Initialize
partial_load_store_bias.

2 years agoFortran: fix ICE overloading elemental intrinsics
Harald Anlauf [Thu, 13 Jan 2022 20:50:45 +0000 (21:50 +0100)]
Fortran: fix ICE overloading elemental intrinsics

gcc/fortran/ChangeLog:

PR fortran/103782
* expr.c (gfc_simplify_expr): Adjust logic for when to scalarize a
call of an intrinsic which may have been overloaded.

gcc/testsuite/ChangeLog:

PR fortran/103782
* gfortran.dg/overload_4.f90: New test.

2 years agoUse enclosing object size if it's smaller than member [PR 101475].
Martin Sebor [Fri, 14 Jan 2022 18:13:08 +0000 (11:13 -0700)]
Use enclosing object size if it's smaller than member [PR 101475].

Resolves:
PR middle-end/101475 - missing -Wstringop-overflow storing a compound literal

gcc/ChangeLog:

PR middle-end/101475
* pointer-query.cc (handle_component_ref): Use the size of
the enclosing object if it's smaller than the member.

gcc/testsuite/ChangeLog:

PR middle-end/101475
* gcc.dg/Wstringop-overflow-15.c: Remove xfails.
* gcc.dg/Wstringop-overflow-68.c: Adjust, remove xfails.
* gcc.dg/Wstringop-overflow-88.c: New test.

2 years agoTest to verify -Wformat-overflow uses context-sensitive ranges.
Martin Sebor [Fri, 14 Jan 2022 16:59:53 +0000 (09:59 -0700)]
Test to verify -Wformat-overflow uses context-sensitive ranges.

gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/builtin-sprintf-warn-28.c: New test.

2 years agoconfigure: Regenerate.
Martin Liska [Fri, 14 Jan 2022 15:52:15 +0000 (16:52 +0100)]
configure: Regenerate.

Regenerate after change made in g:7c6ae994fb587c19ca14aebe18dbc9aca83be609.

gcc/ChangeLog:

* configure: Regenerate.

2 years agolibstdc++: Fix 22_locale/numpunct/members/char/3.cc execution test
Uros Bizjak [Fri, 14 Jan 2022 15:21:02 +0000 (16:21 +0100)]
libstdc++: Fix 22_locale/numpunct/members/char/3.cc execution test

The test fails on Fedora 33+ because nl_NL locale got thousands
separator defined.  Use one of ar_SA, bg_BG, bs_BA, pt_PT
or plain C locale instead.

2022-01-14  Uroš Bizjak  <ubizjak@gmail.com>

libstdc++-v3/ChangeLog:

* testsuite/22_locale/numpunct/members/char/3.cc:
Require pt_PT locale instead of nl_NL.
(test02): Use pt_PT locale instead of nl_NL.

2 years agotestsuite: fix dh-warning typo.
Martin Liska [Fri, 14 Jan 2022 15:15:35 +0000 (16:15 +0100)]
testsuite: fix dh-warning typo.

gcc/testsuite/ChangeLog:

* c-c++-common/Walloca-larger-than.c: Fix typo.

2 years agoi386: Mark some of strict_low_part insn constraints earlyclobbered
Uros Bizjak [Fri, 14 Jan 2022 15:05:17 +0000 (16:05 +0100)]
i386: Mark some of strict_low_part insn constraints earlyclobbered

While there is practically impossible that input registers are matched
with in-out register, better mark the output operand of the split alternative
as earlyclobbered - we do output early to the output operand when
the insn is split.

2022-01-14  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

* config/i386/i386.md (*add<mode>_1_slp"):
Mark alternative 1 output operand earlyclobbered.
(*sub<mode>_1_slp): Ditto.
(*and<mode>_1_slp): Ditto.
(*<code><mode>_1_slp): Ditto.
(*neg<mode>_1_slp): Ditto.
(*one_cmpl<mode>_1_slp): Ditto.
(*ashl<mode>3_1_slp): Ditto.
(*<insn><mode>3_1_slp): Ditto.
(*<insn><mode>3_1_slp): Ditto.

2 years agotestsuite: rename 2 files.
Martin Liska [Fri, 14 Jan 2022 14:21:40 +0000 (15:21 +0100)]
testsuite: rename 2 files.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/pr56868.cpp: Moved to...
* g++.dg/cpp0x/pr56868.C: ...here.
* gcc.dg/torture/pr57993-2.cpp: Moved to...
* g++.dg/torture/pr57993-2.C: ...here.

2 years agotestsuite: rename files in c-c++-common.
Martin Liska [Fri, 14 Jan 2022 14:04:33 +0000 (15:04 +0100)]
testsuite: rename files in c-c++-common.

gcc/testsuite/ChangeLog:

* c-c++-common/Walloca-larger-than.C: Moved to...
* c-c++-common/Walloca-larger-than.c: ...here.

2 years agoopenmp: Fix ICE in [PR103705]
Chung-Lin Tang [Fri, 14 Jan 2022 13:58:34 +0000 (21:58 +0800)]
openmp: Fix ICE in [PR103705]

Fix ICE for cases like:
  #pragma omp target update from(s[0].a[0:1])

where multiple ARRAY_REF nodes exist and require more than one peeling
during [c_]finish_omp_clauses.

PR c++/103705

gcc/c/ChangeLog:

* c-typeck.c (c_finish_omp_clauses): Also continue peeling off of
outer node for ARRAY_REFs.

gcc/cp/ChangeLog:

* semantics.c (finish_omp_clauses): Also continue peeling off of
outer node for ARRAY_REFs.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/pr103705.c: New test.

2 years agotestsuite: Remove executable mode from source files.
Martin Liska [Fri, 14 Jan 2022 13:01:38 +0000 (14:01 +0100)]
testsuite: Remove executable mode from source files.

gcc/testsuite/ChangeLog:

* g++.dg/vect/pr99149.cc: Remove executable mode.
* g++.dg/vect/pr99220.cc: Likewise.
* g++.target/i386/avx512vl-pr100738-1.C: Likewise.
* g++.target/i386/pr100738-1.C: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/bfdot-1.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/bfdot-2.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/bfdot-3.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vdot-3-1.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vdot-3-2.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vdot-3-3.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vdot-3-4.c: Likewise.
* gcc.target/i386/pr101796-1.c: Likewise.
* gcc.target/i386/pr94790-1.c: Likewise.
* gcc.target/i386/pr94790-2.c: Likewise.
* gcc.target/powerpc/mma-double-test.c: Likewise.
* gcc.target/powerpc/mma-single-test.c: Likewise.
* gdc.test/fail_compilation/constraints_aggr.d: Likewise.
* gdc.test/fail_compilation/constraints_defs.d: Likewise.
* gdc.test/fail_compilation/constraints_func1.d: Likewise.
* gdc.test/fail_compilation/constraints_func2.d: Likewise.
* gdc.test/fail_compilation/constraints_func3.d: Likewise.
* gdc.test/fail_compilation/constraints_func4.d: Likewise.
* gdc.test/fail_compilation/constraints_tmpl.d: Likewise.
* gdc.test/fail_compilation/imports/constraints.d: Likewise.

2 years agovect: Check partial vector param for supports_partial_vectors [PR104015]
Kewen Lin [Fri, 14 Jan 2022 13:02:10 +0000 (07:02 -0600)]
vect: Check partial vector param for supports_partial_vectors [PR104015]

As described in PR104015, the function partial_vectors_supported_p
mainly checks optabs for partial vectors support query, but we
still have one parameter param_vect_partial_vector_usage to control
the capability.

Power9 introduces vector with length instructions (for
len_load/len_store) but we don't enable partial vector on it by
default. It should be considered as not supporting partial vector by
default. This fix is to make the flag supports_partial_vectors check
param_vect_partial_vector_usage accordingly.

gcc/ChangeLog:

PR tree-optimization/104015
* tree-vect-loop.c (vect_analyze_loop): Check
param_vect_partial_vector_usage for supports_partial_vectors.

2 years agolibstdc++: Add attribute to features deprecated in C++17 [PR91260]
Jonathan Wakely [Tue, 11 Jan 2022 18:42:38 +0000 (18:42 +0000)]
libstdc++: Add attribute to features deprecated in C++17 [PR91260]

There are a lot of things in the C++ standard library which were
deprecated in C++11, and more in C++17.  Some of them were removed after
deprecation and are no longer present in the standard at all. We have
not removed these from libstdc++ because keeping them as non-standard
extensions is conforming, and avoids gratuitously breaking user code,
and in some cases we need to keep using them to avoid ABI changes. But
we should at least give a warning for using them. That has not been done
previously because of the library's own uses of them (e.g. the
std::iterator class template used as a base class).

This adds deprecated attributes to the relevant components, and then
goes through the whole library to add diagnostic pragmas where needed to
suppress warnings about our internal uses of them. The tests are updated
to either expect the additional warnings, or to suppress them where we
aren't interested in them.

libstdc++-v3/ChangeLog:

PR libstdc++/91260
PR libstdc++/91383
PR libstdc++/95065
* include/backward/binders.h (bind1st, bind2nd): Add deprecated
attribute.
* include/bits/refwrap.h (_Maybe_unary_or_binary_function):
Disable deprecated warnings for base classes.
(_Reference_wrapper_base): Likewise.
* include/bits/shared_ptr_base.h (_Sp_owner_less): Likewise.
* include/bits/stl_bvector.h (_Bit_iterator_base): Likewise.
* include/bits/stl_function.h (unary_function, binary_function):
Add deprecated attribute.
(unary_negate, not1, binary_negate, not2, ptr_fun)
(pointer_to_unary_function, pointer_to_binary_function)
(mem_fun_t, const_mem_fun_t, mem_fun_ref_t, const_mem_fun_ref_t)
(mem_fun1_t, const_mem_fun1_t, mem_fun_ref1_t)
(const_mem_fun1_ref_t, mem_fun, mem_fun_ref): Add deprecated
attributes.
* include/bits/stl_iterator.h: Disable deprecated warnings for
std::iterator base classes.
* include/bits/stl_iterator_base_types.h (iterator): Add
deprecated attribute.
* include/bits/stl_map.h (map::value_compare): Disable
deprecated warnings for base class.
* include/bits/stl_multimap.h (multimap::value_compare):
Likewise.
* include/bits/stl_raw_storage_iter.h (raw_storage_iterator):
Add deprecated attribute.
* include/bits/stl_tempbuf.h (get_temporary_buffer): Likewise.
* include/bits/stream_iterator.h: Disable deprecated warnings.
* include/bits/streambuf_iterator.h: Likewise.
* include/ext/bitmap_allocator.h: Remove unary_function base
classes.
* include/ext/functional: Disable deprecated warnings.
* include/ext/rope: Likewise.
* include/ext/throw_allocator.h: Likewise.
* include/std/type_traits (result_of): Add deprecated attribute.
* include/tr1/functional: Disable deprecated warnings.
* include/tr1/functional_hash.h: Likewise.
* testsuite/20_util/function_objects/binders/1.cc: Add
-Wno-disable-deprecations.
* testsuite/20_util/function_objects/binders/3113.cc: Likewise.
* testsuite/20_util/function_objects/constexpr.cc: Add
dg-warning.
* testsuite/20_util/raw_storage_iterator/base.cc: Likewise.
* testsuite/20_util/raw_storage_iterator/dr2127.cc: Likewise.
* testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc:
Likewise.
* testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/reference_wrapper/24803.cc:
Likewise.
* testsuite/20_util/reference_wrapper/typedefs.cc: Enable for
C++20 and check for absence of nested types.
* testsuite/20_util/shared_ptr/comparison/less.cc: Remove
std::binary_function base class.
* testsuite/20_util/temporary_buffer.cc: Add dg-warning.
* testsuite/21_strings/basic_string/cons/char/69092.cc: Remove
std::iterator base class.
* testsuite/24_iterators/back_insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/front_insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/istream_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/istreambuf_iterator/92285.cc:
Likewise.
* testsuite/24_iterators/istreambuf_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/ostream_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/ostreambuf_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/reverse_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/25_algorithms/copy/34595.cc:
Likewise.
* testsuite/25_algorithms/minmax/3.cc: Remove std::binary_function
base class.
* testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc:
Disable deprecated warnings.
* testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/27_io/basic_filebuf/underflow/wchar_t/9178.cc: Add
dg-warning.
* testsuite/ext/pb_ds/example/priority_queue_erase_if.cc:
Likewise.
* testsuite/ext/pb_ds/example/priority_queue_split_join.cc:
Likewise.
* testsuite/tr1/3_function_objects/reference_wrapper/typedefs.cc:
Disable deprecated warnings.
* testsuite/tr1/6_containers/hash/requirements/base_classes.cc:
Likewise.
* testsuite/util/regression/trait/erase_if_fn.hpp: Remove
std::unary_function base classes.
* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
Remove std::iterator base classes.

2 years agolibgfortran: Partly revert my r12-6498 change to fix Solaris build [PR104006]
Jakub Jelinek [Fri, 14 Jan 2022 11:11:00 +0000 (12:11 +0100)]
libgfortran: Partly revert my r12-6498 change to fix Solaris build [PR104006]

In r12-6498 I've added $(version_dep) to BUILT_SOURCES, previously version_dep
on Linux used to be a file in $(srcdir), but with my changes it is a generated
file in the object directory (preprocessed version of the $(srcdir) file)
and I thought generated files belong to BUILT_SOURCES so that they are
cleaned up etc.
For Linux that is fine, but it broke parallel builds on Solaris.
BUILT_SOURCES is a special variable for automake where automake ensures
that for make all, make check and make install all those $(BUILT_SOURCES)
are generated before actually starting building in parallel the various
object files.  That way we can avoid hacks like:
$(patsubst %.F90,%.lo,$(notdir $(filter %.F90,$(prereq_SRC)))): kinds.inc c99_protos.inc
$(patsubst %.c,%.lo,$(notdir $(filter %.c,$(prereq_SRC)))): kinds.h
$(patsubst %.f90,%.lo,selected_real_kind.f90): selected_real_kind.inc
$(patsubst %.f90,%.lo,selected_int_kind.f90): selected_int_kind.inc
$(patsubst %.F90,%.lo,ieee_exceptions.F90): fpu-target.inc
$(patsubst %.F90,%.lo,ieee_arithmetic.F90): fpu-target.inc ieee_exceptions.lo
$(patsubst %.c,%.lo,fpu.c): fpu-target.h
which makes those dependencies explicit but hides it from automake, so that it
doesn't throw away its rules for those object files.
On Solaris, $(version_dep) contains gfortran.ver and gfortran.ver-sun.
gfortran.ver is like on Linux, it can be in $(BUILT_SOURCES), but unfortunately
gfortran.ver-sun depends on all the object files being compiled already,
so if gfortran.ver-sun appears in $(BUILT_SOURCES), the BUILT_SOURCES function
of ensuring the generated files are generated before building object files
is gone, almost everything is built before all-am is entered and there
are no explicit dependencies that e.g. *.F90 files depend on
kinds.inc etc.

So, this change reverts that mistake and instead adds $(version_dep) to
what is removed during make clean (clean-local in particular).

2022-01-14  Jakub Jelinek  <jakub@redhat.com>

PR libfortran/104006
* Makefile.am (BUILT_SOURCES): Don't include $(version_dep).
(clean-local): Remove $(version_dep).
* Makefile.in: Regenerated.

2 years agoc++: Avoid some -Wreturn-type false positives with const{expr,eval} if [PR103991]
Jakub Jelinek [Fri, 14 Jan 2022 11:09:19 +0000 (12:09 +0100)]
c++: Avoid some -Wreturn-type false positives with const{expr,eval} if [PR103991]

The changes done to genericize_if_stmt in order to improve
-Wunreachable-code* warning (which Richi didn't actually commit
for GCC 12) are I think fine for normal ifs, but for constexpr if
and consteval if we have two competing warnings.
The problem is that we replace the non-taken clause (then or else)
with void_node and keep the if (cond) { something } else {}
or if (cond) {} else { something }; in the IL.
This helps -Wunreachable-code*, if something can't fallthru but the
non-taken clause can, we don't warn about code after it because it
is still (in theory) reachable.
But if the non-taken branch can't fallthru, we can get false positive
-Wreturn-type warnings (which are enabled by default) if there is
nothing after the if and the taken branch can't fallthru either.

One possibility to fix this is revert at least temporarily
to the previous behavior for constexpr and consteval if, yes, we
can get false positive -Wunreachable-code* warnings but the warning
isn't present in GCC 12.
The patch below implements that for constexpr if which throws its
clauses very early (either during parsing or during instantiation),
and for consteval if it decides based on block_may_fallthru on the
non-taken (for constant evaluation only) clause - if the non-taken
branch may fallthru, it does what you did in genericize_if_stmt
for consteval if, if it can't fallthru, it uses the older way
of pretending there wasn't an if and just replacing it with the
taken clause.  There are some false positive risks with this though,
block_may_fallthru is optimistic and doesn't handle some statements
at all (like FOR_STMT, WHILE_STMT, DO_STMT - of course handling those
is quite hard).
For constexpr if (but perhaps for GCC 13?) we could try to
block_may_fallthru before we throw it away and remember it in some
flag on the IF_STMT, but am not sure how dangerous would it be to call
it on the discarded stmts.  Or if it is too dangerous e.g. just
remember whether the discarded block of consteval if wasn't present
or was empty, in that case assume fallthru, and otherwise assume
it can't fallthru (-Wunreachable-code possible false positives).

2022-01-14  Jakub Jelinek  <jakub@redhat.com>

PR c++/103991
* cp-objcp-common.c (cxx_block_may_fallthru) <case IF_STMT>: For
IF_STMT_CONSTEXPR_P with constant false or true condition only
check if the taken clause may fall through.
* cp-gimplify.c (genericize_if_stmt): For consteval if, revert
to r12-5638^ behavior if then_ block can't fall through.  For
constexpr if, revert to r12-5638^ behavior.

* g++.dg/warn/Wreturn-type-13.C: New test.

2 years agoc++: Reject in constant evaluation address comparisons of start of one var and end...
Jakub Jelinek [Fri, 14 Jan 2022 11:07:49 +0000 (12:07 +0100)]
c++: Reject in constant evaluation address comparisons of start of one var and end of another [PR89074]

The following testcase used to be incorrectly accepted.  The match.pd
optimization that uses address_compare punts on folding comparison
of start of one object and end of another one only when those addresses
are cast to integral types, when the comparison is done on pointer types
it assumes undefined behavior and decides to fold the comparison such
that the addresses don't compare equal even when they at runtime they
could be equal.
But C++ says it is undefined behavior and so during constant evaluation
we should reject those, so this patch adds !folding_initializer &&
check to that spot.

Note, address_compare has some special cases, e.g. it assumes that
static vars are never adjacent to automatic vars, which is the case
for the usual layout where automatic vars are on the stack and after
.rodata/.data sections there is heap:
  /* Assume that automatic variables can't be adjacent to global
     variables.  */
  else if (is_global_var (base0) != is_global_var (base1))
    ;
Is it ok that during constant evaluation we don't treat those as undefined
behavior, or shall that be with !folding_initializer && too?

Another special case is:
  if ((DECL_P (base0) && TREE_CODE (base1) == STRING_CST)
       || (TREE_CODE (base0) == STRING_CST && DECL_P (base1))
       || (TREE_CODE (base0) == STRING_CST
           && TREE_CODE (base1) == STRING_CST
           && ioff0 >= 0 && ioff1 >= 0
           && ioff0 < TREE_STRING_LENGTH (base0)
           && ioff1 < TREE_STRING_LENGTH (base1)
          /* This is a too conservative test that the STRING_CSTs
             will not end up being string-merged.  */
           && strncmp (TREE_STRING_POINTER (base0) + ioff0,
                       TREE_STRING_POINTER (base1) + ioff1,
                       MIN (TREE_STRING_LENGTH (base0) - ioff0,
                            TREE_STRING_LENGTH (base1) - ioff1)) != 0))
    ;
  else if (!DECL_P (base0) || !DECL_P (base1))
    return 2;
Here we similarly assume that vars aren't adjacent to string literals
or vice versa.  Do we need to stick !folding_initializer && to those
DECL_P vs. STRING_CST cases?  Though, because of the return 2; for
non-DECL_P that would mean rejecting comparisons like &var == &"foobar"[3]
etc. which ought to be fine, no?  So perhaps we need to watch for
decls. vs. STRING_CSTs like for DECLs whether the address is at the start
or at the end of the string literal or somewhere in between (at least
for folding_initializer)?
And yet another chapter but probably unsolvable is comparison of
string literal addresses.  I think pedantically in C++
&"foo"[0] == &"foo"[0] is undefined behavior, different occurences of
the same string literals might still not be merged in some implementations.
But constexpr const char *s = "foo"; &s[0] == &s[0] should be well defined,
and we aren't tracking anywhere whether the string literal was the same one
or different (and I think other compilers don't track that either).

2022-01-14  Jakub Jelinek  <jakub@redhat.com>

PR c++/89074
* fold-const.c (address_compare): Punt on comparison of address of
one object with address of end of another object if
folding_initializer.

* g++.dg/cpp1y/constexpr-89074-1.C: New test.

2 years agoforwprop: Canonicalize atomic fetch_op op x to op_fetch or vice versa [PR98737]
Jakub Jelinek [Fri, 14 Jan 2022 11:04:59 +0000 (12:04 +0100)]
forwprop: Canonicalize atomic fetch_op op x to op_fetch or vice versa [PR98737]

When writing the PR98737 fix, I've handled just the case where people
use __atomic_op_fetch (p, x, y) etc.
But some people actually use the other builtins, like
__atomic_fetch_op (p, x, y) op x.
The following patch canonicalizes the latter to the former and vice versa
when possible if the result of the builtin is a single use and if
that use is a cast with same precision, also that cast's lhs has a single
use.
For all ops of +, -, &, | and ^ we can do those
__atomic_fetch_op (p, x, y) op x -> __atomic_op_fetch (p, x, y)
(and __sync too) opts, but cases of INTEGER_CST and SSA_NAME x
behave differently.  For INTEGER_CST, typically - x is
canonicalized to + (-x), while for SSA_NAME we need to handle various
casts, which sometimes happen on the second argument of the builtin
(there can be even two subsequent casts for char/short due to the
promotions we do) and there can be a cast on the argument of op too.
And all ops but - are commutative.
For the other direction, i.e.
__atomic_op_fetch (p, x, y) rop x -> __atomic_fetch_op (p, x, y)
we can't handle op of & and |, those aren't reversible, for
op + rop is -, for - rop is + and for ^ rop is ^, otherwise the same
stuff as above applies.
And, there is another case, we canonicalize
x - y == 0 (or != 0) and x ^ y == 0 (or != 0) to x == y (or x != y)
and for constant y x + y == 0 (or != 0) to x == -y (or != -y),
so the patch also virtually undoes those canonicalizations, because
e.g. for the earlier PR98737 patch but even generally, it is better
if a result of atomic op fetch is compared against 0 than doing
atomic fetch op and compare it to some variable or non-zero constant.
As for debug info, for non-reversible operations (& and |) the patch
resets debug stmts if there are any, for -fnon-call-exceptions too
(didn't want to include debug temps right before all uses), but
otherwise it emits (on richi's request) the reverse operation from
the result as a new setter of the old lhs, so that later DCE fixes
up the debug info.

On the emitted assembly for the testcases which are fairly large,
I see substantial decreases of the *.s size:
-rw-rw-r--. 1 jakub jakub 116897 Jan 13 09:58 pr98737-1.svanilla
-rw-rw-r--. 1 jakub jakub  93861 Jan 13 09:57 pr98737-1.spatched
-rw-rw-r--. 1 jakub jakub  70257 Jan 13 09:57 pr98737-2.svanilla
-rw-rw-r--. 1 jakub jakub  67537 Jan 13 09:57 pr98737-2.spatched
There are some functions where due to RA we get one more instruction
than previously, but most of them are smaller even when not hitting
the PR98737 previous patch's optimizations.

2022-01-14  Jakub Jelinek  <jakub@redhat.com>

PR target/98737
* tree-ssa-forwprop.c (simplify_builtin_call): Canonicalize
__atomic_fetch_op (p, x, y) op x into __atomic_op_fetch (p, x, y)
and __atomic_op_fetch (p, x, y) iop x into
__atomic_fetch_op (p, x, y).

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

2 years agoarc: Add DWARF2 alternate CFA column.
Claudiu Zissulescu [Wed, 5 Jan 2022 13:22:10 +0000 (15:22 +0200)]
arc: Add DWARF2 alternate CFA column.

Add DWARF 2 CFA column which tracks the return address from a signal
handler context.  This value must not correspond to a hard register
and must be out of the range of DWARF_FRAME_REGNUM().

gcc/
* config/arc/arc.h (DWARF_FRAME_REGNUM): Update definition.
(DWARF_FRAME_RETURN_COLUMN): Use RETURN_ADDR_REGNUM macro.
(INCOMING_RETURN_ADDR_RTX): Likewise.
(DWARF_ALT_FRAME_RETURN_COLUMN): Define.

gcc/testsuite/
* gcc.target/arc/cancel-1.c: New file.

libgcc/
* config/arc/linux-unwind.h (arc_fallback_frame_state): Use
DWARF_ALT_FRAME_RETURN_COLUMN macro.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2 years agoarc: Update stack size computation when accumulator registers are available.
Claudiu Zissulescu [Thu, 25 Nov 2021 13:38:03 +0000 (15:38 +0200)]
arc: Update stack size computation when accumulator registers are available.

When accumulator registers are available in a processor, they need to
be save onto stack durring interrupts.  We were already doing so, but
the stack size was wrongly computed in the case other than ARC600.

gcc/

* config/arc/arc.c (arc_compute_frame_size): Remove condition when
computin checking accumulator regs.
(arc_expand_prologue): Update comments.
(arc_expand_epilogue): Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2 years agolibstdc++: Add C++20 std::make_shared enhancements (P0674R1)
Jonathan Wakely [Thu, 13 Jan 2022 22:08:43 +0000 (22:08 +0000)]
libstdc++: Add C++20 std::make_shared enhancements (P0674R1)

This adds the overloads of std::make_shared and std::allocate_shared for
creating arrays, added to C++20 by P0674R1.

It also adds std::make_shared_for_overwrite, added to C++20 by P1020R1
(and renamed by P1973R1). The std::make_unique_for_overwite overloads
are already supported.

The original std::make_shared overload is changed to construct a
shared_ptr directly instead of calling std::allocate_shared. This
removes a function call at runtime, and avoids having to do overload
resolution for std::allocate_shared, now that there are five overloads
of it.

Allocating a shared array is done by a new __shared_count constructor.
An array is allocated with space for additional elements at the end and
an instance of new _Sp_counted_array class template is constructed in
that unused capacity.

The non-array form of std::make_shared_for_overwrite uses the same
__shared_count constructor as the original std::make_shared overload,
but a new partial specialization of _Sp_counted_ptr_inplace is selected
when the allocator's value_type is the new _Sp_overwrite_tag type. That
new partial specialization default-initializes its contained object and
destroys it with a destructor call rather than using the allocator.

Despite being C++20 features, this implementation only uses concepts
conditionally, with workarounds when they are not supported. This allows
it to work with older non-GCC compilers (Clang 9 and icc 2021). At some
point we can simplify the code by removing the workarounds.

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr.h (__cpp_lib_shared_ptr_weak_type):
Correct type of macro value.
(shared_ptr): Add additional friend declarations.
(make_shared, allocate_shared): Constrain existing overloads and
remove static_assert.
* include/bits/shared_ptr_base.h (__cpp_lib_smart_ptr_for_overwrite):
New macro.
(_Sp_counted_ptr_inplace<T, Alloc, Lp>): New partial
specialization for use with make_shared_for_overwrite.
(__cpp_lib_shared_ptr_arrays): Update value for C++20.
(_Sp_counted_array_base): New class template.
(_Sp_counted_array): New class template.
(__shared_count(_Tp*&, const _Sp_counted_array_base&, _Init)):
New constructor for allocating shared arrays.
(__shared_ptr(const _Sp_counted_array_base&, _Init)): Likewise.
* include/std/version (__cpp_lib_shared_ptr_weak_type): Correct
type.
(__cpp_lib_shared_ptr_arrays): Update value for C++20.
(__cpp_lib_smart_ptr_for_overwrite): New macro.
* testsuite/20_util/shared_ptr/creation/99006.cc: Adjust
expected errors.
* testsuite/20_util/shared_ptr/creation/array.cc: New test.
* testsuite/20_util/shared_ptr/creation/overwrite.cc: New test.
* testsuite/20_util/shared_ptr/creation/version.cc: New test.
* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: Check
feature test macro. Test non-trivial default-initialization.

2 years agolibstdc++: Ignore cv-quals when std::allocator<void> constructs
Jonathan Wakely [Thu, 13 Jan 2022 21:59:13 +0000 (21:59 +0000)]
libstdc++: Ignore cv-quals when std::allocator<void> constructs

When I added the std::allocator_traits<std::allocator<void>>
specialization it broke code like this:

  std::allocate_shared<const int>(std::allocator<void>());

The problem is that allocator_traits<allocator<void>>::construct(a, p)
now uses std::_Construct(p), which only does a static_cast<void*>(p) and
so fails if the pointer has cv-quals.

This changes std::_Construct (and the related std::_Construct_novalue)
to use a C-style cast to (void*) which matches the effects of the
"voidify" helper in the C++20 standard.

libstdc++-v3/ChangeLog:

* include/bits/stl_construct.h (_Construct, _Construct_novalue):
Also cast away cv-qualifiers when converting pointer to void.
* testsuite/20_util/allocator/void.cc: Test construct function
with cv-qualified types.

2 years agolibstdc++: Use std::construct_at in std::common_iterator [PR103992]
Jonathan Wakely [Wed, 12 Jan 2022 16:58:18 +0000 (16:58 +0000)]
libstdc++: Use std::construct_at in std::common_iterator [PR103992]

This should have been done as part of the LWG 3574 changes.

libstdc++-v3/ChangeLog:

PR libstdc++/103992
* include/bits/stl_iterator.h (common_iterator): Use
std::construct_at instead of placement new.
* testsuite/24_iterators/common_iterator/1.cc: Check copy
construction is usable in constant expressions.

2 years agolibstdc++: Document new std::random_device tokens
Jonathan Wakely [Tue, 11 Jan 2022 21:27:28 +0000 (21:27 +0000)]
libstdc++: Document new std::random_device tokens

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2011.xml: Document new tokens
accepted by std::random_device constructor.
* doc/html/manual/status.html: Regenerate.

2 years agox86_64: Improvements to arithmetic right shifts of V1TImode values.
Roger Sayle [Fri, 14 Jan 2022 10:06:03 +0000 (10:06 +0000)]
x86_64: Improvements to arithmetic right shifts of V1TImode values.

This patch to the i386 backend's ix86_expand_v1ti_ashiftrt provides
improved (shorter) implementations of V1TI mode arithmetic right shifts
for constant amounts between 111 and 126 bits.  The significance of
this range is that this functionality is useful for (eventually)
providing sign extension from HImode and QImode to V1TImode.

For example, x>>112 (to sign extend a 16-bit value), was previously
generated as a four operation sequence:

        movdqa  %xmm0, %xmm1 // word    7 6 5 4 3 2 1 0
        psrad   $31, %xmm0 // V8HI = [S,S,?,?,?,?,?,?]
        psrad   $16, %xmm1 // V8HI = [S,X,?,?,?,?,?,?]
        punpckhqdq      %xmm0, %xmm1 // V8HI = [S,S,?,?,S,X,?,?]
        pshufd  $253, %xmm1, %xmm0 // V8HI = [S,S,S,S,S,S,S,X]

with this patch, we now generates a three operation sequence:

        psrad   $16, %xmm0 // V8HI = [S,X,?,?,?,?,?,?]
        pshufhw $254, %xmm0, %xmm0 // V8HI = [S,S,S,X,?,?,?,?]
        pshufd  $254, %xmm0, %xmm0 // V8HI = [S,S,S,S,S,S,S,X]

The correctness of generated code is confirmed by the existing
run-time test gcc.target/i386/sse2-v1ti-ashiftrt-1.c in the testsuite.
This idiom is safe to use for shifts by 127, but that case gets handled
by a two operation sequence earlier in this function.

2022-01-14  Roger Sayle  <roger@nextmovesoftware.com>
    Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
* config/i386/i386-expand.c (ix86_expand_v1ti_to_ti): Use force_reg.
(ix86_expand_ti_to_v1ti): Use force_reg.
(ix86_expand_v1ti_shift): Use force_reg.
(ix86_expand_v1ti_rotate): Use force_reg.
(ix86_expand_v1ti_ashiftrt): Provide new three operation
implementations for shifts by 111..126 bits.  Use force_reg.

2 years agoARM: fix -Wformat= error
Martin Liska [Fri, 14 Jan 2022 08:16:39 +0000 (09:16 +0100)]
ARM: fix -Wformat= error

gcc/ChangeLog:

* common/config/arm/arm-common.c (arm_target_mode): Fix
warning: unterminated quoting directive [-Wformat=].

2 years agotree-optimization/104009: Conservative underflow estimate in object size
Siddhesh Poyarekar [Fri, 14 Jan 2022 03:26:15 +0000 (08:56 +0530)]
tree-optimization/104009: Conservative underflow estimate in object size

Restrict negative offset computation only to dynamic object sizes, where
size expressions are accurate and not a maximum/minimum estimate and in
cases where negative offsets definitely mean an underflow, e.g. in
MEM_REF of the whole object with negative ofset in addr_object_size.

This ends up missing some cases where __builtin_object_size could have
come up with more precise results, so tests have been adjusted to
reflect that.

gcc/ChangeLog:

PR tree-optimization/104009
* tree-object-size.c (compute_builtin_object_size): Bail out on
negative offset.
(plus_stmt_object_size): Return maximum of wholesize and minimum
of 0 for negative offset.

gcc/testsuite/ChangeLog:

PR tree-optimization/104009
* gcc.dg/builtin-object-size-1.c (test10): New test.
* gcc.dg/builtin-object-size-3.c (test10): Likewise.
(test9): Expect zero size for negative offsets.
* gcc.dg/builtin-object-size-4.c (test8): Likewise.
* gcc.dg/builtin-object-size-5.c (test7): Drop test for
__builtin_object_size.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2 years agoFix ICE of unrecognizable insn. [PR target/104001]
liuhongt [Thu, 13 Jan 2022 14:51:49 +0000 (22:51 +0800)]
Fix ICE of unrecognizable insn. [PR target/104001]

For define_insn_and_split "*xor2andn":

1. Refine predicate of operands[0] from nonimmediate_operand to
register_operand.
2. Remove TARGET_AVX512BW from condition to avoid kmov when TARGET_BMI
is not available.

gcc/ChangeLog:

PR target/104001
PR target/94790
PR target/104014
* config/i386/i386.md (*xor2andn): Refine predicate of
operands[0] from nonimmediate_operand to
register_operand, remove TARGET_AVX512BW from condition.

gcc/testsuite/ChangeLog:

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

2 years agoAdd __attribute__ ((tainted_args))
David Malcolm [Fri, 12 Nov 2021 15:06:23 +0000 (10:06 -0500)]
Add __attribute__ ((tainted_args))

This patch adds a new __attribute__ ((tainted_args)) to the C/C++ frontends.

It can be used on function decls: the analyzer will treat as tainted
all parameters to the function and all buffers pointed to by parameters
to the function.  Adding this in one place to the Linux kernel's
__SYSCALL_DEFINEx macro allows the analyzer to treat all syscalls as
having tainted inputs.  This gives some coverage of system calls without
needing to "teach" the analyzer about "__user" - an example of the use
of this can be seen in CVE-2011-2210, where given:

 SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
                 unsigned long, nbytes, int __user *, start, void __user *, arg)

the analyzer will treat the nbytes param as under attacker control, and
can complain accordingly:

taint-CVE-2011-2210-1.c: In function 'sys_osf_getsysinfo':
taint-CVE-2011-2210-1.c:69:21: warning: use of attacker-controlled value
  'nbytes' as size without upper-bounds checking [CWE-129] [-Wanalyzer-tainted-size]
   69 |                 if (copy_to_user(buffer, hwrpb, nbytes) != 0)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Additionally, the patch allows the attribute to be used on field decls:
specifically function pointers.  Any function used as an initializer
for such a field gets treated as being called with tainted arguments.
An example can be seen in CVE-2020-13143, where adding
__attribute__((tainted_args)) to the "store" callback of
configfs_attribute:

  struct configfs_attribute {
    /* [...snip...] */
    ssize_t (*store)(struct config_item *, const char *, size_t)
      __attribute__((tainted_args));
    /* [...snip...] */
  };

allows the analyzer to see:

 CONFIGFS_ATTR(gadget_dev_desc_, UDC);

and treat gadget_dev_desc_UDC_store as having tainted arguments, so that
it complains:

taint-CVE-2020-13143-1.c: In function 'gadget_dev_desc_UDC_store':
taint-CVE-2020-13143-1.c:33:17: warning: use of attacker-controlled value
  'len + 18446744073709551615' as offset without upper-bounds checking [CWE-823] [-Wanalyzer-tainted-offset]
   33 |         if (name[len - 1] == '\n')
      |             ~~~~^~~~~~~~~

As before this currently still needs -fanalyzer-checker=taint (in
addition to -fanalyzer).

gcc/analyzer/ChangeLog:
* engine.cc: Include "stringpool.h", "attribs.h", and
"tree-dfa.h".
(mark_params_as_tainted): New.
(class tainted_args_function_custom_event): New.
(class tainted_args_function_info): New.
(exploded_graph::add_function_entry): Handle functions with
"tainted_args" attribute.
(class tainted_args_field_custom_event): New.
(class tainted_args_callback_custom_event): New.
(class tainted_args_call_info): New.
(add_tainted_args_callback): New.
(add_any_callbacks): New.
(exploded_graph::build_initial_worklist): Likewise.
(exploded_graph::build_initial_worklist): Find callbacks that are
reachable from global initializers, calling add_any_callbacks on
them.

gcc/c-family/ChangeLog:
* c-attribs.c (c_common_attribute_table): Add "tainted_args".
(handle_tainted_args_attribute): New.

gcc/ChangeLog:
* doc/extend.texi (Function Attributes): Note that "tainted_args" can
be used on field decls.
(Common Function Attributes): Add entry on "tainted_args" attribute.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/attr-tainted_args-1.c: New test.
* gcc.dg/analyzer/attr-tainted_args-misuses.c: New test.
* gcc.dg/analyzer/taint-CVE-2011-2210-1.c: New test.
* gcc.dg/analyzer/taint-CVE-2020-13143-1.c: New test.
* gcc.dg/analyzer/taint-CVE-2020-13143-2.c: New test.
* gcc.dg/analyzer/taint-CVE-2020-13143.h: New test.
* gcc.dg/analyzer/taint-alloc-3.c: New test.
* gcc.dg/analyzer/taint-alloc-4.c: New test.
* gcc.dg/analyzer/test-uaccess.h: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoDaily bump.
GCC Administrator [Fri, 14 Jan 2022 00:16:30 +0000 (00:16 +0000)]
Daily bump.

2 years agotoplevel: Remove incorrectly added file
Jakub Jelinek [Thu, 13 Jan 2022 21:31:19 +0000 (22:31 +0100)]
toplevel: Remove incorrectly added file

2022-01-13  Jakub Jelinek  <jakub@redhat.com>

* Makefile.am: Remove.

2 years agoc++: warning for dependent template members [PR70417]
Anthony Sharp [Sat, 4 Dec 2021 17:23:22 +0000 (17:23 +0000)]
c++: warning for dependent template members [PR70417]

Add a helpful warning message for when the user forgets to
include the "template" keyword after ., -> or :: when
accessing a member in a dependent context, where the member is a
template.

PR c++/70417

gcc/c-family/ChangeLog:

* c.opt: Added -Wmissing-template-keyword.

gcc/cp/ChangeLog:

* parser.c (cp_parser_id_expression): Handle
-Wmissing-template-keyword.
(struct saved_token_sentinel): Add modes to control what happens
on destruction.
(cp_parser_statement): Adjust.
(cp_parser_skip_entire_template_parameter_list): New function that
skips an entire template parameter list.
(cp_parser_require_end_of_template_parameter_list): Rename old
cp_parser_skip_to_end_of_template_parameter_list.
(cp_parser_skip_to_end_of_template_parameter_list): Refactor to be
called from one of the above two functions.
(cp_parser_lambda_declarator_opt)
(cp_parser_explicit_template_declaration)
(cp_parser_enclosed_template_argument_list): Adjust.

gcc/ChangeLog:

* doc/invoke.texi: Documentation for Wmissing-template-keyword.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-mem_fn2.C: Catch warning about missing
template keyword.
* g++.dg/template/dependent-name17.C: New test.
* g++.dg/template/dependent-name18.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
2 years agoi386: Introduce V2QImode vectorized shifts [PR103861]
Uros Bizjak [Thu, 13 Jan 2022 19:48:18 +0000 (20:48 +0100)]
i386: Introduce V2QImode vectorized shifts [PR103861]

Add V2QImode shift operations and split them to synthesized
double HI/LO QImode operations with integer registers.

Also robustify arithmetic split patterns.

2022-01-13  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/103861
* config/i386/i386.md (*ashlqi_ext<mode>_2): New insn pattern.
(*<any_shiftrt:insn>qi_ext<mode>_2): Ditto.
* config/i386/mmx.md (<any_shift:insn>v2qi):
New insn_and_split pattern.

gcc/testsuite/ChangeLog:

PR target/103861
* gcc.target/i386/pr103861.c (shl,ashr,lshr): New tests.

2 years agovect: Add bias parameter for partial vectorization
Robin Dapp [Thu, 13 Jan 2022 08:51:07 +0000 (09:51 +0100)]
vect: Add bias parameter for partial vectorization

This introduces a bias parameter for the len_load/len_store ifns as well as
optabs that is meant to distinguish between Power and s390 variants.
PowerPC's instructions require a bias of 0, while in s390's case
vll/vstl do not support lengths of zero bytes and a bias of -1 must be used.

gcc/ChangeLog:

* internal-fn.c (expand_partial_load_optab_fn): Add bias.
(expand_partial_store_optab_fn): Likewise.
(internal_len_load_store_bias): New function.
* internal-fn.h (VECT_PARTIAL_BIAS_UNSUPPORTED): New define.
(internal_len_load_store_bias): New function.
* tree-vect-loop-manip.c (vect_set_loop_controls_directly): Set bias.
(vect_set_loop_condition_partial_vectors): Add header_seq parameter.
* tree-vect-loop.c (vect_verify_loop_lens): Verify bias.
(vect_estimate_min_profitable_iters): Account for bias.
(vect_get_loop_len): Add bias-adjusted length.
* tree-vect-stmts.c (vectorizable_store): Use.
(vectorizable_load): Use.
* tree-vectorizer.h (struct rgroup_controls): Add bias-adjusted length.
(LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS): New macro.
* config/rs6000/vsx.md: Use const0 bias predicate.
* doc/md.texi: Document bias value.

2 years agoAdd support for allocate clause (OpenMP 5.0).
Hafiz Abid Qadeer [Fri, 24 Sep 2021 09:04:12 +0000 (10:04 +0100)]
Add support for allocate clause (OpenMP 5.0).

This patch adds support for OpenMP 5.0 allocate clause for fortran. It does not
yet support the allocator-modifier as specified in OpenMP 5.1. The allocate
clause is already supported in C/C++.

gcc/fortran/ChangeLog:

* dump-parse-tree.c (show_omp_clauses): Handle OMP_LIST_ALLOCATE.
* gfortran.h (OMP_LIST_ALLOCATE): New enum value.
* openmp.c (enum omp_mask1): Add OMP_CLAUSE_ALLOCATE.
(gfc_match_omp_clauses): Handle OMP_CLAUSE_ALLOCATE
(OMP_PARALLEL_CLAUSES, OMP_DO_CLAUSES, OMP_SECTIONS_CLAUSES)
(OMP_TASK_CLAUSES, OMP_TASKLOOP_CLAUSES, OMP_TARGET_CLAUSES)
(OMP_TEAMS_CLAUSES, OMP_DISTRIBUTE_CLAUSES)
(OMP_SINGLE_CLAUSES): Add OMP_CLAUSE_ALLOCATE.
(OMP_TASKGROUP_CLAUSES): New.
(gfc_match_omp_taskgroup): Use OMP_TASKGROUP_CLAUSES instead of
OMP_CLAUSE_TASK_REDUCTION.
(resolve_omp_clauses): Handle OMP_LIST_ALLOCATE.
(resolve_omp_do): Avoid warning when loop iteration variable is
in allocate clause.
* trans-openmp.c (gfc_trans_omp_clauses): Handle translation of
allocate clause.
(gfc_split_omp_clauses): Update for OMP_LIST_ALLOCATE.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/allocate-1.f90: New test.
* gfortran.dg/gomp/allocate-2.f90: New test.
* gfortran.dg/gomp/allocate-3.f90: New test.
* gfortran.dg/gomp/collapse1.f90: Update error message.
* gfortran.dg/gomp/openmp-simd-4.f90: Likewise.
* gfortran.dg/gomp/clauses-1.f90: Uncomment allocate clause.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/allocate-1.c: New test.
* testsuite/libgomp.fortran/allocate-1.f90: New test.
* libgomp.texi: Remove string that says that allocate clause
support is for C/C++ only.

2 years agoAllow more precision when querying from fold_const.
Andrew MacLeod [Wed, 12 Jan 2022 18:31:08 +0000 (13:31 -0500)]
Allow more precision when querying from fold_const.

fold_const::expr_not_equal_to queries for a current range, but still uses
the old value_range class.  This is causing it to miss opportunities when
ranger can provide something better.

PR tree-optimization/83072
PR tree-optimization/83073
PR tree-optimization/97909
gcc/
* fold-const.c (expr_not_equal_to): Use a multi-range class.

gcc/testsuite/
* gcc.dg/pr83072-2.c: New.
* gcc.dg/pr83073.c: New.

2 years agoAdd relation to unsigned right shift.
Andrew MacLeod [Wed, 12 Jan 2022 18:28:55 +0000 (13:28 -0500)]
Add relation to unsigned right shift.

If the first operand and the shift value of a right shift operation are both
>= 0, then we know the LHS of the operation is <= the first operand.

PR tree-optimization/96707
gcc/
* range-op.cc (operator_rshift::lhs_op1_relation): New.

gcc/testsuite/
* g++.dg/pr96707.C: New.

2 years agoFortran: fix error recovery on bad structure constructor in DATA statement
Harald Anlauf [Wed, 12 Jan 2022 20:24:49 +0000 (21:24 +0100)]
Fortran: fix error recovery on bad structure constructor in DATA statement

gcc/fortran/ChangeLog:

PR fortran/67804
* primary.c (gfc_match_structure_constructor): Recover from errors
that occurred while checking for a valid structure constructor in
a DATA statement.

gcc/testsuite/ChangeLog:

PR fortran/67804
* gfortran.dg/pr93604.f90: Adjust to changed diagnostics.
* gfortran.dg/pr67804.f90: New test.

2 years agoi386: Cleanup V2QI arithmetic instructions
Uros Bizjak [Thu, 13 Jan 2022 18:11:41 +0000 (19:11 +0100)]
i386: Cleanup V2QI arithmetic instructions

2022-01-13  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

* config/i386/mmx.md (negv2qi): Disparage GPR alternative a bit.
Disable for TARGET_PARTIAL_REG_STALL unless optimizing for size.
(negv2qi splitters): Use lowpart_subreg instead of
gen_lowpart to create subreg.
(<plusminus:insn>v2qi3): Disparage GPR alternative a bit.
Disable for TARGET_PARTIAL_REG_STALL unless optimizing for size.
(<plusminus:insn>v2qi3 splitters): Use lowpart_subreg instead of
gen_lowpart to create subreg.
* config/i386/i386.md (*subqi_ext<mode>_2): Move.

2 years agolibgfortran: Fix Solaris version file creation [PR104006]
Jakub Jelinek [Thu, 13 Jan 2022 16:45:58 +0000 (17:45 +0100)]
libgfortran: Fix Solaris version file creation [PR104006]

I forgot to change the gfortran.map-sun goal to gfortran.ver-sun
when changing other spots for the preprocessed version file.

2022-01-13  Jakub Jelinek  <jakub@redhat.com>

PR libfortran/104006
* Makefile.am (gfortran.map-sun): Rename target to ...
(gfortran.ver-sun): ... this.
* Makefile.in: Regenerated.

2 years agoii386: Add 16-bit vector modes to xop_pcmov [PR104003]
Uros Bizjak [Thu, 13 Jan 2022 16:18:59 +0000 (17:18 +0100)]
ii386: Add 16-bit vector modes to xop_pcmov [PR104003]

2022-01-13  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/104003
* config/i386/mmx.md (*xop_pcmov_<mode>): Use VI_16_32 mode iterator.

gcc/testsuite/ChangeLog:

PR target/104003
* g++.target/i386/pr103861-1-sse4.C: New test.
* g++.target/i386/pr103861-1-xop.C: Ditto.

2 years agoFix -Wformat-diag for ARM target.
Martin Liska [Wed, 12 Jan 2022 12:56:32 +0000 (13:56 +0100)]
Fix -Wformat-diag for ARM target.

gcc/ChangeLog:

* common/config/arm/arm-common.c (arm_target_mode): Wrap
keywords with %<, %> and remove trailing punctuation char.
(arm_canon_arch_option_1): Likewise.
(arm_asm_auto_mfpu): Likewise.
* config/arm/arm-builtins.c (arm_expand_builtin): Likewise.
* config/arm/arm.c (arm_options_perform_arch_sanity_checks): Likewise.
(use_vfp_abi): Likewise.
(aapcs_vfp_is_call_or_return_candidate): Likewise.
(arm_handle_cmse_nonsecure_entry): Likewise.
(arm_handle_cmse_nonsecure_call): Likewise.
(thumb1_md_asm_adjust): Likewise.

2 years agors6000: Support SSE4.1 "round" intrinsics
Paul A. Clarke [Mon, 12 Jul 2021 14:38:22 +0000 (09:38 -0500)]
rs6000: Support SSE4.1 "round" intrinsics

Suppress exceptions (when specified), by saving, manipulating, and
restoring the FPSCR.  Similarly, save, set, and restore the floating-point
rounding mode when required.

No attempt is made to optimize writing the FPSCR (by checking if the new
value would be the same), other than using lighter weight instructions
when possible. Note that explicit instruction scheduling "barriers" are
added to prevent floating-point computations from being moved before or
after the explicit FPSCR manipulations.  (That these are required has
been reported as an issue in GCC: PR102783.)

The scalar versions naively use the parallel versions to compute the
single scalar result and then construct the remainder of the result.

Of minor note, the values of _MM_FROUND_TO_NEG_INF and _MM_FROUND_TO_ZERO
are swapped from the corresponding values on x86 so as to match the
corresponding rounding mode values in the Power ISA.

Move implementations of _mm_ceil* and _mm_floor* into _mm_round*, and
convert _mm_ceil* and _mm_floor* into macros. This matches the current
analogous implementations in config/i386/smmintrin.h.

Function signatures match the analogous functions in config/i386/smmintrin.h.

Add tests for _mm_round_pd, _mm_round_ps, _mm_round_sd, _mm_round_ss,
modeled after the very similar "floor" and "ceil" tests.

Include basic tests, plus tests at the boundaries for floating-point
representation, positive and negative, test all of the parameterized
rounding modes as well as the C99 rounding modes and interactions
between the two.

Exceptions are not explicitly tested.

2022-01-13  Paul A. Clarke  <pc@us.ibm.com>

gcc
* config/rs6000/smmintrin.h (_mm_round_pd, _mm_round_ps,
_mm_round_sd, _mm_round_ss, _MM_FROUND_TO_NEAREST_INT,
_MM_FROUND_TO_ZERO, _MM_FROUND_TO_POS_INF, _MM_FROUND_TO_NEG_INF,
_MM_FROUND_CUR_DIRECTION, _MM_FROUND_RAISE_EXC, _MM_FROUND_NO_EXC,
_MM_FROUND_NINT, _MM_FROUND_FLOOR, _MM_FROUND_CEIL, _MM_FROUND_TRUNC,
_MM_FROUND_RINT, _MM_FROUND_NEARBYINT): New.
(_mm_ceil_pd, _mm_ceil_ps, _mm_ceil_sd, _mm_ceil_ss, _mm_floor_pd,
_mm_floor_ps, _mm_floor_sd, _mm_floor_ss): Convert from function to
macro.

gcc/testsuite
* gcc.target/powerpc/sse4_1-round3.h: New.
* gcc.target/powerpc/sse4_1-roundpd.c: New.
* gcc.target/powerpc/sse4_1-roundps.c: New.
* gcc.target/powerpc/sse4_1-roundsd.c: New.
* gcc.target/powerpc/sse4_1-roundss.c: New.

2 years agoc/104002 - shufflevector variable indexing
Richard Biener [Thu, 13 Jan 2022 10:55:14 +0000 (11:55 +0100)]
c/104002 - shufflevector variable indexing

Variable indexing of a __builtin_shufflevector result is broken because
we fail to properly mark the TARGET_EXPR decl as addressable.

2022-01-13  Richard Biener  <rguenther@suse.de>

PR c/104002
gcc/c-family/
* c-common.c (c_common_mark_addressable_vec): Handle TARGET_EXPR.

gcc/testsuite/
* c-c++-common/builtin-shufflevector-3.c: Move ...
* c-c++-common/torture/builtin-shufflevector-3.c: ... here.

2 years agoinliner: Don't emit copy stmts for empty type parameters [PR103989]
Jakub Jelinek [Thu, 13 Jan 2022 14:59:47 +0000 (15:59 +0100)]
inliner: Don't emit copy stmts for empty type parameters [PR103989]

The following patch avoids emitting a parameter copy statement when inlining
if the parameter has empty type.  E.g. the gimplifier does something similar
(except that it needs to evaluate side-effects if any, which isn't the case
here):
  /* For empty types only gimplify the left hand side and right hand
     side as statements and throw away the assignment.  Do this after
     gimplify_modify_expr_rhs so we handle TARGET_EXPRs of addressable
     types properly.  */
  if (is_empty_type (TREE_TYPE (*from_p))
      && !want_value
      /* Don't do this for calls that return addressable types, expand_call
         relies on those having a lhs.  */
      && !(TREE_ADDRESSABLE (TREE_TYPE (*from_p))
           && TREE_CODE (*from_p) == CALL_EXPR))
    {
      gimplify_stmt (from_p, pre_p);
      gimplify_stmt (to_p, pre_p);
      *expr_p = NULL_TREE;
      return GS_ALL_DONE;
    }
Unfortunately, this patch doesn't cure the uninit warnings in that PR,
which is caused by ipa inlining happening even at -Og when the post-IPA
-Og passes don't expect the need to clean up after ipa inlining,
but I think is desirable anyway.

2022-01-13  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/103989
* tree-inline.c (setup_one_parameter): Don't copy parms with
empty type.

2 years agoImprove Intel MIC offloading XFAILing for 'omp_get_device_num'
Thomas Schwinge [Wed, 5 Jan 2022 18:52:25 +0000 (19:52 +0100)]
Improve Intel MIC offloading XFAILing for 'omp_get_device_num'

After recent commit be661959a6b6d8f9c3c8608a746789e7b2ec3ca4
"libgomp/testsuite: Improve omp_get_device_num() tests", we're now iterating
over all OpenMP target devices.  Intel MIC (emulated) offloading still doesn't
properly implement device-side 'omp_get_device_num', and we thus regress:

    PASS: libgomp.c/../libgomp.c-c++-common/target-45.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/target-45.c execution test

    PASS: libgomp.c++/../libgomp.c-c++-common/target-45.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c++/../libgomp.c-c++-common/target-45.c execution test

    PASS: libgomp.fortran/target10.f90   -O0  (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.fortran/target10.f90   -O0  execution test
    PASS: libgomp.fortran/target10.f90   -O1  (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.fortran/target10.f90   -O1  execution test
    PASS: libgomp.fortran/target10.f90   -O2  (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.fortran/target10.f90   -O2  execution test
    PASS: libgomp.fortran/target10.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.fortran/target10.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
    PASS: libgomp.fortran/target10.f90   -O3 -g  (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.fortran/target10.f90   -O3 -g  execution test
    PASS: libgomp.fortran/target10.f90   -Os  (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.fortran/target10.f90   -Os  execution test

Improve the XFAILing added in commit bb75b22aba254e8ff144db27b1c8b4804bad73bb
"Allow matching Intel MIC in OpenMP 'declare variant'" for the case that *any*
Intel MIC offload device is available.

libgomp/
* testsuite/libgomp.c-c++-common/on_device_arch.h
(any_device_arch, any_device_arch_intel_mic): New.
* testsuite/lib/libgomp.exp
(check_effective_target_offload_device_any_intel_mic): New.
* testsuite/libgomp.c-c++-common/target-45.c: Use it.
* testsuite/libgomp.fortran/target10.f90: Likewise.

2 years agoMerge 'c-c++-common/goacc/routine-6.c' into 'c-c++-common/goacc/routine-5.c', and...
Thomas Schwinge [Mon, 22 Nov 2021 15:09:09 +0000 (16:09 +0100)]
Merge 'c-c++-common/goacc/routine-6.c' into 'c-c++-common/goacc/routine-5.c', and document current C/C++ difference

gcc/testsuite/
* c-c++-common/goacc/routine-6.c: Merge into...
* c-c++-common/goacc/routine-5.c: ... this, and document current
C/C++ difference.

2 years agoDocument current '-Wuninitialized' diagnostics for 'libgomp.oacc-fortran/routine...
Thomas Schwinge [Thu, 26 Aug 2021 14:55:21 +0000 (16:55 +0200)]
Document current '-Wuninitialized' diagnostics for 'libgomp.oacc-fortran/routine-10.f90' [PR102192]

libgomp/
PR tree-optimization/102192
* testsuite/libgomp.oacc-fortran/routine-10.f90: Document current
'-Wuninitialized' diagnostics.

2 years agoDocument current '-Wuninitialized'/'-Wmaybe-uninitialized' diagnostics for OpenACC...
Thomas Schwinge [Thu, 26 Aug 2021 14:55:21 +0000 (16:55 +0200)]
Document current '-Wuninitialized'/'-Wmaybe-uninitialized' diagnostics for OpenACC test cases

... including "note: '[...]' was declared here" emitted since recent
commit 9695e1c23be5b5c55d572ced152897313ddb96ae
"Improve -Wuninitialized note location".

For those that seemed incorrect to me, I've placed XFAILed 'dg-bogus'es,
including one more instance of PR77504 etc., and several instances where
for "local variables" of reference-data-type reductions (etc.?) we emit
bogus (?) diagnostics.

For implicit data clauses (including 'firstprivate'), we seem to be missing
diagnostics, so I've placed XFAILed 'dg-warning's.

gcc/testsuite/
* c-c++-common/goacc/builtin-goacc-parlevel-id-size.c: Document
current '-Wuninitialized' diagnostics.
* c-c++-common/goacc/mdc-1.c: Likewise.
* c-c++-common/goacc/nested-reductions-1-kernels.c: Likewise.
* c-c++-common/goacc/nested-reductions-1-parallel.c: Likewise.
* c-c++-common/goacc/nested-reductions-1-routine.c: Likewise.
* c-c++-common/goacc/nested-reductions-2-kernels.c: Likewise.
* c-c++-common/goacc/nested-reductions-2-parallel.c: Likewise.
* c-c++-common/goacc/nested-reductions-2-routine.c: Likewise.
* c-c++-common/goacc/uninit-dim-clause.c: Likewise.
* c-c++-common/goacc/uninit-firstprivate-clause.c: Likewise.
* c-c++-common/goacc/uninit-if-clause.c: Likewise.
* gfortran.dg/goacc/array-with-dt-1.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-2.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-3.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-4.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-5.f90: Likewise.
* gfortran.dg/goacc/derived-chartypes-1.f90: Likewise.
* gfortran.dg/goacc/derived-chartypes-2.f90: Likewise.
* gfortran.dg/goacc/derived-chartypes-3.f90: Likewise.
* gfortran.dg/goacc/derived-chartypes-4.f90: Likewise.
* gfortran.dg/goacc/derived-classtypes-1.f95: Likewise.
* gfortran.dg/goacc/derived-types-2.f90: Likewise.
* gfortran.dg/goacc/host_data-tree.f95: Likewise.
* gfortran.dg/goacc/kernels-tree.f95: Likewise.
* gfortran.dg/goacc/modules.f95: Likewise.
* gfortran.dg/goacc/nested-reductions-1-kernels.f90: Likewise.
* gfortran.dg/goacc/nested-reductions-1-parallel.f90: Likewise.
* gfortran.dg/goacc/nested-reductions-1-routine.f90: Likewise.
* gfortran.dg/goacc/nested-reductions-2-kernels.f90: Likewise.
* gfortran.dg/goacc/nested-reductions-2-parallel.f90: Likewise.
* gfortran.dg/goacc/nested-reductions-2-routine.f90: Likewise.
* gfortran.dg/goacc/parallel-tree.f95: Likewise.
* gfortran.dg/goacc/pr93464.f90: Likewise.
* gfortran.dg/goacc/privatization-1-compute-loop.f90: Likewise.
* gfortran.dg/goacc/privatization-1-compute.f90: Likewise.
* gfortran.dg/goacc/privatization-1-routine_gang-loop.f90:
Likewise.
* gfortran.dg/goacc/privatization-1-routine_gang.f90: Likewise.
* gfortran.dg/goacc/uninit-dim-clause.f95: Likewise.
* gfortran.dg/goacc/uninit-firstprivate-clause.f95: Likewise.
* gfortran.dg/goacc/uninit-if-clause.f95: Likewise.
* gfortran.dg/goacc/uninit-use-device-clause.f95: Likewise.
* gfortran.dg/goacc/wait.f90: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/vred2d-128.c: Document
current '-Wuninitialized' diagnostics.
* testsuite/libgomp.oacc-fortran/data-5.f90: Likewise.
* testsuite/libgomp.oacc-fortran/gemm-2.f90: Likewise.
* testsuite/libgomp.oacc-fortran/gemm.f90: Likewise.
* testsuite/libgomp.oacc-fortran/optional-reduction.f90: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-reduction.f90: Likewise.
* testsuite/libgomp.oacc-fortran/pr70643.f90: Likewise.
* testsuite/libgomp.oacc-fortran/pr96628-part1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-5.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reduction-7.f90: Likewise.
* testsuite/libgomp.oacc-fortran/reference-reductions.f90:
Likewise.

2 years agoSimplify git-backport.py script.
Martin Liska [Thu, 13 Jan 2022 10:45:46 +0000 (11:45 +0100)]
Simplify git-backport.py script.

It's very unlikely that somebody is going to backport a revision
that is > 14 months old to a release branch.

contrib/ChangeLog:

* git-backport.py: Simplify the script as pre-auto-ChangeLog era
is 14 months old.

2 years agoHost and offload targets have no common meaning of address spaces
Thomas Schwinge [Tue, 24 Aug 2021 09:14:10 +0000 (11:14 +0200)]
Host and offload targets have no common meaning of address spaces

gcc/
* tree-streamer-out.c (pack_ts_base_value_fields): Don't pack
'TYPE_ADDR_SPACE' for offloading.
* tree-streamer-in.c (unpack_ts_base_value_fields): Don't unpack
'TYPE_ADDR_SPACE' for offloading.
libgomp/
* testsuite/libgomp.c/address-space-1.c: Remove 'dg-xfail-run-if'
for 'offload_device_intel_mic'.

2 years agoWait at end of OpenACC asynchronous kernels regions
Julian Brown [Fri, 9 Aug 2019 20:01:33 +0000 (13:01 -0700)]
Wait at end of OpenACC asynchronous kernels regions

In OpenACC 'kernels' decomposition, we're improperly nesting synchronous and
asynchronous data and compute regions, giving rise to data races when the
asynchronicity is actually executed, as is visible in at least on test case
with GCN offloading.

The proper fix is to correctly use the asynchronous interfaces, making the
currently synchronous data regions fully asynchronous (see also
<https://gcc.gnu.org/PR97390> "[OpenACC] 'async' clause on 'data' construct",
which is to share the same implementation), but that's for later; for now add
some more synchronization.

gcc/
* omp-oacc-kernels-decompose.cc (add_wait): New function, split out
of...
(add_async_clauses_and_wait): ...here. Call new outlined function.
(decompose_kernels_region_body): Add wait at the end of
explicitly-asynchronous kernels regions.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-1.c: Remove GCN
offloading execution XFAIL.

Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
2 years agoOpenACC 'kernels' decomposition: Mark variables used in synthesized data clauses...
Thomas Schwinge [Thu, 16 Dec 2021 21:02:37 +0000 (22:02 +0100)]
OpenACC 'kernels' decomposition: Mark variables used in synthesized data clauses as addressable [PR100280]

... as otherwise 'gcc/omp-low.c:lower_omp_target' has to create a temporary:

    13073 else if (is_gimple_reg (var))
    13074   {
    13075     gcc_assert (offloaded);
    13076     tree avar = create_tmp_var (TREE_TYPE (var));
    13077     mark_addressable (avar);

..., which (a) is only implemented for actualy *offloaded* regions (but not
data regions), and (b) the subsequently synthesized code for writing to and
later reading back from the temporary fundamentally conflicts with OpenACC
'async' (as used by OpenACC 'kernels' decomposition).  That's all not trivial
to make work, so let's just avoid this case.

gcc/
PR middle-end/100280
* omp-oacc-kernels-decompose.cc (maybe_build_inner_data_region):
Mark variables used in synthesized data clauses as addressable.
gcc/testsuite/
PR middle-end/100280
* c-c++-common/goacc/kernels-decompose-pr100280-1.c: New.
* c-c++-common/goacc/classify-kernels-parloops.c: Likewise.
* c-c++-common/goacc/classify-kernels-unparallelized-parloops.c:
Likewise.
* c-c++-common/goacc/classify-kernels-unparallelized.c: Test
'--param openacc-kernels=decompose'.
* c-c++-common/goacc/classify-kernels.c: Likewise.
* c-c++-common/goacc/kernels-decompose-2.c: Update.
* c-c++-common/goacc/kernels-decompose-ice-1.c: Remove.
* c-c++-common/goacc/kernels-decompose-ice-2.c: Likewise.
* gfortran.dg/goacc/classify-kernels-parloops.f95: New.
* gfortran.dg/goacc/classify-kernels-unparallelized-parloops.f95:
Likewise.
* gfortran.dg/goacc/classify-kernels-unparallelized.f95: Test
'--param openacc-kernels=decompose'.
* gfortran.dg/goacc/classify-kernels.f95: Likewise.
libgomp/
PR middle-end/100280
* testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c:
Update.
* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c:
Likewise.

Suggested-by: Julian Brown <julian@codesourcery.com>
2 years agoEnhance OpenACC 'kernels' decomposition testing
Thomas Schwinge [Mon, 20 Dec 2021 15:14:46 +0000 (16:14 +0100)]
Enhance OpenACC 'kernels' decomposition testing

gcc/testsuite/
* c-c++-common/goacc/kernels-decompose-1.c: Enhance.
* c-c++-common/goacc/kernels-decompose-2.c: Likewise.
* c-c++-common/goacc/kernels-decompose-ice-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-ice-2.c: Likewise.
* gfortran.dg/goacc/kernels-decompose-1.f95: Likewise.
* gfortran.dg/goacc/kernels-decompose-2.f95: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c:
Enhance.
* testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-3.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c:
Likewise.
* testsuite/libgomp.oacc-fortran/asyncwait-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/asyncwait-2.f90: Likewise.
* testsuite/libgomp.oacc-fortran/asyncwait-3.f90: Likewise.
* testsuite/libgomp.oacc-fortran/pr94358-1.f90: Likewise.