]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 years agolibstdc++: Simplify basic_string_view::ends_with [PR 101361]
Jonathan Wakely [Tue, 13 Jul 2021 11:21:27 +0000 (12:21 +0100)] 
libstdc++: Simplify basic_string_view::ends_with [PR 101361]

The use of npos triggers a diagnostic as described in PR c++/101361.
This change replaces the use of npos with the exact length, which is
already known. We can further simplify it by inlining the effects of
compare and substr, avoiding the redundant range checks in the latter.

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

PR c++/101361
* include/std/string_view (ends_with): Use traits_type::compare
directly.

(cherry picked from commit 4d3eaeb4f505b0838c673ee28e7dba8687fc8272)

4 years agolibstdc++: Remove duplicate #include in <string_view>
Jonathan Wakely [Tue, 13 Jul 2021 11:09:37 +0000 (12:09 +0100)] 
libstdc++: Remove duplicate #include in <string_view>

When I added the new C++23 constructor I added a conditional include of
<bits/ranges_base.h>, which was already being included unconditionally.
This removes the unconditional include but changes the condition for the
other one, so it's used for C++20 as well.

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

* include/std/string_view: Only include <bits/ranges_base.h>
once, and only for C++20 and later.

(cherry picked from commit bd1eb556b910fd4853ea83291e495d40adbcdf81)

4 years agolibstdc++: Constrain std::as_writable_bytes [PR101411]
Jonathan Wakely [Mon, 12 Jul 2021 15:09:34 +0000 (16:09 +0100)] 
libstdc++: Constrain std::as_writable_bytes [PR101411]

The std::as_writable_bytes function should be constrained to only accept
writable spans. Currently it can be called but then gives an error in
the function body.

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

PR libstdc++/101411
* include/std/span (as_writable_bytes): Add requires-clause.
* testsuite/23_containers/span/101411.cc: New test.

(cherry picked from commit 9d4393af9d2b37b78eb5b1f84f5d4da3a6f7fba6)

4 years agoRevert x86_order_regs_for_local_alloc changes in r12-1669.
liuhongt [Thu, 24 Jun 2021 08:14:13 +0000 (16:14 +0800)] 
Revert x86_order_regs_for_local_alloc changes in r12-1669.

Still put general regs as first alloca order.

gcc/ChangeLog:

PR target/101185
* config/i386/i386.c (x86_order_regs_for_local_alloc):
Revert r12-1669.

gcc/testsuite/ChangeLog

PR target/101185
* gcc.target/i386/bitwise_mask_op-3.c: Add xfail to
temporarily avoid regression, eventually xfail should be
removed.

4 years agoDisparage slightly the mask register alternative for bitwise operations.
liuhongt [Tue, 15 Jun 2021 08:25:16 +0000 (16:25 +0800)] 
Disparage slightly the mask register alternative for bitwise operations.

The avx512 supports bitwise operations with mask registers, but the
throughput of those instructions is much lower than that of the
corresponding gpr version, so we would additionally disparages
slightly the mask register alternative for bitwise operations in the
LRA.

Also when allocano cost of GENERAL_REGS is same as MASK_REGS, allocate
MASK_REGS first since it has already been disparaged.

gcc/ChangeLog:

PR target/101142
* config/i386/i386.md: (*anddi_1): Disparage slightly the mask
register alternative.
(*and<mode>_1): Ditto.
(*andqi_1): Ditto.
(*andn<mode>_1): Ditto.
(*<code><mode>_1): Ditto.
(*<code>qi_1): Ditto.
(*one_cmpl<mode>2_1): Ditto.
(*one_cmplsi2_1_zext): Ditto.
(*one_cmplqi2_1): Ditto.
* config/i386/i386.c (x86_order_regs_for_local_alloc): Change
the order of mask registers to be before general registers.

gcc/testsuite/ChangeLog:

PR target/101142
* gcc.target/i386/spill_to_mask-1.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-2.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-3.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-4.c: Adjust testcase.

4 years agotree-optimization/101445 - fix negative stride SLP vect with gaps
Richard Biener [Wed, 14 Jul 2021 09:06:58 +0000 (11:06 +0200)] 
tree-optimization/101445 - fix negative stride SLP vect with gaps

The following fixes the IV adjustment for the gap in a negative
stride SLP vectorization.  The adjustment was in the wrong direction,
now fixes as in the patch.

2021-07-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101445
* tree-vect-stmts.c (vectorizable_load): Do the gap adjustment
of the IV in the correct direction for negative stride
accesses.

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

(cherry picked from commit a967a3efd39280fe3f5774e45490e991f8e99059)

4 years agoDaily bump.
GCC Administrator [Wed, 14 Jul 2021 00:18:23 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: requires-expr with dependent extra args [PR101181]
Patrick Palka [Fri, 9 Jul 2021 14:20:25 +0000 (10:20 -0400)] 
c++: requires-expr with dependent extra args [PR101181]

Here we're crashing ultimately because the mechanism for delaying
substitution into a requires-expression (and constexpr if and pack
expansions) doesn't expect to see dependent args.  But we end up
capturing dependent args here during substitution into the default
template argument as part of coerce_template_parms for the dependent
specialization p<T>.

This patch enables the commented out code in add_extra_args for handling
this situation.  This isn't needed for pack expansions (as the
accompanying comment points out), and it doesn't seem strictly necessary
for constexpr if either, but for requires-expressions delaying even
dependent substitution is important for ensuring we don't evaluate
requirements out of order.

It turns out we also need to make a copy of the arguments when capturing
them so that coerce_template_parms doesn't later add to them and form an
unexpected cycle (REQUIRES_EXPR_EXTRA_ARGS (t) would indirectly point to t).
We also need to make tsubst_template_args handle missing template
arguments, since the arguments we capture from coerce_template_parms
and are incomplete at that point.

PR c++/101181

gcc/cp/ChangeLog:

* constraint.cc (tsubst_requires_expr): Pass complain/in_decl to
add_extra_args.
* cp-tree.h (add_extra_args): Add complain/in_decl parameters.
* pt.c (build_extra_args): Make a copy of args.
(add_extra_args): Add complain/in_decl parameters.  Enable the
code for handling the case where the extra arguments are
dependent.
(tsubst_pack_expansion): Pass complain/in_decl to
add_extra_args.
(tsubst_template_args): Handle missing template arguments.
(tsubst_expr) <case IF_STMT>: Pass complain/in_decl to
add_extra_args.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires26.C: New test.
* g++.dg/cpp2a/lambda-uneval16.C: New test.

(cherry picked from commit 2c699fd29829cd6115f78238dab7cab74f0a5009)

4 years agoc++: find_template_parameters and TEMPLATE_DECLs [PR101247]
Patrick Palka [Fri, 9 Jul 2021 14:20:22 +0000 (10:20 -0400)] 
c++: find_template_parameters and TEMPLATE_DECLs [PR101247]

r12-1989 fixed the testcase in the PR, but unfortunately the fix is
buggy: it breaks the case where the common template between the
TEMPLATE_DECL t and ctx_parms is the innermost template (as in
concepts-memtmpl5.C below).  This can be fixed by instead passing the
TREE_TYPE of ctmpl to common_enclosing_class when ctmpl is a class
template.

But even after that's fixed, the analogous case where the innermost
template is a partial specialization is still broken (as in
concepts-memtmpl5a.C below), because ctmpl is always a primary template.

So this patch instead takes a diferent approach that doesn't rely on
ctx_parms at all: when looking for the template parameters of a
TEMPLATE_DECL that are shared with the current template context, just
walk its DECL_CONTEXT.  As long as the template is not overly general
(e.g. we didn't pass it through most_general_template), this should give
us exactly what we want, since if a TEMPLATE_DECL can be referred to
from some template context then the template parameters it uses must all
be in-scope and contained in its DECL_CONTEXT.  This effectively makes
us treat TEMPLATE_DECLs more similarly to other _DECLs (whose DECL_CONTEXT
we also walk).

PR c++/101247

gcc/cp/ChangeLog:

* pt.c (any_template_parm_r) <case TEMPLATE_DECL>: Just walk the
DECL_CONTEXT.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memtmpl4.C: Uncomment the commented out
example, which we now handle correctly.
* g++.dg/cpp2a/concepts-memtmpl5.C: New test.
* g++.dg/cpp2a/concepts-memtmpl5a.C: New test.

(cherry picked from commit f53e66019df819f55d424cc56f8b0ea81c074b55)

4 years agoc++: unqualified member template in constraint [PR101247]
Patrick Palka [Fri, 2 Jul 2021 17:54:57 +0000 (13:54 -0400)] 
c++: unqualified member template in constraint [PR101247]

Here any_template_parm_r is failing to mark the template parameters
implicitly used by the unqualified use of 'd' inside the constraint
because the code to do so assumes each level of a template parameter
list points to the corresponding primary template, but here the
parameter level for A in the out-of-line definition of A::B does not
(nor do the parameter levels for A and C in the definition of A::C),
which causes us to overlook the sharing.

So it seems we can't in general depend on the TREE_TYPE of a template
parameter level being non-empty here.  This patch partially fixes this
by rewriting the relevant part of any_template_parm_r to not depend on
the TREE_TYPE of outer levels.  We still depend on the innermost level
to point to the innermost primary template, so we still crash on the
commented out line in the below testcase.

PR c++/101247

gcc/cp/ChangeLog:

* pt.c (any_template_parm_r) <case TEMPLATE_DECL>: Rewrite to
use common_enclosing_class and to not depend on the TREE_TYPE
of outer levels pointing to the corresponding primary template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memtmpl4.C: New test.

(cherry picked from commit e3528ce197f8886869f95e8a8f901861a319851c)

4 years agoc++: cxx_eval_array_reference and empty elem type [PR101194]
Patrick Palka [Thu, 1 Jul 2021 00:44:52 +0000 (20:44 -0400)] 
c++: cxx_eval_array_reference and empty elem type [PR101194]

Here the initializer for x is represented as an empty CONSTRUCTOR due to
its empty element type.  So during constexpr evaluation of the ARRAY_REF
x[0], we end up trying to value initialize the omitted element at index 0,
which fails because the element type is not default constructible.

This patch makes cxx_eval_array_reference specifically handle the case
where the element type is an empty type.

PR c++/101194

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_array_reference): When the element type
is an empty type and the corresponding element is omitted, just
return an empty CONSTRUCTOR instead of attempting value
initialization.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty16.C: New test.

(cherry picked from commit a688c284dd3848b6c4ea553035f0f9769fb4fbc9)

4 years agoc++: alias CTAD and aggregate deduction cand [PR98832]
Patrick Palka [Thu, 24 Jun 2021 17:11:44 +0000 (13:11 -0400)] 
c++: alias CTAD and aggregate deduction cand [PR98832]

During alias CTAD, we're accidentally ignoring the aggregate deduction
candidate for the underlying template because this guide is added
separately via maybe_aggr_guide (which doesn't yet handle alias
templates) instead of via deduction_guides_for (which does).  This patch
makes maybe_aggr_guide handle alias templates in a manner similar to
deduction_guides_for.

PR c++/98832

gcc/cp/ChangeLog:

* pt.c (maybe_aggr_guide): Handle alias templates appropriately.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias9.C: New test.

(cherry picked from commit c761be53f6b62e22ac5de18c4aaf88648f64f5b7)

4 years agoc++: requires-expression folding [PR101182]
Patrick Palka [Thu, 24 Jun 2021 15:29:02 +0000 (11:29 -0400)] 
c++: requires-expression folding [PR101182]

Here we're crashing because cp_fold_function walks into the (templated)
requirements of a requires-expression outside a template, but the
folding routines aren't prepared to handle templated trees.  This patch
fixes this by making cp_fold use evaluate_requires_expr to fold a
requires-expression as a whole, which also means we no longer need to
explicitly do so during gimplification.  (Note that we delay folding
of such requires-expressions for sake of better diagnostics when one is
used as the condition of a failed static_assert.)

PR c++/101182

gcc/cp/ChangeLog:

* constraint.cc (evaluate_requires_expr): Adjust function comment.
* cp-gimplify.c (cp_genericize_r) <case REQUIRES_EXPR>: Move to ...
(cp_fold) <case REQUIRES_EXPR>: ... here.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires25.C: New test.

(cherry picked from commit c06493dc30afbf65b14d783c7cd53f20877ef577)

4 years agolibstdc++: Reduce ranges::minmax/minmax_element comparison complexity
Patrick Palka [Fri, 18 Jun 2021 23:33:39 +0000 (19:33 -0400)] 
libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

This rewrites ranges::minmax and ranges::minmax_element so that it
performs at most 3*N/2 many comparisons, as required by the standard.
In passing, this also fixes PR100387 by avoiding a premature std::move
in ranges::minmax and in std::shift_right.

PR libstdc++/100387

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__minmax_fn::operator()): Rewrite
to limit comparison complexity to 3*N/2.
(__minmax_element_fn::operator()): Likewise.
(shift_right): Avoid premature std::move of __result.
* testsuite/25_algorithms/minmax/constrained.cc (test04, test05):
New tests.
* testsuite/25_algorithms/minmax_element/constrained.cc (test02):
Likewise.

(cherry picked from commit cc9c94d43dcfa98436152af9c00f011e9dab25f6)

4 years agoc++: access of dtor named by qualified template-id [PR100918]
Patrick Palka [Mon, 7 Jun 2021 16:02:08 +0000 (12:02 -0400)] 
c++: access of dtor named by qualified template-id [PR100918]

Here, when resolving the destructor named by Inner<int>::~Inner<int>
(which is valid until C++20) we end up in cp_parser_lookup_name called
indirectly from cp_parser_template_id to look up the name Inner from
the scope Inner<int>.  The lookup naturally finds the injected-class-name,
and because the flag is_template is true, we adjust this lookup result
to the TEMPLATE_DECL Inner.  We then check access of this adjusted
lookup result.  But this access check fails because the lookup scope is
Inner<int> and the context_for_name_lookup for the TEMPLATE_DECL is
Outer (whereas for the injected-class-name it's also Inner<int>).

The simplest fix seems to be to check access of the original lookup
result (the injected-class-name) instead of the adjusted result (the
TEMPLATE_DECL).  So this patch moves the access check in
cp_parser_lookup_name to before the injected-class-name adjustment.

PR c++/100918

gcc/cp/ChangeLog:

* parser.c (cp_parser_lookup_name): Check access of the lookup
result before we potentially adjust an injected-class-name to
its TEMPLATE_DECL.

gcc/testsuite/ChangeLog:

* g++.dg/template/access38.C: New test.

(cherry picked from commit 6cb35b606c39d5f21f3298c77bfbcaaef3fbc872)

4 years agoc++: Fix reference NTTP binding to noexcept fn [PR97420]
Patrick Palka [Wed, 26 May 2021 12:35:31 +0000 (08:35 -0400)] 
c++: Fix reference NTTP binding to noexcept fn [PR97420]

Here, in C++17 mode, convert_nontype_argument_function is rejecting
binding a non-noexcept function reference template parameter to a
noexcept function (encoded as the template argument '*(int (&) (int)) &f').

The first roadblock to making this work is that the argument is wrapped
an an implicit INDIRECT_REF, so we need to unwrap it before calling
strip_fnptr_conv.

The second roadblock is that the NOP_EXPR cast converts from a function
pointer type to a reference type while simultaneously removing the
noexcept qualification, and fnptr_conv_p doesn't consider this cast to
be a function pointer conversion.  This patch fixes this by making
fnptr_conv_p treat REFERENCE_TYPEs and POINTER_TYPEs interchangeably.

Finally, in passing, this patch also simplifies noexcept_conv_p by
removing a bunch of redundant checks already performed by its only
caller fnptr_conv_p.

PR c++/97420

gcc/cp/ChangeLog:

* cvt.c (noexcept_conv_p): Remove redundant checks and simplify.
(fnptr_conv_p): Don't call non_reference.  Use INDIRECT_TYPE_P
instead of TYPE_PTR_P.
* pt.c (convert_nontype_argument_function): Look through
implicit INDIRECT_REFs before calling strip_fnptr_conv.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit b4329e3dd6fb7c78948fcf9d2f5b9d873deec284)

4 years agomiddle-end/101291 - set loop copy of versioned loop
Richard Biener [Mon, 5 Jul 2021 09:53:07 +0000 (11:53 +0200)] 
middle-end/101291 - set loop copy of versioned loop

This fixes the vectorizer loop versioning code failing to clear
niter related info on the scalar loop as it assumed get_loop_copy
would work even for the outermost loop.  The patch makes that
assumption hold by adjusting the loop versioning code.

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

PR middle-end/101291
* cfgloopmanip.c (loop_version): Set the loop copy of the
versioned loop to the new loop.

(cherry picked from commit 38872c6c0db1b10b17d3913b277c499913208d0b)

4 years agotree-optimization/101394 - fix PRE full redundancy wrt abnormals
Richard Biener [Mon, 12 Jul 2021 08:49:03 +0000 (10:49 +0200)] 
tree-optimization/101394 - fix PRE full redundancy wrt abnormals

This avoids adding a copy from an abnormal picked up from PHI
translation much like we'd avoid inserting the translated
expression on pred edges.

2021-07-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101394
* tree-ssa-pre.c (do_pre_regular_insertion): Avoid inserting
copies from abnormals for a full redundancy.

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

(cherry picked from commit 92343e0ba4d47f21ae20ffcb83d736bdbc15dae0)

4 years agomiddle-end/101423 - internal calls do not trap
Richard Biener [Mon, 12 Jul 2021 08:26:25 +0000 (10:26 +0200)] 
middle-end/101423 - internal calls do not trap

This adjusts gimple_could_trap_p to not consider internal function
calls to trap compared to indirect calls or calls to weak functions.

2021-07-12  Richard Biener  <rguenther@suse.de>

PR middle-end/101423
* gimple.c (gimple_could_trap_p_1): Internal function calls
do not trap.
* tree-eh.c (tree_could_trap_p): Likewise.

(cherry picked from commit 123d0a597beb6d9865f808bf15b0d67f2a8fd5b2)

4 years agotree-optimization/100778 - fix placement of trapping vectorized ops
Richard Biener [Thu, 1 Jul 2021 08:35:38 +0000 (10:35 +0200)] 
tree-optimization/100778 - fix placement of trapping vectorized ops

This avoids placing possibly trapping vectorized operations where
the corresponding scalar operation was possibly not executed.

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

PR tree-optimization/100778
* tree-vect-slp.c (vect_schedule_slp_node): Do not place trapping
vectorized ops ahead of their scalar BB.

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

(cherry picked from commit a3aaba68405751bae3f630669515b7ecdf77efa6)

4 years agotree-optimization/100778 - avoid cross-BB vectorization of trapping op
Richard Biener [Fri, 28 May 2021 12:26:06 +0000 (14:26 +0200)] 
tree-optimization/100778 - avoid cross-BB vectorization of trapping op

This avoids vectorizing a possibly trapping operation when lanes
are handled in different BBs.  I spotted this when working on the
originally reported issue in PR100778.

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

PR tree-optimization/100778
* tree-vect-slp.c (vect_build_slp_tree_1): Prevent possibly
trapping ops in different BBs.

* gcc.dg/vect/bb-slp-pr100778-1.c: New testcase.

(cherry picked from commit f7a07f5a5d8065e7f11133dd1f4ad3510ab2195b)

4 years agoDaily bump.
GCC Administrator [Tue, 13 Jul 2021 00:18:04 +0000 (00:18 +0000)] 
Daily bump.

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

4 years agoDaily bump.
GCC Administrator [Sun, 11 Jul 2021 00:18:12 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 10 Jul 2021 00:18:32 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: concepts TS and explicit specialization [PR101098]
Jason Merrill [Fri, 9 Jul 2021 17:50:01 +0000 (13:50 -0400)] 
c++: concepts TS and explicit specialization [PR101098]

duplicate_decls was not recognizing the explicit specialization as matching
the implicit specialization of g<Y> because
function_requirements_equivalent_p was seeing the C constraint on the
implicit one and not on the explicit.

PR c++/101098

gcc/cp/ChangeLog:

* decl.c (function_requirements_equivalent_p): Only compare
trailing requirements on a specialization.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/explicit-spec1.C: New test.

4 years agoc++: missing dtor with -fno-elide-constructors [PR100838]
Jason Merrill [Mon, 31 May 2021 16:36:25 +0000 (12:36 -0400)] 
c++: missing dtor with -fno-elide-constructors [PR100838]

tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
clear it for nested calls in build_over_call, but in this case both
constructor calls came from convert_like, so we need to clear it in the
recursive call as well.  This revealed that we were adding an extra
ck_rvalue in direct-initialization cases where it was wrong.

For GCC 11, limit the changes to -fno-elide-constructors.

PR c++/100838

gcc/cp/ChangeLog:

* call.c (convert_like_internal): Clear tf_no_cleanup when
recursing.
(build_user_type_conversion_1): Only add ck_rvalue if
LOOKUP_ONLYCONVERTING.

gcc/testsuite/ChangeLog:

* g++.dg/init/no-elide2.C: New test.

4 years agoc++: argument pack with expansion [PR86355]
Jason Merrill [Wed, 26 May 2021 21:38:42 +0000 (17:38 -0400)] 
c++: argument pack with expansion [PR86355]

This testcase revealed that we were using PACK_EXPANSION_EXTRA_ARGS a lot
more than necessary; use_pack_expansion_extra_args_p meant to use it in the
case of corresponding arguments in different argument packs differing in
whether they are pack expansions, but it was mistakenly also returning true
for the case of a single argument pack containing both expansion and
non-expansion elements.

Surprisingly, just disabling that didn't lead to any regressions in the
testsuite; it seems other changes have prevented us getting to this point
for code that used to exercise it.  So this patch limits the check to
arguments in the same position in the packs, and asserts that we never
actually see a mismatch.

PR c++/86355

gcc/cp/ChangeLog:

* pt.c (use_pack_expansion_extra_args_p): Don't compare
args from the same argument pack.

gcc/testsuite/ChangeLog:

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

4 years agoMissing piece in earlier change
Eric Botcazou [Fri, 9 Jul 2021 16:30:54 +0000 (18:30 +0200)] 
Missing piece in earlier change

gcc/ada/
* gcc-interface/utils.c (finish_subprog_decl): Remove obsolete line.

4 years agoipa-sra: Fix thinko when overriding safe_to_import_accesses (PR 101066)
Martin Jambor [Fri, 9 Jul 2021 14:09:53 +0000 (16:09 +0200)] 
ipa-sra: Fix thinko when overriding safe_to_import_accesses (PR 101066)

The "new" IPA-SRA has a more difficult job than the previous
not-truly-IPA version when identifying situations in which a parameter
passed by reference can be passed into a third function and only thee
converted to one passed by value (and possibly "split" at the same
time).

In order to allow this, two conditions must be fulfilled.  First the
call to the third function must happen before any modifications of
memory, because it could change the value passed by reference.
Second, in order to make sure we do not introduce new (invalid)
dereferences, the call must postdominate the entry BB.

The second condition is actually not necessary if the caller function
is also certain to dereference the pointer but the first one must
still hold.  Unfortunately, the code making this overriding decision
also happen to trigger when the first condition is not fulfilled.
This is fixed in the following patch.

gcc/ChangeLog:

2021-06-16  Martin Jambor  <mjambor@suse.cz>

PR ipa/101066
* ipa-sra.c (class isra_call_summary): New member
m_before_any_store, initialize it in the constructor.
(isra_call_summary::dump): Dump the new field.
(ipa_sra_call_summaries::duplicate): Copy it.
(process_scan_results): Set it.
(isra_write_edge_summary): Stream it.
(isra_read_edge_summary): Likewise.
(param_splitting_across_edge): Only override
safe_to_import_accesses if m_before_any_store is set.

gcc/testsuite/ChangeLog:

2021-06-16  Martin Jambor  <mjambor@suse.cz>

PR ipa/101066
* gcc.dg/ipa/pr101066.c: New test.

(cherry picked from commit 763121ccd908f52bc666f277ea2cf42110b3aad9)

4 years agoFix build failure on Windows with older binutils
Eric Botcazou [Fri, 9 Jul 2021 10:08:52 +0000 (12:08 +0200)] 
Fix build failure on Windows with older binutils

This is the build failure on Windows with binutils for which GNU as accepts
the --gdwarf-5 switch but GNU ld generates broken binaries with DWARF 5.

We already have the HAVE_LD_BROKEN_PE_DWARF5 kludge to disable DWARF 5 in
this case but it only tames the DWARF version in the compiler, so the
driver still passes --gdwarf-5 when invoked on an assembly file with -g.

gcc/
PR target/101377
* gcc.c (ASM_DEBUG_DWARF_OPTION): Set again to --gdwarf2 in
the case where HAVE_AS_WORKING_DWARF_N_FLAG is not defined
and HAVE_LD_BROKEN_PE_DWARF5 is defined.

4 years agoDaily bump.
GCC Administrator [Fri, 9 Jul 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: Fix noexcept with unevaluated operand [PR101087]
Marek Polacek [Thu, 8 Jul 2021 00:02:18 +0000 (20:02 -0400)] 
c++: Fix noexcept with unevaluated operand [PR101087]

It sounds plausible that this assert

  int f();
  static_assert(noexcept(sizeof(f())));

should pass: sizeof produces a std::size_t and its operand is not
evaluated, so it can't throw.  noexcept should only evaluate to
false for potentially evaluated operands.  Therefore I think that
check_noexcept_r shouldn't walk into operands of sizeof/decltype/
alignof/typeof.

PR c++/101087

gcc/cp/ChangeLog:

* cp-tree.h (unevaluated_p): New.
* except.c (check_noexcept_r): Use it.  Don't walk into
unevaluated operands.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit dee00bf6894be0cabb8f263c993357a6f8444f8b)

4 years agoDo not replace variable op variable in I/O implied DO loop replacement.
Thomas Koenig [Tue, 6 Jul 2021 05:04:09 +0000 (07:04 +0200)] 
Do not replace variable op variable in I/O implied DO loop replacement.

This PR came about because index expressions of the form k+k in
implied DO loops in I/O statements were considered for replacement
by array slices.

Fixed by only doing the transformation if the expression is of the
type expr OP contastant.

gcc/fortran/ChangeLog:

PR fortran/100227
* frontend-passes.c (traverse_io_block): Adjust test for
when a variable is eligible for the transformation to
array slice.

gcc/testsuite/ChangeLog:

PR fortran/100227
* gfortran.dg/implied_do_io_7.f90: New test.

(cherry picked from commit d7e3855d5dd8c001bb65dc7da1cda0249bfc2986)

4 years agofixincludes: AIX socket.h.
Clément Chigot [Mon, 5 Jul 2021 15:19:44 +0000 (11:19 -0400)] 
fixincludes: AIX socket.h.

Add more context to aix_externcpp1 selection to ensure
that the fix is correctly applied even in future AIX versions.

fixincludes/Changelog:
2021-07-01  Clément Chigot  <clement.chigot@atos.net>

* inclhack.def (aix_externcpp1): Improve select regexp.
* fixincl.x: Regenerate.
* tests/base/sys/socket.h: Update.

(cherry picked from commit 03b634c8e0d3e8628ced79fc4f40873e12a3039c)

4 years agoDaily bump.
GCC Administrator [Thu, 8 Jul 2021 00:18:04 +0000 (00:18 +0000)] 
Daily bump.

4 years agoRevert "c++: Improve init handling"
Jason Merrill [Wed, 7 Jul 2021 21:57:40 +0000 (17:57 -0400)] 
Revert "c++: Improve init handling"

Apparently looking through these codes means that in a template, we end up
feeding a TARGET_EXPR to fold_non_dependent_expr, which should never
happen.  This is a broader issue, but for now let's just revert the change.

This reverts commit d9288bd28e24c755a7216311ee5247e7c88270a6.

PR c++/101072

gcc/cp/ChangeLog:

* decl.c (check_initializer): Don't look through STMT_EXPR and
BIND_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty14.C: Add -fno-elide-constructors.

4 years agoc++: constexpr aggr init of empty class [PR101040]
Jason Merrill [Thu, 24 Jun 2021 21:32:02 +0000 (17:32 -0400)] 
c++: constexpr aggr init of empty class [PR101040]

This is basically the aggregate initializer version of PR97566; as in that
bug, we are trying to initialize empty field 'obj' in 'single' when there's
no CONSTRUCTOR entry for the 'single' base class subobject of 'derived'.  As
with that bug, the fix is to stop trying to add entries for empty fields,
this time in cxx_eval_bare_aggregate.

The change to the other function isn't necessary for this version of
the patch, but seems worthwhile for robustness anyway.

PR c++/101040
PR c++/97566

gcc/cp/ChangeLog:

* class.c (is_empty_field): Handle null argument.
* constexpr.c (cxx_eval_bare_aggregate): Discard initializer
for empty field.

gcc/testsuite/ChangeLog:

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

4 years agors6000: Harden mma_init_builtins
Peter Bergner [Wed, 7 Jul 2021 16:39:34 +0000 (11:39 -0500)] 
rs6000: Harden mma_init_builtins

The previous MMA patch added some fragile code to initialize its new
built-ins.  This patch hardens the initialization.

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

gcc/
* config/rs6000/rs6000-call.c (mma_init_builtins): Use VSX_BUILTIN_LXVP
and VSX_BUILTIN_STXVP.

(cherry picked from commit 6278065af07634278ba30029d92a82b089969baa)

4 years agors6000: Add MMA __builtin_vsx_lxvp and __builtin_vsx_stxvp built-ins
Peter Bergner [Fri, 2 Jul 2021 16:27:52 +0000 (11:27 -0500)] 
rs6000: Add MMA __builtin_vsx_lxvp and __builtin_vsx_stxvp built-ins

Add support for the __builtin_vsx_lxvp and __builtin_vsx_stxvp built-ins
to keep in sync with LLVM which added these earlier.

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

gcc/
* config/rs6000/rs6000-builtin.def (BU_MMA_PAIR_LD, BU_MMA_PAIR_ST):
New macros.
(__builtin_vsx_lxvp, __builtin_vsx_stxvp): New built-ins.
* config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin): Expand
lxvp and stxvp built-ins.
(mma_init_builtins): Handle lxvp and stxvp built-ins.
(builtin_function_type): Likewise.
* doc/extend.texi (__builtin_vsx_lxvp, __builtin_mma_stxvp): Document.

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

(cherry picked from commit 42a9e4e1381ba14d8ef21b331494945c2f51e6be)

4 years agoBackport IEEE 128-bit min/max code.
Michael Meissner [Wed, 7 Jul 2021 16:01:37 +0000 (12:01 -0400)] 
Backport IEEE 128-bit min/max code.

This patch back ports 2 IEEE 128-bit min/max patches from the trunk to GCC
11.  One patch is from June 30th, 2021, and the other from July 1st, 2021.

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

gcc/
* config/rs6000/rs6000.c (rs6000_maybe_emit_fp_cmove): Add IEEE
128-bit floating point conditional move support.
(have_compare_and_set_mask): Add IEEE 128-bit floating point
types.
* config/rs6000/rs6000.md (mov<mode>cc, IEEE128 iterator): New insn.
(mov<mode>cc_p10, IEEE128 iterator): New insn.
(mov<mode>cc_invert_p10, IEEE128 iterator): New insn.
(fpmask<mode>, IEEE128 iterator): New insn.
(xxsel<mode>, IEEE128 iterator): New insn.

Backported from master:
    2021-07-01 Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
* gcc.target/powerpc/float128-cmove.c: New test.
* gcc.target/powerpc/float128-minmax-3.c: New test.

Backported from master:
    2021-07-01 Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
* gcc.target/powerpc/float128-minmax.c: Adjust expected code for
power10.
* lib/target-supports.exp (check_effective_target_has_arch_pwr10):
New.

Backported from master:
    2021-06-30 Michael Meissner  <meissner@linux.ibm.com>

4 years agotree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs
Richard Biener [Mon, 28 Jun 2021 09:05:46 +0000 (11:05 +0200)] 
tree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs

This fixes the missing handling of PHIs in gimple_walk_op which causes
the new vectorizer SLP hybrid detection scheme to fail.

2021-06-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101229
* gimple-walk.c (gimple_walk_op): Handle PHIs.

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

(cherry picked from commit f80c4eaca0805bc9e68ed944519519c3dd1c12e1)

4 years agotree-optimization/101173 - fix interchange dependence checking
Richard Biener [Wed, 23 Jun 2021 07:59:28 +0000 (09:59 +0200)] 
tree-optimization/101173 - fix interchange dependence checking

This adjusts the loop interchange dependence checking to properly
guard all dependence checks with DDR_REVERSED_P or its inverse.

2021-07-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101173
PR tree-optimization/101280
* gimple-loop-interchange.cc
(tree_loop_interchange::valid_data_dependences): Properly
guard all dependence checks with DDR_REVERSED_P or its
inverse.

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

4 years agomiddle-end/101156 - remove not working optimization in gimplification
Richard Biener [Tue, 22 Jun 2021 10:13:44 +0000 (12:13 +0200)] 
middle-end/101156 - remove not working optimization in gimplification

This removes a premature and not working optimization from the
gimplifier.  When gimplification is requested not to produce a SSA
name we try to avoid generating a copy when we did so anyway but
instead replace the LHS of its definition.  But that only works in
case there are no uses of the SSA name already which is something
we cannot easily check, so the following removes said optimization.

Statistics on the whole bootstrap shows we hit this optimization
only for libiberty/cp-demangle.c and overall we have 21652112
gimplifications where just 240 copies are elided.  Preserving
the optimization would require scanning the original expression
and the pre and post sequences for SSA names and uses, that seems
excessive to avoid these 240 copies.

2021-06-22  Richard Biener  <rguenther@suse.de>

PR middle-end/101156
* gimplify.c (gimplify_expr): Remove premature incorrect
optimization.

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

(cherry picked from commit b4e21c80462682c4e6e5e487fe87107b27f8b4bd)

4 years agotree-optimization/100923 - fix alias-ref construction wrt availability
Richard Biener [Tue, 8 Jun 2021 10:52:12 +0000 (12:52 +0200)] 
tree-optimization/100923 - fix alias-ref construction wrt availability

This PR shows that building an ao_ref from value-numbers is prone to
expose bogus contextual alias info to the oracle.  The following makes
sure to construct ao_refs from SSA names available at the program point
only.

On the way it modifies the awkward valueize_refs[_1] API.

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

PR tree-optimization/100923
* tree-ssa-sccvn.c (valueize_refs_1): Take a pointer to
the operand vector to be valueized.
(valueize_refs): Likewise.
(valueize_shared_reference_ops_from_ref): Adjust.
(valueize_shared_reference_ops_from_call): Likewise.
(vn_reference_lookup_3): Likewise.
(vn_reference_lookup_pieces): Likewise.  Re-valueize
with honoring availability when we are about to create
the ao_ref and valueized before.
(vn_reference_lookup): Likewise.
(vn_reference_insert_pieces): Adjust.

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

(cherry picked from commit 7a56d3d3e99cc77ad8a6a674870c814da6225675)

4 years agotree-optimization/101088 - fix SM invalidation issue
Richard Biener [Wed, 16 Jun 2021 07:49:18 +0000 (09:49 +0200)] 
tree-optimization/101088 - fix SM invalidation issue

When we face a sm_ord vs sm_unord for the same ref during
store sequence merging we assert that the ref is already marked
unsupported.  But it can be that it will only be marked so
during the ongoing merging so instead of asserting mark it here.

Also apply some optimization to not waste resources to search
for already unsupported refs.

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

PR tree-optimization/101088
* tree-ssa-loop-im.c (sm_seq_valid_bb): Only look for
supported refs on edges.  Do not assert same ref but
different kind stores are unsuported but mark them so.
(hoist_memory_references): Only look for supported refs
on exits.

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

(cherry picked from commit 43fc4234ad3d9302d3460385b6fdb5e3f59b6986)

4 years agotree-optimization/101025 - fix store-motion dependence checking
Richard Biener [Fri, 11 Jun 2021 10:06:08 +0000 (12:06 +0200)] 
tree-optimization/101025 - fix store-motion dependence checking

This plugs a hole in store-motion where it fails to perform dependence
checking on conditionally executed but not store-motioned refs.

2021-06-11  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101025
* tree-ssa-loop-im.c (sm_seq_valid_bb): Make sure to process
all refs that require dependence checking.

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

(cherry picked from commit b8b80b8aa3d9a7abbcb59b651ea5e84c2ea12d0b)

4 years agoDaily bump.
GCC Administrator [Wed, 7 Jul 2021 00:18:52 +0000 (00:18 +0000)] 
Daily bump.

4 years agoaix: Power10 assembler invocation.
Clément Chigot [Thu, 10 Jun 2021 02:00:55 +0000 (22:00 -0400)] 
aix: Power10 assembler invocation.

gcc/ChangeLog:

2021-06-09  Clement Chigot  <clement.chigot@atos.net>

* config/rs6000/aix71.h (ASM_CPU_SPEC): Add Power10 directive.
* config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.

(cherry picked from commit f8b067056ba5dd53f7bc883a1f59833efc26bd3e)

4 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.

(cherry picked from commit 5a3bf28119c7a8d2d43d26b5eee588ee0e4472e5)

4 years agoDaily bump.
GCC Administrator [Tue, 6 Jul 2021 00:18:24 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Mon, 5 Jul 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 4 Jul 2021 00:18:00 +0000 (00:18 +0000)] 
Daily bump.

4 years agod: Missed RVO optimization with non-POD structs
Iain Buclaw [Sat, 3 Jul 2021 00:42:14 +0000 (02:42 +0200)] 
d: Missed RVO optimization with non-POD structs

The D front-end semantic pass sometimes declares a temporary inside a
return expression.  This is now detected with the RESULT_DECL replacing
the temporary, allowing for RVO to be done.

PR d/101273

gcc/d/ChangeLog:

* toir.cc (IRVisitor::visit (ReturnStatement *)): Detect returns that
use a temporary, and replace with return value.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr101273.d: New test.

(cherry picked from commit 152f4d0e4d3b524ce30d05f20e23a44b0dd29765)

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

4 years agod: RHS value lost when a target_expr modifies LHS in a cond_expr
Iain Buclaw [Fri, 2 Jul 2021 22:13:29 +0000 (00:13 +0200)] 
d: RHS value lost when a target_expr modifies LHS in a cond_expr

To prevent the RHS of an assignment modifying the LHS before the
assignment proper, a target_expr is forced so that function calls that
return with slot optimization modify the temporary instead.  This did
not work for conditional expressions however, to give one example.  So
now the RHS is always forced to a temporary.

PR d/101282

gcc/d/ChangeLog:

* d-codegen.cc (build_assign): Force target_expr on RHS for non-POD
assignment expressions.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr101282.d: New test.

(cherry picked from commit c77230856eac2d28eb7bf10985846885c3c8727b)

4 years agojit: fix test-vector-* failures
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
jit: fix test-vector-* failures

Fix failures seen on i686 due to relying on exact floating-point
equality when testing results of vector division.

gcc/testsuite/ChangeLog:
* jit.dg/test-vector-rvalues.cc (check_div): Add specialization
for v4f, to avoid relying on exact floating-point equality.
* jit.dg/test-vector-types.cc (check_div): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agojit: fix test-asm failures on i?86
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
jit: fix test-asm failures on i?86

On i686, test_i386_basic_asm_4 has:
  error: inconsistent operand constraints in an 'asm'
and test_i386_basic_asm_5 has:
  /tmp/libgccjit-9FsLie/fake.s:9: Error: bad register name `%rdi'
  /tmp/libgccjit-9FsLie/fake.s:10: Error: bad register name `%rsi'

This is only intended as a smoketest of asm support, so only run
it on x86_64.

gcc/testsuite/ChangeLog:
* jit.dg/test-asm.c: Remove i?86-*-* from target specifier.
* jit.dg/test-asm.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix issue with symbolic reads with concrete bindings
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
analyzer: fix issue with symbolic reads with concrete bindings

gcc/analyzer/ChangeLog:
* store.cc (binding_cluster::get_any_binding): Make symbolic reads
from a cluster with concrete bindings return unknown.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/symbolic-7.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: add region_model_manager::get_or_create_int_cst
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
analyzer: add region_model_manager::get_or_create_int_cst

gcc/analyzer/ChangeLog:
* region-model-manager.cc
(region_model_manager::get_or_create_int_cst): New.
(region_model_manager::maybe_undo_optimize_bit_field_compare): Use
it to simplify away a local tree.
* region-model.cc (region_model::on_setjmp): Likewise.
(region_model::on_longjmp): Likewise.
* region-model.h (region_model_manager::get_or_create_int_cst):
New decl.
* store.cc (binding_cluster::zero_fill_region): Use it to simplify
away a local tree.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix bitfield endianness issues [PR99212,PR101082]
David Malcolm [Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)] 
analyzer: fix bitfield endianness issues [PR99212,PR101082]

Looks like my patch for PR analyzer/99212 implicitly assumed
little-endian, which the following patch fixes.

Fixes bitfields-1.c on:
- armeb-none-linux-gnueabihf
- cris-elf
- powerpc64-darwin
- s390-linux-gnu

gcc/analyzer/ChangeLog:
PR analyzer/99212
PR analyzer/101082
* engine.cc: Include "target.h".
(impl_run_checkers): Log BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and
WORDS_BIG_ENDIAN.
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Move support for masking
via ARG0 & CST into...
(region_model_manager::maybe_undo_optimize_bit_field_compare):
...this new function.  Flatten by converting from nested
conditionals to a series of early return statements to reject
failures.  Reject if type is not unsigned_char_type_node.
Handle BYTES_BIG_ENDIAN when determining which bits are bound
in the binding_map.
* region-model.h
(region_model_manager::maybe_undo_optimize_bit_field_compare):
New decl.
* store.cc (bit_range::dump): New function.
* store.h (bit_range::dump): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: tweak priority of callstrings in worklist::key_t::cmp
David Malcolm [Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)] 
analyzer: tweak priority of callstrings in worklist::key_t::cmp

While debugging another issue I noticed that the analyzer could fail to
merge nodes for control flow in which one path had called a function
and another path hadn't:

        BB
       /  \
      /    \
 fn call   no fn call
      \    /
       \  /
     join BB

The root cause was that the worklist sort function wasn't prioritizing
call strings, and thus it was fully exploring the "no function called"
path to the exit BB, and only then exploring the "within the function call"
parts of the "funcion called" path.

This patch prioritizes call strings when sorting the worklist so that
the nodes with deeper call strings are processed before those with shallower
call strings, thus allowing such nodes to be merged at the joinpoint.

gcc/analyzer/ChangeLog:
* engine.cc (worklist::key_t::cmp): Move sort by call_string to
before SCC.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c: Update
expected number of enodes after the loop.
* gcc.dg/analyzer/paths-8.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: make various region_model member functions const
David Malcolm [Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)] 
analyzer: make various region_model member functions const

gcc/analyzer/ChangeLog:
* region-model.cc (region_model::get_lvalue_1): Make const.
(region_model::get_lvalue): Likewise.
(region_model::get_rvalue_1): Likewise.
(region_model::get_rvalue): Likewise.
(region_model::deref_rvalue): Likewise.
(region_model::get_rvalue_for_bits): Likewise.
* region-model.h (region_model::get_lvalue): Likewise.
(region_model::get_rvalue): Likewise.
(region_model::deref_rvalue): Likewise.
(region_model::get_rvalue_for_bits): Likewise.
(region_model::get_lvalue_1): Likewise.
(region_model::get_rvalue_1): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: bitfield fixes [PR99212]
David Malcolm [Fri, 2 Jul 2021 19:19:45 +0000 (15:19 -0400)] 
analyzer: bitfield fixes [PR99212]

This patch verifies the previous fix for bitfield sizes by implementing
enough support for bitfields in the analyzer to get the test cases to pass.

The patch implements support in the analyzer for reading from a
BIT_FIELD_REF, and support for folding BIT_AND_EXPR of a mask, to handle
the cases generated in tests.

The existing bitfields tests in data-model-1.c turned out to rely on
undefined behavior, in that they were assigning values to a signed
bitfield that were outside of the valid range of values.  I believe that
that's why we were seeing target-specific differences in the test
results (PR analyzer/99212).  The patch updates the test to remove the
undefined behaviors.

gcc/analyzer/ChangeLog:
PR analyzer/99212
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Add support for folding
BIT_AND_EXPR of compound_svalue and a mask constant.
* region-model.cc (region_model::get_rvalue_1): Implement
BIT_FIELD_REF in terms of...
(region_model::get_rvalue_for_bits): New function.
* region-model.h (region_model::get_rvalue_for_bits): New decl.
* store.cc (bit_range::from_mask): New function.
(selftest::test_bit_range_intersects_p): New selftest.
(selftest::assert_bit_range_from_mask_eq): New.
(ASSERT_BIT_RANGE_FROM_MASK_EQ): New macro.
(selftest::assert_no_bit_range_from_mask_eq): New.
(ASSERT_NO_BIT_RANGE_FROM_MASK): New macro.
(selftest::test_bit_range_from_mask): New selftest.
(selftest::analyzer_store_cc_tests): Call the new selftests.
* store.h (bit_range::intersects_p): New.
(bit_range::from_mask): New decl.
(concrete_binding::get_bit_range): New accessor.
(store_manager::get_concrete_binding): New overload taking
const bit_range &.

gcc/testsuite/ChangeLog:
PR analyzer/99212
* gcc.dg/analyzer/bitfields-1.c: New test.
* gcc.dg/analyzer/data-model-1.c (struct sbits): Make bitfields
explicitly signed.
(test_44): Update test values assigned to the bits to ones that
fit in the range of the bitfield type.  Remove xfails.
(test_45): Remove xfails.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix region::get_bit_size for bitfields
David Malcolm [Fri, 2 Jul 2021 19:19:45 +0000 (15:19 -0400)] 
analyzer: fix region::get_bit_size for bitfields

gcc/analyzer/ChangeLog:
* analyzer.h (int_size_in_bits): New decl.
* region.cc (int_size_in_bits): New function.
(region::get_bit_size): Reimplement in terms of the above.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: split out struct bit_range from class concrete_binding
David Malcolm [Fri, 2 Jul 2021 19:19:45 +0000 (15:19 -0400)] 
analyzer: split out struct bit_range from class concrete_binding

gcc/analyzer/ChangeLog:
* store.cc (concrete_binding::dump_to_pp): Move bulk of
implementation to...
(bit_range::dump_to_pp): ...this new function.
(bit_range::cmp): New.
(concrete_binding::overlaps_p): Update for use of bit_range.
(concrete_binding::cmp_ptr_ptr): Likewise.
* store.h (struct bit_range): New.
(class concrete_binding): Replace fields m_start_bit_offset and
m_size_in_bits with new field m_bit_range.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: remove redundant typedef
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
analyzer: remove redundant typedef

Delete an overzealous copy&paste.

gcc/analyzer/ChangeLog:
* svalue.h (conjured_svalue::iterator_t): Delete.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: remove unused prototypes
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
analyzer: remove unused prototypes

gcc/analyzer/ChangeLog:
* store.h (store::get_direct_binding): Remove unused decl.
(store::get_default_binding): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: show types for poisoned_svalue and compound_svalue
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
analyzer: show types for poisoned_svalue and compound_svalue

gcc/analyzer/ChangeLog:
* svalue.cc (poisoned_svalue::dump_to_pp): Dump type.
(compound_svalue::dump_to_pp): Dump any type.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agodiagnostic-show-locus: tweak rejection logic
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
diagnostic-show-locus: tweak rejection logic

gcc/ChangeLog:
* diagnostic-show-locus.c (diagnostic_show_locus): Don't reject
printing the same location twice if there are fix-it hints,
multiple locations, or a label.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix missing leak after call to strsep [PR100615]
David Malcolm [Fri, 2 Jul 2021 19:19:43 +0000 (15:19 -0400)] 
analyzer: fix missing leak after call to strsep [PR100615]

PR analyzer/100615 reports a missing leak diagnostic.
The issue is that the code calls strsep which the analyzer doesn't
have special knowledge of, and so conservatively assumes that it
could free the pointer, so drops malloc state for it.

Properly "teaching" the analyzer about strsep would require it
to support bifurcating state at a call, which is currently fiddly to
do, so for now this patch notes that strsep doesn't affect the
malloc state machine, allowing the analyzer to correctly detect the leak.

gcc/analyzer/ChangeLog:
PR analyzer/100615
* sm-malloc.cc: Include "analyzer/function-set.h".
(malloc_state_machine::on_stmt): Call unaffected_by_call_p and
bail on the functions it recognizes.
(malloc_state_machine::unaffected_by_call_p): New.

gcc/testsuite/ChangeLog:
PR analyzer/100615
* gcc.dg/analyzer/pr100615.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix ICE on NULL change.m_expr [PR100244]
David Malcolm [Fri, 2 Jul 2021 19:19:43 +0000 (15:19 -0400)] 
analyzer: fix ICE on NULL change.m_expr [PR100244]

PR analyzer/100244 reports an ICE on a -Wanalyzer-free-of-non-heap
due to a case where free_of_non_heap::describe_state_change can be
passed a NULL change.m_expr for a suitably complicated symbolic value.

Bulletproof it by checking for change.m_expr being NULL before
dereferencing it.

gcc/analyzer/ChangeLog:
PR analyzer/100244
* sm-malloc.cc (free_of_non_heap::describe_state_change):
Bulletproof against change.m_expr being NULL.

gcc/testsuite/ChangeLog:
PR analyzer/100244
* g++.dg/analyzer/pr100244.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoChange EH pointer encodings to PC relative on Windows
Eric Botcazou [Fri, 2 Jul 2021 08:21:11 +0000 (10:21 +0200)] 
Change EH pointer encodings to PC relative on Windows

A big difference between ELF and PE-COFF is that, with the latter, you can
build position-independent executables or DLLs without generating PIC; as
a  matter of fact, flag_pic has historically been forced to 0 for 32-bit:

/* Don't allow flag_pic to propagate since gas may produce invalid code
   otherwise.  */

\
do {
        \
  flag_pic = TARGET_64BIT ? 1 : 0; \
} while (0)

The reason is that the linker builds a .reloc section that collects the
absolute relocations in the generated binary, and the loader uses them to
relocate it at load time if need be (e.g. if --dynamicbase is enabled).

Up to binutils 2.35, the GNU linker didn't build the .reloc section for
executables and defaulted to --enable-auto-image-base for DLLs, which means
that DLLs had an essentially unique load address and, therefore, need not
be relocated by the loader in most cases.

With binutils 2.36 and later, the GNU linker builds a .reloc section for
executables (thus making them PIE), --enable-auto-image-base is disabled
and --dynamicbase is enabled by default, which means that essentially all
the binaries are relocated at load time.

This badly breaks the 32-bit compiler configured to use DWARF-2 EH because
the loader corrupts the .eh_frame section when processing the relocations
contained in the .reloc section.

gcc/
* config/i386/i386.c (asm_preferred_eh_data_format): Always use the
PIC encodings for PE-COFF targets.

4 years agoDaily bump.
GCC Administrator [Fri, 2 Jul 2021 00:18:20 +0000 (00:18 +0000)] 
Daily bump.

4 years agoUse intermediate integer type with proper signedness
Eric Botcazou [Thu, 1 Jul 2021 15:57:16 +0000 (17:57 +0200)] 
Use intermediate integer type with proper signedness

This is a minor regression present on mainline and 11 branch, whereby the
value of the Enum_Rep attribute is always unsigned.

gcc/ada/
PR ada/101094
* exp_attr.adb (Get_Integer_Type): Return an integer type with the
same signedness as the input type.

4 years agoDaily bump.
GCC Administrator [Thu, 1 Jul 2021 00:18:16 +0000 (00:18 +0000)] 
Daily bump.

4 years agoUpdate Power10 scheduling description for new fused instruction types.
Pat Haugen [Wed, 30 Jun 2021 14:54:37 +0000 (09:54 -0500)] 
Update Power10 scheduling description for new fused instruction types.

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

gcc/ChangeLog:
* config/rs6000/power10.md (power10-fused-load, power10-fused-store,
power10-fused_alu, power10-fused-vec, power10-fused-branch): New.

4 years agoDaily bump.
GCC Administrator [Wed, 30 Jun 2021 00:18:23 +0000 (00:18 +0000)] 
Daily bump.

4 years agocompiler: in composite literals use temps only for interfaces
Ian Lance Taylor [Tue, 29 Jun 2021 18:00:13 +0000 (11:00 -0700)] 
compiler: in composite literals use temps only for interfaces

For a composite literal we only need to introduce a temporary variable
if we may be converting to an interface type, so only do it then.
This saves over 80% of compilation time when using gccgo to compile
cmd/internal/obj/x86, as the GCC middle-end spends a lot of time
pointlessly computing interactions between temporary variables.

For PR debug/101064
For golang/go#46600

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

4 years agoc++: Failure to delay noexcept parsing with ptr-operator [PR100752]
Marek Polacek [Tue, 8 Jun 2021 21:44:13 +0000 (17:44 -0400)] 
c++: Failure to delay noexcept parsing with ptr-operator [PR100752]

We weren't passing 'flags' to the recursive call to cp_parser_declarator
in the ptr-operator case and as an effect, delayed parsing of noexcept
didn't work as advertised.  The following change passes more than just
CP_PARSER_FLAGS_DELAY_NOEXCEPT but that doesn't seem to break anything.

I'm now also passing member_p and static_p, as a consequence, two tests
needed small tweaks.

PR c++/100752

gcc/cp/ChangeLog:

* parser.c (cp_parser_declarator): Pass flags down to
cp_parser_declarator.  Also pass static_p/member_p.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept69.C: New test.
* g++.dg/parse/saved1.C: Adjust dg-error.
* g++.dg/template/crash50.C: Likewise.

(cherry picked from commit f9c80eb12c58126a94ad869380af5b88b752c06f)

4 years agors6000: Fix typos in float128 ISA3.1 support
Kewen Lin [Wed, 23 Jun 2021 04:09:30 +0000 (23:09 -0500)] 
rs6000: Fix typos in float128 ISA3.1 support

The recent float128 ISA3.1 support (r12-1340) has some typos,
it makes the libgcc build fail if it's with one binutils
(assembler) which doesn't support Power10 insns.  The error
looks like:

Error: invalid switch -mpower10
Error: unrecognized option -mpower10
... [...libgcc/shared-object.mk:14: float128-p10.o] Error 1

What this patch does are:
  - fix test target typo libgcc_cv_powerpc_3_1_float128_hw
    (written wrongly as libgcc_cv_powerpc_float128_hw, so it's
     going to build ISA3.1 stuffs just when detecting ISA3.0).
  - fix test used for libgcc_cv_powerpc_3_1_float128_hw check.
  - fix test option used for libgcc_cv_powerpc_3_1_float128_hw
    check.
  - remove the ISA3.1 related contents from t-float128-hw.
  - add new macro FLOAT128_HW_INSNS_ISA3_1 to differentiate
    ISA3.1 content from ISA3.0 part in ifunc support.

Bootstrapped/regtested on:
  - powerpc64le-linux-gnu P10
  - powerpc64le-linux-gnu P9 (w/i and w/o p10 supported as)
  - powerpc64-linux-gnu P8 (w/i and w/o p10 supported as)

libgcc/ChangeLog:

PR target/101235
* configure: Regenerate.
* configure.ac (test for libgcc_cv_powerpc_3_1_float128_hw): Fix
typos among the name, CFLAGS and the test.
* config/rs6000/t-float128-hw (fp128_3_1_hw_funcs, fp128_3_1_hw_src,
fp128_3_1_hw_static_obj, fp128_3_1_hw_shared_obj, fp128_3_1_hw_obj):
Remove.
* config/rs6000/t-float128-p10-hw (FLOAT128_HW_INSNS): Append
macro FLOAT128_HW_INSNS_ISA3_1.
(FP128_3_1_CFLAGS_HW): Fix option typo.
* config/rs6000/float128-ifunc.c (SW_OR_HW_ISA3_1): Guard this with
FLOAT128_HW_INSNS_ISA3_1.
(__floattikf_resolve): Likewise.
(__floatuntikf_resolve): Likewise.
(__fixkfti_resolve): Likewise.
(__fixunskfti_resolve): Likewise.
(__floattikf): Likewise.
(__floatuntikf): Likewise.
(__fixkfti): Likewise.
(__fixunskfti): Likewise.

(cherry picked from commit 47749c43acb460ac8f410ee599616d1860ee5a35)

4 years agoDaily bump.
GCC Administrator [Tue, 29 Jun 2021 00:18:12 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Mon, 28 Jun 2021 00:18:00 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 27 Jun 2021 00:17:59 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 26 Jun 2021 00:18:20 +0000 (00:18 +0000)] 
Daily bump.

4 years agoFix SLP permute propagation error
Richard Biener [Thu, 24 Jun 2021 08:47:18 +0000 (10:47 +0200)] 
Fix SLP permute propagation error

This fixes SLP permute propagation to not propagate across operations
that have different semantics on different lanes like for example
the recently added COMPLEX_ADD_ROT90.

2021-06-24  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_optimize_slp): Do not propagate
across operations that have different semantics on different
lanes.

4 years agotree-optimization/101158 - adjust SLP call matching sequence
Richard Biener [Tue, 22 Jun 2021 07:24:24 +0000 (09:24 +0200)] 
tree-optimization/101158 - adjust SLP call matching sequence

This moves the check for same operands after verifying we're
facing compatible calls.

2021-06-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101158
* tree-vect-slp.c (vect_build_slp_tree_1): Move same operand
checking after checking for matching operation.

* gfortran.dg/pr101158.f90: New testcase.

(cherry picked from commit 7a22d8a764418265680a6bb9a9aec31e984eb015)

4 years agotree-optimization/101151 - fix irreducible region check for sinking
Richard Biener [Tue, 22 Jun 2021 08:14:02 +0000 (10:14 +0200)] 
tree-optimization/101151 - fix irreducible region check for sinking

The check whether two blocks are in the same irreducible region
and thus post-dominance checks being unreliable was incomplete
since an irreducible region can contain reducible sub-regions but
if one block is in the irreducible part and one not the check
still doesn't work as expected.

2021-06-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101151
* tree-ssa-sink.c (statement_sink_location): Expand irreducible
region check.

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

(cherry picked from commit a2ef8395fa970498985764514044e5fd00f7d5c0)

4 years agotree-optimization/101105 - fix runtime alias test optimization
Richard Biener [Wed, 23 Jun 2021 10:43:03 +0000 (12:43 +0200)] 
tree-optimization/101105 - fix runtime alias test optimization

We were ignoring DR_STEP for VF == 1 which is OK only in case
the scalar order is preserved or both DR steps are the same.

2021-06-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101105
* tree-vect-data-refs.c (vect_prune_runtime_alias_test_list):
Only ignore steps when they are equal or scalar order is preserved.

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

(cherry picked from commit 50374fdacbd121bc4a61b073e559208ff61bee06)

4 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.

(cherry picked from commit 8d51039cb7c807ed84ff7df5416a1e3ba07a5e63)

4 years agoDaily bump.
GCC Administrator [Fri, 25 Jun 2021 00:18:34 +0000 (00:18 +0000)] 
Daily bump.

4 years agoEmit .file 0 directive earlier in DWARF 5
Eric Botcazou [Thu, 24 Jun 2021 10:55:27 +0000 (12:55 +0200)] 
Emit .file 0 directive earlier in DWARF 5

When the assembler supports it, the compiler automatically passes --gdwarf-5
to it, which has an interesting side effect: any assembly instruction prior
to the first .file directive defines a new line associated with .file 0 in
the .debug_line section and of course the numbering of these implicit lines
has nothing to do with that of the source code.  This can be problematic in
Ada when we do not generate .file/.loc directives for compiled-generated
functions to avoid too jumpy a debugging experience.

gcc/
* dwarf2out.c (dwarf2out_assembly_start): Emit .file 0 marker here..
(dwarf2out_finish): ...instead of here.

4 years agoFix --gdwarf-5 configure tests for Windows
Eric Botcazou [Thu, 24 Jun 2021 10:53:24 +0000 (12:53 +0200)] 
Fix --gdwarf-5 configure tests for Windows

The issues are that 1) they use readelf instead of objdump and 2) they use
ELF syntax in the assembly code.

gcc/
* configure.ac (--gdwarf-5 option): Use objdump instead of readelf.
(working --gdwarf-4/--gdwarf-5 for all sources): Likewise.
(--gdwarf-4 not refusing generated .debug_line): Adjust for Windows.
* configure: Regenerate.

4 years agoFortran: fix sm computation in CFI_allocate [PR93524]
Sandra Loosemore [Tue, 22 Jun 2021 19:42:17 +0000 (12:42 -0700)] 
Fortran: fix sm computation in CFI_allocate [PR93524]

Backported from trunk.

This patch fixes a bug in setting the step multiplier field in the
C descriptor for array dimensions > 2.

2021-06-21  Sandra Loosemore  <sandra@codesourcery.com>
    Tobias Burnus  <tobias@codesourcery.com>

libgfortran/
PR fortran/93524
* runtime/ISO_Fortran_binding.c (CFI_allocate): Fix
sm computation.

gcc/testsuite/
PR fortran/93524
* gfortran.dg/pr93524.c: New.
* gfortran.dg/pr93524.f90: New.

4 years agoDaily bump.
GCC Administrator [Thu, 24 Jun 2021 00:18:21 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDo not enable pcrel-opt by default
Aaron Sawdey [Tue, 22 Jun 2021 21:02:15 +0000 (16:02 -0500)] 
Do not enable pcrel-opt by default

Backported from trunk.

SPEC2017 testing on p10 shows that this optimization does not have a
positive impact on performance. So we are no longer going to enable it
by default. The test cases for it needed to be updated so they always
enable it to test it.

gcc/

* config/rs6000/rs6000-cpus.def: Take OPTION_MASK_PCREL_OPT out
of OTHER_POWER10_MASKS so it will not be enabled by default.

gcc/testsuite/

* gcc.target/powerpc/pcrel-opt-inc-di.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-ld-df.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-ld-di.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-ld-hi.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-ld-qi.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-ld-sf.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-ld-si.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-ld-vector.c: Enable -mpcrel-opt to
test it.
* gcc.target/powerpc/pcrel-opt-st-df.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-st-di.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-st-hi.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-st-qi.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-st-sf.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-st-si.c: Enable -mpcrel-opt to test it.
* gcc.target/powerpc/pcrel-opt-st-vector.c: Enable -mpcrel-opt to
test it.

(cherry picked from commit b7574ca6edb5ac7fab741f46d4f50ac4294c8180)

4 years agoBackport patch from master branch.
Michael Meissner [Wed, 23 Jun 2021 19:00:16 +0000 (15:00 -0400)] 
Backport patch from master branch.

Add IEEE 128-bit min/max support on PowerPC.

This patch adds the support for the IEEE 128-bit floating point C minimum and
maximum instructions.  The next patch will add the support for using the
compare and set mask instruction to implement conditional moves.

This patch does not try to re-use the code used for SF/DF min/max
support.  It defines a separate insn for the IEEE 128-bit support.  It
uses the code iterator <minmax> to simplify adding both operations.

GCC will not convert ternary operations into using min/max instructions
provided in this patch unless the user uses -Ofast.  The next patch that adds
conditional move instructions will enable the ternary conversion in many cases.

gcc/
2021-06-23  Michael Meissner  <meissner@linux.ibm.com>

* config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
3.1 IEEE 128-bit floating point xsmaxcqp/xsmincqp instructions.
* config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
New insns.

gcc/testsuite/
2021-06-23  Michael Meissner  <meissner@linux.ibm.com>

* gcc.target/powerpc/float128-minmax-2.c: New test.

4 years agoi386: Prevent unwanted combine from LZCNT to BSR [PR101175]
Uros Bizjak [Wed, 23 Jun 2021 10:50:53 +0000 (12:50 +0200)] 
i386: Prevent unwanted combine from LZCNT to BSR [PR101175]

The current RTX pattern for BSR allows combine pass to convert LZCNT insn
to BSR. Note that the LZCNT has a defined behavior to return the operand
size when operand is zero, where BSR has not.

Add a BSR specific setting of zero-flag to RTX pattern of BSR insn
in order to avoid matching unwanted combinations.

2021-06-23  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/101175
* config/i386/i386.md (bsr_rex64): Add zero-flag setting RTX.
(bsr): Ditto.
(*bsrhi): Remove.
(clz<mode>2): Update RTX pattern for additions.

gcc/testsuite/

PR target/101175
* gcc.target/i386/pr101175.c: New test.

(cherry picked from commit 1e16f2b472c7d253d564556a048dc4ae16119c00)

4 years agoopenmp: Fix up *_reduction clause handling with UDRs on PARM_DECLs [PR101167]
Jakub Jelinek [Wed, 23 Jun 2021 08:03:28 +0000 (10:03 +0200)] 
openmp: Fix up *_reduction clause handling with UDRs on PARM_DECLs [PR101167]

The following testcase FAILs, because the UDR combiner is invoked incorrectly.
lower_omp_rec_clauses expects that when it sets
DECL_VALUE_EXPR/DECL_HAS_VALUE_EXPR_P
for both the placeholder and the var that everything will be properly
regimplified, but as the variable in question is a PARM_DECL rather than
VAR_DECL, lower_omp_regimplify_p doesn't say that it should be regimplified
and so it is not.

2021-06-23  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/101167
* omp-low.c (lower_omp_regimplify_p): Regimplify also PARM_DECLs
and RESULT_DECLs that have DECL_HAS_VALUE_EXPR_P set.

* testsuite/libgomp.c-c++-common/task-reduction-15.c: New test.

(cherry picked from commit 679506c3830ea1a93c755413609bfac3538e2cbd)

4 years agoinline-asm: Fix ICE with bitfields in "m" operands [PR100785]
Jakub Jelinek [Mon, 21 Jun 2021 11:30:42 +0000 (13:30 +0200)] 
inline-asm: Fix ICE with bitfields in "m" operands [PR100785]

Bitfields, while they live in memory, aren't something inline-asm can easily
operate on.
For C and "=m" or "+m", we were diagnosing bitfields in the past in the
FE, where c_mark_addressable had:
      case COMPONENT_REF:
        if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
          {
            error
              ("cannot take address of bit-field %qD", TREE_OPERAND (x, 1));
            return false;
          }
but that check got moved in GCC 6 to build_unary_op instead and now we
emit an error during expansion and ICE afterwards (i.e. error-recovery).
For "m" it used to be diagnosed in c_mark_addressable too, but since
GCC 6 it is ice-on-invalid.
For C++, this was never diagnosed in the FE, but used to be diagnosed
in the gimplifier and/or during expansion before 4.8.

The following patch does multiple things:
1) diagnoses it in the FEs
2) simplifies during expansion the inline asm if any errors have been
   reported (similarly how e.g. vregs pass if it detects errors on
   inline-asm either deletes them or simplifies to bare minimum -
   just labels), so that we don't have error-recovery ICEs there

2021-06-11  Jakub Jelinek  <jakub@redhat.com>

PR inline-asm/100785
gcc/
* cfgexpand.c (expand_asm_stmt): If errors are emitted,
remove all inputs, outputs and clobbers from the asm and
set template to "".
gcc/c/
* c-typeck.c (c_mark_addressable): Diagnose trying to make
bit-fields addressable.
gcc/cp/
* typeck.c (cxx_mark_addressable): Diagnose trying to make
bit-fields addressable.
gcc/testsuite/
* c-c++-common/pr100785.c: New test.

(cherry picked from commit 644c2cc5f2c09506a7bfef293a7f90efa8d7e5fa)