public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ktkachov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/97442] New: Wrong represenation of AArch64 saba in RTL
Date: Thu, 15 Oct 2020 11:18:34 +0000	[thread overview]
Message-ID: <bug-97442-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 97442
           Summary: Wrong represenation of AArch64 saba in RTL
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64

This is similar to the issue fixed in
https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=8544ed6eea68a80999504c8a4b21b77d29cd86e2

The representation of the SABA (and UABA) in RTL is not correct and the below
testcase will abort at -O3 -fwrapv:

#define N 16
signed char a[] = {-100, -100, -100, -100,-100, -100, -100, -100, -100, -100,
-100, -100, -100, -100, -100, -100 };
signed char b[] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100 };

signed char out[N] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100 };

__attribute__ ((noinline,noipa))
void
foo (void)
{
  for (int i = 0; i < N; i++)
    {
      signed char diff = b[i] - a[i];
      out[i] += diff > 0 ? diff : -diff;
    }
}

signed char out2[N] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100 };

__attribute__ ((noinline,noipa))
void
foo_scalar (void)
{
  for (int i = 0; i < N; i++)
    {
      asm volatile ("");
      signed char diff = b[i] - a[i];
      out2[i] += diff > 0 ? diff : -diff;
    }
}

int
main (void)
{
  foo ();
  foo_scalar ();
  for (int i = 0; i < N; i++)
    if (out[i] != out2[i])
      __builtin_abort ();

  return 0;
}

due to function foo generating a saba when it shouldn't

             reply	other threads:[~2020-10-15 11:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 11:18 ktkachov at gcc dot gnu.org [this message]
2021-08-17  1:23 ` [Bug target/97442] " pinskia at gcc dot gnu.org
2022-12-19 21:45 ` pinskia 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-97442-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).