From b8806f6ffbe72ed8fb7aba3b3a9196ec4d13e614 Mon Sep 17 00:00:00 2001 From: Ju-Zhe Zhong Date: Mon, 3 Jul 2023 17:10:26 +0800 Subject: Middle-end: Change order of LEN_MASK_LOAD/LEN_MASK_STORE arguments Hi, Richard. I fix the order as you suggeted. Before this patch, the order is {len,mask,bias}. Now, after this patch, the order becomes {len,bias,mask}. Since you said we should not need 'internal_fn_bias_index', the bias index should always be the len index + 1. I notice LEN_STORE order is {len,vector,bias}, to make them consistent, I reorder into LEN_STORE {len,bias,vector}. Just like MASK_STORE {mask,vector}. Ok for trunk ? gcc/ChangeLog: * config/riscv/autovec.md: Change order of LEN_MASK_LOAD/LEN_MASK_STORE/LEN_LOAD/LEN_STORE arguments. * config/riscv/riscv-v.cc (expand_load_store): Ditto. * doc/md.texi: Ditto. * gimple-fold.cc (gimple_fold_partial_load_store_mem_ref): Ditto. * internal-fn.cc (len_maskload_direct): Ditto. (len_maskstore_direct): Ditto. (add_len_and_mask_args): New function. (expand_partial_load_optab_fn): Change order of LEN_MASK_LOAD/LEN_MASK_STORE/LEN_LOAD/LEN_STORE arguments. (expand_partial_store_optab_fn): Ditto. (internal_fn_len_index): New function. (internal_fn_mask_index): Change order of LEN_MASK_LOAD/LEN_MASK_STORE/LEN_LOAD/LEN_STORE arguments. (internal_fn_stored_value_index): Ditto. (internal_len_load_store_bias): Ditto. * internal-fn.h (internal_fn_len_index): New function. * tree-ssa-dse.cc (initialize_ao_ref_for_dse): Change order of LEN_MASK_LOAD/LEN_MASK_STORE/LEN_LOAD/LEN_STORE arguments. * tree-vect-stmts.cc (vectorizable_store): Ditto. (vectorizable_load): Ditto. --- gcc/gimple-fold.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/gimple-fold.cc') diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 8434274..4027ff7 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -5391,11 +5391,12 @@ gimple_fold_partial_load_store_mem_ref (gcall *call, tree vectype, bool mask_p) } else { - tree basic_len = gimple_call_arg (call, 2); + internal_fn ifn = gimple_call_internal_fn (call); + int len_index = internal_fn_len_index (ifn); + tree basic_len = gimple_call_arg (call, len_index); if (!poly_int_tree_p (basic_len)) return NULL_TREE; - unsigned int nargs = gimple_call_num_args (call); - tree bias = gimple_call_arg (call, nargs - 1); + tree bias = gimple_call_arg (call, len_index + 1); gcc_assert (TREE_CODE (bias) == INTEGER_CST); /* For LEN_LOAD/LEN_STORE/LEN_MASK_LOAD/LEN_MASK_STORE, we don't fold when (bias + len) != VF. */ @@ -5405,7 +5406,6 @@ gimple_fold_partial_load_store_mem_ref (gcall *call, tree vectype, bool mask_p) /* For LEN_MASK_{LOAD,STORE}, we should also check whether the mask is all ones mask. */ - internal_fn ifn = gimple_call_internal_fn (call); if (ifn == IFN_LEN_MASK_LOAD || ifn == IFN_LEN_MASK_STORE) { tree mask = gimple_call_arg (call, internal_fn_mask_index (ifn)); -- cgit v1.1