From patchwork Sat Aug 27 03:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp499903wro; Fri, 26 Aug 2022 20:50:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR6H+kA1T2E3/XkqZcDxILzHPnK+LX5GrnO0WgDPtnIMxHj3ZY/h7KyWaiEkvP4/B/nSdiAP X-Received: by 2002:a17:906:8a49:b0:73d:cb3f:3401 with SMTP id gx9-20020a1709068a4900b0073dcb3f3401mr7159260ejc.184.1661572250557; Fri, 26 Aug 2022 20:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661572250; cv=none; d=google.com; s=arc-20160816; b=RwtmL/oBGhvqc2Z6c2ukXbMfXMqZcCv/sWW1yYPIvZQuUDmhV3fMJB8tm12Cn84Mtt kjBbdP8HlPct4FFed+noYKLmu0s8SJ2CsLyM0Bcr5cuRk845nOGRKbhjhE8aCF2/fZ8X ZL4i2NLDpl8H0olGKfw3Y1s8bGWrfIMp+aPdvgP6FOhq14AxU7LQU3zcrIinKs4yKF1y eF16BHNiwUfvC8U8QdKS168ihVU1CKhV5v2ifVrXZnfTxcUKxq/JZLvk5hwfKisb6skI n02NIod07+1CABBgyTcnL0quek3uYzMzFhkiuKGG0dQwe0Zx83GVjwRkRzhlxLHenUh0 cVKg== 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=DogwB+HTWAgEEPv/VnJcL6RNoFB4RqUz6ZTHdTU8UNA=; b=LCM8qoYIWaP1DvrqXNrqu+rv2Wz/PCkPSwREl2nIom7F+NVuBNR73sonDXuP6oOp8r sHH1lY2Fv0ABPx8W55aL9YNyJr9xZ87cKClFKqDWbf7B0CvWQlRsgxtDsliRbeQ343eW 3m2IBwe6YopNIqSGkXcVktPoQ/ckV88tb8MCsN9XltWXzQqeWGwF753KfDEPAIwjFtGz IA7XDG27ZQ8w075/kyAajMpKjUdstV0XFWI0woMQveMr+nXJ8wKx75afY5SKehau7h3i yLNFWVfsTXXunb0lmsDdTvieZqbSAqQ6bwAncUnXpCVWHkkhBRO+rARk+7F9SoB0HUpk pVTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ggrNnNiY; 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 nc29-20020a1709071c1d00b0072b33152db1si2490370ejc.858.2022.08.26.20.50.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 20:50:50 -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=ggrNnNiY; 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 5C09B382DB0F for ; Sat, 27 Aug 2022 03:50:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C09B382DB0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661572249; bh=DogwB+HTWAgEEPv/VnJcL6RNoFB4RqUz6ZTHdTU8UNA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ggrNnNiYi+/DYAvHAxkAz8WkswJudmAyvn44mHsZNXfQccGOj0XxF3Wwqt5bL3omW D+pPohJ72EqCgtrp+UlyGYgZlQ8G0EKjrf3SZgzLLiAvl2CbeOroP7TvTPQodfowfP TWCGnQHO3slU2hF7+CpRECLpVHQzkdrjEbozerDs= 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 B2BDB382DB05; Sat, 27 Aug 2022 03:50:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B2BDB382DB05 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27R3koh2024275; Sat, 27 Aug 2022 03:50:04 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3j7bnpr0u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 27 Aug 2022 03:50:03 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27R3aqQP029911; Sat, 27 Aug 2022 03:50:02 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma01dal.us.ibm.com with ESMTP id 3j7aw908nb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 27 Aug 2022 03:50:02 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27R3o18e5702266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 27 Aug 2022 03:50:01 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72C122805A; Sat, 27 Aug 2022 03:50:01 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2766428059; Sat, 27 Aug 2022 03:50:01 +0000 (GMT) Received: from [9.160.4.32] (unknown [9.160.4.32]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Sat, 27 Aug 2022 03:50:01 +0000 (GMT) Message-ID: Date: Fri, 26 Aug 2022 22:50:00 -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] rs6000: Don't ICE when we disassemble an MMA variable [PR101322] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ARy-xTLAYP0Pun8fZi9iosGtlABB8RSW X-Proofpoint-ORIG-GUID: ARy-xTLAYP0Pun8fZi9iosGtlABB8RSW 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-26_14,2022-08-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1011 mlxscore=0 adultscore=0 mlxlogscore=907 phishscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208270014 X-Spam-Status: No, score=-10.1 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?1742284784039522356?= When we expand an MMA disassemble built-in with C++ using a pointer that is casted 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..e796e74f072 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 (TREE_TYPE (src_ptr)) != src_type) + src_ptr = build1 (VIEW_CONVERT_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..59e71e8eb89 --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/pr101322.C @@ -0,0 +1,17 @@ +/* PR target/101322 */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ +/* { dg-require-effective-target power10_ok } */ + +/* 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); +}