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;

}

Reply via email to