[PATCH] RISC-V: Add mode switching target hook to insert rounding mode config for fixed-point instructions

2023-05-17 Thread juzhe . zhong
From: Juzhe-Zhong Hi, this patch support the new coming fixed-point intrinsics: https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/222 Insert fixed-point rounding mode configuration by mode switching target hook. Mode switching target hook is implemented applying LCM (Lazy code Motion

[PATCH] RISC-V: Add RVV comparison autovectorization

2023-05-19 Thread juzhe . zhong
From: Juzhe-Zhong This patch enable RVV auto-vectorization including floating-point unorder and order comparison. The testcases are leveraged from Richard. So include Richard as co-author. Co-Authored-By: Richard Sandiford gcc/ChangeLog: * config/riscv/autovec.md (vcond): New

[PATCH V12] VECT: Fix issue of multiple-rgroup for length is counting elements

2023-05-21 Thread juzhe . zhong
From: Ju-Zhe Zhong Address comments from Richard that splits the patch of fixing multiple-rgroup handling of length counting elements. This patch is fixing issue of handling multiple-rgroup of length is counting elements Before this patch, multiple rgroup run fail: FAIL: gcc.target/riscv/rvv/a

[PATCH] RISC-V: Reorganize the code of CONST_VECTOR handling in riscv.cc

2023-05-22 Thread juzhe . zhong
From: Juzhe-Zhong Since satisfies_constraint_vi (x) belongs to RVV region. We make this condition inside riscv_v_ext_vector_mode_p to make codes more reasonable. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_const_insns): Reorganize the codes. --- gcc/config/riscv/riscv.cc | 12

[PATCH V13] VECT: Fix bug of multiple-rgroup for length is counting elements

2023-05-22 Thread juzhe . zhong
From: Ju-Zhe Zhong Address comments from Richard that splits the patch of fixing multiple-rgroup handling of length counting elements. This patch is fixing issue of handling multiple-rgroup of length is counting elements Before this patch, multiple rgroup run fail: FAIL: gcc.target/riscv/rvv/a

[PATCH V12] VECT: Add decrement IV iteration loop control by variable amount support

2023-05-22 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * tree-vect-loop-manip.cc (vect_adjust_loop_lens_control): New function. (vect_set_loop_controls_directly): Add decrement IV support. (vect_set_loop_condition_partial_vectors): Ditto. * tree-vect-loop.cc: Ditto. * tree-vec

[PATCH] RISC-V: Fix typo of multiple_rgroup-2.h

2023-05-22 Thread juzhe . zhong
From: Juzhe-Zhong Just notice this following fail in the regression: FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-2.c (test for excess errors) FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c (test for excess errors) gcc/testsuite/ChangeLog

[PATCH] RISC-V: Add "m_" prefix for private member

2023-05-22 Thread juzhe . zhong
From: Juzhe-Zhong Since the current framework is hard to maintain and hard to be used in the future possible auto-vectorization patterns. We will need to keep adding more helpers and arguments during the auto-vectorization supporting. We should refactor the framework now for the future use

[PATCH] RISC-V: Refactor the framework of RVV auto-vectorization

2023-05-22 Thread juzhe . zhong
From: Juzhe-Zhong This patch is to refactor the framework of RVV auto-vectorization. Since we find out are keep adding helpers && wrappers when implementing auto-vectorization. It will make the RVV auto-vectorizaiton very messy. After double check my downstream RVV GCC, assemble

[PATCH V2] RISC-V: Refactor the framework of RVV auto-vectorization

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong This patch is to refactor the framework of RVV auto-vectorization. Since we find out are keep adding helpers && wrappers when implementing auto-vectorization. It will make the RVV auto-vectorizaiton very messy. After double check my downstream RVV GCC, assemble

[PATCH] RISC-V: Fix warning of vxrm pattern

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong I just notice the warning: ../../../riscv-gcc/gcc/config/riscv/vector.md:618:1: warning: source missing a mode? gcc/ChangeLog: * config/riscv/vector.md: Add mode. --- gcc/config/riscv/vector.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc

[PATCH V2] RISC-V: Add RVV comparison autovectorization

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong This patch enable RVV auto-vectorization including floating-point unorder and order comparison. The testcases are leveraged from Richard. So include Richard as co-author. Co-Authored-By: Richard Sandiford gcc/ChangeLog: * config/riscv/autovec.md (@vcond_mask_): New

[PATCH V3] RISC-V: Add RVV comparison autovectorization

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong This patch enable RVV auto-vectorization including floating-point unorder and order comparison. The testcases are leveraged from Richard. So include Richard as co-author. Co-Authored-By: Richard Sandiford gcc/ChangeLog: * config/riscv/autovec.md (@vcond_mask_): New

[PATCH] RISC-V: Fix magic number of RVV auto-vectorization expander

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong This simple patch fixes the magic number, replaced by enum to make code more reasonable. Ok for trunk ? gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_vec_series): Fix magic number. (expand_const_vector): Ditto. (legitimize_move): Ditto

[PATCH V2] RISC-V: Fix magic number of RVV auto-vectorization expander

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong This simple patch fixes the magic number, remove magic number make codes more reasonable. Ok for trunk ? gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_vec_series): Remove magic number. (expand_const_vector): Ditto. (legitimize_move): Ditto

[PATCH] RISC-V: Fix incorrect code of touching inaccessible memory address

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong For VLMAX situation, rtx len = ops[m_op_num] is incorrect since the last element the ops array should be ops[m_op_num - 1]; I notice this issue when I am debugging code. This is a code bug even though the following codes will hide this issue. We still should need this minor

[PATCH V2] RISC-V: Fix incorrect code of reaching inaccessible memory address

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong To fix this issue, we seperate Vl operand and normal operands. gcc/ChangeLog: * config/riscv/autovec.md: Adjust for new interface. * config/riscv/riscv-protos.h (emit_vlmax_insn): Add VL operand. (emit_nonvlmax_insn): Add AVL operand. * config

[PATCH V4] RISC-V: Add RVV comparison autovectorization

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong This patch enable RVV auto-vectorization including floating-point unorder and order comparison. The testcases are leveraged from Richard. So include Richard as co-author. Co-Authored-By: Richard Sandiford gcc/ChangeLog: * config/riscv/autovec.md (@vcond_mask_): New

[PATCH V5] RISC-V: Add RVV comparison autovectorization

2023-05-23 Thread juzhe . zhong
From: Juzhe-Zhong This patch enable RVV auto-vectorization including floating-point unorder and order comparison. The testcases are leveraged from Richard. So include Richard as co-author. And this patch is the prerequisite patch for my current middle-end work. Without this patch, I can&#

[PATCH] RISC-V: Add RVV mask logic auto-vectorization

2023-05-24 Thread juzhe . zhong
From: Juzhe-Zhong This patch is adding mask logic auto-vectorization. define the pattern as "define_insn_and_split" to allow combine PASS easily combine series instructions. For example: combine vmxor.mm + vmnot.m into vmxnor.mm Build success and regression PASS Ok for trunk ? gcc

[V2 COMMITTED] RISC-V: Add RVV mask logic auto-vectorization

2023-05-24 Thread juzhe . zhong
From: Juzhe-Zhong This patch is adding mask logic auto-vectorization. define the pattern as "define_insn_and_split" to allow combine PASS easily combine series instructions. For example: combine vmxor.mm + vmnot.m into vmxnor.mm Build success and regression PASS And committed.

[PATCH] RISC-V: Add FRM_ prefix to dynamic rounding mode enum

2023-05-24 Thread juzhe . zhong
From: Juzhe-Zhong An obvious fix to make all enum naming consistent. gcc/ChangeLog: * config/riscv/riscv-protos.h (enum frm_field_enum): Add FRM_ prefix. --- gcc/config/riscv/riscv-protos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv

[PATCH] RISC-V: Remove FRM_REGNUM dependency for rtx conversions

2023-05-24 Thread juzhe . zhong
From: Juzhe-Zhong According to RVV ISA: The conversions use the dynamic rounding mode in frm, except for the rtz variants, which round towards zero. So rtz conversion patterns should not have FRM dependency. We can't support mode switching for FRM yet since rvv intrinsic doc is not up

[PATCH V13] VECT: Add decrement IV iteration loop control by variable amount support

2023-05-24 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch is supporting decrement IV by following the flow designed by Richard: (1) In vect_set_loop_condition_partial_vectors, for the first iteration of: call vect_set_loop_controls_directly. (2) vect_set_loop_controls_directly calculates "step" as in your patch. If rg

[PATCH V14] VECT: Add decrement IV iteration loop control by variable amount support

2023-05-24 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch is supporting decrement IV by following the flow designed by Richard: (1) In vect_set_loop_condition_partial_vectors, for the first iteration of: call vect_set_loop_controls_directly. (2) vect_set_loop_controls_directly calculates "step" as in your patch. If rg

[PATCH V15] VECT: Add decrement IV iteration loop control by variable amount support

2023-05-24 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch is supporting decrement IV by following the flow designed by Richard: (1) In vect_set_loop_condition_partial_vectors, for the first iteration of: call vect_set_loop_controls_directly. (2) vect_set_loop_controls_directly calculates "step" as in your patch. If rg

[PATCH] RISC-V: Fix incorrect VXRM configuration in mode switching for CALL and ASM

2023-05-24 Thread juzhe . zhong
From: Juzhe-Zhong Currenty mode switching incorrect codegen for the following case: void fn (void); void f (void * in, void *out, int32_t x, int n, int m) { for (int i = 0; i < n; i++) { vint32m1_t v = __riscv_vle32_v_i32m1 (in + i, 4); vint32m1_t v2 = __riscv_vle32_v_i32m1_tu (v,

[PATCH V2] RISC-V: Fix incorrect VXRM configuration in mode switching for CALL and ASM

2023-05-25 Thread juzhe . zhong
From: Juzhe-Zhong Currently mode switching incorrect codegen for the following case: void fn (void); void f (void * in, void *out, int32_t x, int n, int m) { for (int i = 0; i < n; i++) { vint32m1_t v = __riscv_vle32_v_i32m1 (in + i, 4); vint32m1_t v2 = __riscv_vle32_v_i32m1_tu (v,

[PATCH] RISC-V: Add RVV FRM enum for floating-point rounding mode intriniscs

2023-05-25 Thread juzhe . zhong
From: Juzhe-Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (register_frm): New function. (DEF_RVV_FRM_ENUM): New macro. (handle_pragma_vector): Add FRM enum * config/riscv/riscv-vector-builtins.def (DEF_RVV_FRM_ENUM): New macro. (RNE): Ditto

[PATCH V16] VECT: Add decrement IV iteration loop control by variable amount support

2023-05-25 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch is supporting decrement IV by following the flow designed by Richard: (1) In vect_set_loop_condition_partial_vectors, for the first iteration of: call vect_set_loop_controls_directly. (2) vect_set_loop_controls_directly calculates "step" as in your patch. If rg

[PATCH V17] VECT: Add decrement IV iteration loop control by variable amount support

2023-05-25 Thread juzhe . zhong
From: Ju-Zhe Zhong Fix format for Richard. This patch is supporting decrement IV by following the flow designed by Richard: (1) In vect_set_loop_condition_partial_vectors, for the first iteration of: call vect_set_loop_controls_directly. (2) vect_set_loop_controls_directly calculates "step

[PATCH] VECT: Add SELECT_VL support

2023-05-25 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch is adding SELECT_VL middle-end support allow target have target dependent optimization in case of length calculation. This patch is inspired by RVV ISA and LLVM: https://reviews.llvm.org/D99750 The SELECT_VL is same behavior as LLVM "get_vector_length" with these f

[PATCH] RISC-V: Fix zero-scratch-regs-3.c fail

2023-05-25 Thread juzhe . zhong
From: Juzhe-Zhong Fix ICE of zero-scratch-regs-3.c: bug.c:7:1: internal compiler error: Segmentation fault 7 | } | ^ 0x1647b23 crash_signal ../../../riscv-gcc/gcc/toplev.cc:314 0x147053f maybe_legitimize_operand ../../../riscv-gcc/gcc/optabs.cc:7947 0x1470dc2

[PATCH V2] RISC-V: Fix zero-scratch-regs-3.c fail

2023-05-25 Thread juzhe . zhong
From: Juzhe-Zhong gcc/ChangeLog: * config/riscv/riscv.cc (vector_zero_call_used_regs): Add explict VL and drop VL in ops. --- gcc/config/riscv/riscv.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index

[PATCH] RISC-V: Fix VSETVL PASS ICE on SLP auto-vectorization

2023-05-25 Thread juzhe . zhong
From: Juzhe-Zhong Fix bug reported here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109974 PR target/109974 gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (source_equal_p): Fix ICE. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/vsetvl/pr109974.c: New test

[PATCH] RISC-V: Support poly move manipulation and selftests.

2022-09-15 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * common/config/riscv/riscv-common.cc: Change "static void" to "void". * config.gcc: Add riscv-selftests.o * config/riscv/predicates.md: Allow const_poly_int. * config/riscv/riscv-protos.h (riscv_reinit): New function. (risc

[PATCH] RISC-V: Add RVV machine modes.

2022-09-15 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv-modes.def (VECTOR_BOOL_MODE): Define RVV mask modes. (ADJUST_NUNITS): Adjust NUNITS using riscv_vector_chunks. (ADJUST_ALIGNMENT): Adjust alignment. (ADJUST_BYTESIZE): Adjust bytesize. (RVV_MODES): New

[PATCH] RISC-V: Add RVV machine modes.

2022-09-15 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv-modes.def (VECTOR_BOOL_MODE): Add RVV mask modes. (ADJUST_NUNITS): Adjust nunits using riscv_vector_chunks. (ADJUST_ALIGNMENT): Adjust alignment. (ADJUST_BYTESIZE): Adjust bytesize using riscv_vector_chunks.

[PATCH] RISC-V: Suppress riscv-selftests.cc warning.

2022-09-16 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch is a fix patch for: https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601643.html Suppress the warning as follows: ../../../riscv-gcc/gcc/poly-int.h: In function ‘poly_int64 eval_value(rtx, std::map&)’: ../../../riscv-gcc/gcc/poly-int.h:845:48: warning: ‘*((

[PATCH] DSE: Enhance dse with def-ref analysis

2022-09-21 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch fix issue: PR 99407 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99407 The enhancement implementation is simple: 1.Search gimple statement in program reverse order. 2.Queue the store statement which may be possible kill the def of previous store statement. 3.Perfo

[PATCH] DSE: Enhance dse with def-ref analysis

2022-09-22 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch fix issue: PR 99407 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99407 The enhancement implementation is simple: 1.Search gimple statement in program reverse order. 2.Queue the store statement which may be possible kill the def of previous store statement. 3.Perfo

[PATCH] RISC-V: Add ABI-defined RVV types.

2022-09-27 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config.gcc: Add riscv-vector-builtins.o. * config/riscv/riscv-builtins.cc (riscv_init_builtins): Add RVV builtin function. * config/riscv/riscv-protos.h (riscv_v_ext_enabled_vector_mode_p): New function. * config/riscv/riscv.c

[Unfinished PATCH] Add first-order recurrence autovectorization

2022-09-29 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * tree-vect-loop.cc (vect_phi_first_order_recurrence_p): New function. (vect_analyze_scalar_cycles_1): Classify first-order recurrence phi. (vect_analyze_loop_operations): Add first-order recurrence autovectorization support. (ve

[PATCH] RISC-V: Introduce RVV header to enable builtin types

2022-09-29 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config.gcc: Add riscv_vector.h. * config/riscv/riscv-builtins.cc: Add RVV builtin types support. * config/riscv/riscv-c.cc (riscv_pragma_intrinsic): New function. (riscv_register_pragmas): Ditto. * config/riscv/riscv-pro

[PATCH] Add first-order recurrence autovectorization

2022-09-30 Thread juzhe . zhong
From: Ju-Zhe Zhong Hi, After fixing previous ICE. I add full implementation (insert permutation to get correct result.) The gimple IR is correct now I think: # t_21 = PHI <_4(6), t_12(9)> # i_22 = PHI # vectp_a.6_26 = PHI # vect_vec_recur_.9_9 = PHI # vectp_b.11_7 = PHI # curr_c

[PATCH] RISC-V: Add missing vsetvl instruction type.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong When implementing built-in framework, I notice I missed vsetvl instruction type, so add it in a single patch preparing for the following patches. gcc/ChangeLog: * config/riscv/riscv.md: Add vsetvl instruction type. --- gcc/config/riscv/riscv.md | 3 ++- 1 file chang

[PATCH] RISC-V: move struct vector_type_info from *.h to *.cc.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (struct vector_type_info): Move from riscv-vector-builtins.h. * config/riscv/riscv-vector-builtins.h (struct vector_type_info): Move to riscv-vector-builtins.cc. --- gcc/config/riscv/riscv-vector-builti

[PATCH] RISC-V: move struct vector_type_info from *.h to *.cc and change "user_name" into "name".

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (struct vector_type_info): Move from config/riscv/riscv-vector-builtins.h. (DEF_RVV_TYPE): Change USER_NAME to NAME. (register_vector_type): Change user_name to name. * config/riscv/riscv-v

[PATCH] RISC-V: Move function place to make it looks better.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (rvv_switcher::rvv_switcher): Move down like ARM SVE. (rvv_switcher::~rvv_switcher): Move down like ARM SVE. (mangle_builtin_type): Move down to make it together with other global function.

[PATCH] RISC-V: Refine register_builtin_types function.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (GTY): Redefine vector types. (build_const_pointer): New function. (register_builtin_type): Ditto. (DEF_RVV_TYPE): Simplify macro. (register_vector_type): Refine implementation.

[PATCH] RISC-V: Clang-format add_vector_attribute function.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (add_vector_type_attribute): Clang-format function. --- gcc/config/riscv/riscv-vector-builtins.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-builtins.cc

[PATCH] RISC-V: Remove TUPLE size macro define.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.h: Remove redundant macro. --- gcc/config/riscv/riscv-vector-builtins.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-builtins.h b/gcc/config/riscv/riscv-vector-builtins.h inde

[PATCH] RISC-V: Refine riscv-vector-builtins.o include files and makefile.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc: Change include files same as ARM SVE. * config/riscv/t-riscv: Refine makefile. --- gcc/config/riscv/riscv-vector-builtins.cc | 9 +++-- gcc/config/riscv/t-riscv | 14 --

[PATCH] RISC-V: Clang-format vector_type_index.

2022-10-10 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-builtins.h (DEF_RVV_TYPE): Clang-format it. --- gcc/config/riscv/riscv-vector-builtins.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-builtins.h b/gcc/config/riscv/risc

[PATCH] RISC-V: Add new line at end of file.

2022-10-11 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-c.cc: Add new line. * config/riscv/riscv_vector.h (vwrite_csr): Add new line. --- gcc/config/riscv/riscv-c.cc | 2 +- gcc/config/riscv/riscv_vector.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git

[PATCH] RISC-V: Reorganize mangle_builtin_type.[NFC]

2022-10-14 Thread juzhe . zhong
From: Ju-Zhe Zhong Hi, this patch fixed my mistake in the previous commit patch. Since "mangle_builtin_type" is a global function will be called in riscv.cc. It's reasonable move it down and put them together stay with other global functions. gcc/ChangeLog: * config/riscv/riscv-vector-

[PATCH] RISC-V: Fix format[NFC]

2022-10-17 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/t-riscv: Change Tab into 2 space. --- gcc/config/riscv/t-riscv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/riscv/t-riscv b/gcc/config/riscv/t-riscv index 2f060437c23..15b9e7c01b1 100644 --- a/gcc/config

[PATCH] RISC-V: Add RVV intrinsic basic framework.

2022-10-17 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config.gcc: Add gt files since function_instance is GTY ((user)). * config/riscv/riscv-builtins.cc (riscv_init_builtins): Add RVV intrinsic framework. (riscv_builtin_decl): Ditto. (riscv_expand_builtin): Ditto. * config

[PATCH] RISC-V: Add RVV vsetvl/vsetvlmax intrinsics and tests.

2022-10-17 Thread juzhe . zhong
--git a/gcc/config/riscv/riscv-vector-builtins-functions.def b/gcc/config/riscv/riscv-vector-builtins-functions.def new file mode 100644 index 000..dc41537865e --- /dev/null +++ b/gcc/config/riscv/riscv-vector-builtins-functions.def @@ -0,0 +1,43 @@ +/* Intrinsic define macros for RISC-V '

[PATCH] RISC-V: Fix REG_CLASS_CONTENTS.

2022-10-23 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv.h (enum reg_class): Fix ALL_REGS. --- gcc/config/riscv/riscv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index acae68ebb2d..37363e975e1 100644 --- a/gcc/

[PATCH] RISC-V: Support (set (mem) (const_poly_int)) handling and remove TI/TF.

2022-10-23 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-switch.def (ENTRY): Remove TI/TF. * config/riscv/riscv.cc (riscv_legitimize_move): Support (set (mem) (const_poly_int)). --- gcc/config/riscv/riscv-vector-switch.def | 4 gcc/config/riscv/riscv.cc

[PATCH] RISC-V: Support (set (mem) (const_poly_int))

2022-10-23 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv.cc (riscv_legitimize_move): Support (set (mem) (const_poly_int)). --- gcc/config/riscv/riscv.cc | 14 ++ 1 file changed, 14 insertions(+) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 90a390

[PATCH] RISC-V: Remove unused TI/TF vector modes.

2022-10-23 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vector-switch.def (ENTRY): Remove unused TI/TF vector modes. --- gcc/config/riscv/riscv-vector-switch.def | 4 1 file changed, 4 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-switch.def b/gcc/config/riscv/riscv-ve

[PATCH] RISC-V: Support load/store in mov pattern for RVV modes.

2022-10-23 Thread juzhe . zhong
, HOST_WIDE_INT); +extern bool legitimize_move (rtx, rtx, machine_mode); +enum tail_policy +{ + TAIL_UNDISTURBED = 0, + TAIL_AGNOSTIC = 1, +}; + +enum mask_policy +{ + MASK_UNDISTURBED = 0, + MASK_AGNOSTIC = 1, +}; } /* We classify builtin types into two classes: diff --git a/gcc/config/riscv

[PATCH] RISC-V: Replace CONSTEXPR with constexpr

2022-10-23 Thread juzhe . zhong
From: Ju-Zhe Zhong Move away from the pre-C++11 compatibility macro CONSTEXPR. This patch is inspired by aarch64: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603974.html. gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc: Replace CONSTEXPR with constexpr th

[PATCH] RISC-V: Support (set (mem) (const_poly_int))

2022-10-23 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv.cc (riscv_legitimize_move): Adjust using force_reg. --- gcc/config/riscv/riscv.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 98374a922d1..1fd34

[PATCH] RISC-V: Fix typo.

2022-10-24 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-modes.def (ADJUST_BYTESIZE): Fix typo. --- gcc/config/riscv/riscv-modes.def | 46 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/gcc/config/riscv/riscv-modes.def b/gcc/config/riscv/

[PATCH] RISC-V: ADJUST_NUNITS according to -march.

2022-10-24 Thread juzhe . zhong
From: Ju-Zhe Zhong This patch fixed PR107357: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107357 gcc/ChangeLog: * config/riscv/riscv-modes.def (VECTOR_BOOL_MODE): Set to minimum size. (ADJUST_NUNITS): Adjust according to -march. (ADJUST_BYTESIZE): Ditto. * config

[PATCH] RISC-V: Fix a mistake in previous patch.

2022-10-25 Thread juzhe . zhong
From: Ju-Zhe Zhong I noticed that I have made a mistake in previous patch: https://patchwork.sourceware.org/project/gcc/patch/20220817071950.271762-1-juzhe.zh...@rivai.ai/ The previous statement before this patch: bool need_barrier_p = (get_frame_size () + cfun->machine->frame.arg_pointer

[PATCH] RISC-V: Change constexpr back to CONSTEXPR

2022-10-27 Thread juzhe . zhong
From: Ju-Zhe Zhong According to https://github.com/gcc-mirror/gcc/commit/f95d3d5de72a1c43e8d529bad3ef59afc3214705. Since GCC 4.8.6 doesn't support constexpr, we should change it back to CONSTEXPR. gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc: Change constexpr back to C

[PATCH] RISC-V: Fix RVV testcases.

2022-10-30 Thread juzhe . zhong
From: Ju-Zhe Zhong gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/abi-2.c: Change ilp32d to ilp32. * gcc.target/riscv/rvv/base/abi-3.c: Ditto. * gcc.target/riscv/rvv/base/abi-4.c: Ditto. * gcc.target/riscv/rvv/base/abi-5.c: Ditto. * gcc.target/riscv/

[PATCH] RISC-V: Add runtime invariant support

2022-08-17 Thread juzhe . zhong
From: zhongjuzhe RISC-V 'V' Extension support scalable vector like ARM SVE. To support RVV, we need to introduce runtime invariant. - For zve32*, the runtime invariant uses 32-bit chunk. - For zve64*, the runtime invariant uses 64-bit chunk. [1] https://github.com/riscv/riscv-v-spec/blob/maste

[PATCH] middle-end: skipp stepped vector test of poly_int (1, 1) and allow the machine_mode definition with poly_uint16 (1, 1)

2022-08-18 Thread juzhe . zhong
From: zhongjuzhe Hello. This patch is preparing for following RVV support. Both ARM SVE and RVV (RISC-V 'V' Extension) support length-agnostic vector. The minimum vector length of ARM SVE is 128-bit and the runtime invariant of ARM SVE is always 128-bit blocks. However, the minimum vector lengt

[PATCH] middle-end: Fix issue of poly_uint16 (1, 1) in self test

2022-08-22 Thread juzhe . zhong
From: zhongjuzhe This patch fix issue of poly_uint16 (1, 1) in machine mode self test. gcc/ChangeLog: * simplify-rtx.cc (test_vector_subregs_fore_back): Make first value and repeat value different. --- gcc/simplify-rtx.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --

[PATCH] middle-end: Fix unexpected warnings for RISC-V port.

2022-08-23 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * tree-vect-loop-manip.cc (vect_gen_vector_loop_niters): Simply initialize const_vf to 0. --- gcc/tree-vect-loop-manip.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc

[PATCH] RISC-V: Add vector registers and classification

2022-08-26 Thread juzhe . zhong
From: zhongjuzhe This patch is preparing patch for RVV support: 1. Add vector registers. 2. Add classification of RVV instructions in attribute 'type'. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_v_ext_vector_mode_p): New function. (riscv_classify_address): Disallow PLUS/LO_S

[PATCH] RISC-V: Add RVV instructions classification

2022-08-27 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv.md: Add new type for vector instructions. --- gcc/config/riscv/riscv.md | 100 +- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md

[PATCH] RISC-V: Add RVV registers

2022-08-27 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv.cc (riscv_v_ext_vector_mode_p): New function. (riscv_classify_address): Disallow PLUS/LO_SUM/CONST_INT address types for RVV. (riscv_address_insns): Add RVV modes condition. (riscv_binary_cost): Ditto.

[PATCH] RISC-V: Fix riscv_vector_chunks configuration according to TARGET_MIN_VLEN

2022-08-29 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv.cc (riscv_convert_vector_bits): Change configuration according to TARGET_MIN_VLEN. * config/riscv/riscv.h (UNITS_PER_FP_REG): Fix annotation. --- gcc/config/riscv/riscv.cc | 11 ++- gcc/config/riscv/riscv.h | 2 +-

[PATCH] RISC-V: Fix annotation

2022-08-29 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv.h (enum reg_class): Change vype to vtype. --- gcc/config/riscv/riscv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 29582f7c545..3ee5a93ce6a 100644 ---

[PATCH] RISC-V: Add RVV constraints.

2022-08-29 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/constraints.md (TARGET_VECTOR ? V_REGS : NO_REGS): Add "vr" constraint. (TARGET_VECTOR ? VD_REGS : NO_REGS): Add "vd" constraint. (TARGET_VECTOR ? VM_REGS : NO_REGS): Add "vm" constraint. (vp): Add poly constraint.

[PATCH] RISC-V: Add csrr vlenb instruction.

2022-08-29 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv.cc (riscv_const_insns): Add cost of poly_int. (riscv_output_move): Add csrr vlenb assembly. * config/riscv/riscv.md (move_type): Add csrr vlenb type. (ext): New attribute. (ext_enabled): Ditto. (

[PATCH] RISC-V: Add RVV registers in TARGET_CONDITION_AL_REGISTER_USAGE

2022-08-29 Thread juzhe . zhong
From: zhongjuzhe gcc/ChangeLog: * config/riscv/riscv.cc (riscv_conditional_register_usage): Add RVV registers. --- gcc/config/riscv/riscv.cc | 9 + 1 file changed, 9 insertions(+) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 50de6a83cba..aebe3c0ab6

[PATCH] RISC-V: Disable the vsetvl fusion for conflict successors

2024-02-01 Thread Juzhe-Zhong
This patch fixes the following ineffective vsetvl insertion: #include "riscv_vector.h" void f (int32_t * restrict in, int32_t * restrict out, size_t n, size_t cond, size_t cond2) { for (size_t i = 0; i < n; i++) { if (i == cond) { vint8mf8_t v = *(vint8mf8_t*)(in + i + 100);

[PATCH v2] RISC-V: Suppress the vsetvl fusion for conflict successors

2024-02-01 Thread Juzhe-Zhong
Update in v2: Add dump information. This patch fixes the following ineffective vsetvl insertion: #include "riscv_vector.h" void f (int32_t * restrict in, int32_t * restrict out, size_t n, size_t cond, size_t cond2) { for (size_t i = 0; i < n; i++) { if (i == cond) { vint8mf8

[PATCH] RISC-V: Remove vsetvl_pre bogus instructions in VSETVL PASS

2024-02-01 Thread Juzhe-Zhong
I realize there is a RTL regression between GCC-14 and GCC-13. https://godbolt.org/z/Ga7K6MqaT GCC-14: (insn 9 13 31 2 (set (reg:DI 15 a5 [138]) (unspec:DI [ (const_int 64 [0x40]) ] UNSPEC_VLMAX)) "/app/example.c":5:15 2566 {vlmax_avldi} (expr_list:REG_EQUI

[PATCH] RISC-V: Allow LICM hoist POLY_INT configuration code sequence

2024-02-01 Thread Juzhe-Zhong
Realize in recent benchmark evaluation (coremark-pro zip-test): vid.v v2 vmv.v.i v5,0 .L9: vle16.v v3,0(a4) vrsub.vxv4,v2,a6 ---> LICM failed to hoist it outside the loop. The root cause is: (insn 56 47 57 4 (set (subreg:DI (reg:HI 220) 0) (re

[PATCH] RISC-V: Expand VLMAX scalar move in reduction

2024-02-01 Thread Juzhe-Zhong
This patch fixes the following: vsetvli a5,a1,e32,m1,tu,ma sllia4,a5,2 sub a1,a1,a5 vle32.v v2,0(a0) add a0,a0,a4 vadd.vv v1,v2,v1 bne a1,zero,.L3 vsetivlizero,1,e32,m1,ta,ma vmv.s.x v2,zero vse

[PATCH] RISC-V: Fix infinite compilation of VSETVL PASS

2024-02-05 Thread Juzhe-Zhong
This patch fixes issue reported by Jeff. Testing is running. Ok for trunk if I passed the testing with no regression ? gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pre_vsetvl::emit_vsetvl): Fix inifinite compilation. (pre_vsetvl::remove_vsetvl_pre_insns): Ditto. --- gcc/conf

[Committed] RISC-V: Robostify dynamic lmul test

2024-01-09 Thread Juzhe-Zhong
While working on refining the cost model, I notice this test will generate unexpected scalar xor instructions if we don't tune cost model carefully. Add more assembler to avoid future regression. Committed. gcc/testsuite/ChangeLog: * gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul2-7.c: A

[PATCH] RISC-V: Minor tweak dynamic cost model

2024-01-09 Thread Juzhe-Zhong
While working on cost model, I notice one case that dynamic lmul cost doesn't work well. Before this patch: foo: lui a4,%hi(.LANCHOR0) li a0,1953 li a1,63 addia4,a4,%lo(.LANCHOR0) li a3,64 vsetvli a2,zero,e32,mf2,ta,ma

[PATCH V2] RISC-V: Minor tweak dynamic cost model

2024-01-09 Thread Juzhe-Zhong
v2 update: Robostify tests. While working on cost model, I notice one case that dynamic lmul cost doesn't work well. Before this patch: foo: lui a4,%hi(.LANCHOR0) li a0,1953 li a1,63 addia4,a4,%lo(.LANCHOR0) li a3,64 vsetvli

[PATCH] RISC-V: Refine unsigned avg_floor/avg_ceil

2024-01-09 Thread Juzhe-Zhong
This patch is inspired by LLVM patches: https://github.com/llvm/llvm-project/pull/76550 https://github.com/llvm/llvm-project/pull/77473 Use vaaddu for AVG vectorization. Before this patch: vsetivlizero,8,e8,mf2,ta,ma vle8.v v3,0(a1) vle8.v v2,0(a2) vwadd

[PATCH] RISC-V: Switch RVV cost model to generic vector cost model

2024-01-10 Thread Juzhe-Zhong
This patch is preparing patch for the following cost model tweak. Since we don't have vector cost model in default tune info (rocket), we set the cost model default as generic cost model by default. The reason we want to switch to generic vector cost model is the default cost model generates infe

[PATCH V2] RISC-V: Switch RVV cost model.

2024-01-10 Thread Juzhe-Zhong
This patch is preparing patch for the following cost model tweak. Since we don't have vector cost model in default tune info (rocket), we set the cost model default as generic cost model by default. The reason we want to switch to generic vector cost model is the default cost model generates infe

[PATCH] RISC-V: VLA preempts VLS on unknown NITERS loop

2024-01-10 Thread Juzhe-Zhong
This patch fixes the known issues on SLP cases: ble a2,zero,.L11 addiw t1,a2,-1 li a5,15 bleut1,a5,.L9 srliw a7,t1,4 sllia7,a7,7 lui t3,%hi(.LANCHOR0) lui a6,%hi(.LANCHOR0+128) addit3,t3,%lo(.L

[PATCH] RISC-V: Increase scalar_to_vec_cost from 1 to 3

2024-01-11 Thread Juzhe-Zhong
This patch fixes the following inefficient vectorized codes: vsetvli a5,zero,e8,mf2,ta,ma li a2,17 vid.v v1 li a4,-32768 vsetvli zero,zero,e16,m1,ta,ma addiw a4,a4,104 vmv.v.i v3,15 lui a1,%hi(a) li a0,1

[PATCH V2] RISC-V: Adjust scalar_to_vec cost accurately

2024-01-11 Thread Juzhe-Zhong
1. This patch set scalar_to_vec cost as 2 instead 1 since scalar move instruction is slightly more costly than normal rvv instructions (e.g. vadd.vv). 2. Adjust scalar_to_vec cost accurately according to the splat value, for example, a value like 32872, needs 2 more scalar instructions:

[Committed] RISC-V: Enhance a testcase

2024-01-11 Thread Juzhe-Zhong
This test should pass no matter how we adjust cost model. Remove -fno-vect-cost-model. Committed. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/fold-min-poly.c: Remove -fno-vect-cost-model --- gcc/testsuite/gcc.target/riscv/rvv/autovec/fold-min-poly.c | 2 +- 1 file changed

[PATCH V3] RISC-V: Adjust scalar_to_vec cost

2024-01-12 Thread Juzhe-Zhong
1. Introduce vector regmove new tune info. 2. Adjust scalar_to_vec cost in add_stmt_cost. We will get optimal codegen after this patch with -march=rv64gcv_zvl256b: lui a5,%hi(a) li a4,19 sb a4,%lo(a)(a5) li a0,0 ret Tested on both RV32/R

<    1   2   3   4   5   6   7   8   9   10   >