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 tree-optimization/107254] [11/12/13 Regression] Wrong vectorizer code (Fortran) since r11-1501-gda2b7c7f0a136b4d
Date: Fri, 14 Oct 2022 08:52:44 +0000	[thread overview]
Message-ID: <bug-107254-4-ZAUcWQ07vM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107254-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So I think the issue is that we have a live operation:

  <bb 3> [local count: 955630225]:
  # jc_42 = PHI <jc_36(7), 1(6)>
  _2 = (integer(kind=8)) jc_42;
  _3 = _2 * stride.1_23;
  _4 = _3 + offset.2_24;
  _5 = _4 + 1;
  _6 = (*h_28(D))[_5];
  _7 = _6 * 9.0000000000000002220446049250313080847263336181640625e-1;
  _8 = _4 + 2;
  _9 = (*h_28(D))[_8];
  temp_29 = _7 + _9;
  _10 = _9 * 9.0000000000000002220446049250313080847263336181640625e-1;
  _11 = _10 - _6;
  (*h_28(D))[_8] = _11;
  (*h_28(D))[_5] = temp_29;
  _12 = (*t_32(D))[_5];
  _13 = _12 * 9.0000000000000002220446049250313080847263336181640625e-1;
  _14 = (*t_32(D))[_8];
  _15 = _13 + _14;
  _16 = _14 * 9.0000000000000002220446049250313080847263336181640625e-1;
  _17 = _16 - _12;
  (*t_32(D))[_8] = _17;
  (*t_32(D))[_5] = _15;
  jc_36 = jc_42 + 1;
  if (_1 < jc_36)
    goto <bb 4>; [11.00%]
  else
    goto <bb 7>; [89.00%]

  <bb 7> [local count: 850510901]:
  goto <bb 3>; [100.00%]

  <bb 4> [local count: 105119324]:
  # _72 = PHI <_15(3)>
  # _71 = PHI <_17(3)>
^^^

that we fail to vectorize which keeps the _12 and _14 loads live but
those are from the wrong iteration.  The out-of loop stores are
caused by invariant motion of 'temp2' (it's memory because it's passed
to dlartg) and which we apperantly cannot disambiguate against the
stores to t so we re-materialize them on the loop exit.

The vectorizer sees

t.f90:27:9: note:   init: stmt relevant? _15 = _13 + _14;
t.f90:27:9: note:   vec_stmt_relevant_p: used out of loop.
t.f90:27:9: note:   vect_is_simple_use: operand _12 *
9.0000000000000002220446049250313080847263336181640625e-1, type of def:
internal
t.f90:27:9: note:   vec_stmt_relevant_p: stmt live but not relevant.
t.f90:27:9: note:   mark relevant 1, live 1: _15 = _13 + _14;

and later

t.f90:27:9: note:   op: VEC_PERM_EXPR
t.f90:27:9: note:       stmt 0 _15 = _13 + _14;
t.f90:27:9: note:       stmt 1 _17 = _16 - _12;
t.f90:27:9: note:       lane permutation { 0[0] 1[1] }
t.f90:27:9: note:       children 0x3358e90 0x3358f18
t.f90:27:9: note:   node 0x3358e90 (max_nunits=1, refcnt=1) vector(4)
real(kind=8)
t.f90:27:9: note:   op template: _15 = _13 + _14;
t.f90:27:9: note:       { }
t.f90:27:9: note:       children 0x3358c70 0x3358e08
...
t.f90:27:9: note:   node 0x3358f18 (max_nunits=1, refcnt=1) vector(4)
real(kind=8)
t.f90:27:9: note:   op template: _17 = _16 - _12;
t.f90:27:9: note:       { }
t.f90:27:9: note:       children 0x3358c70 0x3358e08

investigating further.

  parent reply	other threads:[~2022-10-14  8:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 16:28 [Bug tree-optimization/107254] New: Wrong vectorizer code (GCC 11 only, Fortran) bartoldeman at users dot sourceforge.net
2022-10-13 16:31 ` [Bug tree-optimization/107254] [11 Regression] " pinskia at gcc dot gnu.org
2022-10-13 18:56 ` marxin at gcc dot gnu.org
2022-10-13 19:02 ` pinskia at gcc dot gnu.org
2022-10-14  6:34 ` rguenth at gcc dot gnu.org
2022-10-14  7:50 ` [Bug tree-optimization/107254] [11/12/13 " rguenth at gcc dot gnu.org
2022-10-14  8:31 ` [Bug tree-optimization/107254] [11/12/13 Regression] Wrong vectorizer code (Fortran) marxin at gcc dot gnu.org
2022-10-14  8:52 ` rguenth at gcc dot gnu.org [this message]
2022-10-14  8:52 ` [Bug tree-optimization/107254] [11/12/13 Regression] Wrong vectorizer code (Fortran) since r11-1501-gda2b7c7f0a136b4d rguenth at gcc dot gnu.org
2022-10-14  9:19 ` rguenth at gcc dot gnu.org
2022-10-14 10:00 ` cvs-commit at gcc dot gnu.org
2022-10-14 10:01 ` [Bug tree-optimization/107254] [11/12 " rguenth at gcc dot gnu.org
2022-10-17 12:23 ` bartoldeman at users dot sourceforge.net
2022-10-17 13:11 ` cvs-commit at gcc dot gnu.org
2023-01-24 15:22 ` [Bug tree-optimization/107254] [11 " cvs-commit at gcc dot gnu.org
2023-01-24 15:23 ` 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-107254-4-ZAUcWQ07vM@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).