From patchwork Fri Aug 2 06:17:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1968167 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=erTs19Re; 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 4WZwcB2xycz1yYq for ; Fri, 2 Aug 2024 16:17:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A93E6385DDF9 for ; Fri, 2 Aug 2024 06:17:44 +0000 (GMT) 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 2980E385E44D for ; Fri, 2 Aug 2024 06:17:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2980E385E44D 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 2980E385E44D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722579448; cv=none; b=iKcJCNFsYGluKsJBpK0x1P4jh8h5nEN+IlENJiroJU6/i7qkhLPotCHNCfON/VmkH5IDMRJwiPQV5Xj2ozx5F43YaaG2XykNh9RIopi3S1WAtYWDmEusq6NnShDR324iS9Wka7FvdHEEwj7vlsUdygkBNWcjSjJ6zv5WR01soEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722579448; c=relaxed/simple; bh=nWDZXZ+zIP4m+JpfJeaTwHvYbmfZZU6MljvHCM6sCGQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=edDvdjOtoDioI5M6mnXGuPar18cIJTAW4i398tbiKzg6xQs8MlMIdCLQ/QiK3tlFkUK7kPPB/jfPlPGsoZPSQaG7S/gFgx+JS2dSPUT1u+CvvMLmXSXAx97yCBHAEcVD0T6Y6cYTB+on0c4k788AnYbMTS27y/0nGN5FYQTt5kQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47251hOX001623; Fri, 2 Aug 2024 06:17:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=pp1; bh=+czYlZXI7g2keARbdcVc1bZSHj2EcRlwPIMphBJe 7M8=; b=erTs19Re3CXWylTsTqxlxeC5gArDD0acd5Cx+1+OCRH2DkwUzCdFBe4r dFS4ATitCsN9JErnNUO4QFHxgi7CNIx8S+QYxemUOAaprvmqvAepYWUrNuh3C6Rw HFXKy1v6Kh9Bel6z4uey1XSrBT8pXkMgDA1i6YA1/eaBoeQqBAq6B65NjX4jFvom DPl65fW+m8MXzV6YBiF4PngFTg5O2uXn8fmcLQk+/AL0fCS//G3oVtiWZUp9KZMP jxY5ALPAeCh+gfxmianbJspVsJh5giQ3pCYQgDmA5kacGYhES092iyEp7XcVDIIc tMoMUvdSpuFmO5dT7RWhhIeGloiyMw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rrfj8629-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 06:17:24 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4726HOl9011505; Fri, 2 Aug 2024 06:17:24 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 40rrfj8626-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 06:17:24 +0000 (GMT) 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 4724cBgf009218; Fri, 2 Aug 2024 06:17:23 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 40ndx3dg84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Aug 2024 06:17:23 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4726HJTC19137102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Aug 2024 06:17:22 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D434C5805B; Fri, 2 Aug 2024 06:17:19 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 23FD358059; Fri, 2 Aug 2024 06:17:19 +0000 (GMT) Received: from cowardly-lion.the-meissners.org (unknown [9.61.67.12]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTPS; Fri, 2 Aug 2024 06:17:19 +0000 (GMT) Date: Fri, 2 Aug 2024 02:17:15 -0400 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner Subject: [PATCH 7/9] Change TARGET_POPCNTD to TARGET_POWER7 Message-ID: Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , David Edelsohn , Peter Bergner References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: wgGHQans9bgAYoK8WrIt6jchiIeSphw6 X-Proofpoint-GUID: exjN6J3DAj4x3kxNb0VAtchTVPesubZj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_02,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=995 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020035 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 As part of the architecture flags patches, this patch changes the use of TARGET_POPCNTD to TARGET_POWER7. The POPCNTD instruction was added in power7 (ISA 2.06). 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-08-01 Michael Meissner * config/rs6000/dfp.md (floatdidd2): Change TARGET_POPCNTD to TARGET_POWER7. * config/rs6000/rs6000-builtin.cc (rs6000_builtin_is_supported): Likewise. * config/rs6000/rs6000-string.cc (expand_block_compare_gpr): Likewise. * config/rs6000/rs6000.cc (rs6000_hard_regno_mode_ok_uncached): Likewise. (rs6000_rtx_costs): Likewise. (rs6000_emit_popcount): Likewise. * config/rs6000/rs6000.h (TARGET_LDBRX): Likewise. (TARGET_LFIWZX): Likewise. (TARGET_FCFIDS): Likewise. (TARGET_FCFIDU): Likewise. (TARGET_FCFIDUS): Likewise. (TARGET_FCTIDUZ): Likewise. (TARGET_FCTIWUZ): Likewise. (CTZ_DEFINED_VALUE_AT_ZERO): Likewise. * config/rs6000/rs6000.md (enabled attribute): Likewise. (ctz2): Likewise. (popcntd2): Likewise. (lrintsi2): Likewise. (lrintsi): Likewise. (lrintsi_di): Likewise. (cmpmemsi): Likewise. (bpermd_"): Likewise. (addg6s): Likewise. (cdtbcd): Likewise. (cbcdtd): Likewise. (div_): Likewise. --- gcc/config/rs6000/dfp.md | 2 +- gcc/config/rs6000/rs6000-builtin.cc | 4 ++-- gcc/config/rs6000/rs6000-string.cc | 4 ++-- gcc/config/rs6000/rs6000.cc | 6 +++--- gcc/config/rs6000/rs6000.h | 16 ++++++++-------- gcc/config/rs6000/rs6000.md | 24 ++++++++++++------------ 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/gcc/config/rs6000/dfp.md b/gcc/config/rs6000/dfp.md index fa9d7dd45dd..b8189390d41 100644 --- a/gcc/config/rs6000/dfp.md +++ b/gcc/config/rs6000/dfp.md @@ -214,7 +214,7 @@ (define_insn "*cmp_internal1" (define_insn "floatdidd2" [(set (match_operand:DD 0 "gpc_reg_operand" "=d") (float:DD (match_operand:DI 1 "gpc_reg_operand" "d")))] - "TARGET_DFP && TARGET_POPCNTD" + "TARGET_DFP && TARGET_POWER7" "dcffix %0,%1" [(set_attr "type" "dfp")]) diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index ddf744cd988..140422170a1 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -161,9 +161,9 @@ rs6000_builtin_is_supported (enum rs6000_gen_builtins fncode) case ENB_P6_64: return TARGET_POWER6 && TARGET_POWERPC64; case ENB_P7: - return TARGET_POPCNTD; + return TARGET_POWER7; case ENB_P7_64: - return TARGET_POPCNTD && TARGET_POWERPC64; + return TARGET_POWER7 && TARGET_POWERPC64; case ENB_P8: return TARGET_POWER8; case ENB_P8V: diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index 55b4133b1a3..3674c4bd984 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -1948,8 +1948,8 @@ expand_block_compare_gpr(unsigned HOST_WIDE_INT bytes, unsigned int base_align, bool expand_block_compare (rtx operands[]) { - /* TARGET_POPCNTD is already guarded at expand cmpmemsi. */ - gcc_assert (TARGET_POPCNTD); + /* TARGET_POWER7 is already guarded at expand cmpmemsi. */ + gcc_assert (TARGET_POWER7); /* For P8, this case is complicated to handle because the subtract with carry instructions do not generate the 64-bit carry and so diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 7d50fd97ad8..12d9b11de00 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1998,7 +1998,7 @@ rs6000_hard_regno_mode_ok_uncached (int regno, machine_mode mode) if(GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD) return 1; - if (TARGET_POPCNTD && mode == SImode) + if (TARGET_POWER7 && mode == SImode) return 1; if (TARGET_P9_VECTOR && (mode == QImode || mode == HImode)) @@ -22476,7 +22476,7 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, return false; case POPCOUNT: - *total = COSTS_N_INSNS (TARGET_POPCNTD ? 1 : 6); + *total = COSTS_N_INSNS (TARGET_POWER7 ? 1 : 6); return false; case PARITY: @@ -23263,7 +23263,7 @@ rs6000_emit_popcount (rtx dst, rtx src) rtx tmp1, tmp2; /* Use the PPC ISA 2.06 popcnt{w,d} instruction if we can. */ - if (TARGET_POPCNTD) + if (TARGET_POWER7) { if (mode == SImode) emit_insn (gen_popcntdsi2 (dst, src)); diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 924ca682172..b5b9c01683b 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -442,7 +442,7 @@ extern int rs6000_vector_align[]; #define TARGET_LONG_DOUBLE_128 (rs6000_long_double_type_size > 64) #define TARGET_IEEEQUAD rs6000_ieeequad #define TARGET_ALTIVEC_ABI rs6000_altivec_abi -#define TARGET_LDBRX (TARGET_POPCNTD || rs6000_cpu == PROCESSOR_CELL) +#define TARGET_LDBRX (TARGET_POWER7 || rs6000_cpu == PROCESSOR_CELL) /* ISA 2.01 allowed FCFID to be done in 32-bit, previously it was 64-bit only. Enable 32-bit fcfid's on any of the switches for newer ISA machines. */ @@ -453,12 +453,12 @@ extern int rs6000_vector_align[]; #define TARGET_FCTIDZ TARGET_FCFID #define TARGET_STFIWX TARGET_PPC_GFXOPT #define TARGET_LFIWAX TARGET_POWER6 -#define TARGET_LFIWZX TARGET_POPCNTD -#define TARGET_FCFIDS TARGET_POPCNTD -#define TARGET_FCFIDU TARGET_POPCNTD -#define TARGET_FCFIDUS TARGET_POPCNTD -#define TARGET_FCTIDUZ TARGET_POPCNTD -#define TARGET_FCTIWUZ TARGET_POPCNTD +#define TARGET_LFIWZX TARGET_POWER7 +#define TARGET_FCFIDS TARGET_POWER7 +#define TARGET_FCFIDU TARGET_POWER7 +#define TARGET_FCFIDUS TARGET_POWER7 +#define TARGET_FCTIDUZ TARGET_POWER7 +#define TARGET_FCTIWUZ TARGET_POWER7 /* Only powerpc64 and powerpc476 support fctid. */ #define TARGET_FCTID (TARGET_POWERPC64 || rs6000_cpu == PROCESSOR_PPC476) #define TARGET_CTZ TARGET_MODULO @@ -1752,7 +1752,7 @@ typedef struct rs6000_args zero. The hardware instructions added in Power9 and the sequences using popcount return 32 or 64. */ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \ - (TARGET_CTZ || TARGET_POPCNTD \ + (TARGET_CTZ || TARGET_POWER7 \ ? ((VALUE) = GET_MODE_BITSIZE (MODE), 2) \ : ((VALUE) = -1, 2)) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index dd3bfcc6a3a..089377e5b6a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -373,7 +373,7 @@ (define_attr "enabled" "" (const_int 1) (and (eq_attr "isa" "p7") - (match_test "TARGET_POPCNTD")) + (match_test "TARGET_POWER7")) (const_int 1) (and (eq_attr "isa" "p7v") @@ -2431,7 +2431,7 @@ (define_expand "ctz2" rtx tmp2 = gen_reg_rtx (mode); rtx tmp3 = gen_reg_rtx (mode); - if (TARGET_POPCNTD) + if (TARGET_POWER7) { emit_insn (gen_add3 (tmp1, operands[1], constm1_rtx)); emit_insn (gen_one_cmpl2 (tmp2, operands[1])); @@ -2492,7 +2492,7 @@ (define_insn "popcntb2" (define_insn "popcntd2" [(set (match_operand:GPR 0 "gpc_reg_operand" "=r") (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))] - "TARGET_POPCNTD" + "TARGET_POWER7" "popcnt %0,%1" [(set_attr "type" "popcnt")]) @@ -6749,7 +6749,7 @@ (define_expand "lrintsi2" /* For those old archs in which SImode can't be hold in float registers, call lrintsi_di to put the result in DImode then convert it via stack. */ - if (!TARGET_POPCNTD) + if (!TARGET_POWER7) { rtx tmp = gen_reg_rtx (DImode); emit_insn (gen_lrintsi_di (tmp, operands[1])); @@ -6764,7 +6764,7 @@ (define_insn "*lrintsi" [(set (match_operand:SI 0 "gpc_reg_operand" "=d") (unspec:SI [(match_operand:SFDF 1 "gpc_reg_operand" "")] UNSPEC_FCTIW))] - "TARGET_HARD_FLOAT && TARGET_POPCNTD" + "TARGET_HARD_FLOAT && TARGET_POWER7" "fctiw %0,%1" [(set_attr "type" "fp")]) @@ -6772,7 +6772,7 @@ (define_insn "lrintsi_di" [(set (match_operand:DI 0 "gpc_reg_operand" "=d") (unspec:DI [(match_operand:SFDF 1 "gpc_reg_operand" "")] UNSPEC_FCTIW))] - "TARGET_HARD_FLOAT && !TARGET_POPCNTD" + "TARGET_HARD_FLOAT && !TARGET_POWER7" "fctiw %0,%1" [(set_attr "type" "fp")]) @@ -10133,7 +10133,7 @@ (define_expand "cmpmemsi" (match_operand:BLK 2))) (use (match_operand:SI 3)) (use (match_operand:SI 4))])] - "TARGET_POPCNTD" + "TARGET_POWER7" { if (optimize_insn_for_size_p ()) FAIL; @@ -14400,7 +14400,7 @@ (define_insn "bpermd_" [(set (match_operand:P 0 "gpc_reg_operand" "=r") (unspec:P [(match_operand:P 1 "gpc_reg_operand" "r") (match_operand:P 2 "gpc_reg_operand" "r")] UNSPEC_BPERM))] - "TARGET_POPCNTD" + "TARGET_POWER7" "bpermd %0,%1,%2" [(set_attr "type" "popcnt")]) @@ -14778,7 +14778,7 @@ (define_insn "addg6s" (unspec:SI [(match_operand:SI 1 "register_operand" "r") (match_operand:SI 2 "register_operand" "r")] UNSPEC_ADDG6S))] - "TARGET_POPCNTD" + "TARGET_POWER7" "addg6s %0,%1,%2" [(set_attr "type" "integer")]) @@ -14786,7 +14786,7 @@ (define_insn "cdtbcd" [(set (match_operand:SI 0 "register_operand" "=r") (unspec:SI [(match_operand:SI 1 "register_operand" "r")] UNSPEC_CDTBCD))] - "TARGET_POPCNTD" + "TARGET_POWER7" "cdtbcd %0,%1" [(set_attr "type" "integer")]) @@ -14794,7 +14794,7 @@ (define_insn "cbcdtd" [(set (match_operand:SI 0 "register_operand" "=r") (unspec:SI [(match_operand:SI 1 "register_operand" "r")] UNSPEC_CBCDTD))] - "TARGET_POPCNTD" + "TARGET_POWER7" "cbcdtd %0,%1" [(set_attr "type" "integer")]) @@ -14809,7 +14809,7 @@ (define_insn "div_" (unspec:GPR [(match_operand:GPR 1 "register_operand" "r") (match_operand:GPR 2 "register_operand" "r")] UNSPEC_DIV_EXTEND))] - "TARGET_POPCNTD" + "TARGET_POWER7" "div %0,%1,%2" [(set_attr "type" "div") (set_attr "size" "")])