public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/59594] [4.9 Regression] wrong code (by tree vectorizer) at -O3 on x86_64-linux-gnu
Date: Wed, 22 Jan 2014 13:22:00 -0000	[thread overview]
Message-ID: <bug-59594-4-LxlbN2VLjw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59594-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59594

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 31919
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31919&action=edit
gcc49-pr59594.patch

Untested patch for discussion.  The reason why we (incorrectly) vectorize the
testcase is that we ignore the data dependency, on the testcase both the b[a]
read vs. b[a+1] store and b[a] store vs. b[a+1] store DDRs have dist 1 and
DDR_REVERSED_P set and we ignore those.  Now on say:
int printf (const char *, ...);

int a;
static int b[1024];

int
main ()
{
  for (a = 0; a <= 512; a++)
    {
      b[a - 1] = b[a];
      b[a] = 1;
    }
  printf ("%d\n", b[1]);
  return 0;
}
only the b[a] read vs. b[a-1] store is dist 1 DDR_REVERSED_P and b[a] store vs.
b[a-1] store is dist 1 !DDR_REVERSED_P, thus we don't vectorize it (correctly).
Unfortunately not ignoring dist > 0 && DDR_REVERSED_P ddrs for negative step
regresses the testcase I've attached, where there is a write after read ddr and
it works properly with the current check.  While the attached patch keeps that
testcase (no-vfa-vect-depend*.c) working and fixes the test (pr59594.c), the
conditions are piled completely randomly, I'm afraid I don't know why it is so,
if for the DDR_REVERSED_P continue it matters whether step is positive or
negative, or if that is irrelevant and all the write after write DDR_REVERSED_P
ddrs need to be checked normally (abs (dist) >= *max_vf), or if say only write
after read should be treated as the code treats it right now and even read
after write is problematic.  The DDR_REVERSED_P stuff has been added in 2007
for PR32377, see e.g. http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01067.html

Richard, any ideas?


  parent reply	other threads:[~2014-01-22 13:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-24 17:14 [Bug tree-optimization/59594] New: " su at cs dot ucdavis.edu
2013-12-24 18:10 ` [Bug tree-optimization/59594] [4.9 Regression] " hjl.tools at gmail dot com
2013-12-24 18:37 ` hjl.tools at gmail dot com
2014-01-13 10:19 ` jakub at gcc dot gnu.org
2014-01-13 13:47 ` hjl.tools at gmail dot com
2014-01-13 14:02 ` jakub at gcc dot gnu.org
2014-01-22 13:22 ` jakub at gcc dot gnu.org [this message]
2014-01-24 10:03 ` jakub at gcc dot gnu.org
2014-01-29  9:28 ` jakub at gcc dot gnu.org
2014-01-29 11:04 ` jakub 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-59594-4-LxlbN2VLjw@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).