From patchwork Thu Jan 11 17:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 187459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1604240dyi; Thu, 11 Jan 2024 09:30:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEunhnrIzFCZcUcZgm0LBBmm0OZ16TMRXxOorKdFmZIb99REhID1e0WkJT+7aCCouO6EnY6 X-Received: by 2002:a05:622a:19a9:b0:429:c671:f28a with SMTP id u41-20020a05622a19a900b00429c671f28amr91812qtc.33.1704994214663; Thu, 11 Jan 2024 09:30:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704994214; cv=pass; d=google.com; s=arc-20160816; b=nkqYHcmj5ADN45Ct2TopWSGxFYZ+DdKpHnPljimyfX9necpqQ9m/JS+nferzcFbyUu 5IBGootRFb5Y0zYQiIyyB9Z53SgjblBuk6Qfuq0ElqEssL0mZw3HHIfbHamjF5hLeAqk Wbie1AVx3xXZI9D12VeywPxg+0RWTbDQvKJpvJsuLtoqI67XINpuJ/7+9S6BWLHXazMh EG4VERVUgavm/RmQ0N+K2zlS5MvJP0kCN5ZRgvasiota6HnNfwRGDMFVRguYF7j6WG2A mK+7cbSArAl80P7lXFH2GCxXeLJ/1pzMA5ZMuRVse70aIc3IGHaBz/9DdM0xzjNyvnDh RR6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:mail-followup-to:message-id:subject:to:from:date :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=EM3eifNp09q8cuz0gZgZ8c1zPyQqwaGz8F3XXLhvcU8=; fh=0bQqz0x7CUT8I+BDaNEJSevw0DVHT666RDr0Mh+m1Jk=; b=NNvWsrn3PKTdxJW84QwzRNXQm6VOV/ZjXgsn4O+wcUBHZFTj/YQjRr+CYMTPGx/u/y UEDtsfejISxXZo3TmXRkSh3FbqrRGWgXff97AVtqM2hnRHwgTIv4mcJbL/jWtTAf/Kch eeosCz1YS89nmMi6dPyTHyV4cR9hObsUeluMBu9B0wC8VJuRrSz9pNSXY/ERCE1KtUOr Ts4cUWxwURlKHbgJiAdHR9LawnHPnsGcsbftk3X0Sdl/Xl1zZQQGYes9SBo6UdwzOtIE JI4XZyLM21guBQ4RuCsHlKpRF+2z1U1yg/2SzFJb+fkYSCAuAbueQ3jlSJ6HMRXrUq9A qeFA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=h+l5qAht; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c16-20020ac87dd0000000b00429c8ada4e5si742026qte.385.2024.01.11.09.30.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 09:30:14 -0800 (PST) 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=@ibm.com header.s=pp1 header.b=h+l5qAht; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A09B3857704 for ; Thu, 11 Jan 2024 17:30:14 +0000 (GMT) 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 DFEED3858005 for ; Thu, 11 Jan 2024 17:29:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFEED3858005 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DFEED3858005 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704994173; cv=none; b=KM9FAyMIkn0IJuYAJVZgi+WoDGOS6PY/ZJNMR0rozBtLcOJjCtd0TqvNWjyiJBxfFDE75g6AtaOWFhJYYQlCp5J/22M/wczSiQlmok83Xi7BTwL9m6eNE5Jm4DnqDS8zzLKSapQO29/W9TIbOabRyWKswebRYhHY/mSDNcfKURk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704994173; c=relaxed/simple; bh=lSriXNQMLVjs4tP6v2BAQDVb9xjqbiV0clrjycT77Hk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=kiIAXx+SwlKGVb31DM/+pCP7Ny34K9HsGjcR0bX4Syk/vy2xuBXCZZ4x0NR/jcLpuZlns2rJEL/Nz2AS8jcSyUfEkeoPwj35WaaPVJpsjDYSlKhveYlScdux1LYRCDrS/qy2+BZVlVD68vaDsephxqokUC4zhDNsIvGFoSgiSr0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40BGGtdD015208; Thu, 11 Jan 2024 17:29:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : subject : message-id : mime-version : content-type; s=pp1; bh=EM3eifNp09q8cuz0gZgZ8c1zPyQqwaGz8F3XXLhvcU8=; b=h+l5qAhtKKD7nQeTPD/5pJnVkzQvHxBfgLznIb1aZ7I2PznJFfefIWwuMM1vmsKrLfP0 kcDWTAvTcFNyt0QQchAmX7WZsAZETnwSQMjTQ5Uvz9Y7wHdCQ2FfzOSujL1QXNJsOz9/ 3DHIA3QGDvm/o2fw1p+doXj7vtZERQ7Hw6K+hJMoyfzq9O7zbIrd3mElRnFjyqa5bMyy CK2urnGSlxNc2rp9OGaVS5EDKawL6lqyyfejqLUsGlT9I+eUuulzS5nu3dwe86dn0PKb fL4f3MTzE9Oet3tGlFhMjxypglMPqN7UmPEIwEainTSZFeAW04/wUJeFmsiwmY0Knn8Q fw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjj7051at-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 17:29:28 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40BHTRPp018056; Thu, 11 Jan 2024 17:29:27 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjj7051a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 17:29:27 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40BGPxnY027006; Thu, 11 Jan 2024 17:29:26 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vfkw2cerr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 17:29:26 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40BHTPVZ20382216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jan 2024 17:29:25 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65F4F5805A; Thu, 11 Jan 2024 17:29:25 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4B2358056; Thu, 11 Jan 2024 17:29:24 +0000 (GMT) Received: from cowardly-lion.the-meissners.org (unknown [9.61.128.150]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTPS; Thu, 11 Jan 2024 17:29:24 +0000 (GMT) Date: Thu, 11 Jan 2024 12:29:23 -0500 From: Michael Meissner To: gcc-patches@gcc.gnu.org, Michael Meissner , Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner Subject: [PATCH, V2] PR target/112886, Add %S to print_operand for vector pair support. Message-ID: Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner MIME-Version: 1.0 Content-Disposition: inline X-TM-AS-GCONF: 00 X-Proofpoint-GUID: m1I0BN062kPtFNCMVGXwt3WIHkAJXC4s X-Proofpoint-ORIG-GUID: NBkTeRjoI3wKh6YV06uAodcqARzl7u6f X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-11_09,2024-01-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 suspectscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401110137 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_H4, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787816013438253005 X-GMAIL-MSGID: 1787816013438253005 This is version 2 of the patch. The only difference is I made the test case simpler to read. In looking at support for load vector pair and store vector pair for the PowerPC in GCC, I noticed that we were missing a print_operand output modifier if you are dealing with vector pairs to print the 2nd register in the vector pair. If the instruction inside of the asm used the Altivec encoding, then we could use the %L modifier: __vector_pair *p, *q, *r; // ... __asm__ ("vaddudm %0,%1,%2\n\tvaddudm %L0,%L1,%L2" : "=v" (*p) : "v" (*q), "v" (*r)); Likewise if we know the value to be in a tradiational FPR register, %L will work for instructions that use the VSX encoding: __vector_pair *p, *q, *r; // ... __asm__ ("xvadddp %x0,%x1,%x2\n\txvadddp %L0,%L1,%L2" : "=f" (*p) : "f" (*q), "f" (*r)); But if have a value that is in a traditional Altivec register, and the instruction uses the VSX encoding, %L will a value between 0 and 31, when it should give a value between 32 and 63. This patch adds %S that acts like %x, except that it adds 1 to the register number. I have tested this on power10 and power9 little endian systems and on a power9 big endian system. There were no regressions in the patch. Can I apply it to the trunk? It would be nice if I could apply it to the open branches. Can I backport it after a burn-in period? 2024-01-10 Michael Meissner gcc/ PR target/112886 * config/rs6000/rs6000.cc (print_operand): Add %S output modifier. * doc/md.texi (Modifiers): Mention %S can be used like %x. gcc/testsuite/ PR target/112886 * /gcc.target/powerpc/pr112886.c: New test. --- gcc/config/rs6000/rs6000.cc | 10 ++++--- gcc/doc/md.texi | 5 ++-- gcc/testsuite/gcc.target/powerpc/pr112886.c | 29 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr112886.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 872df3140e3..6353a7ccfb2 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -14504,13 +14504,17 @@ print_operand (FILE *file, rtx x, int code) print_operand (file, x, 0); return; + case 'S': case 'x': - /* X is a FPR or Altivec register used in a VSX context. */ + /* X is a FPR or Altivec register used in a VSX context. %x prints + the VSX register number, %S prints the 2nd register number for + vector pair, decimal 128-bit floating and IBM 128-bit binary floating + values. */ if (!REG_P (x) || !VSX_REGNO_P (REGNO (x))) - output_operand_lossage ("invalid %%x value"); + output_operand_lossage ("invalid %%%c value", (code == 'S' ? 'S' : 'x')); else { - int reg = REGNO (x); + int reg = REGNO (x) + (code == 'S' ? 1 : 0); int vsx_reg = (FP_REGNO_P (reg) ? reg - 32 : reg - FIRST_ALTIVEC_REGNO + 32); diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 47a87d6ceec..53ec957cb23 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -3386,8 +3386,9 @@ A VSX register (VSR), @code{vs0}@dots{}@code{vs63}. This is either an FPR (@code{vs0}@dots{}@code{vs31} are @code{f0}@dots{}@code{f31}) or a VR (@code{vs32}@dots{}@code{vs63} are @code{v0}@dots{}@code{v31}). -When using @code{wa}, you should use the @code{%x} output modifier, so that -the correct register number is printed. For example: +When using @code{wa}, you should use either the @code{%x} or @code{%S} +output modifier, so that the correct register number is printed. For +example: @smallexample asm ("xvadddp %x0,%x1,%x2" diff --git a/gcc/testsuite/gcc.target/powerpc/pr112886.c b/gcc/testsuite/gcc.target/powerpc/pr112886.c new file mode 100644 index 00000000000..4e59dcda6ea --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr112886.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2" } */ + +/* PR target/112886: Test that print_operand %S gives the correct register + number for VSX registers (i.e. if the register is an Altivec register, the + register number is 32..63 instead of 0..31. */ + +void +test (__vector_pair *ptr1, __vector_pair *ptr2, __vector_pair *ptr3) +{ + register __vector_pair p asm ("vs10"); + register __vector_pair q asm ("vs42"); + register __vector_pair r asm ("vs44"); + + q = *ptr2; + r = *ptr3; + + __asm__ ("xvadddp %x0,%x1,%x2\n\txvadddp %S0,%S1,%S2" + : "=wa" (p) + : "wa" (q), "wa" (r)); + + *ptr1 = p; +} + +/* { dg-final { scan-assembler-times {\mxvadddp 10,42,44\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mxvadddp 11,43,45\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mlxvpx?\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mstxvpx?\M} 1 } } */