From patchwork Wed Mar 8 23:01:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 66493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp623041wrd; Wed, 8 Mar 2023 15:02:31 -0800 (PST) X-Google-Smtp-Source: AK7set+BepBtmMC0NpnHIpGzh9H9mNm/jO5WG2akGzLvc6/x0x9uWtmUZDy/o6pWr/D4ERT+lTA2 X-Received: by 2002:a50:ee92:0:b0:4c2:96d0:c0cb with SMTP id f18-20020a50ee92000000b004c296d0c0cbmr21317365edr.23.1678316551788; Wed, 08 Mar 2023 15:02:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678316551; cv=none; d=google.com; s=arc-20160816; b=WE+QJl6UIVZOWya8BZoeteqi52m/xwW0bQzdJF8Q8vpNnweBOw8+xu02Ogv8DHiQnQ qEN6MiDKxfhZTT0jwqoV42MxTLWNIfsZaOuOogmzWJ1zIdXN0cPwJQgLnU6lBjQKOcaF d2/ZkZ2LWDcvjnQeM36Qo++VbI7EHmSXDypzLzwtyJcG4Lkq0+YlYlUenaQk0OD8dxa1 CgP5azLkywDDN2tloMCs/8O1X94dro0hFXBjvMoy9yU7gPWNLopwZHITjyrCTrkqD1n/ CIbwt73byKKJEDO0KpDi2IXQH6Suzlw57Jmli4NgwS5cpfpk14tcyBPX1krOW26RYG5L 2eTQ== 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 :content-transfer-encoding:subject:cc:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=7/gNUUpj6j6fuRsf3jw9RAhZf9KDEVlhh1coMcykAoI=; b=ZfSuswEDUOckQ8Qde42VxqM7lY6nh35zvQboIMo0yU7hPR2GucBzSdNm+WUK0rAgYv 9swbwj4bohc7EoXFuh0zCFrcC2AIW5iwgSk8Aq1Qq9xoCjlnkEj8aQ9VkVYShc9j3jFV oBP2kQYXGKhmcsC1kGJ2Ps7qWFsTVnBlSxh6uqNKIAslI7kGFM+jcZevWhoTb8z3J0Ki XV8aCN6bv8FY/IhOIJouwewz1GWuutZ6wKgNDt71GsowzMqJW+poiVsvq2avhbsOqZXq HN2o9G6+k7fIdy/y4lCD6wyr1Ch0OrJz19EsDSghqrMSL/RnpCrCQh8pKfurEcKk8G0a e66A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TFGh5QVM; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b8-20020aa7c908000000b004acc80b26e2si17519626edt.300.2023.03.08.15.02.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 15:02:31 -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=TFGh5QVM; 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 BCAF138582BC for ; Wed, 8 Mar 2023 23:02:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCAF138582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678316550; bh=7/gNUUpj6j6fuRsf3jw9RAhZf9KDEVlhh1coMcykAoI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=TFGh5QVM6LW2KIcEr/VxpW7nsYLmLEFquUxsWHJeQ3+DLGlOp6oltoKtCHtrJY54e gC7vMtH6J4H9ap+tNzYnIRnNYJety4auDjjIMQmWXIwzg/LJBMq4e2Hd7JWjAfuxHZ IIaqi3u/5b7IhYIoxfnO6qKxGBhX9foVqHMxPeCM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 7A9593858D33 for ; Wed, 8 Mar 2023 23:01:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A9593858D33 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 328KRj3e027498; Wed, 8 Mar 2023 23:01:43 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p6pa7db9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Mar 2023 23:01:43 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 328KIH1P016629; Wed, 8 Mar 2023 23:01:42 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([9.208.129.117]) by ppma04wdc.us.ibm.com (PPS) with ESMTPS id 3p6fhk5xf6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Mar 2023 23:01:42 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 328N1dKC9634422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 Mar 2023 23:01:39 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D19558061; Wed, 8 Mar 2023 23:01:39 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 063BA58060; Wed, 8 Mar 2023 23:01:39 +0000 (GMT) Received: from [9.211.90.110] (unknown [9.211.90.110]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 8 Mar 2023 23:01:38 +0000 (GMT) Message-ID: <40ecb0c8-2821-a72b-549d-6de6876b5d45@linux.ibm.com> Date: Wed, 8 Mar 2023 17:01:38 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: GCC Patches Cc: Segher Boessenkool , Chip Kerchner Subject: [PATCH] rs6000: Accept const pointer operands for MMA builtins [PR109073] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dufYjXAaSSxTQcX4S9TIkOK6c3UKTrTj X-Proofpoint-ORIG-GUID: dufYjXAaSSxTQcX4S9TIkOK6c3UKTrTj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 clxscore=1011 lowpriorityscore=0 mlxscore=0 spamscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080189 X-Spam-Status: No, score=-10.9 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: Peter Bergner via Gcc-patches From: Peter Bergner Reply-To: Peter Bergner 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?1759842456550629417?= X-GMAIL-MSGID: =?utf-8?q?1759842456550629417?= PR109073 shows a problem where GCC 11 and GCC 10 do not accept a const __vector_pair pointer operand to some MMA builtins, which GCC 12 and later correctly accept. Fixed here by initializing the builtins to accept const pointers. This patch was tested in both GCC 11 and GCC 10 on powerpc64le-linux and showed no regressions. Ok for backports? Peter gcc/ PR target/109073 * config/rs6000/rs6000-call.c (mma_init_builtins): Accept const pointer operands for lxvp, stxvp and disassemble builtins. gcc/testsuite/ PR target/109073 * gcc.target/powerpc/mma-builtin-4.c): New const * test. Update expected instruction counts. * gcc.target/powerpc/mma-builtin-5.c: Likewise. * gcc.target/powerpc/mma-builtin-7.c: Likewise. diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index 1be4797e834..3b6d40f0aef 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -14343,22 +14343,30 @@ mma_init_builtins (void) { op[nopnds++] = build_pointer_type (void_type_node); if (d->code == MMA_BUILTIN_DISASSEMBLE_ACC) - op[nopnds++] = build_pointer_type (vector_quad_type_node); + op[nopnds++] = build_pointer_type (build_qualified_type + (vector_quad_type_node, + TYPE_QUAL_CONST)); else - op[nopnds++] = build_pointer_type (vector_pair_type_node); + op[nopnds++] = build_pointer_type (build_qualified_type + (vector_pair_type_node, + TYPE_QUAL_CONST)); } else if (d->code == VSX_BUILTIN_LXVP) { op[nopnds++] = vector_pair_type_node; op[nopnds++] = sizetype; - op[nopnds++] = build_pointer_type (vector_pair_type_node); + op[nopnds++] = build_pointer_type (build_qualified_type + (vector_pair_type_node, + TYPE_QUAL_CONST)); } else if (d->code == VSX_BUILTIN_STXVP) { op[nopnds++] = void_type_node; op[nopnds++] = vector_pair_type_node; op[nopnds++] = sizetype; - op[nopnds++] = build_pointer_type (vector_pair_type_node); + op[nopnds++] = build_pointer_type (build_qualified_type + (vector_pair_type_node, + TYPE_QUAL_CONST)); } else { diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c b/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c index a9fb0107d12..0ba650fcee7 100644 --- a/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c @@ -46,6 +46,15 @@ bar2 (vec_t *dst, __vector_pair *src) dst[4] = res[1]; } +void +bar3 (vec_t *dst, const __vector_pair *src) +{ + vec_t res[2]; + __builtin_vsx_disassemble_pair (res, src); + dst[0] = res[0]; + dst[4] = res[1]; +} + #if !__has_builtin (__builtin_vsx_assemble_pair) # error "__has_builtin (__builtin_vsx_assemble_pair) failed" #endif @@ -67,7 +76,7 @@ bar2 (vec_t *dst, __vector_pair *src) #endif /* { dg-final { scan-assembler-times {\mlxv\M} 6 } } */ -/* { dg-final { scan-assembler-times {\mlxvp\M} 2 } } */ -/* { dg-final { scan-assembler-times {\mstxv\M} 4 } } */ +/* { dg-final { scan-assembler-times {\mlxvp\M} 3 } } */ +/* { dg-final { scan-assembler-times {\mstxv\M} 6 } } */ /* { dg-final { scan-assembler-times {\mstxvp\M} 3 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c b/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c index 00503b7343d..998c436a8bb 100644 --- a/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c @@ -31,6 +31,17 @@ bar (vec_t *dst, __vector_quad *src) dst[12] = res[3]; } +void +bar2 (vec_t *dst, const __vector_quad *src) +{ + vec_t res[4]; + __builtin_mma_disassemble_acc (res, src); + dst[0] = res[0]; + dst[4] = res[1]; + dst[8] = res[2]; + dst[12] = res[3]; +} + #if !__has_builtin (__builtin_mma_assemble_acc) # error "__has_builtin (__builtin_mma_assemble_acc) failed" #endif @@ -40,8 +51,8 @@ bar (vec_t *dst, __vector_quad *src) #endif /* { dg-final { scan-assembler-times {\mlxv\M} 8 } } */ -/* { dg-final { scan-assembler-times {\mlxvp\M} 2 } } */ -/* { dg-final { scan-assembler-times {\mstxv\M} 4 } } */ +/* { dg-final { scan-assembler-times {\mlxvp\M} 4 } } */ +/* { dg-final { scan-assembler-times {\mstxv\M} 8 } } */ /* { dg-final { scan-assembler-times {\mstxvp\M} 4 } } */ -/* { dg-final { scan-assembler-times {\mxxmfacc\M} 3 } } */ -/* { dg-final { scan-assembler-times {\mxxmtacc\M} 3 } } */ +/* { dg-final { scan-assembler-times {\mxxmfacc\M} 4 } } */ +/* { dg-final { scan-assembler-times {\mxxmtacc\M} 4 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c b/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c index c661a4b84bc..23becfde15e 100644 --- a/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c @@ -14,13 +14,25 @@ foo (__vector_pair *dst, __vector_pair *src, long idx) dst[8] = __builtin_vsx_lxvp (257, src); } +void +bar (__vector_pair *dst, const __vector_pair *src, long idx) +{ + dst[0] = __builtin_vsx_lxvp (0, src); + dst[2] = __builtin_vsx_lxvp (32, src); + dst[4] = __builtin_vsx_lxvp (64, src); + /* Non-constant offset should generate a lxvpx. */ + dst[6] = __builtin_vsx_lxvp (idx, src); + /* Non-aligned offset should generate a plxvp. */ + dst[8] = __builtin_vsx_lxvp (257, src); +} + #if !__has_builtin (__builtin_vsx_lxvp) # error "__has_builtin (__builtin_vsx_lxvp) failed" #endif /* { dg-final { scan-assembler-not {\mlxv\M} } } */ /* { dg-final { scan-assembler-not {\mstxv\M} } } */ -/* { dg-final { scan-assembler-times {\mlxvp\M} 3 } } */ -/* { dg-final { scan-assembler-times {\mlxvpx\M} 1 } } */ -/* { dg-final { scan-assembler-times {\mplxvp\M} 1 } } */ -/* { dg-final { scan-assembler-times {\mstxvp\M} 5 } } */ +/* { dg-final { scan-assembler-times {\mlxvp\M} 6 } } */ +/* { dg-final { scan-assembler-times {\mlxvpx\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mplxvp\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mstxvp\M} 10 } } */