From patchwork Thu Oct 13 03:10:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liwei Xu X-Patchwork-Id: 1973 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp66776wrs; Wed, 12 Oct 2022 20:11:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7R5JMonN6So/K0v57tmiYTatb9Y1tKmu7hn8nWnj6j+SAyELM+HvgUnbJa8E6LOEMU7ALH X-Received: by 2002:a17:907:724b:b0:782:f2bb:24d3 with SMTP id ds11-20020a170907724b00b00782f2bb24d3mr24459404ejc.555.1665630670349; Wed, 12 Oct 2022 20:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665630670; cv=none; d=google.com; s=arc-20160816; b=OukV0MlgFU/Lxudwdx5y8CsvsAtxGtu98rrVpr0CLqCCoXag8tb6W1ERZ6j/OeZqgr TBOgEeRgjJvHlSdZwbxIJfhim/9PZAHWXwl2vAWWg+pc7ByRgeGj/rxY7kg6khXOVcR2 2zs3LneCgDIpBkVrVZ8rbz2fdSkhuIRjx6BrKRLPS3tZHdwy2lHDWA7cl3SEnpdbu8eo /avL7nuzIYacRoKkkJCYxfyEeDPut5bus993tLPq/uXt2iUKi28pED0DjdXaGUO5uSAb ecZfHtoyArZogzEzNkfbcseMOwOvm5BaWelNOXB17dxITNfKePxCw4Yqf8NnCO0vX/2W DtCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=mkn/M13sxZJuoaUfPV+vllrYV/PMmgJFRoeTHC56ago=; b=sbFmaijTrvQZo+dDb1A+evgW0NTqMSV3oHK5CJUfEq8/6zcn4pZawjJzHSWz7kqb/P 1Brc/JpMc0xByTXk4GdPcLBVv/kfqwAhZTzXsV5lp/BQgw9zmuCSSgPFinID9+bjOUfa GeJj6qigAp33N4mtWexxb2cHWiIX2INrw3ZpJbPnANVLc+curtPZWSsC0Ahtw+LwLYcF mwRreZG/NaL64toq4Jj6vJXAs2/qCafuTfQrsMO9SMjj/9ptd4LEImOpQadzIRdPWuiQ 6InL6mDRQOzu4Uvj+hJTRHGpUIQ+WafL/FT/JruRtqn5Amcr2NSlXbC2kjoPBaw+KN8v 3OLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=L3D8ifOj; 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 hz5-20020a1709072ce500b007824b741e7asi16908891ejc.236.2022.10.12.20.11.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 20:11:10 -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=L3D8ifOj; 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 A965C38207C9 for ; Thu, 13 Oct 2022 03:10:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A965C38207C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665630659; bh=mkn/M13sxZJuoaUfPV+vllrYV/PMmgJFRoeTHC56ago=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=L3D8ifOjP5WVMFVCAaIM8LTp16vci96tcW5Koj6Ma5NektSlhZQPS2fuhMY5sBxd5 l0j6xeT909sblzy1s+CuKWUA4iEiVD6Pca08tSn+h0oIlNzam8viXvO6ysjKyrPG7J CN3wM7rcUws9reBshKiHdSMxkCKimatZgg+gtXwk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by sourceware.org (Postfix) with ESMTPS id 71896381FE47 for ; Thu, 13 Oct 2022 03:10:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 71896381FE47 X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="306596660" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="306596660" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2022 20:10:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="716165526" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="716165526" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by FMSMGA003.fm.intel.com with ESMTP; 12 Oct 2022 20:10:11 -0700 Received: from shliclel314.sh.intel.com (shliclel314.sh.intel.com [10.239.240.214]) by shvmail03.sh.intel.com (Postfix) with ESMTP id CAF531005629; Thu, 13 Oct 2022 11:10:10 +0800 (CST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Optimize indentical permuation in my last r13-3212-gb88adba751da63 Date: Thu, 13 Oct 2022 11:10:09 +0800 Message-Id: <20221013031009.60175-1-liwei.xu@intel.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, 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: Liwei Xu via Gcc-patches From: Liwei Xu Reply-To: Liwei Xu Cc: wilson@tuliptree.org, admin@levyhsu.com 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?1746540346163109936?= X-GMAIL-MSGID: =?utf-8?q?1746540346163109936?= Add extra index check when merging VEC_CST, this handles the case when exactly op1 needs to be return. This fixes: FAIL: gcc.dg/tree-ssa/forwprop-19.c scan-tree-dump-not forwprop1 "VEC_PERM_EXPR" gcc/ChangeLog: PR target/107220 * match.pd: Check the index of VEC_CST and return the op1 if needed. --- gcc/match.pd | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/match.pd b/gcc/match.pd index 3550c16aaa6..1efdc3abb5d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -8106,6 +8106,7 @@ and, vec_perm_builder builder0; vec_perm_builder builder1; vec_perm_builder builder2 (nelts, nelts, 1); + bool ident_to_1 = true; if (!tree_to_vec_perm_builder (&builder0, @3) || !tree_to_vec_perm_builder (&builder1, @4)) @@ -8115,7 +8116,15 @@ and, vec_perm_indices sel1 (builder1, 1, nelts); for (int i = 0; i < nelts; i++) - builder2.quick_push (sel0[sel1[i].to_constant ()]); + { + int tmp_index = sel0[sel1[i].to_constant ()].to_constant (); + builder2.quick_push (sel0[sel1[i].to_constant ()]); + if ( i != tmp_index) + ident_to_1 = false; + } + + if (ident_to_1) + return @1; vec_perm_indices sel2 (builder2, 2, nelts);