public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds
@ 2022-12-03  8:15 Alexandre Oliva
  2022-12-03 10:04 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Oliva @ 2022-12-03  8:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: Rainer Orth, Mike Stump, Martin Sebor, Hongtao Liu, Kewen Lin


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 take cost analysis into account, which
leads to omitted expected warnings and to unexpected warnings.

On riscv64-elf and arm-eabi/-mcpu=cortex-r5, for example, though the
Warray-bounds-48.c condition passes, we don't issue warnings because
we decide not to vectorize the assignments.

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=cortex-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 cost analyses that lead to the mismatched decisions, I'm disabling
the undesired warnings for these two tests.

Regstrapping on x86_64-linux-gnu, also tested with crosses to
riscv64-elf and arm-eabi.  Ok to install?


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 } */
 
+/* pr102706: disabled warnings because the now-disabled conditions for the
+   bogus warnings to come up do not take cost analysis into account, and often
+   come up wrong.  */
+/* { dg-additional-options "-Wno-stringop-overflow" } */
+
 typedef __INT16_TYPE__ int16_t;
 typedef __INT32_TYPE__ int32_t;
 
@@ -30,7 +35,8 @@ static void nowarn_ax_extern (struct AX *p)
 
 static void warn_ax_local_buf (struct AX *p)
 {
-  p->ax[0] = 4; p->ax[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align &&  { ! vect_slp_v4hi_store_unalign } } } }
+  p->ax[0] = 4; p->ax[1] = 5;  // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                               //   { xfail { vect_slp_v2hi_store_align &&  { ! vect_slp_v4hi_store_unalign } } }
 
   p->ax[2] = 6;     // { dg-warning "\\\[-Warray-bounds" }
   p->ax[3] = 7;     // { dg-warning "\\\[-Warray-bounds" }
@@ -130,7 +136,8 @@ static void warn_a0_extern (struct A0 *p)
 
 static void warn_a0_local_buf (struct A0 *p)
 {
-  p->a0[0] = 4; p->a0[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } }
+  p->a0[0] = 4; p->a0[1] = 5;  // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                               //   { xfail { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } }
 
   p->a0[2] = 6;     // { dg-warning "\\\[-Warray-bounds" }
   p->a0[3] = 7;     // { dg-warning "\\\[-Warray-bounds" }
diff --git a/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c b/gcc/testsuite/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" } */
 
+/* pr102706: disabled warnings because the now-disabled conditions for the
+   bogus warnings to come up do not take cost analysis into account, and often
+   come up wrong.  */
+/* { dg-additional-options "-Wno-stringop-overflow" } */
+
 void sink (void*);
 
 struct A { int i; };
@@ -87,7 +92,8 @@ void test_C_global_buf (void)
   p->b1.a[ 1].i = 0;     // { dg-warning "\\\[-Wzero-length-bounds" }
   sink (p);
 
-  p->b2.a[ 0].i = 0;    // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } } }
+  p->b2.a[ 0].i = 0;    // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                        //   { xfail { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } }
   p->b2.a[ 1].i = 0;
   p->b2.a[ 2].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
   p->b2.a[ 3].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
@@ -117,7 +123,8 @@ void test_C_local_buf (void)
   p->b1.a[ 1].i = 8;     // { dg-warning "\\\[-Wzero-length-bounds" }
   sink (p);
 
-  p->b2.a[ 0].i = 9;
+  p->b2.a[ 0].i = 9;    // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                        //   { xfail { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } }
   p->b2.a[ 1].i = 10;
   p->b2.a[ 2].i = 11;    // { dg-warning "\\\[-Warray-bounds" }
   p->b2.a[ 3].i = 12;    // { dg-warning "\\\[-Warray-bounds" }

-- 
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 <https://stallmansupport.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds
  2022-12-03  8:15 [PATCH] [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds Alexandre Oliva
@ 2022-12-03 10:04 ` Richard Biener
  2022-12-08 10:43   ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2022-12-03 10:04 UTC (permalink / raw)
  To: Alexandre Oliva
  Cc: gcc-patches, Rainer Orth, Mike Stump, Martin Sebor, Hongtao Liu,
	Kewen Lin



> Am 03.12.2022 um 09:16 schrieb Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org>:
> 
> 
> 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 take cost analysis into account, which
> leads to omitted expected warnings and to unexpected warnings.
> 
> On riscv64-elf and arm-eabi/-mcpu=cortex-r5, for example, though the
> Warray-bounds-48.c condition passes, we don't issue warnings because
> we decide not to vectorize the assignments.
> 
> 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=cortex-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 cost analyses that lead to the mismatched decisions, I'm disabling
> the undesired warnings for these two tests.
> 
> Regstrapping on x86_64-linux-gnu, also tested with crosses to
> riscv64-elf and arm-eabi.  Ok to install?

If it’s cost can you try-fno-vect-cost-model? If that works it might be better? Otherwise OK.

Richard 


> 
> 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 } */
> 
> +/* pr102706: disabled warnings because the now-disabled conditions for the
> +   bogus warnings to come up do not take cost analysis into account, and often
> +   come up wrong.  */
> +/* { dg-additional-options "-Wno-stringop-overflow" } */
> +
> typedef __INT16_TYPE__ int16_t;
> typedef __INT32_TYPE__ int32_t;
> 
> @@ -30,7 +35,8 @@ static void nowarn_ax_extern (struct AX *p)
> 
> static void warn_ax_local_buf (struct AX *p)
> {
> -  p->ax[0] = 4; p->ax[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align &&  { ! vect_slp_v4hi_store_unalign } } } }
> +  p->ax[0] = 4; p->ax[1] = 5;  // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
> +                               //   { xfail { vect_slp_v2hi_store_align &&  { ! vect_slp_v4hi_store_unalign } } }
> 
>   p->ax[2] = 6;     // { dg-warning "\\\[-Warray-bounds" }
>   p->ax[3] = 7;     // { dg-warning "\\\[-Warray-bounds" }
> @@ -130,7 +136,8 @@ static void warn_a0_extern (struct A0 *p)
> 
> static void warn_a0_local_buf (struct A0 *p)
> {
> -  p->a0[0] = 4; p->a0[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } }
> +  p->a0[0] = 4; p->a0[1] = 5;  // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
> +                               //   { xfail { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } }
> 
>   p->a0[2] = 6;     // { dg-warning "\\\[-Warray-bounds" }
>   p->a0[3] = 7;     // { dg-warning "\\\[-Warray-bounds" }
> diff --git a/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c b/gcc/testsuite/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" } */
> 
> +/* pr102706: disabled warnings because the now-disabled conditions for the
> +   bogus warnings to come up do not take cost analysis into account, and often
> +   come up wrong.  */
> +/* { dg-additional-options "-Wno-stringop-overflow" } */
> +
> void sink (void*);
> 
> struct A { int i; };
> @@ -87,7 +92,8 @@ void test_C_global_buf (void)
>   p->b1.a[ 1].i = 0;     // { dg-warning "\\\[-Wzero-length-bounds" }
>   sink (p);
> 
> -  p->b2.a[ 0].i = 0;    // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } } }
> +  p->b2.a[ 0].i = 0;    // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
> +                        //   { xfail { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } }
>   p->b2.a[ 1].i = 0;
>   p->b2.a[ 2].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
>   p->b2.a[ 3].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
> @@ -117,7 +123,8 @@ void test_C_local_buf (void)
>   p->b1.a[ 1].i = 8;     // { dg-warning "\\\[-Wzero-length-bounds" }
>   sink (p);
> 
> -  p->b2.a[ 0].i = 9;
> +  p->b2.a[ 0].i = 9;    // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
> +                        //   { xfail { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } }
>   p->b2.a[ 1].i = 10;
>   p->b2.a[ 2].i = 11;    // { dg-warning "\\\[-Warray-bounds" }
>   p->b2.a[ 3].i = 12;    // { dg-warning "\\\[-Warray-bounds" }
> 
> -- 
> 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 <https://stallmansupport.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds
  2022-12-03 10:04 ` Richard Biener
@ 2022-12-08 10:43   ` Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-12-08 10:43 UTC (permalink / raw)
  To: Richard Biener
  Cc: gcc-patches, Rainer Orth, Mike Stump, Martin Sebor, Hongtao Liu,
	Kewen Lin

On Dec  3, 2022, Richard Biener <richard.guenther@gmail.com> wrote:

>> On riscv64-elf and arm-eabi/-mcpu=cortex-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’s cost can you try-fno-vect-cost-model? If that works it might
> 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=cortex-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=cortex-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 } */
 
+/* pr102706: disabled warnings because the now-disabled conditions for the
+   bogus warnings to come up do not take cost analysis into account, and often
+   come up wrong.  */
+/* { dg-additional-options "-Wno-stringop-overflow" } */
+
 typedef __INT16_TYPE__ int16_t;
 typedef __INT32_TYPE__ int32_t;
 
@@ -30,7 +35,8 @@ static void nowarn_ax_extern (struct AX *p)
 
 static void warn_ax_local_buf (struct AX *p)
 {
-  p->ax[0] = 4; p->ax[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align &&  { ! vect_slp_v4hi_store_unalign } } } }
+  p->ax[0] = 4; p->ax[1] = 5;  // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                               //   { xfail { vect_slp_v2hi_store_align &&  { ! vect_slp_v4hi_store_unalign } } }
 
   p->ax[2] = 6;     // { dg-warning "\\\[-Warray-bounds" }
   p->ax[3] = 7;     // { dg-warning "\\\[-Warray-bounds" }
@@ -130,7 +136,8 @@ static void warn_a0_extern (struct A0 *p)
 
 static void warn_a0_local_buf (struct A0 *p)
 {
-  p->a0[0] = 4; p->a0[1] = 5;  // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } }
+  p->a0[0] = 4; p->a0[1] = 5;  // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                               //   { xfail { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } }
 
   p->a0[2] = 6;     // { dg-warning "\\\[-Warray-bounds" }
   p->a0[3] = 7;     // { dg-warning "\\\[-Warray-bounds" }
diff --git a/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c b/gcc/testsuite/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" } */
 
+/* pr102706: disabled warnings because the now-disabled conditions for the
+   bogus warnings to come up do not take cost analysis into account, and often
+   come up wrong.  */
+/* { dg-additional-options "-Wno-stringop-overflow" } */
+
 void sink (void*);
 
 struct A { int i; };
@@ -87,7 +92,8 @@ void test_C_global_buf (void)
   p->b1.a[ 1].i = 0;     // { dg-warning "\\\[-Wzero-length-bounds" }
   sink (p);
 
-  p->b2.a[ 0].i = 0;    // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } } }
+  p->b2.a[ 0].i = 0;    // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                        //   { xfail { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } }
   p->b2.a[ 1].i = 0;
   p->b2.a[ 2].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
   p->b2.a[ 3].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
@@ -117,7 +123,8 @@ void test_C_local_buf (void)
   p->b1.a[ 1].i = 8;     // { dg-warning "\\\[-Wzero-length-bounds" }
   sink (p);
 
-  p->b2.a[ 0].i = 9;
+  p->b2.a[ 0].i = 9;    // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" }
+                        //   { xfail { vect_slp_v2si_store_align &&  { ! vect_slp_v4si_store_unalign } } }
   p->b2.a[ 1].i = 10;
   p->b2.a[ 2].i = 11;    // { dg-warning "\\\[-Warray-bounds" }
   p->b2.a[ 3].i = 12;    // { dg-warning "\\\[-Warray-bounds" }


-- 
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 <https://stallmansupport.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-08 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-03  8:15 [PATCH] [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds Alexandre Oliva
2022-12-03 10:04 ` Richard Biener
2022-12-08 10:43   ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).