From patchwork Thu Jul 21 07:01:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 56213 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 C157A3856DF5 for ; Thu, 21 Jul 2022 07:01:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C157A3856DF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658386900; bh=f+yrePizEKVHexbbBXIwJNkxA5n5HYjYo8Wsgnman0g=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yGDbjnuTTWYg5oLfPophmlC+ohELIi4iVfkVHFm1KmKVxdOQUgHP+BUaT+9vLFFYj wgO8WBf1nJ1PkGOQI0oc36sdXgijyHT5WH676MpfBWJBEBZJM1roPhdOo7YKlm4oF0 +Mxh7L3Kkqaemw/4BEzEHDP+qnA8bWZJsIJf1zEI= 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 [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 7D85A3856DEC for ; Thu, 21 Jul 2022 07:01:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D85A3856DEC 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 AAFD720F49 for ; Thu, 21 Jul 2022 07:01:07 +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 95AEC139FC for ; Thu, 21 Jul 2022 07:01:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id jX5DI7P52GLKBQAAMHmgww (envelope-from ) for ; Thu, 21 Jul 2022 07:01:07 +0000 Date: Thu, 21 Jul 2022 09:01:07 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Add alias disambiguation for vectorizer load/store IFNs MIME-Version: 1.0 Message-Id: <20220721070107.95AEC139FC@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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" The following adds support for MASK_STORE, MASK_LOAD and friends to call_may_clobber_ref_p and ref_maybe_used_by_call_p. Since they all use a special argument to specify TBAA they are not really suited for fnspec handling thus the manual support. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR106365 shows this can be important though in many cases seen there we miss PTA info. * tree-ssa-alias.cc (ref_maybe_used_by_call_p_1): Special-case store internal functions and IFN_MASK_LOAD, IFN_LEN_LOAD and IFN_MASK_LOAD_LANES. (call_may_clobber_ref_p_1): Special-case IFN_MASK_STORE, IFN_LEN_STORE and IFN_MASK_STORE_LANES. --- gcc/tree-ssa-alias.cc | 49 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index 782266bdad8..390cd875074 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see #include "print-tree.h" #include "tree-ssa-alias-compare.h" #include "builtins.h" +#include "internal-fn.h" /* Broad overview of how alias analysis on gimple works: @@ -2793,8 +2794,38 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref, bool tbaa_p) if (ref->volatile_p) return true; - callee = gimple_call_fndecl (call); + if (gimple_call_internal_p (call)) + switch (gimple_call_internal_fn (call)) + { + case IFN_MASK_STORE: + case IFN_SCATTER_STORE: + case IFN_MASK_SCATTER_STORE: + case IFN_LEN_STORE: + return false; + case IFN_MASK_STORE_LANES: + goto process_args; + case IFN_MASK_LOAD: + case IFN_LEN_LOAD: + case IFN_MASK_LOAD_LANES: + { + ao_ref rhs_ref; + tree lhs = gimple_call_lhs (call); + if (lhs) + { + ao_ref_init_from_ptr_and_size (&rhs_ref, + gimple_call_arg (call, 0), + TYPE_SIZE_UNIT (TREE_TYPE (lhs))); + rhs_ref.ref_alias_set = rhs_ref.base_alias_set + = tbaa_p ? get_deref_alias_set (TREE_TYPE + (gimple_call_arg (call, 1))) : 0; + return refs_may_alias_p_1 (ref, &rhs_ref, tbaa_p); + } + break; + } + default:; + } + callee = gimple_call_fndecl (call); if (callee != NULL_TREE) { struct cgraph_node *node = cgraph_node::get (callee); @@ -3005,7 +3036,7 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref, bool tbaa_p) & (ECF_PURE|ECF_CONST|ECF_LOOPING_CONST_OR_PURE|ECF_NOVOPS)) return false; if (gimple_call_internal_p (call)) - switch (gimple_call_internal_fn (call)) + switch (auto fn = gimple_call_internal_fn (call)) { /* Treat these internal calls like ECF_PURE for aliasing, they don't write to any memory the program should care about. @@ -3018,6 +3049,20 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref, bool tbaa_p) case IFN_UBSAN_PTR: case IFN_ASAN_CHECK: return false; + case IFN_MASK_STORE: + case IFN_LEN_STORE: + case IFN_MASK_STORE_LANES: + { + tree rhs = gimple_call_arg (call, + internal_fn_stored_value_index (fn)); + ao_ref lhs_ref; + ao_ref_init_from_ptr_and_size (&lhs_ref, gimple_call_arg (call, 0), + TYPE_SIZE_UNIT (TREE_TYPE (rhs))); + lhs_ref.ref_alias_set = lhs_ref.base_alias_set + = tbaa_p ? get_deref_alias_set + (TREE_TYPE (gimple_call_arg (call, 1))) : 0; + return refs_may_alias_p_1 (ref, &lhs_ref, tbaa_p); + } default: break; }