From patchwork Mon Dec 11 01:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 176421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6783991vqy; Sun, 10 Dec 2023 17:50:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWG2GpM8XJ2FPC1RtugcQkl5oFOX1Dg4dlptpDkrY01VycY+F+b5NmIkkGST7uRoYzUiBN X-Received: by 2002:a05:620a:4399:b0:77f:3f7d:b4a0 with SMTP id a25-20020a05620a439900b0077f3f7db4a0mr4008672qkp.62.1702259401099; Sun, 10 Dec 2023 17:50:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702259401; cv=pass; d=google.com; s=arc-20160816; b=lvyP90kMlFZJbIYSDK7ONnSy34sUyFxRMoJy26mH5jd+GTtLxd+J7KMAcLClynti7Z 6RFVHKcI6vkvzzLVy8dUYT22eIAzDWjQEAlZ7L3JpbmYgTCzNp0bVFbSQk4EPGc+id/G w2AlDFazYWnL690F+IUXadtgpQnfYsgGDlmCfEvuxUWfKiVS301nAyaAxTv6/P0wkmt8 XhTFIoXcIsiQnpA35bitkmcNdhYVmY2Yz7R4OXE6x+IEssToOZR4uMJp6ONvYWxLuxZG swvLjNK63NYS4lNJr4Xta99XsMFoojzlxBlsJOEPyRlJgctmo5IiK7nkT9Kwk7U6tRpM cs8g== 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-transfer-encoding :subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=4Mv4FaDnKOYYUw7AgcJ87HTFMh2ERu8gvfduBg87yfA=; fh=3eUSxJU+9IWNwGHlMjnmqDQDnJfeMKAjlglEUO7a4vw=; b=XA0sRPp0aTvYI1OzzxtY306IgVlMfUa8SpZ+q39XktsWjjJLgZfkpYpBQT9KgyhPm/ Pu0dG4oSpOb1A6FG7ydpJA0UEAEhpvqVM/49plcsXt2PzIcFE84A+aIa3I6qjqGRrak3 T3jgFudYxD4mQJbUKgDKkjI4w5y9NWcZGj4NlhcSi/Ycwu68xEw2yKr68Nan/Hdkdi9K cnXbrzbDgVdvr10ZIYbii99YaD5MZu9jHIfMRtn2I4e0T9LLakQE/7DJHE2mIBm76Znc bEWwAHc6MRm/R4pAV0ShglWqraag3LJMl+7tLyR72xFoKSBFfiQNILNYnbXe2pMeynPu twXQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=TqHewAx4; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dz14-20020a05620a2b8e00b0077d6d82be81si7824946qkb.605.2023.12.10.17.50.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 17:50:01 -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=@ibm.com header.s=pp1 header.b=TqHewAx4; arc=pass (i=1); 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA2013857BAD for ; Mon, 11 Dec 2023 01:50:00 +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 C68A838582B4 for ; Mon, 11 Dec 2023 01:49:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C68A838582B4 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 C68A838582B4 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=1702259377; cv=none; b=UIu6kfjH701VOtbgWPayMKP/1nMdq64ggNRmm3uhx77F955y30acHBB4VipES8UnLuSPsDMWr4XaOObxZmqEylMj8ZgZsRYZFoaWJXb9bQwdgNF9SQX4Uzbbu0LJ+I+bHvUdximdPLAwt1sxTwhcUIuUwcFB19GNZfksvEF+qrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702259377; c=relaxed/simple; bh=fFCbjz4skf3X+Jm8wNbGt47MfRY0O5NEPEM78g7hXbc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=Zlzaz3ojSX1P3dmrxFRwi4FlQ61A83zL6HQt56/40WeXy9OGi6FbHIYRnc1mbea7ZvgGyuCrk2So0bnec9jhGk8Kx/1t/l3kUMEyLwFdFNGzSTkK4rGGbAdLMis19QS5ygfJuB3l9wuwiRym69CyMXymugkVOhJ2i2qC4yRQfuk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BANr1id017706; Mon, 11 Dec 2023 01:49:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : cc : from : subject : content-type : content-transfer-encoding; s=pp1; bh=4Mv4FaDnKOYYUw7AgcJ87HTFMh2ERu8gvfduBg87yfA=; b=TqHewAx4cHqQYl1p49pFXrpYFKF9MRb8Wa722KdGisTmWajMTMHofUqKP7LDQYbTaWi8 GlBfzZi0Lz/r6aXgCJVlp7xFoNBnqTSHxDfZIakrpXomKOt/Pt+BFS/dTMiwfTSIa9tN OZVE/DJi8t0QANeLDqPsjeXPa5tiZP1WzNn08710Il6x8nQDLxPR08Djhj/+3SC5zRpi 0v4Kghx9/2kVbZUPDxK9u/kgMIfe43HDjls2XSViaOe2+pw+zN9WOWr71CVq3WSa+MJY 3R7QJdhT6/w/Y977pyxqtlJuEh96YMMfArQ4EcF5LKiizp2SGHTWHatV0QjblqrEteST Zw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uvtck3fq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 01:49:33 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BB0jDQ4015938; Mon, 11 Dec 2023 01:49:33 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uvtck3fpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 01:49:33 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BAGbP8x014803; Mon, 11 Dec 2023 01:49:32 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uw42k9h2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 01:49:31 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BB1nS985308938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Dec 2023 01:49:28 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B64CD20043; Mon, 11 Dec 2023 01:49:28 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E54632004B; Mon, 11 Dec 2023 01:49:26 +0000 (GMT) Received: from [9.200.48.207] (unknown [9.200.48.207]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 11 Dec 2023 01:49:26 +0000 (GMT) Message-ID: <1a15d34c-f6fd-4e08-ac88-ccc5662d092a@linux.ibm.com> Date: Mon, 11 Dec 2023 09:49:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner From: HAO CHEN GUI Subject: [Patch, rs6000] Correct definition of macro of fixed point efficient unaligned X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: LVR6Btgiac7eEq-GWuYeBFkEKD2pD0bs X-Proofpoint-GUID: mkAaComRXjZkdBdqMJK3pN1l3a61WqF2 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=2023-12-10_16,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 clxscore=1015 suspectscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312110013 X-Spam-Status: No, score=-12.7 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: 1784948353724909685 X-GMAIL-MSGID: 1784948353724909685 Hi, The patch corrects the definition of TARGET_EFFICIENT_OVERLAPPING_UNALIGNED and change its name to a comprehensible name. Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no regressions. Is this OK for trunk? Thanks Gui Haochen ChangeLog rs6000: Correct definition of macro of fixed point efficient unaligned Marco TARGET_EFFICIENT_OVERLAPPING_UNALIGNED is used in rs6000-string.cc to guard whether a platform is efficient on fixed point unaligned load/store. It's originally defined by TARGET_EFFICIENT_UNALIGNED_VSX which is enabled from P8 and can be disabled by mno-vsx option. So the definition is wrong. This patch corrects the problem and define it by "!STRICT_ALIGNMENT" which is true on P7 BE and P8 above. gcc/ * config/rs6000/rs6000.h (TARGET_EFFICIENT_OVERLAPPING_UNALIGNED): Rename to... (TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT): ...this, set it to !STRICT_ALIGNMENT. * config/rs6000/rs6000-string.cc (select_block_compare_mode): Replace TARGET_EFFICIENT_OVERLAPPING_UNALIGNED with TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT. (select_block_compare_mode): Likewise. (expand_block_compare_gpr): Likewise. (expand_block_compare): Likewise. (expand_strncmp_gpr_sequence): Likewise. gcc/testsuite/ * gcc.target/powerpc/target_efficient_unaligned_fixedpoint-1.c: New. * gcc.target/powerpc/target_efficient_unaligned_fixedpoint-2.c: New. patch.diff diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index 44a946cd453..d4030854b2a 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -305,7 +305,7 @@ select_block_compare_mode (unsigned HOST_WIDE_INT offset, else if (bytes == GET_MODE_SIZE (QImode)) return QImode; else if (bytes < GET_MODE_SIZE (SImode) - && TARGET_EFFICIENT_OVERLAPPING_UNALIGNED + && TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT && offset >= GET_MODE_SIZE (SImode) - bytes) /* This matches the case were we have SImode and 3 bytes and offset >= 1 and permits us to move back one and overlap @@ -313,7 +313,7 @@ select_block_compare_mode (unsigned HOST_WIDE_INT offset, unwanted bytes off of the input. */ return SImode; else if (word_mode_ok && bytes < UNITS_PER_WORD - && TARGET_EFFICIENT_OVERLAPPING_UNALIGNED + && TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT && offset >= UNITS_PER_WORD-bytes) /* Similarly, if we can use DImode it will get matched here and can do an overlapping read that ends at the end of the block. */ @@ -1749,7 +1749,7 @@ expand_block_compare_gpr(unsigned HOST_WIDE_INT bytes, unsigned int base_align, load_mode_size = GET_MODE_SIZE (load_mode); if (bytes >= load_mode_size) cmp_bytes = load_mode_size; - else if (TARGET_EFFICIENT_OVERLAPPING_UNALIGNED) + else if (TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT) { /* Move this load back so it doesn't go past the end. P8/P9 can do this efficiently. */ @@ -2026,7 +2026,7 @@ expand_block_compare (rtx operands[]) /* The code generated for p7 and older is not faster than glibc memcmp if alignment is small and length is not short, so bail out to avoid those conditions. */ - if (!TARGET_EFFICIENT_OVERLAPPING_UNALIGNED + if (!TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT && ((base_align == 1 && bytes > 16) || (base_align == 2 && bytes > 32))) return false; @@ -2168,7 +2168,7 @@ expand_strncmp_gpr_sequence (unsigned HOST_WIDE_INT bytes_to_compare, load_mode_size = GET_MODE_SIZE (load_mode); if (bytes_to_compare >= load_mode_size) cmp_bytes = load_mode_size; - else if (TARGET_EFFICIENT_OVERLAPPING_UNALIGNED) + else if (TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT) { /* Move this load back so it doesn't go past the end. P8/P9 can do this efficiently. */ diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 326c45221e9..2f3a82942c1 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -483,9 +483,9 @@ extern int rs6000_vector_align[]; #define TARGET_NO_SF_SUBREG TARGET_DIRECT_MOVE_64BIT #define TARGET_ALLOW_SF_SUBREG (!TARGET_DIRECT_MOVE_64BIT) -/* This wants to be set for p8 and newer. On p7, overlapping unaligned - loads are slow. */ -#define TARGET_EFFICIENT_OVERLAPPING_UNALIGNED TARGET_EFFICIENT_UNALIGNED_VSX +/* Like TARGET_EFFICIENT_UNALIGNED_VSX, indicates if unaligned fixed point + loads/stores are efficient. */ +#define TARGET_EFFICIENT_UNALIGNED_FIXEDPOINT (!STRICT_ALIGNMENT) /* Byte/char syncs were added as phased in for ISA 2.06B, but are not present in power7, so conditionalize them on p8 features. TImode syncs need quad diff --git a/gcc/testsuite/gcc.target/powerpc/target_efficient_unaligned_fixedpoint-1.c b/gcc/testsuite/gcc.target/powerpc/target_efficient_unaligned_fixedpoint-1.c new file mode 100644 index 00000000000..e090755e23f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/target_efficient_unaligned_fixedpoint-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mdejagnu-cpu=power8 -mno-vsx" } */ +/* { dg-final { scan-assembler-not {\mbl memcmp\M} } } */ + +int foo (const char* s1, const char* s2) +{ + return __builtin_memcmp (s1, s2, 20); +} diff --git a/gcc/testsuite/gcc.target/powerpc/target_efficient_unaligned_fixedpoint-2.c b/gcc/testsuite/gcc.target/powerpc/target_efficient_unaligned_fixedpoint-2.c new file mode 100644 index 00000000000..c7ebcd90a0b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/target_efficient_unaligned_fixedpoint-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target le } } */ +/* { dg-options "-O2 -mdejagnu-cpu=power7 -mno-vsx" } */ +/* { dg-final { scan-assembler-times {\mbl memcmp\M} 1 } } */ + +int foo (const char* s1, const char* s2) +{ + return __builtin_memcmp (s1, s2, 20); +}