Commit Graph

192862 Commits

Author SHA1 Message Date
Richard Biener
9f1e32c69d tree-optimization/105786 - avoid strlen replacement for pointers
This avoids matching strlen to a pointer result, avoiding ICEing
because of an integer adjustment using PLUS_EXPR on pointers.

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

	PR tree-optimization/105786
	* tree-loop-distribution.cc
	(loop_distribution::transform_reduction_loop): Only do strlen
	replacement for integer type reductions.

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

(cherry picked from commit 57a8fb92ac)
2022-06-02 10:14:04 +02:00
Richard Biener
9bc27ee76d tree-optimization/105726 - adjust array bound heuristic
There's heuristic to detect ptr[1].a[...] out of bound accesses
reasoning that if ptr points to an array of aggregates a trailing
incomplete array has to have size zero.  The following more
thoroughly constrains the cases this applies to avoid false
positive diagnostics.

2022-05-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105726
	* gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset):
	Constrain array-of-flexarray case more.

	* g++.dg/warn/Warray-bounds-27.C: New testcase.

(cherry picked from commit e7c482b080)
2022-06-02 10:13:49 +02:00
Richard Biener
cdd93e5b88 middle-end/105711 - properly handle CONST_INT when expanding bitfields
This is another place where we fail to pass down the mode of a
CONST_INT.

2022-05-24  Richard Biener  <rguenther@suse.de>

	PR middle-end/105711
	* expmed.cc (extract_bit_field_as_subreg): Add op0_mode parameter
	and use it.
	(extract_bit_field_1): Pass down the mode of op0 to
	extract_bit_field_as_subreg.

	* gcc.target/i386/pr105711.c: New testcase.

(cherry picked from commit 91c7c5edd2)
2022-06-02 10:13:28 +02:00
Martin Sebor
740771a620 PR middle-end/105604 - ICE: in tree_to_shwi with vla in struct and sprintf
gcc/ChangeLog:

	PR middle-end/105604
	* gimple-ssa-sprintf.cc (set_aggregate_size_and_offset): Add comments.
	(get_origin_and_offset_r): Remove null handling.  Handle variable array
	sizes.
	(get_origin_and_offset): Handle null argument here.  Simplify.
	(alias_offset): Update comment.
	* pointer-query.cc (field_at_offset): Update comment.  Handle members
	of variable-length types.

gcc/testsuite/ChangeLog:

	PR middle-end/105604
	* gcc.dg/Wrestrict-24.c: New test.
	* gcc.dg/Wrestrict-25.c: New test.
	* gcc.dg/Wrestrict-26.c: New test.

Co-authored-by: Richard Biener <rguenther@suse.de>
(cherry picked from commit 10d1986aee)
2022-06-02 10:13:10 +02:00
Vineet Gupta
e919fae01b RISC-V: Inhibit FP <--> int register moves via tune param
Under extreme register pressure, compiler can use FP <--> int
moves as a cheap alternate to spilling to memory.
This was seen with SPEC2017 FP benchmark 507.cactu:
ML_BSSN_Advect.cc:ML_BSSN_Advect_Body()

|	fmv.d.x	fa5,s9	# PDupwindNthSymm2Xt1, PDupwindNthSymm2Xt1
| .LVL325:
|	ld	s9,184(sp)		# _12469, %sfp
| ...
| .LVL339:
|	fmv.x.d	s4,fa5	# PDupwindNthSymm2Xt1, PDupwindNthSymm2Xt1
|

The FMV instructions could be costlier (than stack spill) on certain
micro-architectures, thus this needs to be a per-cpu tunable
(default being to inhibit on all existing RV cpus).

Testsuite run with new test reports 10 failures without the fix
corresponding to the build variations of pr105666.c

| 		=== gcc Summary ===
|
| # of expected passes		123318   (+10)
| # of unexpected failures	34       (-10)
| # of unexpected successes	4
| # of expected failures	780
| # of unresolved testcases	4
| # of unsupported tests	2796

gcc/ChangeLog:

	* config/riscv/riscv.cc: (struct riscv_tune_param): Add
	  fmv_cost.
	(rocket_tune_info): Add default fmv_cost 8.
	(sifive_7_tune_info): Ditto.
	(thead_c906_tune_info): Ditto.
	(optimize_size_tune_info): Ditto.
	(riscv_register_move_cost): Use fmv_cost for int<->fp moves.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/pr105666.c: New test.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
(cherry picked from commit b646d7d279)
2022-06-02 10:10:51 +08:00
GCC Administrator
682d238f32 Daily bump. 2022-06-02 00:19:00 +00:00
Jason Merrill
b090938e61 c++: auto and dependent member name [PR105734]
In r12-3643 I improved our handling of type names after . or -> when
unqualified lookup doesn't find anything, but it needs to handle auto
specially.

	PR c++/105734

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_postfix_dot_deref_expression): Use typeof
	if the expression has auto type.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/auto57.C: New test.
2022-06-01 15:53:24 -04:00
Jason Merrill
819e3fda1e c++: auto function as function argument [PR105779]
This testcase demonstrates that the issue in PR105623 is not limited to
templates, so we should do the marking in a less template-specific place.

	PR c++/105779

gcc/cp/ChangeLog:

	* call.cc (resolve_args): Call mark_single_function here.
	* pt.cc (unify_one_argument): Not here.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/auto-fn63.C: New test.
2022-06-01 15:53:24 -04:00
Patrick Palka
e30b73bad9 c++: constexpr init of union sub-aggr w/ base [PR105491]
Here ever since r10-7313-gb599bf9d6d1e18, reduced_constant_expression_p
in C++11/14 is rejecting the marked sub-aggregate initializer (of type S)

  W w = {.D.2445={.s={.D.2387={.m=0}, .b=0}}};
                     ^
ultimately because said initializer has CONSTRUCTOR_NO_CLEARING set,
hence the function must verify that all fields of S are initialized.
And before C++17 it doesn't expect to see base class fields (since
next_initializable_field skips over them), so the presence thereof
causes r_c_e_p to return false.

The reason r10-7313-gb599bf9d6d1e18 causes this is because in that
commit we began using CONSTRUCTOR_NO_CLEARING to precisely track whether
we're in middle of activating a union member.  This ends up affecting
clear_no_implicit_zero, which recurses into sub-aggregate initializers
only if the outer initializer has CONSTRUCTOR_NO_CLEARING set.  After
that commit, the outer union initializer above no longer has the flag
set at this point and so clear_no_implicit_zero no longer recurses into
the marked inner initializer.

But arguably r_c_e_p should be able to accept the marked initializer
regardless of whether CONSTRUCTOR_NO_CLEARING is set.  The primary bug
therefore seems to be that r_c_e_p relies on next_initializable_field
which skips over base class fields in C++11/14.  To fix this, this patch
introduces a new helper function next_subobject_field which is like
next_initializable_field except that it never skips base class fields,
and makes r_c_e_p use it.  This patch then renames next_initializable_field
to next_aggregate_field (and makes it skip over vptr fields again).

NB: This minimal backport of r13-211-g0c7bce0ac184c0 for 12.2 just adds
next_subobject_field and makes reduced_constant_expression_p use it.

	PR c++/105491

gcc/cp/ChangeLog:

	* constexpr.cc (reduced_constant_expression_p): Use
	next_subobject_field instead.
	* cp-tree.h (next_subobject_field): Declare.
	* decl.cc (next_subobject_field): Define.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/constexpr-union7.C: New test.
	* g++.dg/cpp0x/constexpr-union7a.C: New test.
	* g++.dg/cpp2a/constinit17.C: New test.

(cherry picked from commit 0c7bce0ac1)
2022-06-01 08:47:25 -04:00
GCC Administrator
91fbce33d5 Daily bump. 2022-06-01 00:19:09 +00:00
Jason Merrill
102a1472ab c++: lambda in concept [PR105652]
We currently check satisfaction in the context of the constrained
declaration (which may be wrong, see PR104111).  When checking C<int>
for S<int>, we currently substitute into the lambda in the context of
S<T> (rather than S<int>, which seems wrong if the above isn't wrong), so
the new closure type thinks its context is S<T>, which confuses debug
output.  For the moment, let's work around all of this by overriding the
context of the closure.

	PR c++/105652

gcc/cp/ChangeLog:

	* pt.cc (tsubst_lambda_expr): Don't let a namespace-scope lambda
	instantiate into a class-scope lambda.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-lambda20.C: New test.
2022-05-31 15:31:03 -04:00
Jason Merrill
d81be519fd c++: CTAD with alias and nested template [PR105655]
Here, alias_ctad_tweaks expect tsubst_decl of a FUNCTION_DECL to return a
FUNCTION_DECL.  A reasonable expectation, but in this case we were replacing
the template args of the class-scope deduction guide with equivalent args,
so looking in the hash table we found the partial instantiation stored when
instantiating A<int>, which is a TEMPLATE_DECL.  It's fine for that to be
what is stored, but tsubst_function_decl should never return it.

	PR c++/105655

gcc/cp/ChangeLog:

	* pt.cc (build_template_decl): Add assert.
	(tsubst_function_decl): Don't return a template.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/class-deduction-alias13.C: New test.
2022-05-31 15:31:03 -04:00
Jason Merrill
d905769523 c++: deduction from auto fn [PR105623]
Since my patch for PR90451, we defer mark_used of single functions as late
as possible.  And since my r12-1273, we keep BASELINK from lookup around
rather than reconstruct it later.  These both made us try to instantiate g
with a function type that still had 'auto' as its return type.

	PR c++/105623

gcc/cp/ChangeLog:

	* decl2.cc (mark_used): Copy type from fn to BASELINK.
	* pt.cc (unify_one_argument): Call mark_single_function.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/auto-fn62.C: New test.
2022-05-31 15:31:02 -04:00
Jason Merrill
a578b17b59 c++: constexpr ref to array of array [PR102307]
The problem here is that first check_initializer calls
build_aggr_init_full_exprs, which does overload resolution, but then in the
case of failed constexpr throws away the result and does it again in
build_functional_cast.  But in the first overload resolution,
reshape_init_array_1 decided to reuse the inner CONSTRUCTORs because
tf_error is set, so we know we're committed.  But the second pass gets
confused by the CONSTRUCTORs with non-init-list types.

Fixed by avoiding a second pass: instead, pass the call from build_aggr_init
to build_cplus_new, which will turn it into a TARGET_EXPR.  I don't bother
to change the object argument because it will be replaced later in
simplify_aggr_init_expr.

	PR c++/102307

gcc/cp/ChangeLog:

	* decl.cc (check_initializer): Use build_cplus_new in case of
	constexpr failure.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/constexpr-array2.C: New test.
2022-05-31 15:31:02 -04:00
Iain Buclaw
f106ef5302 d: Fix D lexer sometimes fails to compile code read from stdin
As of gdc-12, the lexer expects there 4 bytes of zero padding at the end
of the source buffer to mark the end of input.  Sometimes when reading
from stdin, the data at the end of input is garbage rather than zeroes.
Fix that by explicitly calling memset past the end of the buffer.

	PR d/105544

gcc/d/ChangeLog:

	* d-lang.cc (d_parse_file): Zero padding past the end of the stdin
	buffer so the D lexer has a sentinel to stop parsing at.

(cherry picked from commit a0bc7fd421)
2022-05-31 18:33:31 +02:00
GCC Administrator
a4ae11d935 Daily bump. 2022-05-31 00:19:02 +00:00
Martin Jambor
081c472589
ipa: Check cst type when propagating controled uses info
PR 105639 shows that code with type-mismatches can trigger an assert
after runnning into a branch that was inteded only for references to
variables - as opposed to references to functions.  Fixed by moving
the condition from the assert to the guarding if statement.

gcc/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

	PR ipa/105639
	* ipa-prop.cc (propagate_controlled_uses): Check type of the
	constant before adding a LOAD reference.

gcc/testsuite/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

	PR ipa/105639
	* gcc.dg/ipa/pr105639.c: New test.

(cherry picked from commit f571596f8c)
2022-05-30 22:04:42 +02:00
Jakub Jelinek
8f32de15e4 libcpp: Ignore CPP_PADDING tokens in _cpp_parse_expr [PR105732]
The first part of the following testcase (m1-m3 macros and its use)
regressed with my PR89971 fix, but as the m1,m4-m5 and its use part shows,
the problem isn't new, we can emit a CPP_PADDING token to avoid it from
being adjacent to whatever comes after the __VA_OPT__ (in this case there
is nothing afterwards, true).

In most cases these CPP_PADDING tokens don't matter, all other
callers of cpp_get_token_with_location either ignore CPP_PADDING tokens
completely (e.g. c_lex_with_flags) or they just remember them and
take them into account when printing stuff whether there should be
added whitespace or not (scan_translation_unit + token_streamer::stream).
So, I think we should just ignore CPP_PADDING tokens the same way in
_cpp_parse_expr.

2022-05-27  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/105732
	* expr.cc (_cpp_parse_expr): Handle CPP_PADDING by just another
	token.

	* c-c++-common/cpp/va-opt-10.c: New test.

(cherry picked from commit 58a40e76eb)
2022-05-30 05:36:32 +02:00
Jakub Jelinek
93e6064289 libgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]
since apparently _aligned_malloc requires freeing with _aligned_free and:
 /* Defined if gomp_aligned_alloc doesn't use fallback version
    and free can be used instead of gomp_aligned_free.  */
 #define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC 1
so the second condition isn't satisfied.  For uses inside of the OpenMP
allocators we can still use _aligned_malloc but we need to call _aligned_free
in gomp_aligned_free.

2022-05-28  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/105745
	* libgomp.h (GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC): Don't define for
	defined(HAVE__ALIGNED_MALLOC) case.
	* alloc.c (gomp_aligned_alloc): Move defined(HAVE__ALIGNED_MALLOC)
	handling as last option before fallback instead of first.
	(gomp_aligned_free): For defined(HAVE__ALIGNED_MALLOC) call
	_aligned_free.

(cherry picked from commit 42fd2cd932)
2022-05-30 05:36:32 +02:00
Jakub Jelinek
2f3ccb79ca fold-const: Fix up -fsanitize=null in C++ [PR105729]
The following testcase triggers a false positive UBSan binding a reference
to null diagnostics.
In the FE we instrument conversions from pointer to reference type
to diagnose at runtime if the operand of such a conversion is 0.
The problem is that a GENERIC folding folds
((const struct Bar *) ((const struct Foo *) this)->data) + (sizetype) range_check (x)
conversion to const struct Bar & by converting to that the first
operand of the POINTER_PLUS_EXPR.  But that changes when the -fsanitize=null
binding to reference runtime check occurs.  Without the optimization,
it is invoked on the result of the POINTER_PLUS_EXPR, and as range_check
call throws, that means it never triggers in the testcase.
With the optimization, it checks whether this->data is NULL and it is.

The following patch avoids that optimization during GENERIC folding when
-fsanitize=null is enabled and it is a cast from non-REFERENCE_TYPE to
REFERENCE_TYPE.

2022-05-27  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/105729
	* fold-const.cc (fold_unary_loc): Don't optimize (X &) ((Y *) z + w)
	to (X &) z + w if -fsanitize=null during GENERIC folding.

	* g++.dg/ubsan/pr105729.C: New test.

(cherry picked from commit e2f014fcef)
2022-05-30 05:36:31 +02:00
Jakub Jelinek
120d99a3ec asan: Fix up instrumentation of assignments which are both loads and stores [PR105714]
On the following testcase with -Os asan pass sees:
  <bb 6> [local count: 354334800]:
  # h_21 = PHI <h_15(6), 0(5)>
  *c.3_5 = *d.2_4;
  h_15 = h_21 + 1;
  if (h_15 != 3)
    goto <bb 6>; [75.00%]
  else
    goto <bb 7>; [25.00%]

  <bb 7> [local count: 118111600]:
  *c.3_5 = MEM[(struct a *)&b + 12B];
  _13 = c.3_5->x;
  return _13;
It instruments the
  *c.3_5 = *d.2_4;
assignment by adding
  .ASAN_CHECK (7, c.3_5, 4, 4);
  .ASAN_CHECK (6, d.2_4, 4, 4);
before it (which later lowers to checking the corresponding shadow
memory).  But when considering instrumentation of
  *c.3_5 = MEM[(struct a *)&b + 12B];
it doesn't instrument anything, because it sees that *c.3_5 store is
already instrumented in a dominating block and so there is no need
to instrument *c.3_5 store again (i.e. add another
  .ASAN_CHECK (7, c.3_5, 4, 4);
).  That is true, but misses the fact that we still want to
instrument the MEM[(struct a *)&b + 12B] load.

The following patch fixes that by changing has_stmt_been_instrumented_p
to consider both store and load in the assignment if it does both
(returning true iff both have been instrumented).
That matches how we handle e.g. builtin calls, where we also perform AND
of all the memory locs involved in the call.

I've verified that we still don't add the redundant
  .ASAN_CHECK (7, c.3_5, 4, 4);
call but just add
  _18 = &MEM[(struct a *)&b + 12B];
  .ASAN_CHECK (6, _18, 4, 4);
to instrument the load.

2022-05-25  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/105714
	* asan.cc (has_stmt_been_instrumented_p): For assignments which
	are both stores and loads, return true only if both destination
	and source have been instrumented.

	* gcc.dg/asan/pr105714.c: New test.

(cherry picked from commit af02daff55)
2022-05-30 05:36:31 +02:00
Jakub Jelinek
7b88f9b888 pointer-query: Fix ICE with non-pointer param [PR105635]
The gimple_parm_array_size function comment talks about pointe parameters
but doesn't actually verify it, it checks whether an attribute is present
on the function and then just uses TREE_TYPE (TREE_TYPE (var)) which
assumes a pointer type (or in theory could work for ARRAY_TYPE but
c-family languages which only have that attribute will never have ARRAY_TYPE
parameters; and for VECTOR_TYPE/COMPLEX_TYPE it would mean something quite
different).

So, this patch punts early if var doesn't have pointer/reference type.

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

	PR c/105635
	* pointer-query.cc (gimple_parm_array_size): Return NULL if var
	doesn't have pointer or reference type.

	* gcc.dg/pr105635.c: New test.

(cherry picked from commit 3b4daa0b3c)
2022-05-30 05:36:31 +02:00
GCC Administrator
864dcf71c8 Daily bump. 2022-05-30 00:19:10 +00:00
GCC Administrator
87fdcd896e Daily bump. 2022-05-29 00:18:53 +00:00
GCC Administrator
c2476f7b22 Daily bump. 2022-05-28 00:19:07 +00:00
Jonathan Wakely
01ee07a0dd libstdc++: Fix atomic and error_code printers for versioned namespace
This fixes the printers to work with std::__8::atomic and
std::__v8::ios_errc and std::__v8::future_errc.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Make
	lookup for ios_errc and future_errc check versioned namespace.
	(StdAtomicPrinter): Strip versioned namespace from typename.

(cherry picked from commit 11e1ee1b38)
2022-05-27 18:32:52 +01:00
François Dumont
2a9c87a204 libstdc++: Fix printing of std::span for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__):
	Strip typename from version namespace.

(cherry picked from commit ace4b7f295)
2022-05-27 18:32:52 +01:00
Jonathan Wakely
50712db568 libstdc++: Fix printing of std::atomic<shared_ptr<T>> for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (SharedPointerPrinter): Strip
	versioned namespace from the template argument too.

(cherry picked from commit 634b0089f6)
2022-05-27 18:32:52 +01:00
Jonathan Wakely
7be1dd924d libstdc++: Add constexpr to std::counted_iterator post-increment (LWG 3643)
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (counted_iterator::operator++(int)):
	Add 'constexpr' as per LWG 3643.
	* testsuite/24_iterators/counted_iterator/lwg3643.cc: New test.

(cherry picked from commit 47b20d027a)
2022-05-27 18:32:52 +01:00
Jonathan Wakely
5647e401bb libstdc++: Implement LWG 3683 for pmr::polymorphic_allocator
This issue has recently been moved to Tentatively Ready, and seems
uncontroversial. This allows equality comparison with types that are
convertible to pmr::polymorphic_allocator, which fail deduction for the
existing equality operator.

libstdc++-v3/ChangeLog:

	* include/std/memory_resource (polymorphic_allocator): Add
	non-template equality operator, as proposed for LWG 3683.
	* testsuite/20_util/polymorphic_allocator/lwg3683.cc: New test.

(cherry picked from commit f13f9c99db)
2022-05-27 18:32:52 +01:00
Jonathan Wakely
871aa11366 libstdc++: Reduce <random> test iterations for simulators
Some of these tests take several minutes on a simulator like cris-elf,
so we can conditionally run fewer iterations. The testDiscreteDist
helper already supports custom sizes so we just need to make use of that
when { target simulator } matches.

The relevant code is sufficiently tested on other targets, so we're not
losing anything by only running a small number of iterators for sims.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc:
	Run fewer iterations for simulator targets.
	* testsuite/26_numerics/random/binomial_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/discrete_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/geometric_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/poisson_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc:
	Likewise.

(cherry picked from commit e3b8b4f781)
2022-05-27 18:32:51 +01:00
Jonathan Wakely
bcb39ac643 libstdc++: Skip tests that fail for the versioned namespace
Most tests for the contents of header synopses need to be supressed for
the versioned namespace build, because redeclaring the entities in std
fails when they were originally declared in std::__8.

I added these tests recently without the suppression, so they fail.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/expected/synopsis.cc: Skip for versioned
	namespace.
	* testsuite/27_io/headers/iosfwd/synopsis.cc: Likewise.

(cherry picked from commit 1815462a6e)
2022-05-27 18:32:51 +01:00
Jonathan Wakely
702ac6e761 libstdc++: Fix typo in doxygen @headerfile command
libstdc++-v3/ChangeLog:

	* include/bits/mofunc_impl.h: Fix doxygen command.

(cherry picked from commit 4163b0be81)
2022-05-27 18:32:51 +01:00
Jonathan Wakely
d2b9fdedcd libstdc++: Add noexcept to std::launch operators
libstdc++-v3/ChangeLog:

	* include/std/future (launch): Make operators noexcept.

(cherry picked from commit 8659bcd6b7)
2022-05-27 18:32:51 +01:00
Marek Polacek
2c11a9a380 c++: Fix ICE with -Wmismatched-tags [PR105725]
Here we ICE with -Wmismatched-tags on something like

  template <class T>
  bool B<T, enable_if_t<is_class_v<class T::foo>>>;

Specifically, the "class T::foo" bit.  There, class_decl_loc_t::add gets
a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking
TYPE_BEING_DEFINED will crash.  I think it's OK to allow a TYPENAME_TYPE to
slip into that function; we just shouldn't consider the 'class' tag redundant
(which works as a 'typename').  In fact, every other compiler *requires* it.

	PR c++/105725

gcc/cp/ChangeLog:

	* parser.cc (class_decl_loc_t::add): Check CLASS_TYPE_P.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wmismatched-tags-10.C: New test.

(cherry picked from commit d822f4bbd7)
2022-05-27 12:07:35 -04:00
GCC Administrator
57fdcaf17d Daily bump. 2022-05-27 00:18:42 +00:00
Simon Cook
f1e47f34ab RISC-V: Don't unconditionally add m,a,f,d in arch-canonicalize
This solves an issue where rv32i, etc. are canonicalized to rv32imafd
since the g->i addition of 'm', 'a', 'f', 'd' is not actually gated by
whether the input was rv32g/rv64g.

gcc/ChangeLog:

	* config/riscv/arch-canonicalize: Only add mafd extension if
	base was rv32/rv64g.

(cherry picked from commit 63f198553d)
2022-05-26 14:09:58 +08:00
Kito Cheng
02e8dea494 RISC-V: Fix wrong expansion for arch-canonicalize
rv64gcv should exapnd into:

rv64imafdcv_zicsr_zifencei_zve32f_zve32x_zve64d_zve64f_zve64x_zvl128b_zvl32b_zvl64b

but we exapnd fd twice for now:

rv64imafdfdcv_zicsr_zifencei_zve32f_zve32x_zve64d_zve64f_zve64x_zvl128b_zvl32b_zvl64b

gcc/ChangeLog:

	* config/riscv/arch-canonicalize: Handle g correctly.

(cherry picked from commit 27239e13b1)
2022-05-26 14:09:56 +08:00
GCC Administrator
0320f3b120 Daily bump. 2022-05-26 00:19:12 +00:00
GCC Administrator
ed843f1314 Daily bump. 2022-05-25 00:19:20 +00:00
Qing Zhao
79ae75cc25 i386: Adjust -fzero-call-used-regs to always use XOR [PR101891]
Currently on i386, -fzero-call-used-regs uses a pattern of:

XOR regA,regA
MOV regA,regB
MOV regA,regC
...
RET

However, this introduces both a register ordering dependency (e.g. the CPU
cannot clear regB without clearing regA first), and while greatly reduces
available ROP gadgets, it does technically leave a set of "MOV" ROP gadgets
at the end of functions (e.g. "MOV regA,regC; RET").

This patch will switch to always use XOR on i386:

XOR regA,regA
XOR regB,regB
XOR regC,regC
...
RET

gcc/ChangeLog:

	PR target/101891
	* config/i386/i386.cc (zero_call_used_regno_mode): use V2SImode
	as a generic MMX mode instead of V4HImode.
	(zero_all_mm_registers): Use SET to zero instead of MOV for
	zeroing scratch registers.
	(ix86_zero_call_used_regs): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/zero-scratch-regs-1.c: Add -fno-stack-protector
	-fno-PIC.
	* gcc.target/i386/zero-scratch-regs-10.c: Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-13.c: Add -msse.
	* gcc.target/i386/zero-scratch-regs-14.c: Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-15.c: Add -fno-stack-protector
	-fno-PIC.
	* gcc.target/i386/zero-scratch-regs-16.c: Likewise.
	* gcc.target/i386/zero-scratch-regs-17.c: Likewise.
	* gcc.target/i386/zero-scratch-regs-18.c: Add -fno-stack-protector
	-fno-PIC, adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-19.c: Add -fno-stack-protector
	-fno-PIC.
	* gcc.target/i386/zero-scratch-regs-2.c: Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-20.c: Add -msse.
	* gcc.target/i386/zero-scratch-regs-21.c: Add -fno-stack-protector
	-fno-PIC, Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-22.c: Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-23.c: Likewise.
	* gcc.target/i386/zero-scratch-regs-26.c: Likewise.
	* gcc.target/i386/zero-scratch-regs-27.c: Likewise.
	* gcc.target/i386/zero-scratch-regs-28.c: Likewise.
	* gcc.target/i386/zero-scratch-regs-3.c: Add -fno-stack-protector.
	* gcc.target/i386/zero-scratch-regs-31.c: Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-4.c: Add -fno-stack-protector
	-fno-PIC.
	* gcc.target/i386/zero-scratch-regs-5.c: Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-6.c: Add -fno-stack-protector.
	* gcc.target/i386/zero-scratch-regs-7.c: Likewise.
	* gcc.target/i386/zero-scratch-regs-8.c: Adjust mov to xor.
	* gcc.target/i386/zero-scratch-regs-9.c: Add -fno-stack-protector.

(cherry picked from commit 0b86943aca)
2022-05-24 15:03:40 +00:00
Bruno Haible
394ff2fbfc Extend --with-zstd documentation
The patch that was so far added for documenting --with-zstd is pretty
minimal:
  - it refers to undocumented options --with-zstd-include and
    --with-zstd-lib;
  - it suggests that --with-zstd can be used without an argument;
  - it does not clarify how this option applies to cross-compilation.

How about adding the same details as for the --with-isl,
--with-isl-include, --with-isl-lib options, mutatis mutandis? This patch
does that.

	PR other/105527

gcc/ChangeLog:

	* doc/install.texi (Configuration): Add more details about --with-zstd.
	Document --with-zstd-include and --with-zstd-lib

Signed-off-by: Bruno Haible <bruno@clisp.org>
(cherry picked from commit 3677eb80b6)
2022-05-24 13:33:38 +02:00
Martin Liska
f4c0f9257e docs: document --with-zstd
PR other/105527

gcc/ChangeLog:

	* doc/install.texi: Document the configure option --with-zstd.

(cherry picked from commit 8fa689767a)
2022-05-24 13:33:37 +02:00
GCC Administrator
f0a0aeec44 Daily bump. 2022-05-24 00:19:29 +00:00
GCC Administrator
dbca35e5f3 Daily bump. 2022-05-23 00:19:03 +00:00
GCC Administrator
6d1a2b2c89 Daily bump. 2022-05-22 00:19:11 +00:00
GCC Administrator
e970ccbf3d Daily bump. 2022-05-21 00:19:12 +00:00
Peter Bergner
c83d785850 rs6000: Prefer assigning the MMA vector operands to altivec registers [PR105556]
When optimizing the DGEMM kernel in OpenBLAS to use MMA, the MMA code
uses all 8 accumulators, which overlap all vs0-vs31 vector registers.
Current trunk assigns one of the normal vector inputs to one of the MMA
instructions, which forces us to spill one of the accumulators to memory,
leading to poor performance.  The solution here is to replace the "wa"
constraints for the vector input operands in the MMA instruction patterns
with "v,?wa" so that we prefer using the altivec registers vs32-vs63
over the vs0-vs31 registers.

2022-05-17  Peter Bergner  <bergner@linux.ibm.com>
	    Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	PR target/105556
	* config/rs6000/mma.md (mma_<vv>, mma_<avv>, mma_<pv>, mma_<apv>,
	mma_<vvi4i4i8>, mma_<avvi4i4i8>, mma_<vvi4i4i2>, mma_<avvi4i4i2>,
	mma_<vvi4i4>, mma_<avvi4i4>, mma_<pvi4i2>, mma_<apvi4i2>,
	mma_<vvi4i4i4>, mma_<avvi4i4i4>): Replace "wa" constraints with "v,?wa".
	Update other operands accordingly.

(cherry picked from commit c6e36f05fb)
2022-05-20 18:00:28 -05:00
Richard Biener
fdf50499a4 tree-optimization/103116 - SLP permutes and peeling for gaps
The testcase shows that we can end up with a contiguous access across
loop iterations but by means of permutations the elements accessed
might only cover parts of a vector.  In this case we end up with
GROUP_GAP == 0 but still need to avoid accessing excess elements
in the last loop iterations.  Peeling for gaps is designed to cover
this but a single scalar iteration might not cover all of the excess
elements.  The following ensures peeling for gaps is done in this
situation and when that isn't sufficient because we need to peel
more than one iteration (gcc.dg/vect/pr103116-2.c), fail the SLP
vectorization.

2022-05-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/103116
	* tree-vect-stmts.cc (get_group_load_store_type): Handle the
	case we need peeling for gaps even though GROUP_GAP is zero.

	* gcc.dg/vect/pr103116-1.c: New testcase.
	* gcc.dg/vect/pr103116-2.c: Likewise.

(cherry picked from commit 52b7b86f8c)
2022-05-20 08:00:28 +02:00
GCC Administrator
f682c64377 Daily bump. 2022-05-20 00:19:13 +00:00