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/110760] New: slp introduces new wrapped arithmetic
Date: Thu, 20 Jul 2023 22:42:24 +0000	[thread overview]
Message-ID: <bug-110760-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110760
           Summary: slp introduces new wrapped arithmetic
           Product: gcc
           Version: 14.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 following function from gcc.dg/vect/bb-slp-layout-5.c:

int a[4], b[4], c[4];

void f1()
{
  a[0] = b[3] - c[3];
  a[1] = b[2] + c[2];
  a[2] = b[1] - c[1];
  a[3] = b[0] + c[0];
}

This is vectorized by slp2:
  vector(4) int vect__1.5;
  vector(4) int vect__2.8;
  vector(4) int vect__12.10;
  vector(4) int vect__3.9;
  vector(4) int _22;
  vect__1.5_18 = MEM <vector(4) int> [(int *)&b];
  vect__2.8_19 = MEM <vector(4) int> [(int *)&c];
  vect__12.10_21 = vect__1.5_18 + vect__2.8_19;
  vect__3.9_20 = vect__1.5_18 - vect__2.8_19;
  _22 = VEC_PERM_EXPR <vect__3.9_20, vect__12.10_21, { 3, 6, 1, 4 }>;
  MEM <vector(4) int> [(int *)&a] = _22;

But this introduces new calculations in the temporary vectors of the unused
elements:
  b[0] - c[0];
  b[1] + c[1];
  b[2] - c[2];
  b[3] + c[3];
and these calculations may wrap for input where the original program did not
wrap.

             reply	other threads:[~2023-07-20 22:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 22:42 kristerw at gcc dot gnu.org [this message]
2023-07-20 22:45 ` [Bug tree-optimization/110760] " pinskia at gcc dot gnu.org
2023-07-20 22:46 ` [Bug tree-optimization/110760] slp introduces new overflow arithmetic pinskia at gcc dot gnu.org
2023-07-20 23:29 ` kristerw at gcc dot gnu.org
2023-07-20 23:46 ` pinskia at gcc dot gnu.org
2023-07-21  7:03 ` 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-110760-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).