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/106523] New: forwprop miscompile
Date: Thu, 04 Aug 2022 10:23:41 +0000	[thread overview]
Message-ID: <bug-106523-4@http.gcc.gnu.org/bugzilla/> (raw)

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;

             reply	other threads:[~2022-08-04 10:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 10:23 kristerw at gcc dot gnu.org [this message]
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

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-106523-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).