public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/106523] New: forwprop miscompile
@ 2022-08-04 10:23 kristerw at gcc dot gnu.org
  2022-08-04 10:48 ` [Bug tree-optimization/106523] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kristerw at gcc dot gnu.org @ 2022-08-04 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106523
           Summary: forwprop miscompile
           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: ---

The function f7 from testsuite/c-c++-common/rotate-2.c is miscompiled by
forwprop. This can be seen by running the function as

__attribute__((noinline)) unsigned char
f7 (unsigned char x, unsigned int y)
{
  unsigned int t = x;
  return (t << y) | (t >> ((-y) & 7));
}

int
main (void)
{
  volatile unsigned char x = 152;
  volatile unsigned int y = 19;
  if (f7(x, y) != 4)
    __builtin_abort ();

  return 0;
}

This fails at -O1 and higher optimization levels.

What is happening here is that forwprop1 has optimized the function
to
  _10 = x_7(D) r<< y_9(D);
  return _10;

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

end of thread, other threads:[~2023-07-07 10:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 10:23 [Bug tree-optimization/106523] New: forwprop miscompile kristerw at gcc dot gnu.org
2022-08-04 10:48 ` [Bug tree-optimization/106523] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
2022-08-09 12:40 ` marxin at gcc dot gnu.org
2023-01-16 12:27 ` jakub at gcc dot gnu.org
2023-01-16 12:54 ` jakub at gcc dot gnu.org
2023-01-16 17:43 ` jakub at gcc dot gnu.org
2023-01-17 11:19 ` cvs-commit at gcc dot gnu.org
2023-01-17 11:20 ` [Bug tree-optimization/106523] [10/11/12 " jakub at gcc dot gnu.org
2023-01-17 23:46 ` kristerw at gcc dot gnu.org
2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
2023-02-10 17:56 ` [Bug tree-optimization/106523] [10/11 " jakub at gcc dot gnu.org
2023-07-07 10:43 ` [Bug tree-optimization/106523] [11 " 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).