public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109626] New: forwprop introduces new signed multiplication UB
@ 2023-04-25 21:53 kristerw at gcc dot gnu.org
  2023-04-26  6:36 ` [Bug tree-optimization/109626] " rguenth at gcc dot gnu.org
  2023-04-26  8:50 ` mikael at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: kristerw at gcc dot gnu.org @ 2023-04-25 21:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109626
           Summary: forwprop introduces new signed multiplication UB
           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: ---

Consider the function

int foo(_Bool v0, unsigned v1, unsigned v2)
{
  signed int v5 = v1 >> v2;
  unsigned v6 = -v1;
  unsigned int v7 = v2 - v0;
  return (int)v7 * (int)v6;
}

This does not invoke undefined behavior when called as foo(0, 0x80000000, 1),
but forwprop1 optimizes this to the equivalent of

int foo(_Bool v0, unsigned v1, unsigned v2)
{
  signed int v5 = v1 >> v2;
  unsigned int v7 = v0 - v2;
  return (int)v7 * (int)v1;
}

where the signed multiplication now is calculating -1 * INT_MIN.

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

end of thread, other threads:[~2023-04-26  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25 21:53 [Bug tree-optimization/109626] New: forwprop introduces new signed multiplication UB kristerw at gcc dot gnu.org
2023-04-26  6:36 ` [Bug tree-optimization/109626] " rguenth at gcc dot gnu.org
2023-04-26  8:50 ` mikael 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).