public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/106744] New: phiopt miscompiles min/max
@ 2022-08-26  3:40 kristerw at gcc dot gnu.org
  2022-08-26  6:19 ` [Bug tree-optimization/106744] [13 Regression] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: kristerw at gcc dot gnu.org @ 2022-08-26  3:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106744
           Summary: phiopt miscompiles min/max
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kristerw at gcc dot gnu.org
  Target Milestone: ---

GCC miscompiles the following test at -O1 or higher optimization levels:

#include <stdint.h>

__attribute__((noinline)) uint8_t
three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) {
  uint8_t  xk;
  if (xc > xm) {
    xk = (uint8_t) (xc < xy ? xc : xy);
  } else {
    xk = (uint8_t) (xm < xy ? xm : xy);
  }
  return xk;
}

int
main (void)
{
  volatile uint8_t xy = 255;
  volatile uint8_t xm = 0;
  volatile uint8_t xc = 255;
  if (three_minmax1 (xc, xm, xy) != 255)
    __builtin_abort ();
  return 0;
}

What is happening is that phiopt transforms three_minmax1 to

  _7 = MAX_EXPR <xc_2(D), xy_4(D)>;
  _9 = MIN_EXPR <_7, xm_3(D)>;
  return _9;

instead of the intended

  _7 = MAX_EXPR <xc_2(D), xm_3(D)>;
  _9 = MIN_EXPR <_7, xy_4(D)>;
  return _9;

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

* [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max
  2022-08-26  3:40 [Bug tree-optimization/106744] New: phiopt miscompiles min/max kristerw at gcc dot gnu.org
@ 2022-08-26  6:19 ` rguenth at gcc dot gnu.org
  2022-08-26 10:03 ` tnfchris at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-26  6:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-08-26
            Summary|phiopt miscompiles min/max  |[13 Regression] phiopt
                   |                            |miscompiles min/max
     Ever confirmed|0                           |1
           Priority|P3                          |P1
           Keywords|                            |needs-bisection, wrong-code
   Target Milestone|---                         |13.0
                 CC|                            |tnfchris at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  CCing suspect.

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

* [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max
  2022-08-26  3:40 [Bug tree-optimization/106744] New: phiopt miscompiles min/max kristerw at gcc dot gnu.org
  2022-08-26  6:19 ` [Bug tree-optimization/106744] [13 Regression] " rguenth at gcc dot gnu.org
@ 2022-08-26 10:03 ` tnfchris at gcc dot gnu.org
  2022-08-26 12:47 ` [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max since r13-1950-g9bb19e143cfe8863 marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2022-08-26 10:03 UTC (permalink / raw)
  To: gcc-bugs

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

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

--- Comment #2 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Guilty as charged. Should have made the tests check for SSA names too.

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

* [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max since r13-1950-g9bb19e143cfe8863
  2022-08-26  3:40 [Bug tree-optimization/106744] New: phiopt miscompiles min/max kristerw at gcc dot gnu.org
  2022-08-26  6:19 ` [Bug tree-optimization/106744] [13 Regression] " rguenth at gcc dot gnu.org
  2022-08-26 10:03 ` tnfchris at gcc dot gnu.org
@ 2022-08-26 12:47 ` marxin at gcc dot gnu.org
  2022-08-30  7:01 ` cvs-commit at gcc dot gnu.org
  2022-08-30  7:07 ` tnfchris at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-08-26 12:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
            Summary|[13 Regression] phiopt      |[13 Regression] phiopt
                   |miscompiles min/max         |miscompiles min/max since
                   |                            |r13-1950-g9bb19e143cfe8863
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r13-1950-g9bb19e143cfe8863.

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

* [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max since r13-1950-g9bb19e143cfe8863
  2022-08-26  3:40 [Bug tree-optimization/106744] New: phiopt miscompiles min/max kristerw at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-08-26 12:47 ` [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max since r13-1950-g9bb19e143cfe8863 marxin at gcc dot gnu.org
@ 2022-08-30  7:01 ` cvs-commit at gcc dot gnu.org
  2022-08-30  7:07 ` tnfchris at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-30  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <tnfchris@gcc.gnu.org>:

https://gcc.gnu.org/g:37ebaabde2b88d446369240ae8f03b8e6a284a7b

commit r13-2259-g37ebaabde2b88d446369240ae8f03b8e6a284a7b
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Tue Aug 30 07:49:02 2022 +0100

    middle-end: fix min/max phiopts reduction [PR106744]

    This corrects the argument usage to use them in the order that they occur
in
    the comparisons in gimple.

    gcc/ChangeLog:

            PR tree-optimization/106744
            * tree-ssa-phiopt.cc (minmax_replacement): Correct arguments.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/106744
            * gcc.dg/tree-ssa/minmax-10.c: Make runtime test.
            * gcc.dg/tree-ssa/minmax-11.c: Likewise.
            * gcc.dg/tree-ssa/minmax-12.c: Likewise.
            * gcc.dg/tree-ssa/minmax-13.c: Likewise.
            * gcc.dg/tree-ssa/minmax-14.c: Likewise.
            * gcc.dg/tree-ssa/minmax-15.c: Likewise.
            * gcc.dg/tree-ssa/minmax-16.c: Likewise.
            * gcc.dg/tree-ssa/minmax-3.c: Likewise.
            * gcc.dg/tree-ssa/minmax-4.c: Likewise.
            * gcc.dg/tree-ssa/minmax-5.c: Likewise.
            * gcc.dg/tree-ssa/minmax-6.c: Likewise.
            * gcc.dg/tree-ssa/minmax-7.c: Likewise.
            * gcc.dg/tree-ssa/minmax-8.c: Likewise.
            * gcc.dg/tree-ssa/minmax-9.c: Likewise.

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

* [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max since r13-1950-g9bb19e143cfe8863
  2022-08-26  3:40 [Bug tree-optimization/106744] New: phiopt miscompiles min/max kristerw at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-08-30  7:01 ` cvs-commit at gcc dot gnu.org
@ 2022-08-30  7:07 ` tnfchris at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2022-08-30  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

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

--- Comment #5 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Fixed, thanks for the report.

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

end of thread, other threads:[~2022-08-30  7:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26  3:40 [Bug tree-optimization/106744] New: phiopt miscompiles min/max kristerw at gcc dot gnu.org
2022-08-26  6:19 ` [Bug tree-optimization/106744] [13 Regression] " rguenth at gcc dot gnu.org
2022-08-26 10:03 ` tnfchris at gcc dot gnu.org
2022-08-26 12:47 ` [Bug tree-optimization/106744] [13 Regression] phiopt miscompiles min/max since r13-1950-g9bb19e143cfe8863 marxin at gcc dot gnu.org
2022-08-30  7:01 ` cvs-commit at gcc dot gnu.org
2022-08-30  7:07 ` tnfchris 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).