public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/61927] [4.9/5 Regression] Wrong results with loop vectorization of: "var[i] = ABS_EXPR<var2[i]>  > 9.9e-7"
Date: Tue, 25 Nov 2014 10:53:00 -0000	[thread overview]
Message-ID: <bug-61927-4-JJUXQsVJSo@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61927-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, we store

  MEM[(logical(kind=4) *)_227] = vect_patt_319.44_273;
...
  MEM[(logical(kind=4) *)_227 + 4B] = vect_patt_318.52_169;
...
  MEM[(logical(kind=4) *)_227 + 8B] = vect_patt_304.60_132;
...

the result vectors 4 bytes apart but the vectors are 16byte V4SI ones.

So we unroll the inner two loops and get

  for (i = 1; i <= 8; ++i)
    {
      symm_nonzero[i][0][0] = ABS ... > ...;
      ... repeated 9 times with other constant 2nd/3rd index ...
    }

which we vectorize to a loop with two iterations but still 9 vector stores
to symm_nonzero.  This doesn't make much sense...  it looks like SLP
failed half-way.  Or rather the vectorizer is somehow confused by
the bool pattern detected:

t.f90:42:0: note: pattern recognized: VIEW_CONVERT_EXPR<unsigned
int>(symm_nonzero[_200]) = patt_319;

with the VIEW_CONVERT_EXPR on the LHS which is not seen as grouped store.

So it looks like vect_recog_bool_pattern does not handle grouped stores
properly and

Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c        (revision 218019)
+++ tree-vect-patterns.c        (working copy)
@@ -3261,6 +3261,8 @@ vect_recog_bool_pattern (vec<gimple> *st
       gcc_assert (vectype != NULL_TREE);
       if (!VECTOR_MODE_P (TYPE_MODE (vectype)))
        return NULL;
+      if (STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo))
+       return NULL;
       if (!check_bool_pattern (var, loop_vinfo, bb_vinfo))
        return NULL;

fixes this testcase (and then does not vectorize this loop).

Any takers making this testcase suitable for the testsuite?  It should
abort() for bogus results and return normally for success.  It should
not output to the terminal.


  parent reply	other threads:[~2014-11-25 10:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-27 16:55 [Bug fortran/61927] New: Optimization bug (regression): Array comparison yields unassigned result at -O3 krefson at gmail dot com
2014-07-27 16:56 ` [Bug fortran/61927] " krefson at gmail dot com
2014-07-27 21:30 ` [Bug middle-end/61927] [4.9/4.10 Regression] Optimization bug: " burnus at gcc dot gnu.org
2014-08-11 10:01 ` [Bug middle-end/61927] [4.9/4.10 Regression] Wrong results with loop vectorization of: "var[i] = ABS_EXPR<var2[i]> > 9.9e-7" jakub at gcc dot gnu.org
2014-10-30 10:41 ` [Bug middle-end/61927] [4.9/5 " jakub at gcc dot gnu.org
2014-11-24 13:03 ` rguenth at gcc dot gnu.org
2014-11-25 10:53 ` rguenth at gcc dot gnu.org [this message]
2014-11-25 11:07 ` rguenth at gcc dot gnu.org
2014-11-25 14:56 ` [Bug middle-end/61927] [4.9 " rguenth at gcc dot gnu.org
2014-11-25 14:56 ` [Bug middle-end/61927] [4.9/5 " rguenth at gcc dot gnu.org
2014-11-26 11:43 ` [Bug middle-end/61927] [4.9 " rguenth at gcc dot gnu.org
2014-11-26 11:45 ` 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-61927-4-JJUXQsVJSo@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).