public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114090] New: forwprop -fwrapv miscompilation
@ 2024-02-24 18:02 kristerw at gcc dot gnu.org
  2024-02-24 18:10 ` [Bug tree-optimization/114090] [13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: kristerw at gcc dot gnu.org @ 2024-02-24 18:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114090
           Summary: forwprop -fwrapv miscompilation
           Product: gcc
           Version: 14.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: ---

The function f below returns an incorrect result for INT_MIN when compiled with
-O1 -fwrapv for X86_64:


__attribute__((noipa)) int f(int x) {
    int w = (x >= 0 ? x : 0);
    int y = -x;
    int z = (y >= 0 ? y : 0);
    return w + z;
}

int
main ()
{
  if (f(0x80000000) != 0)
    __builtin_abort ();
  return 0;
}


What is happening is that forwprop has optimized

  w_2 = MAX_EXPR <x_1(D), 0>;
  y_3 = -x_1(D);
  z_4 = MAX_EXPR <y_3, 0>;
  _5 = w_2 + z_4;
  return _5;

to

  _5 = ABS_EXPR <x_1(D)>;
  return _5;

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

end of thread, other threads:[~2024-03-04 12:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-24 18:02 [Bug tree-optimization/114090] New: forwprop -fwrapv miscompilation kristerw at gcc dot gnu.org
2024-02-24 18:10 ` [Bug tree-optimization/114090] [13/14 Regression] " pinskia at gcc dot gnu.org
2024-02-24 18:14 ` pinskia at gcc dot gnu.org
2024-02-24 18:16 ` jakub at gcc dot gnu.org
2024-02-24 18:24 ` jakub at gcc dot gnu.org
2024-02-24 18:27 ` jakub at gcc dot gnu.org
2024-02-24 18:45 ` jakub at gcc dot gnu.org
2024-02-26  9:09 ` cvs-commit at gcc dot gnu.org
2024-02-26  9:27 ` [Bug tree-optimization/114090] [13 " jakub at gcc dot gnu.org
2024-03-02  0:39 ` cvs-commit at gcc dot gnu.org
2024-03-04 12:13 ` jakub 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).