public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3
@ 2020-11-09  2:58 yangyang305 at huawei dot com
  2020-11-09  3:01 ` [Bug tree-optimization/97760] " yangyang305 at huawei dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: yangyang305 at huawei dot com @ 2020-11-09  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97760
           Summary: GCC outputs wrong values when compiling the testcase
                    with -O3
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyang305 at huawei dot com
  Target Milestone: ---

Hi, gcc-trunk outputs wrong values when compiling the attached testcase with
-O3.


gcc -O0 test.c -w && ./a.out

159,150,150
150

gcc -O3 test.c -w && ./a.out

159,123,123
123

GCC version: 11.0.0 20201106 (experimental)

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

* [Bug tree-optimization/97760] GCC outputs wrong values when compiling the testcase with -O3
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
@ 2020-11-09  3:01 ` yangyang305 at huawei dot com
  2020-11-09  8:13 ` [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e marxin at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: yangyang305 at huawei dot com @ 2020-11-09  3:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from yangyang <yangyang305 at huawei dot com> ---
Created attachment 49521
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49521&action=edit
testcase

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

* [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
  2020-11-09  3:01 ` [Bug tree-optimization/97760] " yangyang305 at huawei dot com
@ 2020-11-09  8:13 ` marxin at gcc dot gnu.org
  2020-11-09  8:17 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-11-09  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|GCC outputs wrong values    |[10/11 Regression] GCC
                   |when compiling the testcase |outputs wrong values when
                   |with -O3                    |compiling the testcase with
                   |                            |-O3 since
                   |                            |r10-4200-gb7ff7cef5005721e
           Priority|P3                          |P1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
   Target Milestone|---                         |10.3
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2020-11-09

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r10-4200-gb7ff7cef5005721e.

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

* [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
  2020-11-09  3:01 ` [Bug tree-optimization/97760] " yangyang305 at huawei dot com
  2020-11-09  8:13 ` [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e marxin at gcc dot gnu.org
@ 2020-11-09  8:17 ` rguenth at gcc dot gnu.org
  2020-11-09 13:38 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-09  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.

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

* [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
                   ` (2 preceding siblings ...)
  2020-11-09  8:17 ` rguenth at gcc dot gnu.org
@ 2020-11-09 13:38 ` rguenth at gcc dot gnu.org
  2020-11-09 14:19 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-09 13:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
int b=1;
static int *g = &b;

void __attribute__((noipa))
h (unsigned int n)
{
  int i = 3;
  int f = 3;
  for (; f <= 50; f += 4) {
    i += 4;
    *g = i;
    i += n;
  }
}

int main ()
{
  h (9);
  if (*g != 150 || b != 150)
    __builtin_abort ();
  return 0;
}

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

* [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
                   ` (3 preceding siblings ...)
  2020-11-09 13:38 ` rguenth at gcc dot gnu.org
@ 2020-11-09 14:19 ` rguenth at gcc dot gnu.org
  2020-11-10  9:18 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-09 14:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
t.c:9:12: note:   worklist: examine stmt: i_16 = PHI <i_11(5), 3(2)>
t.c:9:12: note:   vect_is_simple_use: operand (int) _3, type of def: reduction
t.c:9:12: note:   reduc-stmt defining reduc-phi in the same nest.
t.c:9:12: note:   mark relevant 1, live 1: i_11 = (int) _3;

so reduc PHI defs are marked live magically - that's obviously wrong here,
the live stmt is one in the middle of the reduction path (which _is_ marked
live).  What happens is that we generate two vectorized epilogues and depending
on the order we end up with the wrong result in b.

Now, what's _also_ wrong is that we cannot handle this situation since
the epilogue of the middle stmt fails to account for the all-but-the-last
lane effect of the _not_ live stmt.

While the former bug is easy to fix the latter is not.

I have a patch.

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

* [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
                   ` (4 preceding siblings ...)
  2020-11-09 14:19 ` rguenth at gcc dot gnu.org
@ 2020-11-10  9:18 ` cvs-commit at gcc dot gnu.org
  2020-11-10  9:22 ` [Bug tree-optimization/97760] [10 " rguenth 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-11-10  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:2686de5617bfb572343933be2883e8274c9735b5

commit r11-4865-g2686de5617bfb572343933be2883e8274c9735b5
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 9 15:19:56 2020 +0100

    tree-optimization/97760 - reduction paths with unhandled live stmt

    This makes sure we reject reduction paths with a live stmt that
    is not the last one altering the value.  This is because we do not
    handle this in the epilogue unless there's a scalar epilogue loop.

    2020-11-09  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/97760
            * tree-vect-loop.c (check_reduction_path): Reject
            reduction paths we do not handle in epilogue generation.

            * gcc.dg/vect/pr97760.c: New testcase.

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

* [Bug tree-optimization/97760] [10 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
                   ` (5 preceding siblings ...)
  2020-11-10  9:18 ` cvs-commit at gcc dot gnu.org
@ 2020-11-10  9:22 ` rguenth at gcc dot gnu.org
  2020-12-01 15:44 ` cvs-commit at gcc dot gnu.org
  2020-12-01 15:45 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-10  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11 Regression] GCC      |[10 Regression] GCC outputs
                   |outputs wrong values when   |wrong values when compiling
                   |compiling the testcase with |the testcase with -O3 since
                   |-O3 since                   |r10-4200-gb7ff7cef5005721e
                   |r10-4200-gb7ff7cef5005721e  |
      Known to fail|11.0                        |
      Known to work|                            |11.0

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.

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

* [Bug tree-optimization/97760] [10 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
                   ` (6 preceding siblings ...)
  2020-11-10  9:22 ` [Bug tree-optimization/97760] [10 " rguenth at gcc dot gnu.org
@ 2020-12-01 15:44 ` cvs-commit at gcc dot gnu.org
  2020-12-01 15:45 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-01 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 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:7b523f3dff5d7bf49294fe5b794f63cae28d5c5b

commit r10-9102-g7b523f3dff5d7bf49294fe5b794f63cae28d5c5b
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 9 15:19:56 2020 +0100

    tree-optimization/97760 - reduction paths with unhandled live stmt

    This makes sure we reject reduction paths with a live stmt that
    is not the last one altering the value.  This is because we do not
    handle this in the epilogue unless there's a scalar epilogue loop.

    2020-11-09  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/97760
            * tree-vect-loop.c (check_reduction_path): Reject
            reduction paths we do not handle in epilogue generation.

            * gcc.dg/vect/pr97760.c: New testcase.

    (cherry picked from commit 2686de5617bfb572343933be2883e8274c9735b5)

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

* [Bug tree-optimization/97760] [10 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e
  2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
                   ` (7 preceding siblings ...)
  2020-12-01 15:44 ` cvs-commit at gcc dot gnu.org
@ 2020-12-01 15:45 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-12-01 15:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |10.2.1
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

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

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

end of thread, other threads:[~2020-12-01 15:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09  2:58 [Bug tree-optimization/97760] New: GCC outputs wrong values when compiling the testcase with -O3 yangyang305 at huawei dot com
2020-11-09  3:01 ` [Bug tree-optimization/97760] " yangyang305 at huawei dot com
2020-11-09  8:13 ` [Bug tree-optimization/97760] [10/11 Regression] GCC outputs wrong values when compiling the testcase with -O3 since r10-4200-gb7ff7cef5005721e marxin at gcc dot gnu.org
2020-11-09  8:17 ` rguenth at gcc dot gnu.org
2020-11-09 13:38 ` rguenth at gcc dot gnu.org
2020-11-09 14:19 ` rguenth at gcc dot gnu.org
2020-11-10  9:18 ` cvs-commit at gcc dot gnu.org
2020-11-10  9:22 ` [Bug tree-optimization/97760] [10 " rguenth at gcc dot gnu.org
2020-12-01 15:44 ` cvs-commit at gcc dot gnu.org
2020-12-01 15:45 ` 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).