public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102744] New: [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf
@ 2021-10-14 13:48 law at gcc dot gnu.org
  2021-10-14 16:55 ` [Bug tree-optimization/102744] " msebor at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: law at gcc dot gnu.org @ 2021-10-14 13:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102744

            Bug ID: 102744
           Summary: [12 regression] -O2 vectorization causes
                    Wzero-length-array-bounds-2.c to fail on arc-elf
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

Starting with the patch to vectorize at -O2,
gcc.dg/Wzero-length-array-bounds-2.c has started failing on arc-elf.  We're
getting an additional diagnostic:

/home/jlaw/test/gcc/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:90:17:
warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=]

This may well be the same underlying issue as the other problems we're chasing
in this space, if that turns out to be the case, just mark this is a duplicate.
 I haven't debugged it in any notable way.  It should reproduce with just a
cross compiler.

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

* [Bug tree-optimization/102744] [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf
  2021-10-14 13:48 [Bug tree-optimization/102744] New: [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf law at gcc dot gnu.org
@ 2021-10-14 16:55 ` msebor at gcc dot gnu.org
  2021-10-15  1:31 ` crazylht at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-14 16:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102744

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |liuhongt at gcc dot gnu.org
   Last reconfirmed|                            |2021-10-14
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |102706
   Target Milestone|---                         |12.0
           Keywords|                            |diagnostic
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Here's the relevant part of the test with line numbers:

    68  char cbuf1[1 * sizeof (struct C)];
    69  char cbuf2[2 * sizeof (struct C)] = { };
    70  
    71  void test_C_global_buf (void)
    72  {
    73    struct C *p = (struct C*)&cbuf1;
   ...
    84    p = (struct C*)&cbuf2;
   ...
    90    p->b2.a[ 0].i = 0;
    91    p->b2.a[ 1].i = 0;
    92    p->b2.a[ 2].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
    93    p->b2.a[ 3].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
    94    sink (p);

ad the output is below.  We get the two -Warray-bounds instances as expected;
they are issued before vectorization.  Then we get an additional
-Wstringop-overflow for the valid store on line 90 from the strlen pass thanks
to the four stores having been vectorized.  So the problem is basically the
same as in one of the other reports.  I hesistate to mark this a dupe only
because it will need its own suppression (CC'ing Hongtao as a heads up).

As an aside, these regressions will no doubt make the warnings pretty confusing
to users.  We (i.e., I) should try to come up with a fix before GCC 12 goes out
the door.  I don't expect to have the time to to get to it before stage 1 ends.

/src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:92:10:
warning: array subscript 2 is above array bounds of 'struct A[0]'
[-Warray-bounds]
   92 |   p->b2.a[ 2].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
      |   ~~~~~~~^~~~
/src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:10:28: note:
while referencing 'a'
   10 | struct B { int j; struct A a[0]; };
      |                            ^
/src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:93:10:
warning: array subscript 3 is above array bounds of 'struct A[0]'
[-Warray-bounds]
   93 |   p->b2.a[ 3].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
      |   ~~~~~~~^~~~
/src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:10:28: note:
while referencing 'a'
   10 | struct B { int j; struct A a[0]; };
      |                            ^
/src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:90:17:
warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=]
   90 |   p->b2.a[ 0].i = 0;
      |   ~~~~~~~~~~~~~~^~~
/src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:69:6: note:
at offset 16 into destination object 'cbuf2' of size 16
   69 | char cbuf2[2 * sizeof (struct C)] = { };
      |      ^~~~~


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102706
[Bug 102706] [12 regression] -O2 vectorization causes regression in
Warray-bounds-48.c on many targets

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

* [Bug tree-optimization/102744] [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf
  2021-10-14 13:48 [Bug tree-optimization/102744] New: [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf law at gcc dot gnu.org
  2021-10-14 16:55 ` [Bug tree-optimization/102744] " msebor at gcc dot gnu.org
@ 2021-10-15  1:31 ` crazylht at gmail dot com
  2021-10-20  2:13 ` cvs-commit at gcc dot gnu.org
  2022-01-19  8:52 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2021-10-15  1:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102744

--- Comment #2 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Martin Sebor from comment #1)
> Here's the relevant part of the test with line numbers:
> 
>     68	char cbuf1[1 * sizeof (struct C)];
>     69	char cbuf2[2 * sizeof (struct C)] = { };
>     70	
>     71	void test_C_global_buf (void)
>     72	{
>     73	  struct C *p = (struct C*)&cbuf1;
>    ...
>     84	  p = (struct C*)&cbuf2;
>    ...
>     90	  p->b2.a[ 0].i = 0;
>     91	  p->b2.a[ 1].i = 0;
>     92	  p->b2.a[ 2].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
>     93	  p->b2.a[ 3].i = 0;     // { dg-warning "\\\[-Warray-bounds" }
>     94	  sink (p);
> 
> ad the output is below.  We get the two -Warray-bounds instances as
> expected; they are issued before vectorization.  Then we get an additional
> -Wstringop-overflow for the valid store on line 90 from the strlen pass
> thanks to the four stores having been vectorized.  So the problem is
What i got is 2 store vectorized which cause extra -Wstringop-overflow=
For x86 which have 4 stores vectorized, there's no extra warning.
Should be behavior of extra warning for 2 store vectorized but not 4 store
vectorized be expected

Here is dump for arc-elf
void test_C_global_buf ()
{
  int * vectp.23;
  vector(2) int * vectp_cbuf2.22;
  int * vectp.21;
  vector(2) int * vectp_cbuf2.20;
  int * vectp.19;
  vector(2) int * vectp_cbuf1.18;
  int * vectp.17;
  vector(2) int * vectp_cbuf1.16;
  int * _22;

  <bb 2> [local count: 1073741824]:
  MEM <vector(2) int> [(int *)&cbuf1] = { 0, 0 };
  MEM[(struct C *)&cbuf1].b1.a[1].i = 0;
  sink (&cbuf1);
  MEM <vector(2) int> [(int *)&cbuf1 + 8B] = { 0, 0 };
  sink (&cbuf1);
  MEM <vector(2) int> [(int *)&cbuf2] = { 0, 0 };
  MEM[(struct C *)&cbuf2].b1.a[1].i = 0;
  sink (&cbuf2);
  MEM <vector(2) int> [(int *)&cbuf2 + 8B] = { 0, 0 };
  _22 = &MEM[(struct C *)&cbuf2].b2.a[0].i + 8;
  MEM <vector(2) int> [(int *)_22] = { 0, 0 };
  sink (&cbuf2);
  return;


And dump for x86

void test_C_global_buf ()
{
  int * vectp.33;
  vector(4) int * vectp_cbuf2.32;
  int * vectp.31;
  vector(2) int * vectp_cbuf2.30;
  int * vectp.29;
  vector(2) int * vectp_cbuf1.28;
  int * vectp.27;
  vector(2) int * vectp_cbuf1.26;

  <bb 2> [local count: 1073741824]:
  MEM <vector(2) int> [(int *)&cbuf1] = { 0, 0 };
  MEM[(struct C *)&cbuf1].b1.a[1].i = 0;
  sink (&cbuf1);
  MEM <vector(2) int> [(int *)&cbuf1 + 8B] = { 0, 0 };
  sink (&cbuf1);
  MEM <vector(2) int> [(int *)&cbuf2] = { 0, 0 };
  MEM[(struct C *)&cbuf2].b1.a[1].i = 0;
  sink (&cbuf2);
  MEM <vector(4) int> [(int *)&cbuf2 + 8B] = { 0, 0, 0, 0 };
  sink (&cbuf2);
  return;

}

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

* [Bug tree-optimization/102744] [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf
  2021-10-14 13:48 [Bug tree-optimization/102744] New: [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf law at gcc dot gnu.org
  2021-10-14 16:55 ` [Bug tree-optimization/102744] " msebor at gcc dot gnu.org
  2021-10-15  1:31 ` crazylht at gmail dot com
@ 2021-10-20  2:13 ` cvs-commit at gcc dot gnu.org
  2022-01-19  8:52 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-20  2:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102744

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:3c8d8c0be95e99dc0cba7f6fad2429243582119f

commit r12-4523-g3c8d8c0be95e99dc0cba7f6fad2429243582119f
Author: liuhongt <hongtao.liu@intel.com>
Date:   Thu Oct 14 09:31:03 2021 +0800

    Adjust testcase for O2 vectorization.

    As discussed in [1], this patch add xfail/target selector to those
    testcases, also make a copy of them so that they can be tested w/o
    vectorization.

    Newly added xfail/target selectors are used to check the vectorization
    capability of continuous byte/double bytes storage, these scenarios
    are exactly the part of the testcases that regressed after O2
    vectorization.

    [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581456.html.

    2021-10-19  Hongtao Liu  <hongtao.liu@intel.com>
                Kewen Lin  <linkw@linux.ibm.com>

    gcc/ChangeLog

            * doc/sourcebuild.texi (Effective-Target Keywords): Document
            vect_slp_v2qi_store, vect_slp_v4qi_store, vect_slp_v8qi_store,
            vect_slp_v16qi_store, vect_slp_v2hi_store,
            vect_slp_v4hi_store, vect_slp_v2si_store, vect_slp_v4si_store.

    gcc/testsuite/ChangeLog

            PR middle-end/102722
            PR middle-end/102697
            PR middle-end/102462
            PR middle-end/102706
            PR middle-end/102744
            * c-c++-common/Wstringop-overflow-2.c: Adjust testcase with new
            xfail/target selector.
            * gcc.dg/Warray-bounds-51.c: Ditto.
            * gcc.dg/Warray-parameter-3.c: Ditto.
            * gcc.dg/Wstringop-overflow-14.c: Ditto.
            * gcc.dg/Wstringop-overflow-21.c: Ditto.
            * gcc.dg/Wstringop-overflow-68.c: Ditto.
            * gcc.dg/Wstringop-overflow-76.c: Ditto.
            * gcc.dg/Warray-bounds-48.c: Ditto.
            * gcc.dg/Wzero-length-array-bounds-2.c: Ditto.
            * lib/target-supports.exp (check_vect_slp_aligned_store_usage):
            New function.
            (check_effective_target_vect_slp_v2qi_store): Ditto.
            (check_effective_target_vect_slp_v4qi_store): Ditto.
            (check_effective_target_vect_slp_v8qi_store): Ditto.
            (check_effective_target_vect_slp_v16qi_store): Ditto.
            (check_effective_target_vect_slp_v2hi_store): Ditto.
            (check_effective_target_vect_slp_v4hi_store): Ditto.
            (check_effective_target_vect_slp_v2si_store): Ditto.
            (check_effective_target_vect_slp_v4si_store): Ditto.
            * c-c++-common/Wstringop-overflow-2-novec.c: New test.
            * gcc.dg/Warray-bounds-51-novec.c: New test.
            * gcc.dg/Warray-bounds-48-novec.c: New test.
            * gcc.dg/Warray-parameter-3-novec.c: New test.
            * gcc.dg/Wstringop-overflow-14-novec.c: New test.
            * gcc.dg/Wstringop-overflow-21-novec.c: New test.
            * gcc.dg/Wstringop-overflow-76-novec.c: New test.
            * gcc.dg/Wzero-length-array-bounds-2-novec.c: New test.

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

* [Bug tree-optimization/102744] [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf
  2021-10-14 13:48 [Bug tree-optimization/102744] New: [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf law at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-10-20  2:13 ` cvs-commit at gcc dot gnu.org
@ 2022-01-19  8:52 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-19  8:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102744

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The testsuite fail has been resolved.  The general issue with vectorization or
store-merging vs. those diagnostics remains but was always present with
vectorization enabled.

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

end of thread, other threads:[~2022-01-19  8:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 13:48 [Bug tree-optimization/102744] New: [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf law at gcc dot gnu.org
2021-10-14 16:55 ` [Bug tree-optimization/102744] " msebor at gcc dot gnu.org
2021-10-15  1:31 ` crazylht at gmail dot com
2021-10-20  2:13 ` cvs-commit at gcc dot gnu.org
2022-01-19  8:52 ` rguenth at gcc dot gnu.org

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).