Commit graph

204799 commits

Author SHA1 Message Date
Nathaniel Shead
b69ee50081 c++: Improve diagnostics for constexpr cast from void*
This patch improves the errors given when casting from void* in C++26 to
include the expected type if the types of the pointed-to objects were
not similar. It also ensures (for all standard modes) that void* casts
are checked even for DECL_ARTIFICIAL declarations, such as
lifetime-extended temporaries, and is only ignored for cases where we
know it's OK (e.g. source_location::current) or have no other choice
(heap-allocated data).

gcc/cp/ChangeLog:

	* constexpr.cc (is_std_source_location_current): New.
	(cxx_eval_constant_expression): Only ignore cast from void* for
	specific cases and improve other diagnostics.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Marek Polacek  <polacek@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2023-10-19 23:25:31 -04:00
GCC Administrator
c85f74813f Daily bump. 2023-10-20 00:16:39 +00:00
Marek Polacek
4d81962ba0 c++: small tweak for cp_fold_r
This patch is an optimization tweak for cp_fold_r.  If we cp_fold_r the
COND_EXPR's op0 first, we may be able to evaluate it to a constant if -O.
cp_fold has:

3143         if (callee && DECL_DECLARED_CONSTEXPR_P (callee)
3144             && !flag_no_inline)
...
3151             r = maybe_constant_value (x, /*decl=*/NULL_TREE,

flag_no_inline is 1 for -O0:

1124   if (opts->x_optimize == 0)
1125     {
1126       /* Inlining does not work if not optimizing,
1127          so force it not to be done.  */
1128       opts->x_warn_inline = 0;
1129       opts->x_flag_no_inline = 1;
1130     }

but otherwise it's 0 and cp_fold will maybe_constant_value calls to
constexpr functions.  And if it doesn't, then folding the COND_EXPR
will keep both arms, and we can avoid calling maybe_constant_value.

gcc/cp/ChangeLog:

	* cp-gimplify.cc (cp_fold_r): Don't call maybe_constant_value.
2023-10-19 16:18:14 -04:00
Marek Polacek
86d0b08664 doc: Update contrib.texi
I noticed that Patrick is missing here.

gcc/ChangeLog:

	* doc/contrib.texi: Add entry for Patrick Palka.
2023-10-19 16:16:01 -04:00
Andre Vieira
d8e4e7def3 vect: Use inbranch simdclones in masked loops
This patch enables the compiler to use inbranch simdclones when generating
masked loops in autovectorization.

gcc/ChangeLog:

	* omp-simd-clone.cc (simd_clone_adjust_argument_types): Make function
	compatible with mask parameters in clone.
	* tree-vect-stmts.cc (vect_build_all_ones_mask): Allow vector boolean
	typed masks.
	(vectorizable_simd_clone_call): Enable the use of masked clones in
	fully masked loops.
2023-10-19 18:30:25 +01:00
Andre Vieira
8b704ed0b8 vect: don't allow fully masked loops with non-masked simd clones [PR 110485]
When analyzing a loop and choosing a simdclone to use it is possible to choose
a simdclone that cannot be used 'inbranch' for a loop that can use partial
vectors.  This may lead to the vectorizer deciding to use partial vectors which
are not supported for notinbranch simd clones.  This patch fixes that by
disabling the use of partial vectors once a notinbranch simd clone has been
selected.

gcc/ChangeLog:

	PR tree-optimization/110485
	* tree-vect-stmts.cc (vectorizable_simd_clone_call): Disable partial
	vectors usage if a notinbranch simdclone has been selected.

gcc/testsuite/ChangeLog:

	* gcc.dg/gomp/pr110485.c: New test.
2023-10-19 18:30:25 +01:00
Andre Vieira
c9ce846763 vect: Fix vect_get_smallest_scalar_type for simd clones
The vect_get_smallest_scalar_type helper function was using any argument to a
simd clone call when trying to determine the smallest scalar type that would be
vectorized.  This included the function pointer type in a MASK_CALL for
instance, and would result in the wrong type being selected.  Instead this
patch special cases simd_clone_call's and uses only scalar types of the
original function that get transformed into vector types.

gcc/ChangeLog:

	* tree-vect-data-refs.cc (vect_get_smallest_scalar_type): Special case
	simd clone calls and only use types that are mapped to vectors.
	(simd_clone_call_p): New helper function.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-simd-clone-16f.c: Remove unnecessary differentation
	between targets with different pointer sizes.
	* gcc.dg/vect/vect-simd-clone-17f.c: Likewise.
	* gcc.dg/vect/vect-simd-clone-18f.c: Likewise.
2023-10-19 18:30:15 +01:00
Andre Vieira
53d40858c8 parloops: Allow poly nit and bound
Teach parloops how to handle a poly nit and bound e ahead of the changes to
enable non-constant simdlen.

gcc/ChangeLog:

	* tree-parloops.cc (try_transform_to_exit_first_loop_alt): Accept
	poly NIT and ALT_BOUND.
2023-10-19 18:27:18 +01:00
Andre Vieira
87d97e2607 parloops: Copy target and optimizations when creating a function clone
SVE simd clones require to be compiled with a SVE target enabled or the argument
types will not be created properly. To achieve this we need to copy
DECL_FUNCTION_SPECIFIC_TARGET from the original function declaration to the
clones.  I decided it was probably also a good idea to copy
DECL_FUNCTION_SPECIFIC_OPTIMIZATION in case the original function is meant to
be compiled with specific optimization options.

gcc/ChangeLog:

	* tree-parloops.cc (create_loop_fn): Copy specific target and
	optimization options to clone.
2023-10-19 18:26:45 +01:00
Andre Vieira
79a50a1740 omp: Replace simd_clone_subparts with TYPE_VECTOR_SUBPARTS
Refactor simd clone handling code ahead of support for poly simdlen.

gcc/ChangeLog:

	* omp-simd-clone.cc (simd_clone_subparts): Remove.
	(simd_clone_init_simd_arrays): Replace simd_clone_supbarts with
	TYPE_VECTOR_SUBPARTS.
	(ipa_simd_modify_function_body): Likewise.
	* tree-vect-stmts.cc (vectorizable_simd_clone_call): Likewise.
	(simd_clone_subparts): Remove.
2023-10-19 18:26:12 +01:00
François Dumont
c714b4d30d libstdc++: [_Hashtable] Do not reuse untrusted cached hash code
On merge, reuse a merged node's possibly cached hash code only if we are on the
same type of hash and this hash is stateless.

Usage of function pointers or std::function as hash functor will prevent reusing
cached hash code.

libstdc++-v3/ChangeLog

	* include/bits/hashtable_policy.h
	(_Hash_code_base::_M_hash_code(const _Hash&, const _Hash_node_value<>&)): Remove.
	(_Hash_code_base::_M_hash_code<_H2>(const _H2&, const _Hash_node_value<>&)): Remove.
	* include/bits/hashtable.h
	(_M_src_hash_code<_H2>(const _H2&, const key_type&, const __node_value_type&)): New.
	(_M_merge_unique<>, _M_merge_multi<>): Use latter.
	* testsuite/23_containers/unordered_map/modifiers/merge.cc
	(test04, test05, test06): New test cases.
2023-10-19 19:06:08 +02:00
Andrew Pinski
2454ba9e2d c: Fix ICE when an argument was an error mark [PR100532]
In the case of convert_argument, we would return the same expression
back rather than error_mark_node after the error message about
trying to convert to an incomplete type. This causes issues in
the gimplfier trying to see if another conversion is needed.

The code here dates back to before the revision history too so
it might be the case it never noticed we should return an error_mark_node.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR c/100532

gcc/c/ChangeLog:

	* c-typeck.cc (convert_argument): After erroring out
	about an incomplete type return error_mark_node.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr100532-1.c: New test.
2023-10-19 16:52:02 +00:00
Andrew Pinski
9f33e4c50e c: Don't warn about converting NULL to different sso endian [PR104822]
In a similar way we don't warn about NULL pointer constant conversion to
a different named address we should not warn to a different sso endian
either.
This adds the simple check.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR c/104822

gcc/c/ChangeLog:

	* c-typeck.cc (convert_for_assignment): Check for null pointer
	before warning about an incompatible scalar storage order.

gcc/testsuite/ChangeLog:

	* gcc.dg/sso-18.c: New test.
	* gcc.dg/sso-19.c: New test.
2023-10-19 09:49:13 -07:00
Jason Merrill
00e7c49fa0 ABOUT-GCC-NLS: add usage guidance
gcc/ChangeLog:

	* ABOUT-GCC-NLS: Add usage guidance.
2023-10-19 12:34:35 -04:00
Jason Merrill
1ec36bcda3 diagnostic: rename new permerror overloads
While checking another change, I noticed that the new permerror overloads
break gettext with "permerror used incompatibly as both
 --keyword=permerror:2 --flag=permerror:2:gcc-internal-format and
 --keyword=permerror:3 --flag=permerror:3:gcc-internal-format".  So let's
change the name.

gcc/ChangeLog:

	* diagnostic-core.h (permerror): Rename new overloads...
	(permerror_opt): To this.
	* diagnostic.cc: Likewise.

gcc/cp/ChangeLog:

	* typeck2.cc (check_narrowing): Adjust.
2023-10-19 11:44:13 -04:00
Jason Merrill
f53de2baae c++: use G_ instead of _
Since these strings are passed to error_at, they should be marked for
translation with G_, like other diagnostic messages, rather than _, which
forces immediate (redundant) translation.  The use of N_ is less
problematic, but also imprecise.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_primary_expression): Use G_.
	(cp_parser_using_enum): Likewise.
	* decl.cc (identify_goto): Likewise.
2023-10-19 11:30:03 -04:00
Yannick Moy
04d6c74564 ada: Support new SPARK aspect Side_Effects
SPARK RM 6.1.11 introduces a new aspect Side_Effects to denote
those functions which may have output parameters, write global
variables, raise exceptions and not terminate. This adds support
for this aspect and the corresponding pragma in the frontend.

Handling of this aspect in the frontend is very similar to
the handling of aspect Extensions_Visible: both are Boolean
aspects whose expression should be static, they can be specified
on the same entities, with the same rule of inheritance from
overridden to overriding primitives for tagged types.

There is no impact on code generation.

gcc/ada/

	* aspects.ads: Add aspect Side_Effects.
	* contracts.adb (Add_Pre_Post_Condition)
	(Inherit_Subprogram_Contract): Add support for new contract.
	* contracts.ads: Update comments.
	* einfo-utils.adb (Get_Pragma): Add support.
	* einfo-utils.ads (Prag): Update comment.
	* errout.ads: Add explain codes.
	* par-prag.adb (Prag): Add support.
	* sem_ch13.adb (Analyze_Aspect_Specifications)
	(Check_Aspect_At_Freeze_Point): Add support.
	* sem_ch6.adb (Analyze_Subprogram_Body_Helper)
	(Analyze_Subprogram_Declaration): Call new analysis procedure to
	check SPARK legality rules.
	(Analyze_SPARK_Subprogram_Specification): New procedure to check
	SPARK legality rules. Use an explain code for the error.
	(Analyze_Subprogram_Specification): Move checks to new subprogram.
	This code was effectively dead, as the kind for parameters was set
	to E_Void at this point to detect early references.
	* sem_ch6.ads (Analyze_Subprogram_Specification): Add new
	procedure.
	* sem_prag.adb (Analyze_Depends_In_Decl_Part)
	(Analyze_Global_In_Decl_Part): Adapt legality check to apply only
	to functions without side-effects.
	(Analyze_If_Present): Extract functionality in new procedure
	Analyze_If_Present_Internal.
	(Analyze_If_Present_Internal): New procedure to analyze given
	pragma kind.
	(Analyze_Pragmas_If_Present): New procedure to analyze given
	pragma kind associated with a declaration.
	(Analyze_Pragma): Adapt support for Always_Terminates and
	Exceptional_Cases. Add support for Side_Effects. Make sure to call
	Analyze_If_Present to ensure pragma Side_Effects is analyzed prior
	to analyzing pragmas Global and Depends. Use explain codes for the
	errors.
	* sem_prag.ads (Analyze_Pragmas_If_Present): Add new procedure.
	* sem_util.adb (Is_Function_With_Side_Effects): New query function
	to determine if a function is a function with side-effects.
	* sem_util.ads (Is_Function_With_Side_Effects): Same.
	* snames.ads-tmpl: Declare new names for pragma and aspect.
	* doc/gnat_rm/implementation_defined_aspects.rst: Document new aspect.
	* doc/gnat_rm/implementation_defined_pragmas.rst: Document new pragma.
	* gnat_rm.texi: Regenerate.
2023-10-19 16:35:22 +02:00
Sheri Bernstein
c1fbfe5acb ada: Refactor code to remove GNATcheck violation
Rewrite for loop containing an exit (which violates GNATcheck
rule Exits_From_Conditional_Loops), to use a while loop
which contains the exit criteria in its condition.
Also, move special case of first time through loop, to come
before loop.

gcc/ada/

	* libgnat/s-imagef.adb (Set_Image_Fixed): Refactor loop.
2023-10-19 16:35:22 +02:00
Sheri Bernstein
0f3c634840 ada: Add pragma Annotate for GNATcheck exemptions
Exempt the GNATcheck rule "Unassigned_OUT_Parameters"
with the rationale "the OUT parameter is assigned by component".

gcc/ada/

	* libgnat/s-imguti.adb (Set_Decimal_Digits): Add pragma to exempt
	Unassigned_OUT_Parameters.
	(Set_Floating_Invalid_Value): Likewise
2023-10-19 16:35:22 +02:00
Patrick Bernardi
1555d18143 ada: Document gnatbind -Q switch
Add documentation for the -Q gnatbind switch in GNAT User's Guide and
improve gnatbind's help output for the switch to emphasize that it adds the
requested number of stacks to the secondary stack pool generated by the
binder.

gcc/ada/

	* bindusg.adb (Display): Make it clear -Q adds to the number of
	secondary stacks generated by the binder.
	* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
	Document the -Q gnatbind switch and fix references to old
	runtimes.
	* gnat-style.texi: Regenerate.
	* gnat_rm.texi: Regenerate.
	* gnat_ugn.texi: Regenerate.
2023-10-19 16:35:21 +02:00
Ronan Desplanques
0c29a990a6 ada: Seize opportunity to reuse List_Length
This patch is intended as a readability improvement. It doesn't
change the behavior of the compiler.

gcc/ada/

	* sem_ch3.adb (Constrain_Array): Replace manual list length
	computation by call to List_Length.
2023-10-19 16:35:21 +02:00
Piotr Trojanek
7b1b787baa ada: Simplify "not Present" with "No"
gcc/ada/

	* exp_aggr.adb (Expand_Container_Aggregate): Simplify with "No".
2023-10-19 16:35:21 +02:00
Lewis Hyatt
19cc4b9d74 c++: Make -Wunknown-pragmas controllable by #pragma GCC diagnostic [PR89038]
As noted on the PR, commit r13-1544, the fix for PR53431, did not handle
the specific case of -Wunknown-pragmas, because that warning is issued
during preprocessing, but not by libcpp directly (it comes from the
cb_def_pragma callback).  Address that by handling this pragma in
addition to libcpp pragmas during the early pragma handler.

gcc/c-family/ChangeLog:

	PR c++/89038
	* c-pragma.cc (handle_pragma_diagnostic_impl):  Handle
	-Wunknown-pragmas during early processing.

gcc/testsuite/ChangeLog:

	PR c++/89038
	* c-c++-common/cpp/Wunknown-pragmas-1.c: New test.
2023-10-19 09:09:39 -04:00
Lewis Hyatt
202a214d68 libcpp: testsuite: Add test for fixed _Pragma bug [PR82335]
This PR was fixed by r12-4797 and r12-5454. Add test coverage from the PR
that is not represented elsewhere.

gcc/testsuite/ChangeLog:

	PR preprocessor/82335
	* c-c++-common/cpp/diagnostic-pragma-3.c: New test.
2023-10-19 09:08:55 -04:00
Tamar Christina
217a0fcb85 middle-end: don't create LC-SSA PHI variables for PHI nodes who dominate loop
As the testcase shows, when a PHI node dominates the loop there is no new
definition inside the loop.  As such there would be no PHI nodes to update.

When we maintain LCSSA form we create an intermediate node in between the two
loops to thread alongt the value.  However later on when we update the second
loop we don't have any PHI nodes to update and so adjust_phi_and_debug_stmts
does nothing.   This leaves us with an incorrect phi node.  Normally this does
nothing and just gets ignored.  But in the case of the vUSE chain we end up
corrupting the chain.

As such whenever a PHI node's argument dominates the loop, we should remove
the newly created PHI node after edge redirection.

The one exception to this is when the loop has been versioned.  In such cases
the versioned loop may not use the value but the second loop can.

When this happens and we add the loop guard unless the join block has the PHI
it can't find the original value for use inside the guard block.

The next refactoring in the series moves the formation of the guard block
inside peeling itself.  Here we have all the information and wouldn't
need to re-create it later.

gcc/ChangeLog:

	PR tree-optimization/111860
	* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
	Remove PHI nodes that dominate loop.

gcc/testsuite/ChangeLog:

	PR tree-optimization/111860
	* gcc.dg/vect/pr111860.c: New test.
2023-10-19 13:44:01 +01:00
Richard Biener
beab5b95c5 tree-optimization/111131 - SLP for non-IFN gathers
The following implements SLP vectorization support for gathers
without relying on IFNs being pattern detected (and supported by
the target).  That includes support for emulated gathers but also
the legacy x86 builtin path.

	PR tree-optimization/111131
	* tree-vect-loop.cc (update_epilogue_loop_vinfo): Make
	sure to update all gather/scatter stmt DRs, not only those
	that eventually got VMAT_GATHER_SCATTER set.
	* tree-vect-slp.cc (_slp_oprnd_info::first_gs_info): Add.
	(vect_get_and_check_slp_defs): Handle gathers/scatters,
	adding the offset as SLP operand and comparing base and scale.
	(vect_build_slp_tree_1): Handle gathers.
	(vect_build_slp_tree_2): Likewise.

	* gcc.dg/vect/vect-gather-1.c: Now expected to vectorize
	everywhere.
	* gcc.dg/vect/vect-gather-2.c: Expected to not SLP anywhere.
	Massage the scale case to more reliably produce a different
	one.  Scan for the specific messages.
	* gcc.dg/vect/vect-gather-3.c: Masked gather is also supported
	for AVX2, but not emulated.
	* gcc.dg/vect/vect-gather-4.c: Expected to not SLP anywhere.
	Massage to more properly ensure this.
	* gcc.dg/vect/tsvc/vect-tsvc-s353.c: Expect to vectorize
	everywhere.
2023-10-19 14:25:36 +02:00
Richard Biener
b068886dcd Refactor x86 vectorized gather path
The following moves the builtin decl gather vectorization path along
the internal function and emulated gather vectorization paths,
simplifying the existing function down to generating the call and
required conversions to the actual argument types.  This thereby
exposes the unique support of two times larger number of offset
or data vector lanes.  It also makes the code path handle SLP
in principle (but SLP build needs adjustments for this, patch coming).

	* tree-vect-stmts.cc (vect_build_gather_load_calls): Rename
	to ...
	(vect_build_one_gather_load_call): ... this.  Refactor,
	inline widening/narrowing support ...
	(vectorizable_load): ... here, do gather vectorization
	with builtin decls along other gather vectorization.
2023-10-19 14:25:36 +02:00
Alex Coplan
947fb34a16 aarch64: Generalise TFmode load/store pair patterns
This patch generalises the TFmode load/store pair patterns to TImode and
TDmode.  This brings them in line with the DXmode patterns, and uses the
same technique with separate mode iterators (TX and TX2) to allow for
distinct modes in each arm of the load/store pair.

For example, in combination with the post-RA load/store pair fusion pass
in the following patch, this improves the codegen for the following
varargs testcase involving TImode stores:

void g(void *);
int foo(int x, ...)
{
    __builtin_va_list ap;
    __builtin_va_start (ap, x);
    g(&ap);
    __builtin_va_end (ap);
}

from:

foo:
.LFB0:
	stp	x29, x30, [sp, -240]!
.LCFI0:
	mov	w9, -56
	mov	w8, -128
	mov	x29, sp
	add	x10, sp, 176
	stp	x1, x2, [sp, 184]
	add	x1, sp, 240
	add	x0, sp, 16
	stp	x1, x1, [sp, 16]
	str	x10, [sp, 32]
	stp	w9, w8, [sp, 40]
	str	q0, [sp, 48]
	str	q1, [sp, 64]
	str	q2, [sp, 80]
	str	q3, [sp, 96]
	str	q4, [sp, 112]
	str	q5, [sp, 128]
	str	q6, [sp, 144]
	str	q7, [sp, 160]
	stp	x3, x4, [sp, 200]
	stp	x5, x6, [sp, 216]
	str	x7, [sp, 232]
	bl	g
	ldp	x29, x30, [sp], 240
.LCFI1:
	ret

to:

foo:
.LFB0:
	stp	x29, x30, [sp, -240]!
.LCFI0:
	mov	w9, -56
	mov	w8, -128
	mov	x29, sp
	add	x10, sp, 176
	stp	x1, x2, [sp, 1bd4971b7c71e70a637a1dq84]
	add	x1, sp, 240
	add	x0, sp, 16
	stp	x1, x1, [sp, 16]
	str	x10, [sp, 32]
	stp	w9, w8, [sp, 40]
	stp	q0, q1, [sp, 48]
	stp	q2, q3, [sp, 80]
	stp	q4, q5, [sp, 112]
	stp	q6, q7, [sp, 144]
	stp	x3, x4, [sp, 200]
	stp	x5, x6, [sp, 216]
	str	x7, [sp, 232]
	bl	g
	ldp	x29, x30, [sp], 240
.LCFI1:
	ret

Note that this patch isn't neeed if we only use the mode
canonicalization approach in the new ldp fusion pass (since we
canonicalize T{I,F,D}mode to V16QImode), but we seem to get slightly
better performance with mode canonicalization disabled (see
--param=aarch64-ldp-canonicalize-modes in the following patch).

gcc/ChangeLog:

	* config/aarch64/aarch64.md (load_pair_dw_tftf): Rename to ...
	(load_pair_dw_<TX:mode><TX2:mode>): ... this.
	(store_pair_dw_tftf): Rename to ...
	(store_pair_dw_<TX:mode><TX2:mode>): ... this.
	* config/aarch64/iterators.md (TX2): New.
2023-10-19 11:12:23 +01:00
Alex Coplan
61ea0a89c6 aarch64, testsuite: Fix up pr71727.c
The test is trying to check that we don't use q-register stores with
-mstrict-align, so actually check specifically for that.

This is a prerequisite to avoid regressing:

scan-assembler-not "add\tx0, x0, :"

with the upcoming ldp fusion pass, as we change where the ldps are
formed such that a register is used rather than a symbolic (lo_sum)
address for the first load.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pr71727.c: Adjust scan-assembler-not to
	make sure we don't have q-register stores with -mstrict-align.
2023-10-19 11:12:23 +01:00
Alex Coplan
cf776eebe8 aarch64, testsuite: Tweak sve/pcs/args_9.c to allow stps
With the new ldp/stp pass enabled, there is a change in the codegen for
this test as follows:

        add     x8, sp, 16
        ptrue   p3.h, mul3
        str     p3, [x8]
-       str     x8, [sp, 8]
-       str     x9, [sp]
+       stp     x9, x8, [sp]
        ptrue   p3.d, vl8
        ptrue   p2.s, vl7
        ptrue   p1.h, vl6

i.e. we now form an stp that we were missing previously. This patch
adjusts the scan-assembler such that it should pass whether or not
we form the stp.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/sve/pcs/args_9.c: Adjust scan-assemblers to
	allow for stp.
2023-10-19 11:12:23 +01:00
Alex Coplan
583ca5f599 aarch64, testsuite: Prevent stp in lr_free_1.c
The test is looking for individual stores which are able to be merged
into stp instructions.  The test currently passes -fno-schedule-fusion
-fno-peephole2, presumably to prevent these stores from being turned
into stps, but this is no longer sufficient with the new ldp/stp fusion
pass.

As such, we add --param=aarch64-stp-policy=never to prevent stps being
formed.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/lr_free_1.c: Add
	--param=aarch64-stp-policy=never to dg-options.
2023-10-19 11:12:23 +01:00
Alex Coplan
505f1202e3 rtl-ssa: Support inferring uses of mem in change_insns
Currently, rtl_ssa::change_insns requires all new uses and defs to be
specified explicitly.  This turns out to be rather inconvenient for
forming load pairs in the new aarch64 load pair pass, as the pass has to
determine which mem def the final load pair consumes, and then obtain or
create a suitable use (i.e. significant bookkeeping, just to keep the
RTL-SSA IR consistent).  It turns out to be much more convenient to
allow change_insns to infer which def is consumed and create a suitable
use of mem itself.  This patch does that.

gcc/ChangeLog:

	* rtl-ssa/changes.cc (function_info::finalize_new_accesses): Add new
	parameter to give final insn position, infer use of mem if it isn't
	specified explicitly.
	(function_info::change_insns): Pass down final insn position to
	finalize_new_accesses.
	* rtl-ssa/functions.h: Add parameter to finalize_new_accesses.
2023-10-19 11:12:23 +01:00
Alex Coplan
ba230aa1b8 rtl-ssa: Add entry point to allow re-parenting uses
This is needed by the upcoming aarch64 load pair pass, as it can
re-order stores (when alias analysis determines this is safe) and thus
change which mem def a given use consumes (in the RTL-SSA view, there is
no alias disambiguation of memory).

gcc/ChangeLog:

	* rtl-ssa/accesses.cc (function_info::reparent_use): New.
	* rtl-ssa/functions.h (function_info): Declare new member
	function reparent_use.
2023-10-19 11:12:22 +01:00
Alex Coplan
c95aab23c1 rtl-ssa: Add drop_memory_access helper
Add a helper routine to access-utils.h which removes the memory access
from an access_array, if it has one.

gcc/ChangeLog:

	* rtl-ssa/access-utils.h (drop_memory_access): New.
2023-10-19 11:12:22 +01:00
Alex Coplan
c338083377 rtl-ssa: Fix bug in function_info::add_insn_after
In the case that !insn->is_debug_insn () && next->is_debug_insn (), this
function was missing an update of the prev pointer on the first nondebug
insn following the sequence of debug insns starting at next.

This can lead to corruption of the insn chain, in that we end up with:

  insn->next_any_insn ()->prev_any_insn () != insn

in this case.  This patch fixes that.

gcc/ChangeLog:

	* rtl-ssa/insns.cc (function_info::add_insn_after): Ensure we
	update the prev pointer on the following nondebug insn in the
	case that !insn->is_debug_insn () && next->is_debug_insn ().
2023-10-19 11:12:22 +01:00
Haochen Jiang
faa0e82b40 x86: Correct ISA enabled for clients since Arrow Lake
gcc/ChangeLog:

	* config/i386/i386.h: Correct the ISA enabled for Arrow Lake.
	Also make Clearwater Forest depends on Sierra Forest.
	* config/i386/i386-options.cc: Revise the order of the macro
	definition to avoid confusion.
	* doc/extend.texi: Revise documentation.
	* doc/invoke.texi: Correct documentation.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/funcspec-56.inc: Group Clearwater Forest
	with atom cores.
2023-10-19 17:08:36 +08:00
Andrew Stubbs
56ed1055b2 amdgcn: deprecate Fiji device and multilib
LLVM wants to remove it, which breaks our build.  This patch means that
most users won't notice that change, when it comes, and those that do will
have chosen to enable Fiji explicitly.

I'm selecting gfx900 as the new default as that's the least likely for users
to want, which means most users will specify -march explicitly, which means
we'll be free to change the default again, when we need to, without breaking
anybody's makefiles.

gcc/ChangeLog:

	* config.gcc (amdgcn): Switch default to --with-arch=gfx900.
	Implement support for --with-multilib-list.
	* config/gcn/t-gcn-hsa: Likewise.
	* doc/install.texi: Likewise.
	* doc/invoke.texi: Mark Fiji deprecated.
2023-10-19 09:46:57 +01:00
Jiahao Xu
8f4bbdc28d LoongArch:Implement the new vector cost model framework.
This patch make loongarch use the new vector hooks and implements the costing
function determine_suggested_unroll_factor, to make it be able to suggest the
unroll factor for a given loop being vectorized base vec_ops analysis during
vector costing and the available issue information. Referring to aarch64 and
rs6000 port.

The patch also reduces the cost of unaligned stores, making it equal to the
cost of aligned ones in order to avoid odd alignment peeling.

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_vector_costs): Inherit from
	vector_costs.  Add a constructor.
	(loongarch_vector_costs::add_stmt_cost): Use adjust_cost_for_freq to
	adjust the cost for inner loops.
	(loongarch_vector_costs::count_operations): New function.
	(loongarch_vector_costs::determine_suggested_unroll_factor): Ditto.
	(loongarch_vector_costs::finish_cost): Ditto.
	(loongarch_builtin_vectorization_cost): Adjust.
	* config/loongarch/loongarch.opt (loongarch-vect-unroll-limit): New parameter.
	(loongarcg-vect-issue-info): Ditto.
	(mmemvec-cost): Delete.
	* config/loongarch/genopts/loongarch.opt.in
	(loongarch-vect-unroll-limit): Ditto.
	(loongarcg-vect-issue-info): Ditto.
	(mmemvec-cost): Delete.
	* doc/invoke.texi (loongarcg-vect-unroll-limit): Document new option.
2023-10-19 14:15:38 +08:00
Jiahao Xu
08813894fd LoongArch:Implement vec_widen standard names.
Add support for vec_widen lo/hi patterns.  These do not directly
match on Loongarch lasx instructions but can be emulated with
even/odd + vector merge.

gcc/ChangeLog:

	* config/loongarch/lasx.md
	(vec_widen_<su>mult_even_v8si): New patterns.
	(vec_widen_<su>add_hi_<mode>): Ditto.
	(vec_widen_<su>add_lo_<mode>): Ditto.
	(vec_widen_<su>sub_hi_<mode>): Ditto.
	(vec_widen_<su>sub_lo_<mode>): Ditto.
	(vec_widen_<su>mult_hi_<mode>): Ditto.
	(vec_widen_<su>mult_lo_<mode>): Ditto.
	* config/loongarch/loongarch.md (u_bool): New iterator.
	* config/loongarch/loongarch-protos.h
	(loongarch_expand_vec_widen_hilo): New prototype.
	* config/loongarch/loongarch.cc
	(loongarch_expand_vec_interleave): New function.
	(loongarch_expand_vec_widen_hilo): New function.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/vect-widen-add.c: New test.
	* gcc.target/loongarch/vect-widen-mul.c: New test.
	* gcc.target/loongarch/vect-widen-sub.c: New test.
2023-10-19 14:15:35 +08:00
Jiahao Xu
a7b7284fe1 LoongArch:Implement avg and sad standard names.
gcc/ChangeLog:

	* config/loongarch/lasx.md
	(avg<mode>3_ceil): New patterns.
	(uavg<mode>3_ceil): Ditto.
	(avg<mode>3_floor): Ditto.
	(uavg<mode>3_floor): Ditto.
	(usadv32qi): Ditto.
	(ssadv32qi): Ditto.
	* config/loongarch/lsx.md
	(avg<mode>3_ceil): New patterns.
	(uavg<mode>3_ceil): Ditto.
	(avg<mode>3_floor): Ditto.
	(uavg<mode>3_floor): Ditto.
	(usadv16qi): Ditto.
	(ssadv16qi): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/avg-ceil-lasx.c: New test.
	* gcc.target/loongarch/avg-ceil-lsx.c: New test.
	* gcc.target/loongarch/avg-floor-lasx.c: New test.
	* gcc.target/loongarch/avg-floor-lsx.c: New test.
	* gcc.target/loongarch/sad-lasx.c: New test.
	* gcc.target/loongarch/sad-lsx.c: New test.
2023-10-19 14:15:31 +08:00
GCC Administrator
0308461d9d Daily bump. 2023-10-19 00:18:05 +00:00
Andrew Pinski
b20dbddcc4 Fix expansion of (a & 2) != 1
I had a thinko in r14-1600-ge60593f3881c72a96a3fa4844d73e8a2cd14f670
where we would remove the `& CST` part if we ended up not calling
expand_single_bit_test.
This fixes the problem by introducing a new variable that will be used
for calling expand_single_bit_test.
As afar as I know this can only show up when disabling optimization
passes as this above form would have been optimized away.

Committed as obvious after a bootstrap/test on x86_64-linux-gnu.

	PR middle-end/111863

gcc/ChangeLog:

	* expr.cc (do_store_flag): Don't over write arg0
	when stripping off `& POW2`.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/execute/pr111863-1.c: New test.
2023-10-18 15:11:39 -07:00
Andrew Pinski
879c91fccc [c] Fix PR 101364: ICE after error due to diagnose_arglist_conflict not checking for error
When checking to see if we have a function declaration has a conflict due to
promotations, there is no test to see if the type was an error mark and then calls
c_type_promotes_to. c_type_promotes_to is not ready for error_mark and causes an
ICE.

This adds a check for error before the call of c_type_promotes_to.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR c/101364

gcc/c/ChangeLog:

	* c-decl.cc (diagnose_arglist_conflict): Test for
	error mark before calling of c_type_promotes_to.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr101364-1.c: New test.
2023-10-18 15:11:39 -07:00
Andrew Pinski
11e6bcedb4 Fix ICE due to c_safe_arg_type_equiv_p not checking for error_mark node
This is a simple error recovery issue when c_safe_arg_type_equiv_p
was added in r8-5312-gc65e18d3331aa999. The issue is that after
an error, an argument type (of a function type) might turn
into an error mark node and c_safe_arg_type_equiv_p was not ready
for that. So this just adds a check for error operand for its
arguments before getting the main variant.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR c/101285

gcc/c/ChangeLog:

	* c-typeck.cc (c_safe_arg_type_equiv_p): Return true for error
	operands early.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr101285-1.c: New test.
2023-10-18 15:11:38 -07:00
Prathamesh Kulkarni
3ec8ecb8e9 PR111648: Fix wrong code-gen due to incorrect VEC_PERM_EXPR folding.
gcc/ChangeLog:
	PR tree-optimization/111648
	* fold-const.cc (valid_mask_for_fold_vec_perm_cst_p): If a1
	chooses base element from arg, ensure that it's a natural stepped
	sequence.
	(build_vec_cst_rand): New param natural_stepped and use it to
	construct a naturally stepped sequence.
	(test_nunits_min_2): Add new unit tests Case 6 and Case 7.
2023-10-19 00:29:38 +05:30
Dimitar Dimitrov
fe9767eedc pru: Implement TARGET_INSN_COST
This patch slightly improves the embench-iot benchmark score for
PRU code size.  There is also small improvement in a few real-world
firmware programs.

  Embench-iot size
  ------------------------------------------
  Benchmark          before   after    delta
  ---------           ----    ----     -----
  aha-mont64          4.15    4.15         0
  crc32               6.04    6.04         0
  cubic              21.64   21.62     -0.02
  edn                 6.37    6.37         0
  huffbench          18.63   18.55     -0.08
  matmult-int         5.44    5.44         0
  md5sum             25.56   25.43     -0.13
  minver             12.82   12.76     -0.06
  nbody              15.09   14.97     -0.12
  nettle-aes          4.75    4.75         0
  nettle-sha256       4.67    4.67         0
  nsichneu            3.77    3.77         0
  picojpeg            4.11    4.11         0
  primecount          7.90    7.90         0
  qrduino             7.18    7.16     -0.02
  sglib-combined     13.63   13.59     -0.04
  slre                5.19    5.19         0
  st                 14.23   14.12     -0.11
  statemate           2.34    2.34         0
  tarfind            36.85   36.64     -0.21
  ud                 10.51   10.46     -0.05
  wikisort            7.44    7.41     -0.03
  ---------          -----   -----
  Geometric mean      8.42    8.40     -0.02
  Geometric SD        2.00    2.00         0
  Geometric range    12.68   12.62     -0.06

gcc/ChangeLog:

	* config/pru/pru.cc (pru_insn_cost): New function.
	(TARGET_INSN_COST): Define for PRU.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2023-10-18 20:16:20 +03:00
Georg-Johann Lay
67f7bf78ba LibF7: Implement mul_mant for devices without MUL instruction.
libgcc/config/avr/libf7/
	* libf7-asm.sx (mul_mant): Implement for devices without MUL.
	* asm-defs.h (wmov) [!HAVE_MUL]: Fix regno computation.
	* t-libf7 (F7_ASM_FLAGS): Add -g0.
2023-10-18 19:00:09 +02:00
Andrew Carlotti
ff05a3e91d aarch64: Replace duplicated selftests
gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_test_fractional_cost):
	Test <= instead of testing < twice.
2023-10-18 16:23:24 +01:00
Jakub Jelinek
bc4bd69faf cse: Workaround GCC < 5 bug in cse_insn [PR111852]
Before the r5-3834 commit for PR63362, GCC 4.8-4.9 refuses to compile
cse.cc which contains a variable with rtx_def type, because rtx_def
contains a union with poly_uint16 element.  poly_int template has
defaulted default constructor and a variadic template constructor which
could have empty parameter pack. GCC < 5 treated it as non-trivially
constructible class and deleted rtunion and rtx_def default constructors.

For the cse_insn purposes, all we need is a variable with size and alignment
of rtx_def, not necessarily rtx_def itself, which we then memset to 0 and
fill in like rtx is normally allocated from heap, so this patch for
GCC_VERSION < 5000 uses an unsigned char array of the right size/alignment.

2023-10-18  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/111852
	* cse.cc (cse_insn): Add workaround for GCC 4.8-4.9, instead of
	using rtx_def type for memory_extend_buf, use unsigned char
	arrayy with size of rtx_def and its alignment.
2023-10-18 17:01:26 +02:00
Jason Merrill
ef10cb8683 diagnostic: add permerror variants with opt
In the discussion of promoting some pedwarns to be errors by default, rather
than move them all into -fpermissive it seems to me to make sense to support
DK_PERMERROR with an option flag.  This way will also work with
-fpermissive, but users can also still use -Wno-error=narrowing to downgrade
that specific diagnostic rather than everything affected by -fpermissive.

So, for diagnostics that we want to make errors by default we can just
change the pedwarn call to permerror.

The tests check desired behavior for such a permerror in a system header
with various flags.  The patch preserves the existing permerror behavior of
ignoring -w and system headers by default, but respecting them when
downgraded to a warning by -fpermissive.

This seems similar to but a bit better than the approach of forcing
-pedantic-errors that I previously used for -Wnarrowing: specifically, in
that now -w by itself is not enough to silence the -Wnarrowing
error (integer-pack2.C).

gcc/ChangeLog:

	* doc/invoke.texi: Move -fpermissive to Warning Options.
	* diagnostic.cc (update_effective_level_from_pragmas): Remove
	redundant system header check.
	(diagnostic_report_diagnostic): Move down syshdr/-w check.
	(diagnostic_impl): Handle DK_PERMERROR with an option number.
	(permerror): Add new overloads.
	* diagnostic-core.h (permerror): Declare them.

gcc/cp/ChangeLog:

	* typeck2.cc (check_narrowing): Use permerror.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/integer-pack2.C: Add -fpermissive.
	* g++.dg/diagnostic/sys-narrow.h: New test.
	* g++.dg/diagnostic/sys-narrow1.C: New test.
	* g++.dg/diagnostic/sys-narrow1a.C: New test.
	* g++.dg/diagnostic/sys-narrow1b.C: New test.
	* g++.dg/diagnostic/sys-narrow1c.C: New test.
	* g++.dg/diagnostic/sys-narrow1d.C: New test.
	* g++.dg/diagnostic/sys-narrow1e.C: New test.
	* g++.dg/diagnostic/sys-narrow1f.C: New test.
	* g++.dg/diagnostic/sys-narrow1g.C: New test.
	* g++.dg/diagnostic/sys-narrow1h.C: New test.
	* g++.dg/diagnostic/sys-narrow1i.C: New test.
2023-10-18 10:00:25 -04:00