Commit graph

201919 commits

Author SHA1 Message Date
Lehua Ding
4a6c44f4ad RISC-V: Fix compiler warning of riscv_arg_has_vector
Hi,

This little patch fixes a compile warning issue that my previous patch
introduced, sorry for introducing this issue.

Best,
Lehua

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_arg_has_vector): Add default
	switch handler.
2023-06-20 15:04:19 +02:00
Robin Dapp
37c167e89b RISC-V: testsuite: Fix vmul test expectation and fix -ffast-math.
I forgot to check for vfmul in the multiplication tests as well as
some -ffast-math arguments.  Fix this.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/binop/vadd-run.c: Add
	-ffast-math.
	* gcc.target/riscv/rvv/autovec/binop/vadd-zvfh-run.c: Dito.
	* gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c: Remove
	-ffast-math
	* gcc.target/riscv/rvv/autovec/binop/vmul-rv32gcv.c: Check for
	vfmul.
	* gcc.target/riscv/rvv/autovec/binop/vmul-rv64gcv.c: Dito.
2023-06-20 15:04:09 +02:00
Tobias Burnus
99e3214f58 Fortran: Fix parse-dump-tree for OpenMP ALLOCATE clause
Commit r14-1301-gd64e8e1224708e added u2.allocator to gfc_omp_namelist
for better readability and to permit to use namelist->expr for code
like the following:
  !$omp allocators allocate(align(32) : dt%alloc_comp)
    allocate (dt%alloc_comp(5))
  !$omp allocate(dt%alloc_comp2) align(64)
    allocate (dt%alloc_comp2(10))
However, for the parse-tree dump the change was incomplete.

gcc/fortran/ChangeLog:

	* dump-parse-tree.cc (show_omp_namelist): Fix dump of the allocator
	modifier of OMP_LIST_ALLOCATE.
2023-06-20 13:49:54 +02:00
Eric Botcazou
6f695bfd73 ada: Minor tweaks
gcc/ada/

	* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Pass
	the NULL_TREE explicitly and test imported_p in lieu of
	Is_Imported. <E_Function>: Remove public_flag local variable and
	make extern_flag local variable a constant.
2023-06-20 13:25:28 +02:00
Yannick Moy
c11ef75cb2 ada: Fix crash on inlining in GNATprove
After the recent change on detection of non-inlining, calls inside
the iterator part of a quantified expression were not considered
as preventing inlining anymore, leading to a crash later on inside
GNATprove. Now fixed.

gcc/ada/

	* sem_res.adb (Resolve_Call): Fix change that replaced test for
	quantified expressions by the test for potentially unevaluated
	contexts. Both should be performed.
2023-06-20 13:25:28 +02:00
Eric Botcazou
865c5db7cb ada: Further fixes to handling of private views in instances
This removes more bypasses for private views in instances that are present
in type predicates (Conforming_Types, Covers, Specific_Type and Wrong_Type),
which in exchange requires additional work in Sem_Ch12 to restore the proper
view of types during the instantiation of generic bodies.

The main mechanism for this is the Has_Private_View flag, but it comes with
the limitations that 1) there must be a direct reference to the global type
in the generic construct (either a reference to a global object of this type
or the explicit declaration of a local object of this type), which is not
always the case e.g. for loop parameters and 2) it can deal with a single
type at a time, e.g. it cannot deal with an array type and its component
type if their respective views are not the same in the instance.

To overcome the second limitation, a new Has_Secondary_Private_View flag
is introduced to deal with a secondary type, which as of this writing is
either the component type of an array type or the designated type of an
access type (together they make up the vast majority of the problematic
cases for the Has_Private_View flag alone). This new mechanism subsumes
a specific treatment for them that was added in Copy_Generic_Node a few
years ago, although a specific treatment still needs to be preserved for
comparison and equality operators in a narrower case.

Additional handling is also introduced to overcome the first limitation
for loop parameters in Copy_Generic_Node, and a relaxed condition is used
in Exp_Ch7.Convert_View to generate an unchecked conversion between views.

gcc/ada/

	* exp_ch7.adb (Convert_View): Detect more cases of mismatches for
	private types and use Implementation_Base_Type as main criterion.
	* gen_il-fields.ads (Opt_Field_Enum): Add
	Has_Secondary_Private_View
	* gen_il-gen-gen_nodes.adb (N_Expanded_Name): Likewise.
	(N_Direct_Name): Likewise.
	(N_Op): Likewise.
	* sem_ch12.ads (Check_Private_View): Document the usage of second
	flag Has_Secondary_Private_View.
	* sem_ch12.adb (Get_Associated_Entity): New function to retrieve
	the ultimate associated entity, if any.
	(Check_Private_View): Implement Has_Secondary_Private_View
	support.
	(Copy_Generic_Node): Remove specific treatment for Component_Type
	of an array type and Designated_Type of an access type. Add
	specific treatment for comparison and equality operators, as well
	as iterator and loop parameter specifications.
	(Instantiate_Type): Implement Has_Secondary_Private_View support.
	(Requires_Delayed_Save): Call Get_Associated_Entity.
	(Set_Global_Type): Implement Has_Secondary_Private_View support.
	* sem_ch6.adb (Conforming_Types): Remove bypass for private views
	in instances.
	* sem_type.adb (Covers): Return true if Is_Subtype_Of does so.
	Remove bypass for private views in instances.
	(Specific_Type): Likewise.
	* sem_util.adb (Wrong_Type): Likewise.
	* sinfo.ads (Has_Secondary_Private_View): Document new flag.
2023-06-20 13:25:28 +02:00
Ronan Desplanques
31edd39bc4 ada: Remove outdated comment
The Preelaborate pragma the removed comment was referring to was
indeed present in AI 167, as well as in clause 5.3 of the rationale
for Ada 2012, but it never made it into the 2012 version of the
reference manual.

gcc/ada/

	* libgnarl/s-mudido.ads: Remove outdated comment.
2023-06-20 13:25:28 +02:00
Tobias Burnus
0607e93490 Fortran's gfc_match_char: %S to match symbol with host_assoc
gfc_match ("... %s ...", ...) matches a gfc_symbol but with
host_assoc = 0. This commit adds '%S' as variant which matches
with host_assoc = 1

gcc/fortran/ChangeLog:

	* match.cc (gfc_match_char): Match with '%S' a symbol
	with host_assoc = 1.
2023-06-20 13:23:40 +02:00
Richard Biener
9d597e0075 Improve DSE to handle stores before __builtin_unreachable ()
DSE isn't good at identifying program points that end lifetime
of variables that are not associated with virtual operands.  But
at least for those that end basic-blocks we can handle the simple
case where this ending is in the same basic-block as the definition
we want to elide.  That should catch quite some common cases already.

	* tree-ssa-dse.cc (dse_classify_store): When we found
	no defs and the basic-block with the original definition
	ends in __builtin_unreachable[_trap] the store is dead.

	* gcc.dg/tree-ssa/ssa-dse-47.c: New testcase.
	* c-c++-common/asan/pr106558.c: Avoid undefined behavior
	due to missing return.
2023-06-20 12:48:24 +02:00
Richard Biener
85107abeb7 Update virtual SSA form manually where easily possible in phiprop
This keeps virtual SSA form up-to-date in phiprop when easily possible.
Only when we deal with aggregate copies the work would be too
heavy-handed in general.

	* tree-ssa-phiprop.cc (phiprop_insert_phi): For simple loads
	keep the virtual SSA form up-to-date.
2023-06-20 12:48:23 +02:00
Kyrylo Tkachov
63aaff9b3a aarch64: Optimise ADDP with same source operands
We've been asked to optimise the testcase in this patch of a 64-bit ADDP with
the low and high halves of the same 128-bit vector. This can be done by a
single .4s ADDP followed by just reading the bottom 64 bits. A splitter for
this is quite straightforward now that all the vec_concat stuff is collapsed
by simplify-rtx.

With this patch we generate a single:
	addp	v0.4s, v0.4s, v0.4s
instead of:
        dup     d31, v0.d[1]
        addp    v0.2s, v0.2s, v31.2s
        ret

Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (*aarch64_addp_same_reg<mode>):
	New define_insn_and_split.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/simd/addp-same-low_1.c: New test.
2023-06-20 11:03:47 +01:00
Tamar Christina
36de416df8 AArch64: remove test comment from *mov<mode>_aarch64
I accidentally left a test comment in the final version of the patch.
This removes the comment.

gcc/ChangeLog:

	* config/aarch64/aarch64.md (*mov<mode>_aarch64): Drop test comment.
2023-06-20 08:54:42 +01:00
Eric Botcazou
eb5c593cab ada: Fix couple of issues in documentation of overflow checking
There is still a mention of the defunct CHECKED mode and the Default
Settings paragraph is confusing with regard to the -gnato switch.

gcc/ada/

	* doc/gnat_ugn/gnat_and_program_execution.rst (Overflows in GNAT)
	<Default Settings>: Remove obsolete paragraph about -gnato.
	<Implementation Notes>: Replace CHECKED with STRICT.
	* gnat_ugn.texi: Regenerate.
2023-06-20 09:30:50 +02:00
Yannick Moy
8912b95779 ada: Do not issue warning on postcondition in some cases
Warning on suspicious postcondition is not relevant if contract
Exceptional_Cases is present, or if contract Always_Terminates is
present with a non-statically True value, as in those cases the
postcondition can be used to indicate constraints on those pre-state
for which the subprogram might terminate normally.

gcc/ada/

	* sem_util.adb (Check_Result_And_Post_State): Do not warn in cases
	where the warning could be spurious.
2023-06-20 09:30:50 +02:00
Yannick Moy
f1c15fe3f0 ada: Add the ability to add error codes to error messages
Add a new character sequence [] for error codes in error messages
handled by Error_Msg procedures, to use for SPARK-related errors.
Display of additional information on the error or warning based on
the error code is delegated to GNATprove.

gcc/ada/

	* err_vars.ads (Error_Msg_Code): New variable for error codes.
	* errout.adb (Error_Msg_Internal): Display continuation message
	when an error code was present.
	(Set_Msg_Text): Handle character sequence [] for error codes.
	* errout.ads: Document new insertion sequence [].
	(Error_Msg_Code): New renaming.
	* erroutc.adb (Prescan_Message): Detect presence of error code.
	(Set_Msg_Insertion_Code): Handle new insertion sequence [].
	* erroutc.ads (Has_Error_Code): New variable for prescan.
	(Set_Msg_Insertion_Code): Handle new insertion sequence [].
	* contracts.adb (Check_Type_Or_Object_External_Properties):
	Replace reference to SPARK RM section by an error code.
	* sem_elab.adb (SPARK_Processor): Same.
	* sem_prag.adb (Check_Missing_Part_Of): Same.
	* sem_res.adb (Resolve_Actuals, Resolve_Entity_Name): Same.
2023-06-20 09:30:50 +02:00
Piotr Trojanek
b367a66cfb ada: Fix for attribute Range in Exceptional_Cases
Attribute Range is now handled like First and Last when occurring within
the consequence of Exceptional_Cases, i.e. attribute Range is not
considered to be a read of a formal parameter that would not be allowed
in the contract.

gcc/ada/

	* sem_res.adb (Resolve_Entity_Name): Handle Range like First and Last.
2023-06-20 09:30:50 +02:00
Jose Ruiz
0aca9f500e ada: Document partition-wide Ada signal handlers
Indicate the signal handlers that are set by the Ada
run time, and explain how to prevent them if needed.

gcc/ada/

	* doc/gnat_ugn/the_gnat_compilation_model.rst
	(Partition-Wide Settings): add this subsection to document
	configuration settings made by the Ada run time.
	* gnat_ugn.texi: Regenerate.
2023-06-20 09:30:49 +02:00
Piotr Trojanek
86f03e37d6 ada: Fix for quantified expressions in Exceptional_Cases
When detecting illegal uses of formal parameters of the current
subprogram in contract of its Exceptional_Cases, we relied on the
Current_Scope. However, quantified expressions introduce an implicit
scope, which we need to take into account.

gcc/ada/

	* sem_res.adb (Resolve_Entity_Name): Ignore implicit loop scopes
	introduced by quantified expressions.
2023-06-20 09:30:49 +02:00
Bob Duff
970ee828e7 ada: Fix bug in predicate checks with address clauses
This patch fixes a compiler bug triggered by having a type with some
defaulted components, and a predicate, and an object of that type with
an address clause. In this case, the compiler was crashing.

gcc/ada/

	* sem_ch3.adb (Analyze_Object_Declaration): Remove predicate-check
	generation if there is an address clause. These are unnecessary,
	and cause gigi to crash.
	* exp_util.ads (Following_Address_Clause): Remove obsolete "???"
	comments. The suggested changes were done long ago.
2023-06-20 09:30:49 +02:00
Eric Botcazou
d39664b659 ada: Fix fallout of fix to handling of private views in instances
Check_Actual_Type incorrectly switches the view of a private type declared
in the enclosing scope of a generic unit but that has a private ancestor.

gcc/ada/

	* einfo.ads (Has_Private_Ancestor): Fix inaccuracy in description.
	* sem_ch12.adb (Check_Actual_Type): Do not switch the view of the
	type if it has a private ancestor.
2023-06-20 09:30:49 +02:00
Daniel King
b9b1dcc841 ada: Add CHERI intrinsic bindings and helper functions.
The package Interfaces.CHERI provides intrinsic bindings and
helper functions to allow software to query, create, and
manipulate CHERI capabilities.

gcc/ada/

	* libgnat/i-cheri.ads: Add CHERI intrinsics and helper functions.
	* libgnat/i-cheri.adb: Likewise
2023-06-20 09:30:49 +02:00
Eric Botcazou
ccacd752a4 ada: Small fixes to handling of private views in instances
The main change is the removal of the special bypass for private views in
Resolve_Implicit_Dereference, which in exchange requires additional work
in Check_Generic_Actuals and a couple more calls to Set_Global_Type in
Save_References_In_Identifier.  This also removes an unused parameter in
Convert_View and adds a missing comment in Build_Derived_Record_Type.

gcc/ada/

	* exp_ch7.adb (Convert_View): Remove Ind parameter and adjust.
	* sem_ch12.adb (Check_Generic_Actuals): Check the type of both in
	and in out actual objects, as well as the type of formal parameters
	of actual subprograms.  Extend the condition under which the views
	are swapped to nested generic constructs.
	(Save_References_In_Identifier): Call Set_Global_Type on a global
	identifier rewritten as an explicit dereference, either directly
	or after having first been rewritten as a function call.
	(Save_References_In_Operator): Set N2 unconditionally and reuse it.
	* sem_ch3.adb (Build_Derived_Record_Type): Add missing comment.
	* sem_res.adb (Resolve_Implicit_Dereference): Remove special bypass
	for private views in instances.
2023-06-20 09:30:49 +02:00
Eric Botcazou
d22792bc24 ada: Fix internal error on aggregate within container aggregate
This just applies the same fix to Expand_Array_Aggregate as the one that was
recently applied to Convert_To_Assignments.

gcc/ada/

	* exp_aggr.adb (Convert_To_Assignments): Tweak comment.
	(Expand_Array_Aggregate): Do not delay the expansion if the parent
	node is a container aggregate.
2023-06-20 09:30:49 +02:00
Ghjuvan Lacambre
3404e481d0 ada: Fix -fdiagnostics-format=json not printing all messages
The previous version of this code stopped printing messages as soon as
it encountered a deleted or continuation message. This was wrong,
continuation and deleted messages can be followed by live messages that
do need to be printed.

gcc/ada/

	* errout.adb (Output_Messages): Fix loop termination condition.
2023-06-20 09:30:49 +02:00
Eric Botcazou
298a486c58 ada: Introduce -gnateH switch to force reverse Bit_Order threshold to 64
This can be helpful for legacy code that still makes use of an original
reverse Bit_Order clause, i.e. without a Scalar_Storage_Order clause.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler
	Switches): Document -gnateH.
	* opt.ads (Reverse_Bit_Order_Threshold): New variable.
	* sem_ch13.adb (Adjust_Record_For_Reverse_Bit_Order): Use its value
	if it is nonnegative instead of System_Max_Integer_Size.
	* switch-c.adb (Scan_Front_End_Switches): Deal with -gnateH.
	* usage.adb (Usage): Print -gnateH.
	* gnat_ugn.texi: Regenerate.
2023-06-20 09:30:48 +02:00
Yannick Moy
adc853f066 ada: Update annotations in runtime for proof
With bump of stable SPARK used for proof of the runtime,
some annotations need to change.

gcc/ada/

	* libgnat/s-aridou.adb (Scaled_Divide): Add assertions.
	* libgnat/s-valuti.adb: Add Loop_Variant.
	* libgnat/s-valuti.ads: Add Exceptional_Cases on No_Return
	procedure.
2023-06-20 09:30:48 +02:00
Marc Poulhiès
ca27b8a030 ada: Fix type derivation of subtype of derived type
Deriving from a subtype of a derived type of a private type, whose full
view is itself a derived type of a discriminated record with a known
discriminatant was failing with the error message:

  invalid constraint: type has no discriminant

The compiler needs to use the full view to be able to constrain the
type.

Also fix minor typo in comments.

gcc/ada/

	* sem_ch3.adb (Build_Derived_Record_Type): Use full view as
	Parent_Base if needed.
2023-06-20 09:30:48 +02:00
Ghjuvan Lacambre
2071134b54 ada: Pass Error_Node to calls to Error_Msg in lib-load.adb
When not passing Error_Node, Error_Msg will treat Current_Node as the
node attached to the message. When this happens in lib-load.adb due to a
file that cannot be loaded, Current_Node might reference a node that
doesn't actually exist. This is a problem when using -gnatdJ and
-fdiagnostics-format, as in this case GNAT will attempt to retrieve
information from the node attached to the message and thus crash when
said node is invalid.

gcc/ada/

	* lib-load.adb (Load_Unit): Pass Error_Node to calls to Error_Msg.
2023-06-20 09:30:48 +02:00
Claire Dross
b1c3d01619 ada: Remove references to Might_Not_Return and Always_Return
The Might_Not_Return and Always_Return annotations for GNATprove
should now be replaced by the two more precise aspects
Exceptional_Cases and Always_Terminates.
They allow to specify whether a subprogram is allowed to raise
exceptions or fail to complete.

gcc/ada/

	* libgnat/a-strfix.ads: Replace Might_Not_Return annotations by
	Exceptional_Cases and Always_Terminates aspects.
	* libgnat/a-tideio.ads: Idem.
	* libgnat/a-tienio.ads: Idem.
	* libgnat/a-tifiio.ads: Idem.
	* libgnat/a-tiflio.ads: Idem.
	* libgnat/a-tiinio.ads: Idem.
	* libgnat/a-timoio.ads: Idem.
	* libgnat/a-textio.ads: Idem. Also mark functions Name, Col, Line,
	and Page as out of SPARK as they might raise Layout_Error.
	* libgnarl/a-reatim.ads: Replace Always_Return annotations by
	Always_Terminates aspects.
	* libgnat/a-chahan.ads: Idem.
	* libgnat/a-nbnbig.ads: Idem.
	* libgnat/a-nbnbin.ads: Idem.
	* libgnat/a-nbnbre.ads: Idem.
	* libgnat/a-ngelfu.ads: Idem.
	* libgnat/a-nlelfu.ads: Idem.
	* libgnat/a-nllefu.ads: Idem.
	* libgnat/a-nselfu.ads: Idem.
	* libgnat/a-nuelfu.ads: Idem.
	* libgnat/a-strbou.ads: Idem.
	* libgnat/a-strmap.ads: Idem.
	* libgnat/a-strsea.ads: Idem.
	* libgnat/a-strsup.ads: Idem.
	* libgnat/a-strunb.ads: Idem.
	* libgnat/a-strunb__shared.ads: Idem.
	* libgnat/g-souinf.ads: Idem.
	* libgnat/i-c.ads: Idem.
	* libgnat/interfac.ads: Idem.
	* libgnat/interfac__2020.ads: Idem.
	* libgnat/s-aridou.adb: Idem.
	* libgnat/s-arit32.adb: Idem.
	* libgnat/s-atacco.ads: Idem.
	* libgnat/s-spcuop.ads: Idem.
	* libgnat/s-stoele.ads: Idem.
	* libgnat/s-vaispe.ads: Idem.
	* libgnat/s-vauspe.ads: Idem.
	* libgnat/i-cstrin.ads: Add a precondition instead of a
	Might_Not_Return annotation.
2023-06-20 09:30:48 +02:00
Javier Miranda
862f84b4a3 ada: Spurious error on package instantiation
The compiler reports spurious errors processing the instantation
of a generic package when the instantation is performed in the
the body of a package that has a private type T, a dispatching
primitive of T has the same name as a component of T, and
an extension of T is used as the actual parameter for a
formal derived type of T in the instantiation.

gcc/ada/

	* sem_ch4.adb
	(Try_Selected_Component_In_Instance): New subprogram; factorizes
	existing code.
	(Find_Component_In_Instance) Moved inside the new subprogram.
	(Analyze_Selected_Component): Invoke the new subprogram before
	trying the Object.Operation notation.
2023-06-20 09:30:48 +02:00
Ronan Desplanques
869216ec14 ada: Fix edge case in Ada.Calendar.Formatting.Time_Of
Before this patch, Ada.Calendar.Formatting.Time_Of executed extra code
when passed a number of seconds equal to the number of seconds in a day.
This caused the result to be off, perhaps because a statement resetting
the number of seconds to zero was missing.

Instead of adding such a statement, this patch removes the special
handling of the problematic case, which gives the intended result.

gcc/ada/

	* libgnat/a-calfor.adb (Time_Of): Fix handling of special case.
2023-06-20 09:30:48 +02:00
Jan Beulich
d3a21558fd x86: correct and improve "*vec_dupv2di"
The input constraint for the %vmovddup alternative was wrong, as the
upper 16 XMM registers require AVX512VL to be used with this insn. To
compensate, introduce a new alternative permitting all 32 registers, by
broadcasting to the full 512 bits in that case if AVX512VL is not
available.

gcc/

	* config/i386/sse.md (vec_dupv2di): Correct %vmovddup input
	constraint. Add new AVX512F alternative.

gcc/testsuite/

	* gcc.target/i386/avx512f-dupv2di.c: New test.
2023-06-20 09:05:48 +02:00
Richard Biener
963f87f8a6 debug/110295 - mixed up early/late debug for member DIEs
When we process a scope typedef during early debug creation and
we have already created a DIE for the type when the decl is
TYPE_DECL_IS_STUB and this DIE is still in limbo we end up
just re-parenting that type DIE instead of properly creating
a DIE for the decl, eventually picking up the now completed
type and creating DIEs for the members.  Instead this is currently
defered to the second time we come here, when we annotate the
DIEs with locations late where now the type DIE is no longer
in limbo and we fall through doing the job for the decl.

The following makes sure we perform the necessary early tasks
for this by continuing with the decl DIE creation after setting
a parent for the limbo type DIE.

	PR debug/110295
	* dwarf2out.cc (process_scope_var): Continue processing
	the decl after setting a parent in case the existing DIE
	was in limbo.

	* g++.dg/debug/pr110295.C: New testcase.
2023-06-20 08:59:20 +02:00
Juzhe-Zhong
62514099cb RISC-V: Fix fails of testcases
FAIL: gcc.target/riscv/rvv/autovec/vls-vlmax/vec_extract-run.c -std=c99 -O3 -ftree-vectorize --param riscv-autovec-preference=fixed-vlmax (test for excess errors)
Excess errors:
xgcc: fatal error: Cannot find suitable multilib set for '-march=rv64imafdcv_zicsr_zifencei_zve32f_zve32x_zve64d_zve64f_zve64x_zvl128b_zvl32b_zvl64b'/'-mabi=lp64d'
compilation terminated.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_extract-run.c: Fix fail.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_extract-zvfh-run.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_set-run.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/vec_set-zvfh-run.c: Ditto.
2023-06-20 09:17:03 +08:00
Lehua Ding
1d2308d685 RISC-V: Add tuple vector mode psABI checking and simplify code
Hi,

This patch does several things:
  1. Adds the missed checking of tuple vector mode
  2. Extend the scope of checking to all vector types, previously it
     was only for scalable vector types.
  3. Simplify the logic of determining code of vector type which will lower to
     vector tmode  code

Best,
Lehua

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_scalable_vector_type_p): Delete.
	(riscv_arg_has_vector): Simplify.
	(riscv_pass_in_vector_p): Adjust warning message.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/fixed-vlmax-1.c: Add -Wno-psabi option.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-4.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-5.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-6.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-7.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-4.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-5.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-6.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-7.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-4.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-5.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-6.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-7.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm_run-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm_run-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm_run-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm_run-4.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm_run-5.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm_run-6.c: Ditto.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm_run-7.c: Ditto.
	* gcc.target/riscv/rvv/base/pr110119-1.c: Ditto.
	* gcc.target/riscv/rvv/base/pr110119-2.c: Ditto.
	* gcc.target/riscv/vector-abi-1.c: Ditto.
	* gcc.target/riscv/vector-abi-2.c: Ditto.
	* gcc.target/riscv/vector-abi-3.c: Ditto.
	* gcc.target/riscv/vector-abi-4.c: Ditto.
	* gcc.target/riscv/vector-abi-5.c: Ditto.
	* gcc.target/riscv/vector-abi-6.c: Ditto.
	* gcc.target/riscv/vector-abi-7.c: New test.
	* gcc.target/riscv/vector-abi-8.c: New test.
	* gcc.target/riscv/vector-abi-9.c: New test.
2023-06-20 09:15:11 +08:00
GCC Administrator
e517d3f571 Daily bump. 2023-06-20 00:17:14 +00:00
Ben Boeckel
c1dbaa6656 libcpp: reject codepoints above 0x10FFFF
Unicode does not support such values because they are unrepresentable in
UTF-16.

libcpp/

	* charset.cc: Reject encodings of codepoints above 0x10FFFF.
	UTF-16 does not support such codepoints and therefore all
	Unicode rejects such values.

Signed-off-by: Ben Boeckel <ben.boeckel@kitware.com>
2023-06-19 17:20:41 -04:00
Jin Ma
dbcbc858c7 RISC-V: Save and restore FCSR in interrupt functions to avoid program errors.
In order to avoid interrupt functions to change the FCSR, it needs to be saved
and restored at the beginning and end of the function.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_compute_frame_info): Allocate frame for FCSR.
	(riscv_for_each_saved_reg): Save and restore FCSR in interrupt functions.
	* config/riscv/riscv.md (riscv_frcsr): New patterns.
	(riscv_fscsr): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/interrupt-fcsr-1.c: New test.
	* gcc.target/riscv/interrupt-fcsr-2.c: New test.
	* gcc.target/riscv/interrupt-fcsr-3.c: New test.
2023-06-19 13:02:47 -06:00
Toru Kisuki
827b2a279f Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans
gcc/
	PR rtl-optimization/110305
	* simplify-rtx.cc (simplify_context::simplify_binary_operation_1):
	Handle HONOR_SNANS for x + 0.0.
2023-06-19 11:53:11 -06:00
Jan Hubicka
7b34cacc57 optimize std::max early
we currently produce very bad code on loops using std::vector as a stack, since
we fail to inline push_back which in turn prevents SRA and we fail to optimize
out some store-to-load pairs.

I looked into why this function is not inlined and it is inlined by clang.  We
currently estimate it to 66 instructions and inline limits are 15 at -O2 and 30
at -O3.  Clang has similar estimate, but still decides to inline at -O2.

I looked into reason why the body is so large and one problem I spotted is the
way std::max is implemented by taking and returning reference to the values.

  const T& max( const T& a, const T& b );

This makes it necessary to store the values to memory and load them later
and max is used by code computing new size of vector on resize.

We optimize this to MAX_EXPR, but only during late optimizations.  I think this
is a common enough coding pattern and we ought to make this transparent to
early opts and IPA.  The following is easist fix that simply adds phiprop pass
that turns the PHI of address values into PHI of values so later FRE can
propagate values across memory, phiopt discover the MAX_EXPR pattern and DSE
remove the memory stores.

gcc/ChangeLog:

	PR tree-optimization/109811
	PR tree-optimization/109849
	* passes.def: Add phiprop to early optimization passes.
	* tree-ssa-phiprop.cc: Allow clonning.

gcc/testsuite/ChangeLog:

	PR tree-optimization/109811
	PR tree-optimization/109849
	* gcc.dg/tree-ssa/phiprop-1.c: New test.
	* gcc.dg/tree-ssa/pr21463.c: Adjust template.
2023-06-19 18:28:17 +02:00
Tamar Christina
c72a7b8498 AArch64: convert some patterns to compact MD syntax
Hi All,

This converts some patterns in the AArch64 backend to use the new
compact syntax.

gcc/ChangeLog:

	* config/aarch64/aarch64.md (arches): Add nosimd.
	(*mov<mode>_aarch64, *movsi_aarch64, *movdi_aarch64): Rewrite to
	compact syntax.
2023-06-19 15:57:48 +01:00
Tamar Christina
957ae90406 New compact syntax for insn and insn_split in Machine Descriptions.
This patch adds support for a compact syntax for specifying constraints in
instruction patterns. Credit for the idea goes to Richard Earnshaw.

With this new syntax we want a clean break from the current limitations to make
something that is hopefully easier to use and maintain.

The idea behind this compact syntax is that often times it's quite hard to
correlate the entries in the constrains list, attributes and instruction lists.

One has to count and this often is tedious.  Additionally when changing a single
line in the insn multiple lines in a diff change, making it harder to see what's
going on.

This new syntax takes into account many of the common things that are done in MD
files.   It's also worth saying that this version is intended to deal with the
common case of a string based alternatives.   For C chunks we have some ideas
but those are not intended to be addressed here.

It's easiest to explain with an example:

normal syntax:

(define_insn_and_split "*movsi_aarch64"
  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,k,r,r,r,r, r,w, m, m,  r,  r,  r, w,r,w, w")
	(match_operand:SI 1 "aarch64_mov_operand"  " r,r,k,M,n,Usv,m,m,rZ,w,Usw,Usa,Ush,rZ,w,w,Ds"))]
  "(register_operand (operands[0], SImode)
    || aarch64_reg_or_zero (operands[1], SImode))"
  "@
   mov\\t%w0, %w1
   mov\\t%w0, %w1
   mov\\t%w0, %w1
   mov\\t%w0, %1
   #
   * return aarch64_output_sve_cnt_immediate (\"cnt\", \"%x0\", operands[1]);
   ldr\\t%w0, %1
   ldr\\t%s0, %1
   str\\t%w1, %0
   str\\t%s1, %0
   adrp\\t%x0, %A1\;ldr\\t%w0, [%x0, %L1]
   adr\\t%x0, %c1
   adrp\\t%x0, %A1
   fmov\\t%s0, %w1
   fmov\\t%w0, %s1
   fmov\\t%s0, %s1
   * return aarch64_output_scalar_simd_mov_immediate (operands[1], SImode);"
  "CONST_INT_P (operands[1]) && !aarch64_move_imm (INTVAL (operands[1]), SImode)
    && REG_P (operands[0]) && GP_REGNUM_P (REGNO (operands[0]))"
   [(const_int 0)]
   "{
       aarch64_expand_mov_immediate (operands[0], operands[1]);
       DONE;
    }"
  ;; The "mov_imm" type for CNT is just a placeholder.
  [(set_attr "type" "mov_reg,mov_reg,mov_reg,mov_imm,mov_imm,mov_imm,load_4,
		    load_4,store_4,store_4,load_4,adr,adr,f_mcr,f_mrc,fmov,neon_move")
   (set_attr "arch"   "*,*,*,*,*,sve,*,fp,*,fp,*,*,*,fp,fp,fp,simd")
   (set_attr "length" "4,4,4,4,*,  4,4, 4,4, 4,8,4,4, 4, 4, 4,   4")
]
)

New syntax:

(define_insn_and_split "*movsi_aarch64"
  [(set (match_operand:SI 0 "nonimmediate_operand")
	(match_operand:SI 1 "aarch64_mov_operand"))]
  "(register_operand (operands[0], SImode)
    || aarch64_reg_or_zero (operands[1], SImode))"
  {@ [cons: =0, 1; attrs: type, arch, length]
     [r , r  ; mov_reg  , *   , 4] mov\t%w0, %w1
     [k , r  ; mov_reg  , *   , 4] ^
     [r , k  ; mov_reg  , *   , 4] ^
     [r , M  ; mov_imm  , *   , 4] mov\t%w0, %1
     [r , n  ; mov_imm  , *   ,16] #
     /* The "mov_imm" type for CNT is just a placeholder.  */
     [r , Usv; mov_imm  , sve , 4] << aarch64_output_sve_cnt_immediate ("cnt", "%x0", operands[1]);
     [r , m  ; load_4   , *   , 4] ldr\t%w0, %1
     [w , m  ; load_4   , fp  , 4] ldr\t%s0, %1
     [m , rZ ; store_4  , *   , 4] str\t%w1, %0
     [m , w  ; store_4  , fp  , 4] str\t%s1, %0
     [r , Usw; load_4   , *   , 8] adrp\t%x0, %A1;ldr\t%w0, [%x0, %L1]
     [r , Usa; adr      , *   , 4] adr\t%x0, %c1
     [r , Ush; adr      , *   , 4] adrp\t%x0, %A1
     [w , rZ ; f_mcr    , fp  , 4] fmov\t%s0, %w1
     [r , w  ; f_mrc    , fp  , 4] fmov\t%w0, %s1
     [w , w  ; fmov     , fp  , 4] fmov\t%s0, %s1
     [w , Ds ; neon_move, simd, 4] << aarch64_output_scalar_simd_mov_immediate (operands[1], SImode);
  }
  "CONST_INT_P (operands[1]) && !aarch64_move_imm (INTVAL (operands[1]), SImode)
    && REG_P (operands[0]) && GP_REGNUM_P (REGNO (operands[0]))"
  [(const_int 0)]
  {
    aarch64_expand_mov_immediate (operands[0], operands[1]);
    DONE;
  }
)

The main syntax rules are as follows (See docs for full rules):
  - Template must start with "{@" and end with "}" to use the new syntax.
  - "{@" is followed by a layout in parentheses which is "cons:" followed by
    a list of match_operand/match_scratch IDs, then a semicolon, then the
    same for attributes ("attrs:"). Both sections are optional (so you can
    use only cons, or only attrs, or both), and cons must come before attrs
    if present.
  - Each alternative begins with any amount of whitespace.
  - Following the whitespace is a comma-separated list of constraints and/or
    attributes within brackets [], with sections separated by a semicolon.
  - Following the closing ']' is any amount of whitespace, and then the actual
    asm output.
  - Spaces are allowed in the list (they will simply be removed).
  - All alternatives should be specified: a blank list should be
    "[,,]", "[,,;,]" etc., not "[]" or "" (however genattr may segfault if
    you leave certain attributes empty, I have found).
  - The actual constraint string in the match_operand or match_scratch, and
    the attribute string in the set_attr, must be blank or an empty string
    (you can't combine the old and new syntaxes).
  - The common idion * return can be shortened by using <<.
  - Any unexpanded iterators left during processing will result in an error at
    compile time.   If for some reason <> is needed in the output then these
    must be escaped using \.
  - Within an {@ block both multiline and singleline C comments are allowed, but
    when used outside of a C block they must be the only non-whitespace blocks on
    the line
  - Inside an {@ block any unexpanded iterators will result in a compile time
    fault instead of incorrect assembly being generated at runtime.  If the
    literal <> is needed in the output this needs to be escaped with \<\>.
  - This check is not performed inside C blocks (lines starting with *).
  - Instead of copying the previous instruction again in the next pattern, one
    can use ^ to refer to the previous asm string.

This patch works by blindly transforming the new syntax into the old syntax,
so it doesn't do extensive checking. However, it does verify that:
	- The correct number of constraints/attributes are specified.
	- You haven't mixed old and new syntax.
	- The specified operand IDs/attribute names actually exist.
	- You don't have duplicate cons

If something goes wrong, it may write invalid constraints/attributes/template
back into the rtx. But this shouldn't matter because error_at will cause the
program to fail on exit anyway.

Because this transformation occurs as early as possible (before patterns are
queued), the rest of the compiler can completely ignore the new syntax and
assume that the old syntax will always be used.

This doesn't seem to have any measurable effect on the runtime of gen*
programs.

gcc/ChangeLog:

	* gensupport.cc (class conlist, add_constraints, add_attributes,
	skip_spaces, expect_char, preprocess_compact_syntax,
	parse_section_layout, parse_section, convert_syntax): New.
	(process_rtx): Check for conversion.
	* genoutput.cc (process_template): Check for unresolved iterators.
	(class data): Add compact_syntax_p.
	(gen_insn): Use it.
	* gensupport.h (compact_syntax): New.
	(hash-set.h): Include.
	* doc/md.texi: Document it.

Co-Authored-By: Omar Tahir <Omar.Tahir2@arm.com>
2023-06-19 15:56:50 +01:00
Uros Bizjak
bd579e1c69 recog: Change return type of predicate functions from int to bool
Also change some internal variables to bool and change return type of
split_all_insns_noflow to void.

gcc/ChangeLog:

	* recog.h (check_asm_operands): Change return type from int to bool.
	(insn_invalid_p): Ditto.
	(verify_changes): Ditto.
	(apply_change_group): Ditto.
	(constrain_operands): Ditto.
	(constrain_operands_cached): Ditto.
	(validate_replace_rtx_subexp): Ditto.
	(validate_replace_rtx): Ditto.
	(validate_replace_rtx_part): Ditto.
	(validate_replace_rtx_part_nosimplify): Ditto.
	(added_clobbers_hard_reg_p): Ditto.
	(peep2_regno_dead_p): Ditto.
	(peep2_reg_dead_p): Ditto.
	(store_data_bypass_p): Ditto.
	(if_test_bypass_p): Ditto.
	* rtl.h (split_all_insns_noflow): Change
	return type from unsigned int to void.
	* genemit.cc (output_added_clobbers_hard_reg_p): Change return type
	of generated added_clobbers_hard_reg_p from int to bool and adjust
	function body accordingly.  Change "used" variable type from
	int to bool.
	* recog.cc (check_asm_operands): Change return type
	from int to bool and adjust function body accordingly.
	(insn_invalid_p): Ditto.  Change "is_asm" variable to bool.
	(verify_changes): Change return type from int to bool.
	(apply_change_group): Change return type from int to bool
	and adjust function body accordingly.
	(validate_replace_rtx_subexp): Change return type from int to bool.
	(validate_replace_rtx): Ditto.
	(validate_replace_rtx_part): Ditto.
	(validate_replace_rtx_part_nosimplify): Ditto.
	(constrain_operands_cached): Ditto.
	(constrain_operands): Ditto.  Change "lose" and "win"
	variables type from int to bool.
	(split_all_insns_noflow): Change return type from unsigned int
	to void and adjust function body accordingly.
	(peep2_regno_dead_p): Change return type from int to bool.
	(peep2_reg_dead_p): Ditto.
	(peep2_find_free_register): Change "success"
	variable type from int to bool
	(store_data_bypass_p_1): Change return type from int to bool.
	(store_data_bypass_p): Ditto.
2023-06-19 16:41:51 +02:00
Li Xu
5fad778571 RISC-V: Fix VWEXTF iterator requirement
gcc/ChangeLog:

	* config/riscv/vector-iterators.md: zvfh/zvfhmin depends on the
	Zve32f extension.
2023-06-19 22:32:35 +08:00
Pan Li
26bb67fc4d RISC-V: Bugfix for RVV widenning reduction in ZVE32/64
The rvv widdening reduction has 3 different patterns for zve128+, zve64
and zve32. They take the same iterator with different attributions.
However, we need the generated function code_for_reduc (code, mode1, mode2).
The implementation of code_for_reduc may look like below.

code_for_reduc (code, mode1, mode2)
{
  if (code == max && mode1 == VNx1HF && mode2 == VNx1HF)
    return CODE_FOR_pred_reduc_maxvnx1hfvnx16hf; // ZVE128+

  if (code == max && mode1 == VNx1HF && mode2 == VNx1HF)
    return CODE_FOR_pred_reduc_maxvnx1hfvnx8hf;  // ZVE64

  if (code == max && mode1 == VNx1HF && mode2 == VNx1HF)
    return CODE_FOR_pred_reduc_maxvnx1hfvnx4hf;  // ZVE32
}

Thus there will be a problem here. For example zve32, we will have
code_for_reduc (max, VNx1HF, VNx1HF) which will return the code of
the ZVE128+ instead of the ZVE32 logically.

This patch will merge the 3 patterns into pattern, and pass both the
input_vector and the ret_vector of code_for_reduc. For example, ZVE32
will be code_for_reduc (max, VNx1HF, VNx2HF), then the correct code of ZVE32
will be returned as expectation.

Please note both GCC 13 and 14 are impacted by this issue.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-Authored by: Juzhe-Zhong <juzhe.zhong@rivai.ai>

gcc/ChangeLog:

	PR target/110299
	* config/riscv/riscv-vector-builtins-bases.cc: Adjust expand for
	modes.
	* config/riscv/vector-iterators.md: Remove VWLMUL1, VWLMUL1_ZVE64,
	VWLMUL1_ZVE32, VI_ZVE64, VI_ZVE32, VWI, VWI_ZVE64, VWI_ZVE32,
	VF_ZVE63 and VF_ZVE32.
	* config/riscv/vector.md
	(@pred_widen_reduc_plus<v_su><mode><vwlmul1>): Removed.
	(@pred_widen_reduc_plus<v_su><mode><vwlmul1_zve64>): Ditto.
	(@pred_widen_reduc_plus<v_su><mode><vwlmul1_zve32>): Ditto.
	(@pred_widen_reduc_plus<order><mode><vwlmul1>): Ditto.
	(@pred_widen_reduc_plus<order><mode><vwlmul1_zve64>): Ditto.
	(@pred_widen_reduc_plus<v_su><VQI:mode><VHI_LMUL1:mode>): New pattern.
	(@pred_widen_reduc_plus<v_su><VHI:mode><VSI_LMUL1:mode>): Ditto.
	(@pred_widen_reduc_plus<v_su><VSI:mode><VDI_LMUL1:mode>): Ditto.
	(@pred_widen_reduc_plus<order><VHF:mode><VSF_LMUL1:mode>): Ditto.
	(@pred_widen_reduc_plus<order><VSF:mode><VDF_LMUL1:mode>): Ditto.

gcc/testsuite/ChangeLog:

	PR target/110299
	* gcc.target/riscv/rvv/base/pr110299-1.c: New test.
	* gcc.target/riscv/rvv/base/pr110299-1.h: New test.
	* gcc.target/riscv/rvv/base/pr110299-2.c: New test.
	* gcc.target/riscv/rvv/base/pr110299-2.h: New test.
	* gcc.target/riscv/rvv/base/pr110299-3.c: New test.
	* gcc.target/riscv/rvv/base/pr110299-3.h: New test.
	* gcc.target/riscv/rvv/base/pr110299-4.c: New test.
	* gcc.target/riscv/rvv/base/pr110299-4.h: New test.
2023-06-19 22:28:27 +08:00
Pan Li
2ba7347aba RISC-V: Bugfix for RVV float reduction in ZVE32/64
The rvv integer reduction has 3 different patterns for zve128+, zve64
and zve32. They take the same iterator with different attributions.
However, we need the generated function code_for_reduc (code, mode1, mode2).
The implementation of code_for_reduc may look like below.

code_for_reduc (code, mode1, mode2)
{
  if (code == max && mode1 == VNx1HF && mode2 == VNx1HF)
    return CODE_FOR_pred_reduc_maxvnx1hfvnx16hf; // ZVE128+

  if (code == max && mode1 == VNx1HF && mode2 == VNx1HF)
    return CODE_FOR_pred_reduc_maxvnx1hfvnx8hf;  // ZVE64

  if (code == max && mode1 == VNx1HF && mode2 == VNx1HF)
    return CODE_FOR_pred_reduc_maxvnx1hfvnx4hf;  // ZVE32
}

Thus there will be a problem here. For example zve32, we will have
code_for_reduc (max, VNx1HF, VNx1HF) which will return the code of
the ZVE128+ instead of the ZVE32 logically.

This patch will merge the 3 patterns into pattern, and pass both the
input_vector and the ret_vector of code_for_reduc. For example, ZVE32
will be code_for_reduc (max, VNx1HF, VNx2HF), then the correct code of ZVE32
will be returned as expectation.

Please note both GCC 13 and 14 are impacted by this issue.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-Authored by: Juzhe-Zhong <juzhe.zhong@rivai.ai>

gcc/ChangeLog:

	PR target/110277
	* config/riscv/riscv-vector-builtins-bases.cc: Adjust expand for
	ret_mode.
	* config/riscv/vector-iterators.md: Add VHF, VSF, VDF,
	VHF_LMUL1, VSF_LMUL1, VDF_LMUL1, and remove unused attr.
	* config/riscv/vector.md (@pred_reduc_<reduc><mode><vlmul1>): Removed.
	(@pred_reduc_<reduc><mode><vlmul1_zve64>): Ditto.
	(@pred_reduc_<reduc><mode><vlmul1_zve32>): Ditto.
	(@pred_reduc_plus<order><mode><vlmul1>): Ditto.
	(@pred_reduc_plus<order><mode><vlmul1_zve32>): Ditto.
	(@pred_reduc_plus<order><mode><vlmul1_zve64>): Ditto.
	(@pred_reduc_<reduc><VHF:mode><VHF_LMUL1:mode>): New pattern.
	(@pred_reduc_<reduc><VSF:mode><VSF_LMUL1:mode>): Ditto.
	(@pred_reduc_<reduc><VDF:mode><VDF_LMUL1:mode>): Ditto.
	(@pred_reduc_plus<order><VHF:mode><VHF_LMUL1:mode>): Ditto.
	(@pred_reduc_plus<order><VSF:mode><VSF_LMUL1:mode>): Ditto.
	(@pred_reduc_plus<order><VDF:mode><VDF_LMUL1:mode>): Ditto.

gcc/testsuite/ChangeLog:

	PR target/110277
	* gcc.target/riscv/rvv/base/pr110277-1.c: New test.
	* gcc.target/riscv/rvv/base/pr110277-1.h: New test.
	* gcc.target/riscv/rvv/base/pr110277-2.c: New test.
	* gcc.target/riscv/rvv/base/pr110277-2.h: New test.
2023-06-19 21:59:51 +08:00
Andrew Stubbs
d9d6774527 amdgcn: implement vector div and mod libfuncs
Also divmod, but only for scalar modes, for now (because there are no complex
int vectors yet).

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_expand_divmod_libfunc): New function.
	(gcn_init_libfuncs): Add div and mod functions for all modes.
	Add placeholders for divmod functions.
	(TARGET_EXPAND_DIVMOD_LIBFUNC): Define.

libgcc/ChangeLog:

	* config/gcn/lib2-divmod-di.c: Reimplement like lib2-divmod.c.
	* config/gcn/lib2-divmod.c: Likewise.
	* config/gcn/lib2-gcn.h: Add new types and prototypes for all the
	new vector libfuncs.
	* config/gcn/t-amdgcn: Add new files.
	* config/gcn/amdgcn_veclib.h: New file.
	* config/gcn/lib2-vec_divmod-di.c: New file.
	* config/gcn/lib2-vec_divmod-hi.c: New file.
	* config/gcn/lib2-vec_divmod-qi.c: New file.
	* config/gcn/lib2-vec_divmod.c: New file.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/predcom-2.c: Avoid vectors on amdgcn.
	* gcc.dg/unroll-8.c: Likewise.
	* gcc.dg/vect/slp-26.c: Change expected results on amdgdn.
	* lib/target-supports.exp
	(check_effective_target_vect_int_mod): Add amdgcn.
	(check_effective_target_divmod): Likewise.
	* gcc.target/gcn/simd-math-3-16.c: New test.
	* gcc.target/gcn/simd-math-3-2.c: New test.
	* gcc.target/gcn/simd-math-3-32.c: New test.
	* gcc.target/gcn/simd-math-3-4.c: New test.
	* gcc.target/gcn/simd-math-3-8.c: New test.
	* gcc.target/gcn/simd-math-3-char-16.c: New test.
	* gcc.target/gcn/simd-math-3-char-2.c: New test.
	* gcc.target/gcn/simd-math-3-char-32.c: New test.
	* gcc.target/gcn/simd-math-3-char-4.c: New test.
	* gcc.target/gcn/simd-math-3-char-8.c: New test.
	* gcc.target/gcn/simd-math-3-char-run-16.c: New test.
	* gcc.target/gcn/simd-math-3-char-run-2.c: New test.
	* gcc.target/gcn/simd-math-3-char-run-32.c: New test.
	* gcc.target/gcn/simd-math-3-char-run-4.c: New test.
	* gcc.target/gcn/simd-math-3-char-run-8.c: New test.
	* gcc.target/gcn/simd-math-3-char-run.c: New test.
	* gcc.target/gcn/simd-math-3-char.c: New test.
	* gcc.target/gcn/simd-math-3-long-16.c: New test.
	* gcc.target/gcn/simd-math-3-long-2.c: New test.
	* gcc.target/gcn/simd-math-3-long-32.c: New test.
	* gcc.target/gcn/simd-math-3-long-4.c: New test.
	* gcc.target/gcn/simd-math-3-long-8.c: New test.
	* gcc.target/gcn/simd-math-3-long-run-16.c: New test.
	* gcc.target/gcn/simd-math-3-long-run-2.c: New test.
	* gcc.target/gcn/simd-math-3-long-run-32.c: New test.
	* gcc.target/gcn/simd-math-3-long-run-4.c: New test.
	* gcc.target/gcn/simd-math-3-long-run-8.c: New test.
	* gcc.target/gcn/simd-math-3-long-run.c: New test.
	* gcc.target/gcn/simd-math-3-long.c: New test.
	* gcc.target/gcn/simd-math-3-run-16.c: New test.
	* gcc.target/gcn/simd-math-3-run-2.c: New test.
	* gcc.target/gcn/simd-math-3-run-32.c: New test.
	* gcc.target/gcn/simd-math-3-run-4.c: New test.
	* gcc.target/gcn/simd-math-3-run-8.c: New test.
	* gcc.target/gcn/simd-math-3-run.c: New test.
	* gcc.target/gcn/simd-math-3-short-16.c: New test.
	* gcc.target/gcn/simd-math-3-short-2.c: New test.
	* gcc.target/gcn/simd-math-3-short-32.c: New test.
	* gcc.target/gcn/simd-math-3-short-4.c: New test.
	* gcc.target/gcn/simd-math-3-short-8.c: New test.
	* gcc.target/gcn/simd-math-3-short-run-16.c: New test.
	* gcc.target/gcn/simd-math-3-short-run-2.c: New test.
	* gcc.target/gcn/simd-math-3-short-run-32.c: New test.
	* gcc.target/gcn/simd-math-3-short-run-4.c: New test.
	* gcc.target/gcn/simd-math-3-short-run-8.c: New test.
	* gcc.target/gcn/simd-math-3-short-run.c: New test.
	* gcc.target/gcn/simd-math-3-short.c: New test.
	* gcc.target/gcn/simd-math-3.c: New test.
	* gcc.target/gcn/simd-math-4-char-run.c: New test.
	* gcc.target/gcn/simd-math-4-char.c: New test.
	* gcc.target/gcn/simd-math-4-long-run.c: New test.
	* gcc.target/gcn/simd-math-4-long.c: New test.
	* gcc.target/gcn/simd-math-4-run.c: New test.
	* gcc.target/gcn/simd-math-4-short-run.c: New test.
	* gcc.target/gcn/simd-math-4-short.c: New test.
	* gcc.target/gcn/simd-math-4.c: New test.
	* gcc.target/gcn/simd-math-5-16.c: New test.
	* gcc.target/gcn/simd-math-5-32.c: New test.
	* gcc.target/gcn/simd-math-5-4.c: New test.
	* gcc.target/gcn/simd-math-5-8.c: New test.
	* gcc.target/gcn/simd-math-5-char-16.c: New test.
	* gcc.target/gcn/simd-math-5-char-32.c: New test.
	* gcc.target/gcn/simd-math-5-char-4.c: New test.
	* gcc.target/gcn/simd-math-5-char-8.c: New test.
	* gcc.target/gcn/simd-math-5-char-run-16.c: New test.
	* gcc.target/gcn/simd-math-5-char-run-32.c: New test.
	* gcc.target/gcn/simd-math-5-char-run-4.c: New test.
	* gcc.target/gcn/simd-math-5-char-run-8.c: New test.
	* gcc.target/gcn/simd-math-5-char-run.c: New test.
	* gcc.target/gcn/simd-math-5-char.c: New test.
	* gcc.target/gcn/simd-math-5-long-16.c: New test.
	* gcc.target/gcn/simd-math-5-long-32.c: New test.
	* gcc.target/gcn/simd-math-5-long-4.c: New test.
	* gcc.target/gcn/simd-math-5-long-8.c: New test.
	* gcc.target/gcn/simd-math-5-long-run-16.c: New test.
	* gcc.target/gcn/simd-math-5-long-run-32.c: New test.
	* gcc.target/gcn/simd-math-5-long-run-4.c: New test.
	* gcc.target/gcn/simd-math-5-long-run-8.c: New test.
	* gcc.target/gcn/simd-math-5-long-run.c: New test.
	* gcc.target/gcn/simd-math-5-long.c: New test.
	* gcc.target/gcn/simd-math-5-run-16.c: New test.
	* gcc.target/gcn/simd-math-5-run-32.c: New test.
	* gcc.target/gcn/simd-math-5-run-4.c: New test.
	* gcc.target/gcn/simd-math-5-run-8.c: New test.
	* gcc.target/gcn/simd-math-5-run.c: New test.
	* gcc.target/gcn/simd-math-5-short-16.c: New test.
	* gcc.target/gcn/simd-math-5-short-32.c: New test.
	* gcc.target/gcn/simd-math-5-short-4.c: New test.
	* gcc.target/gcn/simd-math-5-short-8.c: New test.
	* gcc.target/gcn/simd-math-5-short-run-16.c: New test.
	* gcc.target/gcn/simd-math-5-short-run-32.c: New test.
	* gcc.target/gcn/simd-math-5-short-run-4.c: New test.
	* gcc.target/gcn/simd-math-5-short-run-8.c: New test.
	* gcc.target/gcn/simd-math-5-short-run.c: New test.
	* gcc.target/gcn/simd-math-5-short.c: New test.
	* gcc.target/gcn/simd-math-5.c: New test.
2023-06-19 12:35:35 +01:00
Andrew Stubbs
1ff8ba48a2 amdgcn: Delete inactive libfuncs
The HImode libfuncs weren't called and trying to enable them fails because
TARGET_PROMOTE_FUNCTION_MODE wants to widen the arguments but the signedness
isn't known.

libgcc/ChangeLog:

	* config/gcn/lib2-gcn.h (QItype, UQItype, HItype, UHItype): Delete.
	(__divhi3, __modhi3, __udivhi3, __umodhi3): Delete.
	* config/gcn/t-amdgcn: Don't build lib2-divmod-hi.c.
	* config/gcn/lib2-divmod-hi.c: Removed.
2023-06-19 12:35:34 +01:00
Andrew Stubbs
1f97a0b412 vect: vectorize via libfuncs
This patch allows vectorization when the libfuncs are defined.

gcc/ChangeLog:

	* tree-vect-generic.cc: Include optabs-libfuncs.h.
	(get_compute_type): Check optab_libfunc.
	* tree-vect-stmts.cc: Include optabs-libfuncs.h.
	(vectorizable_operation): Check optab_libfunc.
2023-06-19 12:35:34 +01:00
Andrew Stubbs
8aeabd9f63 amdgcn: minimal V64TImode vector support
Just enough support for TImode vectors to exist, load, store, move,
without any real instructions available.

This is primarily for the use of divmodv64di4, which uses TImode to
return a pair of DImode values.

gcc/ChangeLog:

	* config/gcn/gcn-protos.h (vgpr_4reg_mode_p): New function.
	* config/gcn/gcn-valu.md (V_4REG, V_4REG_ALT): New iterators.
	(V_MOV, V_MOV_ALT): Likewise.
	(scalar_mode, SCALAR_MODE): Add TImode.
	(vnsi, VnSI, vndi, VnDI): Likewise.
	(vec_merge, vec_merge_with_clobber, vec_merge_with_vcc): Use V_MOV.
	(mov<mode>, mov<mode>_unspec): Use V_MOV.
	(*mov<mode>_4reg): New insn.
	(mov<mode>_exec): New 4reg variant.
	(mov<mode>_sgprbase): Likewise.
	(reload_in<mode>, reload_out<mode>): Use V_MOV.
	(vec_set<mode>): Likewise.
	(vec_duplicate<mode><exec>): New 4reg variant.
	(vec_extract<mode><scalar_mode>): Likewise.
	(vec_extract<V_ALL:mode><V_ALL_ALT:mode>): Rename to ...
	(vec_extract<V_MOV:mode><V_MOV_ALT:mode>): ... this, and use V_MOV.
	(vec_extract<V_4REG:mode><V_4REG_ALT:mode>_nop): New 4reg variant.
	(fold_extract_last_<mode>): Use V_MOV.
	(vec_init<V_ALL:mode><V_ALL_ALT:mode>): Rename to ...
	(vec_init<V_MOV:mode><V_MOV_ALT:mode>): ... this, and use V_MOV.
	(gather_load<mode><vnsi>, gather<mode>_expr<exec>,
	gather<mode>_insn_1offset<exec>, gather<mode>_insn_1offset_ds<exec>,
	gather<mode>_insn_2offsets<exec>): Use V_MOV.
	(scatter_store<mode><vnsi>, scatter<mode>_expr<exec_scatter>,
	scatter<mode>_insn_1offset<exec_scatter>,
	scatter<mode>_insn_1offset_ds<exec_scatter>,
	scatter<mode>_insn_2offsets<exec_scatter>): Likewise.
	(maskload<mode>di, maskstore<mode>di, mask_gather_load<mode><vnsi>,
	mask_scatter_store<mode><vnsi>): Likewise.
	* config/gcn/gcn.cc (gcn_class_max_nregs): Use vgpr_4reg_mode_p.
	(gcn_hard_regno_mode_ok): Likewise.
	(GEN_VNM): Add TImode support.
	(USE_TI): New macro. Separate TImode operations from non-TImode ones.
	(gcn_vector_mode_supported_p): Add V64TImode, V32TImode, V16TImode,
	V8TImode, and V2TImode.
	(print_operand):  Add 'J' and 'K' print codes.
2023-06-19 12:35:34 +01:00