Commit graph

203034 commits

Author SHA1 Message Date
Jonathan Wakely
9bd194434a libstdc++: Fix a -Wsign-compare warning in std::list
libstdc++-v3/ChangeLog:

	* include/bits/list.tcc (list::sort(Cmp)): Fix -Wsign-compare
	warning for loop condition.
2023-08-09 15:19:16 +01:00
Jonathan Wakely
798b1f0476 libstdc++: Suppress clang -Wc99-extensions warnings in <complex>
This prevents Clang from warning about the use of the non-standard
__complex__ keyword.

libstdc++-v3/ChangeLog:

	* include/std/complex: Add diagnostic pragma for clang.
2023-08-09 15:19:16 +01:00
Jonathan Wakely
5b46eacc49 libstdc++: Fix some -Wmismatched-tags warnings
libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (atomic): Change class-head
	to struct.
	* include/bits/stl_tree.h (_Rb_tree_merge_helper): Change
	class-head to struct in friend declaration.
	* include/std/chrono (tzdb_list::_Node): Likewise.
	* include/std/future (_Task_state_base, _Task_state): Likewise.
	* include/std/scoped_allocator (__inner_type_impl): Likewise.
	* include/std/valarray (_BinClos, _SClos, _GClos, _IClos)
	(_ValFunClos, _RefFunClos): Change class-head to struct.
2023-08-09 15:19:15 +01:00
Jonathan Wakely
af89c7792d libstdc++: Fix some -Wunused-parameter warnings
libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (allocate): Add [[maybe_unused]]
	attribute.
	* include/bits/regex_executor.tcc: Remove name of unused
	parameter.
	* include/bits/shared_ptr_atomic.h (atomic_is_lock_free):
	Likewise.
	* include/bits/stl_uninitialized.h: Likewise.
	* include/bits/streambuf_iterator.h (operator==): Likewise.
	* include/bits/uses_allocator.h: Likewise.
	* include/c_global/cmath (isfinite, isinf, isnan): Likewise.
	* include/std/chrono (zoned_time): Likewise.
	* include/std/future (__future_base::_S_allocate_result):
	Likewise.
	(packaged_task): Likewise.
	* include/std/optional (_Optional_payload_base): Likewise.
	* include/std/scoped_allocator (__inner_type_impl): Likewise.
	* include/std/tuple (_Tuple_impl): Likewise.
2023-08-09 15:19:15 +01:00
Jonathan Wakely
008e439f34 libstdc++: Explicitly default some copy ctors and assignments
The standard says that the implicit copy assignment operator is
deprecated for classes that have a user-provided copy constructor, and
vice versa.

libstdc++-v3/ChangeLog:

	* include/bits/new_allocator.h (__new_allocator): Define copy
	assignment operator as defaulted.
	* include/std/complex (complex<float>, complex<double>)
	(complex<long double>): Define copy constructor as defaulted.
2023-08-09 15:19:15 +01:00
Jonathan Wakely
b9e5a4b4f0 libstdc++: Minor fixes for some warnings in <format>
libstdc++-v3/ChangeLog:

	* include/std/format: Fix some warnings.
	(__format::__write(Ctx&, basic_string_view<CharT>)): Remove
	unused function template.
2023-08-09 15:19:15 +01:00
Juzhe-Zhong
c4d6181430 RISC-V: Support NPATTERNS = 1 stepped vector[PR110950]
This patch fix ICE: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110950

0x1cf8939 expand_const_vector
        ../../../riscv-gcc/gcc/config/riscv/riscv-v.cc:1587

	PR target/110950

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (expand_const_vector): Add NPATTERNS = 1
	stepped vector support.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr110950.c: New test.
2023-08-09 21:37:22 +08:00
Paul Thomas
b8ec3c9523 Fortran: Allow pure final procs contained in pure proc. [PR109684]
2023-08-09  Steve Kargl  <sgk@troutmask.apl.washington.edu>

gcc/fortran
	PR fortran/109684
	* resolve.cc (resolve_types): Exclude contained procedures with
	the artificial attribute from test for pureness.
2023-08-09 12:04:09 +01:00
Gaius Mulley
e3476ed223 PR modula2/110779: libgm2 fix solaris bootstrap check for tm_gmtoff
This patch defensively checks for every C function and every struct
used in wrapclock.cc.  It adds return values to GetTimespec and
SetTimespec to allow the module to return a code representing
unavailable.

gcc/m2/ChangeLog:

	PR modula2/110779
	* gm2-libs-iso/SysClock.mod (GetClock): Test GetTimespec
	return value.
	(SetClock): Test SetTimespec return value.
	* gm2-libs-iso/wrapclock.def (GetTimespec): Add integer
	return type.
	(SetTimespec): Add integer return type.

libgm2/ChangeLog:

	PR modula2/110779
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac (AC_CACHE_CHECK): Check for tm_gmtoff field in
	struct tm.
	(GM2_CHECK_LIB): Check for daylight, timezone and tzname.
	* libm2iso/wrapclock.cc (timezone): Guard against absence of
	struct tm and tm_gmtoff.
	(daylight): Check for daylight.
	(timezone): Check for timezone.
	(isdst): Check for isdst.
	(tzname): Check for tzname.
	(GetTimeRealtime): Check for struct timespec.
	(SetTimeRealtime): Check for struct timespec.
	(InitTimespec): Check for struct timespec.
	(KillTimespec): Check for struct timespec.
	(SetTimespec): Check for struct timespec.
	(GetTimespec): Check for struct timespec.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-08-09 09:35:13 +01:00
liuhongt
6ef7956e9d Rename local variable subleaf_level to max_subleaf_level.
gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_available_features):
	Rename local variable subleaf_level to max_subleaf_level.
2023-08-09 15:47:48 +08:00
Richard Biener
b66e613a1a rtl-optimization/110587 - speedup find_hard_regno_for_1
The following applies a micro-optimization to find_hard_regno_for_1,
re-ordering the check so we can easily jump-thread by using an else.
This reduces the time spent in this function by 15% for the testcase
in the PR.

	PR rtl-optimization/110587
	* lra-assigns.cc (find_hard_regno_for_1): Re-order checks.
2023-08-09 08:46:58 +02:00
Kewen Lin
0412f0e374 rs6000: Teach legitimate_address_p about LEN_{LOAD,STORE} [PR110248]
This patch is to teach rs6000_legitimate_address_p to
handle the queried rtx constructed for LEN_{LOAD,STORE},
since lxvl and stxvl doesn't support x-form or ds-form,
so consider it as not legitimate when outer code is PLUS.

	PR tree-optimization/110248

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_legitimate_address_p): Check if
	the given code is for ifn LEN_{LOAD,STORE}, if yes then make it not
	legitimate when outer code is PLUS.
2023-08-09 01:16:05 -05:00
Kewen Lin
4a8e6fa801 ivopts: Call valid_mem_ref_p with ifn [PR110248]
As PR110248 shows, to get the expected query results for
that internal functions LEN_{LOAD,STORE} is able to adopt
some addressing modes, we need to pass down the related
IFN code as well.  This patch is to make IVOPTs pass down
ifn code for USE_PTR_ADDRESS type uses, it adjusts the
related functions {strict_,}memory_address_addr_space_p,
and valid_mem_ref_p as well.

	PR tree-optimization/110248

gcc/ChangeLog:

	* recog.cc (memory_address_addr_space_p): Add one more argument ch of
	type code_helper and pass it to targetm.addr_space.legitimate_address_p
	instead of ERROR_MARK.
	(offsettable_address_addr_space_p): Update one function pointer with
	one more argument of type code_helper as its assignees
	memory_address_addr_space_p and strict_memory_address_addr_space_p
	have been adjusted, and adjust some call sites with ERROR_MARK.
	* recog.h (tree.h): New include header file for tree_code ERROR_MARK.
	(memory_address_addr_space_p): Adjust with one more unnamed argument
	of type code_helper with default ERROR_MARK.
	(strict_memory_address_addr_space_p): Likewise.
	* reload.cc (strict_memory_address_addr_space_p): Add one unnamed
	argument of type code_helper.
	* tree-ssa-address.cc (valid_mem_ref_p): Add one more argument ch of
	type code_helper and pass it to memory_address_addr_space_p.
	* tree-ssa-address.h (valid_mem_ref_p): Adjust the declaration with
	one more unnamed argument of type code_helper with default value
	ERROR_MARK.
	* tree-ssa-loop-ivopts.cc (get_address_cost): Use ERROR_MARK as code
	by default, change it with ifn code for USE_PTR_ADDRESS type use, and
	pass it to all valid_mem_ref_p calls.
2023-08-09 01:16:05 -05:00
Kewen Lin
165b1f6ad1 targhooks: Extend legitimate_address_p with code_helper [PR110248]
As PR110248 shows, some middle-end passes like IVOPTs can
query the target hook legitimate_address_p with some
artificially constructed rtx to determine whether some
addressing modes are supported by target for some gimple
statement.  But for now the existing legitimate_address_p
only checks the given mode, it's unable to distinguish
some special cases unfortunately, for example, for LEN_LOAD
ifn on Power port, we would expand it with lxvl hardware
insn, which only supports one register to hold the address
(the other register is holding the length), that is we
don't support base (reg) + index (reg) addressing mode for
sure.  But hook legitimate_address_p only considers the
given mode which would be some vector mode for LEN_LOAD
ifn, and we do support base + index addressing mode for
normal vector load and store insns, so the hook will return
true for the query unexpectedly.

This patch is to introduce one extra argument of type
code_helper for hook legitimate_address_p, it makes targets
able to handle some special case like what's described
above.

	PR tree-optimization/110248

gcc/ChangeLog:

	* coretypes.h (class code_helper): Add forward declaration.
	* doc/tm.texi: Regenerate.
	* lra-constraints.cc (valid_address_p): Call target hook
	targetm.addr_space.legitimate_address_p with an extra parameter
	ERROR_MARK as its prototype changes.
	* recog.cc (memory_address_addr_space_p): Likewise.
	* reload.cc (strict_memory_address_addr_space_p): Likewise.
	* target.def (legitimate_address_p, addr_space.legitimate_address_p):
	Extend with one more argument of type code_helper, update the
	documentation accordingly.
	* targhooks.cc (default_legitimate_address_p): Adjust for the
	new code_helper argument.
	(default_addr_space_legitimate_address_p): Likewise.
	* targhooks.h (default_legitimate_address_p): Likewise.
	(default_addr_space_legitimate_address_p): Likewise.
	* config/aarch64/aarch64.cc (aarch64_legitimate_address_hook_p): Adjust
	with extra unnamed code_helper argument with default ERROR_MARK.
	* config/alpha/alpha.cc (alpha_legitimate_address_p): Likewise.
	* config/arc/arc.cc (arc_legitimate_address_p): Likewise.
	* config/arm/arm-protos.h (arm_legitimate_address_p): Likewise.
	(tree.h): New include for tree_code ERROR_MARK.
	* config/arm/arm.cc (arm_legitimate_address_p): Adjust with extra
	unnamed code_helper argument with default ERROR_MARK.
	* config/avr/avr.cc (avr_addr_space_legitimate_address_p): Likewise.
	* config/bfin/bfin.cc (bfin_legitimate_address_p): Likewise.
	* config/bpf/bpf.cc (bpf_legitimate_address_p): Likewise.
	* config/c6x/c6x.cc (c6x_legitimate_address_p): Likewise.
	* config/cris/cris-protos.h (cris_legitimate_address_p): Likewise.
	(tree.h): New include for tree_code ERROR_MARK.
	* config/cris/cris.cc (cris_legitimate_address_p): Adjust with extra
	unnamed code_helper argument with default ERROR_MARK.
	* config/csky/csky.cc (csky_legitimate_address_p): Likewise.
	* config/epiphany/epiphany.cc (epiphany_legitimate_address_p):
	Likewise.
	* config/frv/frv.cc (frv_legitimate_address_p): Likewise.
	* config/ft32/ft32.cc (ft32_addr_space_legitimate_address_p): Likewise.
	* config/gcn/gcn.cc (gcn_addr_space_legitimate_address_p): Likewise.
	* config/h8300/h8300.cc (h8300_legitimate_address_p): Likewise.
	* config/i386/i386.cc (ix86_legitimate_address_p): Likewise.
	* config/ia64/ia64.cc (ia64_legitimate_address_p): Likewise.
	* config/iq2000/iq2000.cc (iq2000_legitimate_address_p): Likewise.
	* config/lm32/lm32.cc (lm32_legitimate_address_p): Likewise.
	* config/loongarch/loongarch.cc (loongarch_legitimate_address_p):
	Likewise.
	* config/m32c/m32c.cc (m32c_legitimate_address_p): Likewise.
	(m32c_addr_space_legitimate_address_p): Likewise.
	* config/m32r/m32r.cc (m32r_legitimate_address_p): Likewise.
	* config/m68k/m68k.cc (m68k_legitimate_address_p): Likewise.
	* config/mcore/mcore.cc (mcore_legitimate_address_p): Likewise.
	* config/microblaze/microblaze-protos.h (tree.h): New include for
	tree_code ERROR_MARK.
	(microblaze_legitimate_address_p): Adjust with extra unnamed
	code_helper argument with default ERROR_MARK.
	* config/microblaze/microblaze.cc (microblaze_legitimate_address_p):
	Likewise.
	* config/mips/mips.cc (mips_legitimate_address_p): Likewise.
	* config/mmix/mmix.cc (mmix_legitimate_address_p): Likewise.
	* config/mn10300/mn10300.cc (mn10300_legitimate_address_p): Likewise.
	* config/moxie/moxie.cc (moxie_legitimate_address_p): Likewise.
	* config/msp430/msp430.cc (msp430_legitimate_address_p): Likewise.
	(msp430_addr_space_legitimate_address_p): Adjust with extra code_helper
	argument with default ERROR_MARK and adjust the call to function
	msp430_legitimate_address_p.
	* config/nds32/nds32.cc (nds32_legitimate_address_p): Adjust with extra
	unnamed code_helper argument with default ERROR_MARK.
	* config/nios2/nios2.cc (nios2_legitimate_address_p): Likewise.
	* config/nvptx/nvptx.cc (nvptx_legitimate_address_p): Likewise.
	* config/or1k/or1k.cc (or1k_legitimate_address_p): Likewise.
	* config/pa/pa.cc (pa_legitimate_address_p): Likewise.
	* config/pdp11/pdp11.cc (pdp11_legitimate_address_p): Likewise.
	* config/pru/pru.cc (pru_addr_space_legitimate_address_p): Likewise.
	* config/riscv/riscv.cc (riscv_legitimate_address_p): Likewise.
	* config/rl78/rl78-protos.h (rl78_as_legitimate_address): Likewise.
	(tree.h): New include for tree_code ERROR_MARK.
	* config/rl78/rl78.cc (rl78_as_legitimate_address): Adjust with
	extra unnamed code_helper argument with default ERROR_MARK.
	* config/rs6000/rs6000.cc (rs6000_legitimate_address_p): Likewise.
	(rs6000_debug_legitimate_address_p): Adjust with extra code_helper
	argument and adjust the call to function rs6000_legitimate_address_p.
	* config/rx/rx.cc (rx_is_legitimate_address): Adjust with extra
	unnamed code_helper argument with default ERROR_MARK.
	* config/s390/s390.cc (s390_legitimate_address_p): Likewise.
	* config/sh/sh.cc (sh_legitimate_address_p): Likewise.
	* config/sparc/sparc.cc (sparc_legitimate_address_p): Likewise.
	* config/v850/v850.cc (v850_legitimate_address_p): Likewise.
	* config/vax/vax.cc (vax_legitimate_address_p): Likewise.
	* config/visium/visium.cc (visium_legitimate_address_p): Likewise.
	* config/xtensa/xtensa.cc (xtensa_legitimate_address_p): Likewise.
	* config/stormy16/stormy16-protos.h (xstormy16_legitimate_address_p):
	Likewise.
	(tree.h): New include for tree_code ERROR_MARK.
	* config/stormy16/stormy16.cc (xstormy16_legitimate_address_p):
	Adjust with extra unnamed code_helper argument with default
	ERROR_MARK.
2023-08-09 01:16:05 -05:00
liuhongt
b39f8bdad1 Workaround possible CPUID bug in Sandy Bridge.
Don't access leaf 7 subleaf 1 unless subleaf 0 says it is
supported via EAX.

Intel documentation says invalid subleaves return 0. We had been
relying on that behavior instead of checking the max sublef number.

It appears that some Sandy Bridge CPUs return at least the subleaf 0
EDX value for subleaf 1. Best guess is that this is a bug in a
microcode patch since all of the bits we're seeing set in EDX were
introduced after Sandy Bridge was originally released.

This is causing avxvnniint16 to be incorrectly enabled with
-march=native on these CPUs.

gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_available_features): Check
	EAX for valid subleaf before use CPUID.
2023-08-09 14:01:24 +08:00
GCC Administrator
c8b396243e Daily bump. 2023-08-09 00:16:57 +00:00
Jeff Law
20659be04c [committed] [RISC-V] Fix bug in condition canonicalization for zicond
Vineet's glibc build triggered an ICE building glibc with the latest zicond
bits.  It's a minor issue in the canonicalization of the condition.

When we need to canonicalize the condition we use an SCC insn to handle the
primary comparison with the output going into a temporary with the final value
of 0/1 which we can then use in a zicond instruction.

The mode of the newly generated temporary was taken from mode of the final
destination.  That's simply wrong.  The mode of the condition needs to be
word_mode.

This patch fixes that minor problem and adds a suitable testcase.

gcc/
	* config/riscv/riscv.cc (riscv_expand_conditional_move): Use word_mode
	for the temporary when canonicalizing the condition.

gcc/testsuite
	* gcc.target/riscv/zicond-ice-1.c: New test.
2023-08-08 15:37:34 -06:00
Marek Polacek
a263152643 c++: parser cleanup, remove dummy arguments
Now that cp_parser_constant_expression accepts a null non_constant_p,
we can transitively remove dummy arguments in the call chain.

Running dg.exp and counting the # of is_rvalue_constant_expression calls
from cp_parser_constant_expression:
pre-r14-2800: 2,459,145
this patch  : 1,719,454

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_postfix_expression): Adjust the call to
	cp_parser_braced_list.
	(cp_parser_postfix_open_square_expression): Likewise.
	(cp_parser_new_initializer): Likewise.
	(cp_parser_assignment_expression): Adjust the call to
	cp_parser_initializer_clause.
	(cp_parser_lambda_introducer): Adjust the call to cp_parser_initializer.
	(cp_parser_range_for): Adjust the call to cp_parser_braced_list.
	(cp_parser_jump_statement): Likewise.
	(cp_parser_mem_initializer): Likewise.
	(cp_parser_template_argument): Likewise.
	(cp_parser_default_argument): Adjust the call to cp_parser_initializer.
	(cp_parser_initializer): Handle null is_direct_init and non_constant_p
	arguments.
	(cp_parser_initializer_clause): Handle null non_constant_p argument.
	(cp_parser_braced_list): Likewise.
	(cp_parser_initializer_list): Likewise.
	(cp_parser_member_declaration): Adjust the call to
	cp_parser_initializer_clause and cp_parser_initializer.
	(cp_parser_yield_expression): Adjust the call to cp_parser_braced_list.
	(cp_parser_functional_cast): Likewise.
	(cp_parser_late_parse_one_default_arg): Adjust the call to
	cp_parser_initializer.
	(cp_parser_omp_for_loop_init): Likewise.
	(cp_parser_omp_declare_reduction_exprs): Likewise.
2023-08-08 16:52:10 -04:00
Nathaniel Shead
a90bd3ea6d c++: Report invalid id-expression in decltype [PR100482]
This patch ensures that any errors raised by finish_id_expression when
parsing a decltype expression are properly reported, rather than
potentially going ignored and causing invalid code to be accepted.

We can also now remove the separate check for templates without args as
this is also checked for in finish_id_expression.

	PR c++/100482

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_decltype_expr): Report errors raised by
	finish_id_expression.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/decltype-100482.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2023-08-08 16:03:25 -04:00
Cupertino Miranda
e7cae4f873 bpf: Fixed GC mistakes in BPF builtins code.
This patches fixes problems with GC within the CO-RE builtins
implementation.
List of included headers was also revised.

gcc/ChangeLog:

	* config/bpf/core-builtins.cc: Cleaned include headers.
	(struct cr_builtins): Added GTY.
	(cr_builtins_ref): Created.
	(builtins_data) Changed to GC root.
	(allocate_builtin_data): Changed.
	Included gt-core-builtins.h.
	* config/bpf/coreout.cc: (bpf_core_extra) Added GTY.
	(bpf_core_extra_ref): Created.
	(bpf_comment_info): Changed to GC root.
	(bpf_core_reloc_add, output_btfext_header, btf_ext_init): Changed.
2023-08-08 20:36:36 +01:00
Uros Bizjak
ad5b757d99 i386: Do not sanitize upper part of V2SFmode reg with -fno-trapping-math [PR110832]
Also introduce -m[no-]partial-vector-fp-math option to disable trapping
V2SF named patterns in order to avoid generation of partial vector V4SFmode
trapping instructions.

The new option is enabled by default, because even with sanitization,
a small but consistent speed up of 2 to 3% with Polyhedron capacita
benchmark can be achieved vs. scalar code.

Using -fno-trapping-math improves Polyhedron capacita runtime 8 to 9%
vs. scalar code.  This is what clang does by default, as it defaults
to -fno-trapping-math.

	PR target/110832

gcc/ChangeLog:

	* config/i386/i386.opt (mpartial-vector-fp-math): New option.
	* config/i386/mmx.md (movq_<mode>_to_sse): Do not sanitize
	upper part of V2SFmode register with -fno-trapping-math.
	(<plusminusmult:insn>v2sf3): Enable for ix86_partial_vec_fp_math.
	(divv2sf3): Ditto.
	(<smaxmin:code>v2sf3): Ditto.
	(sqrtv2sf2): Ditto.
	(*mmx_haddv2sf3_low): Ditto.
	(*mmx_hsubv2sf3_low): Ditto.
	(vec_addsubv2sf3): Ditto.
	(vec_cmpv2sfv2si): Ditto.
	(vcond<V2FI:mode>v2sf): Ditto.
	(fmav2sf4): Ditto.
	(fmsv2sf4): Ditto.
	(fnmav2sf4): Ditto.
	(fnmsv2sf4): Ditto.
	(fix_truncv2sfv2si2): Ditto.
	(fixuns_truncv2sfv2si2): Ditto.
	(floatv2siv2sf2): Ditto.
	(floatunsv2siv2sf2): Ditto.
	(nearbyintv2sf2): Ditto.
	(rintv2sf2): Ditto.
	(lrintv2sfv2si2): Ditto.
	(ceilv2sf2): Ditto.
	(lceilv2sfv2si2): Ditto.
	(floorv2sf2): Ditto.
	(lfloorv2sfv2si2): Ditto.
	(btruncv2sf2): Ditto.
	(roundv2sf2): Ditto.
	(lroundv2sfv2si2): Ditto.
	* doc/invoke.texi (x86 Options): Document
	-mpartial-vector-fp-math option.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr110832-1.c: New test.
	* gcc.target/i386/pr110832-2.c: New test.
	* gcc.target/i386/pr110832-3.c: New test.
2023-08-08 18:56:07 +02:00
Andrew Pinski
aadc5c07fe VR-VALUES [PR28794]: optimize compare assignments also
This patch fixes the oldish (2006) bug where VRP was not
optimizing the comparison for assignments while handling
them for GIMPLE_COND only.
It just happens to also solves PR 103281 due to allowing
to optimize `c < 1` to `c == 0` and then we get
`(c == 0) == c` (which was handled by r14-2501-g285c9d04).

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

	PR tree-optimization/103281
	PR tree-optimization/28794

gcc/ChangeLog:

	* vr-values.cc (simplify_using_ranges::simplify_cond_using_ranges_1): Split out
	majority to ...
	(simplify_using_ranges::simplify_compare_using_ranges_1): Here.
	(simplify_using_ranges::simplify_casted_cond): Rename to ...
	(simplify_using_ranges::simplify_casted_compare): This
	and change arguments to take op0 and op1.
	(simplify_using_ranges::simplify_compare_assign_using_ranges_1): New method.
	(simplify_using_ranges::simplify): For tcc_comparison assignments call
	simplify_compare_assign_using_ranges_1.
	* vr-values.h (simplify_using_ranges): Add
	new methods, simplify_compare_using_ranges_1 and simplify_compare_assign_using_ranges_1.
	Rename simplify_casted_cond and simplify_casted_compare and
	update argument types.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr103281-1.c: New test.
	* gcc.dg/tree-ssa/vrp-compare-1.c: New test.
2023-08-08 08:41:14 -07:00
Pan Li
733e8b48cb RISC-V: Enhance the test case for RVV vfsub/vfrsub rounding
This patch would like to enhance the vfsub/vfrsub rounding API test for
below 2 purposes.

* The non-rm API has no frm related insn generated.
* The rm API has the frm backup/restore/set insn generated.

Signed-off-by: Pan Li <pan2.li@intel.com>

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/float-point-single-rsub.c: Enhance
	cases.
	* gcc.target/riscv/rvv/base/float-point-single-sub.c: Ditto.
Signed-off-by: Pan Li <pan2.li@intel.com>
2023-08-08 22:21:40 +08:00
Andrzej Turko
d9dc70cc65 genmatch: Log line numbers indirectly
Currently fprintf calls logging to a dump file take line numbers
in the match.pd file directly as arguments.
When match.pd is edited, referenced code changes line numbers,
which causes changes to many fprintf calls and, thus, to many
(usually all) .cc files generated by genmatch. This forces make
to (unnecessarily) rebuild many .o files.

This change replaces those logging fprintf calls with calls to
a dedicated logging function. Because it reads the line numbers
from the lookup table, it is enough to pass a corresponding index.
Thanks to this, when match.pd changes, it is enough to rebuild
the file containing the lookup table and, of course, those
actually affected by the change.

Signed-off-by: Andrzej Turko <andrzej.turko@gmail.com>

gcc/ChangeLog:

	* genmatch.cc: Log line numbers indirectly.
2023-08-08 15:30:45 +02:00
Andrzej Turko
e6b616c076 genmatch: Reduce variability of generated code
So far genmatch has been using an unordered map to store information about
functions to be generated. Since corresponding locations from match.pd were
used as keys in the map, even small changes to match.pd which caused
line number changes would change the order in which the functions are
generated. This would reshuffle the functions between the generated .cc files.
This way even a minimal modification to match.pd forces recompilation of all
object files originating from match.pd on rebuild.

This commit makes sure that functions are generated in the order of their
processing (in contrast to the random order based on hashes of their
locations in match.pd). This is done by replacing the unordered map with an
ordered one. This way small changes to match.pd does not cause function
renaming and reshuffling among generated source files.
Together with the subsequent change to logging fprintf calls, this
removes unnecessary changes to the files generated by genmatch allowing
for reuse of already built object files during rebuild. The aim is to
make editing of match.pd and subsequent testing easier.

Signed-off-by: Andrzej Turko <andrzej.turko@gmail.com>

gcc/ChangeLog:

	* genmatch.cc: Make sinfo map ordered.
	* Makefile.in: Require the ordered map header for genmatch.o.
2023-08-08 15:30:45 +02:00
Andrzej Turko
3bb0bf067b Support get_or_insert in ordered_hash_map
Get_or_insert method is already supported by the unordered hash map.
Adding it to the ordered map enables us to replace the unordered map
with the ordered one in cases where ordering may be useful.

Signed-off-by: Andrzej Turko <andrzej.turko@gmail.com>

gcc/ChangeLog:

	* ordered-hash-map.h: Add get_or_insert.
	* ordered-hash-map-tests.cc: Use get_or_insert in tests.
2023-08-08 15:30:44 +02:00
Juzhe-Zhong
6ae5565e78 RISC-V: Support CALL conditional autovec patterns
This patch is depending on middle-end patch on vectorizable_call.

Consider this following case:
void foo (float * __restrict a, float * __restrict b, int * __restrict cond, int n)
{
  for (int i = 0; i < n; i++)
    if (cond[i])
      a[i] = b[i] + a[i];
}

Before this patch (**NO** -ffast-math):
<source>:5:21: missed: couldn't vectorize loop
<source>:5:21: missed: not vectorized: control flow in loop.

After this patch:
foo:
	ble	a3,zero,.L5
	mv	a6,a0
.L3:
	vsetvli	a5,a3,e8,mf4,ta,ma
	vle32.v	v0,0(a2)
	vsetvli	a7,zero,e32,m1,ta,ma
	slli	a4,a5,2
	vmsne.vi	v0,v0,0
	sub	a3,a3,a5
	vsetvli	zero,a5,e32,m1,tu,mu    ------> must be TUMU
	vle32.v	v2,0(a0),v0.t
	vle32.v	v1,0(a1),v0.t
	vfadd.vv	v1,v1,v2,v0.t   ------> generated by COND_LEN_ADD with real mask and len.
	vse32.v	v1,0(a6),v0.t
	add	a2,a2,a4
	add	a1,a1,a4
	add	a0,a0,a4
	add	a6,a6,a4
	bne	a3,zero,.L3
.L5:
	ret

gcc/ChangeLog:

	* config/riscv/autovec.md (cond_<optab><mode>): New pattern.
	(cond_len_<optab><mode>): Ditto.
	(cond_fma<mode>): Ditto.
	(cond_len_fma<mode>): Ditto.
	(cond_fnma<mode>): Ditto.
	(cond_len_fnma<mode>): Ditto.
	(cond_fms<mode>): Ditto.
	(cond_len_fms<mode>): Ditto.
	(cond_fnms<mode>): Ditto.
	(cond_len_fnms<mode>): Ditto.
	* config/riscv/riscv-protos.h (riscv_get_v_regno_alignment): Export
	global.
	(enum insn_type): Add new enum type.
	(prepare_ternary_operands): New function.
	* config/riscv/riscv-v.cc (emit_vlmax_masked_fp_mu_insn): Ditto.
	(emit_nonvlmax_tumu_insn): Ditto.
	(emit_nonvlmax_fp_tumu_insn): Ditto.
	(expand_cond_len_binop): Add condtional operations.
	(expand_cond_len_ternop): Ditto.
	(prepare_ternary_operands): New function.
	* config/riscv/riscv.cc (riscv_memmodel_needs_amo_release): Export
	riscv_get_v_regno_alignment as global scope.
	* config/riscv/vector.md: Fix ternary bugs.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/rvv.exp: Add condition tests.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-7.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-8.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith-9.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-7.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-8.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_arith_run-9.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-7.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-8.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-7.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-8.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_logical_run-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-7.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-8.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift-9.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-3.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-4.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-5.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-6.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-7.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-8.c: New test.
	* gcc.target/riscv/rvv/autovec/cond/cond_shift_run-9.c: New test.
	* gcc.target/riscv/rvv/autovec/reduc/reduc_call-1.c: New test.
	* gcc.target/riscv/rvv/autovec/reduc/reduc_call-2.c: New test.
	* gcc.target/riscv/rvv/autovec/reduc/reduc_call-3.c: New test.
	* gcc.target/riscv/rvv/autovec/reduc/reduc_call-4.c: New test.
	* gcc.target/riscv/rvv/autovec/reduc/reduc_call-5.c: New test.
2023-08-08 21:07:56 +08:00
Richard Biener
d9f3ea61fe tree-optimization/49955 - BB reduction with odd number of lanes
The following enhances BB reduction vectorization to support
vectorizing only a subset of the lanes, keeping the rest as
scalar ops.  For now we try to make the number of lanes even
by leaving alone the "last" lane.  That's because SLP discovery
with all lanes will fail too soon to get us any hint on which
lane to strip and likewise we don't know what vector modes the
target supports so restricting ourselves to power-of-two or
other cases isn't easy.

This is enough to get at the vectorization opportunity for the
testcase in the PR - albeit with the chosen lanes not optimal
but at least vectorizable.

	PR tree-optimization/49955
	* tree-vectorizer.h (_slp_instance::remain_stmts): New.
	(SLP_INSTANCE_REMAIN_STMTS): Likewise.
	* tree-vect-slp.cc (vect_free_slp_instance): Release
	SLP_INSTANCE_REMAIN_STMTS.
	(vect_build_slp_instance): Make the number of lanes of
	a BB reduction even.
	(vectorize_slp_instance_root_stmt): Handle unvectorized
	defs of a BB reduction.

	* gfortran.dg/vect/pr49955.f: New testcase.
2023-08-08 14:38:10 +02:00
Ju-Zhe Zhong
02a015fa32 VECT: Support CALL vectorization for COND_LEN_*
Hi, Richard and Richi.

Base on the suggestions from Richard:
https://gcc.gnu.org/pipermail/gcc-patches/2023-July/625396.html

This patch choose (1) approach that Richard provided, meaning:

RVV implements cond_* optabs as expanders.  RVV therefore supports
both IFN_COND_ADD and IFN_COND_LEN_ADD.  No dummy length arguments
are needed at the gimple level.

Such approach can make codes much cleaner and reasonable.

Consider this following case:
void foo (float * __restrict a, float * __restrict b, int * __restrict cond, int n)
{
  for (int i = 0; i < n; i++)
    if (cond[i])
      a[i] = b[i] + a[i];
}

Output of RISC-V (32-bits) gcc (trunk) (Compiler #3)
<source>:5:21: missed: couldn't vectorize loop
<source>:5:21: missed: not vectorized: control flow in loop.

ARM SVE:

...
mask__27.10_51 = vect__4.9_49 != { 0, ... };
...
vec_mask_and_55 = loop_mask_49 & mask__27.10_51;
...
vect__9.17_62 = .COND_ADD (vec_mask_and_55, vect__6.13_56, vect__8.16_60, vect__6.13_56);

For RVV, we want IR as follows:

...
_68 = .SELECT_VL (ivtmp_66, POLY_INT_CST [4, 4]);
...
mask__27.10_51 = vect__4.9_49 != { 0, ... };
...
vect__9.17_60 = .COND_LEN_ADD (mask__27.10_51, vect__6.13_55, vect__8.16_59, vect__6.13_55, _68, 0);
...

Both len and mask of COND_LEN_ADD are real not dummy.

This patch has been fully tested in RISC-V port with supporting both COND_* and COND_LEN_*.

And also, Bootstrap and Regression on X86 passed.

OK for trunk?

gcc/ChangeLog:

	* internal-fn.cc (get_len_internal_fn): New function.
	(DEF_INTERNAL_COND_FN): Ditto.
	(DEF_INTERNAL_SIGNED_COND_FN): Ditto.
	* internal-fn.h (get_len_internal_fn): Ditto.
	* tree-vect-stmts.cc (vectorizable_call): Add CALL auto-vectorization.
2023-08-08 20:37:18 +08:00
Richard Biener
31ec413098 tree-optimization/110924 - fix vop liveness for noreturn const CFG parts
The virtual operand live problem used by sinking assumes we have
virtual uses at each end point of the CFG but as shown in the PR
this isn't true for parts for example ending in __builtin_unreachable.
The following removes the optimization made possible by this and
now requires marking backedges.

	PR tree-optimization/110924
	* tree-ssa-live.h (virtual_operand_live): Update comment.
	* tree-ssa-live.cc (virtual_operand_live::get_live_in): Remove
	optimization, look at each predecessor.
	* tree-ssa-sink.cc (pass_sink_code::execute): Mark backedges.

	* gcc.dg/torture/pr110924.c: New testcase.
2023-08-08 14:24:12 +02:00
yulong
25c4b1620e RISC-V: Fix a bug that causes an error insn.
I test the following rvv intrinsics.
vint64m1_t test_vslide1up_vx_i64m1_m(vbool64_t mask, vint64m1_t src, int64_t value, size_t vl) {
  return __riscv_vslide1up_vx_i64m1_m(mask, src, value, vl);
}
And I got an error info,t hat is error:
  unrecognizable insn:(insn 17 16 18 2
    (set (reg:RVVMIDI 134 [ _1 ])(if_then_else:RVVMIDI
      (unspec:RVVMF64BI [(reg/v:SI 142 [ vl ])(const_int 2 [x2])(const_int 日 [o])(reg:SI 66 vl)(reg:SI 67 vtype)] UNSPEC_VPREDICATE
   (vec_merge:RVVMIDI (reg:RVVMIDI 134 [ _1 ])(unspec:RVVMIDI [(reg:sI 日 zero)] UNSPEC_VUNDEF)
   (reg/v:RVVMF64BI 137 [ mask ]))
   (unspec:RVVM1DI[(reg:sI 日 zero)] UNSPEC_VUNDEF)))

This patch fix it.

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (slide1_sew64_helper): Modify.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/vslide1down-1.c: New test.
	* gcc.target/riscv/rvv/base/vslide1down-2.c: New test.
	* gcc.target/riscv/rvv/base/vslide1down-3.c: New test.
	* gcc.target/riscv/rvv/base/vslide1up-1.c: New test.
	* gcc.target/riscv/rvv/base/vslide1up-2.c: New test.
	* gcc.target/riscv/rvv/base/vslide1up-3.c: New test.
2023-08-08 15:47:03 +08:00
Stefan Schulze Frielinghaus
f3a8dde08b rtl-optimization/110869 Fix tests cmp-mem-const-*.c for sparc
This fixes the rather new tests cmp-mem-const-{1,2,3,4,5,6}.c for sparc.
For -1 and -2 we need at least optimization level 2 on sparc.  For the
sake of homogeneity, change all test cases to -O2.  For -3 and -4 we do
not end up with a comparison of memory and a constant, and finally for
-5 and -6 the constants are reduced by a prior optimization which means
there is nothing left to do.  Thus excluding sparc from those tests.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/110869
	* gcc.dg/cmp-mem-const-1.c: Use optimization level 2.
	* gcc.dg/cmp-mem-const-2.c: Dito.
	* gcc.dg/cmp-mem-const-3.c: Exclude sparc from this test.
	* gcc.dg/cmp-mem-const-4.c: Dito.
	* gcc.dg/cmp-mem-const-5.c: Dito.
	* gcc.dg/cmp-mem-const-6.c: Dito.
2023-08-08 08:53:12 +02:00
Juzhe-Zhong
8f4d2a4c98 RISC-V: Support neg VLS auto-vectorization
#include "riscv_vector.h"

#define DEF_OP_V(PREFIX, NUM, TYPE, OP)                                        \
  void __attribute__ ((noinline, noclone))                                     \
  PREFIX##_##TYPE##NUM (TYPE *restrict a, TYPE *restrict b)                    \
  {                                                                            \
    for (int i = 0; i < NUM; ++i)                                              \
      a[i] = OP b[i];                                                          \
  }

DEF_OP_V (neg, 16, int32_t, -)

After this patch:

neg_int32_t16:
	vsetivli	zero,16,e32,mf2,ta,ma
	vle32.v	v1,0(a1)
	vneg.v	v1,v1
	vse32.v	v1,0(a0)
	ret

gcc/ChangeLog:

	* config/riscv/autovec-vls.md (<optab><mode>2): Add VLS neg.
	* config/riscv/vector.md: Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vls/def.h: Ditto.
	* gcc.target/riscv/rvv/autovec/vls/neg-1.c: New test.
2023-08-08 11:38:11 +08:00
Juzhe-Zhong
99e47791a9 RISC-V: Support VLS shift vectorization
After this patch, this following case will be well optimized:

  void __attribute__ ((noinline, noclone))                                     \
  PREFIX##_##TYPE##NUM (TYPE *restrict a, TYPE *restrict b, TYPE *restrict c)  \
  {                                                                            \
    for (int i = 0; i < NUM; ++i)                                              \
      a[i] = b[i] OP c[i];                                                     \
  }

DEF_OP_VV (shift, 16, int32_t, >>)

ASM:
shift_int32_t16:
	vsetivli	zero,16,e32,mf2,ta,ma
	vle32.v	v1,0(a1)
	vle32.v	v2,0(a2)
	vsra.vv	v1,v1,v2
	vse32.v	v1,0(a0)
	ret

gcc/ChangeLog:

	* config/riscv/autovec.md: Add VLS shift.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS shift.
	* gcc.target/riscv/rvv/autovec/vls/shift-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/shift-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/shift-3.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/shift-4.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/shift-5.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/shift-6.c: New test.
2023-08-08 10:29:54 +08:00
GCC Administrator
4b92dba78d Daily bump. 2023-08-08 00:17:37 +00:00
Juzhe-Zhong
9cba4fce83 RISC-V: Support VLS basic operation auto-vectorization
This patch support VLS modes auto-vectorization to enhance VLA auto-vectorization
when niters is known.

Consider this following case:

  void __attribute__ ((noinline, noclone))                                     \
  PREFIX##_##TYPE##NUM (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c)  \
  {                                                                            \
    for (int i = 0; i < NUM; ++i)                                              \
      a[i] = b[i] OP c[i];                                                     \
  }

DEF_OP_VV (plus, 16, int8_t, +)

Before this patch:

plus_int8_t16(signed char*, signed char*, signed char*):
        li      a5,16
        csrr    a4,vlenb
        bleu    a5,a4,.L2
        mv      a5,a4
.L2:
        vsetvli zero,a5,e8,m1,ta,ma
        vle8.v  v2,0(a1)
        vle8.v  v1,0(a2)
        vsetvli a4,zero,e8,m1,ta,ma
        vadd.vv v1,v1,v2
        vsetvli zero,a5,e8,m1,ta,ma
        vse8.v  v1,0(a0)
        ret

After this patch:

plus_int8_t16:
	vsetivli	zero,16,e8,m1,ta,ma
	vle8.v	v1,0(a2)
	vle8.v	v2,0(a1)
	vadd.vv	v1,v1,v2
	vse8.v	v1,0(a0)
	ret

gcc/ChangeLog:

	* config/riscv/autovec-vls.md (<optab><mode>3): Add VLS modes.
	* config/riscv/vector-iterators.md: Ditto.
	* config/riscv/vector.md: Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vls/def.h: Add basic operations.
	* gcc.target/riscv/rvv/autovec/vls/and-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/and-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/and-3.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/div-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/ior-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/ior-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/ior-3.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/max-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/min-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/minus-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/minus-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/minus-3.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/mod-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/mult-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/plus-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/plus-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/plus-3.c: New test.
2023-08-08 07:06:05 +08:00
Jonathan Wakely
bb3ceeb652 libstdc++: Fix incorrect use of abs and log10 in std::format [PR110860]
The std::formatter implementation for floating-point types uses
__builtin_abs and __builtin_log10 to avoid including all of <cmath>, but
those functions are not generic. The result of abs(2e304) is -INT_MIN
which is undefined, and then log10(INT_MIN) is NaN. As well as being
undefined, we fail to grow the buffer correctly, and then loop more
times than needed to allocate a buffer and try formatting the value into
it again.

We can use if-constexpr to choose the correct form of log10 to use for
the type, and avoid using abs entirely. This avoids the undefined
behaviour and should mean we only reallocate and retry std::to_chars
once.

libstdc++-v3/ChangeLog:

	PR libstdc++/110860
	* include/std/format (__formatter_fp::format): Do not use
	__builtin_abs and __builtin_log10 with arbitrary floating-point
	types.
2023-08-07 22:09:11 +01:00
Jonathan Wakely
c5ea5aecac libstdc++: Constrain __format::_Iter_sink for contiguous iterators [PR110917]
We can't write to a span<_CharT> if the contiguous iterator has a value
type that isn't _CharT.

libstdc++-v3/ChangeLog:

	PR libstdc++/110917
	* include/std/format (__format::_Iter_sink<CharT, OutIter>):
	Constrain partial specialization for contiguous iterators to
	require the value type to be CharT.
	* testsuite/std/format/functions/format_to.cc: New test.
2023-08-07 22:09:11 +01:00
Jonathan Wakely
f6ec0d16a3 i386: Fix grammar typo in diagnostic
gcc/ChangeLog:

	* config/i386/i386.cc (ix86_invalid_conversion): Fix grammar.
2023-08-07 22:09:11 +01:00
Jonathan Wakely
5d87f71bb4 libstdc++: Fix past-the-end increment in std::format [PR110862]
At the end of a replacement field we should check that the closing brace
is actually present before incrementing past it.

libstdc++-v3/ChangeLog:

	PR libstdc++/110862
	* include/std/format (_Scanner::_M_on_replacement_field):
	Check for expected '}' before incrementing iterator.
	* testsuite/std/format/string.cc: Check "{0:{0}" format string.
2023-08-07 22:09:10 +01:00
Indu Bhagat
eff0e7a4ae
toplevel: Makefile.def: add install-strip dependency on libsframe
As noted in PR libsframe/30014 - FTBFS: install-strip fails because
bfdlib relinks and fails to find libsframe, the install time
dependencies of libbfd need to be updated.

ChangeLog:

	* Makefile.def: Reflect that libsframe needs to installed before
	libbfd.  Reorder a bit to better track libsframe dependencies.
	* Makefile.in: Regenerate.
2023-08-07 22:59:42 +02:00
Indu Bhagat
dab58c9363
bfd: linker: merge .sframe sections
The linker merges all the input .sframe sections.  When merging, the
linker verifies that all the input .sframe sections have the same
abi/arch.

The linker uses libsframe library to perform key actions on the
.sframe sections - decode, read, and create output data.  This
implies buildsystem changes to make and install libsframe before
libbfd.

The linker places the output .sframe section in a new segment of its
own: PT_GNU_SFRAME.  A new segment is not added, however, if the
generated .sframe section is empty.

When a section is discarded from the final link, the corresponding
entries in the .sframe section for those functions are also deleted.

The linker sorts the SFrame FDEs on start address by default and sets
the SFRAME_F_FDE_SORTED flag in the .sframe section.

This patch also adds support for generation of SFrame unwind
information for the .plt* sections on x86_64.  SFrame unwind info is
generated for IBT enabled PLT, lazy/non-lazy PLT.

The existing linker option --no-ld-generated-unwind-info has been
adapted to include the control of whether .sframe unwind information
will be generated for the linker generated sections like PLT.

Changes to the linker script have been made as necessary.

ChangeLog:

	* Makefile.def: Add install dependency on libsframe for libbfd.
	* Makefile.in: Regenerated.
2023-08-07 22:59:42 +02:00
Nick Alcock
dc17ceb305
libtool.m4: augment symcode for Solaris 11
This reports common symbols like GNU nm, via a type code of 'C'.

ChangeLog:

	* libtool.m4 (lt_cv_sys_global_symbol_pipe): Augment symcode for
	Solaris 11.

gcc/ChangeLog:

	* configure: Regenerate.

libatomic/ChangeLog:

	* configure: Regenerate.

libbacktrace/ChangeLog:

	* configure: Regenerate.

libcc1/ChangeLog:

	* configure: Regenerate.

libffi/ChangeLog:

	* configure: Regenerate.

libgfortran/ChangeLog:

	* configure: Regenerate.

libgm2/ChangeLog:

	* configure: Regenerate.

libgomp/ChangeLog:

	* configure: Regenerate.

libitm/ChangeLog:

	* configure: Regenerate.

libobjc/ChangeLog:

	* configure: Regenerate.

libphobos/ChangeLog:

	* configure: Regenerate.

libquadmath/ChangeLog:

	* configure: Regenerate.

libsanitizer/ChangeLog:

	* configure: Regenerate.

libssp/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.

libvtv/ChangeLog:

	* configure: Regenerate.

lto-plugin/ChangeLog:

	* configure: Regenerate.

zlib/ChangeLog:

	* configure: Regenerate.
2023-08-07 22:59:41 +02:00
H.J. Lu
161252a840
PKG_CHECK_MODULES: Properly check if $pkg_cv_[]$1[]_LIBS works
There is no need to check $pkg_cv_[]$1[]_LIBS works if package check
failed.

config/ChangeLog:

	* pkg.m4 (PKG_CHECK_MODULES): Use AC_TRY_LINK only if
	$pkg_failed = no.
2023-08-07 22:59:41 +02:00
H.J. Lu
de9e7e9e4a
PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
It is quite normal to have headers without library on multilib OSes.
Add AC_TRY_LINK to PKG_CHECK_MODULES to check if $pkg_cv_[]$1[]_LIBS
works.

config/ChangeLog:

	* pkg.m4 (PKG_CHECK_MODULES): Add AC_TRY_LINK to check if
	$pkg_cv_[]$1[]_LIBS works.
2023-08-07 22:59:41 +02:00
John Ericson
9fc0ae6033
Deprecate a.out support for NetBSD targets.
As discussed previously, a.out support is now quite deprecated, and in
some cases removed, in both Binutils itself and NetBSD, so this legacy
default makes little sense. `netbsdelf*` and `netbsdaout*` still work
allowing the user to be explicit about there choice. Additionally, the
configure script warns about the change as Nick Clifton requested.

One possible concern was the status of NetBSD on NS32K, where only a.out
was supported. But per [1] NetBSD has removed support, and if it were to
come back, it would be with ELF. The binutils implementation is
therefore marked obsolete, per the instructions in the last message.

With that patch and this one applied, I have confirmed the following:

--target=i686-unknown-netbsd
--target=i686-unknown-netbsdelf
  builds completely

--target=i686-unknown-netbsdaout
  properly fails because target is deprecated.

--target=vax-unknown-netbsdaout builds completely except for gas, where
the target is deprecated.

[1]: https://mail-index.netbsd.org/tech-toolchain/2021/07/19/msg004025.html

config/ChangeLog:

	* picflag.m4: Simplify SHmedia NetBSD match by presuming ELF.

gcc/ChangeLog:

	* configure: Regenerate.

libada/ChangeLog:

	* configure: Regenerate.

libgcc/ChangeLog:

	* configure: Regenerate.

libiberty/ChangeLog:

	* configure: Regenerate.
2023-08-07 22:59:41 +02:00
Alan Modra
120397f396
PR27116, Spelling errors found by Debian style checker
config/ChangeLog:

	* override.m4: Correct comment grammar.
2023-08-07 22:59:40 +02:00
Alan Modra
1d6c6dc947
egrep in binutils
Apparently some distros have a nagging egrep that helpfully tells you
egrep is deprecated and to use "grep -E".  The nag message causes a ld
testsuite failure.  What's more the advice isn't that good.  The "-E"
flag may not be available with older versions of grep.

This patch fixes bare invocation of egrep within binutils, replacing
it with the autoconf $EGREP or with grep.

config/ChangeLog:

	* lib-ld.m4 (AC_LIB_PROG_LD_GNU): Require AC_PROG_EGREP and
	invoke $EGREP.
	(AC_LIB_PROG_LD): Likewise.

gcc/ChangeLog:

	* configure: Regenerate.

intl/ChangeLog:

	* configure: Regenerate.

libcpp/ChangeLog:

	* configure: Regenerate.

libgcc/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.
2023-08-07 22:59:40 +02:00
Alexander von Gluck IV
ead5103cc6
Add support for the haiku operating system
These are the os support patches we have been grooming and maintaining
for quite a few years over on git.haiku-os.org.  All of these
architectures are working and most have been stable for quite some time.

ChangeLog:

	* configure: Regenerate.
	* configure.ac: Add Haiku to list of ELF OSes
	* libtool.m4: Update sys_lib_dlsearch_path_spec on Haiku.

gcc/ChangeLog:

	* configure: Regenerate.

libatomic/ChangeLog:

	* configure: Regenerate.

libbacktrace/ChangeLog:

	* configure: Regenerate.

libcc1/ChangeLog:

	* configure: Regenerate.

libffi/ChangeLog:

	* configure: Regenerate.

libgfortran/ChangeLog:

	* configure: Regenerate.

libgm2/ChangeLog:

	* configure: Regenerate.

libgomp/ChangeLog:

	* configure: Regenerate.

libitm/ChangeLog:

	* configure: Regenerate.

libobjc/ChangeLog:

	* configure: Regenerate.

libphobos/ChangeLog:

	* configure: Regenerate.

libquadmath/ChangeLog:

	* configure: Regenerate.

libsanitizer/ChangeLog:

	* configure: Regenerate.

libssp/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.

libvtv/ChangeLog:

	* configure: Regenerate.

lto-plugin/ChangeLog:

	* configure: Regenerate.

zlib/ChangeLog:

	* configure: Regenerate.
2023-08-07 22:59:40 +02:00
Nick Alcock
f330710912
libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case
My previous nm patch handled all cases but one -- if the user set NM in
the environment to a path which contained an option, libtool's nm
detection tries to run nm against a copy of nm with the options in it:
e.g. if NM was set to "nm --blargle", and nm was found in /usr/bin, the
test would try to run "/usr/bin/nm --blargle /usr/bin/nm --blargle".
This is unlikely to be desirable: in this case we should run
"/usr/bin/nm --blargle /usr/bin/nm".

Furthermore, as part of this nm has to detect when the passed-in $NM
contains a path, and in that case avoid doing a path search itself.
This too was thrown off if an option contained something that looked
like a path, e.g. NM="nm -B../prev-gcc"; libtool then tries to run
"nm -B../prev-gcc nm" which rarely works well (and indeed it looks
to see whether that nm exists, finds it doesn't, and wrongly concludes
that nm -p or whatever does not work).

Fix all of these by clipping all options (defined as everything
including and after the first " -") before deciding whether nm
contains a path (but not using the clipped value for anything else),
and then removing all options from the path-modified nm before
looking to see whether that nm existed.

NM=my-nm now does a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM=/usr/bin/my-nm now avoids a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM="my-nm -p../wombat" now does a path search and runs e.g.
  /usr/bin/my-nm -p../wombat -B /usr/bin/my-nm

NM="../prev-binutils/new-nm -B../prev-gcc" now avoids a path search:
  ../prev-binutils/my-nm -B../prev-gcc -B ../prev-binutils/my-nm

This seems to be all combinations, including those used by GCC bootstrap
(which, before this commit, fails to bootstrap when configured
--with-build-config=bootstrap-lto, because the lto plugin is now using
--export-symbols-regex, which requires libtool to find a working nm,
while also using -B../prev-gcc to point at the lto plugin associated
with the GCC just built.)

Regenerate all affected configure scripts.

ChangeLog:

	* libtool.m4 (LT_PATH_NM): Handle user-specified NM with
	options, including options containing paths.

gcc/ChangeLog:

	* configure: Regenerate.

libatomic/ChangeLog:

	* configure: Regenerate.

libbacktrace/ChangeLog:

	* configure: Regenerate.

libcc1/ChangeLog:

	* configure: Regenerate.

libffi/ChangeLog:

	* configure: Regenerate.

libgfortran/ChangeLog:

	* configure: Regenerate.

libgm2/ChangeLog:

	* configure: Regenerate.

libgomp/ChangeLog:

	* configure: Regenerate.

libitm/ChangeLog:

	* configure: Regenerate.

libobjc/ChangeLog:

	* configure: Regenerate.

libphobos/ChangeLog:

	* configure: Regenerate.

libquadmath/ChangeLog:

	* configure: Regenerate.

libsanitizer/ChangeLog:

	* configure: Regenerate.

libssp/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.

libvtv/ChangeLog:

	* configure: Regenerate.

lto-plugin/ChangeLog:

	* configure: Regenerate.

zlib/ChangeLog:

	* configure: Regenerate.
2023-08-07 22:59:39 +02:00