public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
@ 2021-05-23 17:20 pinskia at gcc dot gnu.org
  2021-05-23 17:21 ` [Bug middle-end/100733] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-23 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100733
           Summary: -fcompare-debug failure for pr85213.c at -O1
                    -fdisable-tree-phiopt2
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: wrong-debug
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

So while modifying phi-opt, I ran into pr85213.c testcase failing with the C++
front-end. BUT the problem is not related at all to PHI-OPT changes as the IR
coming out of the front-end is hugely different with and without debug
information turned on.

Without debug info turned on we start with:
NON_LVALUE_EXPR <SAVE_EXPR <-(__builtin_expect ((long int) (x == 0), 3) == 0)>
>;

But with:
NON_LVALUE_EXPR <SAVE_EXPR <-(__builtin_expect (# DEBUG BEGIN STMT;
x != 0; ? 0 : 1, 3) == 0)>>


It just happens with the PHI-OPT, by the time we get to expand, the IR is very
similar BUT the difference comes from SSA names are different.

You can reproduce the failure on the trunk without any patches to PHI-OPT by
doing:
g++ -O1 -fsanitize=undefined -fcompare-debug -fdisable-tree-phiopt2
c-c++-common/ubsan/pr85213.c

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

* [Bug middle-end/100733] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
@ 2021-05-23 17:21 ` pinskia at gcc dot gnu.org
  2021-05-24 11:09 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-23 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note in older versions of GCC (8.x), disabling phiopt1 is needed instead of
phiopt2.

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

* [Bug middle-end/100733] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
  2021-05-23 17:21 ` [Bug middle-end/100733] " pinskia at gcc dot gnu.org
@ 2021-05-24 11:09 ` jakub at gcc dot gnu.org
  2021-05-24 11:11 ` [Bug middle-end/100733] [8/9/10/11/12 Regression] " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-24 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think this is another -gstatement-frontiers issue.
Without -g, during folding we are folding a COND_EXPR with x != 0, 0 and 1
arguments, but with -g it has a STATEMENT_LIST with DEBUG_BEGIN_STMT and x != 0
And that one e.g. in fold_ternary_loc doesn't satisfy truth_value_p, so the
      /* Convert A ? 0 : 1 to !A.  This prefers the use of NOT_EXPR
         over COND_EXPR in cases such as floating point comparisons.  */
      if (integer_zerop (op1)
          && code == COND_EXPR
          && integer_onep (op2)
          && !VECTOR_TYPE_P (type)
          && truth_value_p (TREE_CODE (arg0)))
        return fold_convert_loc (loc, type,
                                 invert_truthvalue_loc (loc, arg0));
folding doesn't happen.  In the past, most of the -gstatement-frontiers related
-fdebug-compare bugfixes were about making sure we gimplify it the same (and we
still have some unresolved (almost unresolvable) ones).  But this shows whole
new category of bugs, the folders aren't really prepared for it, guess neither
generic-match.c (or its callers) or fold-const.c.
E.g. fold_ternary_loc starts with
  if (op0)
    {
      arg0 = op0;
      STRIP_NOPS (arg0);
    }
shouldn't we use expr_single in that code somehow?  Like after the STRIP_NOPS
add
      do
        {
          tree narg0 = expr_single (arg0);
          if (narg0 == arg0)
            break;
          arg0 = narg0;
          STRIP_NOPS (arg0);
        }
      while (1);
perhaps in some macro/inline fn?
Or reconsider the DEBUG_BEGIN_STMT stuff.

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

* [Bug middle-end/100733] [8/9/10/11/12 Regression] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
  2021-05-23 17:21 ` [Bug middle-end/100733] " pinskia at gcc dot gnu.org
  2021-05-24 11:09 ` jakub at gcc dot gnu.org
@ 2021-05-24 11:11 ` jakub at gcc dot gnu.org
  2021-05-25  7:33 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-24 11:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|-fcompare-debug failure for |[8/9/10/11/12 Regression]
                   |pr85213.c at -O1            |-fcompare-debug failure for
                   |-fdisable-tree-phiopt2      |pr85213.c at -O1
                   |                            |-fdisable-tree-phiopt2
   Target Milestone|---                         |9.4

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
-gstatement-frontiers has been introduced in
r8-5241-g8697bf9f46f36168ddba5752db582e673e3cbe8c or so.

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

* [Bug middle-end/100733] [8/9/10/11/12 Regression] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-05-24 11:11 ` [Bug middle-end/100733] [8/9/10/11/12 Regression] " jakub at gcc dot gnu.org
@ 2021-05-25  7:33 ` rguenth at gcc dot gnu.org
  2021-06-01  8:20 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-25  7:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Meh.  I wonder if we can make expr_single cheaper by setting a tree flag on the
STATEMENT_LIST at least?

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

* [Bug middle-end/100733] [8/9/10/11/12 Regression] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-05-25  7:33 ` rguenth at gcc dot gnu.org
@ 2021-06-01  8:20 ` rguenth at gcc dot gnu.org
  2022-05-27  9:45 ` [Bug middle-end/100733] [10/11/12/13 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug middle-end/100733] [10/11/12/13 Regression] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-06-01  8:20 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:45 ` rguenth at gcc dot gnu.org
  2022-06-28 10:45 ` jakub at gcc dot gnu.org
  2023-07-07 10:40 ` [Bug middle-end/100733] [11/12/13/14 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

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

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

* [Bug middle-end/100733] [10/11/12/13 Regression] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-05-27  9:45 ` [Bug middle-end/100733] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:45 ` jakub at gcc dot gnu.org
  2023-07-07 10:40 ` [Bug middle-end/100733] [11/12/13/14 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug middle-end/100733] [11/12/13/14 Regression] -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2
  2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-06-28 10:45 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:40 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2023-07-07 10:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-23 17:20 [Bug middle-end/100733] New: -fcompare-debug failure for pr85213.c at -O1 -fdisable-tree-phiopt2 pinskia at gcc dot gnu.org
2021-05-23 17:21 ` [Bug middle-end/100733] " pinskia at gcc dot gnu.org
2021-05-24 11:09 ` jakub at gcc dot gnu.org
2021-05-24 11:11 ` [Bug middle-end/100733] [8/9/10/11/12 Regression] " jakub at gcc dot gnu.org
2021-05-25  7:33 ` rguenth at gcc dot gnu.org
2021-06-01  8:20 ` rguenth at gcc dot gnu.org
2022-05-27  9:45 ` [Bug middle-end/100733] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-07-07 10:40 ` [Bug middle-end/100733] [11/12/13/14 " rguenth 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).