From patchwork Tue Jul 4 08:39:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 115619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1066011vqx; Tue, 4 Jul 2023 01:40:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPS+ZmEpdicXpqj9rrC+0stcAyuChrpPUeP7iT8QnAxn//q2RFNuvpk1HTZMkZeBcYhLOP X-Received: by 2002:a17:906:a88b:b0:98b:dc6c:b304 with SMTP id ha11-20020a170906a88b00b0098bdc6cb304mr9360612ejb.38.1688460046493; Tue, 04 Jul 2023 01:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688460046; cv=none; d=google.com; s=arc-20160816; b=NHWzHC1N3mXjo5KmjawNGvx95lzyZAl04NBha3wzCog55Y6r3cVeQSfDhmX91+exsV 2zB/nWl9nFRgOpEWe150DNrisz2FJZgprsJRnopSv4Hq8HHDQbC5sOZD8cGdFPCtL7+P JpXbBKVJTY8RuS0HXx0ZM14/A1DIfP+618FjR/sfLQRqYPEgytycoxSu2iVB7zozeS9n W8Qxbl5RDzeicZeIrgtymvErKvIFz71OZA9LagVgRnRINWArFgnTm9x86Cc515HV/GdN ZfA54F5NZS5UJ9lFeVFsimqr0nEoulA3MhojlVOkukWbhfx6NYMoCqINdtq1+YqKkfqf CFiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:cc:to:date:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=URzk19ElWZTBU1ox/Jcm7419DTaus90XbXVVPrJdfzk=; fh=BLfb0g6CdYzWRvkpY1O/Sj8oMG0A1T6mQlpiBtlfuoA=; b=E9MMotEAhI3Hc4xbj3iwjW2bIR/TUxFXoCovk/yunYgjKR7s3WadwHIHdno53dV301 fZ8/l3IjmKwpelr8RPhKURlJDZqSpjPhfjZKlHn8wp4tKfSVheg5FT7slCUrJ+H6MnDf pS6oeM4QYvo2mQdImpf/jxld/WCtdnwAPk7iR+puB1HT3kGCRD4aLKJ/brIwj+2NsRKP xEniWJJPHvSNXofa29iS7KW1kLElXj53S8bIm3l8Z/brptAN91AltRfLMyRzU3jsNvqz 9bWEp2muoR0SR19ddp8jQFoq+OvtV6M0fJVPOTndbLKHUythvFs/C3TJIsSSgQMDK30F skrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=NSnsRvJg; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j18-20020a170906831200b0098891bbc6fdsi12436899ejx.292.2023.07.04.01.40.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 01:40:46 -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=NSnsRvJg; 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 233AB3858C30 for ; Tue, 4 Jul 2023 08:40:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 233AB3858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688460045; bh=URzk19ElWZTBU1ox/Jcm7419DTaus90XbXVVPrJdfzk=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NSnsRvJgN3Tdrd9NVExYgloHaLBBdKVgatEsyWgFDIacMzKLH7iLCWfLWo+QeVvTx YhjuhN0wt7y2R8w0jRvNA+NWZLjSOXr1OeciYbeejkBxznIjisdHmLxRW2TbfFIXaS nKFdR9ar3DHnEckuXEGWc8ZmD893Ved6uAwuV81c= 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 DB5453858C30 for ; Tue, 4 Jul 2023 08:40:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB5453858C30 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 19CFD225D1; Tue, 4 Jul 2023 08:40:00 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 0E4072C141; Tue, 4 Jul 2023 08:40:00 +0000 (UTC) Date: Tue, 4 Jul 2023 08:39:59 +0000 (UTC) To: gcc-patches@gcc.gnu.org cc: andre.simoesdiasvieira@arm.com Subject: [PATCH] tree-optimization/110436 - bogus live/relevant for unused pattern User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, 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 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" Message-Id: <20230704084045.233AB3858C30@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770478681767920903?= X-GMAIL-MSGID: =?utf-8?q?1770478681767920903?= When we compute liveness and relevantness we have to make sure to handle live but not relevant stmts in a way we can later vectorize them. When the stmt uses only operands that do not need vectorization we can just leave such stmts in place - but not in the case they are recognized as patterns. Since we don't have a way to cancel pattern recognition we have to force mark such stmts as relevant. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/110436 * tree-vect-stmts.cc (vect_mark_relevant): Expand dumping, force live but not relevant pattern stmts relevant. * gcc.dg/pr110436.c: New testcase. --- gcc/testsuite/gcc.dg/pr110436.c | 4 ++++ gcc/tree-vect-stmts.cc | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr110436.c diff --git a/gcc/testsuite/gcc.dg/pr110436.c b/gcc/testsuite/gcc.dg/pr110436.c new file mode 100644 index 00000000000..8e63ca04cbe --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110436.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +#include "pr83089.c" diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index a0c39268bf0..c3e6f2d34ed 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -261,11 +261,26 @@ vect_mark_relevant (vec *worklist, stmt_vec_info stmt_info, dump_printf_loc (MSG_NOTE, vect_location, "last stmt in pattern. don't mark" " relevant/live.\n"); + stmt_vec_info old_stmt_info = stmt_info; stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == old_stmt_info); save_relevant = STMT_VINFO_RELEVANT (stmt_info); save_live_p = STMT_VINFO_LIVE_P (stmt_info); + + if (live_p && relevant == vect_unused_in_scope) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "vec_stmt_relevant_p: forcing live patern stmt " + "relevant.\n"); + relevant = vect_used_only_live; + } + + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "mark relevant %d, live %d: %G", relevant, live_p, + stmt_info->stmt); } STMT_VINFO_LIVE_P (stmt_info) |= live_p;