Jakub Jelinek [Tue, 24 Nov 2020 09:45:40 +0000 (10:45 +0100)]
i386: Add *setcc_hi_1* define_insn_and_split [PR97950]
As the following testcase shows, unlike char, int or long long sized
__builtin_*_overflow{,_p}, for short sized one in most cases the ce1 pass
doesn't optimize the jo/jno or jc/jnc jumps with setting of a pseudo to 0/1
into seto/setc. The reason is missing *setcc_hi_1* pattern. The following
patch implements it using mode iterators so that on i486 and pentium?
one can get the zero extension through and instead of movzbw.
2020-11-24 Jakub Jelinek <jakub@redhat.com>
PR target/97950
* config/i386/i386.md (*setcc_si_1_and): Macroize into...
(*setcc_<mode>_1_and): New define_insn_and_split with SWI24 iterator.
(*setcc_si_1_movzbl): Macroize into...
(*setcc_<mode>_1_movzbl): New define_insn_and_split with SWI24
iterator.
* gcc.target/i386/pr97950.c: New test.
Jakub Jelinek [Tue, 24 Nov 2020 09:44:32 +0000 (10:44 +0100)]
middle-end: Prefer no RMW in __builtin_clear_padding implementation where possible
Currently the __builtin_clear_padding expansion code emits no code for
full words that don't have any padding bits, and most of the time if
the only padding bytes are from the start of the word it attempts to merge
them with previous padding store (via {}) or if the only padding bytes are
from the end of the word, it attempts to merge it with following padding
bytes. For everything else it was using a RMW, except when it found
an aligned char/short/int covering all the padding bytes and all those
padding bytes were all ones in that store.
The following patch changes it, such that we only use RMW if the padding has
any bytes which have some padding and some non-padding bits (i.e. bitfields
are involved), often it is the same amount of instructions in the end and
avoids being thread-unsafe unless necessary (and avoids having to wait for
the reads to make it into the CPU). So, if there are no bitfields,
the function will just store some zero bytes, shorts, ints, long longs etc.
where needed.
2020-11-24 Jakub Jelinek <jakub@redhat.com>
* gimple-fold.c (clear_padding_flush): If a word contains only 0
or 0xff bytes of padding other than all set, all clear, all set
followed by all clear or all clear followed by all set, don't emit
a RMW operation on the whole word or parts of it, but instead
clear the individual bytes of padding. For paddings of one byte
size, don't use char[1] and {}, but instead just char and 0.
Jakub Jelinek [Tue, 24 Nov 2020 09:42:56 +0000 (10:42 +0100)]
testsuite: Add testcase for already fixed bug [PR97964]
This testcase started failing with r8-2090 and works again starting
with r11-4755.
2020-11-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/97964
* gcc.dg/tree-ssa/pr97964.c: New test.
Thomas Schwinge [Fri, 20 Nov 2020 09:41:46 +0000 (10:41 +0100)]
More explicit checking of which OMP constructs we're expecting, part II
In particular, more precisely highlight what applies generally vs. the special
handling for the current 'parloops'-based OpenACC 'kernels' implementation.
gcc/
* omp-expand.c (expand_oacc_for): More explicit checking of which
OMP constructs we're expecting.
Thomas Schwinge [Mon, 16 Nov 2020 16:37:06 +0000 (17:37 +0100)]
[testsuite] Avoid Tcl 8.5-specific behavior
gcc/
* doc/install.texi (Prerequisites) <Tcl>: Add comment.
gcc/testsuite/
* c-c++-common/goacc/kernels-decompose-1.c: Avoid Tcl 8.5-specific
behavior.
* c-c++-common/goacc/kernels-decompose-2.c: Likewise.
* gfortran.dg/goacc/kernels-decompose-1.f95: Likewise.
* gfortran.dg/goacc/kernels-decompose-2.f95: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c: Avoid
Tcl 8.5-specific behavior.
* testsuite/libgomp.oacc-fortran/pr94358-1.f90: Likewise.
Reported-by: David Edelsohn <dje.gcc@gmail.com>
Thomas Schwinge [Fri, 6 Nov 2020 08:51:16 +0000 (09:51 +0100)]
[testsuite] Emit 'warning' instead of 'error' diagnostics for 'dg-optimized', 'dg-missed'
The diagnostics produced by 'dg-optimized', 'dg-missed' aren't error
diagnostics (fatal, meaning: causes compilation to fail) but rather warning
diagnostics (non-fatal, doesn't cause compilation to fail). Thus, same as
'dg-message', these should use 'saved-dg-warning' instead of 'saved-dg-error',
which then prints: "(test for *warnings*, line [...]) instead of currently:
"(test for *errors*, line [...])".
This is a small bug-fix for commit
ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.
gcc/testsuite/
* lib/gcc-dg.exp (dg-optimized, dg-missed): Use 'saved-dg-warning'
instead of 'saved-dg-error'.
Thomas Schwinge [Fri, 6 Nov 2020 08:18:06 +0000 (09:18 +0100)]
[testsuite] Enable column location checking for 'dg-optimized', 'dg-missed'
'process-message' would like the 'msgprefix' argument without trailing space.
This is a small bug-fix for commit
ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.
gcc/testsuite/
* lib/gcc-dg.exp (dg-optimized, dg-missed): Fix 'process-message'
call.
* gcc.dg/vect/nodump-vect-opt-info-1.c: Demonstrate.
* gcc.dg/vect/nodump-vect-opt-info-2.c: Likewise.
Jakub Jelinek [Tue, 24 Nov 2020 08:04:28 +0000 (09:04 +0100)]
openmp: Fix C ICE on OpenMP atomics
c_parser_binary_expression was using build2 to create a temporary holder
for binary expression that c_parser_atomic and c_finish_omp_atomic can then
handle. The latter performs then all the needed checking.
Unfortunately, build2 performs some checking too, e.g. PLUS_EXPR vs.
POINTER_PLUS_EXPR or matching types of the arguments, nothing we can guarantee
at the parsing time. So we need something like C++ build_min_nt*. This
patch implements that inline.
2020-11-24 Jakub Jelinek <jakub@redhat.com>
PR c/97958
* c-parser.c (c_parser_binary_expression): For omp atomic binary
expressions, use make_node instead of build2 to avoid checking build2
performs.
* c-c++-common/gomp/pr97958.c: New test.
Jakub Jelinek [Tue, 24 Nov 2020 08:03:17 +0000 (09:03 +0100)]
middle-end, c++: Treat shifts by negative as undefined [PR96929]
The PR38359 change made the -1 >> x to -1 optimization less useful by
requiring that the x must be non-negative.
Shifts by negative amount are UB, but we for historic reasons had in some
(but not all) places some hack to treat shifts by negative value as the
other direction shifts by the negated amount.
The following patch just removes that special handling, instead we punt on
optimizing those (and ideally path isolation should catch that up and turn
those into __builtin_unreachable, perhaps with __builtin_warning next to
it). Folding the shifts in some places as if they were rotates and in other
as if they were saturating just leads to inconsistencies.
For C++ constexpr diagnostics and -fpermissive, I've added code to pretend
fold-const.c has not changed, without -fpermissive it will be an error
anyway and I think it is better not to change all the diagnostics.
During x86_64-linux and i686-linux bootstrap/regtest, my statistics
gathering patch noted 185 unique -m32/-m64 x TU x function_name x shift_kind
x fold-const/tree-ssa-ccp cases. I have investigated the
64 ../../gcc/config/i386/i386.c x86_output_aligned_bss LSHIFT_EXPR wide_int_bitop
64 ../../gcc/config/i386/i386-expand.c emit_memmov LSHIFT_EXPR wide_int_bitop
64 ../../gcc/config/i386/i386-expand.c ix86_expand_carry_flag_compare LSHIFT_EXPR wide_int_bitop
64 ../../gcc/expmed.c expand_divmod LSHIFT_EXPR wide_int_bitop
64 ../../gcc/lra-lives.c process_bb_lives LSHIFT_EXPR wide_int_bitop
64 ../../gcc/rtlanal.c nonzero_bits1 LSHIFT_EXPR wide_int_bitop
64 ../../gcc/varasm.c optimize_constant_pool.isra LSHIFT_EXPR wide_int_bitop
cases and all of them are either during jump threading (dom) or during PRE.
For jump threading, the most common case is 1 << floor_log2 (whatever) where
floor_log2 is return HOST_BITS_PER_WIDE_INT - 1 - clz_hwi (x);
and clz_hwi is if (x == 0) return HOST_BITS_PER_WIDE_INT; return __builtin_clz* (x);
and so has range [-1, 63] and a comparison against == 0 which makes the
threader think it might be nice to jump thread the case leading to 1 << -1.
I think it is better to keep the 1 << -1 s in the IL for this and let path
isolation turn that into __builtin_unreachable () if the user wishes so.
2020-11-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96929
* fold-const.c (wide_int_binop) <case LSHIFT_EXPR, case RSHIFT_EXPR>:
Return false on negative second argument rather than trying to handle
it as shift in the other direction.
* tree-ssa-ccp.c (bit_value_binop) <case LSHIFT_EXPR,
case RSHIFT_EXPR>: Punt on negative shift count rather than trying
to handle it as shift in the other direction.
* match.pd (-1 >> x to -1): Remove tree_expr_nonnegative_p check.
* constexpr.c (cxx_eval_binary_expression): For shifts by constant
with MSB set, emulate older wide_int_binop behavior to preserve
diagnostics and -fpermissive behavior.
* gcc.dg/tree-ssa/pr96929.c: New test.
Jeff Law [Tue, 24 Nov 2020 04:34:24 +0000 (21:34 -0700)]
Fix expected output after recent changes
gcc/testsuite
* gcc.dg/tree-ssa/pr23401.c: Update expected output.
* gcc.dg/tree-ssa/pr27810.c: Update expected output.
* gcc.dg/tree-ssa/slsr-8.c: Update expected output.
Kewen Lin [Tue, 24 Nov 2020 02:33:17 +0000 (20:33 -0600)]
test: Update some cases for vect_partial_vectors_usage_1
Commit r11-3393 improved the epilogue loop handling of partial
vectors and we won't use partial vectors to vectorize a single
iteration scalar loop any more.
The affected test cases have only one single iteration in their
epilogues, so we shouldn't expect the vectorization with
partial vector there.
Tested with explicit --param=vect-partial-vector-usage=1 and
default enablement.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/slp-perm-1.c: Adjust for partial vectors.
* gcc.dg/vect/slp-perm-5.c: Likewise.
* gcc.dg/vect/slp-perm-6.c: Likewise.
* gcc.dg/vect/slp-perm-7.c: Likewise.
Prathamesh Kulkarni [Tue, 24 Nov 2020 01:20:53 +0000 (06:50 +0530)]
tree-opt: Fix segfault in tree-if-conv.c with -march=armv8.2-a+sve [PR97849]
The issue here is that rpo vn may eliminate target ssa_name referred to in
redundant_ssa_names, and thus ifcvt_local_dce may replace candidate
ssa_name with invalid ssa_name resulting in incorrect IR. The patch simply
does ssa_name replacement before calling do_rpo_vn, which fixes the issue.
gcc/
2020-11-24 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/97849
* tree-if-conv.c (tree_if_conversion): Move ssa_name
replacement code from ifcvt_local_dce to this function
before calling do_rpo_vn.
gcc/testsuite/
2020-11-24 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/97849
* gcc.dg/tree-ssa/pr97849.c: New test.
Martin Sebor [Tue, 24 Nov 2020 00:15:54 +0000 (17:15 -0700)]
Dump type attributes in dump_function_to_file.
gcc/ChangeLog:
* tree-cfg.c (dump_function_to_file): Print type attributes
and return type.
gcc/testsuite/ChangeLog:
* gcc.dg/attr-access-5.c: New test.
GCC Administrator [Tue, 24 Nov 2020 00:16:44 +0000 (00:16 +0000)]
Daily bump.
Joseph Myers [Mon, 23 Nov 2020 23:28:58 +0000 (23:28 +0000)]
c: Allow comparison of pointers to complete and incomplete types for C11 [PR95630]
As noted in bug 95630, C11 removed a restriction in C99 on comparing
pointers to compatible complete and incomplete types (this was one of
the changes in N1439, which was largely a terminological change to
make incomplete types a subset of object types rather than a different
kind of type). Implement that change by using pedwarn_c99 with
OPT_Wpedantic for this diagnostic.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/c/
2020-11-23 Joseph Myers <joseph@codesourcery.com>
PR c/95630
* c-typeck.c (build_binary_op): Use pedwarn_c99 with OPT_Wpedantic
for comparisons of complete and incomplete pointers.
gcc/testsuite/
2020-11-23 Joseph Myers <joseph@codesourcery.com>
PR c/95630
* gcc.dg/c11-compare-incomplete-1.c,
gcc.dg/c11-compare-incomplete-2.c,
gcc.dg/c99-compare-incomplete-1.c,
gcc.dg/c99-compare-incomplete-2.c: New tests.
Martin Jambor [Tue, 16 Jun 2020 17:26:32 +0000 (19:26 +0200)]
ipa: special pass-through op for Fortran strides
when Fortran functions pass array descriptors they receive as a
parameter to another function, they actually rebuild it. Thanks to
work done mainly by Feng, IPA-CP can already handle the cases when
they pass directly the values loaded from the original descriptor.
Unfortunately, perhaps the most important one, stride, is first
checked against zero and is replaced with one in that case:
_12 = *a_11(D).dim[0].stride;
if (_12 != 0)
goto <bb 4>; [50.00%]
else
goto <bb 3>; [50.00%]
<bb 3>
// empty BB
<bb 4>
# iftmp.22_9 = PHI <_12(2), 1(3)>
...
parm.6.dim[0].stride = iftmp.22_9;
...
__x_MOD_foo (&parm.6, b_31(D));
in the most important and hopefully common cases, the incoming value
is already 1 and we fail to propagate it.
I would therefore like to propose the following way of encoding this
situation in pass-through jump functions using using ASSERTT_EXPR
operation code meaning that if the incoming value is the same as the
"operand" in the jump function, it is passed on, otherwise the result
is unknown. This of course captures only the single (but most
important) case but is an improvement and does not need enlarging the
jump function structure and is simple to pattern match. Encoding that
zero needs to be changed to one would need another field and matching
it would be slightly more complicated too.
gcc/
2020-06-12 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (ipa_pass_through_data): Expand comment describing
operation.
* ipa-prop.c (analyze_agg_content_value): Detect new special case and
encode it as ASSERT_EXPR.
* ipa-cp.c (values_equal_for_ipcp_p): Move before
ipa_get_jf_arith_result.
(ipa_get_jf_arith_result): Special case ASSERT_EXPR.
gcc/testsuite/
2020-06-12 Martin Jambor <mjambor@suse.cz>
* gfortran.dg/ipcp-array-2.f90: New test.
Jeff Law [Mon, 23 Nov 2020 20:06:11 +0000 (13:06 -0700)]
Adjust rtx_costs for h8300
So the primary purpose of this patch is to make it easier to write tests for
removal of useless test/compare insns on the H8.
In simplest terms the costing model in the H8 port tends to encourage changing
something like:
x = y + 4;
if (x == 0)
into:
x = y + 4;
if (y == -4)
This is a marginal de-optimization on the H8. So fixing it makes the code
ever-so-slightly better in isolation. Fixing this also improves redundant
test/compare elimination and makes writing tests for redundant test/compare
elimination far easier.
gcc/
* config/h8300/h8300.c (h8300_rtx_costs): Handle the various
comparison rtx codes too.
Iain Sandoe [Sun, 15 Nov 2020 09:52:26 +0000 (09:52 +0000)]
config.sub, config.guess : Import upstream 2020-11-07.
This imports from:
sha1
77632d92f25e26b95c64afd3700d51bd03587613
Date: 2020-11-07 04:46:23 +0000
ChangeLog:
* config.guess: Import latest upstream.
* config.sub: Import latest upstream.
Nathan Sidwell [Mon, 23 Nov 2020 18:34:22 +0000 (10:34 -0800)]
testsuite: Adjust pruning
Here is the patch to adjust the include-stack pruning messages to also
strip out c++ modules. The ICE regexp was a little too strict such
that if someone overrides the bug-reporting URL it doesn't trigger.
May as well relax it too.
gcc/testsuite/
* lib/prune.exp (prune_gcc_output): Adjust include stack pruning
for modules.
(print_ices): Relax regexp.
Jonathan Wakely [Mon, 23 Nov 2020 18:16:44 +0000 (18:16 +0000)]
libstdc++: Fix variable declared with wrong type
libstdc++-v3/ChangeLog:
* include/bits/semaphore_base.h
(__platform_semaphore::_M_try_acquire_until): Fix type of
variable.
Stephan Bergmann [Mon, 23 Nov 2020 18:14:44 +0000 (18:14 +0000)]
libstdc++: Fix linker errors due to missing 'inline' keywords
libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h (__thread_relax, __thread_yield):
Add 'inline'.
Jonathan Wakely [Mon, 23 Nov 2020 17:17:09 +0000 (17:17 +0000)]
libstdc++: Add configure checks for semaphores
This moves the checks for POSIX semaphores to configure time. As well as
requiring <semaphore.h> and SEM_VALUE_MAX, we also require the
sem_timedwait function. That was only optional in POSIX 2001 (and is
absent on Darwin).
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_CHECK_GTHREADS): Check for
* config.h.in: Regenerate.
* configure: Regenerate.
* include/bits/semaphore_base.h (_GLIBCXX_HAVE_POSIX_SEMAPHORE):
Check autoconf macro instead of defining it here.
Jonathan Wakely [Sun, 22 Nov 2020 01:00:46 +0000 (01:00 +0000)]
libstdc++: make atomic waiting depend on gthreads or futexes
libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h: Do not define anything unless
gthreads or futexes are available.
* include/bits/atomic_timed_wait.h: Likewise.
* include/bits/semaphore_base.h: Likewise.
* include/std/semaphore: Likewise.
* include/bits/atomic_base.h (atomic_flag::wait)
(atomic_flag::notify_one, atomic_flag::notify_all)
(__atomic_base<I>::wait, __atomic_base<I>::notify_one)
(__atomic_base<I>::notify_all, __atomic_base<P*>::wait)
(__atomic_base<P*>::notify_one, __atomic_base<P*>::notify_all)
(__atomic_impl::wait, __atomic_impl::notify_one)
(__atomic_impl::notify_all, __atomic_float::wait)
(__atomic_float::notify_one, __atomic_float::notify_all)
(__atomic_ref::wait, __atomic_ref::notify_one)
(__atomic_ref::notify_all): Only define if gthreads or futexes
are available.
* include/std/atomic (atomic::wait, atomic::notify_one)
(atomic::notify_all): Likewise.
* include/std/version (__cpp_lib_semaphore): Define
conditionally.
Ian Lance Taylor [Mon, 23 Nov 2020 00:01:14 +0000 (16:01 -0800)]
log/syslog: correct asm name for C function
Patch from Rainer Orth.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/272259
Jonathan Wakely [Mon, 23 Nov 2020 15:46:24 +0000 (15:46 +0000)]
libstdc++: Link tests to libatomic as required [PR 97948]
libstdc++-v3/ChangeLog:
PR libstdc++/97948
* testsuite/29_atomics/atomic_float/wait_notify.cc: Add options
for libatomic.
* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
Jan Hubicka [Mon, 23 Nov 2020 15:58:23 +0000 (16:58 +0100)]
Release ipa-prop's agg.items and make alocation more careful
This saves about 316MB WPAing Firefox
* ipa-prop.c (build_agg_jump_func_from_list,
ipa_read_jump_function): Reserve agg.items precisely.
* ipa-prop.h (ipa_node_params::~ipa_node_params): Release descriptors
(ipa_edge_args::~ipa_edge_args): Release agg.items.
Jan Hubicka [Mon, 23 Nov 2020 15:52:36 +0000 (16:52 +0100)]
Do not leak SSANAMES in lto streamer
* lto-streamer-in.c (input_cfg): Do not init ssa operands.
(input_function): Do not init tree_ssa and set in_ssa_p.
(input_ssa_names): Do it here.
* tree-ssa.c (init_tree_ssa): Add additional SIZE parameter, default
to 0
* tree-ssanames.c (init_ssanames): Do not round size up to 50, allocate
precisely.
* tree-ssa.h (init_tree_ssa): Update prototype.
Nathan Sidwell [Mon, 23 Nov 2020 15:34:17 +0000 (07:34 -0800)]
Diagnostic for module importation
This tweaks the 'included from ...' printing to deal with imports in
the 'include' path. One new thing is that there can now be two
'include' names on a single line. For example 'in module X, included
at Y'. This reads better than placing them on different lines.
gcc/
* diagnostic.c (diagnostic_report_current_module): Adjust for C++
module importation.
Nathan Sidwell [Mon, 23 Nov 2020 15:27:21 +0000 (07:27 -0800)]
c++: Add empty module.cc
This adds an empty module.cc file, along with make rules to build it.
gcc/cp/
* module.cc: New dummy file.
* Make-lang.in: Add rules to build module.o
Jozef Lawrynowicz [Mon, 23 Nov 2020 14:24:43 +0000 (14:24 +0000)]
MSP430: Remove target-specific handling of the "persistent" attribute
The "persistent" attribute is now handled generically, and does not
need specific support in the MSP430 back end.
gcc/ChangeLog:
* config/msp430/msp430.c (msp430_section_attr): Don't warn for "lower"
attribute used with "noinit" or "persistent" attributes.
(msp430_persist_attr): Remove.
(attr_lower_exclusions): Remove ATTR_PERSIST exclusion.
(attr_upper_exclusions): Likewise.
(attr_either_exclusions): Likewise.
(attr_persist_exclusions): Remove.
(msp430_attribute_table): Remove ATTR_PERSIST handling.
(msp430_handle_generic_attribute): Remove ATTR_PERSIST section conflict
handling.
(TARGET_ASM_INIT_SECTIONS): Remove.
(msp430_init_sections): Remove.
(msp430_select_section): Use default_elf_select_section for decls with
the "persistent" attribute.
(msp430_section_type_flags): Remove ".persistent" section handling.
* doc/extend.texi (MSP430 Variable Attributes): Remove "noinit" and
"persistent" documentation.
gcc/testsuite/ChangeLog:
* g++.target/msp430/data-attributes.C: Remove expected warnings for
"lower" attribute conflicts.
Adjust expected wording for "persistent" attribute misuse.
* gcc.target/msp430/data-attributes-2.c: Likewise.
* gcc.target/msp430/pr78818-auto-warn.c: Likewise.
Richard Biener [Mon, 23 Nov 2020 12:46:35 +0000 (13:46 +0100)]
fix hybrid SLP discovery debug stmt issue
This properly skips debug USE_STMTs when looking for non-SLP sinks.
2020-11-23 Richard Biener <rguenther@suse.de>
* tree-vect-slp.c (maybe_push_to_hybrid_worklist): Skip
debug stmts.
* g++.dg/vect/simd-12.cc: New testcase.
Jozef Lawrynowicz [Mon, 23 Nov 2020 12:06:39 +0000 (12:06 +0000)]
Implement the "persistent" attribute
The "persistent" attribute is used for variables that are initialized
by the program loader, but are not initialized by the runtime startup
code. "persistent" variables are placed in a non-volatile area of
memory, which allows their value to "persist" between processor resets.
gcc/c-family/ChangeLog:
* c-attribs.c (handle_special_var_sec_attribute): New.
(handle_noinit_attribute): Remove.
(attr_noinit_exclusions): Rename to...
(attr_section_exclusions): ...this, and add "persistent" attribute
exclusion.
(c_common_attribute_table): Add "persistent" attribute.
gcc/ChangeLog:
* doc/extend.texi (Common Variable Attributes): Document the
"persistent" variable attribute.
* doc/sourcebuild.texi (Effective-Target Keywords): Document
the "persistent" effective target keyword.
* tree.h (DECL_PERSISTENT_P): Define.
* varasm.c (bss_initializer_p): Return false for a
DECL_PERSISTENT_P decl initialized to zero.
(default_section_type_flags): Handle the ".persistent" section.
(default_elf_select_section): Likewise.
(default_unique_section): Likewise.
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/noinit-attribute.c: Moved to...
* c-c++-common/torture/attr-noinit-main.inc: ...here.
* lib/target-supports.exp (check_effective_target_persistent): New.
* c-c++-common/torture/attr-noinit-1.c: New test.
* c-c++-common/torture/attr-noinit-2.c: New test.
* c-c++-common/torture/attr-noinit-3.c: New test.
* c-c++-common/torture/attr-noinit-invalid.c: New test.
* c-c++-common/torture/attr-persistent-1.c: New test.
* c-c++-common/torture/attr-persistent-2.c: New test.
* c-c++-common/torture/attr-persistent-3.c: New test.
* c-c++-common/torture/attr-persistent-invalid.c: New test.
* c-c++-common/torture/attr-persistent-main.inc: New test.
Jozef Lawrynowicz [Mon, 23 Nov 2020 12:06:15 +0000 (12:06 +0000)]
cp/decl.c: Set DECL_INITIAL before attribute processing
Attribute handlers may want to examine DECL_INITIAL for a decl, to
validate the attribute being applied. For C++, DECL_INITIAL is currently
not set until cp_finish_decl, by which time attribute validation has
already been performed.
For msp430-elf this causes the "persistent" attribute to always be
rejected for C++, since DECL_INITIAL must be non-null for the
attribute to be applied to a decl.
This patch ensures DECL_INITIAL is set for initialized decls early in
start_decl, before attribute handlers run. This allows the
initialization status of the decl to be examined by the handlers.
DECL_INITIAL must be restored to it's initial value after attribute
validation is performed, so as to not interfere with later decl
processing.
gcc/cp/ChangeLog:
* decl.c (start_decl): Set DECL_INITIAL for initialized decls
before attribute processing.
gcc/testsuite/ChangeLog:
* gcc.target/msp430/data-attributes-2.c: Adjust test.
* g++.target/msp430/data-attributes.C: New test.
* g++.target/msp430/msp430.exp: New test.
Jozef Lawrynowicz [Mon, 23 Nov 2020 11:43:39 +0000 (11:43 +0000)]
Fix "noinit" attribute being ignored for -O0 and -fdata-sections
Variables with the "noinit" attribute are ignored at -O0 because they
are treated like a regular bss variable and placed in the .bss section.
With -fdata-sections they are ignored because they are not handled in
resolve_unique_section.
gcc/ChangeLog:
* tree.h (DECL_NOINIT_P): Define.
* varasm.c (DECL_NOINIT_P): Check DECL_NOINIT_P before using
unnamed bss/lcomm sections for bss_initializer variables.
(default_elf_select_section): Use DECL_NOINIT_P instead of
looking up attribute for .noinit section selection.
(default_unique_section): Check DECL_NOINIT_P for .noinit
section selection.
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/noinit-attribute.c: Don't override
optimization options set by torture test harness.
* lib/target-supports.exp (check_effective_target_noinit): Adjust
comment formatting.
Matthew Malcomson [Fri, 20 Nov 2020 18:03:59 +0000 (18:03 +0000)]
Document bootstrap-asan configure option
Document how to configure using asan (bootstrap-asan option to the
--with-build-config configure argument).
gcc/ChangeLog:
* doc/install.texi: Document bootstrap-asan option.
Christophe Lyon [Mon, 23 Nov 2020 09:58:43 +0000 (09:58 +0000)]
testsuite/arm: add missing -mthumb to several tests
Some tests force -mcpu=cortex-mXX but do not add -mthumb, causing
errors if GCC is not configured to default to Thumb code
(--with-mode=thumb):
cc1: error: target CPU does not support ARM mode
This patch adds -mthumb where relevant.
2020-11-23 Christophe Lyon <christophe.lyon@linaro.org>
gcc/testsuite/
* gcc.target/arm/cortex-m55-nodsp-flag-hard.c: Add -mthumb.
* gcc.target/arm/cortex-m55-nodsp-flag-softfp.c: Likewise.
* gcc.target/arm/cortex-m55-nodsp-nofp-flag-softfp.c: Likewise.
* gcc.target/arm/cortex-m55-nofp-flag-hard.c: Likewise.
* gcc.target/arm/cortex-m55-nofp-flag-softfp.c: Likewise.
* gcc.target/arm/cortex-m55-nofp-nomve-flag-softfp.c: Likewise.
* gcc.target/arm/cortex-m55-nomve-flag-hard.c: Likewise.
* gcc.target/arm/cortex-m55-nomve-flag-softfp.c: Likewise.
* gcc.target/arm/cortex-m55-nomve.fp-flag-hard.c: Likewise.
* gcc.target/arm/cortex-m55-nomve.fp-flag-softfp.c: Likewise.
* gcc.target/arm/mve/intrinsics/pr97327.c: Likewise.
Richard Sandiford [Mon, 23 Nov 2020 09:06:59 +0000 (09:06 +0000)]
c++: Add missing verify_type_context call [PR97904]
When adding the verify_type_context target hook, I'd missed
a site that needs to check an array element type.
gcc/cp/
PR c++/97904
* pt.c (tsubst): Use verify_type_context to check the type
of an array element.
gcc/testsuite/
PR c++/97904
* g++.dg/ext/sve-sizeless-1.C: Add more template tests.
* g++.dg/ext/sve-sizeless-2.C: Likewise.
GCC Administrator [Mon, 23 Nov 2020 00:16:22 +0000 (00:16 +0000)]
Daily bump.
Uros Bizjak [Sun, 22 Nov 2020 21:26:48 +0000 (22:26 +0100)]
i386: Use SWI48DWI mode iterator for abs and maxmin [PR97873]
Generate special double mode sequence also for TImode on 64bit targets.
2020-11-22 Uroš Bizjak <ubizjak@gmail.com>
PR target/97873
gcc/
* config/i386/i386.md (abs<mode>2): Use SWI48DWI mode iterator.
(*abs<dwi>2_doubleword): Use DWIH mode iterator.
(<maxmin:code><mode>3): Use SWI48DWI mode iterator.
(*<maxmin:code><dwi>3_doubleword): Use DWIH mode iterator.
gcc/testsuite/
* gcc.target/i386/pr97873-2.c: New test.
Austin Law [Sun, 22 Nov 2020 19:26:48 +0000 (12:26 -0700)]
H8 cc0 conversion
gcc/
* config/h8300/addsub.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters.
(add<mod>3_incdec): Remove pattern
(adds/subs splitter): Only run before reload.
* config/h8300/bitfield.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output
of the splitters.
(cstoreqi4, cstorehi4, cstoresi4): Comment out
(*bstzhireg, *cmpstz, *bstz, *bistz, *cmpcondset): Likewise
(*condbset, *cmpcondbclr, *condbclr): Likewise.
(*cmpcondbsetreg, *condbsetreg, *cmpcondbclrreg): Likewise.
(*condbclrreg): Likewise.
* config/h8300/combiner.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters. Add appropriate CC register clobbers to
existing splitters.
(*addsi3_and_r_1): Disable for now.
(*addsi3_and_not_r_1, bit-test branches): Likewise.
* config/h8300/divmod.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters.
* config/h8300/extensions.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters.
* config/h8300/genmova.sh: Drop "cc" attribute from patterns.
* config/h8300/mova.md: Drop "cc" attribute from patterns.
* config/h8300/h8300-modes.def: Add CCZN and CCZNV modes.
* config/h8300/h8300-protos.h (output_plussi): Update prototype.
(compute_plussi_length): Likewise.
(h8300_select_cc_mode): Add prototype.
(compute_a_shift_cc): Remove prototype
(cmpute_logical_op_cc): Likewise.
* config/h8300/h8300.c (names_big): Add "cc" register.
(names_extended, names_upper_extended): Likewise.
(h8300_emit_stack_adjustment): Be more selective about setting
RTX_FRAME_RELATED_P.
(h8300_print_operand): Handle CCZN mode
(h8300_select_cc_mode): New function.
(notice_update_cc): if-0 out. Only kept for reference purposes.
(h8300_expand_store): Likewise.
(h8300_binary_length): Handle new insn forms.
(output_plussi): Add argument for NEED_FLAGS and handle that case.
(compute_plussi_length): Likewise.
(compute_logical_op_cc): Return integer.
(TARGET_FLAGS_REGNUM): Define.
* config/h8300/h8300.h (FIRST_PSEUDO_REGISTER): Bump for cc register.
(FIXED_REGISTERS, CALL_USED_REGISTERS): Handle cc register.
(REG_ALLOC_ORDER, REGISTER_NAMES): Likewise.
(SELECT_CC_MODE): Define.
* config/h8300/h8300.md: Add CC_REG.
Do not include peepholes.md for now.
* config/h8300/jumpcall.md (cbranchqi4): Consolidate into
cbranch<mode>4.
(cbranchhi4, cbranchsi4): Likewise.
(cbranch<mode>4): New expander.
(branch): New define_insn_and_split for use before reload.
(branch_1, branch_1_false): New patterns to match splitter output.
Remove code to manage cc_status.flags.
* config/h8300/logical.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters. Move various peepholes into this file.
* config/h8300/movepush.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters.
* config/h8300/multiply.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters.
* config/h8300/other.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters.
* config/h8300/peepholes.md: Remove peepholes that were moved
elsewhere.
* config/h8300/predicates.md (simple_memory_operand): New.
* config/h8300/proepi.md: Drop "cc" attribute setting.
* config/h8300/shiftrotate.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters.
* config/h8300/testcompare.md: Turn existing patterns into
define_insn_and_split style patterns where the splitter
adds a clobber of the condition code register. Drop "cc"
attribute. Add _clobber_flags patterns to match output of
the splitters. Disable various patterns for now.
Move some peepholes that were previously in peepholes.md here.
Iain Buclaw [Sun, 22 Nov 2020 13:29:54 +0000 (14:29 +0100)]
d: Fix OutOfMemoryError thrown when appending to an array with a side effect
When appending a character to an array, the result of that concat
assignment was not the new value of the array, similarly, when appending
an array to another array, side effects were evaluated in reverse to the
expected order of evaluation.
As of this change, the address of the left-hand side expression is
saved and re-used as the result. Its evaluation is now also forced to
occur before the concat operation itself is called.
gcc/d/ChangeLog:
PR d/97889
* expr.cc (ExprVisitor::visit (CatAssignExp *)): Enforce LTR order of
evaluation on left and right hand side expressions.
gcc/testsuite/ChangeLog:
PR d/97889
* gdc.dg/torture/pr97889.d: New test.
Jakub Jelinek [Sun, 22 Nov 2020 18:16:34 +0000 (19:16 +0100)]
widening_mul: pattern recognize further forms of __builtin_add_overflow [PR95853]
The following patch recognizes some further forms of additions with overflow
checks as shown in the testcase, in particular where the unsigned addition is
performed in a wider mode just to catch overflow with a > narrower_utype_max
check.
2020-11-22 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/95853
* tree-ssa-math-opts.c (uaddsub_overflow_check_p): Add maxval
argument, if non-NULL, instead look for r > maxval or r <= maxval
comparisons.
(match_uaddsub_overflow): Pattern recognize even other forms of
__builtin_add_overflow, in particular when addition is performed
in a wider type and result compared to maximum of the narrower
type.
* gcc.dg/pr95853.c: New test.
Jeff Law [Sun, 22 Nov 2020 17:53:14 +0000 (10:53 -0700)]
Partially revert recent H8 patch for conditional branches
So I'd forgotten an important tidbit on the H8 port. Specifically
for a branch instruction, the target label must be operand 0 for
the length computations.
This really only affects the main conditional branch pattern.
The other conditional branch patterns are split and ultimately
funnel into the main pattern. This patch fixes the issue by
partially reverting an earlier change. This issue didn't show up
until late in the optimization work on cc0 removal of the H8 port,
but was caught by the testsuite. So there's no new test.
Built and regression tested H8 with this change, with and without
the cc0 removal patches.
gcc/
* config/h8300/jumpcall.md (branch_true, branch_false): Revert
recent change. Ensure operand[0] is always the target label.
Iain Sandoe [Sun, 22 Nov 2020 11:19:32 +0000 (11:19 +0000)]
Darwin : Avoid a C++ ODR violation seen with LTO.
We have a similar code pattern in darwin-c.c to one in c-pragmas
(most likely a cut & paste) with a struct type used locally to the
TU. With C++ we need to rename the type to avoid an ODR violation.
gcc/ChangeLog:
* config/darwin-c.c (struct f_align_stack): Rename
to type from align_stack to f_align_stack.
(push_field_alignment): Likewise.
(pop_field_alignment): Likewise.
GCC Administrator [Sun, 22 Nov 2020 00:16:24 +0000 (00:16 +0000)]
Daily bump.
Marek Polacek [Tue, 10 Nov 2020 02:15:33 +0000 (21:15 -0500)]
c++: Extend -Wrange-loop-construct for binding-to-temp [PR94695]
This patch finishes the second half of -Wrange-loop-construct I promised
to implement: it warns when a loop variable in a range-based for-loop is
initialized with a value of a different type resulting in a copy. For
instance:
int arr[10];
for (const double &x : arr) { ... }
where in every iteration we have to create and destroy a temporary value
of type double, to which we bind the reference. This could negatively
impact performance.
As per Clang, this doesn't warn when the range returns a copy, hence the
glvalue_p check.
gcc/ChangeLog:
PR c++/94695
* doc/invoke.texi: Update the -Wrange-loop-construct description.
gcc/cp/ChangeLog:
PR c++/94695
* parser.c (warn_for_range_copy): Warn when the loop variable is
initialized with a value of a different type resulting in a copy.
gcc/testsuite/ChangeLog:
PR c++/94695
* g++.dg/warn/Wrange-loop-construct2.C: New test.
Marek Polacek [Tue, 17 Nov 2020 00:59:35 +0000 (19:59 -0500)]
c++: Reject identifier label in constexpr [PR97846]
[dcl.constexpr]/3 says that the function-body of a constexpr function
shall not contain an identifier label, but we aren't enforcing that.
This patch implements that. Of course, we can't reject artificial
labels.
gcc/cp/ChangeLog:
PR c++/97846
* constexpr.c (potential_constant_expression_1): Reject
LABEL_EXPRs that use non-artifical LABEL_DECLs.
gcc/testsuite/ChangeLog:
PR c++/97846
* g++.dg/cpp1y/constexpr-label.C: New test.
Marek Polacek [Tue, 17 Nov 2020 18:39:39 +0000 (13:39 -0500)]
c++: Fix ICE-on-invalid with -Wvexing-parse [PR97881]
This invalid (?) code broke my assumption that if decl_specifiers->type
is null, there must be any type-specifiers. Turn the assert into an if
to fix this crash.
gcc/cp/ChangeLog:
PR c++/97881
* parser.c (warn_about_ambiguous_parse): Only assume "int" if we
actually saw any type-specifiers.
gcc/testsuite/ChangeLog:
PR c++/97881
* g++.dg/warn/Wvexing-parse9.C: New test.
David Edelsohn [Sat, 21 Nov 2020 20:43:05 +0000 (15:43 -0500)]
testsuite: localclass2 require LTO
The testcase uses LTO but does not include the dg-require LTO.
gcc/testsuite/ChangeLog:
* g++.dg/debug/localclass2.C: Require LTO.
Marek Polacek [Tue, 17 Nov 2020 16:38:25 +0000 (11:38 -0500)]
c++: Allow template lambdas without lambda-declarator [PR97839]
Our implementation of template lambdas incorrectly requires the optional
lambda-declarator. This was probably required by an early draft of
generic lambdas, but now the production is [expr.prim.lambda.general]:
lambda-expression:
lambda-introducer lambda-declarator [opt] compound-statement
lambda-introducer < template-parameter-list > requires-clause [opt]
lambda-declarator [opt] compound-statement
Therefore, we should accept the following test.
gcc/cp/ChangeLog:
PR c++/97839
* parser.c (cp_parser_lambda_declarator_opt): Don't require ().
gcc/testsuite/ChangeLog:
PR c++/97839
* g++.dg/cpp2a/lambda-generic8.C: New test.
Jan Hubicka [Sat, 21 Nov 2020 20:34:02 +0000 (21:34 +0100)]
Use OEP_MATCH_SIDE_EFFECTS in compare_ao_refs
* tree-ssa-alias.c (ao_compare::compare_ao_refs,
ao_compare::hash_ao_ref): Use OEP_MATCH_SIDE_EFFECTS.
Marek Polacek [Thu, 19 Nov 2020 22:56:39 +0000 (17:56 -0500)]
c++: Fix wrong error with constexpr destructor [PR97427]
When I implemented the code to detect modifying const objects in
constexpr contexts, we couldn't have constexpr destructors, so I didn't
consider them. But now we can and that caused a bogus error in this
testcase: [class.dtor]p5 says that "const and volatile semantics are not
applied on an object under destruction. They stop being in effect when
the destructor for the most derived object starts." so we have to clear
the TREE_READONLY flag we set on the object after the constructors have
been called to mark it as no-longer-under-construction. In the ~Foo
call it's now an object under destruction, so don't report those errors.
gcc/cp/ChangeLog:
PR c++/97427
* constexpr.c (cxx_set_object_constness): New function.
(cxx_eval_call_expression): Set new_obj for destructors too.
Call cxx_set_object_constness to set/unset TREE_READONLY of
the object under construction/destruction.
gcc/testsuite/ChangeLog:
PR c++/97427
* g++.dg/cpp2a/constexpr-dtor10.C: New test.
Jonathan Wakely [Sat, 21 Nov 2020 16:52:22 +0000 (16:52 +0000)]
libstdc++: Fix atomic waiting for non-linux targets
This fixes some UNRESOLVED tests on (at least) Solaris and Darwin, and
disables some tests that hang forever on Solaris. A proper fix is still
needed.
libstdc++-v3/ChangeLog:
* include/bits/atomic_base.h (atomic_flag::wait): Use correct
type for __atomic_wait call.
* include/bits/atomic_timed_wait.h (__atomic_wait_until): Check
_GLIBCXX_HAVE_LINUX_FUTEX.
* include/bits/atomic_wait.h (__atomic_notify): Likewise.
* include/bits/semaphore_base.h (_GLIBCXX_HAVE_POSIX_SEMAPHORE):
Only define if SEM_VALUE_MAX or _POSIX_SEM_VALUE_MAX is defined.
* testsuite/29_atomics/atomic/wait_notify/bool.cc: Disable on
non-linux targes.
* testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise.
* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
Jan Hubicka [Sat, 21 Nov 2020 17:07:49 +0000 (18:07 +0100)]
Update vec-35.c and vect-35-big-array.c
We now determine depnedencies across union fields correctly.
* gcc.dg/vect/vect-35-big-array.c: Excpect 2 loops to be vectorized.
* gcc.dg/vect/vect-35.c: Excpect 2 loops to be vectorized.
Jan Hubicka [Sat, 21 Nov 2020 16:41:10 +0000 (17:41 +0100)]
Improve hasing of anonymous namespace types
* ipa-icf.c (sem_function::equals_wpa): Do not compare ODR type with
-fno-devirtualize.
(sem_item_optimizer::update_hash_by_addr_refs): Hash anonymous ODR
types by TYPE_UID of their main variant.
Aaron Sawdey [Tue, 17 Nov 2020 17:55:01 +0000 (12:55 -0500)]
Re-enable vector pair memcpy/memmove expansion
After the MMA opaque mode patch goes in, we can re-enable
use of vector pair in the inline expansion of memcpy/memmove.
gcc/
* config/rs6000/rs6000.c (rs6000_option_override_internal):
Enable vector pair memcpy/memmove expansion.
Aaron Sawdey [Tue, 17 Nov 2020 16:38:20 +0000 (11:38 -0500)]
Make MMA builtins use opaque modes
This patch changes powerpc MMA builtins to use the new opaque
mode class and use modes OO (32 bytes) and XO (64 bytes)
instead of POI/PXI. Using the opaque modes prevents
optimization from trying to do anything with vector
pair/quad, which was the problem we were seeing with the
partial integer modes.
gcc/
* config/rs6000/mma.md (unspec): Add assemble/extract UNSPECs.
(movoi): Change to movoo.
(*movpoi): Change to *movoo.
(movxi): Change to movxo.
(*movpxi): Change to *movxo.
(mma_assemble_pair): Change to OO mode.
(*mma_assemble_pair): New define_insn_and_split.
(mma_disassemble_pair): New define_expand.
(*mma_disassemble_pair): New define_insn_and_split.
(mma_assemble_acc): Change to XO mode.
(*mma_assemble_acc): Change to XO mode.
(mma_disassemble_acc): New define_expand.
(*mma_disassemble_acc): New define_insn_and_split.
(mma_<acc>): Change to XO mode.
(mma_<vv>): Change to XO mode.
(mma_<avv>): Change to XO mode.
(mma_<pv>): Change to OO mode.
(mma_<apv>): Change to XO/OO mode.
(mma_<vvi4i4i8>): Change to XO mode.
(mma_<avvi4i4i8>): Change to XO mode.
(mma_<vvi4i4i2>): Change to XO mode.
(mma_<avvi4i4i2>): Change to XO mode.
(mma_<vvi4i4>): Change to XO mode.
(mma_<avvi4i4>): Change to XO mode.
(mma_<pvi4i2>): Change to XO/OO mode.
(mma_<apvi4i2>): Change to XO/OO mode.
(mma_<vvi4i4i4>): Change to XO mode.
(mma_<avvi4i4i4>): Change to XO mode.
* config/rs6000/predicates.md (input_operand): Allow opaque.
(mma_disassemble_output_operand): New predicate.
* config/rs6000/rs6000-builtin.def:
Changes to disassemble builtins.
* config/rs6000/rs6000-call.c (rs6000_return_in_memory):
Disallow __vector_pair/__vector_quad as return types.
(rs6000_promote_function_mode): Remove function return type
check because we can't test it here any more.
(rs6000_function_arg): Do not allow __vector_pair/__vector_quad
as as function arguments.
(rs6000_gimple_fold_mma_builtin):
Handle mma_disassemble_* builtins.
(rs6000_init_builtins): Create types for XO/OO modes.
* config/rs6000/rs6000-modes.def: DElete OI, XI,
POI, and PXI modes, and create XO and OO modes.
* config/rs6000/rs6000-string.c (expand_block_move):
Update to OO mode.
* config/rs6000/rs6000.c (rs6000_hard_regno_mode_ok_uncached):
Update for XO/OO modes.
(rs6000_rtx_costs): Make UNSPEC_MMA_XXSETACCZ cost 0.
(rs6000_modes_tieable_p): Update for XO/OO modes.
(rs6000_debug_reg_global): Update for XO/OO modes.
(rs6000_setup_reg_addr_masks): Update for XO/OO modes.
(rs6000_init_hard_regno_mode_ok): Update for XO/OO modes.
(reg_offset_addressing_ok_p): Update for XO/OO modes.
(rs6000_emit_move): Update for XO/OO modes.
(rs6000_preferred_reload_class): Update for XO/OO modes.
(rs6000_split_multireg_move): Update for XO/OO modes.
(rs6000_mangle_type): Update for opaque types.
(rs6000_invalid_conversion): Update for XO/OO modes.
* config/rs6000/rs6000.h (VECTOR_ALIGNMENT_P):
Update for XO/OO modes.
* config/rs6000/rs6000.md (RELOAD): Update for XO/OO modes.
gcc/testsuite/
* gcc.target/powerpc/mma-double-test.c (main): Call abort for failure.
* gcc.target/powerpc/mma-single-test.c (main): Call abort for failure.
* gcc.target/powerpc/pr96506.c: Rename to pr96506-1.c.
* gcc.target/powerpc/pr96506-2.c: New test.
Aaron Sawdey [Tue, 17 Nov 2020 23:17:44 +0000 (17:17 -0600)]
Additional small changes to support opaque modes
After building some larger codes using opaque types and some c++ codes
using opaque types it became clear I needed to go through and look for
places where opaque types and modes needed to be handled. A whole pile
of one-liners.
gcc/
* typeclass.h: Add opaque_type_class.
* builtins.c (type_to_class): Identify opaque type class.
* dwarf2out.c (is_base_type): Handle opaque types.
(gen_type_die_with_usage): Handle opaque types.
* expr.c (count_type_elements): Opaque types should
never have initializers.
* ipa-devirt.c (odr_types_equivalent_p): No type-specific handling
for opaque types is needed as it eventually checks the underlying
mode which is what is important.
* tree-streamer.c (record_common_node): Handle opaque types.
* tree.c (type_contains_placeholder_1): Handle opaque types.
(type_cache_hasher::equal): No additional comparison needed for
opaque types.
gcc/c-family
* c-pretty-print.c (c_pretty_printer::simple_type_specifier):
Treat opaque types like other types.
(c_pretty_printer::direct_abstract_declarator): Opaque types are
supported types.
gcc/c
* c-aux-info.c (gen_type): Support opaque types.
gcc/cp
* error.c (dump_type): Handle opaque types.
(dump_type_prefix): Handle opaque types.
(dump_type_suffix): Handle opaque types.
(dump_expr): Handle opaque types.
* pt.c (tsubst): Allow opaque types in templates.
(unify): Allow opaque types in templates.
* typeck.c (structural_comptypes): Handle comparison
of opaque types.
Iain Sandoe [Sat, 21 Nov 2020 09:06:03 +0000 (09:06 +0000)]
Darwin, libgfortran : Do not use environ directly from the library.
On macOS / Darwin, the environ variable can be used directly in the
code of an executable, but cannot be used in the code of a shared
library (i.e. libgfortran.dylib), in this case.
In such cases, the function _NSGetEnviron should be called to get
the address of 'environ'.
libgfortran/ChangeLog:
* intrinsics/execute_command_line.c (environ): Use
_NSGetEnviron to get the environment pointer on Darwin.
Iain Sandoe [Wed, 18 Nov 2020 13:15:47 +0000 (13:15 +0000)]
Darwin, libsanitizer : Support libsanitizer for x86_64-darwin20.
The sanitizer is supported for at least x86_64 and Darwin20.
libsanitizer/ChangeLog:
* configure.tgt: Allow x86_64 Darwin2x.
Ian Lance Taylor [Fri, 20 Nov 2020 23:19:29 +0000 (15:19 -0800)]
libgo: update to Go 1.15.5 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/272146
GCC Administrator [Sat, 21 Nov 2020 00:16:29 +0000 (00:16 +0000)]
Daily bump.
Michael Meissner [Fri, 20 Nov 2020 23:34:24 +0000 (18:34 -0500)]
Include math.h in nextafter-2.c test.
Since the test is compiled with -fno-builtin, include math.h to allow for
implementations (like the PowerPC) that have multiple versions of long double
that are selectable by switch. Math.h could possibly switch what function
nextafterl points to.
gcc/testsuite/
2020-11-17 Michael Meissner <meissner@linux.ibm.com>
* gcc.dg/nextafter-2.c: Include math.h.
Michael Meissner [Fri, 20 Nov 2020 23:24:13 +0000 (18:24 -0500)]
Power10: Add missing IEEE 128-bit XSCMP* built-in mappings.
This patch adds support for mapping the scalar_cmp_exp_qp_* built-in functions
to handle arguments that are either TFmode or KFmode, depending on whether long
double uses the IEEE 128-bit representation (TFmode) or the IBM 128-bit
representation (KFmode). This shows up in the float128-cmp2-runnable.c test
when long double uses the IEEE 128-bit representation.
gcc/
2020-11-20 Michael Meissner <meissner@linux.ibm.com>
* config/rs6000/rs6000-call.c (rs6000_expand_builtin): Add missing
XSCMP* cases for IEEE 128-bit long double.
Thomas Rodgers [Fri, 20 Nov 2020 20:29:34 +0000 (12:29 -0800)]
libstdc++: Add C++2a synchronization support
Add support for -
* atomic_flag::wait/notify_one/notify_all
* atomic::wait/notify_one/notify_all
* counting_semaphore
* binary_semaphore
* latch
libstdc++-v3/ChangeLog:
* include/Makefile.am (bits_headers): Add new header.
* include/Makefile.in: Regenerate.
* include/bits/atomic_base.h (__atomic_flag::wait): Define.
(__atomic_flag::notify_one): Likewise.
(__atomic_flag::notify_all): Likewise.
(__atomic_base<_Itp>::wait): Likewise.
(__atomic_base<_Itp>::notify_one): Likewise.
(__atomic_base<_Itp>::notify_all): Likewise.
(__atomic_base<_Ptp*>::wait): Likewise.
(__atomic_base<_Ptp*>::notify_one): Likewise.
(__atomic_base<_Ptp*>::notify_all): Likewise.
(__atomic_impl::wait): Likewise.
(__atomic_impl::notify_one): Likewise.
(__atomic_impl::notify_all): Likewise.
(__atomic_float<_Fp>::wait): Likewise.
(__atomic_float<_Fp>::notify_one): Likewise.
(__atomic_float<_Fp>::notify_all): Likewise.
(__atomic_ref<_Tp>::wait): Likewise.
(__atomic_ref<_Tp>::notify_one): Likewise.
(__atomic_ref<_Tp>::notify_all): Likewise.
(atomic_wait<_Tp>): Likewise.
(atomic_wait_explicit<_Tp>): Likewise.
(atomic_notify_one<_Tp>): Likewise.
(atomic_notify_all<_Tp>): Likewise.
* include/bits/atomic_wait.h: New file.
* include/bits/atomic_timed_wait.h: New file.
* include/bits/semaphore_base.h: New file.
* include/std/atomic (atomic<bool>::wait): Define.
(atomic<bool>::wait_one): Likewise.
(atomic<bool>::wait_all): Likewise.
(atomic<_Tp>::wait): Likewise.
(atomic<_Tp>::wait_one): Likewise.
(atomic<_Tp>::wait_all): Likewise.
(atomic<_Tp*>::wait): Likewise.
(atomic<_Tp*>::wait_one): Likewise.
(atomic<_Tp*>::wait_all): Likewise.
* include/std/latch: New file.
* include/std/semaphore: New file.
* include/std/version: Add __cpp_lib_semaphore and
__cpp_lib_latch defines.
* testsuite/29_atomics/atomic/wait_notify/bool.cc: New test.
* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
* testsuite/29_atomics/atomic/wait_notify/generic.cc: Liekwise.
* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
* testsuite/30_threads/semaphore/1.cc: New test.
* testsuite/30_threads/semaphore/2.cc: Likewise.
* testsuite/30_threads/semaphore/least_max_value_neg.cc: Likewise.
* testsuite/30_threads/semaphore/try_acquire.cc: Likewise.
* testsuite/30_threads/semaphore/try_acquire_for.cc: Likewise.
* testsuite/30_threads/semaphore/try_acquire_posix.cc: Likewise.
* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
* testsuite/30_threads/latch/1.cc: New test.
* testsuite/30_threads/latch/2.cc: New test.
* testsuite/30_threads/latch/3.cc: New test.
* testsuite/util/atomic/wait_notify_util.h: New File.
Jason Merrill [Fri, 20 Nov 2020 20:20:45 +0000 (15:20 -0500)]
dwarf2: ICE with local class in unused function [PR97918]
Here, since we only mention bar<B>, we never emit debug information for it.
But we do emit debug information for H<J>::h, so we need to refer to the
debug info for bar<B>::J even though there is no bar<B>. We deal with this
sort of thing in dwarf2out with the limbo_die_list; parentless dies like J
get attached to the CU at EOF. But here, we were flushing the limbo list,
then generating the template argument DIE for H<J> that refers to J, which
adds J to the limbo list, too late to be flushed. So let's flush a little
later.
gcc/ChangeLog:
PR c++/97918
* dwarf2out.c (dwarf2out_early_finish): flush_limbo_die_list
after gen_scheduled_generic_parms_dies.
gcc/testsuite/ChangeLog:
PR c++/97918
* g++.dg/debug/localclass2.C: New test.
Martin Sebor [Fri, 20 Nov 2020 21:35:25 +0000 (14:35 -0700)]
PR middle-end/97861 - ICE on an invalid redeclaration of a function with attribute access
gcc/c-family/ChangeLog:
* c-warn.c (warn_parm_array_mismatch): Bail on invalid redeclarations
with fewer arguments.
gcc/testsuite/ChangeLog:
* gcc.dg/attr-access-4.c: New test.
François Dumont [Wed, 22 Jan 2020 16:55:54 +0000 (17:55 +0100)]
libstdc++: Limit memory allocation in stable_sort/inplace_merge (PR 83938)
Reduce memory allocation in stable_sort/inplace_merge algorithms to what is needed
by the implementation.
Co-authored-by: John Chang <john.chang@samba.tv>
libstdc++-v3/ChangeLog:
PR libstdc++/83938
* include/bits/stl_tempbuf.h (get_temporary_buffer): Change __len
computation in the loop to avoid truncation.
* include/bits/stl_algo.h:
(__inplace_merge): Take temporary buffer length from smallest range.
(__stable_sort): Limit temporary buffer length.
* testsuite/25_algorithms/inplace_merge/1.cc (test4): New.
* testsuite/performance/25_algorithms/stable_sort.cc: Test stable_sort
under different heap memory conditions.
* testsuite/performance/25_algorithms/inplace_merge.cc: New test.
Maciej W. Rozycki [Fri, 20 Nov 2020 21:11:22 +0000 (21:11 +0000)]
libada: Check for the presence of _SC_NPROCESSORS_ONLN
Check for the presence of _SC_NPROCESSORS_ONLN rather than using a list
of OS-specific macros to decide whether to use `sysconf' like elsewhere
across GCC sources, fixing a compilation error:
adaint.c: In function '__gnat_number_of_cpus':
adaint.c:2398:26: error: '_SC_NPROCESSORS_ONLN' undeclared (first use in this function)
2398 | cores = (int) sysconf (_SC_NPROCESSORS_ONLN);
| ^~~~~~~~~~~~~~~~~~~~
adaint.c:2398:26: note: each undeclared identifier is reported only once for each function it appears in
at least with with VAX/NetBSD 1.6.2.
gcc/ada/
* adaint.c (__gnat_number_of_cpus): Check for the presence of
_SC_NPROCESSORS_ONLN rather than a list of OS-specific macros
to decide whether to use `sysconf'.
Maciej W. Rozycki [Fri, 20 Nov 2020 21:11:22 +0000 (21:11 +0000)]
NetBSD/libgcc: Check for TARGET_DL_ITERATE_PHDR in the unwinder
Disable USE_PT_GNU_EH_FRAME frame unwinder support for old OS versions,
fixing compilation errors:
.../libgcc/unwind-dw2-fde-dip.c:75:21: error: unknown type name 'Elf_Phdr'
75 | # define ElfW(type) Elf_##type
| ^~~~
.../libgcc/unwind-dw2-fde-dip.c:132:9: note: in expansion of macro 'ElfW'
132 | const ElfW(Phdr) *p_eh_frame_hdr;
| ^~~~
.../libgcc/unwind-dw2-fde-dip.c:75:21: error: unknown type name 'Elf_Phdr'
75 | # define ElfW(type) Elf_##type
| ^~~~
.../libgcc/unwind-dw2-fde-dip.c:133:9: note: in expansion of macro 'ElfW'
133 | const ElfW(Phdr) *p_dynamic;
| ^~~~
.../libgcc/unwind-dw2-fde-dip.c:165:37: warning: 'struct dl_phdr_info' declared inside parameter list will not be visible outside of this definition or declaration
165 | _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
| ^~~~~~~~~~~~
[...]
and producing a working cross-compiler at least with VAX/NetBSD 1.6.2.
libgcc/
* unwind-dw2-fde-dip.c [__OpenBSD__ || __NetBSD__]
(USE_PT_GNU_EH_FRAME): Do not define if !TARGET_DL_ITERATE_PHDR.
Martin Sebor [Fri, 20 Nov 2020 20:44:57 +0000 (13:44 -0700)]
PR middle-end/97879 - ICE on invalid mode in attribute access
gcc/c-family/ChangeLog:
PR middle-end/97879
* c-attribs.c (handle_access_attribute): Handle ATTR_FLAG_INTERNAL.
Error out on invalid modes.
gcc/c/ChangeLog:
PR middle-end/97879
* c-decl.c (start_function): Set ATTR_FLAG_INTERNAL in flags.
gcc/ChangeLog:
PR middle-end/97879
* tree-core.h (enum attribute_flags): Add ATTR_FLAG_INTERNAL.
gcc/testsuite/ChangeLog:
PR middle-end/97879
* gcc.dg/attr-access-3.c: New test.
Ian Lance Taylor [Tue, 17 Nov 2020 04:06:53 +0000 (20:06 -0800)]
compiler, libgo: change mangling scheme
Overhaul the mangling scheme to avoid ambiguities if the package path
contains a dot. Instead of using dot both to separate components and
to mangle characters, use dot only to separate components and use
underscore to mangle characters.
For golang/go#41862
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/271726
François Dumont [Wed, 12 Feb 2020 17:38:57 +0000 (18:38 +0100)]
libstdc++: _Rb_tree code cleanup, remove lambdas
Use new template parameters to replace usage of lambdas to move or not
tree values on copy.
libstdc++-v3/ChangeLog:
* include/bits/move.h (_GLIBCXX_FWDREF): New.
* include/bits/stl_tree.h: Adapt to use latter.
(_Rb_tree<>::_M_clone_node): Add _MoveValue template parameter.
(_Rb_tree<>::_M_mbegin): New.
(_Rb_tree<>::_M_begin): Use latter.
(_Rb_tree<>::_M_copy): Add _MoveValues template parameter.
* testsuite/23_containers/map/allocator/move_cons.cc: New test.
* testsuite/23_containers/multimap/allocator/move_cons.cc: New test.
* testsuite/23_containers/multiset/allocator/move_cons.cc: New test.
* testsuite/23_containers/set/allocator/move_cons.cc: New test.
Jan Hubicka [Fri, 20 Nov 2020 19:36:14 +0000 (20:36 +0100)]
Improve hashing of decls in ipa-icf-gimple
Another remaining case is that we end up comparing calls with mismatching
number of parameters or with different permutations of them.
This is because we hash decls to nothing. This patch improves that by
hashing decls by their code and parm decls by indexes that are stable.
Also for defualt defs in SSA_NAMEs we can add the corresponding decl (that
is usually parm decls).
Still we could improve on this by hasing ssa names by their definit parameters
and possibly making maps of other decls and assigning them stable function
local IDs.
* ipa-icf-gimple.c (func_checker::hash_operand): Improve hashing of
decls.
Jan Hubicka [Fri, 20 Nov 2020 19:33:04 +0000 (20:33 +0100)]
Only compare sizes of automatic variables
one of common remaining reasons for ICF to fail after loading in fuction
body is mismatched type of automatic vairable. This is becuase
compatible_types_p resorts to checking TYPE_MAIN_VARIANTS for
euqivalence that prevents merging many TBAA compaitle cases. (And thus
is also not reflected by the hash extended by alias sets of accesses.)
Since in gimple
automatic variables are just blocks of memory I think we should only
check its size only. All accesses are matched when copmparing the actual
loads/stores.
I am not sure if we need to match types of other DECLs but I decided I can try
to be safe here: for PARM_DECl/RESUILT_DECL we match them anyway to be sure
that functions are ABI compatible. For CONST_DECL and readonly global
VAR_DECLs they are matched when comparing their constructors.
* ipa-icf-gimple.c (func_checker::compare_decl): Do not compare types
of local variables.
Andrew MacLeod [Fri, 20 Nov 2020 15:37:26 +0000 (10:37 -0500)]
re: FAIL: gcc.dg/pr97515.c
Adjust testcase to check in CCP not EVRP.
gcc/testuite/
* gcc.dg/pr97515.c: Check in ccp2, not evrp.
Andrea Corallo [Mon, 9 Nov 2020 15:59:14 +0000 (16:59 +0100)]
PR target/97727 aarch64: [testcase] fix bf16_vstN_lane_2.c for big endian targets
gcc/testsuite/ChangeLog
2020-11-09 Andrea Corallo <andrea.corallo@arm.com>
PR target/97727
* gcc.target/aarch64/advsimd-intrinsics/bf16_vstN_lane_2.c: Relax
regexps.
Nathan Sidwell [Fri, 20 Nov 2020 15:14:13 +0000 (10:14 -0500)]
doc: Fixup a couple of formatting nits
I noticed a couple of places we used @code{program} instead of
@command{program}.
gcc/
* doc/invoke.texi: Replace a couple of @code with @command
Andrea Corallo [Tue, 10 Nov 2020 14:15:27 +0000 (15:15 +0100)]
[PR target/97726] arm: [testsuite] fix some simd tests on armbe
2020-11-10 Andrea Corallo <andrea.corallo@arm.com>
PR target/97726
* gcc.target/arm/simd/bf16_vldn_1.c: Relax regexps not to fail on
big endian.
* gcc.target/arm/simd/vldn_lane_bf16_1.c: Likewise
* gcc.target/arm/simd/vmmla_1.c: Add -mfloat-abi=hard flag.
Tamar Christina [Fri, 20 Nov 2020 13:32:32 +0000 (13:32 +0000)]
SLP: Have vectorizable_slp_permutation set type on invariants
This modifies vectorizable_slp_permutation to update the type of the children
of a perm node before trying to permute them. This allows us to be able to
permute invariant nodes.
This will be covered by test from the SLP pattern matcher.
gcc/ChangeLog:
* tree-vect-slp.c (vectorizable_slp_permutation): Update types on nodes
when needed.
Jonathan Wakely [Fri, 20 Nov 2020 11:30:33 +0000 (11:30 +0000)]
libstdc++: Remove <memory_resource> dependency from <regex> [PR 92546]
Unlike the other headers that declare alias templates in namespace pmr,
<regex> includes <memory_resource>. That was done because the
pmr::string::const_iterator typedef requires pmr::string to be complete,
which requires pmr::polymorphic_allocator<char> to be complete.
By using __normal_iterator<const char*, pmr::string> instead of the
const_iterator typedef we can avoid the completeness requirement.
This makes <regex> smaller, by not requiring <memory_resource> and its
<shared_mutex> dependency, which depends on <chrono>. Backporting this
will also help with PR 97876, where <stop_token> ends up being needed by
<regex> via <memory_resource>.
libstdc++-v3/ChangeLog:
PR libstdc++/92546
* include/std/regex (pmr::smatch, pmr::wsmatch): Declare using
underlying __normal_iterator type, not nested typedef
basic_string::const_iterator.
Richard Biener [Fri, 20 Nov 2020 08:39:53 +0000 (09:39 +0100)]
Deal with (pattern) SLP consumed stmts in hybrid discovery
This makes hybrid SLP discovery deal with stmts indirectly consumed
by SLP, for example via patterns. This means that all uses of a
stmt end up in SLP vectorized stmts.
This helps my prototype patches for PR97832 where I make SLP discovery
re-associate chains to make operands match. This ends up building
SLP computation nodes without 1:1 representatives in the scalar IL
and thus no scalar lane defs in SLP_TREE_SCALAR_STMTS. Nevertheless
all of the original scalar stmts are consumed so this represents
another kind of SLP pattern for the computation chain result.
2020-11-20 Richard Biener <rguenther@suse.de>
* tree-vect-slp.c (maybe_push_to_hybrid_worklist): New function.
(vect_detect_hybrid_slp): Use it. Perform a backward walk
over the IL.
Richard Biener [Fri, 20 Nov 2020 11:10:56 +0000 (12:10 +0100)]
dump SLP_TREE_REPRESENTATIVE
It always annoyed me to see those empty SLP nodes in dumpfiles:
t.c:16:3: note: node 0x3a2a280 (max_nunits=1, refcnt=1)
t.c:16:3: note: { }
t.c:16:3: note: children 0x3a29db0 0x3a29e90
resulting from two-operator handling. The following makes
sure to also dump the operation template or VEC_PERM_EXPR.
2020-11-20 Richard Biener <rguenther@suse.de>
* tree-vect-slp.c (vect_print_slp_tree): Also dump
SLP_TREE_REPRESENTATIVE.
Jakub Jelinek [Fri, 20 Nov 2020 11:28:34 +0000 (12:28 +0100)]
c++: Add __builtin_clear_padding builtin - C++20 P0528R3 compiler side [PR88101]
The following patch implements __builtin_clear_padding builtin that clears
the padding bits in object representation (but preserves value
representation). Inside of unions it clears only those padding bits that
are padding for all the union members (so that it never alters value
representation).
It handles trailing padding, padding in the middle of structs including
bitfields (PDP11 unhandled, I've never figured out how those bitfields
work), VLAs (doesn't handle variable length structures, but I think almost
nobody uses them and it isn't worth the extra complexity). For VLAs and
sufficiently large arrays it uses runtime clearing loop instead of emitting
straight-line code (unless arrays are inside of a union).
The way I think this can be used for atomics is e.g. if the structures
are power of two sized and small enough that we use the hw atomics
for say compare_exchange __builtin_clear_padding could be called first on
the address of expected and desired arguments (for desired only if we want
to ensure that most of the time the atomic memory will have padding bits
cleared), then perform the weak cmpxchg and if that fails, we got the
value from the atomic memory; we can call __builtin_clear_padding on a copy
of that and then compare it with expected, and if it is the same with the
padding bits masked off, we can use the original with whatever random
padding bits in it as the new expected for next cmpxchg.
__builtin_clear_padding itself is not atomic and therefore it shouldn't
be called on the atomic memory itself, but compare_exchange*'s expected
argument is a reference and normally the implementation may store there
the current value from memory, so padding bits can be cleared in that,
and desired is passed by value rather than reference, so clearing is fine
too.
When using libatomic, we can use it either that way, or add new libatomic
APIs that accept another argument, pointer to the padding bit bitmask,
and construct that in the template as
alignas (_T) unsigned char _mask[sizeof (_T)];
std::memset (_mask, ~0, sizeof (_mask));
__builtin_clear_padding ((_T *) _mask);
which will have bits cleared for padding bits and set for bits taking part
in the value representation. Then libatomic could internally instead
of using memcmp compare
for (i = 0; i < N; i++) if ((val1[i] & mask[i]) != (val2[i] & mask[i]))
2020-11-20 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/88101
gcc/
* builtins.def (BUILT_IN_CLEAR_PADDING): New built-in function.
* gimplify.c (gimplify_call_expr): Rewrite single argument
BUILT_IN_CLEAR_PADDING into two-argument variant.
* gimple-fold.c (clear_padding_unit, clear_padding_buf_size): New
const variables.
(struct clear_padding_struct): New type.
(clear_padding_flush, clear_padding_add_padding,
clear_padding_emit_loop, clear_padding_type,
clear_padding_union, clear_padding_real_needs_padding_p,
clear_padding_type_may_have_padding_p,
gimple_fold_builtin_clear_padding): New functions.
(gimple_fold_builtin): Handle BUILT_IN_CLEAR_PADDING.
* doc/extend.texi (__builtin_clear_padding): Document.
gcc/c-family/
* c-common.c (check_builtin_function_arguments): Handle
BUILT_IN_CLEAR_PADDING.
gcc/testsuite/
* c-c++-common/builtin-clear-padding-1.c: New test.
* c-c++-common/torture/builtin-clear-padding-1.c: New test.
* c-c++-common/torture/builtin-clear-padding-2.c: New test.
* c-c++-common/torture/builtin-clear-padding-3.c: New test.
* c-c++-common/torture/builtin-clear-padding-4.c: New test.
* c-c++-common/torture/builtin-clear-padding-5.c: New test.
* g++.dg/torture/builtin-clear-padding-1.C: New test.
* g++.dg/torture/builtin-clear-padding-2.C: New test.
* gcc.dg/builtin-clear-padding-1.c: New test.
Jakub Jelinek [Fri, 20 Nov 2020 11:26:58 +0000 (12:26 +0100)]
arm: Fix up neon_vector_mem_operand [PR97528]
The documentation for POST_MODIFY says:
Currently, the compiler can only handle second operands of the
form (plus (reg) (reg)) and (plus (reg) (const_int)), where
the first operand of the PLUS has to be the same register as
the first operand of the *_MODIFY.
The following testcase ICEs, because combine just attempts to simplify
things and ends up with
(post_modify (reg1) (plus (mult (reg2) (const_int 4)) (reg1))
but the target predicates accept it, because they only verify
that POST_MODIFY's second operand is PLUS and the second operand
of the PLUS is a REG.
The following patch fixes this by performing further verification that
the POST_MODIFY is in the form it should be.
2020-11-20 Jakub Jelinek <jakub@redhat.com>
PR target/97528
* config/arm/arm.c (neon_vector_mem_operand): For POST_MODIFY, require
first POST_MODIFY operand is a REG and is equal to the first operand
of PLUS.
* gcc.target/arm/pr97528.c: New test.
Eric Botcazou [Fri, 20 Nov 2020 11:21:12 +0000 (12:21 +0100)]
Plug loophole in string store merging
There is a loophole in new string store merging support added recently:
it does not check that the stores are consecutive, which is obviously
required if you want to concatenate them... Simple fix attached, the
nice thing being that it can fall back to the regular processing if
any hole is detected in the series of stores, thanks to the handling
of STRING_CST by native_encode_expr.
gcc/ChangeLog:
* gimple-ssa-store-merging.c (struct merged_store_group): Add
new 'consecutive' field.
(merged_store_group): Set it to true.
(do_merge): Set it to false if the store is not consecutive and
set string_concatenation to false in this case.
(merge_into): Call do_merge on entry.
(merge_overlapping): Likewise.
gcc/testsuite/ChangeLog:
* gnat.dg/opt90a.adb: New test.
* gnat.dg/opt90b.adb: Likewise.
* gnat.dg/opt90c.adb: Likewise.
* gnat.dg/opt90d.adb: Likewise.
* gnat.dg/opt90e.adb: Likewise.
* gnat.dg/opt90a_pkg.ads: New helper.
* gnat.dg/opt90b_pkg.ads: Likewise.
* gnat.dg/opt90c_pkg.ads: Likewise.
* gnat.dg/opt90d_pkg.ads: Likewise.
* gnat.dg/opt90e_pkg.ads: Likewise.
Jan Hubicka [Fri, 20 Nov 2020 10:13:02 +0000 (11:13 +0100)]
Fix comment in ipa-icf-gimple.c
* ipa-icf-gimple.c (func_checker::operand_equal_p): Fix comment.
Jan Hubicka [Fri, 20 Nov 2020 10:06:48 +0000 (11:06 +0100)]
Fix comparsion of {CLOBBER} in icf
after fixing few issues I gotto stage where 1.4M icf mismatches are due to
comparing two gimple clobber. The problem is that operand_equal_p match
clobber
case CONSTRUCTOR:
/* In GIMPLE empty constructors are allowed in initializers of
aggregates. */
return !CONSTRUCTOR_NELTS (arg0) && !CONSTRUCTOR_NELTS (arg1);
But this happens too late after comparing its types (that are not very relevant
for memory store).
In the context of ipa-icf we do not really need to match RHS of gimple clobbers:
it is enough to know that the LHS stores can be considered equivalent.
I this added logic to hash them all the same way and compare using
TREE_CLOBBER_P flag. I see other option in extending operand_equal_p
in fold-const to handle them more generously or making stmt hash and compare
to skip comparing/hashing RHS of gimple_clobber_p.
* ipa-icf-gimple.c (func_checker::hash_operand): Hash gimple clobber.
(func_checker::operand_equal_p): Special case gimple clobber.
Uros Bizjak [Fri, 20 Nov 2020 09:26:34 +0000 (10:26 +0100)]
i386: Optimize abs expansion [PR97873]
The patch introduces absM named pattern to generate optimal insn sequence
for CMOVE_TARGET targets. Currently, the expansion goes through neg+max
optabs, and the following code is generated:
movl %edi, %eax
negl %eax
cmpl %edi, %eax
cmovl %edi, %eax
This sequence is unoptimal in two ways. a) The compare instruction is
not needed, since NEG insn sets the sign flag based on the result.
The CMOV can use sign flag to select between negated and original value:
movl %edi, %eax
negl %eax
cmovs %edi, %eax
b) On some targets, CMOV is undesirable due to its performance issues.
In addition to TARGET_EXPAND_ABS bypass, the patch introduces STV
conversion of abs RTX to use PABS SSE insn:
vmovd %edi, %xmm0
vpabsd %xmm0, %xmm0
vmovd %xmm0, %eax
The patch changes compare mode of NEG instruction to CCGOCmode,
which is the same mode as the mode of SUB instruction. IOW, sign bit
becomes usable.
Also, the mode iterator of <maxmin:code><mode>3 pattern is changed
to SWI48x instead of SWI248. The purpose of maxmin expander is to
prepare max/min RTX for STV to eventually convert them to SSE PMAX/PMIN
instructions, in order to *avoid* CMOV insns with general registers.
2020-11-20 Uroš Bizjak <ubizjak@gmail.com>
gcc/
PR target/97873
* config/i386/i386.md (*neg<mode>2_2): Rename from
"*neg<mode>2_cmpz". Use CCGOCmode instead of CCZmode.
(*negsi2_zext): Rename from *negsi2_cmpz_zext.
Use CCGOCmode instead of CCZmode.
(*neg<mode>_ccc_1): New insn pattern.
(*neg<dwi>2_doubleword): Use *neg<mode>_ccc_1.
(abs<mode>2): Add FLAGS_REG clobber.
Use TARGET_CMOVE insn predicate.
(*abs<mode>2_1): New insn_and_split pattern.
(*absdi2_doubleword): Ditto.
(<maxmin:code><mode>3): Use SWI48x mode iterator.
(*<maxmin:code><mode>3): Use SWI48 mode iterator.
* config/i386/i386-features.c
(general_scalar_chain::compute_convert_gain): Handle ABS code.
(general_scalar_chain::convert_insn): Ditto.
(general_scalar_to_vector_candidate_p): Ditto.
gcc/testsuite/
PR target/97873
* gcc.target/i386/pr97873.c: New test.
* gcc.target/i386/pr97873-1.c: New test.
Jakub Jelinek [Fri, 20 Nov 2020 07:45:11 +0000 (08:45 +0100)]
configury: Fix up --enable-link-serialization support
Eric reported that the --enable-link-serialization changes seemed to
cause the binaries to be always relinked, for example from the
gcc/ directory of the build tree:
make
[relink of gnat1, brig1, cc1plus, d21, f951, go1, lto1, ...]
make
[relink of gnat1, brig1, cc1plus, d21, f951, go1, lto1, ...]
Furthermore as reported in PR, it can cause problems during make install
where make install rebuilds the binaries again.
The problem is that for make .PHONY targets are just
"rebuilt" always, so it is very much undesirable for the cc1plus$(exeext)
etc. dependencies to include .PHONY targets, but I was using
them - cc1plus.prev which would depend on some *.serial and
e.g. cc1.serial depending on c and c depending on cc1$(exeext).
The following patch rewrites this so that *.serial and *.prev aren't
.PHONY targets, but instead just make variables.
I was worried that the order in which the language makefile fragments are
included (which is quite random, what order we get from the filesystem
matching */config-lang.in) would be a problem but it seems to work fine
- as it uses make = rather than := variables, later definitions are just
fine for earlier uses as long as the uses aren't needed during the
makefile parsing, but only in the dependencies of make targets and in
their commands.
2020-11-20 Jakub Jelinek <jakub@redhat.com>
PR other/97911
gcc/
* configure.ac: In SERIAL_LIST use lang words without .serial
suffix. Change $lang.prev from a target to variable and instead
of depending on *.serial expand to the *.serial variable if
the word is in the SERIAL_LIST at all, otherwise to nothing.
* configure: Regenerated.
gcc/c/
* Make-lang.in (c.serial): Change from goal to a variable.
(.PHONY): Drop c.serial.
gcc/ada/
* gcc-interface/Make-lang.in (ada.serial): Change from goal to a
variable.
(.PHONY): Drop ada.serial and ada.prev.
(gnat1$(exeext)): Depend on $(ada.serial) rather than ada.serial.
gcc/brig/
* Make-lang.in (brig.serial): Change from goal to a variable.
(.PHONY): Drop brig.serial and brig.prev.
(brig1$(exeext)): Depend on $(brig.serial) rather than brig.serial.
gcc/cp/
* Make-lang.in (c++.serial): Change from goal to a variable.
(.PHONY): Drop c++.serial and c++.prev.
(cc1plus$(exeext)): Depend on $(c++.serial) rather than c++.serial.
gcc/d/
* Make-lang.in (d.serial): Change from goal to a variable.
(.PHONY): Drop d.serial and d.prev.
(d21$(exeext)): Depend on $(d.serial) rather than d.serial.
gcc/fortran/
* Make-lang.in (fortran.serial): Change from goal to a variable.
(.PHONY): Drop fortran.serial and fortran.prev.
(f951$(exeext)): Depend on $(fortran.serial) rather than
fortran.serial.
gcc/go/
* Make-lang.in (go.serial): Change from goal to a variable.
(.PHONY): Drop go.serial and go.prev.
(go1$(exeext)): Depend on $(go.serial) rather than go.serial.
gcc/jit/
* Make-lang.in (jit.serial): Change from goal to a
variable.
(.PHONY): Drop jit.serial and jit.prev.
($(LIBGCCJIT_FILENAME)): Depend on $(jit.serial) rather than
jit.serial.
gcc/lto/
* Make-lang.in (lto1.serial, lto2.serial): Change from goals to
variables.
(.PHONY): Drop lto1.serial, lto2.serial, lto1.prev and lto2.prev.
($(LTO_EXE)): Depend on $(lto1.serial) rather than lto1.serial.
($(LTO_DUMP_EXE)): Depend on $(lto2.serial) rather than lto2.serial.
gcc/objc/
* Make-lang.in (objc.serial): Change from goal to a variable.
(.PHONY): Drop objc.serial and objc.prev.
(cc1obj$(exeext)): Depend on $(objc.serial) rather than objc.serial.
gcc/objcp/
* Make-lang.in (obj-c++.serial): Change from goal to a variable.
(.PHONY): Drop obj-c++.serial and obj-c++.prev.
(cc1objplus$(exeext)): Depend on $(obj-c++.serial) rather than
obj-c++.serial.
Kewen Lin [Fri, 20 Nov 2020 04:32:18 +0000 (22:32 -0600)]
rs6000: Fix p8_mtvsrd_df's insn type
This patch is to fix insn type of p8_mtvsrd_df from mfvsr to mtvsr,
in order to align with the other places using mtvsrd.
gcc/ChangeLog:
* config/rs6000/rs6000.md (p8_mtvsrd_df): Fix insn type.
Martin Uecker [Fri, 20 Nov 2020 06:21:40 +0000 (07:21 +0100)]
C: Drop qualifiers during lvalue conversion [PR97702]
2020-11-20 Martin Uecker <muecker@gwdg.de>
gcc/
* gimplify.c (gimplify_modify_expr_rhs): Optimizie
NOP_EXPRs that contain compound literals.
gcc/c/
* c-typeck.c (convert_lvalue_to_rvalue): Drop qualifiers.
gcc/testsuite/
* gcc.dg/cond-constqual-1.c: Adapt test.
* gcc.dg/lvalue-11.c: New test.
* gcc.dg/pr60195.c: Add warning.
GCC Administrator [Fri, 20 Nov 2020 00:16:40 +0000 (00:16 +0000)]
Daily bump.
Jakub Jelinek [Thu, 19 Nov 2020 23:02:21 +0000 (00:02 +0100)]
ranger: Improve a % b operand ranges [PR91029]
As mentioned in the PR, the previous PR91029 patch was testing
op2 >= 0 which is unnecessary, even negative op2 values will work the same,
furthermore, from if a % b > 0 we can deduce a > 0 rather than just a >= 0
(0 % b would be 0), and it actually valid even for other constants than 0,
a % b > 5 means a > 5 (a % b has the same sign as a and a in [0, 5] would
result in a % b in [0, 5]. Also, we can deduce a range for the other
operand, if we know
a % b >= 20, then b must be (in absolute value for signed modulo) > 20,
for a % [0, 20] the result would be [0, 19].
2020-11-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/91029
* range-op.cc (operator_trunc_mod::op1_range): Don't require signed
types, nor require that op2 >= 0. Implement (a % b) >= x && x > 0
implies a >= x and (a % b) <= x && x < 0 implies a <= x.
(operator_trunc_mod::op2_range): New method.
* gcc.dg/tree-ssa/pr91029-1.c: New test.
* gcc.dg/tree-ssa/pr91029-2.c: New test.
Andrew MacLeod [Thu, 19 Nov 2020 22:41:30 +0000 (17:41 -0500)]
Process only valid shift ranges.
When shifting outside the valid range of [0, precision-1], we can
choose to process just the valid ones since the rest is undefined.
this allows us to produce results for x << [0,2][+INF, +INF] by discarding
the invalid ranges and processing just [0,2].
gcc/
PR tree-optimization/93781
* range-op.cc (get_shift_range): Rename from
undefined_shift_range_check and now return valid shift ranges.
(operator_lshift::fold_range): Use result from get_shift_range.
(operator_rshift::fold_range): Ditto.
gcc/testsuite/
* gcc.dg/tree-ssa/pr93781-1.c: New.
* gcc.dg/tree-ssa/pr93781-2.c: New.
* gcc.dg/tree-ssa/pr93781-3.c: New.
Nathan Sidwell [Thu, 19 Nov 2020 21:18:09 +0000 (13:18 -0800)]
c++: Template hash access
This exposes the template specialization table, so the modules
machinery may access it. The hashed entity (tmpl, args & spec) is
available, along with a hash table walker. We also need a way of
finding or inserting entries, along with some bookkeeping fns to deal
with the instantiation and (partial) specialization lists.
gcc/cp/
* cp-tree.h (struct spec_entry): Moved from pt.c.
(walk_specializations, match_mergeable_specialization)
(get_mergeable_specialization_flags)
(add_mergeable_specialization): Declare.
* pt.c (struct spec_entry): Moved to cp-tree.h.
(walk_specializations, match_mergeable_specialization)
(get_mergeable_specialization_flags)
(add_mergeable_specialization): New.
Jonathan Wakely [Thu, 19 Nov 2020 21:07:06 +0000 (21:07 +0000)]
libstdc++: Avoid calling undefined __gthread_self weak symbol [PR 95989]
Since glibc 2.27 the pthread_self symbol has been defined in libc rather
than libpthread. Because we only call pthread_self through a weak alias
it's possible for statically linked executables to end up without a
definition of pthread_self. This crashes when trying to call an
undefined weak symbol.
We can use the __GLIBC_PREREQ version check to detect the version of
glibc where pthread_self is no longer in libpthread, and call it
directly rather than through the weak reference.
It would be better to check for pthread_self in libc during configure
instead of hardcoding the __GLIBC_PREREQ check. That would be
complicated by the fact that prior to glibc 2.27 libc.a didn't have the
pthread_self symbol, but libc.so.6 did. The configure checks would need
to try to link both statically and dynamically, and the result would
depend on whether the static libc.a happens to be installed during
configure (which could vary between different systems using the same
version of glibc). Doing it properly is left for a future date, as that
will be needed anyway after glibc moves all pthread symbols from
libpthread to libc. When that happens we should revisit the whole
approach of using weak symbols for pthread symbols.
For the purposes of std::this_thread::get_id() we call
pthread_self() directly when using glibc 2.27 or later. Otherwise, if
__gthread_active_p() is true then we know the libpthread symbol is
available so we call that. Otherwise, we are single-threaded and just
use ((__gthread_t)1) as the thread ID.
An undesirable consequence of this change is that code compiled prior to
the change might inline the old definition of this_thread::get_id()
which always returns (__gthread_t)1 in a program that isn't linked to
libpthread. Code compiled after the change will use pthread_self() and
so get a real TID. That could result in the main thread having different
thread::id values in different translation units. This seems acceptable,
as there are not expected to be many uses of thread::id in programs
that aren't linked to libpthread.
An earlier version of this patch also changed __gthread_self() to use
__GLIBC_PREREQ(2, 27) and only use the weak symbol for older glibc. Tha
might still make sense to do, but isn't needed by libstdc++ now.
libstdc++-v3/ChangeLog:
PR libstdc++/95989
* config/os/gnu-linux/os_defines.h (_GLIBCXX_NATIVE_THREAD_ID):
Define new macro to get reliable thread ID.
* include/bits/std_thread.h: (this_thread::get_id): Use new
macro if it's defined.
* testsuite/30_threads/jthread/95989.cc: New test.
* testsuite/30_threads/this_thread/95989.cc: New test.
Nathan Sidwell [Thu, 19 Nov 2020 20:18:37 +0000 (12:18 -0800)]
c++: Expose constexpr hash table
This patch exposes the constexpr hash table so that the modules
machinery can save and load constexpr bodies. While there I noticed
that we could do a little constification of the hasher and comparator
functions. Also combine the saving machinery to a single function
returning void -- nothing ever looked at its return value.
gcc/cp/
* cp-tree.h (struct constexpr_fundef): Moved from constexpr.c.
(maybe_save_constexpr_fundef): Declare.
(register_constexpr_fundef): Take constexpr_fundef object, return
void.
* decl.c (mabe_save_function_definition): Delete, functionality
moved to maybe_save_constexpr_fundef.
(emit_coro_helper, finish_function): Adjust.
* constexpr.c (struct constexpr_fundef): Moved to cp-tree.h.
(constexpr_fundef_hasher::equal): Constify.
(constexpr_fundef_hasher::hash): Constify.
(retrieve_constexpr_fundef): Make non-static.
(maybe_save_constexpr_fundef): Break out checking and duplication
from ...
(register_constexpr_fundef): ... here. Just register the constexpr.
Jan Hubicka [Thu, 19 Nov 2020 19:16:26 +0000 (20:16 +0100)]
Fix two bugs in operand_equal_p
* fold-const.c (operand_compare::operand_equal_p): Fix thinko in
COMPONENT_REF handling and guard types_same_for_odr by
virtual_method_call_p.
(operand_compare::hash_operand): Likewise.
Jakub Jelinek [Thu, 19 Nov 2020 19:02:41 +0000 (20:02 +0100)]
c, tree: Fix ICE from get_parm_array_spec [PR97860]
The C and C++ FEs handle zero sized arrays differently, C uses
NULL TYPE_MAX_VALUE on non-NULL TYPE_DOMAIN on complete ARRAY_TYPEs
with bitsize_zero_node TYPE_SIZE, while C++ FE likes to set
TYPE_MAX_VALUE to the largest value (and min to the lowest).
Martin has used array_type_nelts in get_parm_array_spec where the
function on the C form of [0] arrays returns error_mark_node and the code
crashes soon afterwards. The following patch teaches array_type_nelts about
this (e.g. dwarf2out already handles that as [0]). While it will change
what is_empty_type returns for certain types (e.g. struct S { int a[0]; };),
as those types occupy zero bits in C, it should make an ABI difference.
So, the tree.c change makes the c-decl.c code handle the [0] arrays
like any other constant extents, and the c-decl.c change just makes sure
that if we'd run into error_mark_node e.g. from the VLA expressions, we
don't crash on those.
2020-11-19 Jakub Jelinek <jakub@redhat.com>
PR c/97860
* tree.c (array_type_nelts): For complete arrays with zero min
and NULL max and zero size return -1.
* c-decl.c (get_parm_array_spec): Bail out of nelts is
error_operand_p.
* gcc.dg/pr97860.c: New test.