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: 1691783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=h8e6fBIY; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MsbYj4jX2z23kb for ; Wed, 19 Oct 2022 14:19:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EDA9C3858C83 for ; Wed, 19 Oct 2022 03:19:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDA9C3858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666149555; 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=h8e6fBIYJKMcoiQEqLn5ACvrCl4tUkNBdSEUiTbFAOeALyRCjOE7UmmDg8H0s0Fx2 Kr9Xu54SZfCJ/Kka4v2E3GnmniFFNtLhWaNVgTUT69nQFdr4tEo5sOGQV56GEF7a24 P0eyvk5uYDim9Mo4JNIWTM0i2zRxdppU6mOweG9E= 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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); }