From patchwork Fri Jul 12 21:48:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 1960031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WLQGQ2yfGz1xr4 for ; Sat, 13 Jul 2024 07:48:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9A720385332C for ; Fri, 12 Jul 2024 21:48:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id C06B53858433 for ; Fri, 12 Jul 2024 21:48:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C06B53858433 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bergner.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bergner.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C06B53858433 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720820916; cv=none; b=CuGoqqji++wf5yHR+33fz6qroWFYqNVSEmldFP0SD1Prcz0Q+JtZWCG11wifJzyD1IOp8CAGzbRnpQIZ/LfihW8a53iSW6UlTAa779UfIoEQFoBNcy8B52y6Iov10HPx2RAefc/Kh1XGZlpRWyrZng28mfHq8B9+8Nq2Hpn3gD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720820916; c=relaxed/simple; bh=Npp3WPLvVkMKtUkuuaR04sPAraszWbdPNbFkAOOjua0=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=V2YldR3w/s7ACc3Hx8Srg6H+7vpMbpiSsX/pLb/m6jNScLjcM11nF9KFmAotnIZ/S187m9b+DpHF9JdpezG+w4KsoXh5YbZ3LHyP9PU9h9i4unOhSyxSjSC9TmkM9QiY4h2S3LBvRpJ8ZO+Fl354BHJwXaWdEMbqujxujw90g5Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6007a.ext.cloudfilter.net ([10.0.30.247]) by cmsmtp with ESMTPS id SE0SsDoglnNFGSO80sUEaN; Fri, 12 Jul 2024 21:48:33 +0000 Received: from gator3106.hostgator.com ([50.87.144.141]) by cmsmtp with ESMTPS id SO7zsUXbhyUEQSO7zsIoqH; Fri, 12 Jul 2024 21:48:31 +0000 X-Authority-Analysis: v=2.4 cv=Tc6QtwQh c=1 sm=1 tr=0 ts=6691a4af a=xhSKbkrVh0OjC+l+F4Qcbg==:117 a=GRqTAGWNj5S4Vvd+tmCx+w==:17 a=IkcTkHD0fZMA:10 a=4kmOji7k6h8A:10 a=ywwJbY74WmUA:10 a=VnNF1IyMAAAA:8 a=fWL8-o4TtKtaMqEAZfQA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 Received: from syn-174-082-221-071.res.spectrum.com ([174.82.221.71]:57606 helo=[192.168.86.24]) by gator3106.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1sSO7y-004C7N-Nn; Fri, 12 Jul 2024 16:48:30 -0500 Message-ID: <5f2b5d5e-a682-4084-b70e-89929f4cc6dc@bergner.org> Date: Fri, 12 Jul 2024 16:48:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Segher Boessenkool , "Kewen.Lin" Cc: =?utf-8?q?Ren=C3=A9_Rebe?= , GCC Patches From: Peter Bergner Subject: [PATCH v2] rs6000: Fix .machine cpu selection w/ altivec [PR97367] X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3106.hostgator.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - bergner.org X-BWhitelist: no X-Source-IP: 174.82.221.71 X-Source-L: No X-Exim-ID: 1sSO7y-004C7N-Nn X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: syn-174-082-221-071.res.spectrum.com ([192.168.86.24]) [174.82.221.71]:57606 X-Source-Auth: pshop@bergner.org X-Email-Count: 2 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: YmVyZ25lcjtiZXJnbmVyO2dhdG9yMzEwNi5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-CMAE-Envelope: MS4xfKjHozlgPCpvHeWZuVDu5U/kNV1C39Vf9pVpupqCFMng0rddu/B67VE2p7Biu6qlHBj4JknqJAawUYKVQXOmZss0Cj0FSfidph8tmB5a7LsrCS2X3nVz k+ZzoI8FTIQWK+yblE3rZxBxTjS30IHSNoz17ubzhFf397bB5NW1udRKD0MzV+hLfTkeIP9ag41val3awSRnxpvraqbtaJ21i70= X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org René's patch seems to have stalled, so here is an updated version of the patch with the requested changes to his patch. I'll note I have added an additional code change, which is to also emit a ".machine altivec" if Altivec is enabled. The problem this fixes is for cpus like the G5, which is basically a power4 plus an Altivec unit, its ".machine power4" doesn't enable the assembler to recognize Altivec insns. That isn't a problem if you use gcc -mcpu=G5 to assemble the assembler file, since gcc passes -maltivec to the assembler. However, if you try to assemble the assembler file with as by hand, you'll get "unrecognized opcode" errors. I did not do the same for VSX, since all ".machine " for cpus that support VSX already enable VSX insn recognition, so it's not needed. rs6000: Fix .machine cpu selection w/ altivec [PR97367] There are various non-IBM CPUs with altivec, so we cannot use that flag to determine which .machine cpu to use, so ignore it. Emit an additional ".machine altivec" if Altivec is enabled so that the assembler doesn't require an explicit -maltivec option to assemble any Altivec instructions for those targets where the ".machine cpu" is insufficient to enable Altivec. For example, -mcpu=G5 emits a ".machine power4". This passed bootstrap and regtesting on powrpc64-linux (running the testsuite in both 32-bit and 64-bit modes) with no regressions. Ok for trunk and the release branches after some trunk burn-in time? Peter 2024-07-12 René Rebe Peter Bergner gcc/ PR target/97367 * config/rs6000/rs6000.c (rs6000_machine_from_flags): Do not consider OPTION_MASK_ALTIVEC. (emit_asm_machine): For Altivec compiles, emit a ".machine altivec". gcc/testsuite/ PR target/97367 * gcc.target/powerpc/pr97367.c: New test. Signed-of-by: René Rebe --- gcc/config/rs6000/rs6000.cc | 5 ++++- gcc/testsuite/gcc.target/powerpc/pr97367.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr97367.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 2cbea6ea2d7..2cb8f35739b 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -5888,7 +5888,8 @@ rs6000_machine_from_flags (void) HOST_WIDE_INT flags = rs6000_isa_flags; /* Disable the flags that should never influence the .machine selection. */ - flags &= ~(OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT | OPTION_MASK_ISEL); + flags &= ~(OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT | OPTION_MASK_ISEL + | OPTION_MASK_ALTIVEC); if ((flags & (ISA_3_1_MASKS_SERVER & ~ISA_3_0_MASKS_SERVER)) != 0) return "power10"; @@ -5913,6 +5914,8 @@ void emit_asm_machine (void) { fprintf (asm_out_file, "\t.machine %s\n", rs6000_machine); + if (TARGET_ALTIVEC) + fprintf (asm_out_file, "\t.machine altivec\n"); } #endif diff --git a/gcc/testsuite/gcc.target/powerpc/pr97367.c b/gcc/testsuite/gcc.target/powerpc/pr97367.c new file mode 100644 index 00000000000..f9118dbcdec --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr97367.c @@ -0,0 +1,13 @@ +/* PR target/97367 */ +/* { dg-options "-mdejagnu-cpu=G5" } */ + +/* Verify we emit a ".machine power4" and ".machine altivec" rather + than a ".machine power7". */ + +int dummy (void) +{ + return 0; +} + +/* { dg-final { scan-assembler {\.\mmachine power4\M} } } */ +/* { dg-final { scan-assembler {\.\mmachine altivec\M} } } */