public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu
@ 2020-04-23  0:22 qrzhang at gatech dot edu
  2020-04-23  5:21 ` [Bug tree-optimization/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: qrzhang at gatech dot edu @ 2020-04-23  0:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94724
           Summary: wrong code at -O0 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: qrzhang at gatech dot edu
  Target Milestone: ---

It happens at -O0. gcc-9 works fine.
Bisection points to g:ca6c722561ce9b9dc7b59cfd9d2


The correct output is 1.


$ gcc-trunk -v
gcc version 10.0.1 20200422 (experimental) [master revision
38644f81bab:facc719c537:56b15072aa41633235be57851ab342114e0bacba] (GCC)


$ gcc-9 abc.c ; ./a.out
1

$ gcc-trunk abc.c ; ./a.out
0

$ cat abc.c
short a, b;
int main() {
  (0, (0, (a = 0 >= 0, b))) != 53601;
  printf("%d\n", a);
}

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

* [Bug tree-optimization/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d
  2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
@ 2020-04-23  5:21 ` marxin at gcc dot gnu.org
  2020-04-23  8:45 ` [Bug middle-end/94724] " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-04-23  5:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2020-04-23
           Priority|P3                          |P1
      Known to fail|                            |10.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |9.3.0
            Summary|wrong code at -O0 on        |[10 Regression] wrong code
                   |x86_64-linux-gnu            |at -O0 on x86_64-linux-gnu
                   |                            |since
                   |                            |r10-7344-gca6c722561ce9b9d
            Version|unknown                     |10.0
           Keywords|                            |wrong-code
   Target Milestone|---                         |10.0

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed.

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

* [Bug middle-end/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d
  2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
  2020-04-23  5:21 ` [Bug tree-optimization/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d marxin at gcc dot gnu.org
@ 2020-04-23  8:45 ` jakub at gcc dot gnu.org
  2020-04-23  9:30 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-23  8:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug middle-end/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d
  2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
  2020-04-23  5:21 ` [Bug tree-optimization/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d marxin at gcc dot gnu.org
  2020-04-23  8:45 ` [Bug middle-end/94724] " jakub at gcc dot gnu.org
@ 2020-04-23  9:30 ` jakub at gcc dot gnu.org
  2020-04-23 19:12 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-23  9:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 48359
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48359&action=edit
gcc10-pr94724.patch

Untested fix.  Wanted to create it efficiently, but by building the
COMPONENT_REFs with non-final second operand the flags computed by build2_loc
aren't final either (TREE_SIDE_EFFECTS, TREE_CONSTANT, TREE_READONLY).

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

* [Bug middle-end/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d
  2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (2 preceding siblings ...)
  2020-04-23  9:30 ` jakub at gcc dot gnu.org
@ 2020-04-23 19:12 ` cvs-commit at gcc dot gnu.org
  2020-04-23 19:19 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-23 19:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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

commit r10-7921-gbca558de2a24b2a78c6a321d6cec384e07759d77
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Apr 23 21:11:36 2020 +0200

    tree: Fix up get_narrower [PR94724]

    In the recent get_narrower change, I wanted it to be efficient and avoid
    recursion if there are many nested COMPOUND_EXPRs.  That builds the
    COMPOUND_EXPR nest with the right arguments, but as build2_loc computes
some
    flags like TREE_SIDE_EFFECTS, TREE_CONSTANT and TREE_READONLY, when it
    is called with something that will not be the argument in the end, those
    flags are computed incorrectly.
    So, this patch instead uses an auto_vec and builds them in the reverse
order
    so when they are built, they are built with the correct operands.

    2020-04-23  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/94724
            * tree.c (get_narrower): Instead of creating COMPOUND_EXPRs
            temporarily with non-final second operand and updating it later,
            push COMPOUND_EXPRs into a vector and process it in reverse,
            creating COMPOUND_EXPRs with the final operands.

            * gcc.c-torture/execute/pr94724.c: New test.

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

* [Bug middle-end/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d
  2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (3 preceding siblings ...)
  2020-04-23 19:12 ` cvs-commit at gcc dot gnu.org
@ 2020-04-23 19:19 ` jakub at gcc dot gnu.org
  2020-05-08  7:37 ` cvs-commit at gcc dot gnu.org
  2020-05-08  7:49 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-23 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|jakub at redhat dot com            |
         Resolution|---                         |FIXED

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

* [Bug middle-end/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d
  2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (4 preceding siblings ...)
  2020-04-23 19:19 ` jakub at gcc dot gnu.org
@ 2020-05-08  7:37 ` cvs-commit at gcc dot gnu.org
  2020-05-08  7:49 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-08  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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

commit r11-196-ga139bc2b492de8a761890a5d299951dede3d8f7b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri May 8 09:37:09 2020 +0200

    tree: Avoid variable sharing in get_narrower [PR94724]

    On Thu, May 07, 2020 at 02:45:29PM +0200, Thomas Schwinge wrote:
    > >>+      for (tree op = win; TREE_CODE (op) == COMPOUND_EXPR;
    >
    > ..., and new 'op' variable here.
    >
    > >>+        op = TREE_OPERAND (op, 1))
    > >>+     v.safe_push (op);
    > >>+      FOR_EACH_VEC_ELT_REVERSE (v, i, op)
    > >>+     ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR,
    > >>+                       TREE_TYPE (win), TREE_OPERAND (op, 0),
    > >>+                       ret);
    > >>+      return ret;
    > >>     }
    > >>   while (TREE_CODE (op) == NOP_EXPR)
    > >>     {

    There is no reason for the shadowing and op at this point acts as a
    temporary and will be overwritten in FOR_EACH_VEC_ELT_REVERSE anyway.
    So, we can just s/tree // here.

    2020-05-08  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/94724
            * tree.c (get_narrower): Reuse the op temporary instead of
            shadowing it.

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

* [Bug middle-end/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d
  2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
                   ` (5 preceding siblings ...)
  2020-05-08  7:37 ` cvs-commit at gcc dot gnu.org
@ 2020-05-08  7:49 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-08  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:3a296f322dea92747a0874cb1fd073313749673e

commit r10-8123-g3a296f322dea92747a0874cb1fd073313749673e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri May 8 09:37:09 2020 +0200

    tree: Avoid variable sharing in get_narrower [PR94724]

    On Thu, May 07, 2020 at 02:45:29PM +0200, Thomas Schwinge wrote:
    > >>+      for (tree op = win; TREE_CODE (op) == COMPOUND_EXPR;
    >
    > ..., and new 'op' variable here.
    >
    > >>+        op = TREE_OPERAND (op, 1))
    > >>+     v.safe_push (op);
    > >>+      FOR_EACH_VEC_ELT_REVERSE (v, i, op)
    > >>+     ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR,
    > >>+                       TREE_TYPE (win), TREE_OPERAND (op, 0),
    > >>+                       ret);
    > >>+      return ret;
    > >>     }
    > >>   while (TREE_CODE (op) == NOP_EXPR)
    > >>     {

    There is no reason for the shadowing and op at this point acts as a
    temporary and will be overwritten in FOR_EACH_VEC_ELT_REVERSE anyway.
    So, we can just s/tree // here.

    2020-05-08  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/94724
            * tree.c (get_narrower): Reuse the op temporary instead of
            shadowing it.

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

end of thread, other threads:[~2020-05-08  7:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23  0:22 [Bug tree-optimization/94724] New: wrong code at -O0 on x86_64-linux-gnu qrzhang at gatech dot edu
2020-04-23  5:21 ` [Bug tree-optimization/94724] [10 Regression] wrong code at -O0 on x86_64-linux-gnu since r10-7344-gca6c722561ce9b9d marxin at gcc dot gnu.org
2020-04-23  8:45 ` [Bug middle-end/94724] " jakub at gcc dot gnu.org
2020-04-23  9:30 ` jakub at gcc dot gnu.org
2020-04-23 19:12 ` cvs-commit at gcc dot gnu.org
2020-04-23 19:19 ` jakub at gcc dot gnu.org
2020-05-08  7:37 ` cvs-commit at gcc dot gnu.org
2020-05-08  7:49 ` 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).