From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id E801E3810AEC; Thu, 8 Dec 2022 10:44:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E801E3810AEC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8F3AD116FE7; Thu, 8 Dec 2022 05:44:02 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4xMWzia+1D0L; Thu, 8 Dec 2022 05:44:02 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 748BA116FE4; Thu, 8 Dec 2022 05:44:01 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2B8AhjKC091428 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 8 Dec 2022 07:43:45 -0300 From: Alexandre Oliva To: Richard Biener Cc: gcc-patches@gcc.gnu.org, Rainer Orth , Mike Stump , Martin Sebor , Hongtao Liu , Kewen Lin Subject: Re: [PATCH] [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds Organization: Free thinker, does not speak for AdaCore References: <01D2C372-75C9-48AE-8547-240D30895291@gmail.com> Errors-To: aoliva@lxoliva.fsfla.org Date: Thu, 08 Dec 2022 07:43:45 -0300 In-Reply-To: <01D2C372-75C9-48AE-8547-240D30895291@gmail.com> (Richard Biener's message of "Sat, 3 Dec 2022 11:04:52 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,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 List-Id: On Dec 3, 2022, Richard Biener wrote: >> On riscv64-elf and arm-eabi/-mcpu=3Dcortex-r5, for example, though the >> Warray-bounds-48.c condition passes, we don't issue warnings because >> we decide not to vectorize the assignments. > If it=E2=80=99s cost can you try-fno-vect-cost-model? If that works it mi= ght > be better? Otherwise OK. I tried it, and learned it wasn't about costs after all, so I've adjusted the commit message to reflect this finding. I also caught a mistake in the paragraph quoted above from the commit message. We *do* vectorize on ARM, but don't issue the expected bogus warning. Here's what I'm checking in, thanks! [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds The bogus Wstringop-overflow warnings conditionally issued for Warray-bounds-48.c and -Wzero-length-array-bounds-2.c are expected under conditions that depend on the availability of certain vector patterns, but that don't seem to model the conditions under which the warnings are expected. On riscv64-elf and arm-eabi/-mcpu=3Dcortex-r5, for example, though the Warray-bounds-48.c condition passes, we don't issue warnings. On riscv64-elf, we decide not to vectorize the assignments; on cortex-r5, we do vectorize pairs of assignments, but that doesn't yield the expected warning, even though assignments that should trigger the bogus warning are vectorized and associated with the earlier line where the bogus warning would be expected. On riscv64, for Wzero-length-array-bounds-2.c, we issue the expected warning in test_C_global_buf, but we also issue a warning for test_C_local_buf under the same conditions, that would be expected on other platforms but that is not issued on them. On arm-eabi/-mcpu=3Dcortex-r5, the condition passes so we'd expect the warning in both functions, but we don't warn on either. Instead of further extending the effective target tests, introduced to temporarily tolerate these expected bogus warnings, so as to capture the vectorizer analyses that lead to the mismatched decisions, I'm disabling the undesired warnings for these two tests. for gcc/testsuite/ChangeLog PR tree-optimization/102706 * gcc.dg/Warray-bounds-48.c: Disable -Wstringop-overflow. * gcc.dg/Wzero-length-array-bounds-2.c: Likewise. --- gcc/testsuite/gcc.dg/Warray-bounds-48.c | 11 +++++++++-- gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-48.c b/gcc/testsuite/gcc.dg= /Warray-bounds-48.c index 775b301e37537..e9203140a274a 100644 --- a/gcc/testsuite/gcc.dg/Warray-bounds-48.c +++ b/gcc/testsuite/gcc.dg/Warray-bounds-48.c @@ -4,6 +4,11 @@ { dg-options "-O2 -Wall" } { dg-require-effective-target alloca } */ =20 +/* pr102706: disabled warnings because the now-disabled conditions for the + bogus warnings to come up do not take cost analysis into account, and o= ften + come up wrong. */ +/* { dg-additional-options "-Wno-stringop-overflow" } */ + typedef __INT16_TYPE__ int16_t; typedef __INT32_TYPE__ int32_t; =20 @@ -30,7 +35,8 @@ static void nowarn_ax_extern (struct AX *p) =20 static void warn_ax_local_buf (struct AX *p) { - p->ax[0] =3D 4; p->ax[1] =3D 5; // { dg-warning "\\\[-Wstringop-overflo= w" "pr102706" { target { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_st= ore_unalign } } } } + p->ax[0] =3D 4; p->ax[1] =3D 5; // { dg-bogus "\\\[-Wstringop-overflow"= "pr102706" } + // { xfail { vect_slp_v2hi_store_align &&= { ! vect_slp_v4hi_store_unalign } } } =20 p->ax[2] =3D 6; // { dg-warning "\\\[-Warray-bounds" } p->ax[3] =3D 7; // { dg-warning "\\\[-Warray-bounds" } @@ -130,7 +136,8 @@ static void warn_a0_extern (struct A0 *p) =20 static void warn_a0_local_buf (struct A0 *p) { - p->a0[0] =3D 4; p->a0[1] =3D 5; // { dg-warning "\\\[-Wstringop-overflo= w" "pr102706" { target { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_sto= re_unalign } } } } + p->a0[0] =3D 4; p->a0[1] =3D 5; // { dg-bogus "\\\[-Wstringop-overflow"= "pr102706" } + // { xfail { vect_slp_v2hi_store_align &&= { ! vect_slp_v4hi_store_unalign } } } =20 p->a0[2] =3D 6; // { dg-warning "\\\[-Warray-bounds" } p->a0[3] =3D 7; // { dg-warning "\\\[-Warray-bounds" } diff --git a/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c b/gcc/tests= uite/gcc.dg/Wzero-length-array-bounds-2.c index 2ef5ccd564ac4..19932d05a315f 100644 --- a/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c +++ b/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c @@ -4,6 +4,11 @@ { dg-do compile } { dg-options "-O2 -Wall" } */ =20 +/* pr102706: disabled warnings because the now-disabled conditions for the + bogus warnings to come up do not take cost analysis into account, and o= ften + come up wrong. */ +/* { dg-additional-options "-Wno-stringop-overflow" } */ + void sink (void*); =20 struct A { int i; }; @@ -87,7 +92,8 @@ void test_C_global_buf (void) p->b1.a[ 1].i =3D 0; // { dg-warning "\\\[-Wzero-length-bounds" } sink (p); =20 - p->b2.a[ 0].i =3D 0; // { dg-warning "\\\[-Wstringop-overflow" "pr102= 706" { target { vect_slp_v2si_store_align && { ! vect_slp_v4si_store_unali= gn } } } } + p->b2.a[ 0].i =3D 0; // { dg-bogus "\\\[-Wstringop-overflow" "pr10270= 6" } + // { xfail { vect_slp_v2si_store_align && { ! v= ect_slp_v4si_store_unalign } } } p->b2.a[ 1].i =3D 0; p->b2.a[ 2].i =3D 0; // { dg-warning "\\\[-Warray-bounds" } p->b2.a[ 3].i =3D 0; // { dg-warning "\\\[-Warray-bounds" } @@ -117,7 +123,8 @@ void test_C_local_buf (void) p->b1.a[ 1].i =3D 8; // { dg-warning "\\\[-Wzero-length-bounds" } sink (p); =20 - p->b2.a[ 0].i =3D 9; + p->b2.a[ 0].i =3D 9; // { dg-bogus "\\\[-Wstringop-overflow" "pr10270= 6" } + // { xfail { vect_slp_v2si_store_align && { ! v= ect_slp_v4si_store_unalign } } } p->b2.a[ 1].i =3D 10; p->b2.a[ 2].i =3D 11; // { dg-warning "\\\[-Warray-bounds" } p->b2.a[ 3].i =3D 12; // { dg-warning "\\\[-Warray-bounds" } --=20 Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about