public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
@ 2020-05-13 17:55 asolokha at gmx dot com
  2020-05-13 18:06 ` [Bug tree-optimization/95113] " jakub at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: asolokha at gmx dot com @ 2020-05-13 17:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95113
           Summary: [10/11 Regression] Wrong code w/ -O2 -fexceptions
                    -fnon-call-exceptions
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---
            Target: x86_64-unknown-linux-gnu

The following program compiled w/ gcc-11.0.0-alpha20200510 snapshot
(g:13a46321516e2efd3bbb1f1899c539c6724240a9) w/ -O2 -fexceptions
-fnon-call-exceptions:

int p4, cd;

static long int
sg (long int kl, int mp)
{
  if (mp == 0)
    return 0;

  if (kl == -1 && mp == -1)
    return 0;

  return kl / mp;
}

static int
eo (int *yg)
{
  int du;

  du = sg (p4, 1) + *yg;
  (void) du;

  return cd;
}

int
main (void)
{
  int um = 0;

  cd = sg (1, 1);
  eo (&um);

  return 0;
}

% x86_64-unknown-linux-gnu-gcc-11.0.0 -O2 -fexceptions -Wuninitialized -o good
li6hfrrz.c
% ./good
% echo $?
0
% objdump --section=.text --disassemble=main good | tail -n6

00000000000004e0 <main>:
 4e0:   c7 05 32 1b 00 00 01    movl   $0x1,0x1b32(%rip)        # 201c <cd>
 4e7:   00 00 00
 4ea:   31 c0                   xor    %eax,%eax
 4ec:   c3                      retq

% x86_64-unknown-linux-gnu-gcc-11.0.0 -O2 -fexceptions -fnon-call-exceptions
-Wuninitialized -o bad li6hfrrz.c
% ./bad
zsh: segmentation fault (core dumped)  ./bad
% objdump --section=.text --disassemble=main bad | tail -n6
00000000000004e0 <main>:
 4e0:   c7 05 32 1b 00 00 01    movl   $0x1,0x1b32(%rip)        # 201c <cd>
 4e7:   00 00 00
 4ea:   8b 04 25 00 00 00 00    mov    0x0,%eax
 4f1:   31 c0                   xor    %eax,%eax
 4f3:   c3                      retq

https://gcc.godbolt.org/z/V4a-K7

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
@ 2020-05-13 18:06 ` jakub at gcc dot gnu.org
  2020-05-13 18:15 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-13 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-05-13
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1
   Target Milestone|---                         |10.2
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r10-3542-g0b92cf305dcf34387a8e2564e55ca8948df3b47a

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
  2020-05-13 18:06 ` [Bug tree-optimization/95113] " jakub at gcc dot gnu.org
@ 2020-05-13 18:15 ` jakub at gcc dot gnu.org
  2020-05-13 18:29 ` asolokha at gmx dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-13 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
int a, b;

static inline long int
foo (long int x, int y)
{
  if (y == 0)
    return 0;

  if (x == -1 && y == -1)
    return 0;

  return x / y;
}

static inline int
bar (int *p)
{
  int c = foo (a, 1) + *p;
  return b;
}

int
main ()
{
  int d = 0;
  b = foo (1, 1);
  bar (&d);
  return 0;
}

Guess dup of the other PR where the IPA opts assume DCE which doesn't really
happen (the *p load result is never used).

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
  2020-05-13 18:06 ` [Bug tree-optimization/95113] " jakub at gcc dot gnu.org
  2020-05-13 18:15 ` jakub at gcc dot gnu.org
@ 2020-05-13 18:29 ` asolokha at gmx dot com
  2020-05-14  6:20 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: asolokha at gmx dot com @ 2020-05-13 18:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Arseny Solokha <asolokha at gmx dot com> ---
(In reply to Jakub Jelinek from comment #2)
> Guess dup of the other PR where the IPA opts assume DCE which doesn't really
> happen (the *p load result is never used).

Indeed, -fno-ipa-sra fixes it. So, a duplicate of PR93385?

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2020-05-13 18:29 ` asolokha at gmx dot com
@ 2020-05-14  6:20 ` rguenth at gcc dot gnu.org
  2020-05-28 12:35 ` jamborm at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-14  6:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |93385
           Priority|P3                          |P2


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93385
[Bug 93385] [10/11 Regression] wrong code with u128 modulo at -O2 -fno-dce
-fno-ipa-cp -fno-tree-dce

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2020-05-14  6:20 ` rguenth at gcc dot gnu.org
@ 2020-05-28 12:35 ` jamborm at gcc dot gnu.org
  2020-06-04 15:04 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jamborm at gcc dot gnu.org @ 2020-05-28 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Arseny Solokha from comment #3)
> 
> Indeed, -fno-ipa-sra fixes it. So, a duplicate of PR93385?

Similar, but not quite the same.  I have proposed a fix on the mailing
list: https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546703.html

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2020-05-28 12:35 ` jamborm at gcc dot gnu.org
@ 2020-06-04 15:04 ` cvs-commit at gcc dot gnu.org
  2020-06-08 18:16 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-04 15:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:1980ffec48c6fa41396bea66366f2e591798e1e1

commit r11-935-g1980ffec48c6fa41396bea66366f2e591798e1e1
Author: Martin Jambor <mjambor@suse.cz>
Date:   Thu Jun 4 17:03:27 2020 +0200

    ipa-sra: Do not remove statements necessary because of non-call EH (PR
95113)

    PR 95113 revealed that when reasoning about which parameters are dead,
    IPA-SRA does not perform the same check related to non-call exceptions
    as tree DCE.  It most certainly should and so this patch moves the
    condition used in tree-ssa-dce.c into a separate predicate (in
    tree-eh.c) and uses it from both places.

    gcc/ChangeLog:

    2020-05-27  Martin Jambor  <mjambor@suse.cz>

            PR ipa/95113
            * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Move non-call
            exceptions check to...
            * tree-eh.c (stmt_unremovable_because_of_non_call_eh_p): ...this
            new function.
            * tree-eh.h (stmt_unremovable_because_of_non_call_eh_p): Declare
it.
            * ipa-sra.c (isra_track_scalar_value_uses): Use it.  New parameter
            fun.

    gcc/testsuite/ChangeLog:

    2020-05-27  Martin Jambor  <mjambor@suse.cz>

            PR ipa/95113
            * gcc.dg/ipa/pr95113.c: New test.

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2020-06-04 15:04 ` cvs-commit at gcc dot gnu.org
@ 2020-06-08 18:16 ` cvs-commit at gcc dot gnu.org
  2020-06-08 18:18 ` jamborm at gcc dot gnu.org
  2020-06-08 18:18 ` jamborm at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-08 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:127bf4228d0cb21f28fd5ed4dd820fa4760fc771

commit r10-8264-g127bf4228d0cb21f28fd5ed4dd820fa4760fc771
Author: Martin Jambor <mjambor@suse.cz>
Date:   Mon Jun 8 20:15:22 2020 +0200

    ipa-sra: Do not remove statements necessary because of non-call EH (PR
95113)

    PR 95113 revealed that when reasoning about which parameters are dead,
    IPA-SRA does not perform the same check related to non-call exceptions
    as tree DCE.  It most certainly should and so this patch moves the
    condition used in tree-ssa-dce.c into a separate predicate (in
    tree-eh.c) and uses it from both places.

    gcc/ChangeLog:

    2020-05-27  Martin Jambor  <mjambor@suse.cz>

            PR ipa/95113
            * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Move non-call
            exceptions check to...
            * tree-eh.c (stmt_unremovable_because_of_non_call_eh_p): ...this
            new function.
            * tree-eh.h (stmt_unremovable_because_of_non_call_eh_p): Declare
it.
            * ipa-sra.c (isra_track_scalar_value_uses): Use it.  New parameter
            fun.

    gcc/testsuite/ChangeLog:

    2020-05-27  Martin Jambor  <mjambor@suse.cz>

            PR ipa/95113
            * gcc.dg/ipa/pr95113.c: New test.

    (cherry picked from commit 1980ffec48c6fa41396bea66366f2e591798e1e1)

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
                   ` (6 preceding siblings ...)
  2020-06-08 18:16 ` cvs-commit at gcc dot gnu.org
@ 2020-06-08 18:18 ` jamborm at gcc dot gnu.org
  2020-06-08 18:18 ` jamborm at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jamborm at gcc dot gnu.org @ 2020-06-08 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Fixed.  Thanks for reporting.

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

* [Bug tree-optimization/95113] [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions
  2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
                   ` (7 preceding siblings ...)
  2020-06-08 18:18 ` jamborm at gcc dot gnu.org
@ 2020-06-08 18:18 ` jamborm at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jamborm at gcc dot gnu.org @ 2020-06-08 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #8 from Martin Jambor <jamborm at gcc dot gnu.org> ---
...and marking it as such.

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

end of thread, other threads:[~2020-06-08 18:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 17:55 [Bug tree-optimization/95113] New: [10/11 Regression] Wrong code w/ -O2 -fexceptions -fnon-call-exceptions asolokha at gmx dot com
2020-05-13 18:06 ` [Bug tree-optimization/95113] " jakub at gcc dot gnu.org
2020-05-13 18:15 ` jakub at gcc dot gnu.org
2020-05-13 18:29 ` asolokha at gmx dot com
2020-05-14  6:20 ` rguenth at gcc dot gnu.org
2020-05-28 12:35 ` jamborm at gcc dot gnu.org
2020-06-04 15:04 ` cvs-commit at gcc dot gnu.org
2020-06-08 18:16 ` cvs-commit at gcc dot gnu.org
2020-06-08 18:18 ` jamborm at gcc dot gnu.org
2020-06-08 18:18 ` jamborm 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).