From patchwork Wed Nov 15 23:50:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 165631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2883149vqg; Wed, 15 Nov 2023 15:50:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmkSLqV08/BI/zVw+fENz9aiopbbj6mLOFo8ZTvGXK+eJnXECviYMYgZccZ9aN6wdGcbEK X-Received: by 2002:a05:6870:3c12:b0:1ea:8645:6352 with SMTP id gk18-20020a0568703c1200b001ea86456352mr14842808oab.11.1700092248419; Wed, 15 Nov 2023 15:50:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700092248; cv=pass; d=google.com; s=arc-20160816; b=yzglOxnpT1pbHSYG7VwZchQi2bQigrGJ4pP0oDZfW+EMEZglqJV3mqx1gi6GfQnRzw o/2mQYbnrPsItYOLAjwCjMMwaGjmgGCvjJ9GabZghw3eXC4WEOVM9RV7bkYfeGNLJden FnsM95a/k2ItX5OBAht7CR6+RLwB+rmY9ayeDgn3N/WwKN9g+ezV7N+CLPztKByaq/PR mbLKM+jAoD0ZiJGJ/ZU+SMiSRFb5kbU63rg8EYUQWtvw+9pmte+lO1t7E+QGA/r2Q8Ev 8ywrd1BY6W5SNH6Asd6/x9dyILBLl1pLxP3Y+0hdd8CLRST0lwuaM8APnfqwqvYF4l4R gwpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=MNdJGIe2QaxVk617T4j6V7JOQn0QLxibXZbA7HzEPaQ=; fh=+OHC9cW//0SS67Wd2rg0Yc7DFmx2GNSWzHu9QKH7kEM=; b=NRYwFn4aeikXXlD1hcqbebLoWpfOZ3+bnWywHmm9VnsoWdkr1ZR2zArbuTAp2pFcJB h/nEJz1l2ZcWClDCsuat1Zfz7dMvs0q0zZu3zdhR5Z6rWYt3hEKqlwlU3b93jb03cZ3E WMP/f8hVgG+StXXgWV7KxlQsqt5+P+0AJwnYPRjRtiiBrCwGiBuYt99o70ZNfSwU7+fi oW+zB9Q+ztwRgtaEzuJ41fI4mROgWOYUExlqECkhQtDpiZJuG+fkxSIW2RrvQKKNRqID BCrrrXoCccZIu/mA0O/OswXjXD1ug+cKTtIVtEeAIVmJExLB/huDaAZyIXlz0wDBVzQm +w4w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=FdAJHnFV; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a7-20020a05620a438700b00773bbc97627si11066697qkp.467.2023.11.15.15.50.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 15:50:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=FdAJHnFV; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EC6B3858CD1 for ; Wed, 15 Nov 2023 23:50:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 66A4B3858D32 for ; Wed, 15 Nov 2023 23:50:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66A4B3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 66A4B3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700092225; cv=none; b=VjP6kbMuK9LKqokmi3S6UplB+JMQZZBZLhJ2haYCouQvKzO0F+WExzdABexVZMFev7hgWQbRTNK1Ro0765FTfDDFKU3k06QtTw6e3q7b2aVTbg7Wm3/W6ySBh4Xc7fyhQB4Lp8FDWm0JUIlu6JR8gg2jpHAft4LQyL1FLz7hL7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700092225; c=relaxed/simple; bh=dDquBduH53OA9xMYqmXZbCBp0zcGvfqvsjzn029PgmE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=LFwRsNCMkqY7hBmZfKqbs8HP4+zJhRuAE9O/ETnRhPWA4+KmDCXosNbsAoXf743U+w7hkiEUb7x49cH27tdzs238cC8ll9lZoXJTc0iHrlDrMrWxefYS5P0CUTrYzI7KRtdmh6u2lZOqXyhxkeUO+2bWe8N6xHVNwws5RFuGDJM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFNbnhk022560; Wed, 15 Nov 2023 23:50:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : cc : from : subject : content-type : content-transfer-encoding; s=pp1; bh=MNdJGIe2QaxVk617T4j6V7JOQn0QLxibXZbA7HzEPaQ=; b=FdAJHnFV0T9xXIZxK7AsQLsn+7LcJFij+v2yZblbvkzM99+hr7bCA2a+tB6SNzQUnsAi VKA0skLtRZCbwGj1EvxjJgp64yFSPM08oLDRYBTTR5rSpWCI1lGhB/Zk0LZFd8Pc+zwb NKABtDntNe5Lz1DAMJWcdJjcIdWwUbn8QXa0A8sZYEr8DZncabkBhtXxJb8RIUOyNhCa zYinkhi9CHU1QFqqa1e+rQHZrdqnBsAgHTea8ejlmFXNtsH2sfwAYJDximvW8oU6Kvir TJnM9PXT2QnvwZNdLDRFUUyVWb0dlqTdVvJP5n/I/1m/VZirIjf9ALipFn2t//fH8mZn ZQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud7trr93m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 23:50:21 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AFNiq3s013940; Wed, 15 Nov 2023 23:50:21 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud7trr938-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 23:50:21 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFNKhFR017495; Wed, 15 Nov 2023 23:50:19 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uamayk54m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 23:50:19 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AFNoJhs18088622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Nov 2023 23:50:19 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3B1A58050; Wed, 15 Nov 2023 23:50:18 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53BD958045; Wed, 15 Nov 2023 23:50:18 +0000 (GMT) Received: from [9.61.149.35] (unknown [9.61.149.35]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Nov 2023 23:50:18 +0000 (GMT) Message-ID: <1f32e2bf-83c2-4664-b7f3-4a6996978a5e@linux.ibm.com> Date: Wed, 15 Nov 2023 17:50:17 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Segher Boessenkool , "Kewen.Lin" , David Edelsohn Cc: Michael Meissner , GCC Patches From: Peter Bergner Subject: [PATCH] rs6000: Disassemble opaque modes using subregs to allow optimizations [PR109116] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: WKG1Tb2ux2DeCSj9oC0XfFII0CblONDd X-Proofpoint-GUID: gOT_YPty1OZFO8tA0o0D7juPaCFRfqWJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_20,2023-11-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150187 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782675929612781287 X-GMAIL-MSGID: 1782675929612781287 PR109116 exposes an issue where using unspecs to access each vector component of an opaque mode variable leads to unneeded register copies, because our rtl optimizers cannot handle unspecs. Instead, use subregs to access each vector component of the opaque mode variable, which our optimizers know how to handle. I did not include a test case with the patch, since writing a test case that attempts to ensure we don't emit unneeded register copies is nearly impossible since those copies can still be generated for reasons other than the causes in this patch. I have verified that this patch does improve code generation for some unit tests and our AI libraries team has confirmed that performance of their tests improved when using this patch. This passed bootstrap and regtesting with no regressions on powerpc64le-linux and powerpc64-linux. Ok for trunk? Peter gcc/ PR target/109116 * config/rs6000/mma.md (vsx_disassemble_pair): Expand into a vector register sized subreg. * config/rs6000/mma.md (*vsx_disassemble_pair): Delete. (mma_disassemble_acc): Expand into a vector register sized subreg. (*mma_disassemble_acc): Delete. * config/rs6000/rs6000.cc (rs6000_modes_tieable_p): Allow vector modes to tie with OOmode. diff --git a/gcc/config/rs6000/mma.md b/gcc/config/rs6000/mma.md index 575751d477e..2ca405469e2 100644 --- a/gcc/config/rs6000/mma.md +++ b/gcc/config/rs6000/mma.md @@ -398,29 +398,8 @@ (define_expand "vsx_disassemble_pair" (match_operand 2 "const_0_to_1_operand")] "TARGET_MMA" { - rtx src; - int regoff = INTVAL (operands[2]); - src = gen_rtx_UNSPEC (V16QImode, - gen_rtvec (2, operands[1], GEN_INT (regoff)), - UNSPEC_MMA_EXTRACT); - emit_move_insn (operands[0], src); - DONE; -}) - -(define_insn_and_split "*vsx_disassemble_pair" - [(set (match_operand:V16QI 0 "mma_disassemble_output_operand" "=mwa") - (unspec:V16QI [(match_operand:OO 1 "vsx_register_operand" "wa") - (match_operand 2 "const_0_to_1_operand")] - UNSPEC_MMA_EXTRACT))] - "TARGET_MMA - && vsx_register_operand (operands[1], OOmode)" - "#" - "&& reload_completed" - [(const_int 0)] -{ - int reg = REGNO (operands[1]); - int regoff = INTVAL (operands[2]); - rtx src = gen_rtx_REG (V16QImode, reg + regoff); + int regoff = INTVAL (operands[2]) * GET_MODE_SIZE (V16QImode); + rtx src = simplify_gen_subreg (V16QImode, operands[1], OOmode, regoff); emit_move_insn (operands[0], src); DONE; }) @@ -472,29 +451,8 @@ (define_expand "mma_disassemble_acc" (match_operand 2 "const_0_to_3_operand")] "TARGET_MMA" { - rtx src; - int regoff = INTVAL (operands[2]); - src = gen_rtx_UNSPEC (V16QImode, - gen_rtvec (2, operands[1], GEN_INT (regoff)), - UNSPEC_MMA_EXTRACT); - emit_move_insn (operands[0], src); - DONE; -}) - -(define_insn_and_split "*mma_disassemble_acc" - [(set (match_operand:V16QI 0 "mma_disassemble_output_operand" "=mwa") - (unspec:V16QI [(match_operand:XO 1 "fpr_reg_operand" "d") - (match_operand 2 "const_0_to_3_operand")] - UNSPEC_MMA_EXTRACT))] - "TARGET_MMA - && fpr_reg_operand (operands[1], XOmode)" - "#" - "&& reload_completed" - [(const_int 0)] -{ - int reg = REGNO (operands[1]); - int regoff = INTVAL (operands[2]); - rtx src = gen_rtx_REG (V16QImode, reg + regoff); + int regoff = INTVAL (operands[2]) * GET_MODE_SIZE (V16QImode); + rtx src = simplify_gen_subreg (V16QImode, operands[1], XOmode, regoff); emit_move_insn (operands[0], src); DONE; }) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 5f56c3ed85b..f2efa46c147 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1964,9 +1964,12 @@ rs6000_hard_regno_mode_ok (unsigned int regno, machine_mode mode) static bool rs6000_modes_tieable_p (machine_mode mode1, machine_mode mode2) { - if (mode1 == PTImode || mode1 == OOmode || mode1 == XOmode - || mode2 == PTImode || mode2 == OOmode || mode2 == XOmode) - return mode1 == mode2; + if (mode1 == PTImode || mode1 == OOmode || mode1 == XOmode + || mode2 == PTImode || mode2 == XOmode) + return mode1 == mode2; + + if (mode2 == OOmode) + return ALTIVEC_OR_VSX_VECTOR_MODE (mode1); if (ALTIVEC_OR_VSX_VECTOR_MODE (mode1)) return ALTIVEC_OR_VSX_VECTOR_MODE (mode2);