From patchwork Mon Oct 18 14:15:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 46349 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 BA9B83858433 for ; Mon, 18 Oct 2021 14:15:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA9B83858433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634566544; bh=GBihBjaCknklekwr3dfnvhhgoC71gwX35zJ7838Hl/s=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=bYpmorAkWJKrG0mi76iSZcDced2yr/4VO0vAqV0UlLSK7Bl7Qq0+6ONsjKCdX4vhT o0ln7MPHZ1SXrdL3wnqQ8VguRNptj8Zeks6o5JK6o3LJLgcrqzlWiAvVqrSxZqtKNn lWJCR05DA4MPOStFY/rXlZH8b+WENTW2bVPYQGtE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id A985C3858402 for ; Mon, 18 Oct 2021 14:15:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A985C3858402 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-out2.suse.de (Postfix) with ESMTPS id 66FF31FD6D for ; Mon, 18 Oct 2021 14:15:14 +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 52FDF13E74 for ; Mon, 18 Oct 2021 14:15:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iLkDE3KBbWGvdwAAMHmgww (envelope-from ) for ; Mon, 18 Oct 2021 14:15:14 +0000 Date: Mon, 18 Oct 2021 16:15:14 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Apply TLC to vect_supportable_dr_alignment Message-ID: 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 fixes handling of the return value of vect_supportable_dr_alignment in multiple places. We should use the enum type and not int for storage and not auto-convert the enum return value to bool. It also commonizes the read/write path in vect_supportable_dr_alignment. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-10-18 Richard Biener * tree-vect-data-refs.c (vect_peeling_hash_insert): Do not auto-convert dr_alignment_support to bool. (vect_peeling_supportable): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_supportable_dr_alignment): Commonize read/write case. * tree-vect-stmts.c (vect_get_store_cost): Use dr_alignment_support, not int, for the vect_supportable_dr_alignment result. (vect_get_load_cost): Likewise. --- gcc/tree-vect-data-refs.c | 45 ++++++++++++++------------------------- gcc/tree-vect-stmts.c | 4 ++-- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index a19045f7e46..4c9215874c9 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -1471,7 +1471,8 @@ vect_peeling_hash_insert (hash_table *peeling_htab, _vect_peel_info **new_slot; tree vectype = STMT_VINFO_VECTYPE (dr_info->stmt); bool supportable_dr_alignment - = vect_supportable_dr_alignment (loop_vinfo, dr_info, vectype, true); + = (vect_supportable_dr_alignment (loop_vinfo, dr_info, vectype, true) + != dr_unaligned_unsupported); elem.npeel = npeel; slot = peeling_htab->find (&elem); @@ -1663,7 +1664,7 @@ vect_peeling_supportable (loop_vec_info loop_vinfo, dr_vec_info *dr0_info, = vect_supportable_dr_alignment (loop_vinfo, dr_info, vectype, false); SET_DR_MISALIGNMENT (dr_info, save_misalignment); - if (!supportable_dr_alignment) + if (supportable_dr_alignment == dr_unaligned_unsupported) return false; } @@ -1999,11 +2000,11 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) /* Check for data refs with unsupportable alignment that can be peeled. */ - if (!supportable_dr_alignment) - { - one_dr_unsupportable = true; - unsupportable_dr_info = dr_info; - } + if (supportable_dr_alignment == dr_unaligned_unsupported) + { + one_dr_unsupportable = true; + unsupportable_dr_info = dr_info; + } if (!first_store && DR_IS_WRITE (dr)) { @@ -2356,7 +2357,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) supportable_dr_alignment = vect_supportable_dr_alignment (loop_vinfo, dr_info, vectype, false); - if (!supportable_dr_alignment) + if (supportable_dr_alignment == dr_unaligned_unsupported) { if (known_alignment_for_access_p (dr_info, vectype) || LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo).length () @@ -6720,9 +6721,6 @@ vect_supportable_dr_alignment (vec_info *vinfo, dr_vec_info *dr_info, if (DR_IS_READ (dr)) { - bool is_packed = false; - tree type = (TREE_TYPE (DR_REF (dr))); - if (optab_handler (vec_realign_load_optab, mode) != CODE_FOR_nothing && (!targetm.vectorize.builtin_mask_for_load || targetm.vectorize.builtin_mask_for_load ())) @@ -6744,26 +6742,15 @@ vect_supportable_dr_alignment (vec_info *vinfo, dr_vec_info *dr_info, else return dr_explicit_realign_optimized; } - if (!known_alignment_for_access_p (dr_info, vectype)) - is_packed = not_size_aligned (DR_REF (dr)); - - if (targetm.vectorize.support_vector_misalignment - (mode, type, dr_misalignment (dr_info, vectype), is_packed)) - /* Can't software pipeline the loads, but can at least do them. */ - return dr_unaligned_supported; } - else - { - bool is_packed = false; - tree type = (TREE_TYPE (DR_REF (dr))); - - if (!known_alignment_for_access_p (dr_info, vectype)) - is_packed = not_size_aligned (DR_REF (dr)); - if (targetm.vectorize.support_vector_misalignment - (mode, type, dr_misalignment (dr_info, vectype), is_packed)) - return dr_unaligned_supported; - } + bool is_packed = false; + tree type = (TREE_TYPE (DR_REF (dr))); + if (!known_alignment_for_access_p (dr_info, vectype)) + is_packed = not_size_aligned (DR_REF (dr)); + if (targetm.vectorize.support_vector_misalignment + (mode, type, dr_misalignment (dr_info, vectype), is_packed)) + return dr_unaligned_supported; /* Unsupported. */ return dr_unaligned_unsupported; diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 07123a2970f..eaf3f0abef3 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1027,7 +1027,7 @@ vect_get_store_cost (vec_info *vinfo, stmt_vec_info stmt_info, int ncopies, { dr_vec_info *dr_info = STMT_VINFO_DR_INFO (stmt_info); tree vectype = STMT_VINFO_VECTYPE (stmt_info); - int alignment_support_scheme + dr_alignment_support alignment_support_scheme = vect_supportable_dr_alignment (vinfo, dr_info, vectype, false); switch (alignment_support_scheme) @@ -1218,7 +1218,7 @@ vect_get_load_cost (vec_info *vinfo, stmt_vec_info stmt_info, int ncopies, { dr_vec_info *dr_info = STMT_VINFO_DR_INFO (stmt_info); tree vectype = STMT_VINFO_VECTYPE (stmt_info); - int alignment_support_scheme + dr_alignment_support alignment_support_scheme = vect_supportable_dr_alignment (vinfo, dr_info, vectype, false); switch (alignment_support_scheme)