Commit graph

199255 commits

Author SHA1 Message Date
Jason Merrill
4f181f9c7e c++: static lambda tsubst [PR108526]
A missed piece of the patch for static operator(): in tsubst_function_decl,
we don't want to replace the first parameter with a new closure pointer if
operator() is static.

	PR c++/108526
	PR c++/106651

gcc/cp/ChangeLog:

	* pt.cc (tsubst_function_decl): Don't replace the closure
	parameter if DECL_STATIC_FUNCTION_P.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/static-operator-call5.C: Pass -g.
2023-03-07 14:34:10 -05:00
Jakub Jelinek
f875857e00 libstdc++: Some baseline_symbols.txt updates
This updates baseline_symbols.txt for the Fedora 39 arches.
Most of the added symbols are added to all 5 files, exceptions are
DF16_ rtti stuff (only added on x86 and aarch64 which supports those),
DF16b rtti stuff (only x86 right now), _M_replace_cold (m vs. j
differences), DF128_ charconv (only x86), GLIBCXX_LDBL_3.4.31
symver (s390x), _M_get_sys_info/_M_get_local_info (l vs. x).
I was using
grep ^+ | sed 's/OBJECT:[0-9]*:/OBJECT:/' | sort | uniq -c | sort -n | less
on the patch to analyze.
powerpc64le-linux not included because I'll need to regenerate it.

2023-03-07  Jakub Jelinek  <jakub@redhat.com>

	* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Update.
	* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Update.
2023-03-07 18:57:41 +01:00
Jonathan Wakely
7d30593c38 libstdc++: Fix symver for __gnu_cxx11_ieee128::__try_use_facet [PR108882]
libstdc++-v3/ChangeLog:

	PR libstdc++/108882
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Adjust patterns to
	not match symbols in namespace std::__gnu_cxx11_ieee128.
	* config/os/gnu-linux/ldbl-ieee128-extra.ver: Add patterns for
	std::__gnu_cxx11_ieee128::money_{get,put}.
2023-03-07 17:33:28 +00:00
Jonathan Wakely
291c130ef0 libstdc++: Fix comment typo in eh_personality.cc
libstdc++-v3/ChangeLog:

	* libsupc++/eh_personality.cc: Fix spelling in comment.
2023-03-07 17:33:28 +00:00
Marek Polacek
80f0052b39 c++: -Wdangling-reference with reference wrapper [PR107532]
Here, -Wdangling-reference triggers where it probably shouldn't, causing
some grief.  The code in question uses a reference wrapper with a member
function returning a reference to a subobject of a non-temporary object:

  const Plane & meta = fm.planes().inner();

I've tried a few approaches, e.g., checking that the member function's
return type is the same as the type of the enclosing class (which is
the case for member functions returning *this), but that then breaks
Wdangling-reference4.C with std::optional<std::string>.

This patch adjusts do_warn_dangling_reference so that we look through
reference wrapper classes (meaning, has a reference member and a
constructor taking the same reference type, or is std::reference_wrapper
or std::ranges::ref_view) and don't warn for them, supposing that the
member function returns a reference to a non-temporary object.

	PR c++/107532

gcc/cp/ChangeLog:

	* call.cc (reference_like_class_p): New.
	(do_warn_dangling_reference): Add new bool parameter.  See through
	reference_like_class_p.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wdangling-reference8.C: New test.
	* g++.dg/warn/Wdangling-reference9.C: New test.
2023-03-07 11:05:30 -05:00
Robin Dapp
b2b841fa25 testsuite: Fix another syntax problem in slp-3.c
This fixes another syntax error in slp-3.c.  I missed a '{ ... }' in
order to properly exclude s390_vx.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/slp-3.c: Add '{ ... }'.
2023-03-07 16:42:56 +01:00
Jakub Jelinek
0d573c1f00 c++: Fix up ICE in emit_support_tinfo_1 [PR109042]
In my recent rtti.cc change I assumed when emitting the support tinfos
that the tinfos for the fundamental types haven't been created yet.
Normally (in libsupc++.a (fundamental_type_info.o)) that is the case,
but as can be seen on the testcase, one can violate it by using typeid
etc. in the same TU and do it before ~__fundamental_type_info ()
definition.

The following patch fixes that by popping from unemitted_tinfo_decls
only in the normal case when it is there, and treating non-NULL
DECL_INITIAL on a tinfo node as indication that emit_tinfo_decl has
processed it already.

2023-03-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/109042
	* rtti.cc (emit_support_tinfo_1): Don't assert that last
	unemitted_tinfo_decls element is tinfo, instead pop from it only in
	that case.
	* decl2.cc (c_parse_final_cleanups): Don't call emit_tinfo_decl
	for unemitted_tinfO_decls which have already non-NULL DECL_INITIAL.

	* g++.dg/rtti/pr109042.C: New test.
2023-03-07 16:28:20 +01:00
Marek Polacek
e4692319fd c++: noexcept and copy elision [PR109030]
When processing a noexcept, constructors aren't elided: build_over_call
has
	 /* It's unsafe to elide the constructor when handling
	    a noexcept-expression, it may evaluate to the wrong
	    value (c++/53025).  */
	 && (force_elide || cp_noexcept_operand == 0))
so the assert I added recently needs to be relaxed a little bit.

	PR c++/109030

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_call_expression): Relax assert.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/noexcept77.C: New test.
2023-03-07 10:13:53 -05:00
Marek Polacek
e09bc034d1 c++: error with constexpr operator() [PR107939]
Similarly to PR107938, this also started with r11-557, whereby cp_finish_decl
can call check_initializer even in a template for a constexpr initializer.

Here we are rejecting

  extern const Q q;

  template<int>
  constexpr auto p = q(0);

even though q has a constexpr operator().  It's deemed non-const by
decl_maybe_constant_var_p because even though 'q' is const it is not
of integral/enum type.

If fun is not a function pointer, we don't know if we're using it as an
lvalue or rvalue, so with this patch we pass 'any' for want_rval.  With
that, p_c_e/VAR_DECL doesn't flat out reject the underlying VAR_DECL.

	PR c++/107939

gcc/cp/ChangeLog:

	* constexpr.cc (potential_constant_expression_1) <case CALL_EXPR>: Pass
	'any' when recursing on a VAR_DECL and not a pointer to function.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/var-templ74.C: Remove dg-error.
	* g++.dg/cpp1y/var-templ77.C: New test.
2023-03-07 09:51:52 -05:00
Pan Li
247cacc9e3 RISC-V: Bugfix for rvv bool mode precision adjustment
Fix the bug of the rvv bool mode precision with the adjustment.
The bits size of vbool*_t will be adjusted to
[1, 2, 4, 8, 16, 32, 64] according to the rvv spec 1.0 isa. The
adjusted mode precison of vbool*_t will help underlying pass to
make the right decision for both the correctness and optimization.

Given below sample code:

void test_1(int8_t * restrict in, int8_t * restrict out)
{
  vbool8_t v2 = *(vbool8_t*)in;
  vbool16_t v5 = *(vbool16_t*)in;
  *(vbool16_t*)(out + 200) = v5;
  *(vbool8_t*)(out + 100) = v2;
}

Before the precision adjustment:

addi    a4,a1,100
vsetvli a5,zero,e8,m1,ta,ma
addi    a1,a1,200
vlm.v   v24,0(a0)
vsm.v   v24,0(a4)
// Need one vsetvli and vlm.v for correctness here.
vsm.v   v24,0(a1)

After the precision adjustment:

csrr    t0,vlenb
slli    t1,t0,1
csrr    a3,vlenb
sub     sp,sp,t1
slli    a4,a3,1
add     a4,a4,sp
sub     a3,a4,a3
vsetvli a5,zero,e8,m1,ta,ma
addi    a2,a1,200
vlm.v   v24,0(a0)
vsm.v   v24,0(a3)
addi    a1,a1,100
vsetvli a4,zero,e8,mf2,ta,ma
csrr    t0,vlenb
vlm.v   v25,0(a3)
vsm.v   v25,0(a2)
slli    t1,t0,1
vsetvli a5,zero,e8,m1,ta,ma
vsm.v   v24,0(a1)
add     sp,sp,t1
jr      ra

However, there may be some optimization opportunates after
the mode precision adjustment. It can be token care of in
the RISC-V backend in the underlying separted PR(s).

gcc/ChangeLog:

	PR target/108185
	PR target/108654
	* config/riscv/riscv-modes.def (ADJUST_PRECISION): Adjust VNx*BI
	modes.
	* config/riscv/riscv.cc (riscv_v_adjust_precision): New.
	* config/riscv/riscv.h (riscv_v_adjust_precision): New.
	* genmodes.cc (adj_precision): New.
	(ADJUST_PRECISION): New.
	(emit_mode_adjustments): Handle ADJUST_PRECISION.

gcc/testsuite/ChangeLog:

	PR target/108185
	PR target/108654
	* gcc.target/riscv/rvv/base/pr108185-1.c: New test.
	* gcc.target/riscv/rvv/base/pr108185-2.c: New test.
	* gcc.target/riscv/rvv/base/pr108185-3.c: New test.
	* gcc.target/riscv/rvv/base/pr108185-4.c: New test.
	* gcc.target/riscv/rvv/base/pr108185-5.c: New test.
	* gcc.target/riscv/rvv/base/pr108185-6.c: New test.
	* gcc.target/riscv/rvv/base/pr108185-7.c: New test.
	* gcc.target/riscv/rvv/base/pr108185-8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-authored-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
2023-03-07 21:35:20 +08:00
Xi Ruoyao
59a72acbcc
aarch64: testsuite: disable stack protector for tests relying on stack offset
Stack protector needs a guard value on the stack and change the stack
layout.  So we need to disable it for those tests, to avoid test failure
with --enable-default-ssp.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/shrink_wrap_1.c (dg-options): Add
	-fno-stack-protector.
	* gcc.target/aarch64/stack-check-cfa-1.c (dg-options): Add
	-fno-stack-protector.
	* gcc.target/aarch64/stack-check-cfa-2.c (dg-options): Add
	-fno-stack-protector.
	* gcc.target/aarch64/test_frame_17.c (dg-options): Add
	-fno-stack-protector.
2023-03-07 15:37:01 +08:00
Xi Ruoyao
5937cfb981
aarch64: testsuite: disable stack protector for pr104005.c
Storing stack guarding variable need one stp instruction, breaking the
scan-assembler-not pattern in the test.  Disable stack protector to
avoid a test failure with --enable-default-ssp.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pr104005.c (dg-options): Add
	-fno-stack-protector.
2023-03-07 15:37:01 +08:00
Xi Ruoyao
4c59cfc4a4
aarch64: testsuite: disable stack protector for auto-init-7.c
The test scans for "const_int 0" in the RTL dump, but stack protector
can produce more "const_int 0".  To avoid a failure with
--enable-default-ssp, disable stack protector for this.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/auto-init-7.c (dg-options): Add
	-fno-stack-protector.
2023-03-07 15:37:00 +08:00
Xi Ruoyao
2fa31207ea
aarch64: testsuite: disable stack protector for pr103147-10 tests
Stack protector influence code generation and cause function body checks
fail.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pr103147-10.c (dg-options): Add
	-fno-stack-protector.
	* g++.target/aarch64/pr103147-10.C: Likewise.
2023-03-07 15:37:00 +08:00
Xi Ruoyao
edb336cc57
aarch64: testsuite: disable stack protector for sve-pcs tests
If GCC is configured with --enable-default-ssp, the stack protector can
make many sve-pcs tests fail.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/sve/pcs/aarch64-sve-pcs.exp (sve_flags):
	Add -fno-stack-protector.
2023-03-07 15:37:00 +08:00
Xi Ruoyao
7e8a3dbbb2
aarch64: testsuite: disable PIE for fuse_adrp_add_1.c [PR70150]
In PIE, symbol "fixed_regs" is addressed via GOT.  It will break the
scan-assembler pattern and cause test failure with --enable-default-pie.

gcc/testsuite/ChangeLog:

	PR testsuite/70150
	* gcc.target/aarch64/fuse_adrp_add_1.c (dg-options): Add
	-fno-pie.
2023-03-07 15:37:00 +08:00
Xi Ruoyao
a1ccb4583d
aarch64: testsuite: disable PIE for tests with large code model [PR70150]
These tests set large code model with -mcmodel=large or target pragma for
AArch64.  But if GCC is configured with --enable-default-pie, it triggers
"sorry: unimplemented: code model large with -fpic".  Disable PIE to make
avoid the issue.

gcc/testsuite/ChangeLog:

	PR testsuite/70150
	* gcc.dg/tls/pr78796.c (dg-additional-options): Add -fno-pie
	-no-pie for aarch64-*-*.
	* gcc.target/aarch64/pr63304_1.c (dg-options): Add -fno-pie.
	* gcc.target/aarch64/pr70120-2.c (dg-options): Add -fno-pie.
	* gcc.target/aarch64/pr78733.c (dg-options): Add -fno-pie.
	* gcc.target/aarch64/pr79041-2.c (dg-options): Add -fno-pie.
	* gcc.target/aarch64/pr94530.c (dg-options): Add -fno-pie.
	* gcc.target/aarch64/pr94577.c (dg-options): Add -fno-pie.
	* gcc.target/aarch64/reload-valid-spoff.c (dg-options): Add
	-fno-pie.
2023-03-07 15:36:59 +08:00
Xi Ruoyao
f30f04b1fb
aarch64: testsuite: disable PIE for aapcs64 tests [PR70150]
If GCC is built with --enable-default-pie, a lot of aapcs64 tests fail
because relocation unsupported in PIE is used.

gcc/testsuite/ChangeLog:

	PR testsuite/70150
	* gcc.target/aarch64/aapcs64/aapcs64.exp (additional_flags):
	Add -fno-pie -no-pie.
2023-03-07 15:36:59 +08:00
Hans-Peter Nilsson
1690f928b3 testsuite: Support scanning tree-dumps
No planned usage.

	* lib/target-supports.exp (check_compile): Support scanning tree-dumps.
2023-03-07 02:27:06 +01:00
Hans-Peter Nilsson
e43f970c7f testsuite: Gate gcc.dg/plugin/must-tail-call-1.c and -2.c on tail_call
While gcc.dg/plugin/must-tail-call-2.c passes for all targets even
without this, the error message is, for a target like cris-elf that
doesn't implement sibling calls: "error: cannot tail-call: machine
description does not have a sibcall_epilogue instruction pattern"
rather than "error: cannot tail-call: callee returns a structure".
Also, it'd be confusing to exclude must-tail-call-1.c but not
must-tail-call-2.c

	* gcc.dg/plugin/must-tail-call-1.c, gcc.dg/plugin/must-tail-call-2.c:
	Gate on effective target tail_call.
2023-03-07 02:23:57 +01:00
Hans-Peter Nilsson
318c9101a3 doc: Document testsuite check_effective_target_tail_call
Spot-checked the PDF output for sanity.

	* doc/sourcebuild.texi: Document check_effective_target_tail_call.
2023-03-07 02:22:46 +01:00
Hans-Peter Nilsson
7dde02e9ef testsuite: Add tail_call effective target
The RTL "expand" dump is the first RTL dump, and it also appears to be
the earliest trace of the target having implemented sibcalls.
Including the "," in the pattern searched for, to try and avoid
possible false matches, but there doesn't appear to be any identifiers
or target names nearby so this is just belts and suspenders.  Using
"tail_call" as a shorter and more commonly used term than a derivative
of "sibling calls", and expecting only gcc folks to have heard of
"sibcalls".

	* lib/target-supports.exp (check_effective_target_tail_call): New.
2023-03-07 02:21:47 +01:00
GCC Administrator
3dd4ada437 Daily bump. 2023-03-07 00:16:44 +00:00
Hans-Peter Nilsson
1d92cd072e testsuite: Fix gcc.dg/analyzer/allocation-size-multiline-3.c
For 32-bit newlib targets (such as cris-elf and pru-elf),
that int32_t is "long int".  See other regexps in the
testsuite matching "aka (long )?int" (with single-quotes
where needed) where the pattern in
allocation-size-multiline-3.c matches plain "int".  Uses the
special syntax recently introduced for multi-line patterns.

testsuite:
	* gcc.dg/analyzer/allocation-size-multiline-3.c: Handle
	int32_t being "long int".
2023-03-07 01:14:30 +01:00
Hans-Peter Nilsson
82318c5760 testsuite: Provide means to regexp in multiline patterns
Those multi-line-patterns are literal.  Sometimes a regexp
needs to be matched.  This is a start: just three elements
are supported: "(" ")" and the compound ")?" (and on second
thought, it can be argued that "(...)" alone is not useful).
Note that Tcl "string map" is documented to have the desired
effect: a once-over but no re-recognitions of previously
replaced mapped elements.  Also, drop a doubled "containing".

testsuite:
	* lib/multiline.exp (_build_multiline_regex): Map
	"{re:" to "(", similarly ")?" from ":re?}" and the
	same without question mark.
2023-03-07 01:12:16 +01:00
Joseph Myers
dfb14cdd79 Update gcc fr.po, sv.po
* fr.po, sv.po: Update.
2023-03-06 23:56:30 +00:00
Michael Meissner
306c7b1ac3 PR target/107299: Fix build issue when long double is IEEE 128-bit
This patch updates the IEEE 128-bit types used in libgcc.

At the moment, we cannot build GCC when the target uses IEEE 128-bit long
doubles, such as building the compiler for a native Fedora 36 system.  The
build dies when it is trying to build the _mulkc3.c and _divkc3 modules.

This patch changes libgcc to use long double for the IEEE 128-bit base type if
long double is IEEE 128-bit, and it uses _Float128 otherwise.  The built-in
functions are adjusted to be the correct version based on the IEEE 128-bit base
type used.

While it is desirable to ultimately have __float128 and _Float128 use the same
internal type and mode within GCC, at present if you use the option
-mabi=ieeelongdouble, the __float128 type will use the long double type and not
the _Float128 type.  We get an internal compiler error if we combine the
signbitf128 built-in with a long double type.

I've gone through several iterations of trying to fix this within GCC, and
there are various problems that have come up.  I developed this alternative
patch that changes libgcc so that it does not tickle the issue.  I hope we can
fix the compiler at some point, but right now, this is preventing people on
Fedora 36 systems from building compilers where the default long double is IEEE
128-bit.

2023-03-06   Michael Meissner  <meissner@linux.ibm.com>

libgcc/

	PR target/107299
	* config/rs6000/_divkc3.c (COPYSIGN): Use the correct built-in based on
	whether long double is IBM or IEEE.
	(INFINITY): Likewise.
	(FABS): Likewise.
	* config/rs6000/_mulkc3.c (COPYSIGN): Likewise.
	(INFINITY): Likewise.
	* config/rs6000/quad-float128.h (TF): Remove definition.
	(TFtype): Define to be long double or _Float128.
	(TCtype): Define to be _Complex long double or _Complex _Float128.
	* libgcc2.h (TFtype): Allow machine config files to override this.
	(TCtype): Likewise.
	* soft-fp/quad.h (TFtype): Likewise.
2023-03-06 17:38:33 -05:00
Paul-Antoine Arras
553ff2524f amdgcn: Add instruction patterns for conditional min/max operations
gcc/ChangeLog:

	* config/gcn/gcn-valu.md (<expander><mode>3_exec): Add patterns for
	{s|u}{max|min} in QI, HI and DI modes.
	(<expander><mode>3): Add pattern for {s|u}{max|min} in DI mode.
	(cond_<fexpander><mode>): Add pattern for cond_f{max|min}.
	(cond_<expander><mode>): Add pattern for cond_{s|u}{max|min}.
	* config/gcn/gcn.cc (gcn_spill_class): Allow the exec register to be
	saved in SGPRs.

gcc/testsuite/ChangeLog:

	* gcc.target/gcn/cond_fmaxnm_1.c: New test.
	* gcc.target/gcn/cond_fmaxnm_1_run.c: New test.
	* gcc.target/gcn/cond_fmaxnm_2.c: New test.
	* gcc.target/gcn/cond_fmaxnm_2_run.c: New test.
	* gcc.target/gcn/cond_fmaxnm_3.c: New test.
	* gcc.target/gcn/cond_fmaxnm_3_run.c: New test.
	* gcc.target/gcn/cond_fmaxnm_4.c: New test.
	* gcc.target/gcn/cond_fmaxnm_4_run.c: New test.
	* gcc.target/gcn/cond_fmaxnm_5.c: New test.
	* gcc.target/gcn/cond_fmaxnm_5_run.c: New test.
	* gcc.target/gcn/cond_fmaxnm_6.c: New test.
	* gcc.target/gcn/cond_fmaxnm_6_run.c: New test.
	* gcc.target/gcn/cond_fmaxnm_7.c: New test.
	* gcc.target/gcn/cond_fmaxnm_7_run.c: New test.
	* gcc.target/gcn/cond_fmaxnm_8.c: New test.
	* gcc.target/gcn/cond_fmaxnm_8_run.c: New test.
	* gcc.target/gcn/cond_fminnm_1.c: New test.
	* gcc.target/gcn/cond_fminnm_1_run.c: New test.
	* gcc.target/gcn/cond_fminnm_2.c: New test.
	* gcc.target/gcn/cond_fminnm_2_run.c: New test.
	* gcc.target/gcn/cond_fminnm_3.c: New test.
	* gcc.target/gcn/cond_fminnm_3_run.c: New test.
	* gcc.target/gcn/cond_fminnm_4.c: New test.
	* gcc.target/gcn/cond_fminnm_4_run.c: New test.
	* gcc.target/gcn/cond_fminnm_5.c: New test.
	* gcc.target/gcn/cond_fminnm_5_run.c: New test.
	* gcc.target/gcn/cond_fminnm_6.c: New test.
	* gcc.target/gcn/cond_fminnm_6_run.c: New test.
	* gcc.target/gcn/cond_fminnm_7.c: New test.
	* gcc.target/gcn/cond_fminnm_7_run.c: New test.
	* gcc.target/gcn/cond_fminnm_8.c: New test.
	* gcc.target/gcn/cond_fminnm_8_run.c: New test.
	* gcc.target/gcn/cond_smax_1.c: New test.
	* gcc.target/gcn/cond_smax_1_run.c: New test.
	* gcc.target/gcn/cond_smin_1.c: New test.
	* gcc.target/gcn/cond_smin_1_run.c: New test.
	* gcc.target/gcn/cond_umax_1.c: New test.
	* gcc.target/gcn/cond_umax_1_run.c: New test.
	* gcc.target/gcn/cond_umin_1.c: New test.
	* gcc.target/gcn/cond_umin_1_run.c: New test.
	* gcc.target/gcn/smax_1.c: New test.
	* gcc.target/gcn/smax_1_run.c: New test.
	* gcc.target/gcn/smin_1.c: New test.
	* gcc.target/gcn/smin_1_run.c: New test.
	* gcc.target/gcn/umax_1.c: New test.
	* gcc.target/gcn/umax_1_run.c: New test.
	* gcc.target/gcn/umin_1.c: New test.
	* gcc.target/gcn/umin_1_run.c: New test.
2023-03-06 15:26:27 +01:00
Javier Miranda
14e5b65fd9 Fix assertion failure on VSS library
gcc/ada/
	PR ada/108858
	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): For functions with
	separate spec, if their return type was visible through a limited-
	with context clause, their extra formals were not added when the
	spec was analyzed.  Now the full view must be available, and the
	extra formals can be created and Returns_By_Ref computed.
2023-03-06 11:45:24 +01:00
Eric Botcazou
94a67e3044 Revert "Respect GNATMAKE Makefile variable" commit
It breaks cross native builds.

gcc/ada/
	PR ada/108909
	PR ada/108983
	* Make-generated.in: Do not use GNATMAKE.
	* gcc-interface/Makefile.in: Ditto.
2023-03-06 11:40:04 +01:00
Richard Biener
c1873079b0 tree-optimization/109025 - fixup double reduction detection
The following closes a gap in double reduction detection where we
in the outer loop analysis fail to verify the inner LC PHI use is
the latch definition of the inner loop PHI.  That latch definition
is used to detect that an inner loop is part of a double reduction
when later doing the inner loop analysis.

	PR tree-optimization/109025
	* tree-vect-loop.cc (vect_is_simple_reduction): Verify
	the inner LC PHI use is the inner loop PHI latch definition
	before classifying an outer PHI as double reduction.

	* gcc.dg/vect/pr109025.c: New testcase.
2023-03-06 11:26:19 +01:00
Jan Hubicka
b83acefb04 Enable scatter for generic
2023-03-06  Jan Hubicka  <hubicka@ucw.cz>

	PR target/108429
	* config/i386/x86-tune.def (X86_TUNE_USE_SCATTER_2PARTS): Enable for
	generic.
	(X86_TUNE_USE_SCATTER_4PARTS): Likewise.
	(X86_TUNE_USE_SCATTER): Likewise.
2023-03-06 11:08:26 +01:00
Xi Ruoyao
67401d4597
LoongArch: testsuite: Disable stack protector for some tests
Stack protector will affect stack layout and break the expectation of
these tests, causing test failures if GCC is configured with
--enable-default-ssp.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/prolog-opt.c (dg-options): Add
	-fno-stack-protector.
	* gcc.target/loongarch/stack-check-cfa-1.c (dg-options):
	Likewise.
	* gcc.target/loongarch/stack-check-cfa-2.c (dg-options):
	Likewise.
2023-03-06 15:56:05 +08:00
Xi Ruoyao
75eccddef5
LoongArch: Stop -mfpu from silently breaking ABI [PR109000]
In the toolchain convention, we describe -mfpu= as:

"Selects the allowed set of basic floating-point instructions and
registers. This option should not change the FP calling convention
unless it's necessary."

Though not explicitly stated, the rationale of this rule is to allow
combinations like "-mabi=lp64s -mfpu=64".  This will be useful for
running applications with LP64S/F ABI on a double-float-capable
LoongArch hardware and using a math library with LP64S/F ABI but native
double float HW instructions, for a better performance.

And now a case in Linux kernel has again proven the usefulness of this
kind of combination.  The AMDGPU DCN kernel driver needs to perform some
floating-point operation, but the entire kernel uses LP64S ABI.  So the
translation units of the AMDGPU DCN driver need to be compiled with
-mfpu=64 (the kernel lacks soft-FP routines in libgcc), but -mabi=lp64s
(or you can't link it with the other part of the kernel).

Unfortunately, currently GCC uses TARGET_{HARD,SOFT,DOUBLE}_FLOAT to
determine the floating calling convention.  This causes "-mfpu=64"
silently allow using $fa* to pass parameters and return values EVEN IF
-mabi=lp64s is used.  To make things worse, the generated object file
has SOFT-FLOAT set in the eflags field so the linker will happily link
it with other LP64S ABI object files, but obviously this will lead to
bad results at runtime.  And for now all loongarch64 CPU models (-march
settings) implies -mfpu=64 on by default, so the issue makes a single
"-mabi=lp64s" option basically broken (fortunately most projects for eg
the Linux kernel have used -msoft-float which implies both -mabi=lp64s
and -mfpu=none as we've recommended in the toolchain convention doc).

The fix is simple: use TARGET_*_FLOAT_ABI instead.

I consider this a bug fix: the behavior difference from the toolchain
convention doc is a bug, and generating object files with SOFT-FLOAT
flag but parameters/return values passed through FPRs is definitely a
bug.

Bootstrapped and regtested on loongarch64-linux-gnu.  Ok for trunk and
release/gcc-12 branch?

gcc/ChangeLog:

	PR target/109000
	* config/loongarch/loongarch.h (FP_RETURN): Use
	TARGET_*_FLOAT_ABI instead of TARGET_*_FLOAT.
	(UNITS_PER_FP_ARG): Likewise.

gcc/testsuite/ChangeLog:

	PR target/109000
	* gcc.target/loongarch/flt-abi-isa-1.c: New test.
	* gcc.target/loongarch/flt-abi-isa-2.c: New test.
	* gcc.target/loongarch/flt-abi-isa-3.c: New test.
	* gcc.target/loongarch/flt-abi-isa-4.c: New test.
2023-03-06 15:56:02 +08:00
Ian Lance Taylor
c5e77e98af libgo: revert incorrectly committed change
This directory should be changed upstream, not in the GCC repo.
2023-03-05 20:01:56 -08:00
GCC Administrator
fa9fd68930 Daily bump. 2023-03-06 00:17:04 +00:00
Harald Anlauf
6aa1f40a32 Fortran: fix CLASS attribute handling [PR106856]
gcc/fortran/ChangeLog:

	PR fortran/106856
	* class.cc (gfc_build_class_symbol): Handle update of attributes of
	existing class container.
	(gfc_find_derived_vtab): Fix several memory leaks.
	(find_intrinsic_vtab): Ditto.
	* decl.cc (attr_decl1): Manage update of symbol attributes from
	CLASS attributes.
	* primary.cc (gfc_variable_attr): OPTIONAL shall not be taken or
	updated from the class container.
	* symbol.cc (free_old_symbol): Adjust management of symbol versions
	to not prematurely free array specs while working on the declation
	of CLASS variables.

gcc/testsuite/ChangeLog:

	PR fortran/106856
	* gfortran.dg/interface_41.f90: Remove dg-pattern from valid testcase.
	* gfortran.dg/class_74.f90: New test.
	* gfortran.dg/class_75.f90: New test.

Co-authored-by: Tobias Burnus  <tobias@codesourcery.com>
2023-03-05 21:10:39 +01:00
Jakub Jelinek
ca27d765f1 testsuite: Fix up syntax error in scan-tree-dump-times target selector
On aarch64, powerpc64le and s390x-linux I'm seeing another syntax error
which didn't show up on x86_64-linux nor i686-linux:
ERROR: gcc.dg/vect/slp-perm-8.c -flto -ffat-lto-objects: error executing dg-final: syntax error in target selector "target  ! vect_load_lanes  && vect_partial_vectors_usage_1 &&  ! s390_vx"
ERROR: gcc.dg/vect/slp-perm-8.c: error executing dg-final: syntax error in target selector "target  ! vect_load_lanes  && vect_partial_vectors_usage_1 &&  ! s390_vx"

The following patch fixes that.

2023-03-05  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/vect/slp-perm-8.c: Fix up syntax error in
	scan-tree-dump-times target selector.
2023-03-05 19:08:26 +01:00
Ju-Zhe Zhong
44c918b50a RISC-V: Fix ICE for avl_single-86/avl_single-88/avl_single-90
If prop is demand of vsetvl instruction and reaching doesn't demand
AVL. We don't backward propagate since vsetvl instruction has no
side effects.

FAIL: gcc.target/riscv/rvv/vsetvl/avl_single-86.c  -Og -g  (internal
compiler error: Segmentation fault)
FAIL: gcc.target/riscv/rvv/vsetvl/avl_single-86.c  -Og -g  (test for
excess errors)
FAIL: gcc.target/riscv/rvv/vsetvl/avl_single-88.c  -Og -g  (internal
compiler error: Segmentation fault)
FAIL: gcc.target/riscv/rvv/vsetvl/avl_single-88.c  -Og -g  (test for
excess errors)
FAIL: gcc.target/riscv/rvv/vsetvl/avl_single-90.c  -Og -g  (internal
compiler error: Segmentation fault)
FAIL: gcc.target/riscv/rvv/vsetvl/avl_single-90.c  -Og -g  (test for
excess errors)

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (reg_available_p): Fix bug.
	(pass_vsetvl::backward_demand_fusion): Ditto.
2023-03-06 01:23:44 +08:00
Liao Shihua
2554d90c6c RISC-V: Implement ZKSH and ZKSED extensions
This patch supports Zksh and Zksed extension.
It includes instruction's machine description and built-in funtions.

gcc/ChangeLog:

	* config/riscv/crypto.md (riscv_sm3p0_<mode>): Add ZKSED's and ZKSH's
	instructions.
	(riscv_sm3p1_<mode>): New.
	(riscv_sm4ed_<mode>): New.
	(riscv_sm4ks_<mode>): New.
	* config/riscv/riscv-builtins.cc (AVAIL): Add ZKSED's and ZKSH's AVAIL.
	* config/riscv/riscv-scalar-crypto.def (RISCV_BUILTIN): Add ZKSED's and
	ZKSH's built-in functions.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zksed32.c: New test.
	* gcc.target/riscv/zksed64.c: New test.
	* gcc.target/riscv/zksh32.c: New test.
	* gcc.target/riscv/zksh64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
2023-03-06 01:05:10 +08:00
Liao Shihua
e6416e4323 RISC-V: Implement ZKNH extension
This patch supports Zknh extension.
It includes instruction's machine description and built-in funtions.

gcc/ChangeLog:

	* config/riscv/crypto.md (riscv_sha256sig0_<mode>): Add ZKNH's instructions.
	(riscv_sha256sig1_<mode>): New.
	(riscv_sha256sum0_<mode>): New.
	(riscv_sha256sum1_<mode>): New.
	(riscv_sha512sig0h): New.
	(riscv_sha512sig0l): New.
	(riscv_sha512sig1h): New.
	(riscv_sha512sig1l): New.
	(riscv_sha512sum0r): New.
	(riscv_sha512sum1r): New.
	(riscv_sha512sig0): New.
	(riscv_sha512sig1): New.
	(riscv_sha512sum0): New.
	(riscv_sha512sum1): New.
	* config/riscv/riscv-builtins.cc (AVAIL): And ZKNH's AVAIL.
	* config/riscv/riscv-scalar-crypto.def (RISCV_BUILTIN): And ZKNH's
	built-in functions.
	(DIRECT_BUILTIN): Add new.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zknh-sha256.c: New test.
	* gcc.target/riscv/zknh-sha512-32.c: New test.
	* gcc.target/riscv/zknh-sha512-64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
2023-03-06 01:05:08 +08:00
Liao Shihua
072c558a0f RISC-V: Implement ZKND and ZKNE extensions
This patch supports Zkne and Zknd extension.
It includes instruction's machine description and built-in funtions.

gcc/ChangeLog:

	* config/riscv/constraints.md (D03): Add constants of bs and rnum.
	(DsA): New.
	* config/riscv/crypto.md (riscv_aes32dsi): Add ZKND's and ZKNE's instructions.
	(riscv_aes32dsmi): New.
	(riscv_aes64ds): New.
	(riscv_aes64dsm): New.
	(riscv_aes64im): New.
	(riscv_aes64ks1i): New.
	(riscv_aes64ks2): New.
	(riscv_aes32esi): New.
	(riscv_aes32esmi): New.
	(riscv_aes64es): New.
	(riscv_aes64esm): New.
	* config/riscv/riscv-builtins.cc (AVAIL): Add ZKND's and ZKNE's AVAIL.
	* config/riscv/riscv-scalar-crypto.def (DIRECT_BUILTIN): Add ZKND's and
	ZKNE's built-in functions.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zknd32.c: New test.
	* gcc.target/riscv/zknd64.c: New test.
	* gcc.target/riscv/zkne32.c: New test.
	* gcc.target/riscv/zkne64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
2023-03-06 01:05:00 +08:00
Liao Shihua
2c8095109b RISC-V: Implement ZBKB, ZBKC and ZBKX extensions
This patch supports Zkbk, Zbkc and Zkbx extension.
It includes instruction's machine description and built-in funtions.
It is worth mentioning that this patch only adds instructions in Zbkb but no
longer in Zbb.
If any instructions both in Zbb and Zbkb, they will be generated by code
generator instead of built-in functions.

gcc/ChangeLog:

	* config/riscv/bitmanip.md: Add ZBKB's instructions.
	* config/riscv/riscv-builtins.cc (AVAIL): Add new.
	* config/riscv/riscv.md: Add new type for crypto instructions.
	* config/riscv/crypto.md: Add Scalar Cryptography extension's machine
	description file.
	* config/riscv/riscv-scalar-crypto.def: Add Scalar Cryptography
	extension's built-in function file.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zbkb32.c: New test.
	* gcc.target/riscv/zbkb64.c: New test.
	* gcc.target/riscv/zbkc32.c: New test.
	* gcc.target/riscv/zbkc64.c: New test.
	* gcc.target/riscv/zbkx32.c: New test.
	* gcc.target/riscv/zbkx64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
2023-03-06 01:04:56 +08:00
Liao Shihua
8945633447 RISC-V: Add prototypes for RISC-V Crypto built-in functions
This patch adds prototypes for RISC-V Crypto built-in functions.

gcc/ChangeLog:

	* config/riscv/riscv-builtins.cc (RISCV_FTYPE_NAME2): New.
	(RISCV_FTYPE_NAME3): New.
	(RISCV_ATYPE_QI): New.
	(RISCV_ATYPE_HI): New.
	(RISCV_FTYPE_ATYPES2): New.
	(RISCV_FTYPE_ATYPES3): New.
	* config/riscv/riscv-ftypes.def (2): New.
	(3): New.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
2023-03-06 01:04:53 +08:00
Vineet Gupta
7e52f4420f RISC-V: costs: miscomputed shiftadd_cost triggering synth_mult [PR/108987]
This showed up as dynamic icount regression in SPEC 531.deepsjeng with upstream
gcc (vs. gcc 12.2). gcc was resorting to synthetic multiply using shift+add(s)
even when multiply had clear cost benefit.

|00000000000133b8 <see(state_t*, int, int, int, int) [clone .constprop.0]+0x382>:
|   133b8:	srl	a3,a1,s6
|   133bc:	and	a3,a3,s5
|   133c0:	slli	a4,a3,0x9
|   133c4:	add	a4,a4,a3
|   133c6:	slli	a4,a4,0x9
|   133c8:	add	a4,a4,a3
|   133ca:	slli	a3,a4,0x1b
|   133ce:	add	a4,a4,a3

vs. gcc 12 doing something lke below.

|00000000000131c4 <see(state_t*, int, int, int, int) [clone .constprop.0]+0x35c>:
|   131c4:	ld	s1,8(sp)
|   131c6:	srl	a3,a1,s4
|   131ca:	and	a3,a3,s11
|   131ce:	mul	a3,a3,s1

Bisected this to f90cb39235 ("RISC-V: costs: support shift-and-add in
strength-reduction"). The intent was to optimize cost for
shift-add-pow2-{1,2,3} corresponding to bitmanip insns SH*ADD, but ended
up doing that for all shift values which seems to favor synthezing
multiply among others.

The bug itself is trivial, IN_RANGE() calling pow2p_hwi() which returns bool
vs. exact_log2() returning power of 2.

This fix also requires update to the test introduced by the same commit
which now generates MUL vs. synthesizing it.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_rtx_costs): Fixed IN_RANGE() to
	use exact_log2().

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zba-shNadd-07.c: f2(i*783) now generates MUL vs.
	5 insn sh1add+slli+add+slli+sub.
	* gcc.target/riscv/pr108987.c: New test.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
2023-03-05 17:27:13 +08:00
Ju-Zhe Zhong
7caa1ae5e4 RISC-V: Add RVV misc intrinsic support
Co-authored-by: kito-cheng <kito.cheng@sifive.com>

gcc/ChangeLog:

	* config/riscv/predicates.md (vector_any_register_operand): New predicate.
	* config/riscv/riscv-c.cc (riscv_check_builtin_call): New function.
	(riscv_register_pragmas): Add builtin function check call.
	* config/riscv/riscv-protos.h (RVV_VUNDEF): Adapt macro.
	(check_builtin_call): New function.
	* config/riscv/riscv-vector-builtins-bases.cc (class vundefined): New class.
	(class vreinterpret): Ditto.
	(class vlmul_ext): Ditto.
	(class vlmul_trunc): Ditto.
	(class vset): Ditto.
	(class vget): Ditto.
	(BASE): Ditto.
	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
	* config/riscv/riscv-vector-builtins-functions.def (vluxei8): Change name.
	(vluxei16): Ditto.
	(vluxei32): Ditto.
	(vluxei64): Ditto.
	(vloxei8): Ditto.
	(vloxei16): Ditto.
	(vloxei32): Ditto.
	(vloxei64): Ditto.
	(vsuxei8): Ditto.
	(vsuxei16): Ditto.
	(vsuxei32): Ditto.
	(vsuxei64): Ditto.
	(vsoxei8): Ditto.
	(vsoxei16): Ditto.
	(vsoxei32): Ditto.
	(vsoxei64): Ditto.
	(vundefined): Add new intrinsic.
	(vreinterpret): Ditto.
	(vlmul_ext): Ditto.
	(vlmul_trunc): Ditto.
	(vset): Ditto.
	(vget): Ditto.
	* config/riscv/riscv-vector-builtins-shapes.cc (struct return_mask_def): New class.
	(struct narrow_alu_def): Ditto.
	(struct reduc_alu_def): Ditto.
	(struct vundefined_def): Ditto.
	(struct misc_def): Ditto.
	(struct vset_def): Ditto.
	(struct vget_def): Ditto.
	(SHAPE): Ditto.
	* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
	* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_EEW8_INTERPRET_OPS): New def.
	(DEF_RVV_EEW16_INTERPRET_OPS): Ditto.
	(DEF_RVV_EEW32_INTERPRET_OPS): Ditto.
	(DEF_RVV_EEW64_INTERPRET_OPS): Ditto.
	(DEF_RVV_X2_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X4_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X8_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X16_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X32_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X64_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_LMUL1_OPS): Ditto.
	(DEF_RVV_LMUL2_OPS): Ditto.
	(DEF_RVV_LMUL4_OPS): Ditto.
	(vint16mf4_t): Ditto.
	(vint16mf2_t): Ditto.
	(vint16m1_t): Ditto.
	(vint16m2_t): Ditto.
	(vint16m4_t): Ditto.
	(vint16m8_t): Ditto.
	(vint32mf2_t): Ditto.
	(vint32m1_t): Ditto.
	(vint32m2_t): Ditto.
	(vint32m4_t): Ditto.
	(vint32m8_t): Ditto.
	(vint64m1_t): Ditto.
	(vint64m2_t): Ditto.
	(vint64m4_t): Ditto.
	(vint64m8_t): Ditto.
	(vuint16mf4_t): Ditto.
	(vuint16mf2_t): Ditto.
	(vuint16m1_t): Ditto.
	(vuint16m2_t): Ditto.
	(vuint16m4_t): Ditto.
	(vuint16m8_t): Ditto.
	(vuint32mf2_t): Ditto.
	(vuint32m1_t): Ditto.
	(vuint32m2_t): Ditto.
	(vuint32m4_t): Ditto.
	(vuint32m8_t): Ditto.
	(vuint64m1_t): Ditto.
	(vuint64m2_t): Ditto.
	(vuint64m4_t): Ditto.
	(vuint64m8_t): Ditto.
	(vint8mf4_t): Ditto.
	(vint8mf2_t): Ditto.
	(vint8m1_t): Ditto.
	(vint8m2_t): Ditto.
	(vint8m4_t): Ditto.
	(vint8m8_t): Ditto.
	(vuint8mf4_t): Ditto.
	(vuint8mf2_t): Ditto.
	(vuint8m1_t): Ditto.
	(vuint8m2_t): Ditto.
	(vuint8m4_t): Ditto.
	(vuint8m8_t): Ditto.
	(vint8mf8_t): Ditto.
	(vuint8mf8_t): Ditto.
	(vfloat32mf2_t): Ditto.
	(vfloat32m1_t): Ditto.
	(vfloat32m2_t): Ditto.
	(vfloat32m4_t): Ditto.
	(vfloat64m1_t): Ditto.
	(vfloat64m2_t): Ditto.
	(vfloat64m4_t): Ditto.
	* config/riscv/riscv-vector-builtins.cc (DEF_RVV_TYPE): Ditto.
	(DEF_RVV_EEW8_INTERPRET_OPS): Ditto.
	(DEF_RVV_EEW16_INTERPRET_OPS): Ditto.
	(DEF_RVV_EEW32_INTERPRET_OPS): Ditto.
	(DEF_RVV_EEW64_INTERPRET_OPS): Ditto.
	(DEF_RVV_X2_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X4_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X8_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X16_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X32_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_X64_VLMUL_EXT_OPS): Ditto.
	(DEF_RVV_LMUL1_OPS): Ditto.
	(DEF_RVV_LMUL2_OPS): Ditto.
	(DEF_RVV_LMUL4_OPS): Ditto.
	(DEF_RVV_TYPE_INDEX): Ditto.
	(required_extensions_p): Adapt for new intrinsic support/
	(get_required_extensions): New function.
	(check_required_extensions): Ditto.
	(unsigned_base_type_p): Remove.
	(rvv_arg_type_info::get_scalar_ptr_type): New function.
	(get_mode_for_bitsize): Remove.
	(rvv_arg_type_info::get_scalar_const_ptr_type): New function.
	(rvv_arg_type_info::get_base_vector_type): Ditto.
	(rvv_arg_type_info::get_function_type_index): Ditto.
	(DEF_RVV_BASE_TYPE): New def.
	(function_builder::apply_predication): New class.
	(function_expander::mask_mode): Ditto.
	(function_checker::function_checker): Ditto.
	(function_checker::report_non_ice): Ditto.
	(function_checker::report_out_of_range): Ditto.
	(function_checker::require_immediate): Ditto.
	(function_checker::require_immediate_range): Ditto.
	(function_checker::check): Ditto.
	(check_builtin_call): Ditto.
	* config/riscv/riscv-vector-builtins.def (DEF_RVV_TYPE): New def.
	(DEF_RVV_BASE_TYPE): Ditto.
	(DEF_RVV_TYPE_INDEX): Ditto.
	(vbool64_t): Ditto.
	(vbool32_t): Ditto.
	(vbool16_t): Ditto.
	(vbool8_t): Ditto.
	(vbool4_t): Ditto.
	(vbool2_t): Ditto.
	(vbool1_t): Ditto.
	(vuint8mf8_t): Ditto.
	(vuint8mf4_t): Ditto.
	(vuint8mf2_t): Ditto.
	(vuint8m1_t): Ditto.
	(vuint8m2_t): Ditto.
	(vint8m4_t): Ditto.
	(vuint8m4_t): Ditto.
	(vint8m8_t): Ditto.
	(vuint8m8_t): Ditto.
	(vint16mf4_t): Ditto.
	(vuint16mf2_t): Ditto.
	(vuint16m1_t): Ditto.
	(vuint16m2_t): Ditto.
	(vuint16m4_t): Ditto.
	(vuint16m8_t): Ditto.
	(vint32mf2_t): Ditto.
	(vuint32m1_t): Ditto.
	(vuint32m2_t): Ditto.
	(vuint32m4_t): Ditto.
	(vuint32m8_t): Ditto.
	(vuint64m1_t): Ditto.
	(vuint64m2_t): Ditto.
	(vuint64m4_t): Ditto.
	(vuint64m8_t): Ditto.
	(vfloat32mf2_t): Ditto.
	(vfloat32m1_t): Ditto.
	(vfloat32m2_t): Ditto.
	(vfloat32m4_t): Ditto.
	(vfloat32m8_t): Ditto.
	(vfloat64m1_t): Ditto.
	(vfloat64m4_t): Ditto.
	(vector): Move it def.
	(scalar): Ditto.
	(mask): Ditto.
	(signed_vector): Ditto.
	(unsigned_vector): Ditto.
	(unsigned_scalar): Ditto.
	(vector_ptr): Ditto.
	(scalar_ptr): Ditto.
	(scalar_const_ptr): Ditto.
	(void): Ditto.
	(size): Ditto.
	(ptrdiff): Ditto.
	(unsigned_long): Ditto.
	(long): Ditto.
	(eew8_index): Ditto.
	(eew16_index): Ditto.
	(eew32_index): Ditto.
	(eew64_index): Ditto.
	(shift_vector): Ditto.
	(double_trunc_vector): Ditto.
	(quad_trunc_vector): Ditto.
	(oct_trunc_vector): Ditto.
	(double_trunc_scalar): Ditto.
	(double_trunc_signed_vector): Ditto.
	(double_trunc_unsigned_vector): Ditto.
	(double_trunc_unsigned_scalar): Ditto.
	(double_trunc_float_vector): Ditto.
	(float_vector): Ditto.
	(lmul1_vector): Ditto.
	(widen_lmul1_vector): Ditto.
	(eew8_interpret): Ditto.
	(eew16_interpret): Ditto.
	(eew32_interpret): Ditto.
	(eew64_interpret): Ditto.
	(vlmul_ext_x2): Ditto.
	(vlmul_ext_x4): Ditto.
	(vlmul_ext_x8): Ditto.
	(vlmul_ext_x16): Ditto.
	(vlmul_ext_x32): Ditto.
	(vlmul_ext_x64): Ditto.
	* config/riscv/riscv-vector-builtins.h (DEF_RVV_BASE_TYPE): New def.
	(struct function_type_info): New function.
	(struct rvv_arg_type_info): Ditto.
	(class function_checker): New class.
	(rvv_arg_type_info::get_scalar_type): New function.
	(rvv_arg_type_info::get_vector_type): Ditto.
	(function_expander::ret_mode): New function.
	(function_checker::arg_mode): Ditto.
	(function_checker::ret_mode): Ditto.
	* config/riscv/t-riscv: Add generator.
	* config/riscv/vector-iterators.md: New iterators.
	* config/riscv/vector.md (vundefined<mode>): New pattern.
	(@vundefined<mode>): Ditto.
	(@vreinterpret<mode>): Ditto.
	(@vlmul_extx2<mode>): Ditto.
	(@vlmul_extx4<mode>): Ditto.
	(@vlmul_extx8<mode>): Ditto.
	(@vlmul_extx16<mode>): Ditto.
	(@vlmul_extx32<mode>): Ditto.
	(@vlmul_extx64<mode>): Ditto.
	(*vlmul_extx2<mode>): Ditto.
	(*vlmul_extx4<mode>): Ditto.
	(*vlmul_extx8<mode>): Ditto.
	(*vlmul_extx16<mode>): Ditto.
	(*vlmul_extx32<mode>): Ditto.
	(*vlmul_extx64<mode>): Ditto.
	* config/riscv/genrvv-type-indexer.cc: New file.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/vlmul_v.c: New test.

Co-authored-by: kito-cheng <kito.cheng@sifive.com>
2023-03-05 17:16:30 +08:00
Ju-Zhe Zhong
1bff101b7e RISC-V: Add permutation C/C++ support
gcc/ChangeLog:

	* config/riscv/riscv-protos.h (enum vlen_enum): New enum.
	(slide1_sew64_helper): New function.
	* config/riscv/riscv-v.cc (compute_vlmax): Ditto.
	(get_unknown_min_value): Ditto.
	(force_vector_length_operand): Ditto.
	(gen_no_side_effects_vsetvl_rtx): Ditto.
	(get_vl_x2_rtx): Ditto.
	(slide1_sew64_helper): Ditto.
	* config/riscv/riscv-vector-builtins-bases.cc (class slideop): New class.
	(class vrgather): Ditto.
	(class vrgatherei16): Ditto.
	(class vcompress): Ditto.
	(BASE): Ditto.
	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
	* config/riscv/riscv-vector-builtins-functions.def (vslideup): Ditto.
	(vslidedown): Ditto.
	(vslide1up): Ditto.
	(vslide1down): Ditto.
	(vfslide1up): Ditto.
	(vfslide1down): Ditto.
	(vrgather): Ditto.
	(vrgatherei16): Ditto.
	(vcompress): Ditto.
	* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_EI16_OPS): New macro.
	(vint8mf8_t): Ditto.
	(vint8mf4_t): Ditto.
	(vint8mf2_t): Ditto.
	(vint8m1_t): Ditto.
	(vint8m2_t): Ditto.
	(vint8m4_t): Ditto.
	(vint16mf4_t): Ditto.
	(vint16mf2_t): Ditto.
	(vint16m1_t): Ditto.
	(vint16m2_t): Ditto.
	(vint16m4_t): Ditto.
	(vint16m8_t): Ditto.
	(vint32mf2_t): Ditto.
	(vint32m1_t): Ditto.
	(vint32m2_t): Ditto.
	(vint32m4_t): Ditto.
	(vint32m8_t): Ditto.
	(vint64m1_t): Ditto.
	(vint64m2_t): Ditto.
	(vint64m4_t): Ditto.
	(vint64m8_t): Ditto.
	(vuint8mf8_t): Ditto.
	(vuint8mf4_t): Ditto.
	(vuint8mf2_t): Ditto.
	(vuint8m1_t): Ditto.
	(vuint8m2_t): Ditto.
	(vuint8m4_t): Ditto.
	(vuint16mf4_t): Ditto.
	(vuint16mf2_t): Ditto.
	(vuint16m1_t): Ditto.
	(vuint16m2_t): Ditto.
	(vuint16m4_t): Ditto.
	(vuint16m8_t): Ditto.
	(vuint32mf2_t): Ditto.
	(vuint32m1_t): Ditto.
	(vuint32m2_t): Ditto.
	(vuint32m4_t): Ditto.
	(vuint32m8_t): Ditto.
	(vuint64m1_t): Ditto.
	(vuint64m2_t): Ditto.
	(vuint64m4_t): Ditto.
	(vuint64m8_t): Ditto.
	(vfloat32mf2_t): Ditto.
	(vfloat32m1_t): Ditto.
	(vfloat32m2_t): Ditto.
	(vfloat32m4_t): Ditto.
	(vfloat32m8_t): Ditto.
	(vfloat64m1_t): Ditto.
	(vfloat64m2_t): Ditto.
	(vfloat64m4_t): Ditto.
	(vfloat64m8_t): Ditto.
	* config/riscv/riscv-vector-builtins.cc (DEF_RVV_EI16_OPS): Ditto.
	* config/riscv/riscv.md: Adjust RVV instruction types.
	* config/riscv/vector-iterators.md (down): New iterator.
	(=vd,vr): New attribute.
	(UNSPEC_VSLIDE1UP): New unspec.
	* config/riscv/vector.md (@pred_slide<ud><mode>): New pattern.
	(*pred_slide<ud><mode>): Ditto.
	(*pred_slide<ud><mode>_extended): Ditto.
	(@pred_gather<mode>): Ditto.
	(@pred_gather<mode>_scalar): Ditto.
	(@pred_gatherei16<mode>): Ditto.
	(@pred_compress<mode>): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/binop_vx_constraint-167.c: New test.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-168.c: New test.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-169.c: New test.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-170.c: New test.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-171.c: New test.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-172.c: New test.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-173.c: New test.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-174.c: New test.
2023-03-05 17:16:30 +08:00
Ju-Zhe Zhong
f8ba8a45ed RISC-V: Remove void_type_node of void_args for vsetvlmax intrinsic
This patch is to fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108927.
PR108927

gcc/ChangeLog:

	* config/riscv/riscv-vector-builtins.cc: Remove void_type_node.
2023-03-05 17:16:30 +08:00
Ju-Zhe Zhong
2a2c4c93fd RISC-V: Add testcase for VSETVL PASS
gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/scalar_move-1.c: New test.
	* gcc.target/riscv/rvv/base/scalar_move-2.c: New test.
	* gcc.target/riscv/rvv/base/scalar_move-3.c: New test.
	* gcc.target/riscv/rvv/base/scalar_move-4.c: New test.
	* gcc.target/riscv/rvv/base/scalar_move-5.c: New test.
	* gcc.target/riscv/rvv/base/scalar_move-6.c: New test.
	* gcc.target/riscv/rvv/base/scalar_move-7.c: New test.
	* gcc.target/riscv/rvv/base/scalar_move-8.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-100.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-101.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-78.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-79.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-80.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-81.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-82.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-83.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-84.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-85.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-86.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-87.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-88.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-89.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-90.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-91.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-92.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-93.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-94.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-95.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-96.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-97.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-98.c: New test.
	* gcc.target/riscv/rvv/vsetvl/avl_single-99.c: New test.
2023-03-05 17:16:30 +08:00
Ju-Zhe Zhong
ec99ffabc3 RISC-V: Add scalar move support and fix VSETVL bugs
gcc/ChangeLog:

	* config/riscv/constraints.md (Wb1): New constraint.
	* config/riscv/predicates.md
	(vector_least_significant_set_mask_operand): New predicate.
	(vector_broadcast_mask_operand): Ditto.
	* config/riscv/riscv-protos.h (enum vlmul_type): Adjust.
	(gen_scalar_move_mask): New function.
	* config/riscv/riscv-v.cc (gen_scalar_move_mask): Ditto.
	* config/riscv/riscv-vector-builtins-bases.cc (class vmv): New class.
	(class vmv_s): Ditto.
	(BASE): Ditto.
	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
	* config/riscv/riscv-vector-builtins-functions.def (vmv_x): Ditto.
	(vmv_s): Ditto.
	(vfmv_f): Ditto.
	(vfmv_s): Ditto.
	* config/riscv/riscv-vector-builtins-shapes.cc (struct scalar_move_def): Ditto.
	(SHAPE): Ditto.
	* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
	* config/riscv/riscv-vector-builtins.cc (function_expander::mask_mode): Ditto.
	(function_expander::use_exact_insn): New function.
	(function_expander::use_contiguous_load_insn): New function.
	(function_expander::use_contiguous_store_insn): New function.
	(function_expander::use_ternop_insn): New function.
	(function_expander::use_widen_ternop_insn): New function.
	(function_expander::use_scalar_move_insn): New function.
	* config/riscv/riscv-vector-builtins.def (s): New operand suffix.
	* config/riscv/riscv-vector-builtins.h
	(function_expander::add_scalar_move_mask_operand): New class.
	* config/riscv/riscv-vsetvl.cc (ignore_vlmul_insn_p): New function.
	(scalar_move_insn_p): Ditto.
	(has_vsetvl_killed_avl_p): Ditto.
	(anticipatable_occurrence_p): Ditto.
	(insert_vsetvl): Ditto.
	(get_vl_vtype_info): Ditto.
	(calculate_sew): Ditto.
	(calculate_vlmul): Ditto.
	(incompatible_avl_p): Ditto.
	(different_sew_p): Ditto.
	(different_lmul_p): Ditto.
	(different_ratio_p): Ditto.
	(different_tail_policy_p): Ditto.
	(different_mask_policy_p): Ditto.
	(possible_zero_avl_p): Ditto.
	(first_ratio_invalid_for_second_sew_p): Ditto.
	(first_ratio_invalid_for_second_lmul_p): Ditto.
	(second_ratio_invalid_for_first_sew_p): Ditto.
	(second_ratio_invalid_for_first_lmul_p): Ditto.
	(second_sew_less_than_first_sew_p): Ditto.
	(first_sew_less_than_second_sew_p): Ditto.
	(compare_lmul): Ditto.
	(second_lmul_less_than_first_lmul_p): Ditto.
	(first_lmul_less_than_second_lmul_p): Ditto.
	(first_ratio_less_than_second_ratio_p): Ditto.
	(second_ratio_less_than_first_ratio_p): Ditto.
	(DEF_INCOMPATIBLE_COND): Ditto.
	(greatest_sew): Ditto.
	(first_sew): Ditto.
	(second_sew): Ditto.
	(first_vlmul): Ditto.
	(second_vlmul): Ditto.
	(first_ratio): Ditto.
	(second_ratio): Ditto.
	(vlmul_for_first_sew_second_ratio): Ditto.
	(ratio_for_second_sew_first_vlmul): Ditto.
	(DEF_SEW_LMUL_FUSE_RULE): Ditto.
	(always_unavailable): Ditto.
	(avl_unavailable_p): Ditto.
	(sew_unavailable_p): Ditto.
	(lmul_unavailable_p): Ditto.
	(ge_sew_unavailable_p): Ditto.
	(ge_sew_lmul_unavailable_p): Ditto.
	(ge_sew_ratio_unavailable_p): Ditto.
	(DEF_UNAVAILABLE_COND): Ditto.
	(same_sew_lmul_demand_p): Ditto.
	(propagate_avl_across_demands_p): Ditto.
	(reg_available_p): Ditto.
	(avl_info::has_non_zero_avl): Ditto.
	(vl_vtype_info::has_non_zero_avl): Ditto.
	(vector_insn_info::operator>=): Refactor.
	(vector_insn_info::parse_insn): Adjust for scalar move.
	(vector_insn_info::demand_vl_vtype): Remove.
	(vector_insn_info::compatible_p): New function.
	(vector_insn_info::compatible_avl_p): Ditto.
	(vector_insn_info::compatible_vtype_p): Ditto.
	(vector_insn_info::available_p): Ditto.
	(vector_insn_info::merge): Ditto.
	(vector_insn_info::fuse_avl): Ditto.
	(vector_insn_info::fuse_sew_lmul): Ditto.
	(vector_insn_info::fuse_tail_policy): Ditto.
	(vector_insn_info::fuse_mask_policy): Ditto.
	(vector_insn_info::dump): Ditto.
	(vector_infos_manager::release): Ditto.
	(pass_vsetvl::compute_local_backward_infos): Adjust for scalar move support.
	(pass_vsetvl::get_backward_fusion_type): Adjust for scalar move support.
	(pass_vsetvl::hard_empty_block_p): Ditto.
	(pass_vsetvl::backward_demand_fusion): Ditto.
	(pass_vsetvl::forward_demand_fusion): Ditto.
	(pass_vsetvl::refine_vsetvls): Ditto.
	(pass_vsetvl::cleanup_vsetvls): Ditto.
	(pass_vsetvl::commit_vsetvls): Ditto.
	(pass_vsetvl::propagate_avl): Ditto.
	* config/riscv/riscv-vsetvl.h (enum demand_status): New class.
	(struct demands_pair): Ditto.
	(struct demands_cond): Ditto.
	(struct demands_fuse_rule): Ditto.
	* config/riscv/vector-iterators.md: New iterator.
	* config/riscv/vector.md (@pred_broadcast<mode>): New pattern.
	(*pred_broadcast<mode>): Ditto.
	(*pred_broadcast<mode>_extended_scalar): Ditto.
	(@pred_extract_first<mode>): Ditto.
	(*pred_extract_first<mode>): Ditto.
	(@pred_extract_first_trunc<mode>): Ditto.
	* config/riscv/riscv-vsetvl.def: New file.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/vsetvlmax-10.c: Adjust test.
	* gcc.target/riscv/rvv/vsetvl/vsetvlmax-11.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vsetvlmax-12.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vsetvlmax-15.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vsetvlmax-18.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vsetvlmax-9.c: Ditto.
2023-03-05 16:59:57 +08:00