From patchwork Wed Oct 19 03:18:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 4421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp104243wrs; Tue, 18 Oct 2022 20:19:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fOqhzOSPLq9+aqDqn+rLvBaRyFbQfw4fhLpxLjGqrIz5RpulsDnUJbnPZ1T0FBSTpMbjX X-Received: by 2002:a05:6402:1913:b0:45d:fe2:40 with SMTP id e19-20020a056402191300b0045d0fe20040mr5369558edz.353.1666149595865; Tue, 18 Oct 2022 20:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666149595; cv=none; d=google.com; s=arc-20160816; b=xjpUHR/6uL7OJI9MpMQ8YJJbBKq+mQQObHhgDyGO7xZgVblahzJjX2vn2kM266N+OF NGzG1ylQjKudgAwPgdz7gmQQE2y6eo2oKI1RnQ/8z7WaLB0Ho5CLdzYcrdRBQ57m2Dym ebdVDKeqG5FzbE9ygSwhaDeKtyaOBLM6y+QcQV7USjheLfkXoKxYolWAQ1xst6SNKooR uj25erBWq/gSgNC5oCMTXQCB2/hEHi/cAuI9zkEPu5UhqS77O2xZDtb5vwp2KYtWKceE qcgM5TrXHxBB0Cj6WAd8MNVXZnwCXMvE4E3AT0S+gxkQAcpI2p+0lUYNirOiZ8d0b7Rj ycUA== 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 :content-transfer-encoding:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=xljZ062+MrNEfKEe2Uv9KejKqWRQ9xnAi4ydjkbj/Iw=; b=R24PmK2TD5C2KOtG7mi6btXr/YpmihQD2upF8i8Q5qkjiT1ylColWbizi2NF1ymmTg G2QbqFHQNOcHGw0mmnxH0NCMOLJY3P+EPjrlMqnIlUH8kxUlly+va7enothl4inFHFKE 84VIQESysZTeBuIT7sfWOHcI3DsM6F8Np0JSqIeqVz4M03O+h3YKdqxecubKj8/Sup0R GYlTVYY/nSE0RlQtMZIYxt/rmdyS74try0MkCk0J6I3MLG3tOQfIhvUlc739FTrxCQwv 8tqDCBj6rqAD0+h1CfUEKTKrj4QrFpht0sRBvEBwFTXWUukE7KXZM8NlhGLXmLWDmWKU sU+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=W7WBEzlc; 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 l15-20020a170906794f00b0078d2a84f2f8si14444505ejo.645.2022.10.18.20.19.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 20:19:55 -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=W7WBEzlc; 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 D56B3385735C for ; Wed, 19 Oct 2022 03:19:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D56B3385735C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666149578; bh=xljZ062+MrNEfKEe2Uv9KejKqWRQ9xnAi4ydjkbj/Iw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=W7WBEzlc+dToHNCnMcMdcWGJIppZPXz3Y2I3GcB+dRyKvafD/72RtaE5j6ZPMbffk BlJIC8SO7u/nkNcKv01KryGrgiMQB0dexbEtE3c7kbet8NDNAOBnvCiMzSFASf2JUI Zm3yBt169aXrQ05Csmdho5kDWOi1+c9KH2rfjLtg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id A51113858D39 for ; Wed, 19 Oct 2022 03:18:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A51113858D39 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29J3DArZ029963; Wed, 19 Oct 2022 03:18:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ka94wr3rv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 03:18:51 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29J3GoQH008158; Wed, 19 Oct 2022 03:18:50 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ka94wr3r0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 03:18:50 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29J37EZm002208; Wed, 19 Oct 2022 03:18:48 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 3k7m4jpas3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 03:18:48 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29J3Iksr8127210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Oct 2022 03:18:46 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 37F15A405B; Wed, 19 Oct 2022 03:18:46 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58B12A4054; Wed, 19 Oct 2022 03:18:44 +0000 (GMT) Received: from [9.197.229.72] (unknown [9.197.229.72]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 19 Oct 2022 03:18:44 +0000 (GMT) Message-ID: <31c05be7-64bf-8d93-934c-63262e082e68@linux.ibm.com> Date: Wed, 19 Oct 2022 11:18:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: GCC Patches Subject: [PATCH] vect: Try folding first for shifted value generation [PR107240] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: KZSQHTkyVV34wkfAX61SLVO8q_PujTyd X-Proofpoint-GUID: FKlpL9g6zKgPu1QZuUtlcssu7AVMyUib X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-18_10,2022-10-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=978 adultscore=0 impostorscore=0 mlxscore=0 bulkscore=0 clxscore=1011 priorityscore=1501 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210190015 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Cc: Richard Sandiford , Segher Boessenkool 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?1747084478832744933?= X-GMAIL-MSGID: =?utf-8?q?1747084478832744933?= Hi, As PR107240 shows, when both the value to be shifted and the count used for shifting are constants, it doesn't actually requires a target to support vector shift operations. This patch is to try fold_build2 for the generation of the shifted value first, if it's folded, the shift is gone, otherwise it's the same as before. It can help to make the failures of vect-bitfield-write-{2,3}.c gone on Power. Bootstrapped and regtested on x86_64-redhat-linux, aarch64-linux-gnu and powerpc64{,le}-linux-gnu. Is it ok for trunk? BR, Kewen ----- PR tree-optimization/107240 gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_bit_insert_pattern): Attempt to fold shifted value. --- gcc/tree-vect-patterns.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.27.0 diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 6afd57a50c4..3beda774ec3 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -2098,9 +2098,11 @@ vect_recog_bit_insert_pattern (vec_info *vinfo, stmt_vec_info stmt_info, tree shifted = value; if (shift_n) { + tree shifted_tmp + = fold_build2 (LSHIFT_EXPR, container_type, value, shift); pattern_stmt = gimple_build_assign (vect_recog_temp_ssa_var (container_type), - LSHIFT_EXPR, value, shift); + shifted_tmp); append_pattern_def_seq (vinfo, stmt_info, pattern_stmt); shifted = gimple_get_lhs (pattern_stmt); }