From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93619 invoked by alias); 22 Nov 2019 00:52:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 93609 invoked by uid 89); 22 Nov 2019 00:52:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Google-Smtp-Source:APXvYqzh X-HELO: mail-pl1-f195.google.com Received: from mail-pl1-f195.google.com (HELO mail-pl1-f195.google.com) (209.85.214.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Nov 2019 00:52:56 +0000 Received: by mail-pl1-f195.google.com with SMTP id o9so2363574plk.6 for ; Thu, 21 Nov 2019 16:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=N3oiZpIvs5L1//UY4Y0C4jWEnxFrdjJuuXmghNvi3wI=; b=pWX+kZwStd6BAU1roedYOr0nShR44mcDSAumpgYXmxMZMbaQlN+9Yt1nW0paSAYAxb PtrNpEqIlny+4i5tA7grAVpU4u6eNHM7Fpkvyn/Hy05Jux+qbCS7TBqFSrD8UcARY8TI CuMfAfShEIIDsaZwjtKv5kX5ec9W5nVDZjt27Pi4oElBZo0iWFSuO6BUZgjrJSRjDU4T yTZwaHfiq8TVPbT4cQiSJDtq+9WgBCpstlAGUAzaiZvtsDUX4VvGGSBT4wgLZ/TGhi20 7O5Y5cSk4YCrHneyqbVWEzO9/XYhpVpCUwbamodAXp7Qj91AufW2TcgfKrD7nUtorcqs dzNg== Return-Path: Received: from [192.168.0.41] (97-118-98-145.hlrn.qwest.net. [97.118.98.145]) by smtp.gmail.com with ESMTPSA id v17sm5185670pfc.41.2019.11.21.16.52.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2019 16:52:52 -0800 (PST) Subject: Re: [PATCH] testsuite: Fix array size in gcc.dg/strlenopt-66.c To: Dimitar Dimitrov , gcc-patches@gcc.gnu.org References: <20191121171159.21853-1-dimitar@dinux.eu> <6102992.SbpC3aTTDs@tpdeb> From: Martin Sebor Message-ID: <2c6765ae-a6ac-5ce0-ed2c-65b8ba4b6e39@gmail.com> Date: Fri, 22 Nov 2019 00:57:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <6102992.SbpC3aTTDs@tpdeb> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg02166.txt.bz2 On 11/21/19 2:24 PM, Dimitar Dimitrov wrote: > On Thu, 21 Nov 2019, 20:09:23 EET Martin Sebor wrote: >> On 11/21/19 10:11 AM, Dimitar Dimitrov wrote: >>> One of the passed arguments is actually a string with size 4 ("123"). >>> Adjust the destination buffer accordingly. >>> >>> gcc/testsuite/ChangeLog: >>> >>> 2019-11-21 Dimitar Dimitrov >>> >>> * gcc.dg/strlenopt-66.c (test_strncmp_a4_cond_a5_a3_n): Fix array size. >>> >>> Signed-off-by: Dimitar Dimitrov >>> --- >>> >>> gcc/testsuite/gcc.dg/strlenopt-66.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/gcc/testsuite/gcc.dg/strlenopt-66.c >>> b/gcc/testsuite/gcc.dg/strlenopt-66.c index 4ba31a845b0..3de22c18f4f >>> 100644 >>> --- a/gcc/testsuite/gcc.dg/strlenopt-66.c >>> +++ b/gcc/testsuite/gcc.dg/strlenopt-66.c >>> @@ -88,7 +88,7 @@ __attribute__ ((noclone, noinline, noipa)) void >>> >>> test_strncmp_a4_cond_a5_a3_n (const char *s1, const char *s2, const char >>> *s3,> >>> int i, unsigned n) >>> >>> { >>> >>> - char a3[3], a4[4], a5[5]; >>> + char a3[4], a4[4], a5[5]; >> >> That does look like a mistake. Thanks for bringing it up! >> >> The purpose of the test is to exercise strncmp calls whose first >> two arguments involve arrays of all different sizes (and strings >> of different lengths stored in them). In this function, >> the operands of the conditional expression should also be of >> different sizes than the first argument: one should be smaller >> and the other bigger. >> >> So to keep the test doing what it's meant to do I think we need >> to change lengths of the strings passed to the function to fit >> the arrays rather than the sizes of the locals. (Adding even >> more calls to cover all the permutations of lengths and sizes >> would be a further improvement.) >> >> If this sounds too elaborate let me know and I'll fix the test. >> >> Martin > Hi, > > I admit I'm a bit confused, so I'll let you fix the test as you see fit. > > With "noipa" function attribute the compiler should not be able to propagate > the string constants, so a3/a4/a5 string lengths are unknown when strncmp is > invoked. I don't understand how PR90626 would take effect in such case. The optimization doesn't take effect but the lengths can be assumed to be in the range of the arrays (e.g., the length of a3 can be assumed to be less than 3). The test tries to verify that the comparison of the strncmp call with zero doesn't get folded into false solely based on the ranges of the lengths. It's probably not a the best test. > Also, I fail to see how the different sizes of local arrays influence the > test. They shouldn't influence the outcome of the test but they are considered by the strncmp optimization (and others that deal with strings) because they determine the ranges of lengths of the strings that can be stored in them. I committed r278608 with the fix and added a few more cases. Martin