public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure
@ 2024-09-03 14:47 qinzhao at gcc dot gnu.org
  2024-09-03 16:36 ` [Bug tree-optimization/116585] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2024-09-03 14:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116585
           Summary: SSA corruption with -O3,-fvect-cost-model=very-cheap
                    cures the failure
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qinzhao at gcc dot gnu.org
  Target Milestone: ---

This is bug we found with GCC8 for our very large application. and it can be
repeated till the trunk GCC. (I can reproduce it with GCC15 on both x86 and
aarch64).

the reduced testing case is:
char *s1, *s2;
extern int* my_alloc (int);
extern int _setjmp ();
extern void bar();
void foo(int s1len, int s2len) {
  int e;
  e = _setjmp ();
  {
    int l, i;
    int *md = my_alloc(((sizeof(int)) * (s1len + 1) * (s2len )));
    s1len++;
    {
      for (; s1len; l) {
        for (; s2len; l) {
          for (; s1len; i) {
            int j;
            {
              j = 1;
              for (; j < s2len; j++) {
                int cost;
                if (s1[1] == s2[1])
                  cost = 0;
                else
                  cost = 1;
                md[j * s1len ] = ((cost));
              }
            }
          }
        }
      }
    }
    bar();
  }
}
/home/opc/Install/latest-d/bin/gcc -O3 t.c

Unable to coalesce ssa_names 16 and 30 which are marked as MUST COALESCE.
s1len_16(ab) and  s1len_30(ab)
during RTL pass: expand
t.c: In function ‘foo’:
t.c:5:6: internal compiler error: SSA corruption
    5 | void foo(int s1len, int s2len) {
      |      ^~~
0x342551c internal_error(char const*, ...)
        ../../latest-gcc/gcc/diagnostic-global-context.cc:491
0x18f966c fail_abnormal_edge_coalesce
        ../../latest-gcc/gcc/tree-ssa-coalesce.cc:1012
0x18fb01f coalesce_partitions
        ../../latest-gcc/gcc/tree-ssa-coalesce.cc:1444
0x18fd11d coalesce_ssa_name(_var_map*)
        ../../latest-gcc/gcc/tree-ssa-coalesce.cc:1898
0x1866853 remove_ssa_form
        ../../latest-gcc/gcc/tree-outof-ssa.cc:1065
0x186750b rewrite_out_of_ssa(ssaexpand*)
        ../../latest-gcc/gcc/tree-outof-ssa.cc:1353
0x100c5e5 execute
        ../../latest-gcc/gcc/cfgexpand.cc:6678
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Adding -fvect-cost-model=very-cheap cures the failure on both x86 and aarch64.
/home/opc/Install/latest-d/bin/gcc -O3 -fvect-cost-model=very-cheap t.c
/home/opc/Install/latest/bin/ld: /lib/../lib64/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
/home/opc/Install/latest/bin/ld: /tmp/cceYCJoo.o: in function `foo':
t.c:(.text+0x2c): undefined reference to `my_alloc'
/home/opc/Install/latest/bin/ld: t.c:(.text+0x37): undefined reference to `bar'
collect2: error: ld returned 1 exit status

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

* [Bug tree-optimization/116585] [12/13/14/15 Regression] SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure
  2024-09-03 14:47 [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure qinzhao at gcc dot gnu.org
@ 2024-09-03 16:36 ` pinskia at gcc dot gnu.org
  2024-09-03 17:18 ` [Bug tree-optimization/116585] [12/13/14/15 Regression] SSA corruption with -O3 pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-03 16:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |10.5.0
           Keywords|                            |ice-on-valid-code
   Target Milestone|---                         |12.5
            Summary|SSA corruption with         |[12/13/14/15 Regression]
                   |-O3,-fvect-cost-model=very- |SSA corruption with
                   |cheap cures the failure     |-O3,-fvect-cost-model=very-
                   |                            |cheap cures the failure
      Known to fail|                            |11.1.0

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

* [Bug tree-optimization/116585] [12/13/14/15 Regression] SSA corruption with -O3
  2024-09-03 14:47 [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure qinzhao at gcc dot gnu.org
  2024-09-03 16:36 ` [Bug tree-optimization/116585] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
@ 2024-09-03 17:18 ` pinskia at gcc dot gnu.org
  2024-09-06  6:17 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-03 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|[12/13/14/15 Regression]    |[12/13/14/15 Regression]
                   |SSA corruption with         |SSA corruption with -O3
                   |-O3,-fvect-cost-model=very- |
                   |cheap cures the failure     |
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
   Last reconfirmed|                            |2024-09-03

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug tree-optimization/116585] [12/13/14/15 Regression] SSA corruption with -O3
  2024-09-03 14:47 [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure qinzhao at gcc dot gnu.org
  2024-09-03 16:36 ` [Bug tree-optimization/116585] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
  2024-09-03 17:18 ` [Bug tree-optimization/116585] [12/13/14/15 Regression] SSA corruption with -O3 pinskia at gcc dot gnu.org
@ 2024-09-06  6:17 ` rguenth at gcc dot gnu.org
  2024-09-18  9:11 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-09-06  6:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Something in SCEV or data-ref analysis looks through

  <bb 4> [local count: 2407868]:
  _1 = s1len_15(ab) + 1;


<bb 25>
...
  _21 = (sizetype) s1len_15(ab);
  _18 = _21 + 1; 

increasing the lifetime of s1len_15(ab)

I'll eventually see to suppress this.

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

* [Bug tree-optimization/116585] [12/13/14/15 Regression] SSA corruption with -O3
  2024-09-03 14:47 [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure qinzhao at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-09-06  6:17 ` rguenth at gcc dot gnu.org
@ 2024-09-18  9:11 ` cvs-commit at gcc dot gnu.org
  2024-09-18  9:12 ` [Bug tree-optimization/116585] [12/13/14 " rguenth at gcc dot gnu.org
  2024-09-25 15:59 ` qinzhao at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-09-18  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:1d0cb3b5fca69b81e69cfdb4aea0eebc1ac04750

commit r15-3680-g1d0cb3b5fca69b81e69cfdb4aea0eebc1ac04750
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Sep 18 09:52:55 2024 +0200

    tree-optimization/116585 - SSA corruption with split_constant_offset

    split_constant_offset when looking through SSA defs can end up
    picking SSA leafs that are subject to abnormal coalescing.  This
    can lead to downstream consumers to insert code based on the
    result (like from dataref analysis) in places that violate constraints
    for abnormal coalescing.  It's best to not expand defs whose operands
    are subject to abnormal coalescing - and not either do something when
    a subexpression has operands like that already.

            PR tree-optimization/116585
            * tree-data-ref.cc (split_constant_offset_1): When either
            operand is subject to abnormal coalescing do no further
            processing.

            * gcc.dg/torture/pr116585.c: New testcase.

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

* [Bug tree-optimization/116585] [12/13/14 Regression] SSA corruption with -O3
  2024-09-03 14:47 [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure qinzhao at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-09-18  9:11 ` cvs-commit at gcc dot gnu.org
@ 2024-09-18  9:12 ` rguenth at gcc dot gnu.org
  2024-09-25 15:59 ` qinzhao at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-09-18  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |15.0
           Priority|P3                          |P2
            Summary|[12/13/14/15 Regression]    |[12/13/14 Regression] SSA
                   |SSA corruption with -O3     |corruption with -O3

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.

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

* [Bug tree-optimization/116585] [12/13/14 Regression] SSA corruption with -O3
  2024-09-03 14:47 [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure qinzhao at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-09-18  9:12 ` [Bug tree-optimization/116585] [12/13/14 " rguenth at gcc dot gnu.org
@ 2024-09-25 15:59 ` qinzhao at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2024-09-25 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from qinzhao at gcc dot gnu.org ---
(In reply to Richard Biener from comment #4)
> Fixed on trunk sofar.

thanks a lot for fixing this so quick. 
Will this patch be backported to older releases?

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

end of thread, other threads:[~2024-09-25 15:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-03 14:47 [Bug tree-optimization/116585] New: SSA corruption with -O3,-fvect-cost-model=very-cheap cures the failure qinzhao at gcc dot gnu.org
2024-09-03 16:36 ` [Bug tree-optimization/116585] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
2024-09-03 17:18 ` [Bug tree-optimization/116585] [12/13/14/15 Regression] SSA corruption with -O3 pinskia at gcc dot gnu.org
2024-09-06  6:17 ` rguenth at gcc dot gnu.org
2024-09-18  9:11 ` cvs-commit at gcc dot gnu.org
2024-09-18  9:12 ` [Bug tree-optimization/116585] [12/13/14 " rguenth at gcc dot gnu.org
2024-09-25 15:59 ` qinzhao 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).