]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
8 months agoOpenMP: C++ front-end support for dispatch + adjust_args
Paul-Antoine Arras [Wed, 20 Nov 2024 14:28:58 +0000 (15:28 +0100)] 
OpenMP: C++ front-end support for dispatch + adjust_args

This patch adds C++ support for the `dispatch` construct and the `adjust_args`
clause. It relies on the c-family bits comprised in the corresponding C front
end patch for pragmas and attributes.

Additional C/C++ common testcases are provided in a subsequent patch in the
series.

gcc/cp/ChangeLog:

* decl.cc (omp_declare_variant_finalize_one): Set adjust_args
need_device_ptr attribute.
* parser.cc (cp_parser_direct_declarator): Update call to
cp_parser_late_return_type_opt.
(cp_parser_late_return_type_opt): Add 'tree parms' parameter. Update
call to cp_parser_late_parsing_omp_declare_simd.
(cp_parser_omp_clause_name): Handle nocontext and novariants clauses.
(cp_parser_omp_clause_novariants): New function.
(cp_parser_omp_clause_nocontext): Likewise.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_NOVARIANTS and
PRAGMA_OMP_CLAUSE_NOCONTEXT.
(cp_parser_omp_dispatch_body): New function, inspired from
cp_parser_assignment_expression and cp_parser_postfix_expression.
(OMP_DISPATCH_CLAUSE_MASK): Define.
(cp_parser_omp_dispatch): New function.
(cp_finish_omp_declare_variant): Add parameter. Handle adjust_args
clause.
(cp_parser_late_parsing_omp_declare_simd): Add parameter. Update calls
to cp_finish_omp_declare_variant and cp_finish_omp_declare_variant.
(cp_parser_omp_construct): Handle PRAGMA_OMP_DISPATCH.
(cp_parser_pragma): Likewise.
* semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_NOCONTEXT and
OMP_CLAUSE_NOVARIANTS.
* pt.cc (tsubst_omp_clauses): Handle OMP_CLAUSE_NOCONTEXT and
OMP_CLAUSE_NOVARIANTS.
(tsubst_stmt): Handle OMP_DISPATCH.
(tsubst_expr): Handle IFN_GOMP_DISPATCH.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/adjust-args-1.C: New test.
* g++.dg/gomp/adjust-args-2.C: New test.
* g++.dg/gomp/adjust-args-3.C: New test.
* g++.dg/gomp/dispatch-1.C: New test.
* g++.dg/gomp/dispatch-2.C: New test.
* g++.dg/gomp/dispatch-3.C: New test.
* g++.dg/gomp/dispatch-4.C: New test.
* g++.dg/gomp/dispatch-5.C: New test.
* g++.dg/gomp/dispatch-6.C: New test.
* g++.dg/gomp/dispatch-7.C: New test.

8 months agoOpenMP: C front-end support for dispatch + adjust_args
Paul-Antoine Arras [Wed, 20 Nov 2024 14:28:57 +0000 (15:28 +0100)] 
OpenMP: C front-end support for dispatch + adjust_args

This patch adds support to the C front-end to parse the `dispatch` construct and
the `adjust_args` clause. It also includes some common C/C++ bits for pragmas
and attributes.

Additional common C/C++ testcases are in a later patch in the series.

gcc/c-family/ChangeLog:

* c-attribs.cc (c_common_gnu_attributes): Add attribute for adjust_args
need_device_ptr.
* c-omp.cc (c_omp_directives): Uncomment dispatch.
* c-pragma.cc (omp_pragmas): Add dispatch.
* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_DISPATCH.
(enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_NOCONTEXT and
PRAGMA_OMP_CLAUSE_NOVARIANTS.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_dispatch): New function.
(c_parser_omp_clause_name): Handle nocontext and novariants clauses.
(c_parser_omp_clause_novariants): New function.
(c_parser_omp_clause_nocontext): Likewise.
(c_parser_omp_all_clauses): Handle nocontext and novariants clauses.
(c_parser_omp_dispatch_body): New function adapted from
c_parser_expr_no_commas.
(OMP_DISPATCH_CLAUSE_MASK): Define.
(c_parser_omp_dispatch): New function.
(c_finish_omp_declare_variant): Parse adjust_args.
(c_parser_omp_construct): Handle PRAGMA_OMP_DISPATCH.
* c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_NOVARIANTS and
OMP_CLAUSE_NOCONTEXT.

gcc/testsuite/ChangeLog:

* gcc.dg/gomp/adjust-args-1.c: New test.
* gcc.dg/gomp/dispatch-1.c: New test.
* gcc.dg/gomp/dispatch-2.c: New test.
* gcc.dg/gomp/dispatch-3.c: New test.
* gcc.dg/gomp/dispatch-4.c: New test.
* gcc.dg/gomp/dispatch-5.c: New test.

8 months agoOpenMP: middle-end support for dispatch + adjust_args
Paul-Antoine Arras [Wed, 20 Nov 2024 14:28:57 +0000 (15:28 +0100)] 
OpenMP: middle-end support for dispatch + adjust_args

This patch adds middle-end support for the `dispatch` construct and the
`adjust_args` clause. The heavy lifting is done in `gimplify_omp_dispatch` and
`gimplify_call_expr` respectively. For `adjust_args`, this mostly consists in
emitting a call to `omp_get_mapped_ptr` for the adequate device.

For dispatch, the following steps are performed:

* Handle the device clause, if any: set the default-device ICV at the top of the
dispatch region and restore its previous value at the end.

* Handle novariants and nocontext clauses, if any. Evaluate compile-time
constants and select a variant, if possible. Otherwise, emit code to handle all
possible cases at run time.

gcc/ChangeLog:

* builtins.cc (builtin_fnspec): Handle BUILT_IN_OMP_GET_MAPPED_PTR.
* gimple-low.cc (lower_stmt): Handle GIMPLE_OMP_DISPATCH.
* gimple-pretty-print.cc (dump_gimple_omp_dispatch): New function.
(pp_gimple_stmt_1): Handle GIMPLE_OMP_DISPATCH.
* gimple-walk.cc (walk_gimple_stmt): Likewise.
* gimple.cc (gimple_build_omp_dispatch): New function.
(gimple_copy): Handle GIMPLE_OMP_DISPATCH.
* gimple.def (GIMPLE_OMP_DISPATCH): Define.
* gimple.h (gimple_build_omp_dispatch): Declare.
(gimple_has_substatements): Handle GIMPLE_OMP_DISPATCH.
(gimple_omp_dispatch_clauses): New function.
(gimple_omp_dispatch_clauses_ptr): Likewise.
(gimple_omp_dispatch_set_clauses): Likewise.
(gimple_return_set_retval): Handle GIMPLE_OMP_DISPATCH.
* gimplify.cc (enum omp_region_type): Add ORT_DISPATCH.
(struct gimplify_omp_ctx): Add in_call_args.
(gimplify_call_expr): Handle need_device_ptr arguments.
(is_gimple_stmt): Handle OMP_DISPATCH.
(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_DEVICE in a dispatch
construct. Handle OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT.
(omp_has_novariants): New function.
(omp_has_nocontext): Likewise.
(omp_construct_selector_matches): Handle OMP_DISPATCH with nocontext
clause.
(find_ifn_gomp_dispatch): New function.
(gimplify_omp_dispatch): Likewise.
(gimplify_expr): Handle OMP_DISPATCH.
* gimplify.h (omp_has_novariants): Declare.
* internal-fn.cc (expand_GOMP_DISPATCH): New function.
* internal-fn.def (GOMP_DISPATCH): Define.
* omp-builtins.def (BUILT_IN_OMP_GET_MAPPED_PTR): Define.
(BUILT_IN_OMP_GET_DEFAULT_DEVICE): Define.
(BUILT_IN_OMP_SET_DEFAULT_DEVICE): Define.
* omp-general.cc (omp_construct_traits_to_codes): Add OMP_DISPATCH.
(struct omp_ts_info): Add dispatch.
(omp_resolve_declare_variant): Handle novariants. Adjust
DECL_ASSEMBLER_NAME.
* omp-low.cc (scan_omp_1_stmt): Handle GIMPLE_OMP_DISPATCH.
(lower_omp_dispatch): New function.
(lower_omp_1): Call it.
* tree-inline.cc (remap_gimple_stmt): Handle GIMPLE_OMP_DISPATCH.
(estimate_num_insns): Handle GIMPLE_OMP_DISPATCH.

8 months agoOpenMP: dispatch + adjust_args tree data structures and front-end interfaces
Paul-Antoine Arras [Wed, 20 Nov 2024 14:28:57 +0000 (15:28 +0100)] 
OpenMP: dispatch + adjust_args tree data structures and front-end interfaces

This patch introduces the OMP_DISPATCH tree node, as well as two new clauses
`nocontext` and `novariants`. It defines/exposes interfaces that will be
used in subsequent patches that add front-end and middle-end support, but
nothing generates these nodes yet.

gcc/ChangeLog:

* builtin-types.def (BT_FN_PTR_CONST_PTR_INT): New.
* omp-selectors.h (enum omp_ts_code): Add OMP_TRAIT_CONSTRUCT_DISPATCH.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_NOVARIANTS and
OMP_CLAUSE_NOCONTEXT.
* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_NOVARIANTS
and OMP_CLAUSE_NOCONTEXT.
(dump_generic_node): Handle OMP_DISPATCH.
* tree.cc (omp_clause_num_ops): Add OMP_CLAUSE_NOVARIANTS and
OMP_CLAUSE_NOCONTEXT.
(omp_clause_code_name): Add "novariants" and "nocontext".
* tree.def (OMP_DISPATCH): New.
* tree.h (OMP_DISPATCH_BODY): New macro.
(OMP_DISPATCH_CLAUSES): New macro.
(OMP_CLAUSE_NOVARIANTS_EXPR): New macro.
(OMP_CLAUSE_NOCONTEXT_EXPR): New macro.

gcc/fortran/ChangeLog:

* types.def (BT_FN_PTR_CONST_PTR_INT): Declare.

8 months agolibgccjit: Fix float playback for cross-compilation
Antoni Boucher [Sat, 21 Oct 2023 15:20:46 +0000 (11:20 -0400)] 
libgccjit: Fix float playback for cross-compilation

gcc/jit/ChangeLog:
PR jit/113343
* jit-playback.cc (new_rvalue_from_const): Fix to have the
correct value when cross-compiling.

8 months agoEnable symbolic backtraces on more Linux and BSD ports (continued)
Eric Botcazou [Wed, 20 Nov 2024 14:03:56 +0000 (15:03 +0100)] 
Enable symbolic backtraces on more Linux and BSD ports (continued)

gcc/ada
PR ada/117538
PR ada/117708
* Makefile.rtl (GNU Hurd): Add $(TRASYM_DWARF_UNIX_PAIRS).
(x86-64 kfreebsd): Likewise.
(aarch64 FreeBSD): Likewise.
(x86-64 DragonFly): Likewise.
(S390 Linux): Likewise and add Linux version of s-tsmona.adb.
(Mips Linux): Likewise.
(SPARC Linux): Likewise.
(HP/PA Linux): Linux.
(M68K Linux): Likewise.
(SH4 Linux): Likewise.
(Alpha Linux): Likewise.
(RISC-V Linux): Likewise.

8 months agolibgccjit: Add type checks in gcc_jit_block_add_assignment_op
Antoni Boucher [Wed, 18 Oct 2023 22:33:18 +0000 (18:33 -0400)] 
libgccjit: Add type checks in gcc_jit_block_add_assignment_op

gcc/jit/ChangeLog:

* libgccjit.cc (RETURN_IF_FAIL_PRINTF3): New macro.
(gcc_jit_block_add_assignment_op): Add numeric checks.

gcc/testsuite/ChangeLog:

* jit.dg/test-error-bad-assignment-op.c: New test.

8 months agolibgccjit: Support signed char flag
Antoni Boucher [Mon, 3 Oct 2022 23:11:39 +0000 (19:11 -0400)] 
libgccjit: Support signed char flag

gcc/jit/ChangeLog:

* dummy-frontend.cc (jit_langhook_init): Send flag_signed_char
argument to build_common_tree_nodes.

gcc/testsuite/ChangeLog:

* jit.dg/all-non-failing-tests.h: Add test-signed-char.c.
* jit.dg/test-signed-char.c: New test.

8 months agoaarch64: Add support for SME2p1
Richard Sandiford [Wed, 20 Nov 2024 13:27:42 +0000 (13:27 +0000)] 
aarch64: Add support for SME2p1

This patch adds support for FEAT_SME2p1.  There are two sets of
new instructions: MOVAZ to read from ZA and zero the source data,
and new forms of ZERO.  All of them require streaming mode.

MOVAZ can't reuse the existing UNSPEC_SME_READ* patterns because
of the write to ZA.  I did wonder about trying to use a define_subst,
but it seemed a bit too awkward.

gcc/
* config/aarch64/aarch64-option-extensions.def (sme2p1): New extension.
* doc/invoke.texi: Document it.
* config/aarch64/aarch64.h (TARGET_STREAMING_SME2p1): New macro.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Conditionally define __ARM_FEATURE_SME2p1.
* config/aarch64/iterators.md (UNSPEC_SME_READZ, UNSPEC_SME_READZ_HOR)
(UNSPEC_SME_READZ_VER): New unspecs.
(optab, hv): Handle them.
(SME_READZ_HV): New int iterator.
* config/aarch64/aarch64-sme.md
(UNSPEC_SME_ZERO_SLICES): New unspec.
(@aarch64_sme_<SME_READZ_HV:optab><v_int_container><mode>)
(*aarch64_sme_<SME_READZ_HV:optab><v_int_container><mode>_plus)
(@aarch64_sme_<SME_READZ_HV:optab><VNx1TI_ONLY:mode><SVE_FULL:mode>)
(@aarch64_sme_<SME_READZ_HV:optab><SVE_FULLx24:mode><mode>)
(*aarch64_sme_<SME_READZ_HV:optab><SVE_FULLx24:mode><mode>_plus)
(@aarch64_sme_readz<mode>, *aarch64_sme_readz<mode>_plus)
(@aarch64_sme_zero_za_slices<mode>): New patterns.
(*aarch64_sme_zero_za_slices<mode>_plus): Likewise.
* config/aarch64/aarch64-sve-builtins-shapes.h
(inherent_za_slice): Declare.
* config/aarch64/aarch64-sve-builtins-shapes.cc
(inherent_za_slice_def, inherent_za_slice): New shape.
* config/aarch64/aarch64-sve-builtins-sme.h (svreadz_za)
(svreadz_hor_za, svreadz_ver_za): Declare.
* config/aarch64/aarch64-sve-builtins-sme.cc
(svread_za_slice_base): New class, split out from...
(svread_za_impl): ...here.
(svreadz_za_impl, svreadz_za_tile_impl): New type aliases.
(zero_slices_mode): New function.
(svzero_za_impl::expand): Handle the slice forms.
(svreadz_za, svreadz_hor_za, svreadz_ver_za): New functions.
* config/aarch64/aarch64-sve-builtins-sme.def: Add the SME2p1
instructions.

gcc/testsuite/
* lib/target-supports.exp: Test the assembler for sve-b16b16 support.
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add tests for
__ARM_FEATURE_SME2p1.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za128.c: New test.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za16.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za16_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za16_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za32.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za32_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za32_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za64.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za64_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za64_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za8.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za8_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_hor_za8_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za16.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za16_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za16_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za32.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za32_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za32_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za64.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za64_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za64_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za8.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za8_vg2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_ver_za8_vg4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za32_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za32_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za64_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za64_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za8_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/readz_za8_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg2x1.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg2x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg2x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg4x1.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg4x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zero_za64_vg4x4.c: Likewise.

8 months agoaarch64: Add support for SME_B16B16
Richard Sandiford [Wed, 20 Nov 2024 13:27:41 +0000 (13:27 +0000)] 
aarch64: Add support for SME_B16B16

This patch adds support for the SME_B16B16 extension.  It follows
similar lines to the SME_F16F16 extension added earlier.

gcc/
* config/aarch64/aarch64-option-extensions.def
(sme-b16b16): New extension.
* doc/invoke.texi: Document it.
* config/aarch64/aarch64.h (TARGET_STREAMING_SME_B16B16): New macro.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Conditionally define __ARM_FEATURE_SME_B16B16.
* config/aarch64/aarch64-sve-builtins-sme.def: Add SME_B16B16 forms
of existing intrinsics.
* config/aarch64/aarch64-sme.md
(@aarch64_sme_<SME_BINARY_SLICE_HSDF:optab><mode>)
(*aarch64_sme_<SME_BINARY_SLICE_HSDF:optab><mode>_plus)
(@aarch64_sme_<SME_FP_TERNARY_SLICE:optab><mode><mode>)
(*aarch64_sme_<SME_FP_TERNARY_SLICE:optab><mode><mode>_plus)
(@aarch64_sme_single_<SME_FP_TERNARY_SLICE:optab><mode><mode>)
(*aarch64_sme_single_<SME_FP_TERNARY_SLICE:optab><mode><mode>_plus)
(@aarch64_sme_lane_<SME_FP_TERNARY_SLICE:optab><mode><mode>)
(*aarch64_sme_lane_<SME_FP_TERNARY_SLICE:optab><mode><mode>)
(@aarch64_sme_<SME_FP_MOP:optab><mode><mode>): Extend to BF16 modes.
* config/aarch64/aarch64-sve-builtins.cc (TYPES_za_h_bfloat): New
type macro.
* config/aarch64/iterators.md (SME_ZA_HSDFx24): Add BF16 modes.
(SME_MOP_HSDF): Likewise.

gcc/testsuite/
* lib/target-supports.exp: Test the assembler for sve-b16b16 support.
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add tests for
__ARM_FEATURE_SME_B16B16.
* gcc.target/aarch64/sme2/acle-asm/add_za16_bf16_vg1x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/add_za16_bf16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_lane_za16_bf16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_lane_za16_bf16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_za16_bf16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_za16_bf16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_lane_za16_bf16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_lane_za16_bf16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_za16_bf16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_za16_bf16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mopa_za16_bf16.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mops_za16_bf16.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/sub_za16_bf16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/sub_za16_bf16_vg1x4.c: Likewise.

8 months agoaarch64: Add support for SME_F16F16
Richard Sandiford [Wed, 20 Nov 2024 13:27:41 +0000 (13:27 +0000)] 
aarch64: Add support for SME_F16F16

This patch adds support for the SME_F16F16 extension.  The extension
adds two new instructions to convert from a single vector of f16s
to two vectors of f32s.  It also adds f16 variants of existing SME
ZA instructions.

gcc/
* config/aarch64/aarch64-option-extensions.def
(sme-f16f16): New extension.
* doc/invoke.texi: Document it.  Also document that sme-i16i64 and
sme-f64f64 enable SME.
* config/aarch64/aarch64.h (TARGET_STREAMING_SME_F16F16): New macro.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Conditionally define __ARM_FEATURE_SME_F16F16.
* config/aarch64/aarch64-sve-builtins-sve2.def (svcvt, svcvtl): Add
new SME_F16F16 intrinsics.
* config/aarch64/aarch64-sve-builtins-sme.def: Add SME_F16F16 forms
of existing intrinsics.
* config/aarch64/aarch64-sve-builtins.cc (TYPES_h_float)
(TYPES_cvt_f32_f16, TYPES_za_h_float): New type macros.
* config/aarch64/aarch64-sve-builtins-base.cc
(svcvt_impl::expand): Add sext_optab as another possibility.
* config/aarch64/aarch64-sve-builtins-sve2.h (svcvtl): Declare.
* config/aarch64/aarch64-sve-builtins-sve2.cc (svcvtl_impl): New class.
(svcvtl): New function.
* config/aarch64/iterators.md (VNx8SF_ONLY): New mode iterator.
(SME_ZA_SDFx24): Replace with...
(SME_ZA_HSDFx24): ...this.
(SME_MOP_SDF): Replace with...
(SME_MOP_HSDF): ...this.
(SME_BINARY_SLICE_SDF): Replace with...
(SME_BINARY_SLICE_HSDF): ...this.
* config/aarch64/aarch64-sve2.md (extendvnx8hfvnx8sf2)
(@aarch64_sve_cvtl<mode>): New patterns.
* config/aarch64/aarch64-sme.md
(@aarch64_sme_<SME_BINARY_SLICE_SDF:optab><mode>): Extend to...
(@aarch64_sme_<SME_BINARY_SLICE_HSDF:optab><mode>): ...this.
(*aarch64_sme_<SME_BINARY_SLICE_SDF:optab><mode>_plus): Extend to...
(*aarch64_sme_<SME_BINARY_SLICE_HSDF:optab><mode>_plus): ...this.
(@aarch64_sme_<SME_FP_TERNARY_SLICE:optab><mode><mode>): Extend to
HF modes.
(*aarch64_sme_<SME_FP_TERNARY_SLICE:optab><mode><mode>_plus)
(@aarch64_sme_single_<SME_FP_TERNARY_SLICE:optab><mode><mode>)
(*aarch64_sme_single_<SME_FP_TERNARY_SLICE:optab><mode><mode>_plus)
(@aarch64_sme_lane_<SME_FP_TERNARY_SLICE:optab><mode><mode>)
(*aarch64_sme_lane_<SME_FP_TERNARY_SLICE:optab><mode><mode>)
(@aarch64_sme_<SME_FP_MOP:optab><mode><mode>): Likewise.

gcc/testsuite/
* lib/target-supports.exp: Test the assembler for sve-f16f16 support.
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add tests for
__ARM_FEATURE_SME_F16F16.  Also extend the existing SME tests.
* gcc.target/aarch64/sve/acle/asm/test_sve_acle.h
(TEST_X2_WIDE): New macro
* gcc.target/aarch64/sme2/acle-asm/add_za16_f16_vg1x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/add_za16_f16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/cvt_f32_f16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/cvtl_f32_f16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_lane_za16_f16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_lane_za16_f16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_za16_f16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mla_za16_f16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_lane_za16_f16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_lane_za16_f16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_za16_f16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mls_za16_f16_vg1x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mopa_za16_f16.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mops_za16_f16.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/sub_za16_f16_vg1x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/sub_za16_f16_vg1x4.c: Likewise.

8 months agoaarch64: Add support for SVE_B16B16
Richard Sandiford [Wed, 20 Nov 2024 13:27:40 +0000 (13:27 +0000)] 
aarch64: Add support for SVE_B16B16

This patch adds support for the SVE_B16B16 extension, which provides
non-widening BF16 versions of existing instructions.

Mostly it's just a simple extension of iterators.  The main
complications are:

(1) The new instructions have no immediate forms.  This is easy to
    handle for the cond_* patterns (the ones that have an explicit
    else value) since those are already divided into register and
    non-register versions.  All we need to do is tighten the predicates.

    However, the @aarch64_pred_<optab><mode> patterns handle the
    immediates directly.  Rather than complicate them further,
    it seemed best to add a single @aarch64_pred_<optab><mode> for
    all BF16 arithmetic.

(2) There is no BFSUBR, so the usual method of handling reversed
    operands breaks down.  The patch deals with this using some
    new attributes that together disable the "BFSUBR" alternative.

(3) Similarly, there are no BFMAD or BFMSB instructions, so we need
    to disable those forms in the BFMLA and BFMLS patterns.

The patch includes support for generic bf16 vectors too.

It would be possible to use these instructions for scalars, as with
the recent FLOGB patch, but that's left as future work.

gcc/
* config/aarch64/aarch64-option-extensions.def
(sve-b16b16): New extension.
* doc/invoke.texi: Document it.
* config/aarch64/aarch64.h (TARGET_SME_B16B16, TARGET_SVE2_OR_SME2)
(TARGET_SSVE_B16B16): New macros.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Conditionally define __ARM_FEATURE_SVE_B16B16
* config/aarch64/aarch64-sve-builtins-sve2.def: Add AARCH64_FL_SVE2
to the SVE2p1 requirements.  Add SVE_B16B16 forms of existing
intrinsics.
* config/aarch64/aarch64-sve-builtins.cc (type_suffixes): Treat
bfloat as a floating-point type.
(TYPES_h_bfloat): New macro.
* config/aarch64/aarch64.md (is_bf16, is_rev, supports_bf16_rev)
(mode_enabled): New attributes.
(enabled): Test mode_enabled.
* config/aarch64/iterators.md (SVE_FULL_F_BF): New mode iterator.
(SVE_CLAMP_F): Likewise.
(SVE_Fx24): Add BF16 modes when TARGET_SSVE_B16B16.
(sve_lane_con): Handle BF16 modes.
(b): Handle SF and DF modes.
(is_bf16): New mode attribute.
(supports_bf16, supports_bf16_rev): New int attributes.
* config/aarch64/predicates.md
(aarch64_sve_float_maxmin_immediate): Reject BF16 modes.
* config/aarch64/aarch64-sve.md
(*post_ra_<sve_fp_op><mode>3): Add BF16 support, and likewise
for the associated define_split.
(<optab:SVE_COND_FP_BINARY_OPTAB><mode>): Add BF16 support.
(@cond_<optab:SVE_COND_FP_BINARY><mode>): Likewise.
(*cond_<optab:SVE_COND_FP_BINARY><mode>_2_relaxed): Likewise.
(*cond_<optab:SVE_COND_FP_BINARY><mode>_2_strict): Likewise.
(*cond_<optab:SVE_COND_FP_BINARY><mode>_3_relaxed): Likewise.
(*cond_<optab:SVE_COND_FP_BINARY><mode>_3_strict): Likewise.
(*cond_<optab:SVE_COND_FP_BINARY><mode>_any_relaxed): Likewise.
(*cond_<optab:SVE_COND_FP_BINARY><mode>_any_strict): Likewise.
(@aarch64_mul_lane_<mode>): Likewise.
(<optab:SVE_COND_FP_TERNARY><mode>): Likewise.
(@aarch64_pred_<optab:SVE_COND_FP_TERNARY><mode>): Likewise.
(@cond_<optab:SVE_COND_FP_TERNARY><mode>): Likewise.
(*cond_<optab:SVE_COND_FP_TERNARY><mode>_4_relaxed): Likewise.
(*cond_<optab:SVE_COND_FP_TERNARY><mode>_4_strict): Likewise.
(*cond_<optab:SVE_COND_FP_TERNARY><mode>_any_relaxed): Likewise.
(*cond_<optab:SVE_COND_FP_TERNARY><mode>_any_strict): Likewise.
(@aarch64_<optab:SVE_FP_TERNARY_LANE>_lane_<mode>): Likewise.
* config/aarch64/aarch64-sve2.md
(@aarch64_pred_<optab:SVE_COND_FP_BINARY><mode>): Define BF16 version.
(@aarch64_sve_fclamp<mode>): Add BF16 support.
(*aarch64_sve_fclamp<mode>_x): Likewise.
(*aarch64_sve_<maxmin_uns_op><SVE_Fx24:mode>): Likewise.
(*aarch64_sve_single_<maxmin_uns_op><SVE_Fx24:mode>): Likewise.
* config/aarch64/aarch64.cc (aarch64_sve_float_arith_immediate_p)
(aarch64_sve_float_mul_immediate_p): Return false for BF16 modes.

gcc/testsuite/
* lib/target-supports.exp: Test the assembler for sve-b16b16 support.
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Test the new B16B16
macros.
* gcc.target/aarch64/sve/fmad_1.c: Test bfloat16 too.
* gcc.target/aarch64/sve/fmla_1.c: Likewise.
* gcc.target/aarch64/sve/fmls_1.c: Likewise.
* gcc.target/aarch64/sve/fmsb_1.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_9.c: New test.
* gcc.target/aarch64/sme2/acle-asm/clamp_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/clamp_bf16_x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/max_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/max_bf16_x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/maxnm_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/maxnm_bf16_x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/min_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/min_bf16_x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/minnm_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/minnm_bf16_x4.c: Likewise.
* gcc.target/aarch64/sve/bf16_arith_1.c: Likewise.
* gcc.target/aarch64/sve/bf16_arith_1.h: Likewise.
* gcc.target/aarch64/sve/bf16_arith_2.c: Likewise.
* gcc.target/aarch64/sve/bf16_arith_3.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/add_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clamp_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/max_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/maxnm_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/min_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/minnm_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/mla_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/mla_lane_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/mls_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/mls_lane_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/mul_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/mul_lane_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/sub_bf16.c: Likewise.

8 months agoaarch64: Fix the choice of unspec in two SME patterns
Richard Sandiford [Wed, 20 Nov 2024 13:27:40 +0000 (13:27 +0000)] 
aarch64: Fix the choice of unspec in two SME patterns

@aarch64_sme_write<mode> and *aarch64_sme_write<mode>_plus
were using UNSPEC_SME_READ instead of UNSPEC_SME_WRITE.

gcc/
* config/aarch64/aarch64-sme.md (@aarch64_sme_write<mode>)
(*aarch64_sme_write<mode>_plus): Use UNSPEC_SME_WRITE instead
of UNSPEC_SME_READ.

8 months agoaarch64: Rename some SME iterators
Richard Sandiford [Wed, 20 Nov 2024 13:27:39 +0000 (13:27 +0000)] 
aarch64: Rename some SME iterators

This patch just renames the iterators SME_READ and SME_WRITE to
SME_READ_HV and SME_WRITE_HV, to distinguish them from other forms
of ZA read and write.

gcc/
* config/aarch64/iterators.md (SME_READ): Rename to...
(SME_READ_HV): ...this.
(SME_WRITE): Rename to...
(SME_WRITE_HV): ...this.
* config/aarch64/aarch64-sme.md: Update accordingly.

8 months agoaarch64: Refactor SVE predicated-to-unpredicated splits
Richard Sandiford [Wed, 20 Nov 2024 13:27:39 +0000 (13:27 +0000)] 
aarch64: Refactor SVE predicated-to-unpredicated splits

There are separate patterns for predicated FADD, FSUB, and FMUL.
Previously they each had their own in-built split to convert the
instruction to unpredicated form where appropriate.  However, it's
more convenient for later patches if we use a single separate split
instead.

gcc/
* config/aarch64/iterators.md (SVE_COND_FP): New code attribute.
* config/aarch64/aarch64-sve.md: Use a single define_split to
handle the conversion of predicated FADD, FSUB, and FMUL into
unpredicated forms.

8 months agoaarch64: Rework sme_2mode_function insns
Richard Sandiford [Wed, 20 Nov 2024 13:27:38 +0000 (13:27 +0000)] 
aarch64: Rework sme_2mode_function insns

Many of the SME ZA intrinsics have two type suffixes: one for ZA
and one for the vectors.  The ZA suffix only conveys an element
size, while the vector suffix conveys both an element type and
an element size.  Internally, the ZA suffix maps to an integer mode;
e.g. za32 maps to VNx4SI.

For SME2, it was relatively convenient to use the modes associated
with both suffixes directly.  For example, the (non-widening) FMLA
intrinsics used SME_ZA_SDF_I to iterate over the possible ZA modes,
used SME_ZA_SDFx24 to iterate over the possible vector tuple modes,
and used a C++ condition to make sure that the element sizes agree.

However, for later patches it's more convenient to rely only on
the vector mode in cases where the ZA and vector element sizes
are the same.  This means splitting the widening MOPA/S patterns
from the non-widening ones, but otherwise it's not a big change.

gcc/
* config/aarch64/iterators.md (SME_ZA_SDF_I): Delete.
(SME_MOP_HSDF): Replace with...
(SME_MOP_SDF): ...this.
* config/aarch64/aarch64-sme.md: Change the non-widening FMLA and
FMLS patterns so that both mode parameters are the same, rather than
using both SME_ZA_SDF_I and SME_ZA_SDFx24 and checking that their
element sizes are the same.  Split the FMOPA and FMOPS patterns
into separate non-widening and widening forms, then update the
non-widening forms in a similar way to FMLA and FMLS.
* config/aarch64/aarch64-sve-builtins-functions.h
(sme_2mode_function_t::expand): If the two type suffixes have the same
element size, use the vector tuple mode for both mode parameters.

8 months agofortran: Evaluate once BACK argument of MINLOC/MAXLOC with DIM [PR90608]
Mikael Morin [Wed, 20 Nov 2024 12:59:51 +0000 (13:59 +0100)] 
fortran: Evaluate once BACK argument of MINLOC/MAXLOC with DIM [PR90608]

Evaluate the BACK argument of MINLOC/MAXLOC once before the
scalarization loops in the case where the DIM argument is present.

This is a follow-up to r15-1994-ga55d24b3cf7f4d07492bb8e6fcee557175b47ea3
which added knowledge of BACK to the scalarizer, to
r15-2701-ga10436a8404ad2f0cc5aa4d6a0cc850abe5ef49e which removed it to
handle it out of scalarization instead, and to more immediate previous
patches that added inlining support for MINLOC/MAXLOC with DIM.  The
inlining support for MINLOC/MAXLOC with DIM introduced nested loops, which
made the evaluation of BACK (removed from the scalarizer knowledge by the
forementionned commit) wrapped in a loop, so possibly executed more than
once.  This change adds BACK to the scalarization chain if MINLOC/MAXLOC
will use nested loops, so that it is evaluated by the scalarizer only once
before the outermost loop in that case.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-intrinsic.cc
(walk_inline_intrinsic_minmaxloc): Add a scalar element for BACK as
first item of the chain if BACK is present and there will be nested
loops.
(gfc_conv_intrinsic_minmaxloc): Evaluate BACK using an inherited
scalarization chain if there is a nested loop.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_8.f90: New test.
* gfortran.dg/minloc_9.f90: New test.

8 months agoi386: Remove workaround for Solaris ld 64-bit TLS IE limitation
Uros Bizjak [Wed, 20 Nov 2024 11:57:25 +0000 (12:57 +0100)] 
i386: Remove workaround for Solaris ld 64-bit TLS IE limitation

As detailed in PR target/43309, the Solaris linker initially took the
64-bit x86 TLS IE code sequence literally, assuming that the spec only
allowed %rax as target register.

A workaround has been in place for more than a decade, but is no longer
necessary.  The bug had already been fixed for Solaris 11.1, while trunk
requires Solaris 11.4.

Uros pointed this out and suggested the attached patch.

Bootstrapped without regressions on i386-pc-solaris2.11.

2024-10-15  Uros Bizjak  <ubizjak@gmail.com>

gcc:
* config/i386/i386.cc (legitimize_tls_address)
<TLS_MODEL_INITIAL_EXEC>: Remove 64-bit Solaris ld workaround.
* config/i386/i386.md (UNSPEC_TLS_IE_SUN): Remove.
(tls_initial_exec_64_sun): Remove.

8 months agotestsuite: i386: Fix gcc.target/i386/pr117232-1.c etc. with Solaris as
Rainer Orth [Wed, 20 Nov 2024 11:54:22 +0000 (12:54 +0100)] 
testsuite: i386: Fix gcc.target/i386/pr117232-1.c etc. with Solaris as

Two tests FAIL on Solaris/x86 with the native assembler:

FAIL: gcc.target/i386/pr117232-1.c scan-assembler-times (?n)cmovn?c 7
FAIL: gcc.target/i386/pr117232-apx-1.c scan-assembler-times (?n)cmovn?c 7

The problem is that as expects a slightly different insn syntax, e.g.

cmovl.nc %esi, %eax

instead of

cmovnc %esi, %eax

This patch allows for both forms.

Tested on i386-pc-solaris2.11 (as and gas) and x86_64-pc-linux-gnu.

2024-11-15  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.target/i386/pr117232-1.c (scan-assembler-times): Allow for
cmovl.nc etc.
* gcc.target/i386/pr117232-apx-1.c: Likewise.

8 months agoRISC-V: Refine the rtl dump expand check for vector SAT_ADD
Pan Li [Wed, 20 Nov 2024 07:16:22 +0000 (15:16 +0800)] 
RISC-V: Refine the rtl dump expand check for vector SAT_ADD

This patch would like to remove the unnecessary option for the
vector SAT_ADD testcases at first.  And the different optimization
option like O2 and O3 will be passed to the test files for rtl
expand dump check.  If there are different dump check times for
different optimization options, the target no-opts and/or any-opts
will be leveraged for the dg-final check.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c: Remove
the unnecessary option and refine the rtl IFN dump check.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-4-u8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoRISC-V: Introduce riscv/rvv/autovec/sat folder to rvv.exp testsuite
Pan Li [Wed, 20 Nov 2024 05:32:47 +0000 (13:32 +0800)] 
RISC-V: Introduce riscv/rvv/autovec/sat folder to rvv.exp testsuite

After we move vector SAT_ADD testcases into a isolated folder, aka
riscv/rvv/autovec/sat.  We would like to add the folder as one of
the test items of the rvv.exp testsuite.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/rvv.exp: Add the vector sat folder to
the rvv.exp testsuite.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoRISC-V: Rearrange the test files for vector SAT_ADD [NFC]
Pan Li [Wed, 20 Nov 2024 05:22:40 +0000 (13:22 +0800)] 
RISC-V: Rearrange the test files for vector SAT_ADD [NFC]

The test files of scalar SAT_TRUNC only has numbers as the suffix.
Rearrange the file name to -{form number}-{target-type}.  For example,
test form 3 for uint32_t SAT_TRUNC will have -3-u32.c for asm check and
-run-3-u32.c for the run test.

Meanwhile, all related test files moved to riscv/rvv/autovec/sat/.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-2.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-3.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-4.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-1.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-6.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-7.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-8.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-5.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-10.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-11.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-12.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-9.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-14.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-15.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-16.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-13.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-2.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-3.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-4.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-1.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-1-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-6.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-7.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-8.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-5.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-2-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-10.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-11.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-12.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-9.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-3-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-14.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-15.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-16.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-13.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-run-4-s8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-10.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-11.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-12.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-9.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-1-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-6.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-7.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-8.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-5.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-2-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-10.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-11.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-12.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-9.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-3-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-14.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-15.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-16.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-13.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-4-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-18.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-19.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-20.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-17.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-5-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-22.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-23.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-24.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-21.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-6-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-26.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-27.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-28.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-25.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-7-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-30.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-31.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-32.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-29.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-8-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-2.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-3.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-4.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-1.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-6.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-7.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-8.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-5.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-10.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-11.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-12.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-9.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-14.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-15.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-16.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-13.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-2.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-3.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-4.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-1.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-1-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-6.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-7.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-8.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-5.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-2-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-10.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-11.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-12.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-9.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-3-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-14.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-15.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-16.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-13.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-run-4-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-2.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-3.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-4.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-1.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-6.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-7.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-8.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-5.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-2-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-10.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-11.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-12.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u64.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-9.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-3-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-14.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-4-u16.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-15.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-4-u32.c: ...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-13.c: Move to...
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-4-u8.c: ...here.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_arith.h: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_binary_vvv_run.h: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_binary_vvx_run.h: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_binary_vx_run.h: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_data.h: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agotree-optimization/117574 - bougs niter lt-to-ne
Richard Biener [Fri, 15 Nov 2024 10:56:14 +0000 (11:56 +0100)] 
tree-optimization/117574 - bougs niter lt-to-ne

When trying to change a IV from IV0 < IV1 to IV0' != IV1' we apply
fancy adjustments to the may_be_zero condition we compute rather
than using the obvious IV0->base >= IV1->base expression (to be
able to use > instead of >=?).  This doesn't seem to go well.

PR tree-optimization/117574
* tree-ssa-loop-niter.cc (number_of_iterations_lt_to_ne):
Use the obvious may_be_zero condition.

* gcc.dg/torture/pr117574-1.c: New testcase.

8 months agoExtend expand_absneg_bit to vector modes
Richard Sandiford [Wed, 20 Nov 2024 10:04:46 +0000 (10:04 +0000)] 
Extend expand_absneg_bit to vector modes

Expand can implement NEG and ABS of scalar floating-point modes
by using logic ops to manipulate the sign bit.  This patch extends
that approach to vectors, since it fits relatively easily into the
same structure.

The motivating use case was to inline bf16 NEG and ABS operations
for AArch64.  The patch includes tests for that.

get_absneg_bit_mode required a new opt_mode constructor, so that
opt_mode<T> can be constructed from opt_mode<U> if T is no less
general than U.

gcc/
* machmode.h (opt_mode::opt_mode): New overload.
* optabs-query.h (get_absneg_bit_mode): Declare.
* optabs-query.cc (get_absneg_bit_mode): New function, split
out from expand_absneg_bit.
(can_open_code_p): Use get_absneg_bit_mode.
* optabs.cc (expand_absneg_bit): Likewise.  Take an outer and inner
mode, rather than just one.  Handle vector modes.
(expand_unop, expand_abs_nojump): Update calls accordingly.
Handle vector modes.

gcc/testsuite/
* gcc.target/aarch64/abs_bf_1.c: New test.
* gcc.target/aarch64/neg_bf_1.c: Likewise.
* gcc.target/aarch64/neg_bf_2.c: Likewise.

8 months agoUse can_implement_p in the vectoriser
Richard Sandiford [Wed, 20 Nov 2024 10:04:45 +0000 (10:04 +0000)] 
Use can_implement_p in the vectoriser

This patch goes through the tree-vect-* code and mechanically replaces
all tests of optab_handler against CODE_FOR_nothing with calls to the
new helper functions.

gcc/
* tree-vect-data-refs.cc (vect_supportable_dr_alignment): Use
can_implement_p instead of optab_handler.
* tree-vect-generic.cc (add_rshift, expand_vector_divmod): Likewise.
(optimize_vector_constructor, type_for_widest_vector_mode): Likewise.
(lower_vec_perm, expand_vector_operations_1): Likewise.
* tree-vect-loop.cc (have_whole_vector_shift): Likewise.
* tree-vect-patterns.cc (vect_recog_rotate_pattern): Likewise.
(target_has_vecop_for_code, vect_recog_mult_pattern): Likewise.
(vect_recog_divmod_pattern): Likewise.
* tree-vect-stmts.cc (vect_supportable_shift, vectorizable_shift)
(scan_store_can_perm_p, check_scan_store, vectorizable_store)
(vectorizable_load, vectorizable_condition): Likewise.
(vectorizable_comparison_1): Likewise.

8 months agoAdd helpers to test whether an optab can be implemented
Richard Sandiford [Wed, 20 Nov 2024 10:04:45 +0000 (10:04 +0000)] 
Add helpers to test whether an optab can be implemented

The vectoriser and vector lowering passes both had tests of the form:

    if (op
&& (optab_handler (op, compute_mode) != CODE_FOR_nothing
    || optab_libfunc (op, compute_mode)))
      ...success...
    if (code == MULT_HIGHPART_EXPR
&& can_mult_highpart_p (compute_mode,
TYPE_UNSIGNED (compute_type)))
      ...success...

This patch adds helper routines for this kind of test, so that it's
easier to handle other optab alternatives in a similar way.

gcc/
* optabs-query.cc (can_open_code_p, can_implement_p): Declare.
* optabs-query.h (can_open_code_p, can_implement_p): New functions.
* optabs-tree.cc (target_supports_op_p): Use can_implement_p.
* tree-vect-stmts.cc (vectorizable_operation): Likewise.
* tree-vect-generic.cc (get_compute_type): Likewise.  Remove code
parameter.
(expand_vector_scalar_condition, expand_vector_conversion)
(expand_vector_operations_1): Update calls accordingly.

8 months agoarm, mve: Fix arm_mve_dlstp_check_dec_counter's use of single_pred
Andre Vieira [Wed, 20 Nov 2024 09:23:50 +0000 (09:23 +0000)] 
arm, mve: Fix arm_mve_dlstp_check_dec_counter's use of single_pred

Call 'single_pred_p' before 'single_pred' to verify it is safe to do so.

gcc/ChangeLog:

* config/arm/arm.cc (arm_mve_dlstp_check_dec_counter): Call
single_pred_p to verify it's safe to call single_pred.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/dlstp-loop-form.c: Add loop that triggered ICE.

8 months agofortran: Check for empty MINLOC/MAXLOC ARRAY along DIM only
Mikael Morin [Sat, 18 Nov 2023 19:54:20 +0000 (20:54 +0100)] 
fortran: Check for empty MINLOC/MAXLOC ARRAY along DIM only

In the function generating inline code to implement MINLOC and MAXLOC, only
check for ARRAY size along DIM if DIM is present.

The check for ARRAY emptyness had been checking the size of the full array,
which is correct for MINLOC and MAXLOC without DIM.  But if DIM is
present, the reduction is along DIM only so the check for emptyness
should consider that dimension only as well.

This sounds like a correctness issue, but fortunately the cases where it
makes a difference are cases where ARRAY is empty, so even if the value
calculated for MINLOC or MAXLOC is wrong, it's wrapped in a zero iteration
loop, and the wrong values are not actually used.  In the end this just
avoids unnecessary calculations.

A previous version of this patch regressed on non-constant DIM with rank 1
ARRAY.  The new testcase checks that that case is supported.

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Only get the size
along DIM instead of the full size if DIM is present.

gcc/testsuite/ChangeLog:

* gfortran.dg/minmaxloc_22.f90: New test.

8 months agoPR target/117669 - RISC-V:The 'VEEWTRUNC4' iterator 'RVVMF2BF' type condition error
Feng Wang [Wed, 20 Nov 2024 06:25:54 +0000 (06:25 +0000)] 
PR target/117669 - RISC-V:The 'VEEWTRUNC4' iterator 'RVVMF2BF' type condition error

This patch fix the wrong condition for RVVMF2BF. It should be
TARGET_VECTOR_ELEN_BF_16.
gcc/ChangeLog:

PR target/117669
* config/riscv/vector-iterators.md:

Signed-off-by: Feng Wang <wangfeng@eswincomputing.com>
8 months agoAdd microarchtecture tunable for pass_align_tight_loops [PR117438]
MayShao-oc [Thu, 7 Nov 2024 02:57:02 +0000 (10:57 +0800)] 
Add microarchtecture tunable for pass_align_tight_loops [PR117438]

Hi Hongtao:
   Add m_CASCADELAK, and m_SKYLAKE_AVX512.
   Place X86_TUNE_ALIGN_TIGHT_LOOPS in the appropriate section.

   Bootstrapped X86_64.
   Ok for trunk?
BR
Mayshao
gcc/ChangeLog:

PR target/117438
* config/i386/i386-features.cc (TARGET_ALIGN_TIGHT_LOOPS):
default true in all processors except for m_ZHAOXIN, m_CASCADELAKE, and
m_SKYLAKE_AVX512.
* config/i386/i386.h (TARGET_ALIGN_TIGHT_LOOPS): New Macro.
* config/i386/x86-tune.def (X86_TUNE_ALIGN_TIGHT_LOOPS):
New tune

8 months agotestsuite: arm: Only check for absence of literal pools in no-literal-pool-m0.c
Torbjörn SVENSSON [Sun, 13 Oct 2024 14:23:37 +0000 (16:23 +0200)] 
testsuite: arm: Only check for absence of literal pools in no-literal-pool-m0.c

With the changes in r15-1579-g792f97b44ff, the constants have been
updated.
This patch drops the fragile check on the constants and instead only
checks that there is no literal pool generated.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pure-code/no-literal-pool-m0.c: Only check for
absence of literal pools.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
8 months agolibstdc++: Use const_iterator in std::set::find<K> return type
Jonathan Wakely [Tue, 19 Nov 2024 23:59:00 +0000 (23:59 +0000)] 
libstdc++: Use const_iterator in std::set::find<K> return type

François noticed that the "wrong" type is used in the return type for a
std::set member function template.

The iterator for our std::set is the same type as const_iterator,
so this doesn't actually matter. But it's clearer if the return type
matches the type used in the function body.

libstdc++-v3/ChangeLog:

* include/bits/stl_set.h (set::find): Use const_iterator in
return type, not iterator.

8 months agolibstdc++: Fix std::unordered_set::emplace optimization [PR117686]
Jonathan Wakely [Tue, 19 Nov 2024 23:38:19 +0000 (23:38 +0000)] 
libstdc++: Fix std::unordered_set::emplace optimization [PR117686]

The __is_key_type specialization that matches a pair<key_type, T>
argument is intended for std::unordered_map, not for
std::unordered_set<std::pair<K,T>>.

This uses a pair<const Args&...> as the template argument for
__is_key_type, so that it won't match a set's key_type.

libstdc++-v3/ChangeLog:

PR libstdc++/117686
* include/bits/hashtable.h (_Hashtable::_M_emplace_uniq):
Adjust usage of __is_key_type to avoid false positive.
* testsuite/23_containers/unordered_set/insert/117686.cc:
New test.

8 months agoRISC-V: Refine the rtl expand check for strided ld/st
Pan Li [Tue, 19 Nov 2024 07:27:39 +0000 (15:27 +0800)] 
RISC-V: Refine the rtl expand check for strided ld/st

This patch would like to remove the unnecessary option for the
strided load/store testcases.  After fix the option from the rvv.exp,
both the O2 and O3 will be passed to the test files for rtl expand
dump check but the O2 has 2 time for IFN while the O3 has 4 times with
-fvectorize specificed.

Thus, add xfail O2 for IFN 4 times check, as well as xfail O3 for 2
times check.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-f16.c: Remove
unnecessary optimization option and xfail O2/O3 diff IFN times
from the rtl expand dump.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-f32.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-f64.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/strided/strided_ld_st-1-u8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoRISC-V: Fix incorrect optimization options passing to strided ld/st test
Pan Li [Tue, 19 Nov 2024 07:18:53 +0000 (15:18 +0800)] 
RISC-V: Fix incorrect optimization options passing to strided ld/st test

The testcases of vector strided load/store are designed to pick up
different sorts of optimization options but actually these option
are ignored according to the Execution log of gcc.log.  This patch
would like to make it correct, and then you will see the build option
similar as below from the gcc.log.

Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m1 ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m1 ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m4 ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m8 ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=dynamic ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m8 ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m4 ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=m2 ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=scalable -mrvv-max-lmul=dynamic ...
Executing ... strided_ld_st-1-f16.c -O3 -mrvv-vector-bits=zvl -mrvv-max-lmul=m2 ...

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/rvv.exp: Fix the incorrect optimization options.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoRISC-V: Add the mini support for SiFive extensions.
yulong [Sun, 17 Nov 2024 09:55:30 +0000 (17:55 +0800)] 
RISC-V: Add the mini support for SiFive extensions.

This patch add the mini support for xsfvqmaccqoq, xsfvqmaccdod and
 xsfvfnrclipxfqf extensions.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: New.
* config/riscv/riscv.opt: New.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/predef-sf-3.c: New test.
* gcc.target/riscv/predef-sf-4.c: New test.
* gcc.target/riscv/predef-sf-5.c: New test.

8 months ago[RISC-V][PR target/117649] Fix branch on masked values splitter
Jeff Law [Wed, 20 Nov 2024 02:24:41 +0000 (19:24 -0700)] 
[RISC-V][PR target/117649] Fix branch on masked values splitter

Andreas reported GCC mis-compiled GAS for risc-v  Thankfully he also reduced it
to a nice little testcase.

So the whole point of the pattern in question is to "reduce" the constants by
right shifting away common unnecessary bits in RTL expressions like this:

>   [(set (pc)
>         (if_then_else (any_eq
>                     (and:ANYI (match_operand:ANYI 1 "register_operand" "r")
>                           (match_operand 2 "shifted_const_arith_operand" "i"))
>                     (match_operand 3 "shifted_const_arith_operand" "i"))
>          (label_ref (match_operand 0 "" ""))
>          (pc)))

When applicable, the reduced constants in operands 2/3 fit into a simm12 and
thus do not need multi-instruction synthesis.  Note that we have to also shift
operand 1.

That shift should have been an arithmetic shift, but was incorrectly coded as a
logical shift.

Fixed with the obvious change on the right shift opcode.

Expecting to push to the trunk once the pre-commit tester renders its verdict.
I've already tested in this my tester for rv32 and rv64.

PR target/117649
gcc/
* config/riscv/riscv.md (branch on masked/shifted operands): Use
arithmetic rather than logical shift for operand 1.

gcc/testsuite

* gcc.target/riscv/branch-1.c: Update expected output.
* gcc.target/riscv/pr117649.c: New test.

8 months agoc: Fix ICE for integer constexpr initializers of wrong type [PR115515]
Joseph Myers [Wed, 20 Nov 2024 01:37:30 +0000 (01:37 +0000)] 
c: Fix ICE for integer constexpr initializers of wrong type [PR115515]

Bug 115515 (plus its duplicate 117139) reports an ICE with constexpr
initializer for an integer type variable that is not of integer type.
Fix this by not calling int_fits_type_p unless the previous check for
an integer constant expression passes.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR c/115515

gcc/c/
* c-typeck.cc (check_constexpr_init): Do not call int_fits_type_p
for arguments that are not integer constant expressions.

gcc/testsuite/
* gcc.dg/c23-constexpr-10.c, gcc.dg/gnu23-constexpr-2.c: New
tests.

8 months agoRISC-V: Remove unnecessary option for all other scalar SAT_* testcase
Pan Li [Sun, 17 Nov 2024 11:21:26 +0000 (19:21 +0800)] 
RISC-V: Remove unnecessary option for all other scalar SAT_* testcase

After we create a isolated folder to hold all SAT scalar test,
we have fully control of what optimization options passing to
the testcase.  Thus, it is better to remove the unnecessary
work around for flto option, as well as the -O3 option for
each cases.  The riscv.exp will pass sorts of different optimization
options for each case.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_s_sub-1-i16.c: Remove flto
dg-skip workaround and -O3 option.
* gcc.target/riscv/sat/sat_s_sub-1-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoRISC-V: Rearrange the rest of test files for scalar SAT_* [NFC]
Pan Li [Sun, 17 Nov 2024 10:40:10 +0000 (18:40 +0800)] 
RISC-V: Rearrange the rest of test files for scalar SAT_* [NFC]

Move all the other files of scalar SAT to dir riscv/sat/.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_s_sub-1-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-1-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-1-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-1-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-1-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-1-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-1-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-1-i8.c: ...here.
* gcc.target/riscv/sat_s_sub-2-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-2-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-2-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-2-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-2-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-2-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-2-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-2-i8.c: ...here.
* gcc.target/riscv/sat_s_sub-3-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-3-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-3-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-3-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-3-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-3-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-3-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-3-i8.c: ...here.
* gcc.target/riscv/sat_s_sub-4-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-4-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-4-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-4-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-4-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-4-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-4-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-4-i8.c: ...here.
* gcc.target/riscv/sat_s_sub-run-1-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-1-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-run-1-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-1-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-run-1-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-1-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-run-1-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-1-i8.c: ...here.
* gcc.target/riscv/sat_s_sub-run-2-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-2-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-run-2-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-2-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-run-2-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-2-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-run-2-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-2-i8.c: ...here.
* gcc.target/riscv/sat_s_sub-run-3-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-3-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-run-3-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-3-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-run-3-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-3-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-run-3-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-3-i8.c: ...here.
* gcc.target/riscv/sat_s_sub-run-4-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-4-i16.c: ...here.
* gcc.target/riscv/sat_s_sub-run-4-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-4-i32.c: ...here.
* gcc.target/riscv/sat_s_sub-run-4-i64.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-4-i64.c: ...here.
* gcc.target/riscv/sat_s_sub-run-4-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_sub-run-4-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-1-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-1-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-1-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-1-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-1-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-1-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-1-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-2-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-2-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-2-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-2-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-2-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-2-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-2-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-3-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-3-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-3-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-3-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-3-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-3-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-3-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-4-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-4-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-4-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-4-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-4-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-4-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-4-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-5-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-5-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-5-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-5-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-5-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-5-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-5-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-6-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-6-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-6-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-6-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-6-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-6-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-6-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-7-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-7-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-7-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-7-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-7-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-7-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-7-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-8-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-8-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-8-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-8-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-8-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-8-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-8-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-1-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-1-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-1-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-1-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-1-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-1-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-1-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-1-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-1-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-1-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-1-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-1-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-2-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-2-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-2-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-2-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-2-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-2-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-2-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-2-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-2-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-2-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-2-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-2-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-3-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-3-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-3-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-3-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-3-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-3-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-3-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-3-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-3-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-3-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-3-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-3-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-4-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-4-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-4-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-4-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-4-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-4-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-4-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-4-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-4-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-4-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-4-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-4-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-5-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-5-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-5-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-5-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-5-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-5-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-5-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-5-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-5-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-5-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-5-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-5-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-6-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-6-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-6-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-6-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-6-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-6-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-6-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-6-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-6-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-6-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-6-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-6-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-7-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-7-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-7-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-7-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-7-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-7-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-7-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-7-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-7-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-7-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-7-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-7-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-8-i16-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-8-i16-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-8-i32-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-8-i32-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-8-i32-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-8-i32-to-i8.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-8-i64-to-i16.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-8-i64-to-i16.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-8-i64-to-i32.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-8-i64-to-i32.c: ...here.
* gcc.target/riscv/sat_s_trunc-run-8-i64-to-i8.c: Move to...
* gcc.target/riscv/sat/sat_s_trunc-run-8-i64-to-i8.c: ...here.
* gcc.target/riscv/sat_arith.h: Removed.
* gcc.target/riscv/sat_arith_data.h: Removed.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoDaily bump.
GCC Administrator [Wed, 20 Nov 2024 00:19:59 +0000 (00:19 +0000)] 
Daily bump.

8 months agofortran: Inline non-character MINLOC/MAXLOC with DIM [PR90608]
Mikael Morin [Thu, 8 Aug 2024 10:23:16 +0000 (12:23 +0200)] 
fortran: Inline non-character MINLOC/MAXLOC with DIM [PR90608]

Enable generation of inline MINLOC/MAXLOC code in the cases where DIM is a
constant, and either ARRAY is of REAL type or MASK is an array.  Those cases
are the remaining bits to fully support inlining of non-CHARACTER
MINLOC/MAXLOC with constant DIM.  They are treated together because they
generate similar code, the NANs for REAL types being handled a bit like a
second level of masking.  These are the cases for which we generate two
loops.

This change affects the code generating the second loop, that was
previously accessible only in cases ARRAY had rank 1.

The main changes are in gfc_conv_intrinsic_minmaxloc the replacement of the
locally initialized scalarization loop with the one provided and previously
initialized by the scalarizer.  Same goes for the locally initialized MASK
scalarizer chain.

As this is enabling the code generating a second loop in a context of
reduction and nested loops, care is taken not to advance the parent
scalarization chain twice.

The scalarization chain element(s) for an array MASK are inserted in the
chain at a different place from that of a scalar MASK.  This is done on
purpose to match the code consuming the chains which are in different places
for scalar and array MASK.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_inline_intrinsic_function_p): Return TRUE
for MINLOC/MAXLOC with constant DIM and either REAL ARRAY or
non-scalar MASK.
(walk_inline_intrinsic_minmaxloc): Walk MASK and if it's an array
add the chain obtained before that of ARRAY.
(gfc_conv_intrinsic_minmaxloc): Use the nested loop if there is one.
To evaluate MASK (respectively ARRAY in the second loop), inherit
the scalarizer chain if in a nested loop, otherwise keep using the
chain obtained by walking MASK (respectively ARRAY).  If there is a
nested loop, avoid advancing the parent scalarization chain a second
time in the second loop.

gcc/testsuite/ChangeLog:

* gfortran.dg/minmaxloc_21.f90: New test.

8 months agoc: Do not register nullptr_t built-in type [PR114869]
Joseph Myers [Tue, 19 Nov 2024 21:31:24 +0000 (21:31 +0000)] 
c: Do not register nullptr_t built-in type [PR114869]

As reported in bug 114869, the C front end wrongly creates nullptr_t
as a built-in typedef; it should only be defined in <stddef.h>.  While
the type node needs a name for debug info generation, it doesn't need
to be a valid identifier; use typeof (nullptr) instead, similar to how
the C++ front end uses decltype(nullptr) for this purpose.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR c/114869

gcc/c/
* c-decl.cc (c_init_decl_processing): Register nullptr_type_node
as typeof (nullptr) not nullptr_t.

gcc/testsuite/
* gcc.dg/c23-nullptr-5.c: Use typeof (nullptr) not nullptr_t.
* gcc.dg/c11-nullptr-2.c, gcc.dg/c11-nullptr-3.c,
gcc.dg/c23-nullptr-7.c: New tests

8 months agoAVR: target/54378 - Reconsider the default shift costs.
Georg-Johann Lay [Tue, 19 Nov 2024 17:18:20 +0000 (18:18 +0100)] 
AVR: target/54378 - Reconsider the default shift costs.

This patch calculates more accurate shift costs, but makes
the costs for larger offsets no more expensive than the costs
for an unrolled shift.

gcc/
PR target/54378
* config/avr/avr.cc (avr_default_shift_costs): New static function.
(avr_rtx_costs_1) [ASHIFT, LSHIFTRT, ASHIFTRT]: Use it
to determine the default shift costs for shifts with a
constant shift offset.

8 months agofortran: Check MASK directly instead of its scalarization chain
Mikael Morin [Tue, 19 Nov 2024 20:17:37 +0000 (21:17 +0100)] 
fortran: Check MASK directly instead of its scalarization chain

Update the conditions used by the inline MINLOC/MAXLOC code generation
function to check directly the properties of MASK instead of the
variable holding its scalarization chain.

The inline implementation of MINLOC/MAXLOC in gfc_conv_intrinsic_minmaxloc
uses several conditions checking the presence of a scalarization chain for
MASK, which means that the argument is present and non-scalar.  The next
patch will allow inlining MINLOC/MAXLOC with DIM and MASK, and in that
case the scalarization chain for MASK is initialized elsewhere, so the
variable usually holding it in the function is not used, and the conditions
won't work in that case.

This change updates the conditions to check directly the properties of
MASK so that they work even if the scalarization chain variable is not used.

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Use
conditionals based on the MASK expression rather than on its
scalarization chains.

8 months agoc-family: Fix ICE with __sync_*_and_* on _BitInt [PR117641]
Jakub Jelinek [Tue, 19 Nov 2024 19:36:00 +0000 (20:36 +0100)] 
c-family: Fix ICE with __sync_*_and_* on _BitInt [PR117641]

Only __atomic_* builtins are meant to work on arbitrary _BitInt types
(if not supported in hw we emit a CAS loop which uses __atomic_load_*
in that case), the compatibility __sync_* builtins work only if there
is a corresponding normal integral type (for _BitInt on 32-bit ARM
we'll need to limit even that to no padding, because the padding bits
are well defined there and the hw or libatomic __sync_* APIs don't
guarantee that), IMHO people shouldn't mix very old APIs with very
new ones and I don't see a replacement for the __atomic_load_*.

For size > 16 that is how it already correctly behaves,
in the hunk shown in the patch it is immediately followed by

  if (fetch && !orig_format && TREE_CODE (type) == BITINT_TYPE)
    return -1;

which returns -1 for the __atomic_* builtins (i.e. !orig_format),
which causes caller to use atomic_bitint_fetch_using_cas_loop,
and otherwise does diagnostic and return 0 (which causes caller
to punt).  But for size == 16 if TImode isn't suipported (i.e.
mostly 32-bit arches), we return (correctly) -1 if !orig_format,
so again force atomic_bitint_fetch_using_cas_loop on those arches
for e.g. _BitInt(115), but for orig_format the function returns
16 as if it could do 16 byte __sync_*_and_* (which it can't
because TImode isn't supported; for 16 byte it can only do
(perhaps using libatomic) normal compare and swap).  So we need
to error and return 0, rather than return 16.

The following patch ensures that.

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

PR c/117641
* c-common.cc (sync_resolve_size): For size == 16 fetch of
BITINT_TYPE if TImode isn't supported scalar mode diagnose
and return 0 if orig_format instead of returning 16.

* gcc.dg/bitint-115.c: New test.

8 months agoc: Fix up __builtin_stdc_rotate_{left,right} lowering [PR117456]
Jakub Jelinek [Tue, 19 Nov 2024 19:34:36 +0000 (20:34 +0100)] 
c: Fix up __builtin_stdc_rotate_{left,right} lowering [PR117456]

Apparently the middle-end/expansion can only handle {L,R}ROTATE_EXPR
on types with mode precision, or large/huge BITINT_TYPE.
So, the following patch uses the rotate exprs only in those cases
where it can be handled, and emits code with shifts/ior otherwise.
As types without mode precision including small/medium BITINT_TYPE
have unlikely power of two precision and TRUNC_MOD_EXPR is on many targets
quite expensive, I chose to expand e.g. __builtin_stdc_rotate_left (arg1,
arg2) as
((tem = arg1, count = arg2 % prec)
 ? ((tem << count) | (tem >> (prec - count))) : tem)
rather than
(((tem = arg1) << (count = arg2 % prec))
 | (tem >> (-count % prec))
(where the assignments are really save_exprs, so no UB), because
I think another TRUNC_MOD_EXPR would be more costly in most cases
when the shift count is non-constant (and when it is constant,
it folds to 2 shifts by constant and ior in either case).

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

PR c/117456
gcc/c/
* c-parser.cc (c_parser_postfix_expression): Use LROTATE_EXPR
or RROTATE_EXPR only if type_has_mode_precision_p or if arg1
has BITINT_TYPE with precision larger than MAX_FIXED_MODE_SIZE.
Otherwise build BIT_IOR_EXPR of LSHIFT_EXPR and RSHIFT_EXPR
and wrap it into a COND_EXPR depending on if arg2 is 0 or not.
* c-fold.cc (c_fully_fold_internal): Check for suppression of
-Wshift-count-overflow warning.
gcc/testsuite/
* gcc.dg/builtin-stdc-rotate-4.c: New test.

8 months agotestsuite/52641 - Skip test cases that are not 16-bit clean.
Georg-Johann Lay [Tue, 19 Nov 2024 18:32:24 +0000 (19:32 +0100)] 
testsuite/52641 - Skip test cases that are not 16-bit clean.

gcc/testsuite/
PR testsuite/52641
PR testsuite/116488
PR testsuite/116915
* gcc.dg/torture/pr116488.c: Require int32plus.
* gcc.dg/torture/pr116915.c: Require int32plus.

8 months agoc: fix incorrect TBAA for tagged types across translation units [PR117490]
Martin Uecker [Fri, 8 Nov 2024 17:46:10 +0000 (18:46 +0100)] 
c: fix incorrect TBAA for tagged types across translation units [PR117490]

Two different declarations of tagged types in the same translation unit
are incompatible in C before C23 and without tag also in C23.  Still,
two such types can be compatible to the same tagged type in a different
translation unit, but this means that pointers can alias.

typedef struct { int i; } s1;
typedef struct { int i; } s2;

int f(s1 *p1, s2 *p2)
{
  p1->i = 2;
  p2->i = 3; // p2->i can alias p1->i
  return p1->i;
}

We need to assign the same TYPE_CANONICAL to both types.  This patch fixes
this for C23 and types without tag by also forming equivalence classes for
such types based on their structure as already done for types with tag.
Because this change exposes checking errors related to flexible array
members (cf. PR113688), one test is restricted to C17 for now.

PR c/117490

gcc/c/ChangeLog:
* c-typeck.cc (tagged_types_tu_compatible): Form equivalence
classed for tagless types in C23.

gcc/testsuite/ChangeLog:
* gcc.dg/gnu23-tag-alias-4.c: Adapt test.
* gcc.dg/gnu23-tag-alias-7.c: Adapt test.
* gcc.dg/guality/zero-length-array.c: Restrict to c17.
* gcc.dg/pr117490.c: New test.

8 months agoEnable symbolic backtraces on more Linux and BSD ports
Eric Botcazou [Tue, 19 Nov 2024 17:45:51 +0000 (18:45 +0100)] 
Enable symbolic backtraces on more Linux and BSD ports

gcc/ada
PR ada/117538
* Makefile.rtl (GNU Hurd): Add $(TRASYM_DWARF_UNIX_OBJS).
(x86-64 kfreebsd): Likewise.
(aarch64 FreeBSD): Likewise.
(x86-64 DragonFly): Likewise.
(S390 Linux): Likewise.
(Mips Linux): Likewise.
(SPARC Linux): Likewise.
(HP/PA Linux): Linux.
(M68K Linux): Likewise.
(SH4 Linux): Likewise.
(Alpha Linux): Likewise.
(RISC-V Linux): Likewise.

8 months agoRISC-V: testsuite: fix old-style function definition error [NFC]
Edwin Lu [Mon, 18 Nov 2024 22:36:17 +0000 (14:36 -0800)] 
RISC-V: testsuite: fix old-style function definition error [NFC]

The following testcase was failing with the warning: old-style function
definition ever since the c standard version has been updated. Update
the function definition.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-3.c: Update
function definition.

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
8 months agoAVR: Overhaul shift insns.
Georg-Johann Lay [Mon, 18 Nov 2024 16:35:33 +0000 (17:35 +0100)] 
AVR: Overhaul shift insns.

This patch adds 3-operand alternatives to the shift insns for
offsets that are one less than the bit-size of the mode.
For example, ashrhi3 can support "r,r,C15" without overhead.
Apart from that, the asm out functions for the shifts now use
avr_asm_len to print assembly and to track the isnsns' lengths.

gcc/
* config/avr/avr.md (ashlhi3, *ashlhi3_const_split, *ashlhi3_const)
(*ashlpsi3_split, *ashlpsi3)
(ashlsi3, *ashlsi3_const_split, *ashlsi3_const)
(ashrhi3, *ashrhi3, ashrpsi3, *ashrpsi3, ashrsi3, *ashrsi3)
(*ashrhi3_const_split, *ashrhi3_const, *ashrsi3_const_split, *ashrsi3_const):
Add constraint alternatives that allow a 3-operand operation when the
shift offset is one less than the mode's bitsize.
* config/avr/avr.cc (ashl<mode>3_out, ashr<mode>3_out)
(lshr<mode>3_out): Use avr_asm_len for asm_out and length tracking.
(ashrhi3_out, ashlhi3_out): Support the new "r,r,C15" alternatives.
(ashrsi3_out, ashlsi3_out): Support the new "r,r,C31" alternatives.
(avr_out_ashrpsi3, avr_out_ashlpsi3): Support the new "r,r,C23" alternatives.
gcc/testsuite/
* gcc.target/avr/torture/test-shift.h: New file.
* gcc.target/avr/torture/shift-l-u32.c: New test.
* gcc.target/avr/torture/shift-r-u32.c: New test.
* gcc.target/avr/torture/shift-r-i32.c: New test.
* gcc.target/avr/torture/shift-l-u24.c: New test.
* gcc.target/avr/torture/shift-r-u24.c: New test.
* gcc.target/avr/torture/shift-r-i24.c: New test.
* gcc.target/avr/torture/shift-l-u16.c: New test.
* gcc.target/avr/torture/shift-r-u16.c: New test.
* gcc.target/avr/torture/shift-r-i16.c: New test.
* gcc.target/avr/torture/shift-l-u8.c: New test.
* gcc.target/avr/torture/shift-r-u8.c: New test.
* gcc.target/avr/torture/shift-r-i8.c: New test.

8 months agoAVR: Use more bool.
Georg-Johann Lay [Tue, 19 Nov 2024 13:19:53 +0000 (14:19 +0100)] 
AVR: Use more bool.

Now that the C default is C23, we can use bool in avr.h
(which is still used in libgcc via tm.h).
bool is a keyword in C23, so no stdbool.h is required in libgcc.

gcc/
* config/avr/avr.h (avr_args.has_stack_args): Be a bool.
(struct machine_function) <is_naked, is_noblock, is_OS_task,
is_OS_task, sibcall_fails, attributes_checked_p, is_no_gccisr,
use_L__stack_usage, gasisr.yes, gasisr.maybe>: Same.
* config/avr/avr-protos.h (reg_unused_after)
(test_hard_reg_class, jump_over_one_insn_p): Use bool as
return type.
* config/avr/avr.cc (reg_unused_after)
(test_hard_reg_class, jump_over_one_insn_p): Same.
(cfun->machine->attributes_checked_p, cum->has_stack_args)
(cfun->machine->use_L__stack_usage, cfun->machine->gasisr.yes)
(cfun->machine->sibcall_fails): Use like a bool.

8 months agoRISC-V: Tie MUL and DIV masks to the M extension
Dimitar Dimitrov [Thu, 7 Nov 2024 18:13:02 +0000 (20:13 +0200)] 
RISC-V: Tie MUL and DIV masks to the M extension

When configuring GCC for RV32EC with:
  ./configure                                     \
      --target=riscv32-none-elf                   \
      --with-multilib-generator="rv32ec-ilp32e--" \
      --with-abi=ilp32e                           \
      --with-arch=rv32ec

Then the build fails because division is erroneously left enabled:
   cc1: error: '-mdiv' requires '-march' to subsume the 'M' extension
   -fself-test: 8412281 pass(es) in 0.647173 seconds

Fix by disabling MASK_DIV if multiplication is not available and -mdiv
option has not been explicitly passed.

Tested the above RV32EC-only toolchain using the GNU simulator:
                 === gcc Summary ===

 # of expected passes            211635
 # of unexpected failures        3004
 # of expected failures          1061
 # of unresolved testcases       5651
 # of unsupported tests          18958

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_override_options_internal):
Set division option's default to disabled if multiplication
is not available.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
8 months agotestsuite: robustify gcc.target/m68k/20100512-1.c
Andreas Schwab [Tue, 19 Nov 2024 16:35:14 +0000 (17:35 +0100)] 
testsuite: robustify gcc.target/m68k/20100512-1.c

This has been failing since r5-2883-g8cb65b3725f0c3 which caused the
memset to be optimized out.  Add an unoptimizable reference to the local
variable to keep it.

* gcc.target/m68k/20100512-1.c (doTest1, doTest2): Add asm that
references foo.

8 months agofortran: Inline MINLOC/MAXLOC with DIM and scalar MASK [PR90608]
Mikael Morin [Tue, 19 Nov 2024 16:31:25 +0000 (17:31 +0100)] 
fortran: Inline MINLOC/MAXLOC with DIM and scalar MASK [PR90608]

Enable the generation of inline code for MINLOC/MAXLOC when argument
ARRAY is of integral type and has rank > 1, DIM is a constant, and MASK is
scalar (only absent MASK or rank 1 ARRAY were inlined before).

Scalar masks are implemented with a wrapping condition around the code
one would generate if MASK wasn't present, so they are easy to support
once inline code without MASK is working.

With this change, there are both expressions evaluated inside the nested
loop (ARRAY, and in the future MASK if non-scalar) and expressions evaluated
outside of it (MASK if scalar).  For both one has to advance the
scalarization chain passed as argument SE to gfc_conv_intrinsic_minmaxloc as
they are evaluated, but for expressions evaluated from within the nested
loop one has to advance additionally the nested scalarization chain of the
reduction loop.  This is normally handled transparently through the
inheritance that is defined when initializing gfc_se structs, but there has
to be some variable to inherit from, and there is a single one, SE.  This
variable is kept as base for out of nested loop expressions only (i.e. for
scalar MASK), and this change introduces a new variable to hold the current
advance of the nested loop scalarization chain and serve as inheritance base
to evaluate nested loop expressions (just ARRAY for now, additionally
non-scalar MASK later).

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_inline_intrinsic_function_p): Return TRUE
if MASK is scalar.
(walk_inline_intrinsic_minmaxloc): Append to the scalarization chain
a scalar element for MASK if it's present.
(gfc_conv_intrinsic_minmaxloc): Use a local gfc_se struct to serve
as base for all the expressions evaluated in the nested loop.  To
evaluate MASK when there is a nested loop, enable usage of the
scalarizer and set the original passed in SE argument as current
scalarization chain element to use.  And use the nested loop from
the scalarizer instead of the local loop in that case.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_bounds_8.f90: Accept the error message
generated by the scalarizer in case the MAXLOC intrinsic call is
implemented through inline code.
* gfortran.dg/minmaxloc_20.f90: New test.

8 months agolibstdc++: remove JSON comment.
Jason Merrill [Mon, 18 Nov 2024 13:32:28 +0000 (14:32 +0100)] 
libstdc++: remove JSON comment.

Standard JSON doesn't have comments, and it seems this file needs to be
conforming, not the common JSON-with-comments dialect.

libstdc++-v3/ChangeLog:

* src/c++23/libstdc++.modules.json.in: Remove C++ comment.

8 months agoc++: reduce redundant deprecated warnings
Jason Merrill [Mon, 18 Nov 2024 14:00:32 +0000 (15:00 +0100)] 
c++: reduce redundant deprecated warnings

If a template uses a deprecated function, we should warn there and not also
whenever the template is instantiated.  I implement this by suppressing
the warning at the location; then to make this also work with modules, I
need to make sure to set TREE_NO_WARNING so that the warning spec for this
location gets recorded.

And then I noticed that has_warning_spec was broken such that if it
returned true than get_nowarn_spec would always return null.

gcc/cp/ChangeLog:

* decl2.cc (cp_handle_deprecated_or_unavailable): Avoid redundant
warning.
* call.cc (build_over_call): Set TREE_NO_WARNING for calls
to deprecated functions.
* semantics.cc (finish_call_expr): Propagate TREE_NO_WARNING.

gcc/ChangeLog:

* warning-control.cc (has_warning_spec): Fix handling of
get_no_warning_bit.

gcc/testsuite/ChangeLog:

* g++.dg/warn/deprecated-21.C: New test.
* g++.dg/modules/warn-spec-2_a.C: New test.
* g++.dg/modules/warn-spec-2_b.C: New test.

8 months agoAVR: ad target/84211 - Fix a build failure on some hosts.
Georg-Johann Lay [Tue, 19 Nov 2024 13:53:10 +0000 (14:53 +0100)] 
AVR: ad target/84211 - Fix a build failure on some hosts.

This fixes a build failure on hosts where HARD_REG_SET is not a scalar.
The issue was introduced with the patch for PR84211 in r15-5415.
PR target/84211
gcc/
* config/avr/avr-passes.cc (memento_t::apply_insn1): Don't
use operator &= on memento_t.known but on memento_t itself.

8 months agoamdgcn: Fix build failure (PR117657)
Andrew Stubbs [Tue, 19 Nov 2024 12:01:22 +0000 (12:01 +0000)] 
amdgcn: Fix build failure (PR117657)

The last patch did the right thing to the wrong parameter, which caused a build
failure in Newlib.  This patch fixes it.

gcc/ChangeLog:

PR target/117657
* config/gcn/gcn-valu.md (mask_gather_load<mode><vnsi>): Fix bug in
maskload else patch.

8 months agoaarch64: Bypass hidden attribute warnings in MinGW
Evgeny Karpov [Fri, 1 Nov 2024 16:47:15 +0000 (17:47 +0100)] 
aarch64: Bypass hidden attribute warnings in MinGW

The patch bypasses hidden attribute warnings in MinGW until it is
implemented.

libgcc/ChangeLog:

* config.host: Update.
* config/aarch64/t-mingw: New.

8 months agoAdd LTO support
Evgeny Karpov [Thu, 11 Jul 2024 13:27:35 +0000 (15:27 +0200)] 
Add LTO support

The patch reuses the configuration for LTO from ix86 and adds the
aarch64 architecture to the list of supported COFF headers.

gcc/ChangeLog:

* config/aarch64/cygming.h (TARGET_ASM_LTO_START): New.
(TARGET_ASM_LTO_END): Likewise.
* config/i386/cygming.h (TARGET_ASM_LTO_START): Update.
(TARGET_ASM_LTO_END): Likewise.
* config/i386/i386-protos.h (i386_pe_asm_lto_start): Delete.
(i386_pe_asm_lto_end): Likewise.
* config/mingw/winnt.cc (i386_pe_asm_lto_start): Rename
into ...
(mingw_pe_asm_lto_start): ... this.
(i386_pe_asm_lto_end): Rename into ...
(mingw_pe_asm_lto_end): ... this.
* config/mingw/winnt.h (mingw_pe_asm_lto_start): New.
(mingw_pe_asm_lto_end): Likewise.

libiberty/ChangeLog:

* simple-object-coff.c: Add aarch64.

8 months agoaarch64: Extend the offset limit in "symbol + offset" from 1MB to 16MB
Evgeny Karpov [Thu, 12 Sep 2024 11:19:32 +0000 (13:19 +0200)] 
aarch64: Extend the offset limit in "symbol + offset" from 1MB to 16MB

This patch allows using an offset of up to 16MB in "symbol + offset",
instead of 1MB limit that was used previously.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_load_symref_appropriately):
Update.

8 months agoaarch64: Multiple adjustments to support the SMALL code model correctly
Evgeny Karpov [Wed, 14 Aug 2024 14:43:41 +0000 (16:43 +0200)] 
aarch64: Multiple adjustments to support the SMALL code model correctly

LOCAL_LABEL_PREFIX has been changed to help the assembly
compiler recognize local labels. Emitting locals has been
replaced with the .lcomm directive to declare uninitialized
data without defining an exact section. Functions and objects
were missing declarations. Binutils was not able to distinguish
static from external, or an object from a function.
mingw_pe_declare_object_type has been added to have type
information for relocation on AArch64, which is not the case
for ix86.

This fix relies on changes in binutils.
aarch64: Relocation fixes and LTO
https://sourceware.org/pipermail/binutils/2024-August/136481.html

gcc/ChangeLog:

* config/aarch64/aarch64-coff.h (LOCAL_LABEL_PREFIX):
Use "." as the local label prefix.
(ASM_OUTPUT_ALIGNED_LOCAL): Remove.
(ASM_OUTPUT_LOCAL): New.
* config/aarch64/cygming.h (ASM_OUTPUT_EXTERNAL_LIBCALL):
Update.
(ASM_DECLARE_OBJECT_NAME): New.
(ASM_DECLARE_FUNCTION_NAME): New.
* config/i386/cygming.h (ASM_DECLARE_COLD_FUNCTION_NAME):
Update.
(ASM_OUTPUT_EXTERNAL_LIBCALL): Update.
* config/mingw/winnt.cc (mingw_pe_declare_function_type):
Rename into ...
(mingw_pe_declare_type): ... this.
(i386_pe_start_function): Update.
* config/mingw/winnt.h (mingw_pe_declare_function_type):
Rename into ...
(mingw_pe_declare_type): ... this.

8 months agoaarch64: Exclude symbols using GOT from code models
Evgeny Karpov [Thu, 8 Aug 2024 17:54:13 +0000 (19:54 +0200)] 
aarch64: Exclude symbols using GOT from code models

Symbols using GOT are not supported by the aarch64-w64-mingw32
target and should be excluded from the code models.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_classify_symbol):
Disable GOT for PECOFF target.

8 months agoaarch64: Add minimal C++ support
Evgeny Karpov [Wed, 14 Aug 2024 06:34:30 +0000 (08:34 +0200)] 
aarch64: Add minimal C++ support

The patch resolves compilation issues for the C++ language. Previous
patch series contributed to C++ as well, however, C++ could not be
tested until we got a C++ compiler and could build at least a "Hello
World" C++ program, and in reality, more than that.

Another issue has been fixed in the libstdc++ patch.
https://gcc.gnu.org/pipermail/libstdc++/2024-September/059472.html

gcc/ChangeLog:

* config.gcc: Add missing dependencies.

8 months agoaarch64: Add debugging information
Evgeny Karpov [Fri, 7 Jun 2024 14:55:23 +0000 (16:55 +0200)] 
aarch64: Add debugging information

This patch enables DWARF and allows compilation with debugging
information by using "gcc -g". The unwind info is disabled for
the moment and will be revisited after SEH implementation for
the target.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (TARGET_ASM_UNALIGNED_HI_OP):
Enable DWARF.
(TARGET_ASM_UNALIGNED_SI_OP): Likewise.
(TARGET_ASM_UNALIGNED_DI_OP): Likewise.
* config/aarch64/cygming.h (DWARF2_DEBUGGING_INFO): Likewise.
(PREFERRED_DEBUGGING_TYPE): Likewise.
(DWARF2_UNWIND_INFO): Likewise.
(ASM_OUTPUT_DWARF_OFFSET): Likewise.

8 months agoSupport weak references
Evgeny Karpov [Wed, 14 Aug 2024 15:56:38 +0000 (17:56 +0200)] 
Support weak references

The patch adds support for weak references. The original MinGW
implementation targets ix86, which handles weak symbols differently
compared to AArch64. In AArch64, the weak symbols are replaced by
other symbols which reference the original weak symbols, and the
compiler does not track the original symbol names.
This patch resolves this and declares the original symbols.

Here is an explanation of why this change is needed and what the
difference is between x86_64-w64-mingw32 and aarch64-w64-mingw32.

The way x86_64 calls a weak function:
call  weak_fn2

GCC emits the call and creates the required definitions at the end
of the assembly:

.weak weak_fn2
.def  weak_fn2;   .scl  2;    .type 32;   .endef

This is different from aarch64:

weak_fn2 will be legitimized and replaced by .refptr.weak_fn2,
and there will be no other references to weak_fn2 in the code.

adrp  x0, .refptr.weak_fn2
add   x0, x0, :lo12:.refptr.weak_fn2
ldr   x0, [x0]
blr   x0

GCC does not emit the required definitions at the end of the assembly,
and weak_fn2 is tracked only by the mingw stub sybmol.

Without the change, the stub definition will emit:

    .section      .rdata$.refptr.weak_fn2, "dr"
    .globl  .refptr.weak_fn2
    .linkonce     discard
.refptr.weak_fn2:
    .quad   weak_fn2

which is not enough. This fix will emit the required definitions:

    .weak   weak_fn2
    .def    weak_fn2;   .scl  2;    .type 32;   .endef
    .section      .rdata$.refptr.weak_fn2, "dr"
    .globl  .refptr.weak_fn2
    .linkonce     discard
.refptr.weak_fn2:
    .quad   weak_fn2

This is the first commit in the third patch series with SMALL code
model fixes, optimization fixes, LTO, and minimal C++ enablement.

Prepared, refactored and validated by
Radek Barton <radek.barton@microsoft.com> and
Evgeny Karpov <evgeny.karpov@microsoft.com>

Contributor: Zac Walker <zacwalker@microsoft.com>

gcc/ChangeLog:

* config/aarch64/cygming.h (SUB_TARGET_RECORD_STUB): Request
declaration for weak symbols.
(PE_COFF_LEGITIMIZE_EXTERN_DECL): Legitimize external
declaration for weak symbols.
* config/i386/cygming.h (SUB_TARGET_RECORD_STUB): Update
declarations in ix86 with the same functionality.
(PE_COFF_LEGITIMIZE_EXTERN_DECL): Likewise.
* config/mingw/winnt-dll.cc (legitimize_pe_coff_symbol):
Support declaration for weak symbols if requested.
* config/mingw/winnt.cc (struct stub_list): Likewise.
(mingw_pe_record_stub): Likewise.
(mingw_pe_file_end): Likewise.
* config/mingw/winnt.h (mingw_pe_record_stub): Likewise.

8 months agoada: Rename Within_Case_Or_If_Expression predicate
Eric Botcazou [Sun, 10 Nov 2024 09:46:54 +0000 (10:46 +0100)] 
ada: Rename Within_Case_Or_If_Expression predicate

The case and if expressions are exactly the conditional expressions.

gcc/ada/ChangeLog:

* exp_util.ads (Within_Case_Or_If_Expression): Rename into...
(Within_Conditional_Expression): ...this.
* exp_util.adb (Within_Case_Or_If_Expression): Rename into...
(Within_Conditional_Expression): ...this.
* checks.adb (Install_Null_Excluding_Check): Adjust for renaming.

8 months agoada: Small fix in expansion of array aggregates handled by the back end
Eric Botcazou [Mon, 11 Nov 2024 13:36:59 +0000 (14:36 +0100)] 
ada: Small fix in expansion of array aggregates handled by the back end

The (minimal) expansion is now done by Build_Array_Aggr_Code in all cases,
which means that it must prevent the aggregate from being re-analyzed as
the RHS of the assignment, which may trigger a bogus warning and lead to
another useless rewriting.

The change also inlines Build_Assignment_With_Temporary that is now called
only once by Build_Array_Aggr_Code for this processing.

gcc/ada/ChangeLog:

* exp_aggr.adb (Build_Assignment_With_Temporary): Inline into...
(Build_Array_Aggr_Code): ...this.  Set the Analyzed flag on the
relocated aggregate if it is to be handled by the back-end.

8 months agoada: Cleanup in expansion of aggregates in object declarations with aspects
Eric Botcazou [Fri, 8 Nov 2024 19:50:52 +0000 (20:50 +0100)] 
ada: Cleanup in expansion of aggregates in object declarations with aspects

The strategy to expand aggregates present as initialization expressions in
object declarations, originally with a subsequent address clause given for
the object and later with aspects whose resolution needs to be delayed up
to the freeze point, has been to block their resolution, so as to block
their expansion, during the processing of the declarations, lest they be
nonstatic and expanded in place and therefore generate assignments to the
object before its freeze point, which is forbidden.  Instead a temporary
is created at the declaration point and the aggregates are assigned to it,
and finally the temporary is copied into the object at the freeze point.

Of course this general strategy cannot be applied to limited types because
the copy operation is forbidden for them, so instead aggregates of limited
types are resolved but have their expansion delayed, before being eventually
expanded through Convert_Aggr_In_Object_Decl, which uses the mechanism based
on Initialization_Statements to insert them at the freeze point.

After the series of cleanups, all the aggregates that are initialization
expressions in object declarations and get expanded in place, go through the
Convert_Aggr_In_Object_Decl mechanism, exactly like those of limited type
with address clause/aspects have done historically.  This means that we no
longer need to block the resolution of those of nonlimited type with address
clause/aspects.

gcc/ada/ChangeLog:

* exp_ch3.adb: Remove clauses for Expander.
(Expand_N_Object_Declaration): Remove special processing for delayed
aggregates of limited types as initialization expressions.
* freeze.adb (Warn_Overlay): Bail out if No_Initialization is set on
the declaration node of the entity.
* sem_ch3.adb (Delayed_Aspect_Present): Delete.
(Expand_N_Object_Declaration): Do not block the resolution of the
initialization expression that is an aggregate when the object has
an address clause or delayed aspects.

8 months agofortran: Inline unmasked integral MINLOC/MAXLOC with DIM [PR90608]
Mikael Morin [Fri, 17 Nov 2023 18:04:19 +0000 (19:04 +0100)] 
fortran: Inline unmasked integral MINLOC/MAXLOC with DIM [PR90608]

Enable generation of inline code for the MINLOC and MAXLOC intrinsics,
if the ARRAY argument is of integral type and of rank > 1 (only the rank 1
case was previously inlined), the DIM argument is a constant value and there
is no MASK argument.

The restriction to integral ARRAY and absent MASK limits the scope of
the change to the cases where we generate single loop inline code.

This change uses the existing scalarizer suport for reductions, that is
arrays used in scalarization loops, where each element uses a nested
scalarization loop to calculate its value.  The nested loop (and
respectively the nested scalarization chain) is created while walking the
MINLOC/MAXLOC expression, it's set up automatically at the time the outer
loop is set up, and gfc_conv_intrinsic_minmaxloc is changed to use it as a
replacement for the local loop variable (respectively ARRAY scalarization
chain) used in the non-reduction case (i.e. when DIM is absent).

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_inline_intrinsic_function_p): Return true
if DIM is constant, ARRAY is integral and MASK is absent.
(walk_inline_intrinsic_minmaxloc): If DIM is present, walk ARRAY and
move the dimension corresponding to DIM to a nested chain, keeping
the rest of the dimensions as the returned scalarization chain.
(gfc_conv_intrinsic_minmaxloc): When inside the scalarization loops,
proceed with inline code generation If DIM is present.  If DIM is
present, skip result array creation and final initialization from
individual result local variables.  If DIM is present and ARRAY has
rank greater than 1, use the nested loop initialized by the
scalarizer instead of the local one, use 1 as scalarization
dimension, and evaluate ARRAY using the inherited scalarization
chain instead of creating a local one by walking the expression.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_bounds_1.f90: Also accept the error message
generated by the scalarizer in case the function call is implemented
through inline code.
* gfortran.dg/maxloc_bounds_2.f90: Likewise.
* gfortran.dg/maxloc_bounds_3.f90: Likewise.
* gfortran.dg/minmaxloc_19.f90: New test.

8 months agofortran: Add tests covering inline MINLOC/MAXLOC with DIM [PR90608]
Mikael Morin [Thu, 16 Nov 2023 09:00:26 +0000 (10:00 +0100)] 
fortran: Add tests covering inline MINLOC/MAXLOC with DIM [PR90608]

Add the tests covering the cases for which the following patches will
implement inline expansion of MINLOC and MAXLOC.  Those are cases where the
DIM argument is a constant value, and the ARRAY argument has rank greater
than 1.

PR fortran/90608

gcc/testsuite/ChangeLog:

* gfortran.dg/ieee/maxloc_nan_2.f90: New test.
* gfortran.dg/ieee/minloc_nan_2.f90: New test.
* gfortran.dg/maxloc_with_dim_1.f90: New test.
* gfortran.dg/maxloc_with_dim_and_mask_1.f90: New test.
* gfortran.dg/minloc_with_dim_1.f90: New test.
* gfortran.dg/minloc_with_dim_and_mask_1.f90: New test.

8 months agoRemove Debian from SECURITY.txt
Florian Weimer [Tue, 19 Nov 2024 11:26:22 +0000 (12:26 +0100)] 
Remove Debian from SECURITY.txt

As requested by the Debian security team.

* SECURITY.txt: Remove Debian.

8 months agoRISC-V: Load VLS perm indices directly from memory.
Robin Dapp [Thu, 26 Sep 2024 09:56:08 +0000 (11:56 +0200)] 
RISC-V: Load VLS perm indices directly from memory.

Instead of loading the permutation indices and using vmslt in order to
determine which elements belong to which source vector we can compute
the proper mask at compile time.  That way we can emit vlm instead of
vle + vmslt.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_merge_patterns): Load VLS
indices directly.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/merge-1.c: Check for vlm and
no vmsleu etc.
* gcc.target/riscv/rvv/autovec/vls/merge-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/merge-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/merge-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/merge-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/merge-6.c: Ditto.

8 months agoAvoid repeated calls to temporarily_undo_changes [PR117297]
Richard Sandiford [Tue, 19 Nov 2024 10:19:24 +0000 (10:19 +0000)] 
Avoid repeated calls to temporarily_undo_changes [PR117297]

In an attempt to reduce compile time, rtl-ssa computes the cost
of existing instructions lazily rather than eagerly.  However,
this means that it might need to calculate the cost of an existing
instruction while a change group is already in progress for the
instruction.  rtl_ssa::insn_info::calculate_cost therefore temporarily
undoes any in-progress changes in order to get back the original pattern
and insn code.

rtl-ssa's main use of insn costs is in rtl_ssa::changes_are_worthwhile,
which calculates the cost of a change involving an arbitrary number
of instructions.  Summing up the original cost of N instructions
while those N instructions have in-progress changes could lead to
O(N*N) rtl changes, since each lazy calculation might have to
temporarily undo the changes to all N instructions.

We can avoid that by converting the current temporarily_undo_changes/
redo_changes pair into an RAII class and extending it to allow
nested uses.  rtl_ssa::changes_are_worthwhile can then undo the
in-progress changes once, before computing the original cost of all
the instructions.

gcc/
PR rtl-optimization/117297
* recog.h (temporarily_undo_changes, redo_changes): Delete in
favor of...
(undo_recog_changes): ...this new RAII class.
* fwprop.cc (should_replace_address): Update accordingly.
(fwprop_propagation::check_mem): Likewise.
(try_fwprop_subst_note): Likewise.
(try_fwprop_subst_pattern): Likewise.
* rtl-ssa/insns.cc (insn_info::calculate_cost): Likewise.
* rtl-ssa/changes.cc (rtl_ssa::changes_are_worthwhile): Temporarily
undo all in-progress changes while computing the cost of the original
sequence.
* recog.cc (temporarily_undone_changes): Replace with...
(undo_recog_changes::s_num_changes): ...this static member variable.
(validate_change_1): Update check accordingly.
(confirm_change_group): Likewise.
(num_validated_changes): Likewise.
(temporarily_undo_changes): Replace with...
(undo_recog_changes::undo_recog_changes): ...this constructor.
(redo_changes): Replace with...
(undo_recog_changes::~undo_recog_changes): ...this destructor.

8 months agoexpand: Fix up ICE on VCE from _Complex types to _BitInt [PR117458]
Jakub Jelinek [Tue, 19 Nov 2024 09:26:44 +0000 (10:26 +0100)] 
expand: Fix up ICE on VCE from _Complex types to _BitInt [PR117458]

extract_bit_field can't handle extraction of non-mode precision
from complex mode operands which don't live in memory, e.g. gen_lowpart
crashes on those.
The following patch in that case defers the extract_bit_field call
until op0 is forced into memory.

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/117458
* expr.cc (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: Don't
call extract_bit_field if op0 has complex mode and isn't a MEM,
instead first force op0 into memory and then call extract_bit_field.

* gcc.dg/bitint-116.c: New test.

8 months agobitintlower: Handle PAREN_EXPR [PR117459]
Jakub Jelinek [Tue, 19 Nov 2024 09:25:57 +0000 (10:25 +0100)] 
bitintlower: Handle PAREN_EXPR [PR117459]

The following patch handles PAREN_EXPR in bitint lowering, and handles it
as an optimization barrier, so that temporary arithmetics from PAREN_EXPR
isn't mixed with temporary arithmetics from outside of the PAREN_EXPR.

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/117459
* gimple-lower-bitint.cc (bitint_large_huge::handle_stmt,
bitint_large_huge::lower_stmt): Handle PAREN_EXPR.

* gcc.dg/torture/bitint-74.c: New test.

8 months agobitintlower: Handle EXACT_DIV_EXPR like TRUNC_DIV_EXPR in bitint lowering [PR117571]
Jakub Jelinek [Tue, 19 Nov 2024 09:25:04 +0000 (10:25 +0100)] 
bitintlower: Handle EXACT_DIV_EXPR like TRUNC_DIV_EXPR in bitint lowering [PR117571]

r15-4601 added match.pd simplification of some TRUNC_DIV_EXPR expressions
into EXACT_DIV_EXPR, so bitintlower can now encounter even those.
From bitint lowering POV the fact that the division will be exact
doesn't matter, we still need to call at runtime the __divmodbitint4
API and it wouldn't simplify there anything to know it is exact if
we duplicated that, so the following patch lowers EXACT_DIV_EXPR exactly
as TRUNC_DIV_EXPR.

I think we don't need to backport this unless something introduces
EXACT_DIV_EXPR on BITINT_TYPEd expressions on the 14 branch as well.

2024-11-19  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/117571
* gimple-lower-bitint.cc (bitint_large_huge::lower_muldiv_stmt,
bitint_large_huge::lower_stmt, stmt_needs_operand_addr,
build_bitint_stmt_ssa_conflicts, gimple_lower_bitint): Handle
EXACT_DIV_EXPR like TRUNC_DIV_EXPR.

* gcc.dg/bitint-114.c: New test.

8 months agotestsuite: m68k: Fix tests for C23
Andreas Schwab [Tue, 19 Nov 2024 08:47:54 +0000 (09:47 +0100)] 
testsuite: m68k: Fix tests for C23

* gcc.target/m68k/crash1.c (seq_printf): Add prototype.
* gcc.target/m68k/pr63347.c (oof): Add missing parameter.

8 months ago[PATCH] testsuite: Require C99 for pow-to-ldexp.c
Soumya AR [Tue, 19 Nov 2024 08:53:47 +0000 (14:23 +0530)] 
[PATCH] testsuite: Require C99 for pow-to-ldexp.c

pow-to-ldexp.c checks for calls to __builtin_ldexpf and __builtin_ldexpl, which
will only be performed when the compiler knows the target has a C99 libm
available.

Modified the test to add a C99 runtime requirement.

This fixes the failure on arm-eabi targets for this test case.

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pow-to-ldexp.c: Require c99_runtime.

8 months agoRegenerate config/avr/avr.opt.urls
David Malcolm [Tue, 19 Nov 2024 01:44:09 +0000 (20:44 -0500)] 
Regenerate config/avr/avr.opt.urls

gcc/ChangeLog:
* config/avr/avr.opt.urls: Regenerate for
r15-5415-gc3db52bb47913a.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
8 months agoRISC-V: Remove unnecessary option for scalar SAT_TRUNC testcase
Pan Li [Sat, 16 Nov 2024 02:43:37 +0000 (10:43 +0800)] 
RISC-V: Remove unnecessary option for scalar SAT_TRUNC testcase

After we create a isolated folder to hold all SAT scalar test,
we have fully control of what optimization options passing to
the testcase.  Thus, it is better to remove the unnecessary
work around for flto option, as well as the -O3 option for
each cases.  The riscv.exp will pass sorts of different optimization
options for each case.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_u_trunc-1-u16.c: Remove flto
dg-skip workaround and -O3 option.
* gcc.target/riscv/sat/sat_u_trunc-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u8.c: Ditto.
* gcc.target/riscv/sat/scalar_sat_unary.h: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoRISC-V: Rearrange the test files for scalar SAT_TRUNC [NFC]
Pan Li [Sat, 16 Nov 2024 02:40:27 +0000 (10:40 +0800)] 
RISC-V: Rearrange the test files for scalar SAT_TRUNC [NFC]

The test files of scalar SAT_TRUNC only has numbers as the suffix.
Rearrange the file name to -{form number}-{target-type}.  For example,
test form 3 for uint32_t SAT_TRUNC will have -3-u32.c for asm check and
-run-3-u32.c for the run test.

Meanwhile, all related test files moved to riscv/sat/.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_u_trunc-2.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-1-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-3.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-1-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-4.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-1-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-1.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-1-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-6.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-2-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-7.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-2-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-8.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-2-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-5.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-2-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-10.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-3-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-11.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-3-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-12.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-3-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-9.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-3-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-14.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-4-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-15.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-4-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-16.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-4-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-13.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-4-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-18.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-5-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-19.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-5-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-20.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-5-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-17.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-5-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-22.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-6-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-23.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-6-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-24.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-6-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-21.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-6-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-2.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-1-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-3.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-1-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-4.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-1-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-1.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-1-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-6.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-2-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-7.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-2-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-8.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-2-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-5.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-2-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-10.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-3-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-11.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-3-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-12.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-3-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-9.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-3-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-14.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-4-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-15.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-4-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-16.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-4-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-13.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-4-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-18.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-5-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-19.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-5-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-20.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-5-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-17.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-5-u8.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-22.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-6-u16.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-23.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-6-u32.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-24.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-6-u64.c: ...here.
* gcc.target/riscv/sat_u_trunc-run-21.c: Move to...
* gcc.target/riscv/sat/sat_u_trunc-run-6-u8.c: ...here.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 months agoFlatten anonymous structs in CodeView types
Mark Harmstone [Sun, 10 Nov 2024 00:23:49 +0000 (00:23 +0000)] 
Flatten anonymous structs in CodeView types

If a CodeView struct, class, or union has as a member an anonymous
struct, class, or union, this gets flattened. The sub-struct's members
will appear as if they were part of their parent.

For this, we move part of get_type_num_struct into a new function
add_to_fieldlist, which also handles creating an LF_INDEX overflow item
if an LF_FIELDLIST grows too large. This is because add_struct_member
now calls itself recursively, and so needs to handle overflows itself.

gcc/
* dwarf2codeview.cc (add_to_fieldlist): New function.
(add_struct_member): Call recursively to flatten structs, and call
add_to_fieldlist.
(add_struct_static_member): Call add_to_fieldlist.
(add_struct_function): Call add_to_fieldlist.
(add_struct_inheritance): Call add_to_fieldlist.
(add_struct_nested_type): Call add_to_fieldlist.
(get_type_num_struct): Move code to add_to_fieldlist, and move
responsibility for this to subfunctions.

8 months agoProduce CodeView info about nested types
Mark Harmstone [Tue, 19 Nov 2024 00:46:45 +0000 (00:46 +0000)] 
Produce CodeView info about nested types

If the DIE for a struct, class, or union contains a nested type, add a
LF_NESTTYPE entry to its field list recording this.

Plus if we use a nested type, make sure that its parent also gets
defined. This may entail adding a forward definition and creating a
deferred type, so we need to call flush_deferred_types in
codeview_debug_finish as well.

gcc/
* dwarf2codeview.cc (enum cv_leaf_type): Add LF_NESTTYPE.
(struct codeview_subtype): Add lf_nesttype to union.
(flush_deferred_types): Add declaration.
(write_lf_fieldlist): Handle LF_NESTTYPE.
(codeview_debug_finish): Call flush_deferred_types.
(add_struct_nested_type): New function.
(get_type_num_struct): Call add_struct_nested_type, and if nested make
that parent is added.

8 months agoDaily bump.
GCC Administrator [Tue, 19 Nov 2024 00:19:52 +0000 (00:19 +0000)] 
Daily bump.

8 months agoc: Allow bool and enum null pointer constants [PR112556]
Joseph Myers [Mon, 18 Nov 2024 22:24:48 +0000 (22:24 +0000)] 
c: Allow bool and enum null pointer constants [PR112556]

As reported in bug 112556, GCC wrongly rejects conversion of null
pointer constants with bool or enum type to pointers in
convert_for_assignment (assignment, initialization, argument passing,
return).  Fix the code there to allow BOOLEAN_TYPE and ENUMERAL_TYPE;
it already allowed INTEGER_TYPE and BITINT_TYPE.

This bug (together with -std=gnu23 meaning false has type bool rather
than int) has in turn resulted in people thinking they need to fix
code using false as a null pointer constant for C23 compatibility.
While such a usage is certainly questionable, it has nothing to do
with C23 compatibility and the right place for warnings about such
usage is -Wzero-as-null-pointer-constant.  I think it would be
appropriate to extend -Wzero-as-null-pointer-constant to cover
BOOLEAN_TYPE, ENUMERAL_TYPE and BITINT_TYPE (in all the various
contexts in which that option generates warnings), though this patch
doesn't do anything about that option.

Bootstrapped with no regressions for x86-64-pc-linux-gnu.

PR c/112556

gcc/c/
* c-typeck.cc (convert_for_assignment): Allow conversion of
ENUMERAL_TYPE and BOOLEAN_TYPE null pointer constants to pointers.

gcc/testsuite/
* gcc.dg/c11-null-pointer-constant-1.c,
gcc.dg/c23-null-pointer-constant-1.c: New tests.

8 months agolibdiagnostics: add a "sarif-replay" command-line tool [PR96032]
David Malcolm [Mon, 18 Nov 2024 22:08:37 +0000 (17:08 -0500)] 
libdiagnostics: add a "sarif-replay" command-line tool [PR96032]

This patch adds a new "sarif-replay" command-line tool for
viewing .sarif files.  It uses libdiagnostics to "replay"
any diagnostics found in the .sarif files in text form as if
they were GCC diagnostics.

contrib/ChangeLog:
PR other/96032
* regenerate-sarif-spec-index.py: New file.

gcc/ChangeLog:
PR other/96032
* Makefile.in (lang_checks): If libdiagnostics is enabled, add
check-sarif-replay.
(SARIF_REPLAY_OBJS): New.
(ALL_HOST_OBJS): If libdiagnostics is enabled, add
$(SARIF_REPLAY_OBJS).
(sarif-replay): New.
(install-libdiagnostics): Add sarif-replay to deps, and install
it.
* configure: Regenerate.
* configure.ac (check_languages): If libdiagnostics is enabled,
add check-sarif-replay.
(LIBDIAGNOSTICS): If libdiagnostics is enabled, add sarif-replay.
* doc/install.texi (--enable-libdiagnostics): Note that it also
enables sarif-replay.
* libsarifreplay.cc: New file.
* libsarifreplay.h: New file.
* sarif-replay.cc: New file.
* sarif-spec-urls.def: New file.

gcc/testsuite/ChangeLog:
PR other/96032
* lib/gcc-dg.exp (gcc-dg-test-1): Add "replay-sarif".
* lib/sarif-replay-dg.exp: New file.
* lib/sarif-replay.exp: New file.
* sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.11.11-malformed-placeholder.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif: New test.
* sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif: New test.
* sarif-replay.dg/2.1.0-valid/error-with-note.sarif: New test.
* sarif-replay.dg/2.1.0-valid/escaped-braces.sarif: New test.
* sarif-replay.dg/2.1.0-valid/null-runs.sarif: New test.
* sarif-replay.dg/2.1.0-valid/signal-1.c.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-1.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-2.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-3.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-4.sarif: New test.
* sarif-replay.dg/2.1.0-valid/tutorial-example.sarif: New test.
* sarif-replay.dg/dg.exp: New script.
* sarif-replay.dg/malformed-json/array-missing-comma.sarif: New test.
* sarif-replay.dg/malformed-json/array-with-trailing-comma.sarif:
New test.
* sarif-replay.dg/malformed-json/bad-token.sarif: New test.
* sarif-replay.dg/malformed-json/object-missing-comma.sarif: New test.
* sarif-replay.dg/malformed-json/object-with-trailing-comma.sarif:
New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
8 months agojson: add json parsing support
David Malcolm [Mon, 18 Nov 2024 22:08:36 +0000 (17:08 -0500)] 
json: add json parsing support

This patch implements JSON parsing support.

It's based on the parsing parts of the patch I posted here:
https://gcc.gnu.org/legacy-ml/gcc-patches/2017-08/msg00417.html
with the parsing moved to a separate source file and header, heavily
rewritten to capture source location information for JSON values, and
to capture errors via a result template.

I also added optional support for C and C++ style comments, which is
extremely useful in DejaGnu tests.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add json-parsing.o.
* json-parsing.cc: New file.
* json-parsing.h: New file.
* json.cc (selftest::assert_print_eq): Remove "static".
* json.h (json::array::begin): New.
(json::array::end): New.
(json::array::length): New.
(json::array::get): New.
(is_a_helper <json::value *>::test): New.
(is_a_helper <const json::value *>::test): New.
(is_a_helper <json::object *>::test): New.
(is_a_helper <const json::object *>::test): New.
(is_a_helper <json::array *>::test): New.
(is_a_helper <const json::array *>::test): New.
(is_a_helper <json::float_number *>::test): New.
(is_a_helper <const json::float_number *>::test): New.
(is_a_helper <json::integer_number *>::test): New.
(is_a_helper <const json::integer_number *>::test): New.
(is_a_helper <json::string *>::test): New.
(is_a_helper <const json::string *>::test): New.
(selftest::assert_print_eq): New decl.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::json_parser_cc_tests.
* selftest.h (selftest::json_parser_cc_tests): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
8 months agoAdd libdiagnostics (v4)
David Malcolm [Mon, 18 Nov 2024 22:08:36 +0000 (17:08 -0500)] 
Add libdiagnostics (v4)

This patch adds a new libdiagnostics shared library available as
part of the GCC build via --enable-libdiagnostics when
configuring GCC.

It combines the following patches from:
  https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668632.html
    [PATCH 1/8] libdiagnostics v4: header
    [PATCH 2/8] libdiagnostics v4: implementation
    [PATCH 3/8] libdiagnostics: add API docs
    [PATCH 4/8] libdiagnostics v4: add C++ wrapper API
    [PATCH 6/8] libdiagnostics v4: test suite

ChangeLog:
* configure.ac (--enable-libdiagnostics): New.
* configure: Regenerate.

gcc/ChangeLog:
* configure.ac (check_languages): Add check-libdiagnostics.
(--enable-libdiagnostics): New.
* configure: Regenerate.
* Makefile.in (enable_libdiagnostics): New.
(lang_checks): If libdiagnostics is enabled, add
check-libdiagnostics.
(ALL_HOST_OBJS): If libdiagnostics is enabled, add
$(libdiagnostics_OBJS).
(start.encap): Add LIBDIAGNOSTICS.
(libdiagnostics_OBJS): New.
(LIBDIAGNOSTICS_VERSION_NUM): New, adapted from code in
jit/Make-lang.in.
(LIBDIAGNOSTICS_MINOR_NUM): Likewise.
(LIBDIAGNOSTICS_RELEASE_NUM): Likewise.
(LIBDIAGNOSTICS_FILENAME): Likewise.
(LIBDIAGNOSTICS_IMPORT_LIB): Likewise.
(libdiagnostics): Likewise.
(LIBDIAGNOSTICS_AGE): Likewise.
(LIBDIAGNOSTICS_BASENAME): Likewise.
(LIBDIAGNOSTICS_SONAME): Likewise.
(LIBDIAGNOSTICS_LINKER_NAME): Likewise.
(LIBDIAGNOSTICS_COMMA): Likewise.
(LIBDIAGNOSTICS_VERSION_SCRIPT_OPTION): Likewise.
(LIBDIAGNOSTICS_SONAME_OPTION): Likewise.
(LIBDIAGNOSTICS_SONAME_SYMLINK): Likewise.
(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK): Likewise.
(LIBDIAGNOSTICS_FILENAME): Likewise.
(libdiagnostics.serial): Likewise.
(LIBDIAGNOSTICS_EXTRA_OPTS): Likewise.
(install): If libdiagnostics is enabled, add
install-libdiagnostics.
(libdiagnostics.install-headers): New.
(libdiagnostics.install-common): New, adapted from code in
jit/Make-lang.in.
(install-libdiagnostics): New.
* diagnostic-format-text.h
(diagnostic_text_output_format::get_location_text): Make public.
* doc/install.texi (--enable-libdiagnostics): New.
* doc/libdiagnostics/Makefile: New file.
* doc/libdiagnostics/conf.py: New file.
* doc/libdiagnostics/index.rst: New file.
* doc/libdiagnostics/make.bat: New file.
* doc/libdiagnostics/topics/diagnostic-manager.rst: New file.
* doc/libdiagnostics/topics/diagnostics.rst: New file.
* doc/libdiagnostics/topics/execution-paths.rst: New file.
* doc/libdiagnostics/topics/fix-it-hints.rst: New file.
* doc/libdiagnostics/topics/index.rst: New file.
* doc/libdiagnostics/topics/logical-locations.rst: New file.
* doc/libdiagnostics/topics/message-formatting.rst: New file.
* doc/libdiagnostics/topics/metadata.rst: New file.
* doc/libdiagnostics/topics/physical-locations.rst: New file.
* doc/libdiagnostics/topics/retrofitting.rst: New file.
* doc/libdiagnostics/topics/sarif.rst: New file.
* doc/libdiagnostics/topics/text-output.rst: New file.
* doc/libdiagnostics/topics/ux.rst: New file.
* doc/libdiagnostics/tutorial/01-hello-world.rst: New file.
* doc/libdiagnostics/tutorial/02-physical-locations.rst: New file.
* doc/libdiagnostics/tutorial/03-logical-locations.rst: New file.
* doc/libdiagnostics/tutorial/04-notes.rst: New file.
* doc/libdiagnostics/tutorial/05-warnings.rst: New file.
* doc/libdiagnostics/tutorial/06-fix-it-hints.rst: New file.
* doc/libdiagnostics/tutorial/07-execution-paths.rst: New file.
* doc/libdiagnostics/tutorial/index.rst: New file.
* libdiagnostics++.h: New file.
* libdiagnostics.cc: New file.
* libdiagnostics.h: New file.
* libdiagnostics.map: New file.

gcc/testsuite/ChangeLog:
* libdiagnostics.dg/libdiagnostics.exp: New, adapted from jit.exp.
* libdiagnostics.dg/sarif.py: New.
* libdiagnostics.dg/test-dump.c: New test.
* libdiagnostics.dg/test-error-c.py: New test.
* libdiagnostics.dg/test-error-with-note-c.py: New test.
* libdiagnostics.dg/test-error-with-note.c: New test.
* libdiagnostics.dg/test-error-with-note.cc: New test.
* libdiagnostics.dg/test-error.c: New test.
* libdiagnostics.dg/test-error.cc: New test.
* libdiagnostics.dg/test-example-1.c: New test.
* libdiagnostics.dg/test-fix-it-hint-c.py: New test.
* libdiagnostics.dg/test-fix-it-hint.c: New test.
* libdiagnostics.dg/test-fix-it-hint.cc: New test.
* libdiagnostics.dg/test-helpers++.h: New test.
* libdiagnostics.dg/test-helpers.h: New test.
* libdiagnostics.dg/test-labelled-ranges.c: New test.
* libdiagnostics.dg/test-labelled-ranges.cc: New test.
* libdiagnostics.dg/test-labelled-ranges.py: New test.
* libdiagnostics.dg/test-logical-location-c.py: New test.
* libdiagnostics.dg/test-logical-location.c: New test.
* libdiagnostics.dg/test-metadata-c.py: New test.
* libdiagnostics.dg/test-metadata.c: New test.
* libdiagnostics.dg/test-multiple-lines-c.py: New test.
* libdiagnostics.dg/test-multiple-lines.c: New test.
* libdiagnostics.dg/test-no-column-c.py: New test.
* libdiagnostics.dg/test-no-column.c: New test.
* libdiagnostics.dg/test-no-diagnostics-c.py: New test.
* libdiagnostics.dg/test-no-diagnostics.c: New test.
* libdiagnostics.dg/test-note-with-fix-it-hint-c.py: New test.
* libdiagnostics.dg/test-note-with-fix-it-hint.c: New test.
* libdiagnostics.dg/test-text-sink-options.c: New test.
* libdiagnostics.dg/test-warning-c.py: New test.
* libdiagnostics.dg/test-warning-with-path-c.py: New test.
* libdiagnostics.dg/test-warning-with-path.c: New test.
* libdiagnostics.dg/test-warning.c: New test.
* libdiagnostics.dg/test-write-sarif-to-file-c.py: New test.
* libdiagnostics.dg/test-write-sarif-to-file.c: New test.
* libdiagnostics.dg/test-write-text-to-file.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
8 months agotestsuite: move dg-test cleanup code from gcc-dg.exp to its own file
David Malcolm [Mon, 18 Nov 2024 21:49:04 +0000 (16:49 -0500)] 
testsuite: move dg-test cleanup code from gcc-dg.exp to its own file

I need to use this cleanup logic for the testsuite for libdiagnostics
where it's too awkward to directly use gcc-dg.exp itself.

No functional change intended.

gcc/testsuite/ChangeLog:
* lib/dg-test-cleanup.exp: New file, from material moved from
lib/gcc-dg.exp.
* lib/gcc-dg.exp: Add load_lib of dg-test-cleanup.exp.
(cleanup-after-saved-dg-test): Move to lib/dg-test-cleanup.exp.
(dg-test): Likewise for override.
(initialize_prune_notes): Likewise.

libatomic/ChangeLog:
* testsuite/lib/libatomic.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libgomp/ChangeLog:
* testsuite/lib/libgomp.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
libitm/ChangeLog:
* testsuite/lib/libitm.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libphobos/ChangeLog:
* testsuite/lib/libphobos-dg.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libstdc++-v3/ChangeLog:
* testsuite/lib/libstdc++.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libvtv/ChangeLog:
* testsuite/lib/libvtv.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
8 months agoi386: Enable *rsqrtsf2_sse without TARGET_SSE_MATH [PR117357]
Uros Bizjak [Mon, 18 Nov 2024 21:38:46 +0000 (22:38 +0100)] 
i386: Enable *rsqrtsf2_sse without TARGET_SSE_MATH [PR117357]

__builtin_ia32_rsqrtsf2 expander generates UNSPEC_RSQRT insn pattern
also when TARGET_SSE_MATH is not set.  Enable *rsqrtsf2_sse without
TARGET_SSE_MATH to avoid ICE with unrecognizable insn.

PR target/117357

gcc/ChangeLog:

* config/i386/i386.md (*rsqrtsf2_sse):
Also enable for !TARGET_SSE_MATH.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr117357.c: New test.

8 months agoFix test failures for enum-alias-{1,2,3} on arm-eabi [PR117419]
Martin Uecker [Tue, 12 Nov 2024 17:08:17 +0000 (18:08 +0100)] 
Fix test failures for enum-alias-{1,2,3} on arm-eabi [PR117419]

The tests added for PR115157 fail on arm-eabi.  Add __INT_MAX__
to enum to make sure they have size int.

PR testsuite/117419

gcc/testsuite/ChangeLog:
* gcc.dg/enum-alias-1.c: Add __INT_MAX__.
* gcc.dg/enum-alias-2.c: Likewise.
* gcc.dg/enum-alias-3.c: Likewise.

Tested-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
8 months agoAdd a timevar for late combine
Richard Sandiford [Mon, 18 Nov 2024 19:33:58 +0000 (19:33 +0000)] 
Add a timevar for late combine

When adding late-combine.cc, I forgot to add a timevar for it.

gcc/
* timevar.def (TV_LATE_COMBINE): New timevar.
* late-combine.cc (pass_data_late_combine): Use it.

8 months agoaarch64: Improve early-ra handling of reductions
Richard Sandiford [Mon, 18 Nov 2024 19:32:51 +0000 (19:32 +0000)] 
aarch64: Improve early-ra handling of reductions

At the moment, early-ra ducks out of allocating any region
that contains a register with both a strong FPR affinity and
a strong GPR affinity.  The proper allocators are much better
at handling that situation.

But this means that early-ra tends not to allocate a region
of vector code that ends in a reduction to a scalar integer
if any later arithmetic is done on the scalar integer result.

Currently, if a block acts as an isolated allocation region, the pass
will try to split the block into subregions *between* instructions if
there are no live FPRs or FPR allocnos.  In the reduction case described
above, it's convenient to try the same thing *within* instructions.
If a block of vector code ends in a reduction, all FPRs and FPR
allocnos will be dead between the "use phase" and the "def phase"
of the reduction: the vector input will then have died, but the
scalar result will not yet have been born.

If we split the block that way, the problematic reduction result
will be part of the second region, which we can skip allocating,
but the vector work will be part of a separate region, which we
might be able to allocate.

This avoids a MOV in the testcase and also helps a small amount
with x264.

gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::IGNORE_REG): New flag.
(early_ra::fpr_preference): Handle it.
(early_ra::record_constraints): Fail the allocation if an
IGNORE_REG output operand is not independent of the inputs.
(defines_multi_def_pseudo): New function.
(early_ra::could_split_region_here): New member function, split
out from...
(early_ra::process_block): ...here.  Try splitting a block into
multiple regions between the definition and use phases of an
instruction.  Set IGNORE_REG on the output registers if we do so.

gcc/testsuite/
* gcc.target/aarch64/early_ra_1.c: New test.

8 months agoaarch64: Extend early-ra splitting of single-block regions
Richard Sandiford [Mon, 18 Nov 2024 19:32:50 +0000 (19:32 +0000)] 
aarch64: Extend early-ra splitting of single-block regions

When early-ra treats a block as an isolated allocation region,
it opportunistically splits the block into smaller regions
at points where no FPRs or FPR allocnos are live.  Previously
it only did this if m_allocation_successful, since the contrary
included cases in which the live range information wasn't trustworthy.

After earlier patches, we should now be able to trust the live range
information whenever m_accurate_live_ranges is true.  This means that
we can split the block into regions even if allocation failed for the
current (sub)region.

This is just something I noticed by inspection.  I don't have
a particular test case for it.

gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::process_block): Check m_accurate_live_ranges
rather than m_allocation_successful when deciding whether
to split a block into multiple regions.  Skip over subregions
that we decide not to allocate.

8 months agoaarch64: Relax early_ra treatment of modes_tieable_p
Richard Sandiford [Mon, 18 Nov 2024 19:32:50 +0000 (19:32 +0000)] 
aarch64: Relax early_ra treatment of modes_tieable_p

At least on aarch64, modes_tieable_p is a stricter condition than
can_change_mode_class.  can_change_mode_class tells us whether the
subreg rules produce a sensible result for a particular mode change.
modes_tieable_p in addition tells us whether a mode change is
reasonable for optimisation purposes.

A false return from either hook should (and does) prevent early_ra
from attempting an allocation.  But only a false return from
can_change_mode_class should invalidate the liveness tracking;
we can still analyse subregs for which can_change_mode_class is
true and modes_tieable_p is false.

This doesn't make a difference on its own, but it helps later
patches.

gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::get_allocno_subgroup): Split can_change_mode_class test
out from modes_tieable_p test and only invalidate the live range
information for the former.

8 months agoaarch64: Improve early_ra dump information
Richard Sandiford [Mon, 18 Nov 2024 19:32:49 +0000 (19:32 +0000)] 
aarch64: Improve early_ra dump information

The early-ra pass often didn't print a dump message when aborting the
allocation.  This patch uses a similar helper to the previous patch.

gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::record_allocation_failure): New member function.
(early_ra::get_allocno_subgroup): Use it instead of setting
m_allocation_successful directly.
(early_ra::record_constraints): Likewise.
(early_ra::allocate_colors): Likewise.

8 months agoaarch64: Add early_ra::record_live_range_failure
Richard Sandiford [Mon, 18 Nov 2024 19:32:49 +0000 (19:32 +0000)] 
aarch64: Add early_ra::record_live_range_failure

So far, early_ra has used a single m_allocation_successful bool
to record whether the current region is still being allocated.
But there are (at least) two reasons why we might pull out of
attempting an allocation:

(1) We can't track the liveness of individual FP allocnos,
    due to some awkward subregs.

(2) We're afraid of doing a worse job than the proper allocator.

A later patch needs to distinguish (1) from other reasons, since
(1) means that the liveness information is not trustworthy.
(Currently we assume it is not trustworthy whenever
m_allocation_successful is false, but that's too conservative.)

gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::record_live_range_failure): New member function.
(early_ra::m_accurate_live_ranges): New member variable.
(early_ra::start_new_region): Set m_accurate_live_ranges to true.
(early_ra::get_allocno_subgroup): Use record_live_range_failure
to abort the allocation on invalid subregs.