public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher
@ 2021-01-12 17:01 vsevolod.livinskij at frtk dot ru
  2021-01-12 18:45 ` [Bug tree-optimization/98640] [10/11 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80 marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vsevolod.livinskij at frtk dot ru @ 2021-01-12 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98640
           Summary: GCC produces incorrect code with -O1 and higher
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
#include <stdio.h>

unsigned long long int var_0 = 18128133247277979402ULL;
long long int var_14 = 6557021550272328915LL;
unsigned long long int var_83 = 10966786425750692026ULL;

void test() {
  var_14 = var_0 + (bool)7;
  var_83 = 1 + (int)var_0; // 1 + 888395530
}

int main() {
    test();
    printf("%llu\n", var_83);
}

https://godbolt.org/z/axYx1f

>$ g++ -O0 driver.cpp && ./a.out 
888395531
>$ g++ -O1 driver.cpp && ./a.out 
18128133247277979403

gcc version 11.0.0 20210112 (cf2ac1c30af0fa783c8d72e527904dda5d8cc330)

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

* [Bug tree-optimization/98640] [10/11 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80
  2021-01-12 17:01 [Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher vsevolod.livinskij at frtk dot ru
@ 2021-01-12 18:45 ` marxin at gcc dot gnu.org
  2021-01-13  8:18 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-01-12 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-01-12
            Summary|GCC produces incorrect code |[10/11 Regression] GCC
                   |with -O1 and higher         |produces incorrect code
                   |                            |with -O1 and higher since
                   |                            |r10-2711-g3ed01d5408045d80
   Target Milestone|---                         |10.3
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
      Known to fail|                            |10.2.0, 11.0

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Thanks for the report, started with r10-2711-g3ed01d5408045d80.

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

* [Bug tree-optimization/98640] [10/11 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80
  2021-01-12 17:01 [Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher vsevolod.livinskij at frtk dot ru
  2021-01-12 18:45 ` [Bug tree-optimization/98640] [10/11 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80 marxin at gcc dot gnu.org
@ 2021-01-13  8:18 ` rguenth at gcc dot gnu.org
  2021-01-13 10:13 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-13  8:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

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

* [Bug tree-optimization/98640] [10/11 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80
  2021-01-12 17:01 [Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher vsevolod.livinskij at frtk dot ru
  2021-01-12 18:45 ` [Bug tree-optimization/98640] [10/11 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80 marxin at gcc dot gnu.org
  2021-01-13  8:18 ` rguenth at gcc dot gnu.org
@ 2021-01-13 10:13 ` cvs-commit at gcc dot gnu.org
  2021-03-03 10:36 ` [Bug tree-optimization/98640] [10 " cvs-commit at gcc dot gnu.org
  2021-03-03 10:37 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-13 10:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS 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:ffd28c265e6d611983cd27e9332dc799039a3f04

commit r11-6632-gffd28c265e6d611983cd27e9332dc799039a3f04
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jan 13 09:43:52 2021 +0100

    tree-optimization/98640 - fix bogus sign-extension with VN

    VN tried to express a sign extension from int to long of
    a trucated quantity with a plain conversion but that loses the
    truncation.  Since there's no single operand doing truncate plus
    sign extend (there was a proposed SEXT_EXPR to do that at some
    point mapping to RTL sign_extract) don't bother to appropriately
    model this with two ops (which the VN insert machinery doesn't
    handle and which is unlikely to CSE fully).

    2021-01-13  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/98640
            * tree-ssa-sccvn.c (visit_nary_op): Do not try to
            handle plus or minus from a truncated operand to be
            sign-extended.

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

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

* [Bug tree-optimization/98640] [10 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80
  2021-01-12 17:01 [Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher vsevolod.livinskij at frtk dot ru
                   ` (2 preceding siblings ...)
  2021-01-13 10:13 ` cvs-commit at gcc dot gnu.org
@ 2021-03-03 10:36 ` cvs-commit at gcc dot gnu.org
  2021-03-03 10:37 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-03 10:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:268b54382e5248ee1a5e3f4a0841358e03290d17

commit r10-9407-g268b54382e5248ee1a5e3f4a0841358e03290d17
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jan 13 09:43:52 2021 +0100

    tree-optimization/98640 - fix bogus sign-extension with VN

    VN tried to express a sign extension from int to long of
    a trucated quantity with a plain conversion but that loses the
    truncation.  Since there's no single operand doing truncate plus
    sign extend (there was a proposed SEXT_EXPR to do that at some
    point mapping to RTL sign_extract) don't bother to appropriately
    model this with two ops (which the VN insert machinery doesn't
    handle and which is unlikely to CSE fully).

    2021-01-13  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/98640
            * tree-ssa-sccvn.c (visit_nary_op): Do not try to
            handle plus or minus from a truncated operand to be
            sign-extended.

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

    (cherry picked from commit ffd28c265e6d611983cd27e9332dc799039a3f04)

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

* [Bug tree-optimization/98640] [10 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80
  2021-01-12 17:01 [Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher vsevolod.livinskij at frtk dot ru
                   ` (3 preceding siblings ...)
  2021-03-03 10:36 ` [Bug tree-optimization/98640] [10 " cvs-commit at gcc dot gnu.org
@ 2021-03-03 10:37 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-03 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-03-03 10:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 17:01 [Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher vsevolod.livinskij at frtk dot ru
2021-01-12 18:45 ` [Bug tree-optimization/98640] [10/11 Regression] GCC produces incorrect code with -O1 and higher since r10-2711-g3ed01d5408045d80 marxin at gcc dot gnu.org
2021-01-13  8:18 ` rguenth at gcc dot gnu.org
2021-01-13 10:13 ` cvs-commit at gcc dot gnu.org
2021-03-03 10:36 ` [Bug tree-optimization/98640] [10 " cvs-commit at gcc dot gnu.org
2021-03-03 10:37 ` 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).