platform/upstream/gcc.git
3 years ago[OpenACC privatization] Explain OpenACC privatization candidate selection [PR90115]
Thomas Schwinge [Thu, 20 May 2021 13:55:18 +0000 (15:55 +0200)]
[OpenACC privatization] Explain OpenACC privatization candidate selection [PR90115]

gcc/
PR middle-end/90115
* omp-low.c (oacc_privatization_candidate_p): New function.
(oacc_privatization_scan_clause_chain)
(oacc_privatization_scan_decl_chain): Use it.  Also
'gcc_checking_assert' that we're not seeing duplicates.

3 years ago[OpenACC privatization] Skip processing if no work to be done [PR90115]
Thomas Schwinge [Thu, 20 May 2021 13:45:06 +0000 (15:45 +0200)]
[OpenACC privatization] Skip processing if no work to be done [PR90115]

gcc/
PR middle-end/90115
* omp-offload.c (execute_oacc_device_lower): Skip processing if no
work to be done.

3 years ago[OpenACC privatization] Explain two different configurations [PR90115]
Thomas Schwinge [Thu, 20 May 2021 13:44:09 +0000 (15:44 +0200)]
[OpenACC privatization] Explain two different configurations [PR90115]

gcc/
PR middle-end/90115
* omp-offload.c (execute_oacc_device_lower): Explain.

3 years ago[OpenACC privatization] Don't let unhandled 'IFN_UNIQUE_OACC_PRIVATE' linger [PR90115]
Thomas Schwinge [Thu, 20 May 2021 13:37:07 +0000 (15:37 +0200)]
[OpenACC privatization] Don't let unhandled 'IFN_UNIQUE_OACC_PRIVATE' linger [PR90115]

Make sure they're all handled in 'execute_oacc_device_lower'.  Why we at all
can have 'level == -1' cases is a separate bug to be fixed.

gcc/
PR middle-end/90115
* omp-offload.c (execute_oacc_device_lower)
<IFN_UNIQUE_OACC_PRIVATE>: Diagnose and handle for 'level == -1'
case, too.
* internal-fn.c (expand_UNIQUE): Don't expect
'IFN_UNIQUE_OACC_PRIVATE'.

3 years ago[OpenACC privatization] Don't evaluate OpenMP 'for' clauses [PR90115]
Thomas Schwinge [Thu, 20 May 2021 13:22:24 +0000 (15:22 +0200)]
[OpenACC privatization] Don't evaluate OpenMP 'for' clauses [PR90115]

gcc/
PR middle-end/90115
* omp-low.c (lower_omp_for): Don't evaluate OpenMP 'for' clauses.

3 years ago[OpenACC privatization, nvptx] Tighten some aspects [PR90115]
Thomas Schwinge [Thu, 20 May 2021 13:08:38 +0000 (15:08 +0200)]
[OpenACC privatization, nvptx] Tighten some aspects [PR90115]

No functional change.

gcc/
PR middle-end/90115
* config/nvptx/nvptx.c (nvptx_goacc_adjust_private_decl)
(nvptx_goacc_expand_var_decl): Tighten.

3 years agoopenacc: Add support for gang local storage allocation in shared memory [PR90115]
Julian Brown [Fri, 26 Feb 2021 12:34:49 +0000 (04:34 -0800)]
openacc: Add support for gang local storage allocation in shared memory [PR90115]

This patch implements a method to track the "private-ness" of
OpenACC variables declared in offload regions in gang-partitioned,
worker-partitioned or vector-partitioned modes. Variables declared
implicitly in scoped blocks and those declared "private" on enclosing
directives (e.g. "acc parallel") are both handled. Variables that are
e.g. gang-private can then be adjusted so they reside in GPU shared
memory.

The reason for doing this is twofold: correct implementation of OpenACC
semantics, and optimisation, since shared memory might be faster than
the main memory on a GPU. Handling of private variables is intimately
tied to the execution model for gangs/workers/vectors implemented by
a particular target: for current targets, we use (or on mainline, will
soon use) a broadcasting/neutering scheme.

That is sufficient for code that e.g. sets a variable in worker-single
mode and expects to use the value in worker-partitioned mode. The
difficulty (semantics-wise) comes when the user wants to do something like
an atomic operation in worker-partitioned mode and expects a worker-single
(gang private) variable to be shared across each partitioned worker.
Forcing use of shared memory for such variables makes that work properly.

In terms of implementation, the parallelism level of a given loop is
not fixed until the oaccdevlow pass in the offload compiler, so the
patch delays fixing the parallelism level of variables declared on or
within such loops until the same point. This is done by adding a new
internal UNIQUE function (OACC_PRIVATE) that lists (the address of) each
private variable as an argument, and other arguments set so as to be able
to determine the correct parallelism level to use for the listed
variables. This new internal function fits into the existing scheme for
demarcating OpenACC loops, as described in comments in the patch.

Two new target hooks are introduced: TARGET_GOACC_ADJUST_PRIVATE_DECL and
TARGET_GOACC_EXPAND_VAR_DECL.  The first can tweak a variable declaration
at oaccdevlow time, and the second at expand time.  The first or both
of these target hooks can be used by a given offload target, depending
on its strategy for implementing private variables.

This patch updates the TARGET_GOACC_ADJUST_PRIVATE_DECL target hook in
the AMD GCN backend to the current name and prototype. (An earlier
version of the hook was already present, but dormant.)

gcc/
PR middle-end/90115
* doc/tm.texi.in (TARGET_GOACC_EXPAND_VAR_DECL)
(TARGET_GOACC_ADJUST_PRIVATE_DECL): Add documentation hooks.
* doc/tm.texi: Regenerate.
* expr.c (expand_expr_real_1): Expand decls using the
expand_var_decl OpenACC hook if defined.
* internal-fn.c (expand_UNIQUE): Handle IFN_UNIQUE_OACC_PRIVATE.
* internal-fn.h (IFN_UNIQUE_CODES): Add OACC_PRIVATE.
* omp-low.c (omp_context): Add oacc_privatization_candidates
field.
(lower_oacc_reductions): Add PRIVATE_MARKER parameter.  Insert
before fork.
(lower_oacc_head_tail): Add PRIVATE_MARKER parameter.  Modify
private marker's gimple call arguments, and pass it to
lower_oacc_reductions.
(oacc_privatization_scan_clause_chain)
(oacc_privatization_scan_decl_chain, lower_oacc_private_marker):
New functions.
(lower_omp_for, lower_omp_target, lower_omp_1): Use these.
* omp-offload.c (convert.h): Include.
(oacc_loop_xform_head_tail): Treat private-variable markers like
fork/join when transforming head/tail sequences.
(struct var_decl_rewrite_info): Add struct.
(oacc_rewrite_var_decl, is_sync_builtin_call): New functions.
(execute_oacc_device_lower): Support rewriting gang-private
variables using target hook, and fix up addr_expr and var_decl
nodes afterwards.
* target.def (adjust_private_decl, expand_var_decl): New hooks.
* config/gcn/gcn-protos.h (gcn_goacc_adjust_gangprivate_decl):
Rename to...
(gcn_goacc_adjust_private_decl): ...this.
* config/gcn/gcn-tree.c (gcn_goacc_adjust_gangprivate_decl):
Rename to...
(gcn_goacc_adjust_private_decl): ...this. Add LEVEL parameter.
* config/gcn/gcn.c (TARGET_GOACC_ADJUST_GANGPRIVATE_DECL): Rename
definition using gcn_goacc_adjust_gangprivate_decl...
(TARGET_GOACC_ADJUST_PRIVATE_DECL): ...to this, using
gcn_goacc_adjust_private_decl.
* config/nvptx/nvptx.c (tree-pretty-print.h): Include.
(gang_private_shared_size): New global variable.
(gang_private_shared_align): Likewise.
(gang_private_shared_sym): Likewise.
(gang_private_shared_hmap): Likewise.
(nvptx_option_override): Initialize these.
(nvptx_file_end): Output gang_private_shared_sym.
(nvptx_goacc_adjust_private_decl, nvptx_goacc_expand_var_decl):
New functions.
(nvptx_set_current_function): Clear gang_private_shared_hmap.
(TARGET_GOACC_ADJUST_PRIVATE_DECL): Define hook.
(TARGET_GOACC_EXPAND_VAR_DECL): Likewise.
libgomp/
PR middle-end/90115
* testsuite/libgomp.oacc-c-c++-common/private-atomic-1-gang.c: New
test.
* testsuite/libgomp.oacc-fortran/private-atomic-1-gang.f90:
Likewise.
* testsuite/libgomp.oacc-fortran/private-atomic-1-worker.f90:
Likewise.

Co-Authored-By: Chung-Lin Tang <cltang@codesourcery.com>
Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
3 years agox86: Remove MAX_BITSIZE_MODE_ANY_INT
H.J. Lu [Fri, 21 May 2021 12:52:11 +0000 (05:52 -0700)]
x86: Remove MAX_BITSIZE_MODE_ANY_INT

It is only defined for i386 and everyone uses the default:

 #define MAX_BITSIZE_MODE_ANY_INT (64*BITS_PER_UNIT)

Whatever problems we had before, they have been fixed now.

* config/i386/i386-modes.def (MAX_BITSIZE_MODE_ANY_INT): Removed.

3 years agoElide expand_constructor if move by pieces is preferred
H.J. Lu [Fri, 21 May 2021 12:16:20 +0000 (05:16 -0700)]
Elide expand_constructor if move by pieces is preferred

Elide expand_constructor when the constructor is static storage and not
mostly zeros and we can move it by pieces prefer to do so since that's
usually more efficient than performing a series of stores from immediates.

2021-05-21  Richard Biener  <rguenther@suse.de>
    H.J. Lu  <hjl.tools@gmail.com>

gcc/

PR middle-end/90773
* expr.c (expand_constructor): Elide expand_constructor if
move by pieces is preferred.

gcc/testsuite/

* gcc.target/i386/pr90773-24.c: New test.
* gcc.target/i386/pr90773-25.c: Likewise.

3 years agoDon't skip 'libgomp.oacc-fortran/privatized-ref-2.f90' for nvptx offloading
Thomas Schwinge [Fri, 21 May 2021 07:03:43 +0000 (09:03 +0200)]
Don't skip 'libgomp.oacc-fortran/privatized-ref-2.f90' for nvptx offloading

libgomp/
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Don't skip
for nvptx offloading.

3 years agoAdd 'libgomp.oacc-fortran/privatized-ref-2.f90'
Tobias Burnus [Wed, 3 Jun 2020 13:35:12 +0000 (15:35 +0200)]
Add 'libgomp.oacc-fortran/privatized-ref-2.f90'

libgomp/
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: New.

3 years agoaarch64: Add attributes for builtins specified in aarch64-builtins.c
Kyrylo Tkachov [Fri, 21 May 2021 13:46:00 +0000 (14:46 +0100)]
aarch64: Add attributes for builtins specified in aarch64-builtins.c

Besides the builtins in aarch64-simd-builtins.def there are a number of builtins defined in aarch64-builtins.c itself.
They could also benefit from the attributes generated by aarch64_get_attributes.
However aarch64_get_attributes and its helpers are only set up to handle a aarch64_simd_builtin_datum.

This patch changes these functions to instead take a flag and mode value that are extracted from
aarch64_simd_builtin_datum.flags and aarch64_simd_builtin_datum.mode anyway.
Then the various builtin init functions in aarch64-builtins.c can pass down their own FLAG_* flags
that they want to derive attributes from.

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.c (aarch64_call_properties):
Take a flag and mode value as arguments.
(aarch64_modifies_global_state_p): Likewise.
(aarch64_reads_global_state_p): Likewise.
(aarch64_could_trap_p): Likewise.
(aarch64_get_attributes): Likewise.
(aarch64_init_simd_builtins): Adjust callsite of above.
(aarch64_init_fcmla_laneq_builtins): Use aarch64_get_attributes to get
function attributes to apply to builtins.
(aarch64_init_crc32_builtins): Likewise.
(aarch64_init_builtin_rsqrt): Likewise.

3 years agoAdd insn types for fusion pairs
Aaron Sawdey [Tue, 2 Mar 2021 23:50:52 +0000 (17:50 -0600)]
Add insn types for fusion pairs

This adds new values for insn attr type for p10 fusion. The genfusion.pl
script is modified to use them, and fusion.md regenerated to capture
the new patterns. There are also some formatting only changes to
fusion.md that apparently weren't captured after a previous commit
of genfusion.pl.

gcc/
* config/rs6000/rs6000.md (define_attr "type"): Add types for fusion.
* config/rs6000/genfusion.pl (gen_ld_cmpi_p10): Use new fusion types.
(gen_2logical): Use new fusion types.
* config/rs6000/fusion.md: Regenerate.

3 years agoi386: Add comparisons for 4-byte vectors [PR100637]
Uros Bizjak [Fri, 21 May 2021 11:03:04 +0000 (13:03 +0200)]
i386: Add comparisons for 4-byte vectors [PR100637]

2021-05-21  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/100637
* config/i386/i386-expand.c (ix86_expand_sse_movcc):
Handle V4QI and V2HI modes.
(ix86_expand_sse_movcc): Ditto.
* config/i386/mmx.md (*<sat_plusminus:insn><VI_32:mode>3):
New instruction pattern.
(*eq<VI_32:mode>3): Ditto.
(*gt<VI_32:mode>3): Ditto.
(*xop_pcmov_<VI_32:mode>): Ditto.
(mmx_pblendvb32): Ditto.
(mmx_pblendvb64): Rename from mmx_pblendvb.
(vec_cmp<VI_32:mode><VI_32:mode>): New expander.
(vec_cmpu<VI_32:mode><VI_32:mode>): Ditto.
(vcond<VI_32:mode><VI_32:mode>): Ditto.
(vcondu<VI_32:mode><VI_32:mode>): Ditto.
(vcond_mask_<VI_32:mode><VI_32:mode>): Ditto.

gcc/testsuite/

PR target/100637
* g++.target/i386/pr100637-1b.C: New test.
* g++.target/i386/pr100637-1w.C: Ditto.
* gcc.target/i386/pr100637-2b.c: Ditto.
* gcc.target/i386/pr100637-2w.c: Ditto.

3 years agoDetect illegal conditions in Raise_xxx_Error nodes
Piotr Trojanek [Fri, 21 May 2021 09:30:26 +0000 (11:30 +0200)]
Detect illegal conditions in Raise_xxx_Error nodes

Enforce comment from sinfo.ads about the Condition field in N_Raise_xxx_Error
nodes. Only an extra sanity check; the behaviour is not affected.

gcc/ada/
* gcc-interface/trans.c (Raise_Error_to_gnu): Add an assertion.

3 years agolibsanitizer: Remove cyclades from libsanitizer
Tamar Christina [Fri, 21 May 2021 09:30:59 +0000 (10:30 +0100)]
libsanitizer: Remove cyclades from libsanitizer

The Linux kernel has removed the interface to cyclades from
the latest kernel headers[1] due to them being orphaned for the
past 13 years.

libsanitizer uses this header when compiling against glibc, but
glibcs itself doesn't seem to have any references to cyclades.

Further more it seems that the driver is broken in the kernel and
the firmware doesn't seem to be available anymore.

As such since this is breaking the build of libsanitizer (and so the
GCC bootstrap[2]) I propose to remove this.

[1] https://lkml.org/lkml/2021/3/2/153
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100379

(cherry picked from commit f7c5351552387bd43f6ca3631016d7f0dfe0f135)

libsanitizer/ChangeLog:

PR sanitizer/100379
* sanitizer_common/sanitizer_common_interceptors_ioctl.inc: Cherry-pick
llvm-project revision f7c5351552387bd43f6ca3631016d7f0dfe0f135.
* sanitizer_common/sanitizer_platform_limits_posix.cpp: Likewise.
* sanitizer_common/sanitizer_platform_limits_posix.h: Likewise.

3 years agoRemove discriminant checks in gigi
Eric Botcazou [Fri, 21 May 2021 09:25:53 +0000 (11:25 +0200)]
Remove discriminant checks in gigi

gcc/ada/
* gcc-interface/utils.c (gnat_pushdecl): Fix typo in comment.
* gcc-interface/utils2.c (build_simple_component_ref): Build NULL_EXPR
if the offset of the field has overflowed.
(build_component_ref): Add gigi checking assertion that the reference
has been built and replace the discriminant check by a Program_Error.

3 years agoConsistently generate debug info for elaboration variables
Eric Botcazou [Fri, 21 May 2021 09:19:32 +0000 (11:19 +0200)]
Consistently generate debug info for elaboration variables

This makes sure that debug info is generated for elaboration variables,
even if the variables are not generated exclusively for this purpose.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Named_Integer>: Do
not pass default value in call to create_var_decl.
<E_Variable>: Likewise.
<E_Record_Subtype>: Both pass true for const_flag and false for
const_decl_allowed_p in call to create_var_decl.
Small tweaks in the generic record type case.
(elaborate_expression): Rename need_debug into need_for_debug and
adjust throughout.
(elaborate_expression_1): Likewise.  Pass Needs_Debug_Info instead
of need_for_debug in call to create_var_decl.
(elaborate_expression_2): Likewise.
* gcc-interface/utils.c (maybe_pad_type): Pass false for
const_decl_allowed_p in call to create_var_decl.

3 years agoReplace ? with ?? in warning messages
Ghjuvan Lacambre [Fri, 21 May 2021 09:14:13 +0000 (11:14 +0200)]
Replace ? with ?? in warning messages

The former has been deprecated in favor of the latter.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity): Replace ? with ??.
(gnat_to_gnu_param): Likewise.
(gnat_to_gnu_subprog_type): Likewise.
(warn_on_field_placement): Likewise.
(intrin_arglists_compatible_p): Likewise.
* gcc-interface/trans.c (Pragma_to_gnu): Likewise.
(gnat_to_gnu): Likewise.
(validate_unchecked_conversion): Likewise.
* gcc-interface/utils.c (maybe_pad_type): Likewise.

3 years agoFix internal error on locally derived bit-packed array type
Eric Botcazou [Fri, 21 May 2021 08:57:02 +0000 (10:57 +0200)]
Fix internal error on locally derived bit-packed array type

This is a regression present on the mainline, 11 and 10 branches,
in the form of an ICE on a locally derived bit-packed array type.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Process
the implementation type of a packed type implemented specially.
gcc/testsuite/
* gnat.dg/derived_type7.adb, gnat.dg/derived_type7.ads: New test.

3 years agoAlways translate Is_Pure flag into pure in C sense
Eric Botcazou [Fri, 21 May 2021 08:45:21 +0000 (10:45 +0200)]
Always translate Is_Pure flag into pure in C sense

Gigi has historically translated the Is_Pure flag of the front-end into
the "const" attribute of GNU C.  That's correct for subprograms of pure
Ada units, but not fully exact according to the semantics of the flag.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_subprog_type): Always translate
the Is_Pure flag into the "pure" attribute of GNU C.

3 years agoFix segfault at run time on strict-alignment platforms
Eric Botcazou [Fri, 21 May 2021 08:40:41 +0000 (10:40 +0200)]
Fix segfault at run time on strict-alignment platforms

This fixes a regression present on the mainline and 11 branch by
restricting the problematic change dealing with bitfields whose
nomimal subtype is self-referential to the cases where the size
is really lower.

gcc/ada/
* gcc-interface/trans.c (Call_to_gnu): Restrict previous change
to bitfields whose size is not equal to the type size.
(gnat_to_gnu): Likewise.

3 years agotree-optimization: Improve spaceship_replacement [PR94589]
Jakub Jelinek [Fri, 21 May 2021 08:39:50 +0000 (10:39 +0200)]
tree-optimization: Improve spaceship_replacement [PR94589]

On Wed, May 19, 2021 at 01:30:31PM -0400, Jason Merrill via Gcc-patches wrote:
> Here, when genericizing lexicographical_compare_three_way, we haven't yet
> walked the operands, so (a == a) still sees ADDR_EXPR <a>, but this is after
> we've changed the type of a to REFERENCE_TYPE.  When we try to fold (a == a)
> by constexpr evaluation, the constexpr code doesn't understand trying to
> take the address of a reference, and we end up crashing.
>
> Fixed by avoiding constexpr evaluation in genericize_spaceship, by using
> fold_build2 instead of build_new_op on scalar operands.  Class operands
> should have been expanded during parsing.

Unfortunately this slightly changed the IL and spaceship_replacement no
longer pattern matches it.

Here are 3 improvements that make it match:

1) as mentioned in the comment above spaceship_replacement, for
   strong_ordering, we are pattern matching something like:
   x == y ? 0 : x < y ? -1 : 1;
   and for partial_ordering
   x == y ? 0 : x < y ? -1 : x > y ? 1 : 2;
   but given the == comparison done first and the other comparisons only
   if == was false, we actually don't care if the other comparisons
   are < vs. <= (or > vs. >=), provided the operands of the comparison
   are the same; we know == is false when doing those and < vs. <= or
   > vs. >= have the same behavior for NaNs too
2) when y is an integral constant, we should treat x < 5 equivalently
   to x <= 4 etc.
3) the code punted if cond2_phi_edge wasn't a EDGE_TRUE_VALUE edge, but
   as the new IL shows, that isn't really needed; given 1) that
   > and >= are equivalent in the code, any of swapping the comparison
   operands, changing L[TE]_EXPR to G[TE]_EXPR or vice versa or
   swapping the EDGE_TRUE_VALUE / EDGE_FALSE_VALUE bits on the edges
   reverses one of the two comparisons

2021-05-21  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94589
* tree-ssa-phiopt.c (spaceship_replacement): For integral rhs1 and
rhs2, treat x <= 4 equivalently to x < 5 etc.  In cmp1 and cmp2 (if
not the same as cmp3) treat <= the same as < and >= the same as >.
Don't require that cond2_phi_edge is true edge, instead take
false/true edges into account based on cmp1/cmp2 comparison kinds.

3 years agoFix spurious No_Elaboration violation for Size attribute
Eric Botcazou [Fri, 21 May 2021 08:34:00 +0000 (10:34 +0200)]
Fix spurious No_Elaboration violation for Size attribute

We optimize the associated range check but nevertheless flag a violation.

gcc/ada/
* gcc-interface/trans.c (Call_to_gnu): Minor tweaks.
(gnat_to_gnu_external): Likewise.
(Raise_Error_to_gnu): Return an empty statement list if there is a
condition and it is always false.
(gnat_to_gnu): Do not check for elaboration code a priori during the
translation but a posteriori instead.

3 years agoFix incorrect SLOC on instruction
Eric Botcazou [Fri, 21 May 2021 08:26:50 +0000 (10:26 +0200)]
Fix incorrect SLOC on instruction

This puts the missing SLOC on a statement generated by a return.

gcc/ada/
* gcc-interface/trans.c (gnat_to_gnu) <N_Simple_Return_Statement>:
Put a SLOC on the assignment from the return value to the return
object in the copy-in/copy-out case.

3 years agoUse EXACT_DIV_EXPR as much as possible
Eric Botcazou [Fri, 21 May 2021 08:19:32 +0000 (10:19 +0200)]
Use EXACT_DIV_EXPR as much as possible

...when the division is exact, typically dividing TYPE_SIZE by BITS_PER_UNIT.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Replace
CEIL_DIV_EXPR with EXACT_DIV_EXPR.
* gcc-interface/misc.c (gnat_type_max_size): Likewise.
* gcc-interface/utils.c (maybe_pad_type): Likewise.
(finish_record_type): Likewise.  And always compute the unit size.

3 years agoi386: Add minmax and abs patterns for 4-byte vectors [PR100637]
Uros Bizjak [Fri, 21 May 2021 06:01:34 +0000 (08:01 +0200)]
i386: Add minmax and abs patterns for 4-byte vectors [PR100637]

2021-05-21  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/100637
* config/i386/mmx.md (SMAXMIN_MMXMODEI): New mode iterator.
(<smaxmin:code><SMAXMIN_MMXMODEI:mode>3): Macroize expander
from <smaxmin:code>v4hi3> and <smaxmin:code><MMXMODE14:mode>3
using SMAXMIN_MMXMODEI mode iterator.
(*<smaxmin:code>v4qi3): New insn pattern.
(*<smaxmin:code>v2hi3): Ditto.
(SMAXMIN_VI_32): New mode iterator.
(<smaxmin:code><SMAXMIN_VI_32>mode3): New expander.

(UMAXMIN_MMXMODEI): New mode iterator.
(<umaxmin:code><UMAXMIN_MMXMODEI:mode>3): Macroize expander
from <umaxmin:code>v8qi3> and <umaxmin:code><MMXMODE24:mode>3
using UMAXMIN_MMXMODEI mode iterator.
(*<umaxmin:code>v4qi3): New insn pattern.
(*<umaxmin:code>v2hi3): Ditto.
(UMAXMIN_VI_32): New mode iterator.
(<umaxmin:code><UMAXMIN_VI_32>mode3): New expander.

(abs<VI_32:mode>2): New insn pattern.
(ssse3_abs<MMXMODEI:mode>2, abs<MMXMODEI:mode>2): Move from ...
* config/i386/sse.md: ... here.

3 years agolibstdc++: Implement LWG 3490 change to drop_while_view::begin()
Patrick Palka [Fri, 21 May 2021 04:05:18 +0000 (00:05 -0400)]
libstdc++: Implement LWG 3490 change to drop_while_view::begin()

libstdc++-v3/ChangeLog:

PR libstdc++/100606
* include/std/ranges (drop_while_view::begin): Assert the
precondition added by LWG 3490.

3 years agolibstdc++: Fix access issue in iota_view::_Sentinel [PR100690]
Patrick Palka [Fri, 21 May 2021 03:39:05 +0000 (23:39 -0400)]
libstdc++: Fix access issue in iota_view::_Sentinel [PR100690]

libstdc++-v3/ChangeLog:

PR libstdc++/100690
* include/std/ranges (iota_view::_Sentinel::_M_distance_from):
Split out this member function from ...
(iota_view::_Sentinel::operator-): ... here, for sake of access
control.
* testsuite/std/ranges/iota/iota_view.cc (test05): New test.

3 years agoDaily bump.
GCC Administrator [Fri, 21 May 2021 00:16:57 +0000 (00:16 +0000)]
Daily bump.

3 years agoaix: collect2 text files in archive
David Edelsohn [Thu, 20 May 2021 18:07:18 +0000 (14:07 -0400)]
aix: collect2 text files in archive

Rust places text files in archives.  AIX ld ignores such files with a
warning.  The collect2 wrapper for ld had been exiting with a fatal
error if it scanned an archive that contained a non-COFF file.

This patch updates collect2.c to issue a warning and ignore the file
member, matching the behavior of AIX ld.  GCC can encounter archives
created by Rust and should not issue a fatal error.  This changes
fatal_error to warning, with an implicit location and no associated
optimization flag.

gcc/ChangeLog:

2021-05-20  Clement Chigot  <clement.chigot@atos.net>
    David Edelsohn  <dje.gcc@gmail.com>

* collect2.c (scan_prog_file): Issue non-fatal warning for
non-COFF files.

3 years agoc++: designators in single-element init lists
Jason Merrill [Thu, 20 May 2021 01:13:43 +0000 (21:13 -0400)]
c++: designators in single-element init lists

While looking at PR100489, it occurred to me that places that currently
use an initializer-list with a single element to initialize an object of the
same type shouldn't do that if the element has a designator.

gcc/cp/ChangeLog:

* call.c (reference_binding): Check for designator.
(implicit_conversion_1, build_special_member_call): Likewise.
* decl.c (reshape_init_r): Likewise.
* pt.c (do_class_deduction): Likewise.
* typeck2.c (digest_init_r): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/desig19.C: New test.

3 years agoc++: designated init with anonymous union [PR100489]
Jason Merrill [Thu, 20 May 2021 01:12:45 +0000 (21:12 -0400)]
c++: designated init with anonymous union [PR100489]

My patch for PR98463 added an assert that tripped on this testcase, because
we ended up with a U CONSTRUCTOR with an initializer for a, which is not a
member of U.  We need to wrap the a initializer in another CONSTRUCTOR for
the anonymous union.

There was already support for this in process_init_constructor_record, but
not in process_init_constructor_union.  But since this is about brace
elision, it really belongs under reshape_init rather than digest_init, so
this patch moves the handling to reshape_init_class, which also handles
unions.

PR c++/100489

gcc/cp/ChangeLog:

* decl.c (reshape_init_class): Handle designator for
member of anonymous aggregate here.
* typeck2.c (process_init_constructor_record): Not here.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/desig18.C: New test.

3 years agolibstdc++: Do not use static_assert without message in C++11
Jonathan Wakely [Thu, 20 May 2021 20:12:15 +0000 (21:12 +0100)]
libstdc++: Do not use static_assert without message in C++11

libstdc++-v3/ChangeLog:

* include/bits/random.tcc (__representable_as_double)
(__p1_representable_as_double): Add "" to static asserts.

3 years agolibstdc++: Use __builtin_unreachable for constexpr assertions [PR 100676]
Jonathan Wakely [Thu, 20 May 2021 15:39:06 +0000 (16:39 +0100)]
libstdc++: Use __builtin_unreachable for constexpr assertions [PR 100676]

The current implementation of compile-time precondition checks causes
compilation to fail by calling a non-constexpr function declared at
block scope. This breaks the CUDA compiler, which wraps some libstdc++
headers in a pragma that declares everything as a __host__ __device__
function, but others are not wrapped and so everything is a __host__
function. The local declaration thus gets redeclared as two different
types of function, which doesn't work.

Just use __builtin_unreachable to make constant evaluation fail, instead
of the local function declaration. Also simplify the assertion macros,
which has the side effect of giving simpler compilation errors when
using Clang.

libstdc++-v3/ChangeLog:

PR libstdc++/100676
* include/bits/c++config (__glibcxx_assert_1): Rename to ...
(__glibcxx_constexpr_assert): ... this.
(__glibcxx_assert_impl): Use __glibcxx_constexpr_assert.
(__glibcxx_assert): Define as either __glibcxx_constexpr_assert
or __glibcxx_assert_impl.
(__glibcxx_assert_2): Remove
* include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_AT_F): Use
__glibcxx_constexpr_assert instead of __glibcxx_assert_1.
* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
Adjust expected error.
* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc:
Likewise.
* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
Likewise.
Likewise.
* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
Likewise.
* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc:
Likewise.
* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
Likewise.
* testsuite/23_containers/span/back_neg.cc: Likewise.
* testsuite/23_containers/span/front_neg.cc: Likewise.
* testsuite/23_containers/span/index_op_neg.cc: Likewise.

3 years agoc++: Add new warning options for C++ language mismatches
Jonathan Wakely [Wed, 19 May 2021 20:35:58 +0000 (21:35 +0100)]
c++: Add new warning options for C++ language mismatches

This adds new warning flags, enabled by default: -Wc++11-extensions,
-Wc++14-extensions, -Wc++17-extensions, -Wc++20-extensions, and
-Wc++23-extensions. The names of the flags are copied from Clang, which
already has similar options.

No new diagnostics are added, but the new OPT_Wxxx variables are used to
control existing pedwarns about occurences of new C++ constructs in code
using an old C++ standard dialect. This allows several existing warnings
that cannot currently be disabled to be controlled by the appropriate
-Wno-xxx flag. For example, it will now be possible to disable warnings
about using variadic templates in C++98 code, by using the new
-Wno-c++11-extensions option. This will allow libstdc++ headers to
disable those warnings unconditionally by using diagnostic pragmas, so
that they are not emitted even if -Wsystem-headers is used.

Some of the affected diagnostics are currently only given when
-Wpedantic is used. Now that we have a more specific warning flag, we
could consider making them not depend on -Wpedantic, and only on the new
flag. This patch does not do that, as it intends to make no changes to
what is accepted/rejected by default. The only effect should be that
the new option is shown when -fdiagnostics-show-option is active, and
that some warnings can be disabled by using the new flags (and for the
warnings that previously only dependend on -Wpedantic, it will now be
possible to disable just those warnings while still using -Wpedantic for
its other benefits).

gcc/c-family/ChangeLog:

* c.opt (Wc++11-extensions, Wc++14-extensions)
(Wc++17-extensions, Wc++20-extensions, Wc++23-extensions): New
options.

gcc/cp/ChangeLog:

* call.c (maybe_warn_array_conv): Use new warning option.
* decl.c (mark_inline_variable, grokdeclarator): Likewise.
* error.c (maybe_warn_cpp0x): Likewise.
* parser.c (cp_parser_primary_expression)
(cp_parser_unqualified_id)
(cp_parser_pseudo_destructor_name)
(cp_parser_lambda_introducer)
(cp_parser_lambda_declarator_opt)
(cp_parser_selection_statement)
(cp_parser_init_statement)
(cp_parser_decomposition_declaration)
(cp_parser_function_specifier_opt)
(cp_parser_static_assert)
(cp_parser_namespace_definition)
(cp_parser_using_declaration)
(cp_parser_asm_definition)
(cp_parser_ctor_initializer_opt_and_function_body)
(cp_parser_initializer_list)
(cp_parser_type_parameter_key)
(cp_parser_member_declaration)
(cp_parser_try_block)
(cp_parser_std_attribute_spec): Likewise.
* pt.c (check_template_variable): Likewise.

gcc/ChangeLog:

* doc/invoke.texi (-Wno-c++11-extensions)
(-Wno-c++14-extensions, -Wno-c++17-extensions)
(-Wno-c++20-extensions, -Wno-c++23-extensions): Document
new options.

3 years agodwarf: new dwarf_debuginfo_p predicate
Indu Bhagat [Fri, 30 Apr 2021 15:03:52 +0000 (08:03 -0700)]
dwarf: new dwarf_debuginfo_p predicate

This patch introduces a dwarf_debuginfo_p predicate that abstracts and
replaces complex checks on write_symbols.

gcc/c-family/ChangeLog:

* c-lex.c (init_c_lex): Use dwarf_debuginfo_p.

gcc/ChangeLog:

* config/c6x/c6x.c (c6x_output_file_unwind): Use dwarf_debuginfo_p.
* config/darwin.c (darwin_override_options): Likewise.
* config/i386/cygming.h (DBX_REGISTER_NUMBER): Likewise.
* config/i386/darwin.h (DBX_REGISTER_NUMBER): Likewise.
(DWARF2_FRAME_REG_OUT): Likewise.
* config/mips/mips.c (mips_output_filename): Likewise.
* config/rs6000/rs6000.c (rs6000_xcoff_declare_function_name):
Likewise.
(rs6000_dbx_register_number): Likewise.
* dbxout.c: Include flags.h.
* dwarf2cfi.c (cfi_label_required_p): Likewise.
(dwarf2out_do_frame): Likewise.
* except.c: Include flags.h.
* final.c (dwarf2_debug_info_emitted_p): Likewise.
(final_scan_insn_1): Likewise.
* flags.h (dwarf_debuginfo_p): New function declaration.
* opts.c (dwarf_debuginfo_p): New function definition.
* targhooks.c (default_debug_unwind_info): Use dwarf_debuginfo_p.
* toplev.c (process_options): Likewise.

3 years agoopts: change write_symbols to support bitmasks
Indu Bhagat [Fri, 30 Apr 2021 14:52:40 +0000 (07:52 -0700)]
opts: change write_symbols to support bitmasks

To support multiple debug formats, we need to move away from explicit
enumeration of each individual combination of debug formats.

gcc/c-family/ChangeLog:

* c-opts.c (c_common_post_options): Adjust access to debug_type_names.
* c-pch.c (struct c_pch_validity): Use type uint32_t.
(pch_init): Renamed member.
(c_common_valid_pch): Adjust access to debug_type_names.

gcc/ChangeLog:

* common.opt: Change type to support bitmasks.
* flag-types.h (enum debug_info_type): Rename enumerator constants.
(NO_DEBUG): New bitmask.
(DBX_DEBUG): Likewise.
(DWARF2_DEBUG): Likewise.
(XCOFF_DEBUG): Likewise.
(VMS_DEBUG): Likewise.
(VMS_AND_DWARF2_DEBUG): Likewise.
* flags.h (debug_set_to_format): New function declaration.
(debug_set_count): Likewise.
(debug_set_names): Likewise.
* opts.c (debug_type_masks): Array of bitmasks for debug formats.
(debug_set_to_format): New function definition.
(debug_set_count): Likewise.
(debug_set_names): Likewise.
(set_debug_level): Update access to debug_type_names.
* toplev.c: Likewise.

gcc/objc/ChangeLog:

* objc-act.c (synth_module_prologue): Use uint32_t instead of enum
debug_info_type.

gcc/testsuite/ChangeLog:

* gcc.dg/pch/valid-1.c: Adjust diagnostic message in testcase.
* lib/dg-pch.exp: Adjust diagnostic message.

3 years agoPR middle-end/100684 - spurious -Wnonnull with -O1 on a C++ lambda
Martin Sebor [Thu, 20 May 2021 19:15:58 +0000 (13:15 -0600)]
PR middle-end/100684 - spurious -Wnonnull with -O1 on a C++ lambda

gcc/ChangeLog:

PR middle-end/100684
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Handle C++ lambda.

gcc/testsuite/ChangeLog:

PR middle-end/100684
* g++.dg/warn/Wnonnull13.C: New test.
* g++.dg/warn/Wnonnull14.C: New test.
* g++.dg/warn/Wnonnull15.C: New test.

3 years agoFix a test failure in g++.dg/modules/omp-1_c.C
Bernd Edlinger [Thu, 20 May 2021 18:19:43 +0000 (20:19 +0200)]
Fix a test failure in g++.dg/modules/omp-1_c.C

Adjust the line number due to previous commit,
which added a line for dg-require-effective-target.

2021-05-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* g++.dg/modules/omp-1_c.C: Fix testcase.

3 years agolibstdc++: Implement missing P0896R4 changes to reverse_iterator [PR100639]
Patrick Palka [Thu, 20 May 2021 18:08:17 +0000 (14:08 -0400)]
libstdc++: Implement missing P0896R4 changes to reverse_iterator [PR100639]

This implements the P0896R4 changes to reverse_iterator's member types
value_type, difference_type and reference in C++20 mode, which fixes
taking the reverse_iterator of an iterator with a non-integral
difference_type (such as iota_view<long long>).

libstdc++-v3/ChangeLog:

PR libstdc++/100639
* include/bits/stl_iterator.h (reverse_iterator::difference_type):
In C++20 mode, define in terms of iter_difference_t as per P0896R4.
(reverse_iterator::reference): Likewise, but with iter_reference_t.
(reverse_iterator::value_type): Likewise, but with iter_value_t.
* testsuite/std/ranges/adaptors/reverse.cc (test08): New test.
* testsuite/24_iterators/reverse_iterator/100639.cc: New test.

3 years agoi386: Avoid integer logic insns for 32bit and 64bit vector modes [PR100701]
Uros Bizjak [Thu, 20 May 2021 16:48:16 +0000 (18:48 +0200)]
i386: Avoid integer logic insns for 32bit and 64bit vector modes [PR100701]

Integer logic instructions clobber flags, do not use them for
32bit and 64bit vector modes.

2021-05-20  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/100701
* config/i386/i386.md (isa): Remove x64_bmi.
(enabled): Remove x64_bmi.
* config/i386/mmx.md (mmx_andnot<MMXMODEI:mode>3):
Remove general register alternative.
(*andnot<VI_32:mode>3): Ditto.
(*mmx_<any_logic:code><MMXMODEI:mode>3): Ditto.
(*<any_logic:code><VI_32:mode>3): Ditto.

gcc/testsuite/

PR target/100701
* gcc.target/i386/pr100701.c: New test.

3 years agoFortran/OpenMP: Add support for 'close' in map clause
Marcel Vollweiler [Thu, 20 May 2021 15:52:34 +0000 (08:52 -0700)]
Fortran/OpenMP: Add support for 'close' in map clause

gcc/fortran/ChangeLog:

* openmp.c (gfc_match_omp_clauses): Support map-type-modifier 'close'.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/map-6.f90: New test.
* gfortran.dg/gomp/map-7.f90: New test.
* gfortran.dg/gomp/map-8.f90: New test.

3 years agoFix gnat.dg spurious failures on PowerPC64 LE
Eric Botcazou [Thu, 20 May 2021 15:12:11 +0000 (17:12 +0200)]
Fix gnat.dg spurious failures on PowerPC64 LE

gcc/testsuite
PR testsuite/96488
* gnat.dg/unchecked_convert5.adb: Do not run on PowerPC64 LE.
* gnat.dg/unchecked_convert6.adb: Likewise.

3 years agolibstdc++: Disable floating_to_chars.cc on 16 bit targets
Joern Rennecke [Thu, 20 May 2021 12:21:41 +0000 (13:21 +0100)]
libstdc++: Disable floating_to_chars.cc on 16 bit targets

This patch conditionally disables the compilation of floating_to_chars.cc
on 16 bit targets, thus fixing a build failure for these targets as
the POW10_SPLIT_2 array exceeds the maximum object size.

libstdc++-v3/
PR libstdc++/100361
* include/std/charconv (to_chars): Hide the overloads for
floating-point types for 16 bit targets.
* src/c++17/floating_to_chars.cc: Don't compile for 16 bit targets.
* testsuite/20_util/to_chars/double.cc: Run this test only on
size32plus targets.
* testsuite/20_util/to_chars/float.cc: Likewise.
* testsuite/20_util/to_chars/long_double.cc: Likewise.

3 years agoarm: Fix build failure by adding includes
Kewen Lin [Thu, 20 May 2021 10:16:19 +0000 (05:16 -0500)]
arm: Fix build failure by adding includes

Commit r12-939 missed to add the required include files for
the newly used type loop_vec_info.  This patch is to add
the include file "tree-vectorizer.h" which defines
loop_vec_info and its required include file "cfgloop.h".

gcc/ChangeLog:

* config/arm/arm.c: Include head files tree-vectorizer.h and
cfgloop.h.

3 years agoi386: Add mult-high and shift patterns for 4-byte vectors [PR100637]
Uros Bizjak [Thu, 20 May 2021 09:11:21 +0000 (11:11 +0200)]
i386: Add mult-high and shift patterns for 4-byte vectors [PR100637]

2021-05-20  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/100637
* config/i386/mmx.md (Yv_Yw): Revert adding V4QI and V2HI modes.
(*<plusminus:insn><VI_32:mode>3): Use Yw instad of <Yv_Yw> constrint.
(<s>mulv4hi3_highpart): New expander.
(*<s>mulv2hi3_highpart): New insn pattern.
(<s>mulv2hi3_higpart): New expander.
(*<any_shift:insn>v2hi3): New insn pattern.
(<any_shift:insn>v2hi3): New expander.
* config/i386/sse.md (smulhrsv2hi3): New expander.
(*smulhrsv2hi3): New insn pattern.

gcc/testsuite/

PR target/100637
* gcc.target/i386/pr100637-1w.c (shl, ashr, lshr): New tests.

3 years agovect: Replace hardcoded inner loop cost factor
Kewen Lin [Wed, 19 May 2021 10:42:51 +0000 (05:42 -0500)]
vect: Replace hardcoded inner loop cost factor

This patch is to replace the current hardcoded weight factor
50, which is applied by the loop vectorizer to the cost of
statements in an inner loop relative to the loop being
vectorized, with one newly added member inner_loop_cost_factor
in loop vinfo.  It also introduces one parameter
vect-inner-loop-cost-factor whose default value is 50, and
is used to initialize the inner_loop_cost_factor member.

The motivation here is that: if targets want to have one
unique function to gather some information in each add_stmt_cost
call, no matter that it's put before or after the cost tweaking
part for inner loop, it may have the need to adjust (expand or
shrink) the gathered data as the factor.  Now the factor is
hardcoded, it's not easily maintained.

Bootstrapped/regtested on powerpc64le-linux-gnu P9,
x86_64-redhat-linux and aarch64-linux-gnu.

gcc/ChangeLog:

* doc/invoke.texi (vect-inner-loop-cost-factor): Document new
parameter.
* params.opt (vect-inner-loop-cost-factor): New.
* targhooks.c (default_add_stmt_cost): Replace hardcoded factor
50 with LOOP_VINFO_INNER_LOOP_COST_FACTOR, include head file
tree-vectorizer.h and its required ones.
* config/aarch64/aarch64.c (aarch64_add_stmt_cost): Replace
hardcoded factor 50 with LOOP_VINFO_INNER_LOOP_COST_FACTOR.
* config/arm/arm.c (arm_add_stmt_cost): Likewise.
* config/i386/i386.c (ix86_add_stmt_cost): Likewise.
* config/rs6000/rs6000.c (rs6000_add_stmt_cost): Likewise.
* tree-vect-loop.c (vect_compute_single_scalar_iteration_cost):
Likewise.
(_loop_vec_info::_loop_vec_info): Init inner_loop_cost_factor.
* tree-vectorizer.h (_loop_vec_info): Add inner_loop_cost_factor.
(LOOP_VINFO_INNER_LOOP_COST_FACTOR): New macro.

3 years agoc: Add support for __FILE_NAME__ macro (PR c/42579)
Christophe Lyon [Thu, 20 May 2021 08:10:50 +0000 (08:10 +0000)]
c: Add support for __FILE_NAME__ macro (PR c/42579)

The toolchain provided by ST for stm32 has had support for
__FILENAME__ for a while, but clang/llvm has recently implemented
support for __FILE_NAME__, so it seems better to use the same macro
name in GCC.

It happens that the ST patch is similar to the one proposed in PR
c/42579.

Given these input files:
::::::::::::::
mydir/myinc.h
::::::::::::::
char* mystringh_file = __FILE__;
char* mystringh_filename = __FILE_NAME__;
char* mystringh_base_file = __BASE_FILE__;
::::::::::::::
mydir/mysrc.c
::::::::::::::

char* mystring_file = __FILE__;
char* mystring_filename = __FILE_NAME__;
char* mystring_base_file = __BASE_FILE__;

we produce:
$ gcc mydir/mysrc.c -I . -E
char* mystringh_file = "./mydir/myinc.h";
char* mystringh_filename = "myinc.h";
char* mystringh_base_file = "mydir/mysrc.c";

char* mystring_file = "mydir/mysrc.c";
char* mystring_filename = "mysrc.c";
char* mystring_base_file = "mydir/mysrc.c";

2021-05-20  Christophe Lyon  <christophe.lyon@linaro.org>
    Torbjörn Svensson  <torbjorn.svensson@st.com>

PR c/42579
libcpp/
* include/cpplib.h (cpp_builtin_type): Add BT_FILE_NAME entry.
* init.c (builtin_array): Likewise.
* macro.c (_cpp_builtin_macro_text): Add support for BT_FILE_NAME.

gcc/
* doc/cpp.texi (Common Predefined Macros): Document __FILE_NAME__.

gcc/testsuite/
* c-c++-common/spellcheck-reserved.c: Add tests for __FILE_NAME__.
* c-c++-common/cpp/file-name-1.c: New test.

3 years agoTestsuite/Fortran: gfortran.dg/pr96711.f90 - fix expected value for PowerPC [PR96983]
Tobias Burnus [Thu, 20 May 2021 07:51:10 +0000 (09:51 +0200)]
Testsuite/Fortran: gfortran.dg/pr96711.f90 - fix expected value for PowerPC [PR96983]

gcc/testsuite/ChangeLog:

PR fortran/96983
* gfortran.dg/pr96711.f90: Use 2**digit(x) instead of a hard-coded value;
add comments regarding what the code does.

3 years agoopenmp: Handle explicit linear clause properly in combined constructs with target...
Jakub Jelinek [Thu, 20 May 2021 07:17:40 +0000 (09:17 +0200)]
openmp: Handle explicit linear clause properly in combined constructs with target [PR99928]

linear clause should have the effect of firstprivate+lastprivate (or for IVs
not declared in the construct lastprivate) on outer constructs and eventually
map(tofrom:) on target when combined with it.

2021-05-20  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/99928
* gimplify.c (gimplify_scan_omp_clauses) <case OMP_CLAUSE_LINEAR>: For
explicit linear clause when combined with target, make it map(tofrom:)
instead of no clause or firstprivate.

* c-c++-common/gomp/pr99928-4.c: Remove all xfails.
* c-c++-common/gomp/pr99928-5.c: Likewise.

3 years agophiopt: Simplify (X & Y) == X -> (X & ~Y) == 0 even in presence of integral conversio...
Jakub Jelinek [Thu, 20 May 2021 07:10:38 +0000 (09:10 +0200)]
phiopt: Simplify (X & Y) == X -> (X & ~Y) == 0 even in presence of integral conversions [PR94589]

On Wed, May 19, 2021 at 10:15:53AM +0200, Christophe Lyon via Gcc-patches wrote:
> After this update, the test fails on arm and aarch64: according to the
> logs, the optimization is still performed 14 times.

Seems this is because
              if (change
                  && !flag_syntax_only
                  && (load_extend_op (TYPE_MODE (TREE_TYPE (and0)))
                      == ZERO_EXTEND))
                {
                  tree uns = unsigned_type_for (TREE_TYPE (and0));
                  and0 = fold_convert_loc (loc, uns, and0);
                  and1 = fold_convert_loc (loc, uns, and1);
                }
in fold-const.c adds on these targets extra casts that prevent the
optimizations.

2021-05-20  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94589
* match.pd ((X & Y) == X -> (X & ~Y) == 0): Simplify even in presence
of integral conversions.

3 years agolibcpp: Fix up -fdirectives-only handling of // comments on last line not terminated...
Jakub Jelinek [Thu, 20 May 2021 07:09:07 +0000 (09:09 +0200)]
libcpp: Fix up -fdirectives-only handling of // comments on last line not terminated with newline [PR100646]

As can be seen on the testcases, before the -fdirectives-only preprocessing
rewrite the preprocessor would assume // comments are terminated by the
end of file even when newline wasn't there, but now we error out.
The following patch restores the previous behavior.

2021-05-20  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/100646
* lex.c (cpp_directive_only_process): Treat end of file as termination
for !is_block comments.

* gcc.dg/cpp/pr100646-1.c: New test.
* gcc.dg/cpp/pr100646-2.c: New test.

3 years agoc++: _Complex template parameter [PR100634]
Jason Merrill [Wed, 19 May 2021 21:33:21 +0000 (17:33 -0400)]
c++: _Complex template parameter [PR100634]

We were crashing because invalid_nontype_parm_type_p allowed _Complex
template parms, but convert_nontype_argument didn't know what to do for
them.  Let's just disallow it, people can and should use std::complex
instead.

PR c++/100634

gcc/cp/ChangeLog:

* pt.c (invalid_nontype_parm_type_p): Return true for COMPLEX_TYPE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-complex1.C: New test.

3 years agoc++: ICE with using and enum [PR100659]
Jason Merrill [Wed, 19 May 2021 20:40:24 +0000 (16:40 -0400)]
c++: ICE with using and enum [PR100659]

Here the code for 'using enum' is confused by the combination of a
using-decl and an enum that are not from 'using enum'; this CONST_DECL is
from the normal unscoped enum scoping.

PR c++/100659

gcc/cp/ChangeLog:

* cp-tree.h (CONST_DECL_USING_P): Check for null TREE_TYPE.

gcc/testsuite/ChangeLog:

* g++.dg/parse/access13.C: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 20 May 2021 00:16:40 +0000 (00:16 +0000)]
Daily bump.

3 years agoPR c/100619 - ICE on a VLA parameter with too many dimensions
Martin Sebor [Wed, 19 May 2021 22:13:13 +0000 (16:13 -0600)]
PR c/100619 - ICE on a VLA parameter with too many dimensions

gcc/c-family/ChangeLog:

PR c/100619
* c-attribs.c (build_attr_access_from_parms): Handle arbitrarily many
bounds.

gcc/testsuite/ChangeLog:

PR c/100619
* gcc.dg/pr100619.c: New test.

3 years agoSplit gimple range folding with ranges into a stand alone class.
Andrew MacLeod [Wed, 19 May 2021 00:33:09 +0000 (20:33 -0400)]
Split gimple range folding with ranges into a stand alone class.

Introduces fold_using_range which folds any kind of gimple statement by
querying argument ranges thru a generic range_query.
This pulls all the statement processing into a client neutral location.

* gimple-range.cc (fur_source::get_operand): New.
(gimple_range_fold): Delete.
(fold_using_range::fold_stmt): Move from gimple_ranger::calc_stmt.
(fold_using_range::range_of_range_op): Move from gimple_ranger.
(fold_using_range::range_of_address): Ditto.
(fold_using_range::range_of_phi): Ditto.
(fold_using_range::range_of_call): Ditto.
(fold_using_range::range_of_builtin_ubsan_call): Move from
range_of_builtin_ubsan_call.
(fold_using_range::range_of_builtin_call): Move from
range_of_builtin_call.
(gimple_ranger::range_of_builtin_call): Delete.
(fold_using_range::range_of_cond_expr): Move from gimple_ranger.
(gimple_ranger::fold_range_internal): New.
(gimple_ranger::range_of_stmt): Use new fold_using_range API.
(fold_using_range::range_of_ssa_name_with_loop_info): Move from
gimple_ranger.  Improve ranges of SSA_NAMES when possible.
* gimple-range.h (gimple_ranger): Remove various range_of routines.
(class fur_source): New.
(class fold_using_range): New.
(fur_source::fur_source): New.
(fold_range): New.
* vr-values.c (vr_values::extract_range_basic): Use fold_using_range
instead of range_of_builtin_call.

3 years agoc++: ICE with <=> fallback [PR100367]
Jason Merrill [Tue, 18 May 2021 16:29:33 +0000 (12:29 -0400)]
c++: ICE with <=> fallback [PR100367]

Here, when genericizing lexicographical_compare_three_way, we haven't yet
walked the operands, so (a == a) still sees ADDR_EXPR <a>, but this is after
we've changed the type of a to REFERENCE_TYPE.  When we try to fold (a == a)
by constexpr evaluation, the constexpr code doesn't understand trying to
take the address of a reference, and we end up crashing.

Fixed by avoiding constexpr evaluation in genericize_spaceship, by using
fold_build2 instead of build_new_op on scalar operands.  Class operands
should have been expanded during parsing.

PR c++/100367
PR c++/96299

gcc/cp/ChangeLog:

* method.c (genericize_spaceship): Use fold_build2 for scalar
operands.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-fallback1.C: New test.

3 years agodoc: Update description of __GXX_EXPERIMENTAL_CXX0X__
Jonathan Wakely [Wed, 19 May 2021 10:11:11 +0000 (11:11 +0100)]
doc: Update description of __GXX_EXPERIMENTAL_CXX0X__

This macro has been obsolete for years, and C++0x features are no longer
experimental or liable to be removed.

gcc/ChangeLog:

* doc/cpp.texi (Common Predefined Macros): Update documentation
for the __GXX_EXPERIMENTAL_CXX0X__ macro.

3 years agoc++: implicit deduction guides, protected access
Jason Merrill [Tue, 18 May 2021 16:16:08 +0000 (12:16 -0400)]
c++: implicit deduction guides, protected access

Jonathan raised this issue with CWG, and there seems to be general agreement
that a deduction guide generated from a constructor should have access to
the same names that the constructor has access to.  That seems to be as easy
as setting DECL_CONTEXT.

gcc/cp/ChangeLog:

* pt.c (build_deduction_guide): Treat the implicit deduction guide
as a member of the class.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction-access1.C: New test.
* g++.dg/cpp1z/class-deduction-access2.C: New test.

3 years agoc++: Relax attribute on friend declaration checking [PR100596]
Marek Polacek [Tue, 18 May 2021 20:11:16 +0000 (16:11 -0400)]
c++: Relax attribute on friend declaration checking [PR100596]

It turned out that there are codebases that profusely use GNU attributes
on friend declarations, so we have to dial back our checking and allow
them.  And for C++11 attributes let's just warn instead of giving
errors.

PR c++/100596

gcc/cp/ChangeLog:

* cp-tree.h (any_non_type_attribute_p): Remove.
* decl.c (grokdeclarator): Turn an error into a warning and only
warn for standard attributes.
* decl2.c (any_non_type_attribute_p): Remove.
* parser.c (cp_parser_elaborated_type_specifier): Turn an error
into a warning and only warn for standard attributes.
(cp_parser_member_declaration): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/friend7.C: Turn a few dg-warnings into dg-errors.
Remove dg-errors for GNU attributes.
* g++.dg/ext/attrib63.C: Remove dg-error.
* g++.dg/cpp0x/friend8.C: New test.

3 years agotestuite: Check pthread for omp module testing
Kito Cheng [Wed, 19 May 2021 10:06:27 +0000 (18:06 +0800)]
testuite: Check pthread for omp module testing

gcc/testsuite/ChangeLog:

* g++.dg/modules/omp-1_a.C: Check pthread is available.
* g++.dg/modules/omp-1_b.C: Ditto.
* g++.dg/modules/omp-1_c.C: Ditto.
* g++.dg/modules/omp-2_a.C: Ditto.
* g++.dg/modules/omp-2_b.C: Ditto.

3 years agoarm: Fix ICE with CMSE nonsecure calls on Armv8.1-M [PR100333]
Alex Coplan [Wed, 19 May 2021 14:52:45 +0000 (15:52 +0100)]
arm: Fix ICE with CMSE nonsecure calls on Armv8.1-M [PR100333]

As the PR shows, we ICE shortly after expanding nonsecure calls for Armv8.1-M.
For Armv8.1-M, we have TARGET_HAVE_FPCXT_CMSE. As it stands, the expander
(arm.md:nonsecure_call_internal) moves the callee's address to a register (with
copy_to_suggested_reg) only if !TARGET_HAVE_FPCXT_CMSE.

However, looking at the pattern which the insn appears to be intended to
match (thumb2.md:*nonsecure_call_reg_thumb2_fpcxt), it requires the
callee's address to be in a register.

This patch therefore just forces the callee's address into a register in
the expander.

gcc/ChangeLog:

PR target/100333
* config/arm/arm.md (nonsecure_call_internal): Always ensure
callee's address is in a register.

gcc/testsuite/ChangeLog:

PR target/100333
* gcc.target/arm/cmse/pr100333.c: New test.

3 years agoarm/testsuite: Fix testcase for PR99977
Christophe Lyon [Wed, 19 May 2021 14:45:54 +0000 (14:45 +0000)]
arm/testsuite: Fix testcase for PR99977

Some targets (eg arm-none-uclinuxfdpiceabi) do not support Thumb-1,
and since the testcase forces -march=armv8-m.base, we need to check
whether this option is actually supported.

Using dg-add-options arm_arch_v8m_base ensure that we pass -mthumb as
needed too.

2021-05-19  Christophe Lyon  <christophe.lyon@linaro.org>

PR target/99977
gcc/testsuite/
* gcc.target/arm/pr99977.c: Require arm_arch_v8m_base.

3 years agoRISC-V: Properly parse the letter 'p' in '-march'.
Geng Qi [Tue, 18 May 2021 03:16:14 +0000 (11:16 +0800)]
RISC-V: Properly parse the letter 'p' in '-march'.

gcc/ChangeLog:
* common/config/riscv/riscv-common.c
(riscv_subset_list::parsing_subset_version): Properly parse the letter
'p' in '-march'.
(riscv_subset_list::parse_std_ext,
 riscv_subset_list::parse_multiletter_ext): To handle errors generated
in riscv_subset_list::parsing_subset_version.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/arch-12.c: New.
* gcc.target/riscv/attribute-19.c: New.

3 years agoaarch64: Use correct type attributes for RTL generating XTN(2)
Jonathan Wright [Tue, 18 May 2021 14:56:53 +0000 (15:56 +0100)]
aarch64: Use correct type attributes for RTL generating XTN(2)

Use the correct "neon_move_narrow_q" type attribute in RTL patterns
that generate XTN/XTN2 instructions.

This makes a material difference because these instructions can be
executed on both SIMD pipes in the Cortex-A57 core model, whereas the
"neon_shift_imm_narrow_q" attribute (in use until now) would suggest
to the scheduler that they could only execute on one of the two
pipes.

gcc/ChangeLog:

2021-05-18  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd.md: Use "neon_move_narrow_q"
type attribute in patterns generating XTN(2).

3 years agoaarch64: Use an expander for quad-word vec_pack_trunc pattern
Jonathan Wright [Sun, 16 May 2021 12:01:47 +0000 (13:01 +0100)]
aarch64: Use an expander for quad-word vec_pack_trunc pattern

The existing vec_pack_trunc RTL pattern emits an opaque two-
instruction assembly code sequence that prevents proper instruction
scheduling. This commit changes the pattern to an expander that emits
individual xtn and xtn2 instructions.

This commit also consolidates the duplicate truncation patterns.

gcc/ChangeLog:

2021-05-17  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd.md (aarch64_simd_vec_pack_trunc_<mode>):
Remove as duplicate of...
(aarch64_xtn<mode>): This.
(aarch64_xtn2<mode>_le): Move position in file.
(aarch64_xtn2<mode>_be): Move position in file.
(aarch64_xtn2<mode>): Move position in file.
(vec_pack_trunc_<mode>): Define as an expander.

3 years agotestsuite: aarch64: Add tests for high-half narrowing instructions
Jonathan Wright [Fri, 14 May 2021 13:20:05 +0000 (14:20 +0100)]
testsuite: aarch64: Add tests for high-half narrowing instructions

Add tests to confirm that a *2 (write to high-half) Neon instruction
is generated from vcombine* of a narrowing intrinsic sequence.

gcc/testsuite/ChangeLog:

2021-05-14  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/narrow_high_combine.c: New test.

3 years agoaarch64: Refactor aarch64_<sur>q<r>shr<u>n_n<mode> RTL pattern
Jonathan Wright [Fri, 14 May 2021 16:18:34 +0000 (17:18 +0100)]
aarch64: Refactor aarch64_<sur>q<r>shr<u>n_n<mode> RTL pattern

Split the aarch64_<sur>q<r>shr<u>n_n<mode> pattern into separate
scalar and vector variants. Further split the vector pattern into
big/little endian variants that model the zero-high-half semantics
of the underlying instruction - allowing for more combinations with
the write-to-high-half variant (aarch64_<sur>q<r>shr<u>n2_n<mode>.)

gcc/ChangeLog:

2021-05-14  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Split builtin
generation for aarch64_<sur>q<r>shr<u>n_n<mode> pattern into
separate scalar and vector generators.
* config/aarch64/aarch64-simd.md
(aarch64_<sur>q<r>shr<u>n_n<mode>): Define as an expander and
split into...
(aarch64_<sur>q<r>shr<u>n_n<mode>_insn_le): This and...
(aarch64_<sur>q<r>shr<u>n_n<mode>_insn_be): This.
* config/aarch64/iterators.md: Define SD_HSDI iterator.

3 years agoaarch64: Relax aarch64_sqxtun2<mode> RTL pattern
Jonathan Wright [Fri, 14 May 2021 13:49:47 +0000 (14:49 +0100)]
aarch64: Relax aarch64_sqxtun2<mode> RTL pattern

Use UNSPEC_SQXTUN instead of UNSPEC_SQXTUN2 in aarch64_sqxtun2<mode>
patterns. This allows for more more aggressive combinations and
ultimately better code generation. The now redundant UNSPEC_SQXTUN2
is removed.

gcc/ChangeLog:

2021-05-14  Jonathn Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd.md: Use UNSPEC_SQXTUN instead
of UNSPEC_SQXTUN2.
* config/aarch64/iterators.md: Remove UNSPEC_SQXTUN2.

3 years agoaarch64: Relax aarch64_<sur>q<r>shr<u>n2_n<mode> RTL pattern
Jonathan Wright [Thu, 4 Mar 2021 12:36:09 +0000 (12:36 +0000)]
aarch64: Relax aarch64_<sur>q<r>shr<u>n2_n<mode> RTL pattern

Implement saturating right-shift and narrow high Neon intrinsic RTL
patterns using a vec_concat of a register_operand and a VQSHRN_N
unspec - instead of just a VQSHRN_N unspec. This more relaxed pattern
allows for more aggressive combinations and ultimately better code
generation.

gcc/ChangeLog:

2021-03-04  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd.md (aarch64_<sur>q<r>shr<u>n2_n<mode>):
Implement as an expand emitting a big/little endian
instruction pattern.
(aarch64_<sur>q<r>shr<u>n2_n<mode>_insn_le): Define.
(aarch64_<sur>q<r>shr<u>n2_n<mode>_insn_be): Define.

3 years agoaarch64: Relax aarch64_<sur><addsub>hn2<mode> RTL pattern
Jonathan Wright [Wed, 3 Mar 2021 16:59:28 +0000 (16:59 +0000)]
aarch64: Relax aarch64_<sur><addsub>hn2<mode> RTL pattern

Implement v[r]addhn2 and v[r]subhn2 Neon intrinsic RTL patterns using
a vec_concat of a register_operand and an ADDSUBHN unspec - instead
of just an ADDSUBHN2 unspec. This more relaxed pattern allows for
more aggressive combinations and ultimately better code generation.

This patch also removes the now redundant [R]ADDHN2 and [R]SUBHN2
unspecs and their iterator.

gcc/ChangeLog:

2021-03-03  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd.md (aarch64_<sur><addsub>hn2<mode>):
Implement as an expand emitting a big/little endian
instruction pattern.
(aarch64_<sur><addsub>hn2<mode>_insn_le): Define.
(aarch64_<sur><addsub>hn2<mode>_insn_be): Define.
* config/aarch64/iterators.md: Remove UNSPEC_[R]ADDHN2 and
UNSPEC_[R]SUBHN2 unspecs and ADDSUBHN2 iterator.

3 years agomiddle-end/100672 - fix bogus right shift folding
Richard Biener [Wed, 19 May 2021 11:35:07 +0000 (13:35 +0200)]
middle-end/100672 - fix bogus right shift folding

This fixes the bogus use of TYPE_PRECISION on vector types
from optimizing -((int)x >> 31) into (unsigned)x >> 31.

2021-05-19  Richard Biener  <rguenther@suse.de>

PR middle-end/100672
* fold-const.c (fold_negate_expr_1): Use element_precision.
(negate_expr_p): Likewise.

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

3 years agoFix typos.
Martin Liska [Wed, 19 May 2021 13:25:36 +0000 (15:25 +0200)]
Fix typos.

PR testsuite/100658

gcc/cp/ChangeLog:

* mangle.c (write_encoding): Fix typos.

gcc/jit/ChangeLog:

* libgccjit.c (gcc_jit_context_new_function): Fix typos.

gcc/testsuite/ChangeLog:

* gcc.dg/local1.c: Fix typos.
* gcc.dg/ucnid-5-utf8.c: Likewise.
* gcc.dg/ucnid-5.c: Likewise.

3 years agoaarch64: Enable aarch64_load to use UNSPEC_PRED_X loads
Andre Simoes Dias Vieira [Mon, 17 May 2021 14:43:53 +0000 (15:43 +0100)]
aarch64: Enable aarch64_load to use UNSPEC_PRED_X loads

This patch will enable the use of loads using the UNSPEC_PRED_X enum in the
aarch64_load pattern, thus enabling combine to combine such loads with extends.

gcc/ChangeLog:
2021-05-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* config/aarch64/iterators.md (SVE_PRED_LOAD): New iterator.
(pred_load): New int attribute.
* config/aarch64/aarch64-sve.md
(aarch64_load_<ANY_EXTEND:optab><SVE_HSDI:mode><SVE_PARTIAL_I:mode>): Use
SVE_PRED_LOAD enum iterator and corresponding pred_load attribute.
* config/aarch64/aarch64-sve-builtins-base.cc (expand): Update call to
code_for_aarch64_load.

gcc/testsuite/ChangeLog:
2021-05-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* gcc.target/aarch64/sve/logical_unpacked_and_2.c: Change
scan-assembly-times to scan-assembly not for superfluous uxtb.
* gcc.target/aarch64/sve/logical_unpacked_and_3.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_and_4.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_and_6.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_and_7.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_eor_2.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_eor_3.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_eor_4.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_eor_6.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_eor_7.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_orr_2.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_orr_3.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_orr_4.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_orr_6.c: Likewise.
* gcc.target/aarch64/sve/logical_unpacked_orr_7.c: Likewise.
* gcc.target/aarch64/sve/ld1_extend.c: New test.

3 years agoAvoid marking TARGET_MEM_REF bases addressable
Richard Biener [Wed, 19 May 2021 10:36:19 +0000 (12:36 +0200)]
Avoid marking TARGET_MEM_REF bases addressable

The following does no longer mark TARGET_MEM_REF bases addressable,
mimicing MEM_REFs beahvior here.  In contrast to the latter,
TARGET_MEM_REF RTL expansion expects to always operate on memory
though, so make sure we expand them so.

2021-05-19  Richard Biener  <rguenther@suse.de>

* cfgexpand.c (discover_nonconstant_array_refs_r): Make
sure TARGET_MEM_REF bases are expanded as memory.
* tree-ssa-operands.c (operands_scanner::get_tmr_operands):
Do not mark TARGET_MEM_REF bases addressable.
* tree-ssa.c (non_rewritable_mem_ref_base): Handle
TARGET_MEM_REF bases as never rewritable.
* gimple-walk.c (walk_stmt_load_store_addr_ops): Do not
walk TARGET_MEM_REF bases as address-takens.
* tree-ssa-dce.c (ref_may_be_aliased): Handle TARGET_MEM_REF.

3 years agoEnable more WITH_SIZE_EXPR processing
Richard Biener [Wed, 19 May 2021 08:20:37 +0000 (10:20 +0200)]
Enable more WITH_SIZE_EXPR processing

This enables the alias machinery for WITH_SIZE_EXPR which can appear
in call LHS and arguments.  In particular this drops the NULL
return from get_base_address and it adjusts get_ref_base_and_extent
and friends to use the size information in WITH_SIZE_EXPR and
look through it for further processing.

2021-05-19  Richard Biener  <rguenther@suse.de>

* builtins.c (get_object_alignment_1): Strip outer
WITH_SIZE_EXPR.
* tree-dfa.c (get_ref_base_and_extent): Handle outer
WITH_SIZE_EXPR for size processing and process the
containing ref.
* tree-ssa-alias.c (ao_ref_base_alias_set): Strip
outer WITH_SIZE_EXPR.
(ao_ref_base_alias_ptr_type): Likewise.
(refs_may_alias_p_2): Allow WITH_SIZE_EXPR in ref->ref
and handle that accordingly, stripping it for the
core alias workers.
* tree.c (get_base_address): Handle WITH_SIZE_EXPR by
looking through it instead of returning NULL.

3 years agoAdd 'libgomp.oacc-c-c++-common/private-atomic-1.c' [PR83812]
Thomas Schwinge [Wed, 19 May 2021 09:58:49 +0000 (11:58 +0200)]
Add 'libgomp.oacc-c-c++-common/private-atomic-1.c' [PR83812]

... to at least document/test/XFAIL nvptx offloading: PR83812 "operation not
supported on global/shared address space".

libgomp/
PR target/83812
* testsuite/libgomp.oacc-c-c++-common/private-atomic-1.c: New.

3 years agoAdd 'libgomp.oacc-c-c++-common/loop-gwv-2.c'
Julian Brown [Mon, 13 Aug 2018 20:41:50 +0000 (21:41 +0100)]
Add 'libgomp.oacc-c-c++-common/loop-gwv-2.c'

libgomp/
* testsuite/libgomp.oacc-c-c++-common/loop-gwv-2.c: New.

3 years agobuiltins: Fix ICE with unprototyped builtin call [PR100576]
Jakub Jelinek [Wed, 19 May 2021 10:05:30 +0000 (12:05 +0200)]
builtins: Fix ICE with unprototyped builtin call [PR100576]

For unprototyped builtins the checking we perform is only about whether
the used argument is integral, pointer etc., not the exact precision.
We emit a warning about the problem though:
pr100576.c: In function ‘foo’:
pr100576.c:9:11: warning: implicit declaration of function ‘memcmp’ [-Wimplicit-function-declaration]
    9 |   int n = memcmp (p, v, b);
      |           ^~~~~~
pr100576.c:1:1: note: include ‘<string.h>’ or provide a declaration of ‘memcmp’
  +++ |+#include <string.h>
    1 | /* PR middle-end/100576 */
pr100576.c:9:25: warning: ‘memcmp’ argument 3 type is ‘int’ where ‘long unsigned int’ is expected in a call to built-in function declared without prototype
+[-Wbuiltin-declaration-mismatch]
    9 |   int n = memcmp (p, v, b);
      |                         ^
It means in the testcase below where the user incorrectly called memcmp
with last argument int rather then size_t, the warning stuff in builtins.c
ICEs because it compares a wide_int from such a bound with another wide_int
which has precision of size_t/sizetype and wide_int asserts the compared
wide_ints are compatible.

Fixed by forcing the bound to have the right type.

2021-05-19  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/100576
* builtins.c (check_read_access): Convert bound to size_type_node if
non-NULL.

* gcc.c-torture/compile/pr100576.c: New test.

3 years agoapply TLC to GIMPLE reference verification
Richard Biener [Tue, 18 May 2021 11:57:06 +0000 (13:57 +0200)]
apply TLC to GIMPLE reference verification

This inlines verify_types_in_gimple_min_lval and makes sure we
also verify call lhs and arguments.  It also asserts that
WITH_SIZE_EXPR in plain assignments does not happen, instead
those should have become memcpy/memset.

2021-05-18  Richard Biener  <rguenther@suse.de>

* tree-cfg.c (verify_types_in_gimple_min_lval): Inline...
(verify_types_in_gimple_reference): ... here.  Sanitize.
(verify_gimple_call): Verify references in LHS and arguments.
(verify_gimple_assign_single): Reject WITH_SIZE_EXPR.

3 years agoi386: Allow 64bit vector modes in general registers
Uros Bizjak [Wed, 19 May 2021 07:57:29 +0000 (09:57 +0200)]
i386: Allow 64bit vector modes in general registers

Allow V8QI, V4HI and V2SI modes in 64bit general registers for
TARGET_64BIT and add alternatives using general registers
to 64bit vector logic instructions.

2021-05-19  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
* config/i386/i386.h (VALID_INT_MODE_P):
Add V8QI, V4HI and V2SI modes for TARGET_64BIT.
* config/i386/i386.md (isa): Add x64_bmi.
(enabled): Handle x64_bmi.
* config/i386/mmx.md (mmx_andnot<MMXMODEI:mode>3):
Add alternative using 64bit general registers.
(*mmx_<any_logic:code><MMXMODEI:mode>3): Ditto.

3 years agoFix commit mistake in testcase gcc.dg/tree-ssa/ssa-sink-3.c
Bernd Edlinger [Wed, 19 May 2021 07:51:44 +0000 (09:51 +0200)]
Fix commit mistake in testcase gcc.dg/tree-ssa/ssa-sink-3.c

the test case was accidenally changed to empty file.

2021-05-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* gcc.dg/tree-ssa/ssa-sink-3.c: Fix test case.

3 years agoopenmp: Handle lastprivate on combined target correctly [PR99928]
Jakub Jelinek [Wed, 19 May 2021 07:21:09 +0000 (09:21 +0200)]
openmp: Handle lastprivate on combined target correctly [PR99928]

This patch deals with 2 issues:
1) the gimplifier couldn't differentiate between
 #pragma omp parallel master
 #pragma omp taskloop simd
and
 #pragma omp parallel master taskloop simd
when there is a significant difference for clause handling between
the two; as master construct doesn't have any clauses, we don't currently
represent it during gimplification by an gimplification omp context at all,
so this patch makes sure we don't set OMP_PARALLEL_COMBINED on parallel master
when not combined further.  If we ever add a separate master context during
gimplification, we'd use ORT_COMBINED_MASTER vs. ORT_MASTER (or MASKED probably).
2) lastprivate when combined with target should be map(tofrom:) on the target,
this change handles it only when not combined with firstprivate though, that
will need further work (similarly to linear or reduction).

2021-05-19  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/99928
gcc/
* tree.h (OMP_MASTER_COMBINED): Define.
* gimplify.c (gimplify_scan_omp_clauses): Rewrite lastprivate
handling for outer combined/composite constructs to a loop.
Handle lastprivate on combined target.
(gimplify_expr): Formatting fix.
gcc/c/
* c-parser.c (c_parser_omp_master): Set OMP_MASTER_COMBINED on
master when combined with taskloop.
(c_parser_omp_parallel): Don't set OMP_PARALLEL_COMBINED on
parallel master when not combined with taskloop.
gcc/cp/
* parser.c (cp_parser_omp_master): Set OMP_MASTER_COMBINED on
master when combined with taskloop.
(cp_parser_omp_parallel): Don't set OMP_PARALLEL_COMBINED on
parallel master when not combined with taskloop.
gcc/testsuite/
* c-c++-common/gomp/pr99928-2.c: Remove all xfails.
* c-c++-common/gomp/pr99928-12.c: New test.

3 years agogcc/go/ChangeLog: remove entry for reverted change
Ian Lance Taylor [Wed, 19 May 2021 03:08:22 +0000 (20:08 -0700)]
gcc/go/ChangeLog: remove entry for reverted change

3 years agogofrontend: revert startswith change
Ian Lance Taylor [Wed, 19 May 2021 03:07:29 +0000 (20:07 -0700)]
gofrontend: revert startswith change

This file is copied from a different repo and should not be changed
directly in the GCC repo.

3 years agolibgo: update configure to current sources
Ian Lance Taylor [Wed, 19 May 2021 01:09:27 +0000 (18:09 -0700)]
libgo: update configure to current sources

Change-Id: I12766baf02bfdf2233f1c5bde1a270f06b020aa7
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/321076
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agolibgo: update bzip2 binary test cases to match source repo
Ian Lance Taylor [Wed, 19 May 2021 01:32:14 +0000 (18:32 -0700)]
libgo: update bzip2 binary test cases to match source repo

3 years agoRun pass_sink_code once more before store_merging
Xionghu Luo [Wed, 19 May 2021 02:34:18 +0000 (21:34 -0500)]
Run pass_sink_code once more before store_merging

Gimple sink code pass runs quite early, there may be some new
oppertunities exposed by later gimple optmization passes, this patch
runs the sink code pass once more before store_merging.  For detailed
discussion, please refer to:
https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562352.html

Tested the SPEC2017 performance on P8LE, 544.nab_r is improved
by 2.43%, but no big changes to other cases, GEOMEAN is improved quite
small with 0.25%.

gcc/ChangeLog:

2021-05-18  Xionghu Luo  <luoxhu@linux.ibm.com>

* passes.def: Add sink_code pass before store_merging.
* tree-ssa-sink.c (pass_sink_code:clone): New.

gcc/testsuite/ChangeLog:

2021-05-18  Xionghu Luo  <luoxhu@linux.ibm.com>

* gcc.dg/tree-ssa/ssa-sink-1.c: Adjust.
* gcc.dg/tree-ssa/ssa-sink-2.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-3.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-4.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-5.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-6.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-7.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-8.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-9.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-10.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-13.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-14.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-16.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-17.c: Ditto.
* gcc.dg/tree-ssa/ssa-sink-18.c: New.

3 years agolibgo: use Windows line endings in testwinsignal
Ian Lance Taylor [Wed, 19 May 2021 01:28:17 +0000 (18:28 -0700)]
libgo: use Windows line endings in testwinsignal

3 years agoc++: ICE with bad definition of decimal32 [PR100261]
Jason Merrill [Tue, 18 May 2021 21:15:42 +0000 (17:15 -0400)]
c++: ICE with bad definition of decimal32 [PR100261]

The change to only look at the global binding for non-classes meant that
here, when dealing with decimal32 which is magically mangled like its first
non-static data member, we got a collision with the mangling for float.
Fixed by also looking up an existing binding for such magical classes.

PR c++/100261

gcc/cp/ChangeLog:

* rtti.c (get_tinfo_decl_direct): Check TYPE_TRANSPARENT_AGGR.

gcc/testsuite/ChangeLog:

* g++.dg/dfp/mangle-6.C: New test.

3 years agoc++: template template parm pack expansion [PR100372]
Jason Merrill [Tue, 18 May 2021 21:12:37 +0000 (17:12 -0400)]
c++: template template parm pack expansion [PR100372]

Here we have a pack expansion of a template template parameter pack, of
which the pattern is a TEMPLATE_DECL, which strip_typedefs doesn't want to
see.

PR c++/100372

gcc/cp/ChangeLog:

* tree.c (strip_typedefs): Only look at the pattern of a
TYPE_PACK_EXPANSION if it's a type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-ttp1.C: New test.

3 years agoDaily bump.
GCC Administrator [Wed, 19 May 2021 00:16:45 +0000 (00:16 +0000)]
Daily bump.

3 years agosim: depend on gnulib
Mike Frysinger [Sat, 8 May 2021 02:30:30 +0000 (22:30 -0400)]
sim: depend on gnulib

We're going to start using gnulib in the sim, so make sure it exists.

ChangeLog:

* Makefile.def: Add configure-sim dependency on all-gnulib.
* Makefile.in: Regenerated.

3 years agors6000: Remove old psabi warnings
Bill Schmidt [Tue, 18 May 2021 14:04:39 +0000 (09:04 -0500)]
rs6000: Remove old psabi warnings

Long ago we were forced to make some small ABI breaks to correct errors
in the implementation, and we added warning messages for the changes
from GCC 4.9 to GCC 5.  Enough time has passed that these are now just
irritants, so let's remove them.  Also clean up associated macros using
rs6000_special_adjust_field_align_p, which has been always returning
false for a long time.

2021-05-18  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/freebsd64.h (ADJUST_FIELD_ALIGN): Remove call to
rs6000_special_adjust_field_align_p.
* config/rs6000/linux64.h (ADJUST_FIELD_ALIGN): Likewise.
* config/rs6000/rs6000-call.c (rs6000_function_arg_boundary):
Remove ABI warning.
(rs6000_function_arg): Likewise.
* config/rs6000/rs6000-protos.h
(rs6000_special_adjust_field_align_p): Remove prototype.
* config/rs6000/rs6000.c (rs6000_special_adjust_field_align_p):
Remove.
* config/rs6000/sysv4.h (ADJUST_FIELD_ALIGN): Remove call to
rs6000_special_adjust_field_align_p.

gcc/testsuite/
* gcc.target/powerpc/ppc64-abi-warn-1.c: Remove.
* gcc.target/powerpc/ppc64-abi-warn-2.c: Remove.
* gcc.target/powerpc/ppc64-abi-warn-3.c: Remove.

3 years agod: Use filename_ncmp instead of strncmp
Iain Buclaw [Tue, 18 May 2021 20:57:23 +0000 (22:57 +0200)]
d: Use filename_ncmp instead of strncmp

gcc/d/ChangeLog:

* d-incpath.cc (prefixed_path): Use filename_ncmp instead of strncmp.

3 years agod: Use startswith function instead of strncmp
Iain Buclaw [Tue, 18 May 2021 20:56:10 +0000 (22:56 +0200)]
d: Use startswith function instead of strncmp

gcc/d/ChangeLog:

* types.cc (TypeVisitor::visit (TypeEnum *)): Use startswith function
instead of strncmp.

3 years agod: Revert "Come up with startswith function."
Iain Buclaw [Tue, 18 May 2021 17:05:20 +0000 (19:05 +0200)]
d: Revert "Come up with startswith function."

This reverts changes to the DMD front-end in commit
6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b.

Changes were incorrectly committed directly to the GCC repo instead of
the master repository.

gcc/d/ChangeLog:

* dmd/dinterpret.c (evaluateIfBuiltin): Revert last change.
* dmd/dmangle.c: Likewise.
* dmd/hdrgen.c: Likewise.
* dmd/identifier.c (Identifier::toHChars2): Likewise.

3 years agoc++: Prune dead functions.
Marek Polacek [Thu, 11 Mar 2021 19:01:52 +0000 (14:01 -0500)]
c++: Prune dead functions.

I was looking at the LCOV coverage report for the C++ FE and
found a bunch of unused functions that I think we can remove.
Obviously, I left alone various dump_* and debug_* routines.
I haven't removed cp_build_function_call although it is also
currently unused.

* lambda_return_type: was used in parser.c in GCC 7, unused since r255950,
* classtype_has_non_deleted_copy_ctor: appeared in GCC 10, its usage
  was removed in c++/95350,
* contains_wildcard_p: used in GCC 9, unused since r276764,
* get_template_head_requirements: seems to never have been used,
* check_constrained_friend: seems to never have been used,
* subsumes_constraints: unused since r276764,
* push_void_library_fn: usage removed in r248328,
* get_template_parms_at_level: unused since r157857,
* get_pattern_parm: unused since r275387.

(Some of the seemingly unused functions, such as set_global_friend, are
actually used in libcc1.)

gcc/cp/ChangeLog:

* class.c (classtype_has_non_deleted_copy_ctor): Remove.
* constraint.cc (contains_wildcard_p): Likewise.
(get_template_head_requirements): Likewise.
(check_constrained_friend): Likewise.
(subsumes_constraints): Likewise.
* cp-tree.h (classtype_has_non_deleted_copy_ctor): Likewise.
(push_void_library_fn): Likewise.
(get_pattern_parm): Likewise.
(get_template_parms_at_level): Likewise.
(lambda_return_type): Likewise.
(get_template_head_requirements): Likewise.
(check_constrained_friend): Likewise.
(subsumes_constraints): Likewise.
* decl.c (push_void_library_fn): Likewise.
* lambda.c (lambda_return_type): Likewise.
* pt.c (get_template_parms_at_level): Likewise.
(get_pattern_parm): Likewise.