From patchwork Wed Dec 14 11:21:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 33160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp153541wrn; Wed, 14 Dec 2022 03:22:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ygy9JHrUNVfw5wgyMTa71kGJXKCpiI9cKpeOF567gcZhMyKQ16lAfpEQfilovCbMCcJGk X-Received: by 2002:a17:906:a007:b0:7be:e26a:6104 with SMTP id p7-20020a170906a00700b007bee26a6104mr21392845ejy.52.1671016937253; Wed, 14 Dec 2022 03:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671016937; cv=none; d=google.com; s=arc-20160816; b=WrKJcjVqBxKhTwmy+q3+rNJkNfWaJMvNDDRPB5G9I8sBv02CiBv0GqywTS+FUUpv98 mIv8iTPu8J0GMHsWXQj8z+dRlz55zQPx/kigka4H6uoo/agzni/66rfTLKxXseW8AwYU +LZ30MvExffoF0wZk3NK7e5y5UpazAYSAcTc5jlNk4kOQTN03IAQvdN5m0ZKk3tSUO7H 74sJbVqzdRMQLdY7W/2sY9cmGRl+0qVxyxfzje9FYbDI5owjlF9gIJC3oWjk8k00BaeJ rajIJSzzxipNIQ1//oJdtlZLJx56pIl4zysYicf7ijf+ubD5B3hR1NIK4GMraaYGYB2N Hujg== 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:mime-version :content-transfer-encoding:subject:cc:to:content-language:user-agent :date:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=5pN90LWJ2sPgQxT//8R7clVr6llDz7WIFnsAIAuFlOM=; b=d3XeV7dtpQHK/cXKEaLyMFLPw/sSiDKI7W5Gp4z5WraPbD+iM6TsPvDOapYqU0rtdI ZHM+1GF5Ti9G0pYqKtLDTMR/IM7C0QTgD0QFSa46oAZs28ge39EORQ7+BIichqZMmDLq MFWivcjXi9bMWVXb8cjBESL63a2f0O78hKU/LTZDlWHs8DIT8G+gtDwfXTtkQy1ENcqY qSNq/NhEd4eViNDnWbrPFGdpXZmtFN60F/WDEHrmS05KULBWZek8vmlOx4PaKQzKeXm0 t5Psw4t+eLH9BttfOjmMu6Cq7p8tVyVPAO3vT0cOnuyz7hdJ9eH0ccjkiIY6TRV0Fm1u EdAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qmBWZNhl; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qw38-20020a1709066a2600b007ae26c753edsi12065772ejc.52.2022.12.14.03.22.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 03:22:17 -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=@gcc.gnu.org header.s=default header.b=qmBWZNhl; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B0383830FF2 for ; Wed, 14 Dec 2022 11:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B0383830FF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671016936; bh=5pN90LWJ2sPgQxT//8R7clVr6llDz7WIFnsAIAuFlOM=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=qmBWZNhlATf/DETstAJasmAQ0E6QA/s+m+zViZ2wlZ6fPmtPRTw0CQvvmcJcdC7RW RGAT1v1xKhp4FAPA2Z5HJuxwd9LnCDqT7KHUodjLb484pl9Oy7J8mfXTLAS9HeWsWP XU7QyABKmS/JQejDmyv1s3LvJATnsQH0htcsquAw= 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 0A74E3830FEA for ; Wed, 14 Dec 2022 11:21:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0A74E3830FEA Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BEArofO005937; Wed, 14 Dec 2022 11:21:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mfd4m0nhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 11:21:29 +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 2BEBKuBP027281; Wed, 14 Dec 2022 11:21:29 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mfd4m0ngk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 11:21:28 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BEAOMQe001043; Wed, 14 Dec 2022 11:21:26 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3meyyeh1kk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 11:21:26 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BEBLOYJ44827024 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Dec 2022 11:21:24 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BACC20040; Wed, 14 Dec 2022 11:21:24 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 261CB20043; Wed, 14 Dec 2022 11:21:22 +0000 (GMT) Received: from [9.197.253.236] (unknown [9.197.253.236]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 14 Dec 2022 11:21:21 +0000 (GMT) Message-ID: <055fe22a-9fae-f6b1-c7a8-36ccc37fa9a8@linux.ibm.com> Date: Wed, 14 Dec 2022 19:21:20 +0800 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 Cc: Segher Boessenkool , Peter Bergner , David Edelsohn , Richard Sandiford Subject: [PATCH] rs6000: Raise error for __vector_{quad, pair} uses without MMA enabled [PR106736] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: DzO5yNZf3q3PAHR8JaYWo-MG2FqzM_Vm X-Proofpoint-ORIG-GUID: Byq7ZhcdD_iy1GDReheVM9zQpM6T2n9Z X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-14_04,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 clxscore=1015 phishscore=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212140087 X-Spam-Status: No, score=-11.3 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" 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?1752188256222981335?= X-GMAIL-MSGID: =?utf-8?q?1752188256222981335?= Hi, As PR106736 shows, it's unexpected to use __vector_quad and __vector_pair types without MMA support, it would cause ICE when expanding the corresponding assignment. We can't guard these built-in types registering under MMA support as Peter pointed out in that PR, because the registering is global, it doesn't work for target pragma/attribute support with MMA enabled. The existing verify_type_context mentioned in [2] can help to make the diagnostics invalid built-in type uses better, but as Richard pointed out in [4], it can't deal with all cases. As the discussions in [1][3], this patch is to check the invalid use of built-in types __vector_quad and __vector_pair in mov pattern of OOmode and XOmode, on the currently being expanded gimple assignment statement. It still puts an assertion in else arm rather than just makes it go through, it's to ensure we can catch any other possible unexpected cases in time if there are. Bootstrapped and regtested on powerpc64-linux-gnu P8, powerpc64le-linux-gnu P9 and P10. I'm going to push this next week if no objections. [1] https://gcc.gnu.org/pipermail/gcc/2022-December/240218.html [2] https://gcc.gnu.org/pipermail/gcc/2022-December/240220.html [3] https://gcc.gnu.org/pipermail/gcc/2022-December/240223.html [4] https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608083.html BR, Kewen ----- PR target/106736 gcc/ChangeLog: * config/rs6000/mma.md (define_expand movoo): Call function rs6000_opaque_type_invalid_use_p to check and emit error message for the invalid use of opaque type. (define_expand movxo): Likewise. * config/rs6000/rs6000-protos.h (rs6000_opaque_type_invalid_use_p): New function declaration. (currently_expanding_gimple_stmt): New extern declaration. * config/rs6000/rs6000.cc (rs6000_opaque_type_invalid_use_p): New function. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr106736-1.c: New test. * gcc.target/powerpc/pr106736-2.c: Likewise. * gcc.target/powerpc/pr106736-3.c: Likewise. * gcc.target/powerpc/pr106736-4.c: Likewise. * gcc.target/powerpc/pr106736-5.c: Likewise. --- gcc/config/rs6000/mma.md | 10 ++++- gcc/config/rs6000/rs6000-protos.h | 2 + gcc/config/rs6000/rs6000.cc | 39 ++++++++++++++++++- gcc/testsuite/gcc.target/powerpc/pr106736-1.c | 20 ++++++++++ gcc/testsuite/gcc.target/powerpc/pr106736-2.c | 17 ++++++++ gcc/testsuite/gcc.target/powerpc/pr106736-3.c | 18 +++++++++ gcc/testsuite/gcc.target/powerpc/pr106736-4.c | 19 +++++++++ gcc/testsuite/gcc.target/powerpc/pr106736-5.c | 18 +++++++++ 8 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106736-1.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106736-2.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106736-3.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106736-4.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106736-5.c -- 2.27.0 diff --git a/gcc/config/rs6000/mma.md b/gcc/config/rs6000/mma.md index 032f4263cb0..f2952a3c3be 100644 --- a/gcc/config/rs6000/mma.md +++ b/gcc/config/rs6000/mma.md @@ -285,8 +285,11 @@ (define_expand "movoo" expanding to RTL and have seen errors. It would not cause further ICEs as the compilation would stop soon after expanding. */ } + else if (rs6000_opaque_type_invalid_use_p (currently_expanding_gimple_stmt)) + ; else - gcc_unreachable (); + /* Catch unexpected cases. */ + gcc_assert (false); }) (define_insn_and_split "*movoo" @@ -329,8 +332,11 @@ (define_expand "movxo" some missing required conditions. So do the same handlings for XOmode as OOmode here. */ } + else if (rs6000_opaque_type_invalid_use_p (currently_expanding_gimple_stmt)) + ; else - gcc_unreachable (); + /* Catch unexpected cases. */ + gcc_assert (false); }) (define_insn_and_split "*movxo" diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index d0d89320ef6..d6cf6f87f54 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -344,4 +344,6 @@ extern rtx rs6000_gen_lvx (enum machine_mode, rtx, rtx); extern rtx rs6000_gen_stvx (enum machine_mode, rtx, rtx); extern void rs6000_emit_xxspltidp_v2df (rtx, long value); +extern gimple *currently_expanding_gimple_stmt; +extern bool rs6000_opaque_type_invalid_use_p (gimple *); #endif /* rs6000-protos.h */ diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index eb7ad5e954f..70e93c54483 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -28834,7 +28834,44 @@ constant_generates_xxspltidp (vec_const_128bit_type *vsx_const) return sf_value; } - +/* Now we have only two opaque types, they are __vector_quad and + __vector_pair built-in types. They are target specific and + only available when MMA is supported. With MMA supported, it + simply returns true, otherwise it checks if the given gimple + STMT is an assignment stmt and uses either of these two opaque + types unexpectedly, if yes, it would raise an error message + and returns true, otherwise it returns false. */ + +bool +rs6000_opaque_type_invalid_use_p (gimple *stmt) +{ + if (TARGET_MMA) + return false; + + if (stmt) + { + /* The usage of MMA opaque types is very limited for now, + to check with gassign is enough so far. */ + if (gassign *ga = dyn_cast (stmt)) + { + tree lhs = gimple_assign_lhs (ga); + tree type = TREE_TYPE (lhs); + if (type == vector_quad_type_node) + { + error ("type %<__vector_quad%> requires the %qs option", "-mmma"); + return true; + } + else if (type == vector_pair_type_node) + { + error ("type %<__vector_pair%> requires the %qs option", "-mmma"); + return true; + } + } + } + + return false; +} + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-rs6000.h" diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-1.c b/gcc/testsuite/gcc.target/powerpc/pr106736-1.c new file mode 100644 index 00000000000..65bd79d3dce --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106736-1.c @@ -0,0 +1,20 @@ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* If the default cpu type is power10 or later, type __vector_quad is + supported. To keep the test point available all the time, this case + specifies -mdejagnu-cpu=power9 here. */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +/* Verify there is no ICE and don't check the error messages on unsupported + type since they could be fragile and are not test points of this case. */ + +/* { dg-excess-errors "pr106736-1" } */ + +extern void bar (__vector_quad *); + +void +foo (__vector_quad *a, __vector_quad *b) +{ + __vector_quad arr[2] = {*a, *b}; + bar (&arr[0]); +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-2.c b/gcc/testsuite/gcc.target/powerpc/pr106736-2.c new file mode 100644 index 00000000000..12ad936fccc --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106736-2.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* If the default cpu type is power10 or later, type __vector_pair is + supported. To keep the test point available all the time, this case + specifies -mdejagnu-cpu=power9 here. */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +/* Verify there is no ICE and don't check the error messages on unsupported + type since they could be fragile and are not test points of this case. */ + +/* { dg-excess-errors "pr106736-2" } */ + +void +foo (__vector_pair *a, __vector_pair *b) +{ + *a = *b; +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-3.c b/gcc/testsuite/gcc.target/powerpc/pr106736-3.c new file mode 100644 index 00000000000..4fb368b8fb5 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106736-3.c @@ -0,0 +1,18 @@ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* If the default cpu type is power10 or later, type __vector_quad is + supported. To keep the test point available all the time, this case + specifies -mdejagnu-cpu=power9 here. */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +/* Verify there is no ICE and don't check the error messages on unsupported + type since they could be fragile and are not test points of this case. */ + +/* { dg-excess-errors "pr106736-3" } */ + +__vector_quad ga; +void +foo (__vector_quad *a) +{ + ga = *a; +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-4.c b/gcc/testsuite/gcc.target/powerpc/pr106736-4.c new file mode 100644 index 00000000000..4b366416b0a --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106736-4.c @@ -0,0 +1,19 @@ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* If the default cpu type is power10 or later, type __vector_quad is + supported. To keep the test point available all the time, this case + specifies -mdejagnu-cpu=power9 here. */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +/* Verify there is no ICE and don't check the error messages on unsupported + type since they could be fragile and are not test points of this case. */ + +/* { dg-excess-errors "pr106736-4" } */ + +__vector_quad ga; +__vector_quad gb; +void +foo () +{ + gb = ga; +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-5.c b/gcc/testsuite/gcc.target/powerpc/pr106736-5.c new file mode 100644 index 00000000000..d7370b81e81 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106736-5.c @@ -0,0 +1,18 @@ +/* { dg-require-effective-target powerpc_p9modulo_ok } */ +/* If the default cpu type is power10 or later, type __vector_pair is + supported. To keep the test point available all the time, this case + specifies -mdejagnu-cpu=power9 here. */ +/* { dg-options "-mdejagnu-cpu=power9" } */ + +/* Verify there is no ICE and don't check the error messages on unsupported + type since they could be fragile and are not test points of this case. */ + +/* { dg-excess-errors "pr106736-5" } */ + +__vector_pair ga; +void +foo (__vector_pair *a) +{ + *a = ga; +} +