From patchwork Tue Mar 21 13:04:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 72856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1762939wrt; Tue, 21 Mar 2023 06:05:01 -0700 (PDT) X-Google-Smtp-Source: AK7set8KSwy49Eo/rgDExwbkPP2gf7UM9KfZPNkI11w9STMoHaaYsny0VCU0StmHur9jYeVlpILc X-Received: by 2002:a05:6402:3da:b0:4af:81f1:5afb with SMTP id t26-20020a05640203da00b004af81f15afbmr17230279edw.14.1679403901156; Tue, 21 Mar 2023 06:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679403901; cv=none; d=google.com; s=arc-20160816; b=BTHbq12RXLDvNJym8CufYqy1ZV6GAuFH/rf/3kOHg92iOXO9YbZWrzKj8c1CdfdO7o ijgRo5l6H4StzThySPs5Zbwq5ywRKr59pAhl7hEVRuS4MZN0rTQHS5c9QxvRWCCQ88GQ +Qz+YP7aqG6dhUbXbD4g4owfUOgcYy7ZZuH73cpDXhaUFmOCcFLXBE2WyCTN+BK0GBTH HJqLNW8eK+zHElEGgqAPa0SGqaeFjgb6Rls/GEkOaDhRYgQe7sIflCPE9o41xIHYpp4X ZQvtuPW8FNyPi6NPqaPpivX3getRvFANesX6HBsqSpFQp0dUv9hIc0HttKZLTYKCAPy2 akew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=HDrxAtinN1QDW2py2TSAiliOK1WleXKC0u5OYU1PLB8=; b=yYY/4/KOp+ikBtvqUlVQquiFHnegSrz0m6ewLQGs3uIDvMJbkG3WIvf6wxoIGu24jX OsQ/laHm6HG8mu/btsxcwnFpmeMFt/kPpGbQOu99shi/X6dIlfFT3UylKrYnP4HIC7nH lZAf5qSS/e/HJ/jWXjap3hglF/o7eMh+ZRL0jEZdwFTHMsPLWf68djGG84mTL8/wtI8U pWvLjh5BebWMNr/+8/la+w4lapiNfWw9F2HwE+zdra6mT9AoYML9CjT4L3/xUstid1Nf bbsKgxZNkzIvcPCm9I9uvQ9Dmnvvx8oP/082PoUMk8VoetUl80jxGENbRxlY4xaOF4nf a+LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dnBYHT9O; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u15-20020aa7db8f000000b00501c1f1a0fesi6330442edt.590.2023.03.21.06.05.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 06:05:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dnBYHT9O; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF1883858436 for ; Tue, 21 Mar 2023 13:04:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF1883858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679403897; bh=HDrxAtinN1QDW2py2TSAiliOK1WleXKC0u5OYU1PLB8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dnBYHT9OHweojn/AxjkBS+il1WYAyZylkH9PcXcYqeVZZPdMCmjv6CHDH7SJCsDIh IUG9LQKInjlcmFWEYJjELBMnheIbYbOsv8Du+wF1qUan6gFcR9mgrU8YiS8I+cqgse 0tNNBTlmVoB3v4MX51fhYRL9RYQMCXakYflV6ri8= 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 [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id D7A603858D37 for ; Tue, 21 Mar 2023 13:04:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7A603858D37 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 01F4D21E0A for ; Tue, 21 Mar 2023 13:04:10 +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 E34FE13440 for ; Tue, 21 Mar 2023 13:04:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 5NNVNkmrGWRFewAAMHmgww (envelope-from ) for ; Tue, 21 Mar 2023 13:04:09 +0000 Date: Tue, 21 Mar 2023 14:04:09 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/109219 - avoid looking at STMT_SLP_TYPE MIME-Version: 1.0 Message-Id: <20230321130409.E34FE13440@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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760982625069143375?= X-GMAIL-MSGID: =?utf-8?q?1760982625069143375?= The following avoids looking at STMT_SLP_TYPE apart from the only place needing it - transform and analysis of non-SLP loop stmts. In particular it doesn't have a reliable meaning on SLP representatives which are also passed as stmt_vinfo to vectorizable_* routines. The proper way to check in those is to look for the slp_node argument instead. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed to trunk sfoar. PR tree-optimization/109219 * tree-vect-loop.cc (vectorizable_reduction): Check slp_node, not STMT_SLP_TYPE. * tree-vect-stmts.cc (vectorizable_condition): Likewise. * tree-vect-slp.cc (vect_slp_analyze_node_operations_1): Remove assertion on STMT_SLP_TYPE. * gcc.dg/torture/pr109219.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr109219.c | 21 +++++++++++++++++++++ gcc/tree-vect-loop.cc | 2 +- gcc/tree-vect-slp.cc | 2 -- gcc/tree-vect-stmts.cc | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr109219.c diff --git a/gcc/testsuite/gcc.dg/torture/pr109219.c b/gcc/testsuite/gcc.dg/torture/pr109219.c new file mode 100644 index 00000000000..2b5c514ad85 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr109219.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ftree-vectorize" } */ + +int safe_lshift_func_int32_t_s_s_left, safe_lshift_func_int32_t_s_s_right, + safe_sub_func_uint64_t_u_u_ui2, safe_mul_func_uint64_t_u_u_ui2, g_79_2, + g_97_l_439; +void g_97(int * __restrict l_437) +{ + for (; g_97_l_439; g_97_l_439 += 1) + for (char l_502 = 0; l_502 < 4; l_502++) + { + int __trans_tmp_14 = ((safe_lshift_func_int32_t_s_s_right >= 2 + || safe_lshift_func_int32_t_s_s_left) + ? 1 : safe_lshift_func_int32_t_s_s_right); + long __trans_tmp_15 = __trans_tmp_14 * safe_mul_func_uint64_t_u_u_ui2; + unsigned short __trans_tmp_16 = -__trans_tmp_15; + int __trans_tmp_7 + = (__trans_tmp_16 ^ 65535UL) - safe_sub_func_uint64_t_u_u_ui2; + *l_437 ^= (short)(__trans_tmp_7 ^ g_79_2); + } +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 320c15f144b..1ba9f18d73e 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -7424,7 +7424,7 @@ vectorizable_reduction (loop_vec_info loop_vinfo, } /* Check extra constraints for variable-length unchained SLP reductions. */ - if (STMT_SLP_TYPE (stmt_info) + if (slp_node && !REDUC_GROUP_FIRST_ELEMENT (stmt_info) && !nunits_out.is_constant ()) { diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 9a4e000925e..356bdfb93d9 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -5951,8 +5951,6 @@ vect_slp_analyze_node_operations_1 (vec_info *vinfo, slp_tree node, return true; } - gcc_assert (STMT_SLP_TYPE (stmt_info) != loop_vect); - bool dummy; return vect_analyze_stmt (vinfo, stmt_info, &dummy, node, node_instance, cost_vec); diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index f5e7561d8c8..efa2d0daa52 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -10510,7 +10510,7 @@ vectorizable_condition (vec_info *vinfo, = STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info)) != NULL; if (for_reduction) { - if (STMT_SLP_TYPE (stmt_info)) + if (slp_node) return false; reduc_info = info_for_reduction (vinfo, stmt_info); reduction_type = STMT_VINFO_REDUC_TYPE (reduc_info);