public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
@ 2022-12-07 12:44 zhendong.su at inf dot ethz.ch
  2022-12-07 16:45 ` [Bug tree-optimization/108007] " pinskia at gcc dot gnu.org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2022-12-07 12:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108007
           Summary: wrong code at -Os and above with "-fno-dce
                    -fno-tree-dce" on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/51r5Kqr9q

It appears to be a regression from 9.*, and affects 10.* till trunk. 

[599] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221207 (experimental) [master r13-4532-gda7fb32d403] (GCC) 
[600] % 
[600] % gcctk -Os -fno-dce -fno-tree-dce small.c
[601] % ./a.out
Segmentation fault
[602] % 
[602] % cat small.c
int a, b, d, e, f = 10000000, h;
short c, g;
static int *i() {
  g = f;
 L:
  h = e = ~g;
  g = ~f % g & e;
  if (!g)
    goto L;
  c++;
  while (g < 1)
    ;
  return &a;
}
static void k() {
  int *l, m = 2;
  l = i();
  for (; d < 1; d++)
    m |= *l >= b;
}
int main() {
  k();
  return 0;
}

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

* [Bug tree-optimization/108007] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
@ 2022-12-07 16:45 ` pinskia at gcc dot gnu.org
  2022-12-07 16:54 ` [Bug ipa/108007] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-07 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#(insn:TI 36 66 40 8 (set (reg:CCGC 17 flags)
#        (compare:CCGC (mem:SI (const_int 0 [0]) [1 *removed_return.17_12(D)+0
S4 A32])
#            (reg:SI 1 dx [orig:83 b.0_5 ] [83]))) "/app/example.cpp":20:13 11
{*cmpsi_1}
#     (expr_list:REG_UNUSED (reg:CCGC 17 flags)
#        (nil)))
        cmpl    %edx, 0 # 36      [c=8 l=7]  *cmpsi_1/0

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

* [Bug ipa/108007] [10/11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
  2022-12-07 16:45 ` [Bug tree-optimization/108007] " pinskia at gcc dot gnu.org
@ 2022-12-07 16:54 ` pinskia at gcc dot gnu.org
  2022-12-07 16:59 ` pinskia at gcc dot gnu.org
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-07 16:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong code at -Os and above |[10/11/12/13 Regression]
                   |with "-fno-dce              |wrong code at -Os and above
                   |-fno-tree-dce" on           |with "-fno-dce
                   |x86_64-linux-gnu            |-fno-tree-dce" on
                   |                            |x86_64-linux-gnu
      Known to fail|                            |10.1.0, 11.1.0, 12.2.0
   Target Milestone|---                         |10.5
                 CC|                            |marxin at gcc dot gnu.org
            Version|unknown                     |13.0
          Component|tree-optimization           |ipa
      Known to work|                            |9.1.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
========== IPA-SRA decisions ==========

Evaluating analysis results for i/8
  Will remove return value.
  Created new node i.isra/12

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

* [Bug ipa/108007] [10/11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
  2022-12-07 16:45 ` [Bug tree-optimization/108007] " pinskia at gcc dot gnu.org
  2022-12-07 16:54 ` [Bug ipa/108007] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
@ 2022-12-07 16:59 ` pinskia at gcc dot gnu.org
  2022-12-07 17:00 ` pinskia at gcc dot gnu.org
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-07 16:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-12-07
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
     Ever confirmed|0                           |1

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

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

* [Bug ipa/108007] [10/11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2022-12-07 16:59 ` pinskia at gcc dot gnu.org
@ 2022-12-07 17:00 ` pinskia at gcc dot gnu.org
  2022-12-08  9:50 ` marxin at gcc dot gnu.org
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-07 17:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely due to r10-3311-gff6686d2e5f797 (the new IPA-SRA).

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

* [Bug ipa/108007] [10/11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2022-12-07 17:00 ` pinskia at gcc dot gnu.org
@ 2022-12-08  9:50 ` marxin at gcc dot gnu.org
  2022-12-21 11:41 ` rguenth at gcc dot gnu.org
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-12-08  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> Most likely due to r10-3311-gff6686d2e5f797 (the new IPA-SRA).

Yes, it's since the revision.

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

* [Bug ipa/108007] [10/11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2022-12-08  9:50 ` marxin at gcc dot gnu.org
@ 2022-12-21 11:41 ` rguenth at gcc dot gnu.org
  2023-04-03 14:32 ` jakub at gcc dot gnu.org
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-21 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
   Last reconfirmed|2022-12-07 00:00:00         |2022-12-21

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Martin, can you please have a look?

Summary for node main/10:
  Returns value
  No parameter information.

  Summary for edge main/10->k/9:
    return value ignored

Summary for node k/9:
  No parameter information.

  Summary for edge k/9->i/8:
    return value used only to compute caller return value

Summary for node i/8:
  Returns value
  No parameter information.


the k->i edge info looks misleading (the caller returns nothing), but
the uses are all "dead".  Eventually those dead stmts are now supposed
to be cleaned up by the inliner because of the possibility of -fno-[tree-]dce,
just in this case that isn't working?

Not sure if really P2, but I guess return value removal isn't yet handled
in that code path?

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

* [Bug ipa/108007] [10/11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (5 preceding siblings ...)
  2022-12-21 11:41 ` rguenth at gcc dot gnu.org
@ 2023-04-03 14:32 ` jakub at gcc dot gnu.org
  2023-04-03 14:35 ` jakub at gcc dot gnu.org
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-03 14:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Martin, any progress on this?
Feels like PRs we've discussed in the past (and some of them have been fixed),
where IPA passes assume something isn't really needed to be computed because
all its uses will be dead, but doesn't actually DCE them and because DCE is
disabled, it is still needed?

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

* [Bug ipa/108007] [10/11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (6 preceding siblings ...)
  2023-04-03 14:32 ` jakub at gcc dot gnu.org
@ 2023-04-03 14:35 ` jakub at gcc dot gnu.org
  2023-05-12 12:57 ` [Bug ipa/108007] [10/11/12/13/14 " jamborm at gcc dot gnu.org
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-03 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
E.g. PR93385.

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

* [Bug ipa/108007] [10/11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (7 preceding siblings ...)
  2023-04-03 14:35 ` jakub at gcc dot gnu.org
@ 2023-05-12 12:57 ` jamborm at gcc dot gnu.org
  2023-07-07 10:44 ` [Bug ipa/108007] [11/12/13/14 " rguenth at gcc dot gnu.org
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-05-12 12:57 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

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

--- Comment #9 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I have proposed a patch on the mailing list:
https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618346.html

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (8 preceding siblings ...)
  2023-05-12 12:57 ` [Bug ipa/108007] [10/11/12/13/14 " jamborm at gcc dot gnu.org
@ 2023-07-07 10:44 ` rguenth at gcc dot gnu.org
  2023-09-20 14:10 ` jamborm at gcc dot gnu.org
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (9 preceding siblings ...)
  2023-07-07 10:44 ` [Bug ipa/108007] [11/12/13/14 " rguenth at gcc dot gnu.org
@ 2023-09-20 14:10 ` jamborm at gcc dot gnu.org
  2023-09-21  2:15 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-09-20 14:10 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |19373742 at buaa dot edu.cn

--- Comment #11 from Martin Jambor <jamborm at gcc dot gnu.org> ---
*** Bug 111490 has been marked as a duplicate of this bug. ***

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (10 preceding siblings ...)
  2023-09-20 14:10 ` jamborm at gcc dot gnu.org
@ 2023-09-21  2:15 ` pinskia at gcc dot gnu.org
  2023-09-21  2:17 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21  2:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111508 has been marked as a duplicate of this bug. ***

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (11 preceding siblings ...)
  2023-09-21  2:15 ` pinskia at gcc dot gnu.org
@ 2023-09-21  2:17 ` pinskia at gcc dot gnu.org
  2023-09-21  2:19 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21  2:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111509 has been marked as a duplicate of this bug. ***

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (12 preceding siblings ...)
  2023-09-21  2:17 ` pinskia at gcc dot gnu.org
@ 2023-09-21  2:19 ` pinskia at gcc dot gnu.org
  2023-09-22 17:30 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21  2:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111507 has been marked as a duplicate of this bug. ***

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (13 preceding siblings ...)
  2023-09-21  2:19 ` pinskia at gcc dot gnu.org
@ 2023-09-22 17:30 ` pinskia at gcc dot gnu.org
  2023-10-03 16:53 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-22 17:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111540 has been marked as a duplicate of this bug. ***

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (14 preceding siblings ...)
  2023-09-22 17:30 ` pinskia at gcc dot gnu.org
@ 2023-10-03 16:53 ` cvs-commit at gcc dot gnu.org
  2023-10-03 17:18 ` jamborm at gcc dot gnu.org
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-03 16:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:

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

commit r14-4382-g1be18ea110a2d69570dbc494588a7c73173883be
Author: Martin Jambor <mjambor@suse.cz>
Date:   Tue Oct 3 18:44:51 2023 +0200

    ipa: Self-DCE of uses of removed call LHSs (PR 108007)

    PR 108007 is another manifestation where we rely on DCE to clean-up
    after IPA-SRA and if the user explicitely switches DCE off, IPA-SRA
    can leave behind statements which are fed uninitialized values and
    trap, even though their results are themselves never used.

    I have already fixed this for unused parameters in callees, this bug
    shows that almost the same thing can happen for removed returns, on
    the side of callers.  This means that the issue has to be fixed
    elsewhere, in call redirection.  This patch adds a function which
    looks for (and through, using a work-list) uses of operations fed
    specific SSA names and removes them all.

    That would have been easy if it wasn't for debug statements during
    tree-inline (from which call redirection is also invoked).  Debug
    statements are decoupled from the rest at this point and iterating
    over uses of SSAs does not bring them up.  During tree-inline they are
    handled especially at the end, I assume in order to make sure that
    relative ordering of UIDs are the same with and without debug info.

    This means that during tree-inline we need to make a hash of killed
    SSAs, that we already have in copy_body_data, available to the
    function making the purging.  So the patch duly does also that, making
    the interface slightly ugly.

    gcc/ChangeLog:

    2023-09-27  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            * cgraph.h (cgraph_edge): Add a parameter to
            redirect_call_stmt_to_callee.
            * ipa-param-manipulation.h (ipa_param_adjustments): Add a
            parameter to modify_call.
            * cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): New
            parameter killed_ssas, pass it to padjs->modify_call.
            * ipa-param-manipulation.cc (purge_transitive_uses): New function.
            (ipa_param_adjustments::modify_call): New parameter killed_ssas.
            Instead of substituting uses, invoke purge_transitive_uses.  If
            hash of killed SSAs has not been provided, create a temporary one
            and release SSAs that have been added to it.
            * tree-inline.cc (redirect_all_calls): Create
            id->killed_new_ssa_names earlier, pass it to edge redirection,
            adjust a comment.
            (copy_body): Release SSAs in id->killed_new_ssa_names.

    gcc/testsuite/ChangeLog:

    2023-05-11  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            * gcc.dg/ipa/pr108007.c: New test.

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (15 preceding siblings ...)
  2023-10-03 16:53 ` cvs-commit at gcc dot gnu.org
@ 2023-10-03 17:18 ` jamborm at gcc dot gnu.org
  2023-10-05 12:13 ` jamborm at gcc dot gnu.org
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-10-03 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

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

--- Comment #17 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Fixed on master (gcc14). I do not intend to backport the patch to any released
version, simply do not switch off DCE on them.

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (16 preceding siblings ...)
  2023-10-03 17:18 ` jamborm at gcc dot gnu.org
@ 2023-10-05 12:13 ` jamborm at gcc dot gnu.org
  2024-01-11  1:05 ` [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797 pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-10-05 12:13 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

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

--- Comment #18 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I had to revert the patch because it broke bootstrap on ppc64le (see PR
111688).  I'll re visit after I address that failure.

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (17 preceding siblings ...)
  2023-10-05 12:13 ` jamborm at gcc dot gnu.org
@ 2024-01-11  1:05 ` pinskia at gcc dot gnu.org
  2024-01-16 12:44 ` jamborm at gcc dot gnu.org
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-11  1:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110294 has been marked as a duplicate of this bug. ***

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (18 preceding siblings ...)
  2024-01-11  1:05 ` [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797 pinskia at gcc dot gnu.org
@ 2024-01-16 12:44 ` jamborm at gcc dot gnu.org
  2024-01-24 18:14 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-01-16 12:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I have submitted a slightly modified patch to the mailing list:
https://inbox.sourceware.org/gcc-patches/ri6cyu1e9kw.fsf@/T/#u

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (19 preceding siblings ...)
  2024-01-16 12:44 ` jamborm at gcc dot gnu.org
@ 2024-01-24 18:14 ` cvs-commit at gcc dot gnu.org
  2024-01-24 19:09 ` jamborm at gcc dot gnu.org
  2024-04-08 15:51 ` [Bug ipa/108007] [11/12/13 " cvs-commit at gcc dot gnu.org
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-24 18:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:a9a8426e534760b8d3a250e9bd3cff4db131a2be

commit r14-8398-ga9a8426e534760b8d3a250e9bd3cff4db131a2be
Author: Martin Jambor <mjambor@suse.cz>
Date:   Wed Jan 24 19:12:31 2024 +0100

    ipa: Self-DCE of uses of removed call LHSs (PR 108007)

    PR 108007 is another manifestation where we rely on DCE to clean-up
    after IPA-SRA and if the user explicitely switches DCE off, IPA-SRA
    can leave behind statements which are fed uninitialized values and
    trap, even though their results are themselves never used.

    I have already fixed this for unused parameters in callees, this bug
    shows that almost the same thing can happen for removed returns, on
    the side of callers.  This means that the issue has to be fixed
    elsewhere, in call redirection.  This patch adds a function which
    looks for (and through, using a work-list) uses of operations fed
    specific SSA names and removes them all.

    That would have been easy if it wasn't for debug statements during
    tree-inline (from which call redirection is also invoked).  Debug
    statements are decoupled from the rest at this point and iterating
    over uses of SSAs does not bring them up.  During tree-inline they are
    handled especially at the end, I assume in order to make sure that
    relative ordering of UIDs are the same with and without debug info.

    This means that during tree-inline we need to make a hash of killed
    SSAs, that we already have in copy_body_data, available to the
    function making the purging.  So the patch duly does also that, making
    the interface slightly ugly.  Moreover, all newly unused SSA names
    need to be freed and as PR 112616 showed, it must be done in a defined
    order, which is what newly added ipa_release_ssas_in_hash does.

    gcc/ChangeLog:

    2024-01-12  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            PR ipa/112616
            * cgraph.h (cgraph_edge): Add a parameter to
            redirect_call_stmt_to_callee.
            * ipa-param-manipulation.h (ipa_param_adjustments): Add a
            parameter to modify_call.
            (ipa_release_ssas_in_hash): Declare.
            * cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): New
            parameter killed_ssas, pass it to padjs->modify_call.
            * ipa-param-manipulation.cc (purge_all_uses): New function.
            (ipa_param_adjustments::modify_call): New parameter killed_ssas.
            Instead of substituting uses, invoke purge_all_uses.  If
            hash of killed SSAs has not been provided, create a temporary one
            and release SSAs that have been added to it.
            (compare_ssa_versions): New function.
            (ipa_release_ssas_in_hash): Likewise.
            * tree-inline.cc (redirect_all_calls): Create
            id->killed_new_ssa_names earlier, pass it to edge redirection,
            adjust a comment.
            (copy_body): Release SSAs in id->killed_new_ssa_names.

    gcc/testsuite/ChangeLog:

    2024-01-15  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            PR ipa/112616
            * gcc.dg/ipa/pr108007.c: New test.
            * gcc.dg/ipa/pr112616.c: Likewise.

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

* [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (20 preceding siblings ...)
  2024-01-24 18:14 ` cvs-commit at gcc dot gnu.org
@ 2024-01-24 19:09 ` jamborm at gcc dot gnu.org
  2024-04-08 15:51 ` [Bug ipa/108007] [11/12/13 " cvs-commit at gcc dot gnu.org
  22 siblings, 0 replies; 24+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-01-24 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Fixed on trunk.  I did not want to backport this but because of PR 112616 I
will probably do after a few weeks on master, if there are no issues.

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

* [Bug ipa/108007] [11/12/13 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797
  2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (21 preceding siblings ...)
  2024-01-24 19:09 ` jamborm at gcc dot gnu.org
@ 2024-04-08 15:51 ` cvs-commit at gcc dot gnu.org
  22 siblings, 0 replies; 24+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-08 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #23 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Martin Jambor
<jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:40ddc0b05a47f999b24f20c1becb79004995731b

commit r13-8594-g40ddc0b05a47f999b24f20c1becb79004995731b
Author: Martin Jambor <mjambor@suse.cz>
Date:   Mon Apr 8 17:34:33 2024 +0200

    ipa: Self-DCE of uses of removed call LHSs (PR 108007)

    PR 108007 is another manifestation where we rely on DCE to clean-up
    after IPA-SRA and if the user explicitely switches DCE off, IPA-SRA
    can leave behind statements which are fed uninitialized values and
    trap, even though their results are themselves never used.

    I have already fixed this for unused parameters in callees, this bug
    shows that almost the same thing can happen for removed returns, on
    the side of callers.  This means that the issue has to be fixed
    elsewhere, in call redirection.  This patch adds a function which
    looks for (and through, using a work-list) uses of operations fed
    specific SSA names and removes them all.

    That would have been easy if it wasn't for debug statements during
    tree-inline (from which call redirection is also invoked).  Debug
    statements are decoupled from the rest at this point and iterating
    over uses of SSAs does not bring them up.  During tree-inline they are
    handled especially at the end, I assume in order to make sure that
    relative ordering of UIDs are the same with and without debug info.

    This means that during tree-inline we need to make a hash of killed
    SSAs, that we already have in copy_body_data, available to the
    function making the purging.  So the patch duly does also that, making
    the interface slightly ugly.  Moreover, all newly unused SSA names
    need to be freed and as PR 112616 showed, it must be done in a defined
    order, which is what newly added ipa_release_ssas_in_hash does.

    This backport to gcc-13 also contains
    54e505d0446f86b7ad383acbb8e5501f20872b64 in order not to reintroduce
    PR 113757.

    gcc/ChangeLog:

    2024-04-05  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            PR ipa/112616
            * cgraph.h (cgraph_edge): Add a parameter to
            redirect_call_stmt_to_callee.
            * ipa-param-manipulation.h (ipa_param_adjustments): Add a
            parameter to modify_call.
            (ipa_release_ssas_in_hash): Declare.
            * cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): New
            parameter killed_ssas, pass it to padjs->modify_call.
            * ipa-param-manipulation.cc (purge_all_uses): New function.
            (ipa_param_adjustments::modify_call): New parameter killed_ssas.
            Instead of substituting uses, invoke purge_all_uses.  If
            hash of killed SSAs has not been provided, create a temporary one
            and release SSAs that have been added to it.
            (compare_ssa_versions): New function.
            (ipa_release_ssas_in_hash): Likewise.
            * tree-inline.cc (redirect_all_calls): Create
            id->killed_new_ssa_names earlier, pass it to edge redirection,
            adjust a comment.
            (copy_body): Release SSAs in id->killed_new_ssa_names.

    gcc/testsuite/ChangeLog:

    2024-01-15  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            PR ipa/112616
            * gcc.dg/ipa/pr108007.c: New test.
            * gcc.dg/ipa/pr112616.c: Likewise.

    (cherry picked from commit a9a8426e534760b8d3a250e9bd3cff4db131a2be)

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

end of thread, other threads:[~2024-04-08 15:51 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2022-12-07 16:45 ` [Bug tree-optimization/108007] " pinskia at gcc dot gnu.org
2022-12-07 16:54 ` [Bug ipa/108007] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
2022-12-07 16:59 ` pinskia at gcc dot gnu.org
2022-12-07 17:00 ` pinskia at gcc dot gnu.org
2022-12-08  9:50 ` marxin at gcc dot gnu.org
2022-12-21 11:41 ` rguenth at gcc dot gnu.org
2023-04-03 14:32 ` jakub at gcc dot gnu.org
2023-04-03 14:35 ` jakub at gcc dot gnu.org
2023-05-12 12:57 ` [Bug ipa/108007] [10/11/12/13/14 " jamborm at gcc dot gnu.org
2023-07-07 10:44 ` [Bug ipa/108007] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-09-20 14:10 ` jamborm at gcc dot gnu.org
2023-09-21  2:15 ` pinskia at gcc dot gnu.org
2023-09-21  2:17 ` pinskia at gcc dot gnu.org
2023-09-21  2:19 ` pinskia at gcc dot gnu.org
2023-09-22 17:30 ` pinskia at gcc dot gnu.org
2023-10-03 16:53 ` cvs-commit at gcc dot gnu.org
2023-10-03 17:18 ` jamborm at gcc dot gnu.org
2023-10-05 12:13 ` jamborm at gcc dot gnu.org
2024-01-11  1:05 ` [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797 pinskia at gcc dot gnu.org
2024-01-16 12:44 ` jamborm at gcc dot gnu.org
2024-01-24 18:14 ` cvs-commit at gcc dot gnu.org
2024-01-24 19:09 ` jamborm at gcc dot gnu.org
2024-04-08 15:51 ` [Bug ipa/108007] [11/12/13 " cvs-commit 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).