From patchwork Fri Aug 7 22:16:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 1342418 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=qMqURlnF; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BNfpd685Wz9sPC for ; Sat, 8 Aug 2020 08:16:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0472C389853E; Fri, 7 Aug 2020 22:16:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0472C389853E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596838598; bh=fo/12CVGzRSpr5xFdBBujYOkDTtc6yOf/NRbYJhX+HY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qMqURlnF24om84yZf/rK/BDs14tCW3J3FzqZoeGSa8K6mb4RmSGN+PwC22boSSV+B XTyqpSC7fp/AUycnIFegHBvuEXYPrj/ckXpSsnNzH/omCbgFZ1boAM5owrQSNlBy1w 0dZmaU9X1YA961kRcqIhcfDCfEKEFJvEUk2BlOyg= 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 61673389367E for ; Fri, 7 Aug 2020 22:16:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 61673389367E Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 077M5YAr076837; Fri, 7 Aug 2020 18:16:34 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 32sfetr71e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Aug 2020 18:16:34 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 077LxmCn022441; Fri, 7 Aug 2020 22:16:33 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma03wdc.us.ibm.com with ESMTP id 32n019wnnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Aug 2020 22:16:33 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 077MGTNF19137036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Aug 2020 22:16:29 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6087787BF; Fri, 7 Aug 2020 22:16:31 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10987787AE; Fri, 7 Aug 2020 22:16:30 +0000 (GMT) Received: from [9.65.195.179] (unknown [9.65.195.179]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 7 Aug 2020 22:16:30 +0000 (GMT) To: Segher Boessenkool Subject: [PATCH] rs6000: MMA built-ins reject typedefs of MMA types Message-ID: <33595562-7b21-d706-afdf-c6d3aebc7625@linux.ibm.com> Date: Fri, 7 Aug 2020 17:16:30 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-07_20:2020-08-06, 2020-08-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008070150 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_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Bill Schmidt , GCC Patches , Rajalakshmi Srinivasaraghavan Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" We do not allow conversions between the MMA types and other types. However, we are being too strict in not matching MMA types with typdefs of those types. Use TYPE_CANONICAL to see through the types to their canonical types before comparing them. This is currently bootstrapping and regtesting. Ok for trunk if tests are clean? Ok for GCC 10 too, after a couple of days? Peter gcc/ PR target/96530 * config/rs6000/rs6000.c (rs6000_invalid_conversion): Use canonical types for type comparisons. Refactor code to simplify it. gcc/testsuite/ PR target/96530 * gcc.target/powerpc/pr96530.c: New test. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index d26a18f3ece..9124796ff76 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -26803,34 +26803,48 @@ rs6000_cannot_substitute_mem_equiv_p (rtx mem) static const char * rs6000_invalid_conversion (const_tree fromtype, const_tree totype) { - if (element_mode (fromtype) != element_mode (totype)) + /* Make sure we're working with the canonical types. */ + if (TYPE_CANONICAL (fromtype) != NULL_TREE) + fromtype = TYPE_CANONICAL (fromtype); + if (TYPE_CANONICAL (totype) != NULL_TREE) + totype = TYPE_CANONICAL (totype); + + machine_mode frommode = element_mode (fromtype); + machine_mode tomode = element_mode (totype); + + if (frommode != tomode) { /* Do not allow conversions to/from PXImode and POImode types. */ - if (TYPE_MODE (fromtype) == PXImode) + if (frommode == PXImode) return N_("invalid conversion from type %<__vector_quad%>"); - if (TYPE_MODE (totype) == PXImode) + if (tomode == PXImode) return N_("invalid conversion to type %<__vector_quad%>"); - if (TYPE_MODE (fromtype) == POImode) + if (frommode == POImode) return N_("invalid conversion from type %<__vector_pair%>"); - if (TYPE_MODE (totype) == POImode) + if (tomode == POImode) return N_("invalid conversion to type %<__vector_pair%>"); } else if (POINTER_TYPE_P (fromtype) && POINTER_TYPE_P (totype)) { + /* We really care about the modes of the base types. */ + frommode = element_mode (TREE_TYPE (fromtype)); + tomode = element_mode (TREE_TYPE (totype)); + /* Do not allow conversions to/from PXImode and POImode pointer types, except to/from void pointers. */ - if (TYPE_MODE (TREE_TYPE (fromtype)) == PXImode - && TYPE_MODE (TREE_TYPE (totype)) != VOIDmode) - return N_("invalid conversion from type %<* __vector_quad%>"); - if (TYPE_MODE (TREE_TYPE (totype)) == PXImode - && TYPE_MODE (TREE_TYPE (fromtype)) != VOIDmode) - return N_("invalid conversion to type %<* __vector_quad%>"); - if (TYPE_MODE (TREE_TYPE (fromtype)) == POImode - && TYPE_MODE (TREE_TYPE (totype)) != VOIDmode) - return N_("invalid conversion from type %<* __vector_pair%>"); - if (TYPE_MODE (TREE_TYPE (totype)) == POImode - && TYPE_MODE (TREE_TYPE (fromtype)) != VOIDmode) - return N_("invalid conversion to type %<* __vector_pair%>"); + if (frommode != tomode + && frommode != VOIDmode + && tomode != VOIDmode) + { + if (frommode == PXImode) + return N_("invalid conversion from type %<* __vector_quad%>"); + if (tomode == PXImode) + return N_("invalid conversion to type %<* __vector_quad%>"); + if (frommode == POImode) + return N_("invalid conversion from type %<* __vector_pair%>"); + if (tomode == POImode) + return N_("invalid conversion to type %<* __vector_pair%>"); + } } /* Conversion allowed. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr96530.c b/gcc/testsuite/gcc.target/powerpc/pr96530.c new file mode 100644 index 00000000000..29bb9e3cc53 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr96530.c @@ -0,0 +1,20 @@ +/* PR target/96530 */ +/* { dg-do compile } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2" } */ + +/* Verify we do not reject bar() below due to the typedef. */ + +typedef __vector_quad vquad_t; + +void +foo (__vector_quad *dst) +{ + __builtin_mma_xxsetaccz (dst); +} + +void +bar (vquad_t *dst) +{ + __builtin_mma_xxsetaccz (dst); +}