211837 Commits

Author SHA1 Message Date
Chung-Lin Tang
ea9516fe49 OpenACC 2.7: adjust 2.6 references to 2.7
More adjustments to indicate OpenACC 2.7 support.

2025-04-11  Chung-Lin Tang  <cltang@baylibre.com>

gcc/fortran/ChangeLog:

	* intrinsic.texi (OpenACC Module OPENACC): Adjust version
	references to 2.7 from 2.6.

libgomp/ChangeLog:

	* libgomp.texi (Enabling OpenACC): Adjust version
	references to 2.7 from 2.6.
	* openacc.f90 (module openacc): Adjust openacc_version to 201811.
	* openacc_lib.h (openacc_version): Adjust openacc_version to 201811.
	* testsuite/libgomp.oacc-fortran/openacc_version-1.f: Adjust
	test value to 201811.
	* testsuite/libgomp.oacc-fortran/openacc_version-2.f90: Likewise.
2025-04-11 13:51:55 +00:00
Chung-Lin Tang
b05827d566 OpenACC 2.7: update _OPENACC value test in testcases
Adjust value test of _OPENACC to 201811 for OpenACC 2.7 update.

2025-04-11  Chung-Lin Tang  <cltang@baylibre.com>

gcc/testsuite/ChangeLog:

	* c-c++-common/cpp/openacc-define-3.c: Adjust test.
	* gfortran.dg/openacc-define-3.f90: Adjust test.
2025-04-11 10:36:22 +00:00
Chung-Lin Tang
28244925ed OpenACC 2.7: update _OPENACC symbol to 201811
This patch updates the _OPENACC preprocessor symbol to "201811",
to indicate OpenACC 2.7 support.

2025-04-11  Chung-Lin Tang  <cltang@baylibre.com>

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Updated _OPENACC to "201811"
	for OpenACC 2.7.

gcc/fortran/ChangeLog:

	* cpp.cc (cpp_define_builtins): Updated _OPENACC to "201811"
	for OpenACC 2.7.
2025-04-11 08:46:12 +00:00
Tobias Burnus
b25ca24813 Merge remote-tracking branch 'origin/releases/gcc-14' into devel/omp/gcc-14
Merge up to r14-11542-g059107eb22c480 (8th Apr 2025)
2025-04-08 23:51:05 +02:00
Tobias Burnus
e14ab294c0 OpenMP: Fix append_args handling in modify_call_for_omp_dispatch
At tree level, the addr ref is also required for array dummy arguments,
contrary to C; the GOMP_interop calls in modify_call_for_omp_dispatch
were updated accordingly (using build_fold_addr_expr).

As the GOMP_interop calls had no location data associated with them,
the init call happened as soon as executing the previous line of code,
which was confusing; solution: use the location data of the function
call itself.

	PR middle-end/119662

gcc/ChangeLog:

	* gimplify.cc (modify_call_for_omp_dispatch): Fix GOMP_interop
	arg passing; add location info to function calls.

libgomp/ChangeLog:

	* testsuite/libgomp.c/append-args-fr-1.c: New test.
	* testsuite/libgomp.c/append-args-fr.h: New test.

gcc/testsuite/ChangeLog:
	* c-c++-common/gomp/append-args-interop.c: Update for fixed
	GOMP_interop call.
	* g++.dg/gomp/append-args-8.C: Likewise.
	* gfortran.dg/gomp/append-args-interop.f90: Likewise.

(cherry picked from commit 0f77d88fdf797842ac0134a4013b4227dd5a658f)
2025-04-08 23:50:47 +02:00
Jonathan Wakely
059107eb22
libstdc++: Fix use-after-free in std::format [PR119671]
When formatting floating-point values to wide strings there's a case
where we invalidate a std::wstring buffer while a std::wstring_view is
still referring to it.

libstdc++-v3/ChangeLog:

	PR libstdc++/119671
	* include/std/format (__formatter_fp::format): Do not invalidate
	__wstr unless _M_localized returns a valid string.
	* testsuite/std/format/functions/format.cc: Check wide string
	formatting of floating-point types with classic locale.

Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
(cherry picked from commit e33b62eed7fd0a82d758b23252d288585b6790d2)
2025-04-08 10:13:39 +01:00
Jonathan Wakely
7e789f3420
libstdc++: Add new header to Doxygen config file
libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add text_encoding.

(cherry picked from commit 5430fcd1a3222d62c1b9560de251268c8bc50303)
2025-04-08 10:13:39 +01:00
Jonathan Wakely
7ad64ffe10
libstdc++: Replace use of __mindist in ranges::uninitialized_xxx algos [PR101587]
In r15-8980-gf4b6acfc36fb1f I introduced a new function object for
finding the smaller of two distances. In bugzilla Hewill Kang pointed
out that we still need to explicitly convert the result back to the
right difference type, because the result might be an integer-like class
type that doesn't convert to an integral type explicitly.

Rather than doing that conversion in the __mindist function object, I
think it's simpler to remove it again and just do a comparison and
assignment. We always want the result to have a specific type, so we can
just check if the value of the other type is smaller, and then convert
that to the other type if so.

libstdc++-v3/ChangeLog:

	PR libstdc++/101587
	* include/bits/ranges_uninitialized.h (__detail::__mindist):
	Remove.
	(ranges::uninitialized_copy, ranges::uninitialized_copy_n)
	(ranges::uninitialized_move, ranges::uninitialized_move_n): Use
	comparison and assignment instead of __mindist.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc:
	Check with ranges that use integer-like class type for
	difference type.
	* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
	Likewise.

Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
Reviewed-by: Hewill Kang <hewillk@gmail.com>
(cherry picked from commit 03ac8886e5c1fa16da90276fd721a57fa9435f4f)
2025-04-08 10:13:39 +01:00
Jonathan Wakely
ef11c1573d
libstdc++: Replace use of std::min in ranges::uninitialized_xxx algos [PR101587]
Because ranges can have any signed integer-like type as difference_type,
it's not valid to use std::min(diff1, diff2). Instead of calling
std::min with an explicit template argument, this adds a new __mindist
helper that determines the common type and uses that with std::min.

libstdc++-v3/ChangeLog:

	PR libstdc++/101587
	* include/bits/ranges_uninitialized.h (__detail::__mindist):
	New function object.
	(ranges::uninitialized_copy, ranges::uninitialized_copy_n)
	(ranges::uninitialized_move, ranges::uninitialized_move_n): Use
	__mindist instead of std::min.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc:
	Check ranges with difference difference types.
	* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
	Likewise.

(cherry picked from commit f4b6acfc36fb1f72fdd5bf4da208515e6495a062)
2025-04-08 10:13:39 +01:00
Lulu Cheng
73a62377ae LoongArch: Add LoongArch architecture detection to __float128 support in libgfortran and libquadmath [PR119408].
In GCC14, LoongArch added __float128 as an alias for _Float128.
In commit r15-8962, support for q/Q suffixes for 128-bit floating point
numbers.  This will cause the compiler to automatically link libquadmath
when compiling Fortran programs.  But on LoongArch `long double` is
IEEE quad, so there is no need to implement libquadmath.
This causes link failure.

	PR target/119408

libgfortran/ChangeLog:

	* acinclude.m4: When checking for __float128 support, determine
	whether the current architecture is LoongArch.  If so, return false.
	* configure: Regenerate.

libquadmath/ChangeLog:

	* configure.ac: When checking for __float128 support, determine
	whether the current architecture is LoongArch.  If so, return false.
	* configure: Regenerate.

	Sigend-off-by: Xi Ruoyao <xry111@xry111.site>
	Sigend-off-by: Jakub Jelinek <jakub@redhat.com>

(cherry picked from commit 1534f0099c98ea14c08a401302b05edf2231f411)
2025-04-08 09:19:14 +08:00
GCC Administrator
da91ea5de5 Daily bump. 2025-04-08 00:23:26 +00:00
Patrick Palka
5cdf31f080 libstdc++: Work around C++20 tuple<tuple<any>> constraint recursion [PR116440]
The type tuple<tuple<any>> is clearly copy/move constructible, but for
reasons that are not yet completely understood checking this triggers
constraint recursion with our C++20 tuple implementation (but not the
C++17 implementation).

It turns out this recursion stems from considering the non-template
tuple(const _Elements&) constructor during the copy/move constructibility
check.  Considering this constructor is ultimately redundant, since the
defaulted copy/move constructors are better matches.

GCC has a non-standard "perfect candidate" optimization[1] that causes
overload resolution to shortcut considering template candidates if we
find a (non-template) perfect candidate.  So to work around this issue
(and as a general compile-time optimization) this patch turns the
problematic constructor into a template so that GCC doesn't consider it
when checking for copy/move constructibility of this tuple type.

Changing the template-ness of a constructor can affect overload
resolution (since template-ness is a tiebreaker) so there's a risk this
change could e.g. introduce overload resolution ambiguities.  But the
original C++17 implementation has long defined this constructor as a
template (in order to constrain it etc), so doing the same thing in the
C++20 mode should naturally be quite safe.

The testcase still fails with Clang (in C++20 mode) since it doesn't
implement said optimization.

[1]: See r11-7287-g187d0d5871b1fa and
https://isocpp.org/files/papers/P3606R0.html

	PR libstdc++/116440

libstdc++-v3/ChangeLog:

	* include/std/tuple (tuple::tuple(const _Elements&...))
	[C++20]: Turn into a template.
	* testsuite/20_util/tuple/116440.C: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 6570fa6f2612a4e4ddd2fcfc119369a1a48656e4)
2025-04-07 19:38:39 -04:00
Jason Merrill
749221fac5 c++: constinit and value-initialization [PR119652]
Value-initialization built an AGGR_INIT_EXPR to set AGGR_INIT_ZERO_FIRST on.
Passing that AGGR_INIT_EXPR to maybe_constant_value returned a TARGET_EXPR,
which potential_constant_expression_1 mistook for a temporary.

We shouldn't add a TARGET_EXPR to the AGGR_INIT_EXPR in this case, just like
we already avoid adding it to CONSTRUCTOR or CALL_EXPR.

	PR c++/119652

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_outermost_constant_expr): Also don't add a
	TARGET_EXPR around AGGR_INIT_EXPR.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit c7dc9b6f889fa8f9e4ef060c3af107eaf54265c5)
2025-04-07 13:15:45 -04:00
Jason Merrill
e2a178a511 c++: __FUNCTION__ in lambda return type [PR118629]
In this testcase, the use of __FUNCTION__ is within a function parameter
scope, the lambda's.  And P1787 changed __func__ to live in the parameter
scope.  But [basic.scope.pdecl] says that the point of declaration of
__func__ is immediately before {, so in the trailing return type it isn't in
scope yet, so this __FUNCTION__ should refer to foo().

Looking first for a block scope, then a function parameter scope, gives us
the right result.

	PR c++/118629

gcc/cp/ChangeLog:

	* name-lookup.cc (pushdecl_outermost_localscope): Look for an
	sk_block.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/lambda/lambda-__func__3.C: New test.

(cherry picked from commit 7d561820525fd3b9d8f3876333c0584d75e7c053)
2025-04-07 13:15:45 -04:00
GCC Administrator
2e58e23802 Daily bump. 2025-04-07 00:21:21 +00:00
GCC Administrator
cfd1652f00 Daily bump. 2025-04-06 00:21:18 +00:00
GCC Administrator
4feaf39363 Daily bump. 2025-04-05 00:21:41 +00:00
Jason Merrill
ecc2725d61 c++: lambda in requires outside template [PR99546]
Since r10-7441 we set processing_template_decl in a requires-expression so
that we can use tsubst_expr to evaluate the requirements, but that confuses
lambdas terribly; begin_lambda_type silently returns error_mark_node and we
continue into other failures.  This patch clears processing_template_decl
again while we're defining the closure and op() function, so it only remains
set while parsing the introducer (i.e. any init-captures) and building the
resulting object.  This properly avoids trying to create another lambda in
tsubst_lambda_expr.

	PR c++/99546
	PR c++/113925
	PR c++/106976
	PR c++/109961
	PR c++/117336

gcc/cp/ChangeLog:

	* lambda.cc (build_lambda_object): Handle fake
	requires-expr processing_template_decl.
	* parser.cc (cp_parser_lambda_expression): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-requires2.C: New test.
	* g++.dg/cpp2a/lambda-requires3.C: New test.
	* g++.dg/cpp2a/lambda-requires4.C: New test.
	* g++.dg/cpp2a/lambda-requires5.C: New test.

(cherry picked from commit 25992d8daff60726a247ec7850d540aed5335639)
2025-04-04 16:31:59 -04:00
Patrick Palka
49b6308d25 c++: constraint variable used in evaluated context [PR117849]
Here we wrongly reject the type-requirement at parse time due to its use
of the constraint variable 't' within a template argument (an evaluated
context).  Fix this simply by refining the "use of parameter outside
function body" error path to exclude constraint variables.

PR c++/104255 tracks the same issue for function parameters, but fixing
that would be more involved, requiring changes to the PARM_DECL case of
tsubst_expr.

	PR c++/117849

gcc/cp/ChangeLog:

	* semantics.cc (finish_id_expression_1): Allow use of constraint
	variable outside an unevaluated context.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 6e973e87e3fec6f33e97edf8fce2fcd121e53961)
2025-04-04 14:30:34 -04:00
Patrick Palka
9a747094ac c++: P2280R4 and speculative constexpr folding [PR119387]
Compiling the testcase in this PR uses 2.5x more memory and 6x more
time ever since r14-5979 which implements P2280R4.  This is because
our speculative constexpr folding now does a lot more work trying to
fold ultimately non-constant calls to constexpr functions, and in turn
produces a lot of garbage.  We do sometimes successfully fold more
thanks to P2280R4, but it seems to be trivial stuff like calls to
std::array::size or std::addressof.  The benefit of P2280 therefore
doesn't seem worth the cost during speculative constexpr folding, so
this patch restricts the paper to only manifestly-constant evaluation.

	PR c++/119387

gcc/cp/ChangeLog:

	* constexpr.cc (p2280_active_p): New.
	(cxx_eval_constant_expression) <case VAR_DECL>: Use it to
	restrict P2280 relaxations.
	<case PARM_DECL>: Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit a926345f22b500a2620adb83e6821e01fb8cc8fd)
2025-04-04 14:30:34 -04:00
Eric Botcazou
a210011c5c Ada: Fix thinko in Eigensystem for complex Hermitian matrices
The implementation solves the eigensystem for a NxN complex Hermitian matrix
by first solving it for a 2Nx2N real symmetric matrix and then interpreting
the 2Nx1 real vectors as Nx1 complex ones, but the last step does not work.

The patch fixes the last step and also performs a small cleanup throughout
the implementation, mostly in the commentary and without functional changes.

gcc/ada/
	* libgnat/a-ngcoar.adb (Eigensystem): Adjust notation and fix the
	layout of the real symmetric matrix in the main comment.  Adjust
	the layout of the associated code accordingly and correctly turn
	the 2Nx1 real vectors into Nx1 complex ones.
	(Eigenvalues): Minor similar tweaks.
	* libgnat/a-ngrear.adb (Jacobi): Minor tweaks in the main comment.
	Adjust notation and corresponding parameter names of functions.
	Fix call to Unit_Matrix routine.  Adjust the comment describing
	the various kinds of iterations to match the implementation.
2025-04-04 11:50:12 +02:00
Victor Do Nascimento
2b9a842b82 vect: Relax scan-tree-dump strict pattern matching [PR118597]
Using specific SSA names in pattern matching in `dg-final' makes tests
"unstable", in that changes in passes prior to the pass whose dump is
analyzed in the particular test may change the numbering of the SSA
variables, causing the test to start failing spuriously.

We thus switch from specific SSA names to the use of a multi-line
regular expression making use of capture groups for matching particular
variables across different statements, ensuring the test will pass
more consistently across different versions of GCC.

	PR testsuite/118597

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-fncall-mask.c: Update test directives.
2025-04-04 10:45:52 +01:00
GCC Administrator
370f05455e Daily bump. 2025-04-04 00:21:55 +00:00
Sandra Loosemore
be92d54c56 OpenMP: Require target and/or targetsync init modifier [PR118965]
As noted in PR 118965, the initial interop implementation overlooked
the requirement in the OpenMP spec that at least one of the "target"
and "targetsync" modifiers is required in both the interop construct
init clause and the declare variant append_args clause.

Adding the check was fairly straightforward, but it broke about a
gazillion existing test cases.  In particular, things like "init (x, y)"
which were previously accepted (and tested for being accepted) aren't
supposed to be allowed by the spec, much less things like "init (target)"
where target was previously interpreted as a variable name instead of a
modifier.  Since one of the effects of the change is that at least one
modifier is always required, I found that deleting all the code that was
trying to detect and handle the no-modifier case allowed for better
diagnostics.

gcc/c/ChangeLog
	PR middle-end/118965
	* c-parser.cc (c_parser_omp_clause_init_modifiers): Adjust
	error message.
	(c_parser_omp_clause_init): Remove code for recognizing clauses
	without modifiers.  Diagnose missing target/targetsync modifier.
	(c_finish_omp_declare_variant): Diagnose missing target/targetsync
	modifier.

gcc/cp/ChangeLog
	PR middle-end/118965
	* parser.cc (c_parser_omp_clause_init_modifiers): Adjust
	error message.
	(cp_parser_omp_clause_init): Remove code for recognizing clauses
	without modifiers.  Diagnose missing target/targetsync modifier.
	(cp_finish_omp_declare_variant): Diagnose missing target/targetsync
	modifier.

gcc/fortran/ChangeLog
	PR middle-end/118965
	* openmp.cc (gfc_parser_omp_clause_init_modifiers): Fix some
	inconsistent code indentation.  Remove code for recognizing
	clauses	without modifiers.  Diagnose prefer_type without a
	following paren.  Adjust error message for an unrecognized modifier.
	Diagnose missing target/targetsync modifier.
	(gfc_match_omp_init): Fix more inconsistent code indentation.

gcc/testsuite/ChangeLog
	PR middle-end/118965
	* c-c++-common/gomp/append-args-1.c: Add target/targetsync
	modifiers so tests do what they were previously supposed to do.
	Adjust expected output.
	* c-c++-common/gomp/append-args-7.c: Likewise.
	* c-c++-common/gomp/append-args-8.c: Likewise.
	* c-c++-common/gomp/append-args-9.c: Likewise.
	* c-c++-common/gomp/interop-1.c: Likewise.
	* c-c++-common/gomp/interop-2.c: Likewise.
	* c-c++-common/gomp/interop-3.c: Likewise.
	* c-c++-common/gomp/interop-4.c: Likewise.
	* c-c++-common/gomp/pr118965-1.c: New.
	* c-c++-common/gomp/pr118965-2.c: New.
	* g++.dg/gomp/append-args-1.C: Add target/targetsync modifiers
	and adjust expected output.
	* g++.dg/gomp/append-args-2.C: Likewise.
	* g++.dg/gomp/append-args-6.C: Likewise.
	* g++.dg/gomp/append-args-7.C: Likewise.
	* g++.dg/gomp/append-args-8.C: Likewise.
	* g++.dg/gomp/interop-5.C: Likewise.
	* gfortran.dg/gomp/append_args-1.f90: Add target/targetsync
	modifiers and adjust expected output.
	* gfortran.dg/gomp/append_args-2.f90: Likewise.
	* gfortran.dg/gomp/append_args-3.f90: Likewise.
	* gfortran.dg/gomp/append_args-4.f90: Likewise.
	* gfortran.dg/gomp/interop-1.f90: Likewise.
	* gfortran.dg/gomp/interop-2.f90: Likewise.
	* gfortran.dg/gomp/interop-3.f90: Likewise.
	* gfortran.dg/gomp/interop-4.f90: Likewise.
	* gfortran.dg/gomp/pr118965-1.f90: New.
	* gfortran.dg/gomp/pr118965-2.f90: New.

(cherry picked from commit aca8155c09001f269a20d6df438fa0e749dd5388)
2025-04-03 23:58:30 +00:00
Tomasz Kamiński
83cd4bda12 libstdc++: Restored accidentally removed test case.
It was removed by accident r14-11523-gad1b71fc2882c1.

libstdc++-v3/ChangeLog:

	* testsuite/std/format/functions/format.cc: Restored line.

(cherry picked from commit 81c990aa84b22562157ce2926577b392b4a129d3)
2025-04-03 15:03:54 +02:00
Tomasz Kamiński
ad1b71fc28 libstdc++: Fix handling of field width for wide strings and characters [PR119593]
This patch corrects handling of UTF-32LE and UTF32-BE in
__unicode::__literal_encoding_is_unicode<_CharT>, so they are
recognized as unicode and functions produces correct result for wchar_t.

Use `__unicode::__field_width` to compute the estimated witdh
of the charcter for unicode wide encoding.

	PR libstdc++/119593

libstdc++-v3/ChangeLog:

	* include/bits/unicode.h
	(__unicode::__literal_encoding_is_unicode<_CharT>):
	Corrected handing for UTF-16 and UTF-32 with "LE" or "BE" suffix.
	* include/std/format (__formatter_str::_S_character_width):
	Define.
	(__formatter_str::_S_character_width): Updated passed char
	length.
	* testsuite/std/format/functions/format.cc: Test for wchar_t.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-03 14:31:43 +02:00
Andre Vehreschild
f955c5b409 Fortran: Fix freeing procedure pointer components [PR119380]
Backported from gcc-15.

	PR fortran/119380

gcc/fortran/ChangeLog:

	* trans-array.cc (structure_alloc_comps): Prevent freeing of
	procedure pointer components.

gcc/testsuite/ChangeLog:

	* gfortran.dg/proc_ptr_comp_54.f90: New test.
2025-04-03 11:38:33 +02:00
GCC Administrator
1fb3a8dd95 Daily bump. 2025-04-03 00:23:36 +00:00
Richard Biener
534a7895e9 tree-optimization/119145 - avoid stray .MASK_CALL after vectorization
When we BB vectorize an if-converted loop body we make sure to not
leave around .MASK_LOAD or .MASK_STORE created by if-conversion but
we failed to check for .MASK_CALL.

	PR tree-optimization/119145
	* tree-vectorizer.cc (try_vectorize_loop_1): Avoid BB
	vectorizing an if-converted loop body when there's a .MASK_CALL
	in the loop body.

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

(cherry picked from commit 7950d4cceb9fc7559b1343c95fc651cefbe287a0)
2025-04-02 14:00:18 +02:00
Richard Biener
2f87983131 middle-end/119119 - re-gimplification of empty CTOR assignments
The following testcase runs into a re-gimplification issue during
inlining when processing

  MEM[(struct e *)this_2(D)].a = {};

where re-gimplification does not handle assignments in the same
way than the gimplifier but instead relies on rhs_predicate_for
and gimplifying the RHS standalone.  This fails to handle
special-casing of CTORs.  The is_gimple_mem_rhs_or_call predicate
already handles clobbers but not empty CTORs so we end up in
the fallback code trying to force the CTOR into a separate stmt
using a temporary - but as we have a non-copyable type here that ICEs.

The following generalizes empty CTORs in is_gimple_mem_rhs_or_call
since those need no additional re-gimplification.

	PR middle-end/119119
	* gimplify.cc (is_gimple_mem_rhs_or_call): All empty CTORs
	are OK when not a register type.

	* g++.dg/torture/pr11911.C: New testcase.

(cherry picked from commit 3bd61c1dfaa2d7153eb4be82f423533ea937d0f9)
2025-04-02 14:00:18 +02:00
Richard Biener
d3e4c092c4 tree-optimization/119096 - bogus conditional reduction vectorization
When we vectorize a .COND_ADD reduction and apply the single-use-def
cycle optimization we can end up chosing the wrong else value for
subsequent .COND_ADD.  The following rectifies this.

	PR tree-optimization/119096
	* tree-vect-loop.cc (vect_transform_reduction): Use the
	correct else value for .COND_fn.

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

(cherry picked from commit 10e4107dfcf9fe324d0902f16411a75c596dab91)
2025-04-02 14:00:18 +02:00
Richard Biener
85ed633f26 ipa/119067 - bogus TYPE_PRECISION check on VECTOR_TYPE
odr_types_equivalent_p can end up using TYPE_PRECISION on vector
types which is a no-go.  The following instead uses TYPE_VECTOR_SUBPARTS
for vector types so we also end up comparing the number of vector elements.

	PR ipa/119067
	* ipa-devirt.cc (odr_types_equivalent_p): Check
	TYPE_VECTOR_SUBPARTS for vectors.

	* g++.dg/lto/pr119067_0.C: New testcase.
	* g++.dg/lto/pr119067_1.C: Likewise.

(cherry picked from commit f22e89167b3abfbf6d67f42fc4d689d8ffdc1810)
2025-04-02 14:00:17 +02:00
Richard Biener
faadd1d27a tree-optimization/119057 - bogus double reduction detection
We are detecting a cycle as double reduction where the inner loop
cycle has extra out-of-loop uses.  This clashes at least with
assumptions from the SLP discovery code which says the cycle
isn't reachable from another SLP instance.  It also was not intended
to support this case, in fact with GCC 14 we seem to generate wrong
code here.

	PR tree-optimization/119057
	* tree-vect-loop.cc (check_reduction_path): Add argument
	specifying whether we're analyzing the inner loop of a
	double reduction.  Do not allow extra uses outside of the
	double reduction cycle in this case.
	(vect_is_simple_reduction): Adjust.

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

(cherry picked from commit 758de6263dfc7ba8701965fa468691ac23cb7eb5)
2025-04-02 14:00:17 +02:00
Richard Biener
ed7f67d951 lto/114501 - missed free-lang-data for CONSTRUCTOR index
The following makes sure to also walk CONSTRUCTOR element indexes
which can be FIELD_DECLs, referencing otherwise unused types we
need to clean.  walk_tree only walks CONSTRUCTOR element data.

	PR lto/114501
	* ipa-free-lang-data.cc (find_decls_types_r): Explicitly
	handle CONSTRUCTORs as walk_tree handling of those is
	incomplete.

	* g++.dg/pr114501_0.C: New testcase.

(cherry picked from commit fdd95e1cf29137a19baed25f8c817d320dfe63e3)
2025-04-02 14:00:17 +02:00
Richard Biener
d9faa7c2eb ipa/111245 - bogus modref analysis for store in call that might throw
We currently record a kill for

  *x_4(D) = always_throws ();

because we consider the store always executing since the appropriate
check for whether the stmt could throw is guarded by
!cfun->can_throw_non_call_exceptions.

	PR ipa/111245
	* ipa-modref.cc (modref_access_analysis::analyze_store): Do
	not guard the check of whether the stmt could throw by
	cfun->can_throw_non_call_exceptions.

	* g++.dg/torture/pr111245.C: New testcase.

(cherry picked from commit e6037af6d5e5a43c437257580d75bc8b35a6dcfd)
2025-04-02 14:00:17 +02:00
Andrew Carlotti
35ed15af7d aarch64: Use PAUTH instead of V8_3A in some places
PR target/119383

gcc/ChangeLog:

	* config/aarch64/aarch64.cc
	(aarch64_expand_epilogue): Use TARGET_PAUTH.
	* config/aarch64/aarch64.md: Update comment.

(cherry picked from commit 20385cb92cbd4a1934661ab97a162c1e25935836)
2025-04-02 09:32:08 +00:00
Jonathan Wakely
88f0c1fe28
libstdc++: Fix std::ranges::iter_move for function references [PR119469]
The result of std::move (or a cast to an rvalue reference) on a function
reference is always an lvalue. Because std::ranges::iter_move was using
the type std::remove_reference_t<X>&& as the result of std::move, it was
giving the wrong type for function references. Use a decltype-specifier
with declval<remove_reference_t<X>>() instead of just using the
remove_reference_t<X>&& type directly. This gives the right result,
while still avoiding the cost of doing overload resolution for
std::move.

libstdc++-v3/ChangeLog:

	PR libstdc++/119469
	* include/bits/iterator_concepts.h (_IterMove::__result): Use
	decltype-specifier instead of an explicit type.
	* testsuite/24_iterators/customization_points/iter_move.cc:
	Check results for function references.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 3e52eb28c537aaa03afb78ef9dff8325c5f41f78)
2025-04-02 09:55:46 +01:00
Jonathan Wakely
58a2b7f055
libstdc++: Fix ranges::iter_move handling of rvalues [PR106612]
The specification for std::ranges::iter_move apparently requires us to
handle types which do not satisfy std::indirectly_readable, for example
with overloaded operator* which behaves differently for different value
categories.

libstdc++-v3/ChangeLog:

	PR libstdc++/106612
	* include/bits/iterator_concepts.h (_IterMove::__iter_ref_t):
	New alias template.
	(_IterMove::__result): Use __iter_ref_t instead of
	std::iter_reference_t.
	(_IterMove::__type): Remove incorrect __dereferenceable
	constraint.
	(_IterMove::operator()): Likewise. Add correct constraints. Use
	__iter_ref_t instead of std::iter_reference_t. Forward parameter
	as correct value category.
	(iter_swap): Add comments.
	* testsuite/24_iterators/customization_points/iter_move.cc: Test
	that iter_move is found by ADL and that rvalue arguments are
	handled correctly.

Reviewed-by: Patrick Palka <ppalka@redhat.com>

(cherry picked from commit a8ee522c5923ba17851e4b71316a2dff19d6368f)
2025-04-02 09:55:46 +01:00
Jonathan Wakely
9d5baaa92c
libstdc++: Fix -Warray-bounds warning in std::vector<bool> [PR110498]
In this case, we need to tell the compiler that the current size is not
larger than the new size so that all the existing elements can be copied
to the new storage. This avoids bogus warnings about overflowing the new
storage when the compiler can't tell that that cannot happen.

We might as well also hoist the loads of begin() and end() before the
allocation too. All callers will have loaded at least begin() before
calling _M_reallocate.

libstdc++-v3/ChangeLog:

	PR libstdc++/110498
	* include/bits/vector.tcc (vector<bool, A>::_M_reallocate):
	Hoist loads of begin() and end() before allocation and use them
	to state an unreachable condition.
	* testsuite/23_containers/vector/bool/capacity/110498.cc: New
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit aa3aaf2bfb8fcc17076993df4297597b68bc5f60)
2025-04-02 09:55:46 +01:00
Jonathan Wakely
f0c4ffcd86
libstdc++: Fix -Wstringop-overread warning in std::vector<bool> [PR114758]
As in r13-4393-gcca06f0d6d76b0 and a few other commits, we can avoid
bogus warnings in std::vector<bool> by hoisting some loads to before the
allocation that calls operator new. This means that the compiler has
enough info to remove the dead branches that trigger bogus warnings.

On trunk this is only needed with -fno-assume-sane-operators-new-delete
but it will help on the branches where that option doesn't exist.

libstdc++-v3/ChangeLog:

	PR libstdc++/114758
	* include/bits/vector.tcc (vector<bool, A>::_M_fill_insert):
	Hoist loads of begin() and end() before allocation.
	* testsuite/23_containers/vector/bool/capacity/114758.cc: New
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit 1f6c19f307c8de9830130a0ba071c24e3835beb3)
2025-04-02 09:55:46 +01:00
Jonathan Wakely
4366711d2d
libstdc++: Fix bogus -Wstringop-overflow in std::vector::insert [PR117983]
This was fixed on trunk by r15-4473-g3abe751ea86e34, but that isn't
suitable for backporting. Instead, just add another unreachable
condition in std::vector::_M_range_insert so the compiler knows this
memcpy doesn't use a length originating from a negative ptrdiff_t
converted to a very positive size_t.

libstdc++-v3/ChangeLog:

	PR libstdc++/117983
	* include/bits/vector.tcc (vector::_M_range_insert): Add
	unreachable condition to tell the compiler begin() <= end().
	* testsuite/23_containers/vector/modifiers/insert/117983.cc: New
	test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit 878812b6f6905774ab37cb78903e3e11bf1c508c)
2025-04-02 09:55:45 +01:00
Jonathan Wakely
6b11aed73f
libstdc++: Fix -Warray-bounds warning in std::vector::resize [PR114945]
This is yet another false positive warning fix. This time the compiler
can't prove that when the vector has sufficient excess capacity to
append new elements, the pointer to the existing storage is not null.

libstdc++-v3/ChangeLog:

	PR libstdc++/114945
	* include/bits/vector.tcc (vector::_M_default_append): Add
	unreachable condition so the compiler knows that _M_finish is
	not null.
	* testsuite/23_containers/vector/capacity/114945.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

(cherry picked from commit 844eed3364309bd20cbb7d6793a16b7c6b889ba4)
2025-04-02 09:55:45 +01:00
Thomas Schwinge
f82475810a GCN: Don't emit weak undefined symbols [PR119369]
This resolves all instances of PR119369
"GCN: weak undefined symbols -> execution test FAIL, 'HSA_STATUS_ERROR_VARIABLE_UNDEFINED'";
for all affected test cases, the execution test status progresses FAIL -> PASS.

This however also causes a small number of (expected) regressions, very similar
to GCC/nvptx:

    [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C  -std=c++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C  -std=c++26 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C  -std=c++98 (test for excess errors)

    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++11  scan-assembler .weak[ \t]*_?_ZTH11derived_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++11  scan-assembler .weak[ \t]*_?_ZTH13container_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++11  scan-assembler .weak[ \t]*_?_ZTH8base_obj
    PASS: g++.dg/cpp0x/pr84497.C  -std=c++11 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++17  scan-assembler .weak[ \t]*_?_ZTH11derived_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++17  scan-assembler .weak[ \t]*_?_ZTH13container_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++17  scan-assembler .weak[ \t]*_?_ZTH8base_obj
    PASS: g++.dg/cpp0x/pr84497.C  -std=c++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++26  scan-assembler .weak[ \t]*_?_ZTH11derived_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++26  scan-assembler .weak[ \t]*_?_ZTH13container_obj
    [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C  -std=c++26  scan-assembler .weak[ \t]*_?_ZTH8base_obj
    PASS: g++.dg/cpp0x/pr84497.C  -std=c++26 (test for excess errors)

    [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C  -std=gnu++17  scan-assembler weak[^ \t]*[ \t]_?_Z3foov
    PASS: g++.dg/ext/weak2.C  -std=gnu++17 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C  -std=gnu++26  scan-assembler weak[^ \t]*[ \t]_?_Z3foov
    PASS: g++.dg/ext/weak2.C  -std=gnu++26 (test for excess errors)
    [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C  -std=gnu++98  scan-assembler weak[^ \t]*[ \t]_?_Z3foov
    PASS: g++.dg/ext/weak2.C  -std=gnu++98 (test for excess errors)

    [-PASS:-]{+FAIL:+} gcc.dg/attr-weakref-1.c (test for excess errors)
    [-FAIL:-]{+UNRESOLVED:+} gcc.dg/attr-weakref-1.c [-execution test-]{+compilation failed to produce executable+}

    @@ -131211,25 +131211,25 @@ PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?c
    PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?d
    PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?e
    PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?g
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?j
    PASS: gcc.dg/weak/weak-1.c scan-assembler-not weak[^ \t]*[ \t]_?i

    PASS: gcc.dg/weak/weak-12.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-12.c scan-assembler weak[^ \t]*[ \t]_?foo

    PASS: gcc.dg/weak/weak-15.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?c
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?d
    PASS: gcc.dg/weak/weak-15.c scan-assembler-not weak[^ \t]*[ \t]_?b

    PASS: gcc.dg/weak/weak-16.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-16.c scan-assembler weak[^ \t]*[ \t]_?kallsyms_token_index
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-16.c scan-assembler weak[^ \t]*[ \t]_?kallsyms_token_table
    PASS: gcc.dg/weak/weak-2.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1c
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1e
    PASS: gcc.dg/weak/weak-2.c scan-assembler-not weak[^ \t]*[ \t]_?ffoo1d

    PASS: gcc.dg/weak/weak-3.c  (test for warnings, line 58)
    PASS: gcc.dg/weak/weak-3.c  (test for warnings, line 73)
    PASS: gcc.dg/weak/weak-3.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1c
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1e
    PASS: gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1f
    PASS: gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1g
    PASS: gcc.dg/weak/weak-3.c scan-assembler-not weak[^ \t]*[ \t]_?ffoo1d

    PASS: gcc.dg/weak/weak-4.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1c
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1d
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1e
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1f
    @@ -131267,16 +131267,16 @@ PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1i
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1j
    PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1k

    PASS: gcc.dg/weak/weak-5.c (test for excess errors)
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1a
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1b
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1c
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1d
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1e
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1f
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1g
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1h
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1i
    [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1j
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1k
    PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1l

These get 'dg-xfail-if'ed or 'dg-skip-if'ed, (mostly) similar to GCC/nvptx.

	PR target/119369
	gcc/
	* config/gcn/gcn-protos.h (gcn_asm_weaken_decl): Declare.
	* config/gcn/gcn.cc (gcn_asm_weaken_decl): New.
	* config/gcn/gcn-hsa.h (ASM_WEAKEN_DECL): '#define' to this.
	gcc/testsuite/
	* g++.dg/abi/pure-virtual1.C: 'dg-xfail-if' GCN.
	* g++.dg/cpp0x/pr84497.C: 'dg-skip-if' GCN.
	* g++.dg/ext/weak2.C: Likewise.
	* gcc.dg/attr-weakref-1.c: Likewise.
	* gcc.dg/weak/weak-1.c: Likewise.
	* gcc.dg/weak/weak-12.c: Likewise.
	* gcc.dg/weak/weak-15.c: Likewise.
	* gcc.dg/weak/weak-16.c: Likewise.
	* gcc.dg/weak/weak-2.c: Likewise.
	* gcc.dg/weak/weak-3.c: Likewise.
	* gcc.dg/weak/weak-4.c: Likewise.
	* gcc.dg/weak/weak-5.c: Likewise.

(cherry picked from commit 2f58d8ac03911063d6a8887a2bee7b4e25ac1871)
2025-04-02 09:40:14 +02:00
Thomas Schwinge
45fe2a8c8a GCN, libstdc++: '#define _GLIBCXX_USE_WEAK_REF 0' [PR119369]
This fixes a few hundreds of compilation/linking FAILs (similar to PR69506),
where the GCN/LLVM 'ld' reported:

    ld: error: relocation R_AMDGPU_REL32_LO cannot be used against symbol '_ZGTtnam'; recompile with -fPIC
    >>> defined in [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a(cow-stdexcept.o)
    >>> referenced by cow-stdexcept.cc:259 ([...]/libstdc++-v3/src/c++11/cow-stdexcept.cc:259)
    >>>               cow-stdexcept.o:(_txnal_cow_string_C1_for_exceptions(void*, char const*, void*)) in archive [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a

    ld: error: relocation R_AMDGPU_REL32_HI cannot be used against symbol '_ZGTtnam'; recompile with -fPIC
    >>> defined in [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a(cow-stdexcept.o)
    >>> referenced by cow-stdexcept.cc:259 ([...]/source-gcc/libstdc++-v3/src/c++11/cow-stdexcept.cc:259)
    >>>               cow-stdexcept.o:(_txnal_cow_string_C1_for_exceptions(void*, char const*, void*)) in archive [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a

    [...]

..., which is:

    $ c++filt _ZGTtnam
    transaction clone for operator new[](unsigned long)

..., and similarly for other libitm symbols.

However, the affected test cases, if applicable, then run into execution test
FAILs, due to PR119369
"GCN: weak undefined symbols -> execution test FAIL, 'HSA_STATUS_ERROR_VARIABLE_UNDEFINED'".

	PR target/119369
	libstdc++-v3/
	* config/cpu/gcn/cpu_defines.h: New.
	* configure.host [GCN] (cpu_defines_dir): Point to it.

(cherry picked from commit 816335960d020eac92d49bc9cd13729afd313da7)
2025-04-02 09:39:01 +02:00
Joern Rennecke
86feb06ab1 Fix PR testsuite/116271, gcc.dg/vect/tsvc/vect-tsvc-s176.c fails
gcc/testsuite:
	PR testsuite/116271
	* gcc.dg/vect/tsvc/vect-tsvc-s176.c [TRUNCATE_TEST]: Make sure
	that m stays the same as the loop bound of the middle loop.
	* gcc.dg/vect/tsvc/tsvc.h (get_expected_result) <s176> [TRUNCATE_TEST]:
	Adjust expected value.

(cherry picked from commit beb94f5979953969593a2387561cdbc8fedfaeb1)
2025-04-02 09:38:19 +02:00
Joern Rennecke
37cf0b5aba Reduce iteration counts for gcc.dg/vect/tsvc tests.
testsuite/
	* gcc.dg/vect/tsvc/tsvc.h (iterations): Allow to override,
	default to 10.
	(get_expected_result): Add values for iterations counts
	10, 256 and 3200.
	(run): Add code to output values for new iterations counts.
	* gcc.dg/vect/tsvc/vect-tsvc-s1119.c (dg-additional-options):
	Add -Diterations=LEN_2D .
	* gcc.dg/vect/tsvc/vect-tsvc-s115.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s119.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s125.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s2102.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s2233.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s2275.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s231.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s235.c: Likewise.
	* gcc.dg/vect/tsvc/vect-tsvc-s176.c: (dg-additional-options):
	Add -Diterations=3200 .
	[!run_expensive_tests]: dg-additional-options "-DTRUNCATE_TEST" .
	[TRUNCATE_TEST]: Set m to 32.

(cherry picked from commit 8fac69a2dbff98ebe1feb87faba0d9b81a173c40)
2025-04-02 09:37:49 +02:00
Richard Biener
c839965c2e debug/101533 - ICE with variant typedef DIE generation
There's a sanity check in gen_type_die_with_usage that trips
unnecessarily for a case where the relevant DIE has already been
generated successfully in other ways.  The following keys the
existing TREE_ASM_WRITTEN check on the correct object, honoring
this and does nothing instead of ICEing for the testcase at hand.

	PR debug/101533
	* dwarf2out.cc (gen_type_die_with_usage): When we have
	output the typedef already do nothing for a typedef variant.
	Do not set TREE_ASM_WRITTEN on the type.

	* g++.dg/debug/pr101533.C: New testcase.

(cherry picked from commit 99a3f013c3bb8bc022ca488b40aa18fd97b5224d)
2025-04-02 09:23:07 +02:00
Richard Biener
a57c877f88 middle-end/101478 - ICE with degenerate address during gimplification
When we gimplify &MEM[0B + 4] we are re-folding the address in case
types are not canonical which ends up with a constant address that
recompute_tree_invariant_for_addr_expr ICEs on.  Properly guard
that call.

	PR middle-end/101478
	* gimplify.cc (gimplify_addr_expr): Check we still have an
	ADDR_EXPR before calling recompute_tree_invariant_for_addr_expr.

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

(cherry picked from commit 33ead6400ad59d4b38fa0527a9a7b53a28114ab7)
2025-04-02 09:23:07 +02:00
Richard Biener
9d516fb8ea tree-optimization/98845 - ICE with tail-merging and DCE/DSE disabled
The following shows that tail-merging will make dead SSA defs live
in paths where it wasn't before, possibly introducing UB or as
in this case, uses of abnormals that eventually fail coalescing
later.  The fix is to register such defs for stmt comparison.

	PR tree-optimization/98845
	* tree-ssa-tail-merge.cc (stmt_local_def): Consider a
	def with no uses not local.

	* gcc.dg/pr98845.c: New testcase.
	* gcc.dg/pr81192.c: Adjust.

(cherry picked from commit 6b8a8c9fd68c5dabaec5ddbc25efeade44f37a14)
2025-04-02 09:23:07 +02:00
Richard Biener
e3290933ea lto/91299 - weak definition inlined with LTO
The following fixes a thinko in the handling of interposed weak
definitions which confused the interposition check in
get_availability by setting DECL_EXTERNAL too early.

	PR lto/91299
gcc/lto/
	* lto-symtab.cc (lto_symtab_merge_symbols): Set DECL_EXTERNAL
	only after calling get_availability.

gcc/testsuite/
	* gcc.dg/lto/pr91299_0.c: New testcase.
	* gcc.dg/lto/pr91299_1.c: Likewise.

(cherry picked from commit bc34db5b12e008f6ec4fdf4ebd22263c8617e5e3)
2025-04-02 09:23:07 +02:00