public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102722] New: [Disgnostic]Xpass for gcc.dg/Wstringop-overflow-68.c after O2 vectorization.
@ 2021-10-13  2:49 crazylht at gmail dot com
  2021-10-20  2:13 ` [Bug middle-end/102722] " cvs-commit at gcc dot gnu.org
  2021-12-16 18:28 ` msebor at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: crazylht at gmail dot com @ 2021-10-13  2:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102722
           Summary: [Disgnostic]Xpass for gcc.dg/Wstringop-overflow-68.c
                    after O2 vectorization.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

void warn_comp_lit (void)
{
  *(AC2*)a1 = Ac2;      // { dg-warning "writing 2 bytes into a region of size
1" "pr101475" { xfail *-*-* } }

  // and warning should be expected, refer to PR102697.
  *(AC4*)a2 = Ac4;      // { dg-warning "writing 4 bytes into a region of size
2" "pr101475" { xfail { ! { i?86-*-* x86_64-*-* } } } }
  *(AC4*)a3 = Ac4;      // { dg-warning "writing 4 bytes into a region of size
3" "pr101475" { xfail { ! { i?86-*-* x86_64-*-* } } } }
  *(AC8*)a4 = Ac8;      // { dg-warning "writing 8 bytes into a region of size
4" "pr101475" { xfail { ! { i?86-*-* x86_64-*-* } } } }
  *(AC8*)a7 = Ac8;      // { dg-warning "writing 8 bytes into a region of size
7" "pr101475" { xfail { ! { i?86-*-* x86_64-*-* } } } }
  *(AC16*)a15 = Ac16;   // { dg-warning "writing 16 bytes into a region of size
15" "pr101475" { xfail { ! { i?86-*-* x86_64-*-* } } } }
}

The xpass here looks exact what we want,After vectorization, it's optimized to
  // MEM <vector(4) char> [(char *)&a2] = { 0, 1, 2, 3 };
  // MEM <vector(4) char> [(char *)&a3] = { 0, 1, 2, 3 };
  // MEM <vector(8) char> [(char *)&a4] = { 0, 1, 2, 3, 4, 5, 6, 7 };
  // MEM <vector(8) char> [(char *)&a7] = { 0, 1, 2, 3, 4, 5, 6, 7 };
  // MEM <vector(16) char> [(char *)&a15] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15 };
and Wstring-overflow catchs these.

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

* [Bug middle-end/102722] [Disgnostic]Xpass for gcc.dg/Wstringop-overflow-68.c after O2 vectorization.
  2021-10-13  2:49 [Bug middle-end/102722] New: [Disgnostic]Xpass for gcc.dg/Wstringop-overflow-68.c after O2 vectorization crazylht at gmail dot com
@ 2021-10-20  2:13 ` cvs-commit at gcc dot gnu.org
  2021-12-16 18:28 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ 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=102722

--- Comment #1 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] 3+ messages in thread

* [Bug middle-end/102722] [Disgnostic]Xpass for gcc.dg/Wstringop-overflow-68.c after O2 vectorization.
  2021-10-13  2:49 [Bug middle-end/102722] New: [Disgnostic]Xpass for gcc.dg/Wstringop-overflow-68.c after O2 vectorization crazylht at gmail dot com
  2021-10-20  2:13 ` [Bug middle-end/102722] " cvs-commit at gcc dot gnu.org
@ 2021-12-16 18:28 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-16 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Target|                            |sparc-sun-solaris2.11
             Status|UNCONFIRMED                 |RESOLVED
   Last reconfirmed|                            |2021-12-16
                 CC|                            |msebor at gcc dot gnu.org
               Host|x86_64-pc-linux-gnu         |

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The underlying problem behind the fails/xfails in the test boils down to
pr101475.  Here's a small test case that shows what's going on.  With an x86_64
native GCC 12 -Wstringop-overflow triggers for the overflow in fa4() but not
for the one in fa3().  The reason is the difference in the IL (the expected
instances of the warning are issued from tree-ssa-strlen.c): GCC 12 handles the
vectorized assignment in the latter but not the form in fa3(). The reason for
the missing warning is that for COMPONENT_REF, compute_objsize() only considers
the size of the sobobject and not also that of the complete object (like the
underlying buffer).

$ cat pr102722.c && gcc -O2 -S -fdump-tree-strlen=/dev/stdout pr102722.c
typedef struct AC3 { char a[3]; } AC3;
typedef struct AC4 { char a[4]; } AC4;

extern char a1[1];

void fa3 (void)
{
  *(AC3*)a1 = (AC3) { 0, 1, 2 };  // { dg-warning "-Wstringop-overflow" }
}

void fa4 (void)
{
  *(AC4*)a1 = (AC4) { 0, 1, 2, 3 };  // { dg-warning "-Wstringop-overflow" }
}



;; Function fa3 (fa3, funcdef_no=0, decl_uid=1985, cgraph_uid=1,
symbol_order=0)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
void fa3 ()
{
  <bb 2> [local count: 1073741824]:
  MEM[(struct AC3 *)&a1].a[0] = 0;
  MEM[(struct AC3 *)&a1].a[1] = 1;
  MEM[(struct AC3 *)&a1].a[2] = 2;
  return;

}



;; Function fa4 (fa4, funcdef_no=1, decl_uid=1989, cgraph_uid=2,
symbol_order=1)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
pr102722.c: In function ‘fa4’:
pr102722.c:13:13: warning: writing 4 bytes into a region of size 1
[-Wstringop-overflow=]
   13 |   *(AC4*)a1 = (AC4) { 0, 1, 2, 3 };  // { dg-warning
"-Wstringop-overflow" }
      |   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
pr102722.c:4:13: note: destination object ‘a1’ of size 1
    4 | extern char a1[1];
      |             ^~
void fa4 ()
{
  char * vectp.10;
  vector(4) char * vectp_a1.9;

  <bb 2> [local count: 1073741824]:
  MEM <vector(4) char> [(char *)&a1] = { 0, 1, 2, 3 };
  return;

}

*** This bug has been marked as a duplicate of bug 101475 ***

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

end of thread, other threads:[~2021-12-16 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13  2:49 [Bug middle-end/102722] New: [Disgnostic]Xpass for gcc.dg/Wstringop-overflow-68.c after O2 vectorization crazylht at gmail dot com
2021-10-20  2:13 ` [Bug middle-end/102722] " cvs-commit at gcc dot gnu.org
2021-12-16 18:28 ` msebor 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).