From patchwork Tue Dec 12 19:40:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sawdey X-Patchwork-Id: 847613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-469064-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uO0JlMtO"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yx9Fh5sWtz9t34 for ; Wed, 13 Dec 2017 06:42:15 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; q=dns; s=default; b=Rk4qP+jqzlcK57rLoD1AAtTLwFUV8Dc5eodplVC/sc1 IfS8tkH77ItZDx67x3XHwmPR6dxyQX4pr7NloDGg/Ua/2gmve/LAcbSFufZPqLZq HDx7b1b9zinlGcS6oQtXk8BHWV5IdfCuWMe7u5fI1xgSrBnkD0vKXNTmlWlumuqE = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; s=default; bh=bxmpclralwV0gRkUb/I9qxdrnXs=; b=uO0JlMtOrquEPEJuA 8LAaQUN75r0nmzapuNvsayybLe7Ui+8enFpmNPegg2NTX4MChExfwEWzsX4wk1yK fnRca1OcZ7ql/4Hxq80t76sso+8lNil5HM+D7s6AUS0UTiWugYlZDtG6byYwZ/oP i3/33e/026qqQeZJpkt0uGl+2w= Received: (qmail 3112 invoked by alias); 12 Dec 2017 19:42:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3100 invoked by uid 89); 12 Dec 2017 19:42:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=aaaaaaa, believed, Hx-languages-length:2585 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Dec 2017 19:42:05 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBCJfkBa013382 for ; Tue, 12 Dec 2017 14:42:03 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ethht3qku-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 12 Dec 2017 14:41:47 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Dec 2017 14:40:45 -0500 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 12 Dec 2017 14:40:42 -0500 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vBCJegRd49807476; Tue, 12 Dec 2017 19:40:42 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADBB8AE052; Tue, 12 Dec 2017 14:41:42 -0500 (EST) Received: from ragesh3a.rchland.ibm.com (unknown [9.10.86.140]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 6EB29AE043; Tue, 12 Dec 2017 14:41:42 -0500 (EST) Subject: [PATCH][rs6000][PR target/82190] fix mem size info in rtl generated by memcmp and strncmp/strcmp builtin expansion From: Aaron Sawdey To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool , David Edelsohn , Bill Schmidt Date: Tue, 12 Dec 2017 13:40:41 -0600 Mime-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17121219-2213-0000-0000-000002495CA4 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008194; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00959266; UDB=6.00485121; IPR=6.00739288; BA=6.00005738; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018506; XFM=3.00000015; UTC=2017-12-12 19:40:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121219-2214-0000-0000-0000586C70BA Message-Id: <1513107641.30918.8.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712120280 X-IsSubscribed: yes In the code I put in gcc7 for expanding memcmp and strcmp/strncmp as builtins, I used set_mem_size to set the size of loads to only the bytes I was actually going to compare. However this is really incorrect and the test case for 82190 was failing because alias analysis believed the bogus size and though there was no conflict between an 8byte load used for comparing 6 bytes and a later store to the 7th byte. As a result it eliminated that load from the 7 byte compare that followed later. This patch changes the set_mem_size calls in expand_block_move and expand_strn_compare to set the size to the size of the load being done regardless of how many bytes are being used. OK for trunk if bootstrap/regtest passes on ppc64le? 2017-12-12 Aaron Sawdey PR target/82190 * config/rs6000/rs6000-string.c (expand_block_move, expand_strn_compare): fix set_mem_size() calls. Index: gcc/config/rs6000/rs6000-string.c =================================================================== --- gcc/config/rs6000/rs6000-string.c (revision 255585) +++ gcc/config/rs6000/rs6000-string.c (working copy) @@ -1247,6 +1247,9 @@ if (bytes > rs6000_block_move_inline_limit) return 0; + bool isP8 = (rs6000_cpu == PROCESSOR_POWER8); + bool isP9 = (rs6000_cpu == PROCESSOR_POWER9); + for (offset = 0; bytes > 0; offset += move_bytes, bytes -= move_bytes) { union { @@ -1258,7 +1261,7 @@ /* Altivec first, since it will be faster than a string move when it applies, and usually not significantly larger. */ - if (TARGET_ALTIVEC && bytes >= 16 && align >= 128) + if (TARGET_ALTIVEC && bytes >= 16 && (isP8 || isP9 || align >= 128)) { move_bytes = 16; mode = V4SImode; Index: gcc/testsuite/gcc.dg/pr82190.c =================================================================== --- gcc/testsuite/gcc.dg/pr82190.c (nonexistent) +++ gcc/testsuite/gcc.dg/pr82190.c (working copy) @@ -0,0 +1,22 @@ +/* PR target/82190 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-optimize-strlen -fweb" } */ + +char src[64] __attribute__ ((aligned)) = "aaaaaaa"; +char dst[64] __attribute__ ((aligned)); + +int +main () +{ + __builtin_memcpy (dst, src, 6); + if (__builtin_memcmp (dst, src, 6)) + __builtin_abort (); + + __builtin_memcpy (dst, src, 7); + if (__builtin_memcmp (dst, src, 7)) + __builtin_abort (); + + return 0; +} + +