From patchwork Wed Nov 13 19:46:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 2010987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=cGVmV7Pd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4XpYjC5kFTz1xty for ; Thu, 14 Nov 2024 06:47:43 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E2C013858C31 for ; Wed, 13 Nov 2024 19:47:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2C013858C31 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=cGVmV7Pd 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 AC5403858CD1 for ; Wed, 13 Nov 2024 19:46:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC5403858CD1 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 AC5403858CD1 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=1731527193; cv=none; b=lShgaSfJK0wLY5ZgSERPC9oqWTECqMWECpzuOlSkioymYp2YRnbE4VvTjKEQgDF7+c5Sv5+d2DMHTJIR7f0GZaKCy0h6oHTqTVdol3EPWb1JnCGTOqQI3w6FrcJmTWy1yX6VJPApErmevv0k357KG6vnBLtiS47C1H2xEPOTGEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731527193; c=relaxed/simple; bh=CK91jcUeQg2ULkSnAK0zk4zTWdMARPuo8EVg3zCdTG8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=OspjKBfsWVSotuRVTALjPIGRKb1OI85OkjjVT2kO6K/La9DTAomdgBvmUHG6G49uutLZ6+1vA/GR1AL/aAAdvCAAdIdhIdeSeMdXiOyR7aJfjGAaAIxD6qTu73M/rsUegM0Kcb5vOxbRzFT2s0h4gqunOeh6nobq7jt+/iM67NQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC5403858CD1 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ADIfTwY016326; Wed, 13 Nov 2024 19:46:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=1M8zNia66k0TH95ce4Eyp8y6v1/gpC uhE0PAMc18C1g=; b=cGVmV7PdJyRhfDZN2eEZHhmjgrkHAyrXVKzkuCrvplEMiO Xu2Tfco7KJ8xwIHoxA2NQb7SOl3y7gj9E+NEk51/viVVhaVWcN1xLUD9aefzDJjN FW051X5uRiCL6ogYed62L/Ho+L9KGCr0xiFi56M44mYZ3KFb4bqjAAwZkztK93qN PY6XTaGaZmkRufD0ajvFpAQABOmh/lo880X+782pjHbg32i1h0mN1ZHc/K29ZWl0 SxLVDfXXHQL8h3iapj1BYqskZMe172DJpHrdc2FAnNr5LMaEzoGJORuwR5hqNged C1Bmzg8HlqKeZ0fbgNPXTkRtXbAHLgalJwNcg+Wg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42vyd390c3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 19:46:33 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4ADDjo5J010514; Wed, 13 Nov 2024 19:46:32 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 42tj2s6yxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 19:46:32 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ADJkVNg51380620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Nov 2024 19:46:31 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95E1D5805A; Wed, 13 Nov 2024 19:46:31 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 446F558063; Wed, 13 Nov 2024 19:46:31 +0000 (GMT) Received: from cowardly-lion.the-meissners.org (unknown [9.61.109.186]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTPS; Wed, 13 Nov 2024 19:46:31 +0000 (GMT) Date: Wed, 13 Nov 2024 14:46:29 -0500 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , Peter Bergner Subject: [PATCH V3, 04/11] Change TARGET_POPCNTB to TARGET_POWER5 Message-ID: Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , Peter Bergner References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: k7kD99ICcekUVS6P1rSu3UoMHjiiZjy0 X-Proofpoint-ORIG-GUID: k7kD99ICcekUVS6P1rSu3UoMHjiiZjy0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=727 phishscore=0 impostorscore=0 clxscore=1015 mlxscore=0 spamscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411130157 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 As part of the architecture flags patches, this patch changes the use of TARGET_POPCNTB to TARGET_POWER5. The POPCNTB instruction was added in ISA 2.02 (power5). I have built both big endian and little endian bootstrap compilers and there were no regressions. In addition, I constructed a test case that used every archiecture define (like _ARCH_PWR4, etc.) and I also looked at the .machine directive generated. I ran this test for all supported combinations of -mcpu, big/little endian, and 32/64 bit support. Every single instance generated exactly the same code with the patches installed compared to the compiler before installing the patches. Can I install this patch on the GCC 15 trunk? 2024-11-13 Michael Meissner * config/rs6000/rs6000-builtin.cc (rs6000_builtin_is_supported): Use TARGET_POWER5 instead of TARGET_POPCNTB. * config/rs6000/rs6000.h (TARGET_EXTRA_BUILTINS): Use TARGET_POWER5 instead of TARGET_POPCNTB. Eliminate TARGET_CMPB and TARGET_POPCNTD tests since TARGET_POWER5 will always be true for those tests. (TARGET_FRE): Use TARGET_POWER5 instead of TARGET_POPCNTB. (TARGET_FRSQRTES): Likewise. * config/rs6000/rs6000.md (enabled attribute): Likewise. (popcount): Use TARGET_POWER5 instead of TARGET_POPCNTB. Drop test for TARGET_POPCNTD (i.e power7), since TARGET_POPCNTB will always be set if TARGET_POPCNTD is set. (popcntb2): Use TARGET_POWER5 instead of TARGET_POPCNTB. (parity2): Likewise. (parity2_cmpb): Remove TARGET_POPCNTB test, since it will always be true when TARGET_CMPB (i.e. power6) is set. --- gcc/config/rs6000/rs6000-builtin.cc | 2 +- gcc/config/rs6000/rs6000.h | 8 +++----- gcc/config/rs6000/rs6000.md | 10 +++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index 9bdbae1ecf9..98a0545030c 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -155,7 +155,7 @@ rs6000_builtin_is_supported (enum rs6000_gen_builtins fncode) case ENB_ALWAYS: return true; case ENB_P5: - return TARGET_POPCNTB; + return TARGET_POWER5; case ENB_P6: return TARGET_CMPB; case ENB_P6_64: diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 7ad8baca177..4500724d895 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -547,9 +547,7 @@ extern int rs6000_vector_align[]; #define TARGET_EXTRA_BUILTINS (TARGET_POWERPC64 \ || TARGET_PPC_GPOPT /* 970/power4 */ \ - || TARGET_POPCNTB /* ISA 2.02 */ \ - || TARGET_CMPB /* ISA 2.05 */ \ - || TARGET_POPCNTD /* ISA 2.06 */ \ + || TARGET_POWER5 /* ISA 2.02 & above */ \ || TARGET_ALTIVEC \ || TARGET_VSX \ || TARGET_HARD_FLOAT) @@ -563,9 +561,9 @@ extern int rs6000_vector_align[]; #define TARGET_FRES (TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT) #define TARGET_FRE (TARGET_HARD_FLOAT \ - && (TARGET_POPCNTB || VECTOR_UNIT_VSX_P (DFmode))) + && (TARGET_POWER5 || VECTOR_UNIT_VSX_P (DFmode))) -#define TARGET_FRSQRTES (TARGET_HARD_FLOAT && TARGET_POPCNTB \ +#define TARGET_FRSQRTES (TARGET_HARD_FLOAT && TARGET_POWER5 \ && TARGET_PPC_GFXOPT) #define TARGET_FRSQRTE (TARGET_HARD_FLOAT \ diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 8eda2f7bb0d..10d13bf812d 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -379,7 +379,7 @@ (define_attr "enabled" "" (const_int 1) (and (eq_attr "isa" "p5") - (match_test "TARGET_POPCNTB")) + (match_test "TARGET_POWER5")) (const_int 1) (and (eq_attr "isa" "p6") @@ -2510,7 +2510,7 @@ (define_expand "ffs2" (define_expand "popcount2" [(set (match_operand:GPR 0 "gpc_reg_operand") (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand")))] - "TARGET_POPCNTB || TARGET_POPCNTD" + "TARGET_POWER5" { rs6000_emit_popcount (operands[0], operands[1]); DONE; @@ -2520,7 +2520,7 @@ (define_insn "popcntb2" [(set (match_operand:GPR 0 "gpc_reg_operand" "=r") (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_POPCNTB))] - "TARGET_POPCNTB" + "TARGET_POWER5" "popcntb %0,%1" [(set_attr "type" "popcnt")]) @@ -2535,7 +2535,7 @@ (define_insn "popcntd2" (define_expand "parity2" [(set (match_operand:GPR 0 "gpc_reg_operand") (parity:GPR (match_operand:GPR 1 "gpc_reg_operand")))] - "TARGET_POPCNTB" + "TARGET_POWER5" { rs6000_emit_parity (operands[0], operands[1]); DONE; @@ -2544,7 +2544,7 @@ (define_expand "parity2" (define_insn "parity2_cmpb" [(set (match_operand:GPR 0 "gpc_reg_operand" "=r") (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_PARITY))] - "TARGET_CMPB && TARGET_POPCNTB" + "TARGET_CMPB" "prty %0,%1" [(set_attr "type" "popcnt")])