[PATCH v2 07/11] Native complex ops: Vectorization of native complex operations

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Add vectors of complex types to vectorize native operations. Because of the vectorize was designed to work with scalar elements, several functions and target hooks have to be adapted or duplicated to support complex types. After that, the vectorization of native complex operations follows

[PATCH v2 05/11] Native complex ops: Add the conjugate op in optabs

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Add an optab and rtl operation for the conjugate, called conj, to expand CONJ_EXPR. gcc/ChangeLog: * rtl.def: Add a conj operation in rtl * optabs.def: Add a conj optab * optabs-tree.cc (optab_for_tree_code): use the conj_optab to convert a CONJ_EXPR

[PATCH v2 11/11] Native complex ops: Experimental support in x86 backend

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Add an experimental support for native complex operation handling in the x86 backend. For now it only support add, sub, mul, conj, neg, mov in SCmode (complex float). Performance gains are still marginal on this target because there are no particular instructions to speedup complex operati

[PATCH v2 09/11] Native complex ops: remove useless special cases

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Remove two special cases which are now useless with the new complex handling. gcc/ChangeLog: * tree-ssa-forwprop.cc (pass_forwprop::execute): Remove two special cases --- gcc/tree-ssa-forwprop.cc | 133 +-- 1 file changed, 3 insertions(+), 1

[PATCH v2 04/11] Native complex ops: Allow native complex regs and ops in rtl

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Support registers of complex types in rtl. Also adapt the functions called during the expand pass to support native complex operations. gcc/ChangeLog: * explow.cc (trunc_int_for_mode): Allow complex int modes * expr.cc (emit_move_complex_parts): Move both parts at the

[PATCH v2 10/11] Native complex ops: Add a fast complex multiplication pattern

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Add a new fast_mult_optab to define a pattern corresponding to the fast path of a IEEE compliant multiplication. Indeed, the backend programmer can change the fast path without having to handle manually the IEEE checks. gcc/ChangeLog: * internal-fn.def: Add a FAST_MULT internal f

[PATCH v2 06/11] Native complex ops: Update how complex rotations are handled

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Catch complex rotation by 90° and 270° in fold-const.cc like before, but now convert them into the new COMPLEX_ROT90 and COMPLEX_ROT270 internal functions. Also add crot90 and crot270 optabs to expose these operation the backends. So conditionnaly lower COMPLEX_ROT90/COMPLEX_ROT270 by chec

[PATCH v2 08/11] Native complex ops: Add explicit vector of complex

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Allow the creation and usage of builtins vectors of complex in C, using __attribute__ ((vector_size ())) gcc/c-family/ChangeLog: * c-attribs.cc (vector_mode_valid_p): Add cases for vectors of complex (handle_mode_attribute): Likewise (type_valid_for_vector

[PATCH v2 02/11] Native complex ops: Move functions to hooks

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Move read_complex_part and write_complex_part to target hooks. Their signature also change because of the type of argument part is now complex_part_t. Calls to theses functions are updated accordingly. gcc/ChangeLog: * target.def: Define hooks for read_complex_part and wr

[PATCH v2 03/11] Native complex ops: Add gen_rtx_complex hook

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Add a new target hook for complex element creation during the expand pass, called gen_rtx_complex. The default implementation calls gen_rtx_CONCAT like before. Then calls to gen_rtx_CONCAT for complex handling are replaced by calls to targetm.gen_rtx_complex. gcc/ChangeLog: * tar

[PATCH v2 01/11] Native complex ops : Conditional lowering

2023-09-12 Thread Sylvain Noiry via Gcc-patches
Summary: Allow the cplxlower pass to identify if an operation does not need to be lowered through optabs. In this case, lowering is not performed. The cplxlower pass now has to handle a mix of lowered and non-lowered operations. A quick access to both parts of a complex constant is also implemented

[PATCH v2 0/11] Native complex operations

2023-09-12 Thread Sylvain Noiry via Gcc-patches
I have updated the series of patches. Most changes consist of bug fixes. However 2 new patches add features: PATCH 9/11: Remove useless special cases This patch remove two special cases for complex which are now fairly enough handled by the general case. Don't hesitate to tell me if you

[PATCH 9/9] Native complex operation: Experimental support in x86 backend

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Add an experimental support for native complex operation handling in the x86 backend. For now it only support add, sub, mul, conj, neg, mov in SCmode (complex float). Performance gains are still marginal on this target because there are no particular instructions to speedup complex operation, excep

[PATCH 7/9] Native complex operations: Vectorization of native complex operations

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Add vectors of complex types to vectorize native operations. Because of the vectorize was designed to work with scalar elements, several functions and target hooks have to be adapted or duplicated to support complex types. After that, the vectorization of native complex operations follows exactly t

[PATCH 5/9] Native complex operations: Add the conjugate op in optabs

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Add an optab and rtl operation for the conjugate, called conj, to expand CONJ_EXPR. gcc/ChangeLog: * rtl.def: Add a conj operation in rtl * optabs.def: Add a conj optab * optabs-tree.cc (optab_for_tree_code): use the conj_optab to convert a CONJ_EXPR * expr

[PATCH 6/9] Native complex operations: Update how complex rotations are handled

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Catch complex rotation by 90° and 270° in fold-const.cc like before, but now convert them into the new COMPLEX_ROT90 and COMPLEX_ROT270 internal functions. Also add crot90 and crot270 optabs to expose these operation the backends. So conditionnaly lower COMPLEX_ROT90/COMPLEX_ROT270 by checking if c

[PATCH 8/9] Native complex operations: Add explicit vector of complex

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Allow the creation and usage of builtins vectors of complex in C, using __attribute__ ((vector_size ())) gcc/c-family/ChangeLog: * c-attribs.cc (vector_mode_valid_p): Add cases for vectors of complex (handle_mode_attribute): Likewise (type_valid_for_vector_size): L

[PATCH 4/9] Native complex operations: Allow native complex regs and ops in rtl

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Support registers of complex types in rtl. Also adapt the functions called during the expand pass to support native complex operations. gcc/ChangeLog: * explow.cc (trunc_int_for_mode): Allow complex int modes * expr.cc (emit_move_complex_parts): Move both parts at the same

[PATCH 3/9] Native complex operations: Add gen_rtx_complex hook

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Add a new target hook for complex element creation during the expand pass, called gen_rtx_complex. The default implementation calls gen_rtx_CONCAT like before. Then calls to gen_rtx_CONCAT for complex handling are replaced by calls to targetm.gen_rtx_complex. gcc/ChangeLog: * target.def:

[PATCH 2/9] Native complex operations: Move functions to hooks

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Move read_complex_part and write_complex_part to target hooks. Their signature also change because of the type of argument part is now complex_part_t. Calls to theses functions are updated accordingly. gcc/ChangeLog: * target.def: Define hooks for read_complex_part and write_compl

[PATCH 1/9] Native complex operations: Conditional lowering

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Allow the cplxlower pass to identify if an operation does not need to be lowered through optabs. In this case, lowering is not performed. The cplxlower pass now has to handle a mix of lowered and non-lowered operations. A quick access to both parts of a complex constant is also implemented. gcc/lt

[PATCH 0/9] Native complex operations

2023-07-17 Thread Sylvain Noiry via Gcc-patches
Hi, I have recently started a discussion about exposing complex operations directly to the backends, to better exploit ISA with complex instructions. The title of the original message is "[RFC] Exposing complex numbers to target backends" [1]. This message starts a serie of 9 patches of the impl