From patchwork Wed Aug 31 23:36:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:a445:0:0:0:0:0 with SMTP id e5csp33428wra; Wed, 31 Aug 2022 16:37:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Kmvv26ZIMA5cdxVtjPrOjum7rj1S6Ze39hMPlOkdklxVMmPwbRNvs22JyDx2bqIQ/n/AZ X-Received: by 2002:a17:907:3d90:b0:741:346a:6e46 with SMTP id he16-20020a1709073d9000b00741346a6e46mr17060983ejc.279.1661989056677; Wed, 31 Aug 2022 16:37:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661989056; cv=none; d=google.com; s=arc-20160816; b=OIqtvEtVU/RJc2iPRb8WWIvmiH8vydPJD7XgC6aEYX4zvI8cNRnVKZFLx6hnAHCOeB C9vS5Kyq1GGQBxKHMEK+D2a6gsq7KpjwjC8wnj3nuydXkD5PyKwPAeg4EaOB8CX3/xlO fd9CcpkP0C3UWp1WMiV4vH0dDKnc5cj/nW9aTeIO88/oX3tzkX/j5/Wm8yKnFEGrXRu9 +ZA3pBywC9+tweWtQvn8Q/McASs4cx4xi9LQA3c8LkU6tSovzvNIYAkEqFqRvpM/gHD0 mBIKwNNl3xGa+KA9emxxU1qH6BJAA/6m+2yVuJ8nLgqYQLITMiPSbSwmBkFxxSNCoTSR fA5Q== 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=vXmh18D+FU3G2CNkLc663RvXNLhUITHa9+9u+xMkGOY=; b=zAoOg9mGmmczM/FX8S+jU7ymp46ywFXXwswj04IksHeBQeGGO7NSKIC7TX837p+tjC fJPgw1bX1pZUEGrc0nQlC/iI4xyZwTiRLj15JUpDLgC30KD4EL7JG9d2TeDlZe3hOQiM en5BuHc0Ehh+AVFiSFSWtUBTJMxZRafq6R+sbmHOdWoKxeQ+rAJAgftnGZMjSNAvc2tG KNj+tCIf2/8i1GqgT5khSlO0VRUTs2oChBmitbiewKnI/d3x0ZAfv9m8IT+2zcPmB8M8 KX+0DqlBgpQgObIzIVrTEOuS2VQ7KinE50P9gZI3n0ooWMpD7EF7bGvP5kaXoLKcTlIv OaRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eAz1ozM7; 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 i23-20020a50fc17000000b00446fdce2a62si402544edr.420.2022.08.31.16.37.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 16:37:36 -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=eAz1ozM7; 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 7618638515ED for ; Wed, 31 Aug 2022 23:37:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7618638515ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661989051; bh=vXmh18D+FU3G2CNkLc663RvXNLhUITHa9+9u+xMkGOY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=eAz1ozM7g1YQSRGpLsRSpJVPIbKzOSjfucvX0ZdSKsqYNSGjtGAmGaeJCiTjt+xVk +e2Vb/JMsUxZeKK3ySRTc2gTPLGXa9M7mWnsKhj+HSSpW9JnGS+KZljuKVeVqvhNHT W6SLtRTjd7182EW0UyeByA3nf3JTILm5eh5AUitg= 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 00C9F3858C55 for ; Wed, 31 Aug 2022 23:36:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 00C9F3858C55 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27VNK2BS027749; Wed, 31 Aug 2022 23:36:44 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jah7h0d5y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Aug 2022 23:36:44 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27VNLKBT016949; Wed, 31 Aug 2022 23:36:43 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma04wdc.us.ibm.com with ESMTP id 3j7aw9wjh5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Aug 2022 23:36:43 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27VNag7b8323742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Aug 2022 23:36:42 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCA32BE053; Wed, 31 Aug 2022 23:42:24 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E736BE051; Wed, 31 Aug 2022 23:42:24 +0000 (GMT) Received: from [9.160.4.32] (unknown [9.160.4.32]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 31 Aug 2022 23:42:24 +0000 (GMT) Message-ID: <12282b03-1673-bf87-a793-bb696c13d064@linux.ibm.com> Date: Wed, 31 Aug 2022 18:36:40 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Content-Language: en-US To: Segher Boessenkool Subject: [PATCH v2] rs6000: Don't ICE when we disassemble an MMA variable [PR101322] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: GOlVqTBuur50mIyEkfL4TdZ_Q_Ivincz X-Proofpoint-GUID: GOlVqTBuur50mIyEkfL4TdZ_Q_Ivincz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-31_14,2022-08-31_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 spamscore=0 clxscore=1015 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208310112 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_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Peter Bergner via Gcc-patches From: Peter Bergner Reply-To: Peter Bergner Cc: GCC Patches 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?1742284784039522356?= X-GMAIL-MSGID: =?utf-8?q?1742721836952205866?= Changes from v1: * Fix spelling typo in git log entry * Fix broken test checking src_ptr's type * Use NOP_EXPR rather than VIEW_CONVERT_EXPR * Change order of dg-options When we expand an MMA disassemble built-in with C++ using a pointer that is cast to a valid MMA type, the type isn't passed down to the expand machinery and we end up using the base type of the pointer which leads to an ICE. This patch enforces we always use the correct MMA type regardless of the pointer type being used. This passed bootstrap and regtesting on powerpc64le-linux with no regressions. Ok for trunk and backports after some burn-in time? Peter gcc/ PR target/101322 * config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_mma_builtin): Enforce the use of a valid MMA pointer type. gcc/testsuite/ PR target/101322 * g++.target/powerpc/pr101322.C: New test. diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index 12afa86854c..e6948b9abb7 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -1085,7 +1085,12 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi, unsigned nvec = (fncode == RS6000_BIF_DISASSEMBLE_ACC) ? 4 : 2; tree dst_ptr = gimple_call_arg (stmt, 0); tree src_ptr = gimple_call_arg (stmt, 1); - tree src_type = TREE_TYPE (src_ptr); + tree src_type = (fncode == RS6000_BIF_DISASSEMBLE_ACC) + ? build_pointer_type (vector_quad_type_node) + : build_pointer_type (vector_pair_type_node); + if (TREE_TYPE (src_ptr) != src_type) + src_ptr = build1 (NOP_EXPR, src_type, src_ptr); + tree src = create_tmp_reg_or_ssa_name (TREE_TYPE (src_type)); gimplify_assign (src, build_simple_mem_ref (src_ptr), &new_seq); diff --git a/gcc/testsuite/g++.target/powerpc/pr101322.C b/gcc/testsuite/g++.target/powerpc/pr101322.C new file mode 100644 index 00000000000..43eaf3afcd4 --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/pr101322.C @@ -0,0 +1,17 @@ +/* PR target/101322 */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* Verify we don't ICE on the following test cases. */ + +void +foo (char *resp, char *vpp) +{ + __builtin_vsx_disassemble_pair (resp, (__vector_pair *) vpp); +} + +void +bar (char *resp, char *vpp) +{ + __builtin_mma_disassemble_acc (resp, (__vector_quad *)vpp); +}