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: 81859 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E77E3857B8B for ; Mon, 11 Dec 2023 01:49:53 +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+patchwork=sourceware.org@gcc.gnu.org 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); +}