From patchwork Mon Nov 20 13:59:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 167147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2216418vqn; Mon, 20 Nov 2023 06:00:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1gblIoDBqacaFRRvIiztboeyZOwezhpqB5G7zvh7jgsMFCiBUk30lN7itD9BeFxjIAbkm X-Received: by 2002:a05:6870:e2d0:b0:1f4:d9a6:d4ee with SMTP id w16-20020a056870e2d000b001f4d9a6d4eemr9001508oad.12.1700488834374; Mon, 20 Nov 2023 06:00:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700488834; cv=pass; d=google.com; s=arc-20160816; b=xMoVIKLZNm5oIkBNNxjneSYtxUJpncokWsHWrvq/bLsRSsp81CqF1MBxsCaofl+H6n kbeRIO8VawLMQT0IaqupCHH0/6MVvg9rTm38m9DZozFO9GRzzPMCVbzNZOvUFbwhPUB9 AiXt1xAv+FXHNoqNjsBfFy/ygaYagBiGNROvJlbyaL2ViTfNM1ukpIF7kfr7dk0Z+DDt jsr7vf5hfJytDB2+j9G8T8Ftt08/6Xp8ejlPbWh6hCjYod51t9t+YcnrXUYKl/laNVux vmgO3Y6EQCyOKhil/ZxsFpCMLleVgg+PRrFsSpoHXxj7U4jT1AV1mYzIBnuCy9ORV8qV dNIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:subject:to:from:date:dkim-signature:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=xiGq547xZ5sJ6XaDiWg+icQxdbbIXlb8eZ78dzu5HU8=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=al51T3R5YJ3t+/MhmGXtyM2piOFxtlMsarSXRn+nGE6kQ0ltQ4AbSSeiKS+TOZFyr4 SUWYCtvS06icblbzOlS0ySwCVhHYM0224fr9AuHHPi4mo8fegYE/rZQLeoTGHdBL+Dwg 0h+2egzrOAaa8j+jkOOBRrlQnhfvriJwqJqZc2TwZUW5Qyr73Fwxp/5AA5j3eLV8J+Gv 9kmjOhvv43HOQeMjgAMddSn9xTBJU1o2WLCSmTPAKELOT0pOR52f6pcBEtnkzqq3tqVu QaFk/LvyouUkZPF3ZI0Wpv8KJDUgqRduLhFblF/LoKX+w5Nv+3zmIOT+CCLGxv49+CQt lhfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=P7pnjPyh; dkim=neutral (no key) header.i=@suse.de header.b=KSXurk34; arc=pass (i=1); 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=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a11-20020a05622a02cb00b0041eadf10883si7582262qtx.163.2023.11.20.06.00.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 06:00:34 -0800 (PST) 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=@suse.de header.s=susede2_rsa header.b=P7pnjPyh; dkim=neutral (no key) header.i=@suse.de header.b=KSXurk34; arc=pass (i=1); 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=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 591B83891C17 for ; Mon, 20 Nov 2023 14:00:23 +0000 (GMT) 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 2BA7338582AD for ; Mon, 20 Nov 2023 13:59:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2BA7338582AD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2BA7338582AD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700488799; cv=none; b=C9A35wLiDHP+EefZv4LmSjulqT3/pyCkGzrC4/D/LTKlxljTWXd/Bagaa76n7DBy0TlH2jKndU20dE2bXZSH7qEuuQPdrKWqoyx64jKFs19fu983WPtxi+ASlx+CyBhJ9DYu/oLtzcTCJgDtzwqksqG+NJXleXn/XA2BpDDYKBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700488799; c=relaxed/simple; bh=xmFB9oXuZBSaLlhq+teoewZBucg0H+svuIT6PnKOjco=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version; b=gQahb3bW1SwdHSUKVOFKsEqDULNPPGAMWWtM2dciQg7I40cmQJfrH0qpSJ+ZcmjCSz4nBI7TIcKsuhqvJM8Eh5OPmHk5YdYtLSIi1tPkqis24gpgWqKAZD1Gq79yHtir6vzHqG0FF/grun+4iM6d5WrP+XI4cWuBUfk6MreTJPA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0DC5B218D6 for ; Mon, 20 Nov 2023 13:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700488797; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=xiGq547xZ5sJ6XaDiWg+icQxdbbIXlb8eZ78dzu5HU8=; b=P7pnjPyh8Ptz0bLmgpHqToIQEPuh5PEQmF1pkKd4n+HrwtebifyHrS+gAUNUl6p+5pb1iP vCQGC3dGaua4miypamTxr6fWHFYLfnZngVyEyljDnyHHyToLlg3QPiW3VgZce3NYO/8XIW F2+3iklyR0WGqlygVmhgGufbpcD1qWA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700488797; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=xiGq547xZ5sJ6XaDiWg+icQxdbbIXlb8eZ78dzu5HU8=; b=KSXurk34QuUqcEo7smgXamoYxNiLZc3fSkQ8tw371KvHlSaczqcOTC3DZ3KtPD2Lp3J/ps RRQAsM2+X4tNMyCw== 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 F2EAF2C191 for ; Mon, 20 Nov 2023 13:59:56 +0000 (UTC) Date: Mon, 20 Nov 2023 13:59:56 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/112618 - unused .MASK_CALL User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spamd-Bar: ++++++++++++++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 149.44.160.134 is neither permitted nor denied by domain of rguenther@suse.de) smtp.mailfrom=rguenther@suse.de X-Rspamd-Server: rspamd1 X-Spamd-Result: default: False [16.49 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; TO_DN_NONE(0.00)[]; R_SPF_SOFTFAIL(4.60)[~all:c]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MX_GOOD(-0.01)[]; NEURAL_SPAM_LONG(3.50)[1.000]; DMARC_NA(1.20)[suse.de]; VIOLATED_DIRECT_SPF(3.50)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 16.49 X-Rspamd-Queue-Id: 0DC5B218D6 X-Spam-Status: No, score=-10.7 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20231120140023.591B83891C17@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783091780145752714 X-GMAIL-MSGID: 1783091780145752714 We have to make sure to remove unused .MASK_CALL internal function calls after vectorization. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/112618 * tree-vect-loop.cc (vect_transform_loop_stmt): For not relevant and unused .MASK_CALL make sure we remove the scalar stmt. * gcc.dg/pr112618.c: New testcase. --- gcc/testsuite/gcc.dg/pr112618.c | 26 ++++++++++++++++++++++++++ gcc/tree-vect-loop.cc | 11 ++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr112618.c diff --git a/gcc/testsuite/gcc.dg/pr112618.c b/gcc/testsuite/gcc.dg/pr112618.c new file mode 100644 index 00000000000..897e6a8ed2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr112618.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int m, *p; + +__attribute__ ((simd)) int +bar (int x) +{ + if (x) + { + if (m < 1) + for (m = 0; m < 1; ++m) + ++x; + p = &x; + for (;;) + ++m; + } + return 0; +} + +__attribute__ ((simd)) int +foo (int x) +{ + bar (x); + return 0; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 92d2e0ef9be..5c2c1d8b971 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10520,7 +10520,16 @@ vect_transform_loop_stmt (loop_vec_info loop_vinfo, stmt_vec_info stmt_info, if (!STMT_VINFO_RELEVANT_P (stmt_info) && !STMT_VINFO_LIVE_P (stmt_info)) - return false; + { + if (is_gimple_call (stmt_info->stmt) + && gimple_call_internal_p (stmt_info->stmt, IFN_MASK_CALL)) + { + gcc_assert (!gimple_call_lhs (stmt_info->stmt)); + *seen_store = stmt_info; + return false; + } + return false; + } if (STMT_VINFO_VECTYPE (stmt_info)) {