From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by sourceware.org (Postfix) with ESMTPS id 99204385703C for ; Thu, 20 Jul 2023 08:06:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99204385703C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp70t1689840391twwckob9 Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 20 Jul 2023 16:06:30 +0800 (CST) X-QQ-SSF: 01400000000000G0U000000A0000000 X-QQ-FEAT: dKvkn8qoLrGELk9ib8iJ4v58oPYqEjWfsYiLfe57utteEyeo5W8/xwQoqUeos tyYtv6aXhrt+CjPJmWJ28JAvZmGRWYnPJfueklnDTvdM/L5E/bwdoPttnBmTzEwabq8YX8e NekPR3Qu9JRzqYqxt6te8okQL3xSxvaqLP32BpNkZ70FcN/HcB/RsYgj/iy/G/+J9gLMF1I /A4ef2fP8/gN0XwzMWnEeSD8ABOLkVyVTdggUGem6/xXloYVTu0rfIysSNJyTQvtQ/URizN Stq7P2ZAFuDQRMpCvFm4QTFrqm/dIH/hjQ/Eb8LtcCU4N5a/nrnOYhcEBYhDmFndlgEUXs5 XUYyRGkIuvZ4YvkbU9PbQU1Ucx6+br6qgf7hHqHNETwDmv55EWe8gts1C2FLhqvC5Hw667z RmU2dpmz6ZM= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9414783224039918084 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, Ju-Zhe Zhong Subject: [PATCH] CODE STRUCTURE: Refine codes in Vectorizer Date: Thu, 20 Jul 2023 16:06:29 +0800 Message-Id: <20230720080629.1060969-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Ju-Zhe Zhong Hi, Richard and Richi. I plan to refine the codes that I recently support for RVV auto-vectorization. This patch is inspired last review comments from Richard: https://patchwork.sourceware.org/project/gcc/patch/20230712042124.111818-1-juzhe.zhong@rivai.ai/ Richard said he prefer the the code structure as follows: Please instead switch the if condition so that the structure is: if (...) vect_record_loop_mask (...) else if (...) vect_record_loop_len (...) else can't use partial vectors This is his last comments. So, I come back to refine this piece of codes. Does it look reasonable ? This next refine patch is change all names of "LEN_MASK" into "MASK_LEN" but should come after this patch. gcc/ChangeLog: * tree-vect-stmts.cc (check_load_store_for_partial_vectors): Refine code structure. --- gcc/tree-vect-stmts.cc | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index cb86d544313..b86e159ae4c 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -1605,6 +1605,7 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype, nvectors = vect_get_num_copies (loop_vinfo, vectype); vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo); + vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo); machine_mode vecmode = TYPE_MODE (vectype); bool is_load = (vls_type == VLS_LOAD); if (memory_access_type == VMAT_LOAD_STORE_LANES) @@ -1631,33 +1632,29 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype, internal_fn ifn = (is_load ? IFN_MASK_GATHER_LOAD : IFN_MASK_SCATTER_STORE); - if (!internal_gather_scatter_fn_supported_p (ifn, vectype, - gs_info->memory_type, - gs_info->offset_vectype, - gs_info->scale)) - { - ifn = (is_load - ? IFN_LEN_MASK_GATHER_LOAD - : IFN_LEN_MASK_SCATTER_STORE); - if (internal_gather_scatter_fn_supported_p (ifn, vectype, - gs_info->memory_type, - gs_info->offset_vectype, - gs_info->scale)) - { - vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo); - vect_record_loop_len (loop_vinfo, lens, nvectors, vectype, 1); - return; - } + internal_fn len_ifn = (is_load + ? IFN_LEN_MASK_GATHER_LOAD + : IFN_LEN_MASK_SCATTER_STORE); + if (internal_gather_scatter_fn_supported_p (ifn, vectype, + gs_info->memory_type, + gs_info->offset_vectype, + gs_info->scale)) + vect_record_loop_mask (loop_vinfo, masks, nvectors, vectype, + scalar_mask); + else if (internal_gather_scatter_fn_supported_p (len_ifn, vectype, + gs_info->memory_type, + gs_info->offset_vectype, + gs_info->scale)) + vect_record_loop_len (loop_vinfo, lens, nvectors, vectype, 1); + else + { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "can't operate on partial vectors because" " the target doesn't have an appropriate" " gather load or scatter store instruction.\n"); LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; - return; } - vect_record_loop_mask (loop_vinfo, masks, nvectors, vectype, - scalar_mask); return; } @@ -1703,7 +1700,6 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype, if (get_len_load_store_mode (vecmode, is_load).exists (&vmode)) { nvectors = group_memory_nvectors (group_size * vf, nunits); - vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo); unsigned factor = (vecmode == vmode) ? 1 : GET_MODE_UNIT_SIZE (vecmode); vect_record_loop_len (loop_vinfo, lens, nvectors, vectype, factor); using_partial_vectors_p = true; -- 2.36.3