From patchwork Wed Feb 8 05:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 54179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3261449wrn; Tue, 7 Feb 2023 21:09:24 -0800 (PST) X-Google-Smtp-Source: AK7set+8zuvLvboipI1czvuP4bQfiKFfiT0A0cSP66YkANX0tX5NU/4zg1W0flt3gr59+U78sobR X-Received: by 2002:a50:ba8e:0:b0:4a2:358e:e734 with SMTP id x14-20020a50ba8e000000b004a2358ee734mr5615531ede.7.1675832964702; Tue, 07 Feb 2023 21:09:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675832964; cv=none; d=google.com; s=arc-20160816; b=hbxMqLVFyJ5hpVEfTqjDq6Js7cJ87ETDWq1FJDPwubTwk64UaAqSZaZgzJ50Xlx1jb XFYurdcAy1j7dhSATIFztDWsl/rqsalxxrUJFrPPgy38dhJmLsfNtbFBb01h5p3hGQKj oJW/9Z9r3uJ7lGR/yfTiU201R3E2Xs2hWkOx+o4jEOMZg/FGPqgpxXIelU2tEwCPbW+X fFLWECoioH/tLCu+yN3EUUsgOstqDjB/rrtchMmBFM4QhKQEkjK7AYYBMjxuzcRVFBdi M8d3k5ocbEo38Mql2DM4jqfEQ4cpx8XxAC8MGhJ/b4XfCx/VGdzc5Ub4TRr+r1BfRwv0 Uj+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:cc:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=uN3FKLte7dzvUphBoV/Q4FZ9Y6SncRYaQVCydD5wzgA=; b=vfvxJHflROc5+Do40V+S+R7wcLp1vk0P08VBu0pXKjwwDH6HcAuw50lkwtVDzu77Rj 9axO7OsMEYmvn3MeJZw2Vk7J/SI0TM8i4lMXoOs27HhaiaB7tbAuYIxctrfjuEQZ2t/O QRQEYgk0aomn49+lqxBQBlrv5KDdGQvNFJhiAYTFiiBAVBF6Goh7x7UqHPKb2zU4jROm nroJ7QfQLpQKT9M2MOI7W9KS+Fw0Ud5lPfBKgV+nDKuSXbPfJJOsWwxc4VLBbsfBaNZE bWiVFftatYe70af27y6+REPOp/ddHDM5G7KMDTOGg4hPqFBh6NB2FROdwZbN+MIcrbQ1 b03Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lJwwRoCH; 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 m17-20020a056402051100b004aad8cfeb37si306005edv.276.2023.02.07.21.09.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 21:09:24 -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=@gcc.gnu.org header.s=default header.b=lJwwRoCH; 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 7E3F238582AC for ; Wed, 8 Feb 2023 05:09:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E3F238582AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675832963; bh=uN3FKLte7dzvUphBoV/Q4FZ9Y6SncRYaQVCydD5wzgA=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=lJwwRoCHDc3sDfpp43DgP+7HIONwiEuDi2EfP+WAuGVO8sO5RQkMJdTjf2LqTUMWd OriBzrdsCTJxwU+rtqYTieEVN2t/x3v6CSpKVBEDMXjhdWo2jaFa87s3bS/7oOr/5B x0V+7oRn+8oC4IGIZTRjlqwlZeojD/YKOkLt+sn4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 447643858D39 for ; Wed, 8 Feb 2023 05:08:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 447643858D39 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3183nvCl025943; Wed, 8 Feb 2023 05:08:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nm467hkk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Feb 2023 05:08:37 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31855REn014385; Wed, 8 Feb 2023 05:08:36 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nm467hkjt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Feb 2023 05:08:36 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 317ErpMr005776; Wed, 8 Feb 2023 05:08:35 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3nhf06k3w8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Feb 2023 05:08:35 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31858VXG24314232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 Feb 2023 05:08:31 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BFBE2004B; Wed, 8 Feb 2023 05:08:31 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACE4420040; Wed, 8 Feb 2023 05:08:29 +0000 (GMT) Received: from [9.200.144.91] (unknown [9.200.144.91]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 8 Feb 2023 05:08:29 +0000 (GMT) Message-ID: <740e9ed6-8730-1dec-ca78-a002df8d431a@linux.ibm.com> Date: Wed, 8 Feb 2023 13:08:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner Subject: [PATCH, rs6000] Split TImode for logical operations in expand pass [PR100694] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NadvJHQ-_NyX-ybtJH6MNbB3TBFPd6_k X-Proofpoint-GUID: vfWD_DYM9IiOiWG5aDqYS4mawCB0Xzd8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-08_01,2023-02-06_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302080040 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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: HAO CHEN GUI via Gcc-patches From: HAO CHEN GUI Reply-To: HAO CHEN GUI 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?1757238226907101514?= X-GMAIL-MSGID: =?utf-8?q?1757238226907101514?= Hi, The logical operations for TImode is split after reload pass right now. Some potential optimizations miss as the split is too late. This patch removes TImode from "AND", "IOR", "XOR" and "NOT" expander so that these logical operations can be split at expand pass. The new test case illustrates the optimization. Two test cases of pr92398 are merged into one as all sub-targets generates the same sequence of instructions with the patch. Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Thanks Gui Haochen ChangeLog 2023-02-08 Haochen Gui gcc/ PR target/100694 * config/rs6000/rs6000.md (BOOL_128_V): New mode iterator for 128-bit vector types. (and3): Replace BOOL_128 with BOOL_128_V. (ior3): Likewise. (xor3): Likewise. (one_cmpl2 expander): New expander with BOOL_128_V. (one_cmpl2 insn_and_split): Rename to ... (*one_cmpl2): ... this. gcc/testsuite/ PR target/100694 * gcc.target/powerpc/pr100694.c: New. * gcc.target/powerpc/pr92398.c: New. * gcc.target/powerpc/pr92398.h: Remove. * gcc.target/powerpc/pr92398.p9-.c: Remove. * gcc.target/powerpc/pr92398.p9+.c: Remove. patch.diff diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 4bd1dfd3da9..455b7329643 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -743,6 +743,15 @@ (define_mode_iterator BOOL_128 [TI (V2DF "TARGET_ALTIVEC") (V1TI "TARGET_ALTIVEC")]) +;; Mode iterator for logical operations on 128-bit vector types +(define_mode_iterator BOOL_128_V [(V16QI "TARGET_ALTIVEC") + (V8HI "TARGET_ALTIVEC") + (V4SI "TARGET_ALTIVEC") + (V4SF "TARGET_ALTIVEC") + (V2DI "TARGET_ALTIVEC") + (V2DF "TARGET_ALTIVEC") + (V1TI "TARGET_ALTIVEC")]) + ;; For the GPRs we use 3 constraints for register outputs, two that are the ;; same as the output register, and a third where the output register is an ;; early clobber, so we don't have to deal with register overlaps. For the @@ -7135,23 +7144,23 @@ (define_expand "subti3" ;; 128-bit logical operations expanders (define_expand "and3" - [(set (match_operand:BOOL_128 0 "vlogical_operand") - (and:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand") - (match_operand:BOOL_128 2 "vlogical_operand")))] + [(set (match_operand:BOOL_128_V 0 "vlogical_operand") + (and:BOOL_128_V (match_operand:BOOL_128_V 1 "vlogical_operand") + (match_operand:BOOL_128_V 2 "vlogical_operand")))] "" "") (define_expand "ior3" - [(set (match_operand:BOOL_128 0 "vlogical_operand") - (ior:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand") - (match_operand:BOOL_128 2 "vlogical_operand")))] + [(set (match_operand:BOOL_128_V 0 "vlogical_operand") + (ior:BOOL_128_V (match_operand:BOOL_128_V 1 "vlogical_operand") + (match_operand:BOOL_128_V 2 "vlogical_operand")))] "" "") (define_expand "xor3" - [(set (match_operand:BOOL_128 0 "vlogical_operand") - (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand") - (match_operand:BOOL_128 2 "vlogical_operand")))] + [(set (match_operand:BOOL_128_V 0 "vlogical_operand") + (xor:BOOL_128_V (match_operand:BOOL_128_V 1 "vlogical_operand") + (match_operand:BOOL_128_V 2 "vlogical_operand")))] "" "") @@ -7449,7 +7458,14 @@ (define_insn_and_split "*eqv3_internal2" (const_string "16")))]) ;; 128-bit one's complement -(define_insn_and_split "one_cmpl2" +(define_expand "one_cmpl2" +[(set (match_operand:BOOL_128_V 0 "vlogical_operand" "=") + (not:BOOL_128_V + (match_operand:BOOL_128_V 1 "vlogical_operand" "")))] + "" + "") + +(define_insn_and_split "*one_cmpl2" [(set (match_operand:BOOL_128 0 "vlogical_operand" "=") (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")))] diff --git a/gcc/testsuite/gcc.target/powerpc/pr100694.c b/gcc/testsuite/gcc.target/powerpc/pr100694.c new file mode 100644 index 00000000000..96a895d6c44 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr100694.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times {(?n)^\s+[a-z]} 3 } } */ + +/* It just needs two std and one blr. */ +void foo (unsigned __int128* res, unsigned long long hi, unsigned long long lo) +{ + unsigned __int128 i = hi; + i <<= 64; + i |= lo; + *res = i; +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.c b/gcc/testsuite/gcc.target/powerpc/pr92398.c new file mode 100644 index 00000000000..7d6201cc5bb --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr92398.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times {\mnot\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mstd\M} 2 } } */ + +/* All platforms should generate the same instructions: not;not;std;std. */ +void bar (__int128_t *dst, __int128_t src) +{ + *dst = ~src; +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.h b/gcc/testsuite/gcc.target/powerpc/pr92398.h deleted file mode 100644 index 5a4a8bcab80..00000000000 --- a/gcc/testsuite/gcc.target/powerpc/pr92398.h +++ /dev/null @@ -1,17 +0,0 @@ -/* This test code is included into pr92398.p9-.c and pr92398.p9+.c. - The two files have the tests for the number of instructions generated for - P9- versus P9+. - - store generates difference instructions as below: - P9+: mtvsrdd;xxlnot;stxv. - P8/P7/P6 LE: not;not;std;std. - P8 BE: mtvsrd;mtvsrd;xxpermdi;xxlnor;stxvd2x. - P7/P6 BE: std;std;addi;lxvd2x;xxlnor;stxvd2x. - P9+ and P9- LE are expected, P6/P7/P8 BE are unexpected. */ - -void -bar (__int128_t *dst, __int128_t src) -{ - *dst = ~src; -} - diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.p9+.c b/gcc/testsuite/gcc.target/powerpc/pr92398.p9+.c deleted file mode 100644 index 72dd1d9a274..00000000000 --- a/gcc/testsuite/gcc.target/powerpc/pr92398.p9+.c +++ /dev/null @@ -1,12 +0,0 @@ -/* { dg-do compile { target { lp64 && has_arch_pwr9 } } } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ -/* { dg-options "-O2 -mvsx" } */ - -/* { dg-final { scan-assembler-times {\mmtvsrdd\M} 1 } } */ -/* { dg-final { scan-assembler-times {\mxxlnor\M} 1 } } */ -/* { dg-final { scan-assembler-times {\mstxv\M} 1 } } */ -/* { dg-final { scan-assembler-not {\mld\M} } } */ -/* { dg-final { scan-assembler-not {\mnot\M} } } */ - -/* Source code for the test in pr92398.h */ -#include "pr92398.h" diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.p9-.c b/gcc/testsuite/gcc.target/powerpc/pr92398.p9-.c deleted file mode 100644 index bd7fa98af51..00000000000 --- a/gcc/testsuite/gcc.target/powerpc/pr92398.p9-.c +++ /dev/null @@ -1,10 +0,0 @@ -/* { dg-do compile { target { lp64 && {! has_arch_pwr9} } } } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ -/* { dg-options "-O2 -mvsx" } */ - -/* { dg-final { scan-assembler-times {\mnot\M} 2 { xfail be } } } */ -/* { dg-final { scan-assembler-times {\mstd\M} 2 { xfail { { {! has_arch_pwr9} && has_arch_pwr8 } && be } } } } */ - -/* Source code for the test in pr92398.h */ -#include "pr92398.h" -