public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kristerw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106883] New: SLSR may generate signed wrap
Date: Thu, 08 Sep 2022 00:05:37 +0000	[thread overview]
Message-ID: <bug-106883-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106883
           Summary: SLSR may generate signed wrap
           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: ---

SLSR may generate new signed wrap for cases where the original did not wrap.
This can be seen in the function f from gcc.dg/tree-ssa/slsr-19.c:

int
f (int c, int s)
{
  int x1, x2, y1, y2;

  y1 = c + 2;
  x1 = s * y1;
  y2 = y1 + 2;
  x2 = s * y2;
  return x1 + x2;
}

SLSR optimizes this to

int f (int c, int s)
{
   int y1;
   int x2;
   int x1;
   int _7;
   int slsr_9;

   <bb 2>:
   y1_2 = c_1(D) + 2;
   x1_4 = y1_2 * s_3(D);
   slsr_9 = s_3(D) * 2;
   x2_6 = x1_4 + slsr_9;
   _7 = x1_4 + x2_6;
   return _7;

Calling f(-3, 0x75181005) does not make any operation wrap in the original
function, but slsr_9 overflow in the optimized code.

             reply	other threads:[~2022-09-08  0:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  0:05 kristerw at gcc dot gnu.org [this message]
2022-09-08  9:44 ` [Bug tree-optimization/106883] " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106883-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).