]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 years agoopenmp: Add support for allocator and align modifiers on allocate clauses
Jakub Jelinek [Wed, 22 Sep 2021 07:52:32 +0000 (09:52 +0200)] 
openmp: Add support for allocator and align modifiers on allocate clauses

As the allocate-2.c testcase shows, this change isn't 100% backwards compatible,
one could have allocate and/or align functions that return an OpenMP allocator
handle and previously it would call those functions and now would use those
names as keywords for the modifiers.  But it allows specify extra alignment
requirements for the allocations.

2021-09-22  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree.h (OMP_CLAUSE_ALLOCATE_ALIGN): Define.
* tree.c (omp_clause_num_ops): Change number of OMP_CLAUSE_ALLOCATE
arguments from 2 to 3.
* tree-pretty-print.c (dump_omp_clause): Print allocator() around
allocate clause allocator and print align if present.
* omp-low.c (scan_sharing_clauses): Force allocate_map entry even
for omp_default_mem_alloc if align modifier is present.  If align
modifier is present, use TREE_LIST to encode both allocator and
align.
(lower_private_allocate, lower_rec_input_clauses, create_task_copyfn):
Handle align modifier on allocator clause if present.
gcc/c-family/
* c-omp.c (c_omp_split_clauses): Copy over OMP_CLAUSE_ALLOCATE_ALIGN.
gcc/c/
* c-parser.c (c_parser_omp_clause_allocate): Parse allocate clause
modifiers.
gcc/cp/
* parser.c (cp_parser_omp_clause_allocate): Parse allocate clause
modifiers.
* semantics.c (finish_omp_clauses) <OMP_CLAUSE_ALLOCATE>: Perform
semantic analysis of OMP_CLAUSE_ALLOCATE_ALIGN.
* pt.c (tsubst_omp_clauses) <case OMP_CLAUSE_ALLOCATE>: Handle
also OMP_CLAUSE_ALLOCATE_ALIGN.
gcc/testsuite/
* c-c++-common/gomp/allocate-6.c: New test.
* c-c++-common/gomp/allocate-7.c: New test.
* g++.dg/gomp/allocate-4.C: New test.
libgomp/
* testsuite/libgomp.c-c++-common/allocate-2.c: New test.
* testsuite/libgomp.c-c++-common/allocate-3.c: New test.

(cherry picked from commit 059b819e3c94aae3dd0be55bd512ee6ee4e28798)

3 years agoFortran: Fix -Wno-missing-include-dirs handling [PR55534]
Tobias Burnus [Tue, 21 Sep 2021 06:44:34 +0000 (08:44 +0200)] 
Fortran: Fix -Wno-missing-include-dirs handling [PR55534]

gcc/fortran/ChangeLog:

PR fortran/55534
* cpp.c: Define GCC_C_COMMON_C for #include "options.h" to make
cpp_reason_option_codes available.
(gfc_cpp_register_include_paths): Make static, set pfile's
warn_missing_include_dirs and move before caller.
(gfc_cpp_init_cb): New, cb code moved from ...
(gfc_cpp_init_0): ... here.
(gfc_cpp_post_options): Call gfc_cpp_init_cb.
(cb_cpp_diagnostic_cpp_option): New. As implemented in c-family
to match CppReason flags to -W... names.
(cb_cpp_diagnostic): Use it to replace single special case.
* cpp.h (gfc_cpp_register_include_paths): Remove as now static.
* gfortran.h (gfc_check_include_dirs): New prototype.
(gfc_add_include_path): Add new bool arg.
* options.c (gfc_init_options): Don't set -Wmissing-include-dirs.
(gfc_post_options): Set it here after commandline processing. Call
gfc_add_include_path with defer_warn=false.
(gfc_handle_option): Call it with defer_warn=true.
* scanner.c (gfc_do_check_include_dir, gfc_do_check_include_dirs,
gfc_check_include_dirs): New. Diagnostic moved from ...
(add_path_to_list): ... here, which came before cmdline processing.
Take additional bool defer_warn argument.
(gfc_add_include_path): Take additional defer_warn arg.
* scanner.h (struct gfc_directorylist): Reorder for alignment issues,
add new 'bool warn'.

libgfortran/ChangeLog:
PR fortran/55534
* configure.ac (AM_FCFLAGS): Add -Wno-missing-include-dirs.
* configure: Regenerate.

libgomp/ChangeLog:
PR fortran/55534
* testsuite/libgomp.fortran/fortran.exp: Add -Wno-missing-include-dirs
to ALWAYS_CFLAGS.
* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.

gcc/testsuite/ChangeLog:
* gfortran.dg/include_6.f90: Change dg-error to
dg-warning and update pattern.
* gfortran.dg/include_14.f90: New test.
* gfortran.dg/include_15.f90: New test.
* gfortran.dg/include_16.f90: New test.
* gfortran.dg/include_17.f90: New test.
* gfortran.dg/include_18.f90: New test.
* gfortran.dg/include_19.f90: New test.
* gfortran.dg/include_20.f90: New test.
* gfortran.dg/include_21.f90: New test.

(cherry picked from commit 417ea5c02cef7f000e66d1af22b066c2c1cda047)

3 years agoFortran/OpenMP: unconstrained/reproducible ordered modifier
Tobias Burnus [Mon, 20 Sep 2021 15:31:45 +0000 (17:31 +0200)] 
Fortran/OpenMP: unconstrained/reproducible ordered modifier

gcc/fortran/ChangeLog:

* gfortran.h (gfc_omp_clauses): Add order_unconstrained.
* dump-parse-tree.c (show_omp_clauses): Dump it.
* openmp.c (gfc_match_omp_clauses): Match unconstrained/reproducible
modifiers to ordered(concurrent).
(OMP_DISTRIBUTE_CLAUSES): Accept ordered clause.
(resolve_omp_clauses): Reject ordered + order on same directive.
* trans-openmp.c (gfc_trans_omp_clauses, gfc_split_omp_clauses): Pass
on unconstrained modifier of ordered(concurrent).

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/order-5.f90: New test.
* gfortran.dg/gomp/order-6.f90: New test.
* gfortran.dg/gomp/order-7.f90: New test.
* gfortran.dg/gomp/order-8.f90: New test.
* gfortran.dg/gomp/order-9.f90: New test.

(cherry picked from commit 0de4184baca19cdd4ebc2d8aa2d538330cae51ee)

3 years agoRevert "GCC11 - Fortran: combined directives - order(concurrent) not on distribute"
Tobias Burnus [Mon, 20 Sep 2021 15:26:57 +0000 (17:26 +0200)] 
Revert "GCC11 - Fortran: combined directives - order(concurrent) not on distribute"

This reverts commit b1dc26d3543d79805751c26ba5b142eeeb1f55b8.
Reason: This only applies to GCC 11 and is superceeded to a GCC 12 patch,
which will be cherry-picked in the next commit.

3 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 20 Sep 2021 15:25:44 +0000 (17:25 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9017-gb1dc26d3543d79805751c26ba5b142eeeb1f55b8 (Sept 20, 2021)

3 years agoGCC11 - Fortran: combined directives - order(concurrent) not on distribute
Tobias Burnus [Mon, 20 Sep 2021 15:24:56 +0000 (17:24 +0200)] 
GCC11 - Fortran: combined directives - order(concurrent) not on distribute

While OpenMP 5.1 and GCC 12 permits 'order(concurrent)' on distribute,
OpenMP 5.0 and GCC 11 don't. This patch for GCC 11 ensures the clause also
does not end up on 'distribute' when splitting combined directives.

gcc/fortran/ChangeLog:

* trans-openmp.c (gfc_split_omp_clauses): Don't put 'order(concurrent)'
on 'distribute' for combined directives, matching OpenMP 5.0

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/distribute-order-concurrent.f90: New test.

3 years agoopenmp: Support in_reduction for Fortran
Chung-Lin Tang [Mon, 20 Sep 2021 13:25:51 +0000 (21:25 +0800)] 
openmp: Support in_reduction for Fortran

This patch is a merge of:
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579673.html

with some of the adjustments suggested by Jakub:
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579694.html

This patch does the required adjustments to let 'in_reduction' work for Fortran.
Task directive in_reduction now also works for Fortran after this patch.

gcc/fortran/ChangeLog:

* openmp.c (gfc_match_omp_clause_reduction): Add 'openmp_target' default
false parameter. Add 'always,tofrom' map for OMP_LIST_IN_REDUCTION case.
(gfc_match_omp_clauses): Add 'openmp_target' default false parameter,
adjust call to gfc_match_omp_clause_reduction.
(match_omp): Adjust call to gfc_match_omp_clauses
* trans-openmp.c (gfc_trans_omp_taskgroup): Add call to
gfc_match_omp_clause, create and return block.

gcc/ChangeLog:

* omp-low.c (scan_sharing_clauses): Place in_reduction copy of variable
in outer ctx if if exists. Check if non-existent in field_map before
installing OMP_CLAUSE_IN_REDUCTION decl.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/reduction4.f90: Adjust omp target in_reduction' scan
pattern.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/target-in-reduction-1.f90: New test.

3 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 20 Sep 2021 06:53:26 +0000 (08:53 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9016-g79c523d40de1b7ce1dd0f4865c0855ab2bf6744b (Sept 20, 2021).

3 years agoopenmp: Handle unconstrained and reproducible modifiers on order(concurrent)
Jakub Jelinek [Mon, 20 Sep 2021 06:52:39 +0000 (08:52 +0200)] 
openmp: Handle unconstrained and reproducible modifiers on order(concurrent)

This patch adds handling for unconstrained and reproducible modifiers on
order(concurrent) clause.  For all static schedules (including auto and
no schedule or dist_schedule clauses) I believe what we implement is
reproducible, so the patch doesn't do much beyond recognizing those.
Note, there is an OpenMP/spec issue that needs resolution on what
should happen with the dynamic schedules (whether it should be an error
to mix such clauses, or silently make it non-reproducible, and in which
exact cases), so it might need some follow-up.

Besides that, this patch allows order(concurrent) clause on the distribute
construct which is something also added in OpenMP 5.1, and finally
check the newly added restriction that at most one order clause
can appear on a construct.

The allowing of order clause on distribute has a side-effect that
order(concurrent) copyin(thrpriv) is no longer allowed on combined/composite
constructs with distribute parallel for{, simd} in it, previously the
order applied only to for/simd and so a threadprivate var could be seen
in the construct, but now it also applies to distribute and so on the parallel
we shouldn't refer to a threadprivate var.

2021-09-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree.h (OMP_CLAUSE_ORDER_UNCONSTRAINED): Define.
* tree-pretty-print.c (dump_omp_clause): Print unconstrained:
for OMP_CLAUSE_ORDER_UNCONSTRAINED.
gcc/c-family/
* c-omp.c (c_omp_split_clauses): Split order clause also to
distribute construct.  Copy over OMP_CLAUSE_ORDER_UNCONSTRAINED.
gcc/c/
* c-parser.c (c_parser_omp_clause_order): Parse unconstrained
and reproducible modifiers.
(OMP_DISTRIBUTE_CLAUSE_MASK): Add order clause.
gcc/cp/
* parser.c (cp_parser_omp_clause_order): Parse unconstrained
and reproducible modifiers.
(OMP_DISTRIBUTE_CLAUSE_MASK): Add order clause.
gcc/testsuite/
* c-c++-common/gomp/order-1.c (f2): Add tests for distribute
with order clause.
(f3): Remove.
* c-c++-common/gomp/order-2.c: Don't expect error for distribute
with order clause.
* c-c++-common/gomp/order-5.c: New test.
* c-c++-common/gomp/order-6.c: New test.
* c-c++-common/gomp/clause-dups-1.c (f1): Add tests for
duplicated order clause.
(f9): New function.
* c-c++-common/gomp/clauses-1.c (baz, bar): Don't mix copyin and
order(concurrent) clauses on the same composite construct combined
with distribute, instead split it into two tests, one without
copyin and one without order(concurrent).  Add order(concurrent)
clauses to {,{,target} teams} distribute.
* g++.dg/gomp/attrs-1.C (baz, bar): Likewise.
* g++.dg/gomp/attrs-2.C (baz, bar): Likewise.

(cherry picked from commit e9d8fcabd032b873bf3fe14ae8afd8970827c0cb)

3 years agoopenmp: Allow private or firstprivate arguments to default clause even for C/C++
Jakub Jelinek [Mon, 20 Sep 2021 06:49:26 +0000 (08:49 +0200)] 
openmp: Allow private or firstprivate arguments to default clause even for C/C++

OpenMP 5.1 allows default(private) or default(firstprivate) even in C/C++,
but it behaves the same way as in Fortran only for variables not declared at
namespace or file scope.  For the namespace/file scope variables it instead
behaves as default(none).

2021-09-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
* gimplify.c (omp_default_clause): For C/C++ default({,first}private),
if file/namespace scope variable doesn't have predetermined sharing,
treat it as if there was default(none).
gcc/c/
* c-parser.c (c_parser_omp_clause_default): Handle private and
firstprivate arguments, adjust diagnostics on unknown argument.
gcc/cp/
* parser.c (cp_parser_omp_clause_default): Handle private and
firstprivate arguments, adjust diagnostics on unknown argument.
* cp-gimplify.c (cxx_omp_finish_clause): Handle OMP_CLAUSE_PRIVATE.
gcc/testsuite/
* c-c++-common/gomp/default-2.c: New test.
* c-c++-common/gomp/default-3.c: New test.
* g++.dg/gomp/default-1.C: New test.
libgomp/
* testsuite/libgomp.c++/default-1.C: New test.
* testsuite/libgomp.c-c++-common/default-1.c: New test.
* libgomp.texi (OpenMP 5.1): Mark "private and firstprivate argument
to default clause in C and C++" as implemented.

(cherry picked from commit e5597f2ad55219092929dc12ea15e1edba06df18)

3 years agoDaily bump.
GCC Administrator [Mon, 20 Sep 2021 00:17:58 +0000 (00:17 +0000)] 
Daily bump.

3 years agoFortran - fix handling of optional allocatable DT arguments with INTENT(OUT)
Harald Anlauf [Thu, 16 Sep 2021 18:12:21 +0000 (20:12 +0200)] 
Fortran - fix handling of optional allocatable DT arguments with INTENT(OUT)

gcc/fortran/ChangeLog:

PR fortran/102287
* trans-expr.c (gfc_conv_procedure_call): Wrap deallocation of
allocatable components of optional allocatable derived type
procedure arguments with INTENT(OUT) into a presence check.

gcc/testsuite/ChangeLog:

PR fortran/102287
* gfortran.dg/intent_out_14.f90: New test.

(cherry picked from commit cfea7b86f2430b9cb8018379b071f4004233119c)

3 years agoFortran - fix ICE during error recovery checking entry characteristics
Harald Anlauf [Tue, 14 Sep 2021 18:23:27 +0000 (20:23 +0200)] 
Fortran - fix ICE during error recovery checking entry characteristics

gcc/fortran/ChangeLog:

PR fortran/102311
* resolve.c (resolve_entries): Attempt to recover cleanly after
rejecting mismatched function entries.

gcc/testsuite/ChangeLog:

PR fortran/102311
* gfortran.dg/entry_25.f90: New test.

(cherry picked from commit b305ec979d9dfc8153859a62a8ab9dd43c3bfc73)

3 years agoDaily bump.
GCC Administrator [Sun, 19 Sep 2021 00:17:58 +0000 (00:17 +0000)] 
Daily bump.

3 years agoFortran: Fix some issues with pointers to character.
José Rui Faustino de Sousa [Sat, 5 Jun 2021 11:12:50 +0000 (11:12 +0000)] 
Fortran: Fix some issues with pointers to character.

gcc/fortran/ChangeLog:

PR fortran/100120
PR fortran/100816
PR fortran/100818
PR fortran/100819
PR fortran/100821
* trans-array.c (gfc_get_array_span): rework the way character
array "span" was calculated.
(gfc_conv_expr_descriptor): improve handling of character sections
and unlimited polymorphic objects.
* trans-expr.c (gfc_get_character_len): new function to calculate
character string length.
(gfc_get_character_len_in_bytes): new function to calculate
character string length in bytes.
(gfc_conv_scalar_to_descriptor): add call to set the "span".
(gfc_trans_pointer_assignment): set "_len" and antecipate the
initialization of the deferred character length hidden argument.
* trans-intrinsic.c (gfc_conv_associated): set "force_no_tmp" to
avoid the creation of a temporary.
* trans-types.c (gfc_get_dtype_rank_type): rework type detection
so that unlimited polymorphic objects get proper type infomation,
also important for bind(c).
(gfc_get_dtype): add argument to pass the rank if necessary.
(gfc_get_array_type_bounds): cosmetic change to have character
arrays called character instead of unknown.
* trans-types.h (gfc_get_dtype): modify prototype.
* trans.c (get_array_span): rework the way character array "span"
was calculated.
* trans.h (gfc_get_character_len): new prototype.
(gfc_get_character_len_in_bytes): new prototype.
Add "unlimited_polymorphic" flag to "gfc_se" type to signal when
expression carries an unlimited polymorphic object.

libgfortran/ChangeLog:

PR fortran/100120
* intrinsics/associated.c (associated): have associated verify if
the "span" matches insted of the "elem_len".
* libgfortran.h (GFC_DESCRIPTOR_SPAN): add macro to retrive the
descriptor "span".

gcc/testsuite/ChangeLog:

PR fortran/100120
* gfortran.dg/PR100120.f90: New test.
PR fortran/100816
PR fortran/100818
PR fortran/100819
PR fortran/100821
* gfortran.dg/character_workout_1.f90: New test.
* gfortran.dg/character_workout_4.f90: New test.

(cherry picked from commit d514626ee2566c68b8a79c7b99aaf791d69e1b2f)

3 years agoDaily bump.
GCC Administrator [Sat, 18 Sep 2021 00:18:17 +0000 (00:18 +0000)] 
Daily bump.

3 years agoFortran: Use _Float128 rather than __float128 for c_float128 kind.
Sandra Loosemore [Fri, 17 Sep 2021 17:15:42 +0000 (10:15 -0700)] 
Fortran: Use _Float128 rather than __float128 for c_float128 kind.

The GNU Fortran manual documents that the c_float128 kind corresponds
to __float128, but in fact the implementation uses float128_type_node,
which is _Float128.  Both refer to the 128-bit IEEE/ISO encoding, but
some targets including aarch64 only define _Float128 and not __float128,
and do not provide quadmath.h.  This caused errors in some test cases
referring to __float128.

This patch changes the documentation (including code comments) and
test cases to use _Float128 to match the implementation.

2021-09-16  Sandra Loosemore  <sandra@codesourcery.com>

gcc/fortran/

* intrinsic.texi (ISO_C_BINDING): Change C_FLOAT128 to correspond
to _Float128 rather than __float128.
* iso-c-binding.def (c_float128): Update comments.
* trans-intrinsic.c (gfc_builtin_decl_for_float_kind): Likewise.
(build_round_expr): Likewise.
(gfc_build_intrinsic_lib_fndcecls): Likewise.
* trans-types.h (gfc_real16_is_float128): Likewise.

gcc/testsuite/
* gfortran.dg/PR100914.c: Do not include quadmath.h.  Use
_Float128 _Complex instead of __complex128.
* gfortran.dg/PR100914.f90: Add -Wno-pedantic to suppress error
about use of _Float128.
* gfortran.dg/c-interop/typecodes-array-float128-c.c: Use
_Float128 instead of __float128.
* gfortran.dg/c-interop/typecodes-sanity-c.c: Likewise.
* gfortran.dg/c-interop/typecodes-scalar-float128-c.c: Likewise.
* lib/target-supports.exp
(check_effective_target_fortran_real_c_float128): Update comments.

libgfortran/
* ISO_Fortran_binding.h: Update comments.
* runtime/ISO_Fortran_binding.c: Likewise.

(cherry picked from commit 00b1324f9285f49a6f9516f408f6be5bc6545219)

3 years agoFortran: TS 29113 testsuite
Sandra Loosemore [Fri, 17 Sep 2021 17:08:45 +0000 (10:08 -0700)] 
Fortran: TS 29113 testsuite

Add tests to exercise features added to Fortran via TS 29113, "Further
Interoperability of Fortran with C":

https://wg5-fortran.org/N1901-N1950/N1942.pdf

2021-09-01  Sandra Loosemore  <sandra@codesourcery.com>

gcc/testsuite/
* gfortran.dg/c-interop/allocatable-dummy-c.c: New file.
* gfortran.dg/c-interop/allocatable-dummy.f90: New file.
* gfortran.dg/c-interop/allocatable-optional-pointer.f90: New file.
* gfortran.dg/c-interop/allocate-c.c: New file.
* gfortran.dg/c-interop/allocate-errors-c.c: New file.
* gfortran.dg/c-interop/allocate-errors.f90: New file.
* gfortran.dg/c-interop/allocate.f90: New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-1.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-2.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-3.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-4.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-5.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-6.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-7.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-8.f90:
New file.
* gfortran.dg/c-interop/assumed-type-dummy.f90: New file.
* gfortran.dg/c-interop/c-interop.exp: New file.
* gfortran.dg/c-interop/c1255-1.f90: New file.
* gfortran.dg/c-interop/c1255-2.f90: New file.
* gfortran.dg/c-interop/c1255a.f90: New file.
* gfortran.dg/c-interop/c407a-1.f90: New file.
* gfortran.dg/c-interop/c407a-2.f90: New file.
* gfortran.dg/c-interop/c407b-1.f90: New file.
* gfortran.dg/c-interop/c407b-2.f90: New file.
* gfortran.dg/c-interop/c407c-1.f90: New file.
* gfortran.dg/c-interop/c516.f90: New file.
* gfortran.dg/c-interop/c524a.f90: New file.
* gfortran.dg/c-interop/c535a-1.f90: New file.
* gfortran.dg/c-interop/c535a-2.f90: New file.
* gfortran.dg/c-interop/c535b-1.f90: New file.
* gfortran.dg/c-interop/c535b-2.f90: New file.
* gfortran.dg/c-interop/c535b-3.f90: New file.
* gfortran.dg/c-interop/c535c-1.f90: New file.
* gfortran.dg/c-interop/c535c-2.f90: New file.
* gfortran.dg/c-interop/c535c-3.f90: New file.
* gfortran.dg/c-interop/c535c-4.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-1.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-2.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-3.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-4.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-5.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-6.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-7-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-7.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-8-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-8.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-1.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-2.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-3.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-4.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-5.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-6.f90: New file.
* gfortran.dg/c-interop/contiguous-1-c.c: New file.
* gfortran.dg/c-interop/contiguous-1.f90: New file.
* gfortran.dg/c-interop/contiguous-2-c.c: New file.
* gfortran.dg/c-interop/contiguous-2.f90: New file.
* gfortran.dg/c-interop/contiguous-3-c.c: New file.
* gfortran.dg/c-interop/contiguous-3.f90: New file.
* gfortran.dg/c-interop/deferred-character-1.f90: New file.
* gfortran.dg/c-interop/deferred-character-2.f90: New file.
* gfortran.dg/c-interop/dump-descriptors.c: New file.
* gfortran.dg/c-interop/dump-descriptors.h: New file.
* gfortran.dg/c-interop/establish-c.c: New file.
* gfortran.dg/c-interop/establish-errors-c.c: New file.
* gfortran.dg/c-interop/establish-errors.f90: New file.
* gfortran.dg/c-interop/establish.f90: New file.
* gfortran.dg/c-interop/explicit-interface.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-1.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-2.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-3.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-4.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-5.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-6.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-7-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-7.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-8-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-8.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-9-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-9.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-1.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-2.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-3.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-4.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-5.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-6.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-7-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-7.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-1.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-2.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-3.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-4.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-5.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-6.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-7.f90: New file.
* gfortran.dg/c-interop/note-5-3.f90: New file.
* gfortran.dg/c-interop/note-5-4-c.c: New file.
* gfortran.dg/c-interop/note-5-4.f90: New file.
* gfortran.dg/c-interop/optional-c.c: New file.
* gfortran.dg/c-interop/optional.f90: New file.
* gfortran.dg/c-interop/rank-class.f90: New file.
* gfortran.dg/c-interop/rank.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-1.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-2.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-3.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-4.f90: New file.
* gfortran.dg/c-interop/section-1-c.c: New file.
* gfortran.dg/c-interop/section-1.f90: New file.
* gfortran.dg/c-interop/section-1p.f90: New file.
* gfortran.dg/c-interop/section-2-c.c: New file.
* gfortran.dg/c-interop/section-2.f90: New file.
* gfortran.dg/c-interop/section-2p.f90: New file.
* gfortran.dg/c-interop/section-3-c.c: New file.
* gfortran.dg/c-interop/section-3.f90: New file.
* gfortran.dg/c-interop/section-3p.f90: New file.
* gfortran.dg/c-interop/section-4-c.c: New file.
* gfortran.dg/c-interop/section-4.f90: New file.
* gfortran.dg/c-interop/section-errors-c.c: New file.
* gfortran.dg/c-interop/section-errors.f90: New file.
* gfortran.dg/c-interop/select-c.c: New file.
* gfortran.dg/c-interop/select-errors-c.c: New file.
* gfortran.dg/c-interop/select-errors.f90: New file.
* gfortran.dg/c-interop/select.f90: New file.
* gfortran.dg/c-interop/setpointer-c.c: New file.
* gfortran.dg/c-interop/setpointer-errors-c.c: New file.
* gfortran.dg/c-interop/setpointer-errors.f90: New file.
* gfortran.dg/c-interop/setpointer.f90: New file.
* gfortran.dg/c-interop/shape.f90: New file.
* gfortran.dg/c-interop/size.f90: New file.
* gfortran.dg/c-interop/tkr.f90: New file.
* gfortran.dg/c-interop/typecodes-array-basic-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-basic.f90: New file.
* gfortran.dg/c-interop/typecodes-array-char-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-char.f90: New file.
* gfortran.dg/c-interop/typecodes-array-float128-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-float128.f90: New file.
* gfortran.dg/c-interop/typecodes-array-int128-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-int128.f90: New file.
* gfortran.dg/c-interop/typecodes-array-longdouble-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-longdouble.f90: New file.
* gfortran.dg/c-interop/typecodes-sanity-c.c: New file.
* gfortran.dg/c-interop/typecodes-sanity.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-basic-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-basic.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-float128-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-float128.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-int128-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-int128.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-longdouble-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-longdouble.f90: New file.
* gfortran.dg/c-interop/ubound.f90: New file.
* lib/target-supports.exp
(check_effective_target_fortran_real_c_float128): New function.

(cherry picked from commit cb17b5054118ec0f727956fd6e034b577b5e261c)

3 years agoFortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h.
Sandra Loosemore [Fri, 17 Sep 2021 14:13:29 +0000 (16:13 +0200)] 
Fortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h.

2021-09-17  Sandra Loosemore  <sandra@codesourcery.com>
    Tobias Burnus  <tobias@codesourcery.com>

libgfortran/
* ISO_Fortran_binding.h: Only include float.h if the C compiler
doesn't have predefined __LDBL_* and __DBL_* macros. Handle
LDBL_MANT_DIG == 53 for FreeBSD.

(cherry picked from commit 654187d05376f08667c8ba88309073e0345431c2)

3 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Fri, 17 Sep 2021 13:22:20 +0000 (15:22 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9011-g469aad8b5d787c728fbe8b4ec6537385d7815d5a (Sept 17, 2021).

3 years agolibgomp: Spelling error fix in OpenMP 5.1 conformance section
Jakub Jelinek [Fri, 17 Sep 2021 13:21:24 +0000 (15:21 +0200)] 
libgomp: Spelling error fix in OpenMP 5.1 conformance section

Fix spelling of OpenMP directive declare variant.

2021-09-17  Jakub Jelinek  <jakub@redhat.com>

* libgomp.texi (OpenMP 5.1): Spelling fix,
declare variante -> declare variant.

(cherry picked from commit 4a7842bb99249295bfbdfaa6a3030414e4d9eb9d)

3 years agoopenmp: Add support for OpenMP 5.1 atomics for C++
Jakub Jelinek [Fri, 17 Sep 2021 13:20:20 +0000 (15:20 +0200)] 
openmp: Add support for OpenMP 5.1 atomics for C++

Besides the C++ FE changes, I've noticed that the C FE didn't reject
  #pragma omp atomic capture compare
  { v = x; x = y; }
and other forms of atomic swap, this patch fixes that too.  And the
c-family/ routine needed quite a few changes so that the new code
in it works fine with both FEs.

2021-09-17  Jakub Jelinek  <jakub@redhat.com>

gcc/c-family/
* c-omp.c (c_finish_omp_atomic): Avoid creating
TARGET_EXPR if test is true, use create_tmp_var_raw instead of
create_tmp_var and add a zero initializer to TARGET_EXPRs that
had NULL initializer.  When omitting operands after v = x,
use type of v rather than type of x.  Fix type of vtmp
TARGET_EXPR.
gcc/c/
* c-parser.c (c_parser_omp_atomic): Reject atomic swap if capture
is true.
gcc/cp/
* cp-tree.h (finish_omp_atomic): Add r and weak arguments.
* parser.c (cp_parser_omp_atomic): Update function comment for
OpenMP 5.1 atomics, parse OpenMP 5.1 atomics and fail, compare and
weak clauses.
* semantics.c (finish_omp_atomic): Add r and weak arguments, handle
them, handle COND_EXPRs.
* pt.c (tsubst_expr): Adjust for COND_EXPR forms that
finish_omp_atomic can now produce.
gcc/testsuite/
* c-c++-common/gomp/atomic-18.c: Expect same diagnostics in C++ as in
C.
* c-c++-common/gomp/atomic-25.c: Drop c effective target.
* c-c++-common/gomp/atomic-26.c: Likewise.
* c-c++-common/gomp/atomic-27.c: Likewise.
* c-c++-common/gomp/atomic-28.c: Likewise.
* c-c++-common/gomp/atomic-29.c: Likewise.
* c-c++-common/gomp/atomic-30.c: Likewise.  Adjust expected diagnostics
for C++ when it differs from C.
(foo): Change return type from double to void.
* g++.dg/gomp/atomic-5.C: Adjust expected diagnostics wording.
* g++.dg/gomp/atomic-20.C: New test.
libgomp/
* testsuite/libgomp.c-c++-common/atomic-19.c: Drop c effective target.
Use /* */ comments instead of //.
* testsuite/libgomp.c-c++-common/atomic-20.c: Likewise.
* testsuite/libgomp.c-c++-common/atomic-21.c: Likewise.
* testsuite/libgomp.c++/atomic-16.C: New test.
* testsuite/libgomp.c++/atomic-17.C: New test.

(cherry picked from commit 3a2bcffac602f5de56537a77db1062984bcefd45)

3 years agoAdd OpenACC 'host_data' testing to 'gfortran.dg/goacc/unexpected-end.f90'
Thomas Schwinge [Fri, 17 Sep 2021 13:16:02 +0000 (15:16 +0200)] 
Add OpenACC 'host_data' testing to 'gfortran.dg/goacc/unexpected-end.f90'

Use underscore instead of space in 'host_data'.

Follow-up to recent commit 33fdbbe4ce6055eb858096d01720ccf94aa854ec
"Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]".

gcc/testsuite/
* gfortran.dg/goacc/unexpected-end.f90: Add OpenACC 'host_data'
testing.

(cherry picked from commit 8b69c481fc86e04c6c83f3a49eef2760c175a8f2)

3 years agoFix PR rtl-optimization/102306
Eric Botcazou [Fri, 17 Sep 2021 08:12:12 +0000 (10:12 +0200)] 
Fix PR rtl-optimization/102306

This is a duplication of volatile loads introduced during GCC 9 development
by the 2->2 mechanism of the RTL combiner.  There is already a substantial
checking for volatile references in can_combine_p but it implicitly assumes
that the combination reduces the number of instructions, which is of course
not the case here.  So the fix teaches try_combine to abort the combination
when it is about to make a copy of volatile references to preserve them.

gcc/
PR rtl-optimization/102306
* combine.c (try_combine): Abort the combination if we are about to
duplicate volatile references.

gcc/testsuite/
* gcc.target/sparc/20210917-1.c: New test.

3 years agoDaily bump.
GCC Administrator [Fri, 17 Sep 2021 00:18:02 +0000 (00:18 +0000)] 
Daily bump.

3 years agoFortran - fix handling of substring start and end indices
Harald Anlauf [Mon, 13 Sep 2021 17:26:35 +0000 (19:26 +0200)] 
Fortran - fix handling of substring start and end indices

gcc/fortran/ChangeLog:

PR fortran/85130
* expr.c (find_substring_ref): Handle given substring start and
end indices as signed integers, not unsigned.

gcc/testsuite/ChangeLog:

PR fortran/85130
* gfortran.dg/substr_6.f90: Revert commit r8-7574, adding again
test that was erroneously considered as illegal.

(cherry picked from commit 8d93ba93d3b13ac3d3c34404cad87732c809605b)

3 years agoFortran - ensure simplification of bounds of array-valued named constants
Harald Anlauf [Mon, 13 Sep 2021 17:28:10 +0000 (19:28 +0200)] 
Fortran - ensure simplification of bounds of array-valued named constants

gcc/fortran/ChangeLog:

PR fortran/82314
* decl.c (add_init_expr_to_sym): For proper initialization of
array-valued named constants the array bounds need to be
simplified before adding the initializer.

gcc/testsuite/ChangeLog:

PR fortran/82314
* gfortran.dg/pr82314.f90: New test.

(cherry picked from commit 104c05c5284b7822d770ee51a7d91946c7e56d50)

3 years agosparc: Add scheduling information for LEON5
Daniel Cederman [Mon, 25 Mar 2019 08:12:17 +0000 (09:12 +0100)] 
sparc: Add scheduling information for LEON5

The LEON5 can often dual issue instructions from the same 64-bit aligned
double word if there are no data dependencies. Add scheduling information
to avoid scheduling unpairable instructions back-to-back.

gcc/ChangeLog:

* config/sparc/sparc-opts.h (enum sparc_processor_type): Add LEON5
* config/sparc/sparc.c (struct processor_costs): Add LEON5 costs
(leon5_adjust_cost): Increase cost of store with data dependency
on ALU instruction and FPU anti-dependencies.
(sparc_option_override): Add LEON5 costs
(sparc_adjust_cost): Add LEON5 cost adjustments
* config/sparc/sparc.h: Add LEON5
* config/sparc/sparc.md: Include LEON5 scheduling information
* config/sparc/sparc.opt: Add LEON5
* doc/invoke.texi: Add LEON5
* config/sparc/leon5.md: New file.

3 years agosparc: Add NOP in stack_protect_setsi if sparc_fix_b2bst enabled
Daniel Cederman [Thu, 1 Oct 2020 07:11:38 +0000 (09:11 +0200)] 
sparc: Add NOP in stack_protect_setsi if sparc_fix_b2bst enabled

This is needed to prevent the Store -> (Non-store or load) -> Store
sequence.

gcc/ChangeLog:

* config/sparc/sparc.md (stack_protect_setsi): Add NOP to prevent
sensitive sequence for B2BST errata workaround.

3 years agosparc: Prevent atomic instructions in beginning of functions for UT700
Daniel Cederman [Mon, 12 Oct 2020 06:50:35 +0000 (08:50 +0200)] 
sparc: Prevent atomic instructions in beginning of functions for UT700

A call to the function might have a load instruction in the delay slot
and a load followed by an atomic function could cause a deadlock.

gcc/ChangeLog:

* config/sparc/sparc.c (sparc_do_work_around_errata): Do not begin
functions with atomic instruction in the UT700 errata workaround.

3 years agosparc: Skip all empty assembly statements
Daniel Cederman [Fri, 16 Oct 2020 07:12:30 +0000 (09:12 +0200)] 
sparc: Skip all empty assembly statements

This version detects multiple empty assembly statements in a row and also
detects non-memory barrier empty assembly statements (__asm__("")). It
can be used instead of next_active_insn().

gcc/ChangeLog:

* config/sparc/sparc.c (next_active_non_empty_insn): New function
that returns next active non empty assembly instruction.
(sparc_do_work_around_errata): Use new function.

3 years agosparc: Treat more instructions as load or store in errata workarounds
Daniel Cederman [Fri, 25 Sep 2020 11:17:46 +0000 (13:17 +0200)] 
sparc: Treat more instructions as load or store in errata workarounds

Check the attribute of instruction to determine if it performs a store
or load operation. This more generic approach sees the last instruction
in the GOTdata_op model as a potential load and treats the memory barrier
as a potential store instruction.

gcc/ChangeLog:

* config/sparc/sparc.c (store_insn_p): Add predicate for store
attributes.
(load_insn_p): Add predicate for load attributes.
(sparc_do_work_around_errata): Use new predicates.

3 years agosparc: Print out bit names for LEON and LEON3 with -mdebug
Andreas Larsson [Wed, 5 Jul 2017 11:36:31 +0000 (13:36 +0200)] 
sparc: Print out bit names for LEON and LEON3 with -mdebug

gcc/ChangeLog:

* config/sparc/sparc.c (dump_target_flag_bits): Print bit names for
LEON and LEON3.

3 years agoFix target/101934: aarch64 memset code creates unaligned stores for -mstrict-align
Andrew Pinski [Tue, 31 Aug 2021 04:41:14 +0000 (04:41 +0000)] 
Fix target/101934: aarch64 memset code creates unaligned stores for -mstrict-align

The problem here is the aarch64_expand_setmem code did not check
STRICT_ALIGNMENT if it is creating an overlapping store.
This patch adds that check and the testcase works.

gcc/ChangeLog:

PR target/101934
* config/aarch64/aarch64.c (aarch64_expand_setmem):
Check STRICT_ALIGNMENT before creating an overlapping
store.

gcc/testsuite/ChangeLog:

PR target/101934
* gcc.target/aarch64/memset-strict-align-1.c: New test.

(cherry picked from commit a45786e9a31f995087d8cb42bc3a4fe06911e588)

3 years agoDaily bump.
GCC Administrator [Thu, 16 Sep 2021 00:17:54 +0000 (00:17 +0000)] 
Daily bump.

3 years agoc++: Fix handling of decls with flexible array members initialized with side-effects...
Jakub Jelinek [Wed, 15 Sep 2021 20:21:17 +0000 (22:21 +0200)] 
c++: Fix handling of decls with flexible array members initialized with side-effects [PR88578]

> > Note, if the flexible array member is initialized only with non-constant
> > initializers, we have a worse bug that this patch doesn't solve, the
> > splitting of initializers into constant and dynamic initialization removes
> > the initializer and we don't have just wrong DECL_*SIZE, but nothing is
> > emitted when emitting those vars into assembly either and so the dynamic
> > initialization clobbers other vars that may overlap the variable.
> > I think we need keep an empty CONSTRUCTOR elt in DECL_INITIAL for the
> > flexible array member in that case.
>
> Makes sense.

So, the following patch fixes that.

The typeck2.c change makes sure we keep those CONSTRUCTORs around (although
they should be empty because all their elts had side-effects/was
non-constant if it was removed earlier), and the varasm.c change is to avoid
ICEs on those as well as ICEs on other flex array members that had some
initializers without side-effects, but not on the last array element.

The code was already asserting that the (index of the last elt in the
CONSTRUCTOR + 1) times elt size is equal to TYPE_SIZE_UNIT of the local->val
type, which is true for C flex arrays or for C++ if they don't have any
side-effects or the last elt doesn't have side-effects, this patch changes
that to assertion that the TYPE_SIZE_UNIT is greater than equal to the
offset of the end of last element in the CONSTRUCTOR and uses TYPE_SIZE_UNIT
(int_size_in_bytes) in the code later on.

2021-09-15  Jakub Jelinek  <jakub@redhat.com>

PR c++/88578
PR c++/102295
gcc/
* varasm.c (output_constructor_regular_field): Instead of assertion
that array_size_for_constructor result is equal to size of
TREE_TYPE (local->val) in bytes, assert that the type size is greater
or equal to array_size_for_constructor result and use type size as
fieldsize.
gcc/cp/
* typeck2.c (split_nonconstant_init_1): Don't throw away empty
initializers of flexible array members if they have non-zero type
size.
gcc/testsuite/
* g++.dg/ext/flexary39.C: New test.
* g++.dg/ext/flexary40.C: New test.

(cherry picked from commit e5d1af8a07ae9fcc40ea5c781c3ad46d20ea12a6)

3 years agoc++: Update DECL_*SIZE for objects with flexible array members with initializers...
Jakub Jelinek [Tue, 14 Sep 2021 14:56:30 +0000 (16:56 +0200)] 
c++: Update DECL_*SIZE for objects with flexible array members with initializers [PR102295]

The C FE updates DECL_*SIZE for vars which have initializers for flexible
array members for many years, but C++ FE kept DECL_*SIZE the same as the
type size (i.e. as if there were zero elements in the flexible array
member).  This results e.g. in ELF symbol sizes being too small.

Note, if the flexible array member is initialized only with non-constant
initializers, we have a worse bug that this patch doesn't solve, the
splitting of initializers into constant and dynamic initialization removes
the initializer and we don't have just wrong DECL_*SIZE, but nothing is
emitted when emitting those vars into assembly either and so the dynamic
initialization clobbers other vars that may overlap the variable.
I think we need keep an empty CONSTRUCTOR elt in DECL_INITIAL for the
flexible array member in that case.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

PR c++/102295
* decl.c (layout_var_decl): For aggregates ending with a flexible
array member, add the size of the initializer for that member to
DECL_SIZE and DECL_SIZE_UNIT.

* g++.target/i386/pr102295.C: New test.

(cherry picked from commit 818c505188ff5cd8eb048eb0e614c4ef732225bd)

3 years agoc++: Fix __is_*constructible/assignable for templates [PR102305]
Jakub Jelinek [Tue, 14 Sep 2021 14:55:04 +0000 (16:55 +0200)] 
c++: Fix __is_*constructible/assignable for templates [PR102305]

is_xible_helper returns error_mark_node (i.e. false from the traits)
for abstract classes by testing ABSTRACT_CLASS_TYPE_P (to) early.
Unfortunately, as the testcase shows, that doesn't work on class templates
that haven't been instantiated yet, ABSTRACT_CLASS_TYPE_P for them is false
until it is instantiated, which is done when the routine later constructs
a dummy object with that type.

The following patch fixes this by calling complete_type first, so that
ABSTRACT_CLASS_TYPE_P test will work properly, while keeping the handling
of arrays with unknown bounds, or incomplete types where it is done
currently.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

PR c++/102305
* method.c (is_xible_helper): Call complete_type on to.

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

(cherry picked from commit f008fd3a480e3718436156697ebe7eeb47841457)

3 years agoEnable store fusion on Power10.
Pat Haugen [Mon, 30 Aug 2021 15:58:21 +0000 (10:58 -0500)] 
Enable store fusion on Power10.

gcc/ChangeLog:

* config/rs6000/rs6000-cpus.def (ISA_3_1_MASKS_SERVER): Add
OPTION_MASK_P10_FUSION_2STORE.
(POWERPC_MASKS): Likewise.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Enable
store fusion for Power10.
(is_fusable_store): New.
(power10_sched_reorder): Likewise.
(rs6000_sched_reorder): Do Power10 specific reordering.
(rs6000_sched_reorder2): Likewise.
* config/rs6000/rs6000.opt: Add new option.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/fusion-p10-stst.c: New test.
* gcc.target/powerpc/fusion-p10-stst2.c: New test.

3 years agors6000: Generate an lxvp instead of two adjacent lxv instructions
Peter Bergner [Wed, 14 Jul 2021 23:27:02 +0000 (18:27 -0500)] 
rs6000: Generate an lxvp instead of two adjacent lxv instructions

The MMA build built-ins currently use individual lxv instructions to
load up the registers of a __vector_pair or __vector_quad.  If the
memory addresses of the built-in operands are to adjacent locations,
then we can use an lxvp in some cases to load up two registers at once.
The patch below adds support for checking whether memory addresses are
adjacent and emitting an lxvp instead of two lxv instructions.

2021-07-14  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (adjacent_mem_locations): Return the lower
addressed memory rtx, if any.
(rs6000_split_multireg_move): Fix code formatting.
Handle MMA build built-ins with operands in adjacent memory locations.

gcc/testsuite/
* gcc.target/powerpc/mma-builtin-9.c: New test.

(cherry picked from commit 69feb7601e86274fa9abbfb420b00c8adf947e7b)

3 years agors6000: Move rs6000_split_multireg_move to later in file
Peter Bergner [Wed, 14 Jul 2021 23:23:31 +0000 (18:23 -0500)] 
rs6000: Move rs6000_split_multireg_move to later in file

An upcoming change to rs6000_split_multireg_move requires it to be
moved later in the file to fix a declaration issue.

2021-07-14  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (rs6000_split_multireg_move): Move to later
in the file.

(cherry picked from commit 7d914777fc6c6151f430d798fc97bae927a430f7)

3 years agoDaily bump.
GCC Administrator [Wed, 15 Sep 2021 00:18:10 +0000 (00:18 +0000)] 
Daily bump.

3 years agoVerify destination[source] of a load[store] instruction is a register.
Pat Haugen [Tue, 14 Sep 2021 20:02:09 +0000 (15:02 -0500)] 
Verify destination[source] of a load[store] instruction is a register.

Backported from master:
2021-08-09  Pat Haugen  <pthaugen@linux.ibm.com>

gcc/ChangeLog:

* config/rs6000/rs6000.c (is_load_insn1): Verify destination is a
register.
(is_store_insn1): Verify source is a register.

3 years agoFortran: Add missing ST_OMP_END_SCOPE handling [PR102313]
Tobias Burnus [Tue, 14 Sep 2021 14:50:11 +0000 (16:50 +0200)] 
Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]

PR fortran/102313

gcc/fortran/ChangeLog:

* parse.c (gfc_ascii_statement): Add missing ST_OMP_END_SCOPE.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/unexpected-end.f90: New test.
* gfortran.dg/gomp/unexpected-end.f90: New test.

(cherry picked from commit 33fdbbe4ce6055eb858096d01720ccf94aa854ec)

3 years agoFix PR ada/101970
Eric Botcazou [Tue, 14 Sep 2021 09:33:05 +0000 (11:33 +0200)] 
Fix PR ada/101970

This is a regression present on the mainline and 11 branch in the form of an
ICE for an enumeration type with a full signed representation for its size.

gcc/ada/
PR ada/101970
* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Enum_Rep>:
Use an unchecked conversion instead of a regular conversion in the
enumeration case and remove Conversion_OK flag in the integer case.
<Attribute_Pos>: Remove superfluous test.

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

3 years agotestsuite: Use sync_long_long instead of sync_int_long for atomic-29.c test
Jakub Jelinek [Tue, 14 Sep 2021 09:32:46 +0000 (11:32 +0200)] 
testsuite: Use sync_long_long instead of sync_int_long for atomic-29.c test

As discussed, the test tests atomics on doubles which are 64-bit and so we
should use sync_long_long effective target instead of sync_int_long that
covers 64-bit atomics only on 64-bit arches.  I've added -march=pentium
to follow what is documented for sync_long_long, I guess -march=zarch should
be added for s390* too, but haven't tested that.

And using sync_long_long found a syntax error in that effective target
implementation, so I've fixed that too.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

* c-c++-common/gomp/atomic-29.c: Add -march=pentium
dg-additional-options for ia32.  Use sync_long_long effective target
instead of sync_int_long.
* lib/target-supports.exp (check_effective_target_sync_long_long): Fix
a syntax error.

(cherry picked from commit b29fc21482c0e203136eb5d44bdc1495de3918c6)

3 years agoopenmp: Add testing checks (whether lhs appears in operands at all) to more trees
Jakub Jelinek [Tue, 14 Sep 2021 09:31:17 +0000 (11:31 +0200)] 
openmp: Add testing checks (whether lhs appears in operands at all) to more trees

This patch adds testing checks (goa_stabilize_expr with NULL pre_p) for more
tree codes, so that we don't gimplify their operands individually unless lhs
appears in them.  Also, so that we don't have exponential compile time complexity
with the added checks, I've added a depth computation, we don't expect lhs
to be found in depth 8 or above as all the atomic forms must have x expression
in specific places in the expressions.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

* gimplify.c (goa_stabilize_expr): Add depth argument, propagate
it to recursive calls, for depth above 7 just gimplify or return.
Perform a test even for MODIFY_EXPR, ADDR_EXPR, COMPOUND_EXPR with
__builtin_clear_padding and TARGET_EXPR.
(gimplify_omp_atomic): Adjust goa_stabilize_expr callers.

(cherry picked from commit 3f89d5ebcca8ea8c363db39cd3946db12b11adcc)

3 years agoDo not issue size error for too large array type
Eric Botcazou [Tue, 14 Sep 2021 09:14:37 +0000 (11:14 +0200)] 
Do not issue size error for too large array type

The error is to be issued when objects of the type are declared instead.

gcc/ada/
* gcc-interface/decl.c (validate_size): Do not issue an error if the
old size has overflowed.

3 years agoFix inaccurate bounds in debug info for vector array types
Eric Botcazou [Tue, 14 Sep 2021 09:10:17 +0000 (11:10 +0200)] 
Fix inaccurate bounds in debug info for vector array types

They should not be 0-based, unless the array type itself is.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity): For vector types, make
the representative array the debug type.

3 years agoFix internal error on pointer-to-pointer binding in LTO mode
Eric Botcazou [Tue, 14 Sep 2021 08:44:34 +0000 (10:44 +0200)] 
Fix internal error on pointer-to-pointer binding in LTO mode

gcc/ada/
* gcc-interface/utils.c (update_pointer_to): Set TYPE_CANONICAL on
pointer and reference types.

3 years agoRemove superfluous call to UI_Is_In_Int_Range
Eric Botcazou [Tue, 14 Sep 2021 08:21:20 +0000 (10:21 +0200)] 
Remove superfluous call to UI_Is_In_Int_Range

gcc/ada/
* gcc-interface/utils.c (can_materialize_object_renaming_p): Do not
call UI_Is_In_Int_Range on the result of Normalized_First_Bit.

3 years agoGive more informative error message for by-reference types
Eric Botcazou [Tue, 14 Sep 2021 07:41:36 +0000 (09:41 +0200)] 
Give more informative error message for by-reference types

Recent compilers enforce more strictly the RM C.6(18) clause, which says
that volatile record types are by-reference types.  This changes the typical
error message now given in these cases.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity) <is_type>: Declare new
constant.  Adjust error message issued by validate_size in the case
of by-reference types.
(validate_size): Always use the error strings passed by the caller.

3 years agors6000: Expand fmod and remainder when built with fast-math [PR97142]
Xionghu Luo [Tue, 7 Sep 2021 01:22:50 +0000 (20:22 -0500)] 
rs6000: Expand fmod and remainder when built with fast-math [PR97142]

fmod/fmodf and remainder/remainderf could be expanded instead of library
call when fast-math build, which is much faster.

fmodf:
     fdivs   f0,f1,f2
     friz    f0,f0
     fnmsubs f1,f2,f0,f1

remainderf:
     fdivs   f0,f1,f2
     frin    f0,f0
     fnmsubs f1,f2,f0,f1

SPEC2017 Ofast P8LE: 511.povray_r +1.14%,  526.blender_r +1.72%

gcc/ChangeLog:

2021-09-07  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/97142
* config/rs6000/rs6000.md (fmod<mode>3): New define_expand.
(remainder<mode>3): Likewise.

gcc/testsuite/ChangeLog:

2021-09-07  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/97142
* gcc.target/powerpc/pr97142.c: New test.

(cherry-picked from 546ecb0054af302acf0839c7f3eb78598f8c0672)

3 years agoDaily bump.
GCC Administrator [Tue, 14 Sep 2021 00:18:11 +0000 (00:18 +0000)] 
Daily bump.

3 years agolibgfortran: Handle m68k extended real format in ISO_Fortran_binding.h
Andreas Schwab [Mon, 13 Sep 2021 08:30:16 +0000 (10:30 +0200)] 
libgfortran: Handle m68k extended real format in ISO_Fortran_binding.h

libgfortran/
* ISO_Fortran_binding.h (CFI_type_long_double)
(CFI_type_long_double_Complex) [LDBL_MANT_DIG == 64 &&
LDBL_MIN_EXP == -16382 && LDBL_MAX_EXP == 16384]: Define.

(cherry picked from commit fc4a29c0781186269dc5f668e76ecea82030dde3)

3 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 13 Sep 2021 06:59:27 +0000 (08:59 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-8983-gb79f0b99fde48e33ab9b01e1e2d3c184ee60cb93 (Sept 13, 2021)

3 years agolibgfortran: Makefile fix for ISO_Fortran_binding.h
Tobias Burnus [Mon, 13 Sep 2021 06:58:54 +0000 (08:58 +0200)] 
libgfortran: Makefile fix for ISO_Fortran_binding.h

libgfortran/ChangeLog:

* Makefile.am (gfor_built_src): Depend on
include/ISO_Fortran_binding.h not on ISO_Fortran_binding.h.
(ISO_Fortran_binding.h): Rename make target to ...
(include/ISO_Fortran_binding.h): ... this.
* Makefile.in: Regenerate.

(cherry picked from commit fc4f0631de806c89a383fd02428a16e91068b9f6)

3 years agoFortran: Revert to non-multilib-specific ISO_Fortran_binding.h
Sandra Loosemore [Mon, 13 Sep 2021 06:57:32 +0000 (08:57 +0200)] 
Fortran: Revert to non-multilib-specific ISO_Fortran_binding.h

Commit fef67987cf502fe322e92ddce22eea7ac46b4d75 changed the
libgfortran build process to generate multilib-specific versions of
ISO_Fortran_binding.h from a template, by running gfortran to identify
the values of the Fortran kind constants C_LONG_DOUBLE, C_FLOAT128,
and C_INT128_T.  This caused multiple problems with search paths, both
for build-tree testing and installed-tree use, not all of which have
been fixed.

This patch reverts to a non-multilib-specific .h file that uses GCC's
predefined preprocessor symbols to detect the supported types and map
them to kind values in the same way as the Fortran front end.

2021-09-06  Sandra Loosemore  <sandra@codesourcery.com>

libgfortran/
* ISO_Fortran_binding-1-tmpl.h: Deleted.
* ISO_Fortran_binding-2-tmpl.h: Deleted.
* ISO_Fortran_binding-3-tmpl.h: Deleted.
* ISO_Fortran_binding.h: New file to replace the above.
* Makefile.am (gfor_cdir): Remove MULTISUBDIR.
(ISO_Fortran_binding.h): Simplify to just copy the file.
* Makefile.in: Regenerated.
* mk-kinds-h.sh: Revert pieces no longer needed for
ISO_Fortran_binding.h.

(cherry picked from commit 13beaf9e8d2d8264c0ad8f6504793fdcf26f3f73)

3 years agolibgfortran: Further fixes for GFC/CFI descriptor conversions.
Sandra Loosemore [Mon, 13 Sep 2021 06:55:52 +0000 (08:55 +0200)] 
libgfortran: Further fixes for GFC/CFI descriptor conversions.

This patch is for:
PR100907 - Bind(c): failure handling wide character
PR100911 - Bind(c): failure handling C_PTR
PR100914 - Bind(c): errors handling complex
PR100915 - Bind(c): failure handling C_FUNPTR
PR100917 - Bind(c): errors handling long double real

All of these problems are related to the GFC descriptors constructed
by the Fortran front end containing ambigous or incomplete
information.  This patch does not attempt to change the GFC data
structure or the front end, and only makes the runtime interpret it in
more reasonable ways.  It's not a complete fix for any of the listed
issues.

The Fortran front end does not distinguish between C_PTR and
C_FUNPTR, mapping both onto BT_VOID.  That is what this patch does also.

The other bugs are related to GFC descriptors only containing elem_len
and not kind.  For complex types, the elem_len needs to be divided by
2 and then mapped onto a real kind.  On x86 targets, the kind
corresponding to C long double is different than its elem_len; since
we cannot accurately disambiguate between a 16-byte kind 10 long
double from __float128, this patch arbitrarily prefers to interpret that as
the standard long double type rather than the GNU extension.

Similarly, for character types, the GFC descriptor cannot distinguish
between character(kind=c_char, len=4) and character(kind=ucs4, len=1).
But since the front end currently rejects anything other than len=1
(PR92482) this patch uses the latter interpretation.

2021-09-01  Sandra Loosemore  <sandra@codesourcery.com>
    José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/testsuite/
PR fortran/100911
PR fortran/100915
PR fortran/100916
* gfortran.dg/PR100911.c: New file.
* gfortran.dg/PR100911.f90: New file.
* gfortran.dg/PR100914.c: New file.
* gfortran.dg/PR100914.f90: New file.
* gfortran.dg/PR100915.c: New file.
* gfortran.dg/PR100915.f90: New file.

libgfortran/
PR fortran/100907
PR fortran/100911
PR fortran/100914
PR fortran/100915
PR fortran/100917
* ISO_Fortran_binding-1-tmpl.h (CFI_type_cfunptr): Make equivalent
to CFI_type_cptr.
* runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Fix
handling of CFI_type_cptr and CFI_type_cfunptr.  Additional error
checking and code cleanup.
(gfc_desc_to_cfi_desc): Likewise.  Also correct kind mapping
for character, complex, and long double types.

(cherry picked from commit 93b6b2f614eb692d1d8126ec6cb946984a9d01d7)

3 years agoopenmp: Implement OpenMP 5.1 atomics, so far for C only
Jakub Jelinek [Mon, 13 Sep 2021 06:50:43 +0000 (08:50 +0200)] 
openmp: Implement OpenMP 5.1 atomics, so far for C only

This patch implements OpenMP 5.1 atomics (with clarifications from upcoming 5.2).
The most important changes are that it is now possible to write (for C/C++,
for Fortran it was possible before already) min/max atomics and more importantly
compare and exchange in various forms.
Also, acq_rel is now allowed on read/write and acq_rel/acquire are allowed on
update, and there are new compare, weak and fail clauses.

2021-09-10  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree-core.h (enum omp_memory_order): Add OMP_MEMORY_ORDER_MASK,
OMP_FAIL_MEMORY_ORDER_UNSPECIFIED, OMP_FAIL_MEMORY_ORDER_RELAXED,
OMP_FAIL_MEMORY_ORDER_ACQUIRE, OMP_FAIL_MEMORY_ORDER_RELEASE,
OMP_FAIL_MEMORY_ORDER_ACQ_REL, OMP_FAIL_MEMORY_ORDER_SEQ_CST and
OMP_FAIL_MEMORY_ORDER_MASK enumerators.
(OMP_FAIL_MEMORY_ORDER_SHIFT): Define.
* gimple-pretty-print.c (dump_gimple_omp_atomic_load,
dump_gimple_omp_atomic_store): Print [weak] for weak atomic
load/store.
* gimple.h (enum gf_mask): Change GF_OMP_ATOMIC_MEMORY_ORDER
to 6-bit mask, adjust GF_OMP_ATOMIC_NEED_VALUE value and add
GF_OMP_ATOMIC_WEAK.
(gimple_omp_atomic_weak_p, gimple_omp_atomic_set_weak): New inline
functions.
* tree.h (OMP_ATOMIC_WEAK): Define.
* tree-pretty-print.c (dump_omp_atomic_memory_order): Adjust for
fail memory order being encoded in the same enum and also print
fail clause if present.
(dump_generic_node): Print weak clause if OMP_ATOMIC_WEAK.
* gimplify.c (goa_stabilize_expr): Add target_expr and rhs arguments,
handle pre_p == NULL case as a test mode that only returns value
but doesn't change gimplify nor change anything otherwise, adjust
recursive calls, add MODIFY_EXPR, ADDR_EXPR, COND_EXPR, TARGET_EXPR
and CALL_EXPR handling, adjust COMPOUND_EXPR handling for
__builtin_clear_padding calls, for !rhs gimplify as lvalue rather
than rvalue.
(gimplify_omp_atomic): Adjust goa_stabilize_expr caller.  Handle
COND_EXPR rhs.  Set weak flag on gimple load/store for
OMP_ATOMIC_WEAK.
* omp-expand.c (omp_memory_order_to_fail_memmodel): New function.
(omp_memory_order_to_memmodel): Adjust for fail clause encoded
in the same enum.
(expand_omp_atomic_cas): New function.
(expand_omp_atomic_pipeline): Use omp_memory_order_to_fail_memmodel
function.
(expand_omp_atomic): Attempt to optimize atomic compare and exchange
using expand_omp_atomic_cas.
gcc/c-family/
* c-common.h (c_finish_omp_atomic): Add r and weak arguments.
* c-omp.c: Include gimple-fold.h.
(c_finish_omp_atomic): Add r and weak arguments.  Add support for
OpenMP 5.1 atomics.
gcc/c/
* c-parser.c (c_parser_conditional_expression): If omp_atomic_lhs and
cond.value is >, < or == with omp_atomic_lhs as one of the operands,
don't call build_conditional_expr, instead build a COND_EXPR directly.
(c_parser_binary_expression): Avoid calling parser_build_binary_op
if omp_atomic_lhs even in more cases for >, < or ==.
(c_parser_omp_atomic): Update function comment for OpenMP 5.1 atomics,
parse OpenMP 5.1 atomics and fail, compare and weak clauses, allow
acq_rel on atomic read/write and acq_rel/acquire clauses on update.
* c-typeck.c (build_binary_op): For flag_openmp only handle
MIN_EXPR/MAX_EXPR.
gcc/cp/
* parser.c (cp_parser_omp_atomic): Allow acq_rel on atomic read/write
and acq_rel/acquire clauses on update.
* semantics.c (finish_omp_atomic): Adjust c_finish_omp_atomic caller.
gcc/testsuite/
* c-c++-common/gomp/atomic-17.c (foo): Add tests for atomic read,
write or update with acq_rel clause and atomic update with acquire clause.
* c-c++-common/gomp/atomic-18.c (foo): Adjust expected diagnostics
wording, remove tests moved to atomic-17.c.
* c-c++-common/gomp/atomic-21.c: Expect only 2 omp atomic release and
2 omp atomic acq_rel directives instead of 4 omp atomic release.
* c-c++-common/gomp/atomic-25.c: New test.
* c-c++-common/gomp/atomic-26.c: New test.
* c-c++-common/gomp/atomic-27.c: New test.
* c-c++-common/gomp/atomic-28.c: New test.
* c-c++-common/gomp/atomic-29.c: New test.
* c-c++-common/gomp/atomic-30.c: New test.
* c-c++-common/goacc-gomp/atomic.c: Expect 1 omp atomic release and
1 omp atomic_acq_rel instead of 2 omp atomic release directives.
* gcc.dg/gomp/atomic-5.c: Adjust expected error diagnostic wording.
* g++.dg/gomp/atomic-18.C:Expect 4 omp atomic release and
1 omp atomic_acq_rel instead of 5 omp atomic release directives.
libgomp/
* testsuite/libgomp.c-c++-common/atomic-19.c: New test.
* testsuite/libgomp.c-c++-common/atomic-20.c: New test.
* testsuite/libgomp.c-c++-common/atomic-21.c: New test.

(cherry picked from commit 8122fbff770bcff183a9c3c72e8092c0ca32150b)

3 years agolibgomp.texi: Extend OpenMP 5.0 Implementation Status
Tobias Burnus [Mon, 13 Sep 2021 06:40:35 +0000 (08:40 +0200)] 
libgomp.texi: Extend OpenMP 5.0 Implementation Status

libgomp/
* libgomp.texi (OpenMP Implementation Status): Extend
OpenMP 5.0 section.
(OpenACC Profiling Interface): Fix typo.

(cherry picked from commit ff7bc505b17e67ba244ca284aa7514a4f0fc27b6)

3 years agolibgomp.texi: Add OpenMP Implementation Status
Tobias Burnus [Mon, 13 Sep 2021 06:39:23 +0000 (08:39 +0200)] 
libgomp.texi: Add OpenMP Implementation Status

libgomp/
* libgomp.texi (Enabling OpenMP): Refer to OMP spec in general
not to 4.5; link to new section.
(OpenMP Implementation Status): New.

(cherry picked from commit cff72ef4e2ff8d5775470a8a01a6d9760d2c70be)

3 years agoinvoke.texi: Fix @opindex for -foffload-options
Tobias Burnus [Mon, 13 Sep 2021 06:36:17 +0000 (08:36 +0200)] 
invoke.texi: Fix @opindex for -foffload-options

gcc/
* doc/invoke.texi (-foffload-options): Fix @opindex.

(cherry picked from commit 1bc66017c118229a101f0a2c097a9c209f777883)

3 years agoFortran: Fix Bind(C) char-len check, add ptr-contiguous check
Tobias Burnus [Mon, 13 Sep 2021 06:34:33 +0000 (08:34 +0200)] 
Fortran: Fix Bind(C) char-len check, add ptr-contiguous check

Add F2018, 18.3.6 (5), pointer + contiguous is not permitted
check for dummies in BIND(C) procs.

Fix misreading of F2018, 18.3.4/18.3.5 + 18.3.6 (5) regarding
character dummies passed as byte stream to a bind(C) dummy arg:
Per F2018, 18.3.1 only len=1 is interoperable (since F2003).
F2008 added 'constant expression' for vars (F2018, 18.3.4/18.3.5),
applicable to dummy args per F2018, C1554. I misread this such
that len > 1 is permitted if len is a constant expr.

While the latter would work as character len=1 a(10) and len=2 a(5)
have the same storage sequence and len is fixed, it is still invalid.
Hence, it is now rejected again.

gcc/fortran/ChangeLog:

* decl.c (gfc_verify_c_interop_param): Reject pointer with
CONTIGUOUS attributes as dummy arg. Reject character len > 1
when passed as byte stream.

gcc/testsuite/ChangeLog:

* gfortran.dg/bind_c_char_6.f90: Update dg-error.
* gfortran.dg/bind_c_char_7.f90: Likewise.
* gfortran.dg/bind_c_char_8.f90: Likewise.
* gfortran.dg/iso_c_binding_char_1.f90: Likewise.
* gfortran.dg/pr32599.f03: Likewise.
* gfortran.dg/bind_c_char_9.f90: Comment testcase bits which are
implementable but not valid F2018.
* gfortran.dg/bind_c_contiguous.f90: New test.

(cherry picked from commit 943c65c4494145e993af43c821c82000013c6375)

3 years agoDaily bump.
GCC Administrator [Mon, 13 Sep 2021 00:18:13 +0000 (00:18 +0000)] 
Daily bump.

3 years agod: Don't include terminating null pointer in string expression conversion (PR102185)
Iain Buclaw [Fri, 3 Sep 2021 07:34:00 +0000 (09:34 +0200)] 
d: Don't include terminating null pointer in string expression conversion (PR102185)

This gets re-added by the ExprVisitor when lowering StringExp back into a
STRING_CST during the code generator pass.

PR d/102185

gcc/d/ChangeLog:

* d-builtins.cc (d_eval_constant_expression): Don't include
terminating null pointer in string expression conversion.

gcc/testsuite/ChangeLog:

* gdc.dg/pr102185.d: New test.

(cherry picked from commit 53a4def0dc1aac39d592a0d20e9ec16e8b5574ac)

3 years agoDaily bump.
GCC Administrator [Sun, 12 Sep 2021 00:17:52 +0000 (00:17 +0000)] 
Daily bump.

3 years agoFortran - out of bounds in array constructor with implied do loop
Harald Anlauf [Thu, 9 Sep 2021 19:34:01 +0000 (21:34 +0200)] 
Fortran - out of bounds in array constructor with implied do loop

gcc/fortran/ChangeLog:

PR fortran/98490
* trans-expr.c (gfc_conv_substring): Do not generate substring
bounds check for implied do loop index variable before it actually
becomes defined.

gcc/testsuite/ChangeLog:

PR fortran/98490
* gfortran.dg/bounds_check_23.f90: New test.

(cherry picked from commit 5fe0865ab788bdc387b284a3ad57e5a95a767b18)

3 years agoFortran - improve error recovery determining array element from constructor
Harald Anlauf [Tue, 7 Sep 2021 18:51:49 +0000 (20:51 +0200)] 
Fortran - improve error recovery determining array element from constructor

gcc/fortran/ChangeLog:

PR fortran/101327
* expr.c (find_array_element): When bounds cannot be determined as
constant, return error instead of aborting.

gcc/testsuite/ChangeLog:

PR fortran/101327
* gfortran.dg/pr101327.f90: New test.

(cherry picked from commit 2a1537a19cb2fa85823cfa18ed40baa4b259b4e3)

3 years agoDaily bump.
GCC Administrator [Sat, 11 Sep 2021 00:18:00 +0000 (00:18 +0000)] 
Daily bump.

3 years agocompiler: correct condition for calling memclrHasPointers
Ian Lance Taylor [Fri, 10 Sep 2021 18:14:25 +0000 (11:14 -0700)] 
compiler: correct condition for calling memclrHasPointers

When compiling append(s, make([]typ, ln)...), where typ has a pointer,
and the append fits within the existing capacity of s, the condition
used to clear out the new elements was reversed.

Fixes golang/go#47771

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

3 years agoDaily bump.
GCC Administrator [Fri, 10 Sep 2021 00:17:54 +0000 (00:17 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Thu, 9 Sep 2021 00:18:03 +0000 (00:18 +0000)] 
Daily bump.

3 years agoc++: Fix docs on assignment of virtual bases [PR60318]
Jonathan Wakely [Tue, 31 Aug 2021 08:46:41 +0000 (09:46 +0100)] 
c++: Fix docs on assignment of virtual bases [PR60318]

The description of behaviour is incorrect, the virtual base gets
assigned before entering the bodies of A::operator= and B::operator=,
not after.

The example is also ill-formed (passing a string literal to char*) and
undefined (missing return from Base::operator=).

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
gcc/ChangeLog:

PR c++/60318
* doc/trouble.texi (Copy Assignment): Fix description of
behaviour and fix code in example.

(cherry picked from commit 3c64582372cf445eabc4f9e99def7e33fb0270ee)

3 years agoi386: Fix up @xorsign<mode>3_1 [PR102224]
Jakub Jelinek [Wed, 8 Sep 2021 09:25:31 +0000 (11:25 +0200)] 
i386: Fix up @xorsign<mode>3_1 [PR102224]

As the testcase shows, we miscompile @xorsign<mode>3_1 if both input
operands are in the same register, because the splitter overwrites op1
before with op1 & mask before using op0.

For dest = xorsign op0, op0 we can actually simplify it from
dest = (op0 & mask) ^ op0 to dest = op0 & ~mask (aka abs).

The expander change is an optimization improvement, if we at expansion
time know it is xorsign op0, op0, we can emit abs right away and get better
code through that.

The @xorsign<mode>3_1 is a fix for the case where xorsign wouldn't be known
to have same operands during expansion, but during RTL optimizations they
would appear.  We need to use earlyclobber, we require dest and op1 to be
the same but op0 must be different because we overwrite
op1 first.

2021-09-08  Jakub Jelinek  <jakub@redhat.com>

PR target/102224
* config/i386/i386.md (xorsign<mode>3): If operands[1] is equal to
operands[2], emit abs<mode>2 instead.
(@xorsign<mode>3_1): Add early-clobber for output operand.

* gcc.dg/pr102224.c: New test.
* gcc.target/i386/avx-pr102224.c: New test.

(cherry picked from commit a7b626d98a9a821ffb33466818d6aa86cac1d6fd)

3 years agotestsuite: Allow .sdata in more cases in gcc.dg/array-quals-1.c
Joseph Myers [Wed, 8 Sep 2021 15:38:18 +0000 (15:38 +0000)] 
testsuite: Allow .sdata in more cases in gcc.dg/array-quals-1.c

When testing for Nios II (gcc-testresults shows this for MIPS as
well), failures of gcc.dg/array-quals-1.c appear where a symbol was
found in .sdata rather than one of the expected sections.

FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?a$ (found a) has section ^\\.(const|rodata|srodata)|\\[RO\\] (found .sdata)
FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?b$ (found b) has section ^\\.(const|rodata|srodata)|\\[RO\\] (found .sdata)
FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?c$ (found c) has section ^\\.(const|rodata|srodata)|\\[RO\\] (found .sdata)
FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?d$ (found d) has section ^\\.(const|rodata|srodata)|\\[RO\\] (found .sdata)

Jakub's commit 0b34dbc0a24864b1674bff7a92fa3cf0f1cbcea1 allowed .sdata
for many variables in that test where use of .sdata caused a failure
on powerpc-linux.  I'm presuming the choice of which variables had
.sdata allowed was based only on the code generated for powerpc-linux,
not on any reason it would be wrong to allow it for the other
variables; thus, this patch adjusts the test to allow .sdata for some
more variables where that is needed on Nios II (and in one case where
it's not needed on Nios II, but the test results on gcc-testresults
suggest that it is needed on MIPS).

Tested with no regressions with cross to nios2-elf.

* gcc.dg/array-quals-1.c: Allow .sdata section in more cases.

(cherry picked from commit d27d694151c5604d2daba23dd2a328ae70b65194)

3 years agotestsuite: Use explicit -ftree-cselim in tests using -fdump-tree-cselim-details
Joseph Myers [Wed, 8 Sep 2021 14:59:41 +0000 (14:59 +0000)] 
testsuite: Use explicit -ftree-cselim in tests using -fdump-tree-cselim-details

When testing for Nios II (gcc-testresults shows this for various other
targets as well), tests scanning cselim dumps produce an UNRESOLVED
result because those dumps do not exist.

cselim is enabled conditionally by code in toplev.c:

  if (flag_tree_cselim == AUTODETECT_VALUE)
    {
      if (HAVE_conditional_move)
flag_tree_cselim = 1;
      else
flag_tree_cselim = 0;
    }

Add explicit -ftree-cselim to dg-options in the affected tests (as
already used by some other tests of cselim dumps) so that this dump
exists on all architectures.

Tested with no regressions with cross to nios2-elf, where this causes
the tests in question to PASS instead of being UNRESOLVED.

* gcc.dg/tree-ssa/pr89430-1.c, gcc.dg/tree-ssa/pr89430-2.c,
gcc.dg/tree-ssa/pr89430-3.c, gcc.dg/tree-ssa/pr89430-4.c,
gcc.dg/tree-ssa/pr89430-5.c, gcc.dg/tree-ssa/pr89430-6.c,
gcc.dg/tree-ssa/pr89430-7-comp-ref.c,
gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c: Use -ftree-cselim.

(cherry picked from commit d081516ae1771984bfacb9f2c402a1973fa70d69)

3 years agoDaily bump.
GCC Administrator [Wed, 8 Sep 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

3 years agogcc: xtensa: fix PR target/102115
Max Filippov [Tue, 7 Sep 2021 22:40:00 +0000 (15:40 -0700)] 
gcc: xtensa: fix PR target/102115

2021-09-07  Takayuki 'January June' Suwa  <jjsuwa_sys3175@yahoo.co.jp>
gcc/
PR target/102115
* config/xtensa/xtensa.c (xtensa_emit_move_sequence): Add
'CONST_INT_P (src)' to the condition of the block that tries to
eliminate literal when loading integer contant.

(cherry picked from commit b552c4e601c7fdc4d341e29cc1ed6081d42b00d0)

3 years agoc++: Fix up constexpr evaluation of deleting dtors [PR100495]
Jakub Jelinek [Tue, 7 Sep 2021 17:33:28 +0000 (19:33 +0200)] 
c++: Fix up constexpr evaluation of deleting dtors [PR100495]

We do not save bodies of constexpr clones and instead evaluate the bodies
of the constexpr functions they were cloned from.
I believe that is just fine for constructors because complete vs. base
ctors differ only in classes that have virtual bases and such constructors
aren't constexpr, similarly complete/base destructors.
But as the testcase below shows, for deleting destructors it is not fine,
deleting dtors while marked as clones in fact are just artificial functions
with synthetized body which calls the user destructor and deallocation.

So, either we'd need to evaluate the destructor and afterwards synthetize
and evaluate the deallocation, or we can just save and use the deleting
dtors bodies.  The latter seems much easier to me.

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

PR c++/100495
* constexpr.c (maybe_save_constexpr_fundef): Save body even for
constexpr deleting dtors.
(cxx_eval_call_expression): Don't use DECL_CLONED_FUNCTION for
deleting dtors.

* g++.dg/cpp2a/constexpr-new21.C: New test.

(cherry picked from commit 81f9718139cb1cc164ada411ada8cca9f32b8be8)

3 years agoC, C++, Fortran, OpenMP: Add support for 'flush seq_cst' construct.
Marcel Vollweiler [Tue, 7 Sep 2021 11:07:02 +0000 (04:07 -0700)] 
C, C++, Fortran, OpenMP: Add support for 'flush seq_cst' construct.

This patch adds support for the 'seq_cst' memory order clause on the 'flush'
directive which was introduced in OpenMP 5.1.

gcc/c-family/ChangeLog:

* c-omp.c (c_finish_omp_flush): Handle MEMMODEL_SEQ_CST.

gcc/c/ChangeLog:

* c-parser.c (c_parser_omp_flush): Parse 'seq_cst' clause on 'flush'
directive.

gcc/cp/ChangeLog:

* parser.c (cp_parser_omp_flush): Parse 'seq_cst' clause on 'flush'
directive.
* semantics.c (finish_omp_flush): Handle MEMMODEL_SEQ_CST.

gcc/fortran/ChangeLog:

* openmp.c (gfc_match_omp_flush): Parse 'seq_cst' clause on 'flush'
directive.
* trans-openmp.c (gfc_trans_omp_flush): Handle OMP_MEMORDER_SEQ_CST.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/flush-1.c: Add test case for 'seq_cst'.
* c-c++-common/gomp/flush-2.c: Add test case for 'seq_cst'.
* g++.dg/gomp/attrs-1.C: Adapt test to handle all flush clauses.
* g++.dg/gomp/attrs-2.C: Adapt test to handle all flush clauses.
* gfortran.dg/gomp/flush-1.f90: Add test case for 'seq_cst'.
* gfortran.dg/gomp/flush-2.f90: Add test case for 'seq_cst'.

(cherry picked from commit ba1cc6956b956eb5b92c45af79a8b1fe426ec4d3)

3 years agoDaily bump.
GCC Administrator [Tue, 7 Sep 2021 00:17:59 +0000 (00:17 +0000)] 
Daily bump.

3 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 6 Sep 2021 13:24:47 +0000 (15:24 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-8966-g57f6800aefdd102cd43f0df53ca8bcbcc7202b41 (Sept 6, 2021)

3 years ago'libgomp.c/target-43.c': '-latomic' for nvptx offloading
Thomas Schwinge [Mon, 6 Sep 2021 13:23:03 +0000 (15:23 +0200)] 
'libgomp.c/target-43.c': '-latomic' for nvptx offloading

... to avoid a regression with recent
commit 090f0d78f194e3cda23fe904016db77ea36c38fa
"openmp: Improve expand_omp_atomic_pipeline":

    unresolved symbol __atomic_compare_exchange_1
    collect2: error: ld returned 1 exit status
    mkoffload: fatal error: [...]/gcc/x86_64-pc-linux-gnu-accel-nvptx-none-gcc returned 1 exit status

libgomp/
* testsuite/libgomp.c/target-43.c: '-latomic' for nvptx offloading.

(cherry picked from commit 086bb917d6efa32d9841c34a3b762f4278c762cd)

3 years agotree-optimization/102046 - fix SLP build from scalars with patterns
Richard Biener [Wed, 25 Aug 2021 08:06:01 +0000 (10:06 +0200)] 
tree-optimization/102046 - fix SLP build from scalars with patterns

When we swap operands for SLP builds we lose track where exactly
pattern defs are - but we fail to update the any_pattern member
of the operands info.  Do so conservatively.

2021-08-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102046
* tree-vect-slp.c (vect_build_slp_tree_2): Conservatively
update ->any_pattern when swapping operands.

* gcc.dg/vect/pr102046.c: New testcase.

(cherry picked from commit 29c77454e5ab33ce06a741eacdfbd5348fbccc95)

3 years agotree-optimization/101925 - fix VN with reverse storage order
Richard Biener [Mon, 16 Aug 2021 13:17:08 +0000 (15:17 +0200)] 
tree-optimization/101925 - fix VN with reverse storage order

This fixes value-numbering breaking reverse storage order accesses
due to a missed check.  It adds a new overload for
reverse_storage_order_for_component_p and sets reversed on the
VN IL ops for component and array accesses accordingly.
It also compares the reversed reference ops flag on reference
lookup.

2021-08-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101925
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Set
reverse on COMPONENT_REF and ARRAY_REF according to
what reverse_storage_order_for_component_p does.
(vn_reference_eq): Compare reversed on reference ops.
(reverse_storage_order_for_component_p): New overload.
(vn_reference_lookup_3): Check reverse_storage_order_for_component_p
on the reference looked up.

* gcc.dg/sso-16.c: New testcase.

(cherry picked from commit 0215b3559e55f39f38e10984a804c53907f7491c)

3 years agomiddle-end/101824 - properly handle volatiles in nested fn lowering
Richard Biener [Mon, 9 Aug 2021 08:19:10 +0000 (10:19 +0200)] 
middle-end/101824 - properly handle volatiles in nested fn lowering

When we build the COMPONENT_REF of a formerly volatile local off
the FRAME decl we have to make sure to mark the COMPONENT_REF
as TREE_THIS_VOLATILE.  While the GIMPLE operand scanner looks
at the FIELD_DECL this is not how volatile GENERIC refs work.

2021-08-09  Richard Biener  <rguenther@suse.de>

PR middle-end/101824
* tree-nested.c (get_frame_field): Mark the COMPONENT_REF as
volatile in case the variable was.

* gcc.dg/tree-ssa/pr101824.c: New testcase.

(cherry picked from commit bb169406cdc9e044eaec500dd742c2fed40f5488)

3 years agoDaily bump.
GCC Administrator [Mon, 6 Sep 2021 00:17:59 +0000 (00:17 +0000)] 
Daily bump.

3 years agoFortran - extend set of substring expressions handled in length simplification
Harald Anlauf [Tue, 31 Aug 2021 19:00:53 +0000 (21:00 +0200)] 
Fortran - extend set of substring expressions handled in length simplification

gcc/fortran/ChangeLog:

PR fortran/100950
* simplify.c (substring_has_constant_len): Minimize checks for
substring expressions being allowed.

gcc/testsuite/ChangeLog:

PR fortran/100950
* gfortran.dg/pr100950.f90: Extend coverage.

(cherry picked from commit e4cb3bb9ac11b4126ffa718287dd509a4b10a658)

3 years agoFortran - simplify length of substring with constant bounds
Harald Anlauf [Thu, 19 Aug 2021 19:00:45 +0000 (21:00 +0200)] 
Fortran - simplify length of substring with constant bounds

gcc/fortran/ChangeLog:

PR fortran/100950
* simplify.c (substring_has_constant_len): New.
(gfc_simplify_len): Handle case of substrings with constant
bounds.

gcc/testsuite/ChangeLog:

PR fortran/100950
* gfortran.dg/pr100950.f90: New test.

(cherry picked from commit d881460deb1f0bdfc3e8fa2d391a03a9763cbff4)

3 years agoDaily bump.
GCC Administrator [Sun, 5 Sep 2021 00:17:58 +0000 (00:17 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Sat, 4 Sep 2021 00:18:02 +0000 (00:18 +0000)] 
Daily bump.

3 years agoFortran - correct check for constraint F2008:C628 / F2018:C932
Harald Anlauf [Mon, 30 Aug 2021 20:41:01 +0000 (22:41 +0200)] 
Fortran - correct check for constraint F2008:C628 / F2018:C932

gcc/fortran/ChangeLog:

PR fortran/101349
* resolve.c (resolve_allocate_expr): An unlimited polymorphic
argument to ALLOCATE must be ALLOCATABLE or a POINTER.  Fix the
corresponding check.

gcc/testsuite/ChangeLog:

PR fortran/101349
* gfortran.dg/unlimited_polymorphic_33.f90: New test.

(cherry picked from commit 9213ff13247739d6d335064a6b568278a872a991)

3 years agoFortran - fix whitespace issue during parsing of assigned goto
Harald Anlauf [Mon, 30 Aug 2021 21:07:56 +0000 (23:07 +0200)] 
Fortran - fix whitespace issue during parsing of assigned goto

gcc/fortran/ChangeLog:

PR fortran/102113
* match.c (gfc_match_goto): Allow for whitespace in parsing list
of labels.

gcc/testsuite/ChangeLog:

PR fortran/102113
* gfortran.dg/goto_9.f90: New test.

(cherry picked from commit a7083b83e45852540a4a09ee11b74dc28d777399)

3 years agoUse UNSPSEC_XXSPLTIDP instead of UNSPEC_XXSPLTID
Michael Meissner [Fri, 3 Sep 2021 18:12:38 +0000 (14:12 -0400)] 
Use UNSPSEC_XXSPLTIDP instead of UNSPEC_XXSPLTID

Backport from master:  2021-08-24  Michael Meissner  <meissner@linux.ibm.com>

2021-09-03  Michael Meissner  <meissner@linux.ibm.com>

gcc/

* config/rs6000/altivec.md (UNSPEC_XXSPLTIDP): Rename from
UNSPEC_XXSPLTID.
(xxspltidp_v2df): Likewise.
(xxspltidp_v2df_inst): Likewise.

3 years agoMake xxsplti*, xpermx, xxeval be vecperm type.
Michael Meissner [Fri, 3 Sep 2021 18:03:45 +0000 (14:03 -0400)] 
Make xxsplti*, xpermx, xxeval be vecperm type.

Backport from master: 2021-08-24  Michael Meissner  <meissner@linux.ibm.com>

gcc/

* config/rs6000/altivec.md (xxspltiw_v4si): Use vecperm type
attribute.  Backport from master, 2021-08-24.
(xxspltiw_v4si_inst): Likewise.
(xxspltiw_v4sf_inst): Likewise.
(xxspltidp_v2df): Likewise.
(xxspltidp_v2df_inst): Likewise.
(xxsplti32dx_v4si): Likewise.
(xxsplti32dx_v4si_inst): Likewise.
(xxsplti32dx_v4sf_inst): Likewise.
(xxblend_<mode>): Likewise.
(xxpermx): Likewise.
(xxpermx_inst): Likewise.
(xxeval): Likewise.

3 years agoFix tests that require IBM 128-bit long double
Michael Meissner [Fri, 3 Sep 2021 16:59:47 +0000 (12:59 -0400)] 
Fix tests that require IBM 128-bit long double

2021-09-03  Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
PR target/94630
* gcc.target/powerpc/pr70117.c: Specify that we need the long double
type to be IBM 128-bit.  Remove the code to use __ibm128.
Backport from master 2021-08-25.
* c-c++-common/dfp/convert-bfp-11.c: Specify that we need the long
double type to be IBM 128-bit.  Run the test at -O2 optimization.
Backport from master 2021-08-25.
* lib/target-supports.exp (add_options_for_long_double_ibm128): New
function.  Backport from master 2021-08-25.
(check_effective_target_long_double_ibm128): New function.
(add_options_for_long_double_ieee128): New function.
(check_effective_target_long_double_ieee128): New function.
(add_options_for_long_double_64bit): New function.
(check_effective_target_long_double_64bit): New function.

3 years agolibgomp.*/error-1.{c,f90}: Fix dg-output newline pattern
Tobias Burnus [Fri, 3 Sep 2021 13:30:56 +0000 (15:30 +0200)] 
libgomp.*/error-1.{c,f90}: Fix dg-output newline pattern

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/error-1.c: Use \r\n not \n\r in
dg-output.
* testsuite/libgomp.fortran/error-1.f90: Likewise.

(cherry picked from commit 4ce90454c2c81246be993d997cab12e21bc0be68)

3 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Fri, 3 Sep 2021 09:48:57 +0000 (11:48 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-8953-g259945a0a4880b66f93f71eebe70f78c91e02d5e (Sep 3, 2021)

3 years agoopenmp: Improve expand_omp_atomic_pipeline
Jakub Jelinek [Fri, 3 Sep 2021 08:15:17 +0000 (10:15 +0200)] 
openmp: Improve expand_omp_atomic_pipeline

When __atomic_* builtins were introduced, omp-expand.c (omp-low.c
at that point) has been adjusted in several spots so that it uses
the atomic builtins instead of sync builtins, but
expand_omp_atomic_pipeline has not because the __atomic_compare_exchange_*
APIs take address of the argument, so it kept using __sync_val_compare_swap_*.
That means it always uses seq_cst though.
This patch changes it to use the ATOMIC_COMPARE_EXCHANGE ifn which gimple-fold
folds __atomic_compare_exchange_* into - that ifn also passes expected
directly.

2021-09-03  Jakub Jelinek  <jakub@redhat.com>

* omp-expand.c (expand_omp_atomic_pipeline): Use
IFN_ATOMIC_COMPARE_EXCHANGE instead of
BUILT_IN_SYNC_VAL_COMPARE_AND_SWAP_? so that memory order
can be provided.

(cherry picked from commit 090f0d78f194e3cda23fe904016db77ea36c38fa)