From patchwork Tue Oct 19 08:12:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 46377 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9329C3858408 for ; Tue, 19 Oct 2021 08:13:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9329C3858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634631189; bh=H5P+rDcvGhGm7WaHpgwEkL3yv2eKBvzzSXt7Bp2r1lA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cWtcfTutkbKwEkIRs1ZXPcT20YtjGdQEtVbYNAQyPkOybbN7Bhgg+QrWUA3rNrAwO cLxiKd6t7cGzvjnkT1YUD99QqpGC8yLdaYv1VD368TpWH0dwHsqyd7T1+gK9yS68WL vDGipamKUtSeuQCA/wKy5TSow7X4DE7MmrEVK6eI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 97254385840B for ; Tue, 19 Oct 2021 08:12:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 97254385840B Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6B7E92195F for ; Tue, 19 Oct 2021 08:12:39 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 57CF0140ED for ; Tue, 19 Oct 2021 08:12:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QedAFPd9bmGtBgAAMHmgww (envelope-from ) for ; Tue, 19 Oct 2021 08:12:39 +0000 Date: Tue, 19 Oct 2021 10:12:39 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Add misalignment output parameter to get_load_store_type Message-ID: <3ssrqr0-s3s3-2q63-s1ro-o349r4136558@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This makes us compute the misalignment alongside the alignment support scheme in get_load_store_type, removing some out-of-place calls to the DR alignment API. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-10-18 Richard Biener * tree-vect-stmts.c (get_group_load_store_type): Add misalignment output parameter and initialize it. (get_group_load_store_type): Likewise. (vectorizable_store): Remove now redundant queries. (vectorizable_load): Likewise. --- gcc/tree-vect-stmts.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 5d8fe42e200..c3690769d8f 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -2109,6 +2109,7 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, bool masked_p, vec_load_store_type vls_type, vect_memory_access_type *memory_access_type, dr_alignment_support *alignment_support_scheme, + int *misalignment, gather_scatter_info *gs_info) { loop_vec_info loop_vinfo = dyn_cast (vinfo); @@ -2294,10 +2295,16 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, if (*memory_access_type == VMAT_GATHER_SCATTER || *memory_access_type == VMAT_ELEMENTWISE) - *alignment_support_scheme = dr_unaligned_supported; + { + *alignment_support_scheme = dr_unaligned_supported; + *misalignment = DR_MISALIGNMENT_UNKNOWN; + } else - *alignment_support_scheme - = vect_supportable_dr_alignment (vinfo, first_dr_info, vectype); + { + *alignment_support_scheme + = vect_supportable_dr_alignment (vinfo, first_dr_info, vectype); + *misalignment = dr_misalignment (first_dr_info, vectype); + } if (vls_type != VLS_LOAD && first_stmt_info == stmt_info) { @@ -2337,7 +2344,9 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, storing it in *MEMORY_ACCESS_TYPE if so. If we decide to use gathers or scatters, fill in GS_INFO accordingly. In addition *ALIGNMENT_SUPPORT_SCHEME is filled out and false is returned if - the target does not support the alignment scheme. + the target does not support the alignment scheme. *MISALIGNMENT + is set according to the alignment of the access (including + DR_MISALIGNMENT_UNKNOWN when it is unknown). SLP says whether we're performing SLP rather than loop vectorization. MASKED_P is true if the statement is conditional on a vectorized mask. @@ -2351,10 +2360,12 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, unsigned int ncopies, vect_memory_access_type *memory_access_type, dr_alignment_support *alignment_support_scheme, + int *misalignment, gather_scatter_info *gs_info) { loop_vec_info loop_vinfo = dyn_cast (vinfo); poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype); + *misalignment = DR_MISALIGNMENT_UNKNOWN; if (STMT_VINFO_GATHER_SCATTER_P (stmt_info)) { *memory_access_type = VMAT_GATHER_SCATTER; @@ -2402,7 +2413,8 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, if (!get_group_load_store_type (vinfo, stmt_info, vectype, slp_node, masked_p, vls_type, memory_access_type, - alignment_support_scheme, gs_info)) + alignment_support_scheme, + misalignment, gs_info)) return false; } else if (STMT_VINFO_STRIDED_P (stmt_info)) @@ -2439,6 +2451,8 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, = vect_supportable_dr_alignment (vinfo, STMT_VINFO_DR_INFO (stmt_info), vectype); + *misalignment = dr_misalignment (STMT_VINFO_DR_INFO (stmt_info), + vectype); } } @@ -7337,9 +7351,10 @@ vectorizable_store (vec_info *vinfo, vect_memory_access_type memory_access_type; enum dr_alignment_support alignment_support_scheme; + int misalignment; if (!get_load_store_type (vinfo, stmt_info, vectype, slp_node, mask, vls_type, ncopies, &memory_access_type, - &alignment_support_scheme, &gs_info)) + &alignment_support_scheme, &misalignment, &gs_info)) return false; if (mask) @@ -8218,14 +8233,13 @@ vectorizable_store (vec_info *vinfo, gcc_assert (aligned_access_p (first_dr_info, vectype)); misalign = 0; } - else if (dr_misalignment (first_dr_info, vectype) - == DR_MISALIGNMENT_UNKNOWN) + else if (misalignment == DR_MISALIGNMENT_UNKNOWN) { align = dr_alignment (vect_dr_behavior (vinfo, first_dr_info)); misalign = 0; } else - misalign = dr_misalignment (first_dr_info, vectype); + misalign = misalignment; if (dataref_offset == NULL_TREE && TREE_CODE (dataref_ptr) == SSA_NAME) set_ptr_info_alignment (get_ptr_info (dataref_ptr), align, @@ -8693,9 +8707,10 @@ vectorizable_load (vec_info *vinfo, vect_memory_access_type memory_access_type; enum dr_alignment_support alignment_support_scheme; + int misalignment; if (!get_load_store_type (vinfo, stmt_info, vectype, slp_node, mask, VLS_LOAD, ncopies, &memory_access_type, - &alignment_support_scheme, &gs_info)) + &alignment_support_scheme, &misalignment, &gs_info)) return false; if (mask) @@ -9553,14 +9568,14 @@ vectorizable_load (vec_info *vinfo, gcc_assert (aligned_access_p (first_dr_info, vectype)); misalign = 0; } - else if (dr_misalignment (first_dr_info, vectype) == -1) + else if (misalignment == DR_MISALIGNMENT_UNKNOWN) { align = dr_alignment (vect_dr_behavior (vinfo, first_dr_info)); misalign = 0; } else - misalign = dr_misalignment (first_dr_info, vectype); + misalign = misalignment; if (dataref_offset == NULL_TREE && TREE_CODE (dataref_ptr) == SSA_NAME) set_ptr_info_alignment (get_ptr_info (dataref_ptr),