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/98544] [11 regression] Wrong code generated by tree vectorizer since r11-3917-g28290cb50c7dbf87
Date: Thu, 07 Jan 2021 14:35:40 +0000	[thread overview]
Message-ID: <bug-98544-4-KdpSETBSnO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98544-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #2)
> Confirmed, one can reduce that to a single loop vectorization:
> 
> $ g++ bug2.cc  -std=c++17 -O1 -mavx -ftree-loop-vectorize
> -fdbg-cnt=vect_loop:10-10 && ./a.out
> 
> but the loop is quite huge.

btw, 11-11 or 12-12 or 13-13 also is enough individually to trigger a
miscompare.
The 11-11 loop looks smallest to me:

***dbgcnt: lower limit 11 reached for vect_loop.***
***dbgcnt: upper limit 11 reached for vect_loop.***
fft1d.h:1256:23: optimized: loop vectorized using 32 byte vectors
fft1d.h:1256:23: optimized:  loop versioned for vectorization because of
possible aliasing

it also only needs a single alias check (just guessing where things may go
wrong)

The source corresponds to

template<typename T> void radb2(size_t ido, size_t l1,
  const T * DUCC0_RESTRICT cc, T * DUCC0_RESTRICT ch,
  const T0 * DUCC0_RESTRICT wa) const
  {
  auto WA = [wa,ido](size_t x, size_t i) { return wa[i+x*(ido-1)]; };
  auto CC = [cc,ido](size_t a, size_t b, size_t c) -> const T&
    { return cc[a+ido*(b+2*c)]; };
  auto CH = [ch,ido,l1](size_t a, size_t b, size_t c) -> T&
    { return ch[a+ido*(b+l1*c)]; };

  for (size_t k=0; k<l1; k++)
    PM (CH(0,k,0),CH(0,k,1),CC(0,0,k),CC(ido-1,1,k));
  if ((ido&1)==0)
    for (size_t k=0; k<l1; k++)
      {
      CH(ido-1,k,0) = T0( 2)*CC(ido-1,0,k);
      CH(ido-1,k,1) = T0(-2)*CC(0    ,1,k);
      }
  if (ido<=2) return;
  for (size_t k=0; k<l1;++k)
====>  this loop
    for (size_t i=2; i<ido; i+=2)
      {
      size_t ic=ido-i;
      T ti2, tr2;
      PM (CH(i-1,k,0),tr2,CC(i-1,0,k),CC(ic-1,1,k));
      PM (ti2,CH(i  ,k,0),CC(i  ,0,k),CC(ic  ,1,k));
      MULPM (CH(i,k,1),CH(i-1,k,1),WA(0,i-2),WA(0,i-1),ti2,tr2);
      }
<====
  }

  parent reply	other threads:[~2021-01-07 14:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 18:50 [Bug c++/98544] New: [11 regression] Wrong code generated by tree vectorizer martin@mpa-garching.mpg.de
2021-01-05 19:36 ` [Bug tree-optimization/98544] " martin@mpa-garching.mpg.de
2021-01-06  6:00 ` marxin at gcc dot gnu.org
2021-01-06  6:03 ` [Bug tree-optimization/98544] [11 regression] Wrong code generated by tree vectorizer since r11-3917-g28290cb50c7dbf87 marxin at gcc dot gnu.org
2021-01-06  9:02 ` rguenth at gcc dot gnu.org
2021-01-07 13:59 ` rguenth at gcc dot gnu.org
2021-01-07 14:26 ` marxin at gcc dot gnu.org
2021-01-07 14:27 ` rguenth at gcc dot gnu.org
2021-01-07 14:35 ` rguenth at gcc dot gnu.org [this message]
2021-01-07 15:01 ` rguenth at gcc dot gnu.org
2021-01-07 15:05 ` rguenth at gcc dot gnu.org
2021-01-07 15:19 ` rguenth at gcc dot gnu.org
2021-01-07 15:29 ` rguenth at gcc dot gnu.org
2021-01-07 15:37 ` martin@mpa-garching.mpg.de
2021-01-07 15:50 ` rguenth at gcc dot gnu.org
2021-01-07 16:08 ` martin@mpa-garching.mpg.de
2021-01-07 16:48 ` rguenth at gcc dot gnu.org
2021-01-08 12:14 ` rguenth at gcc dot gnu.org
2021-01-08 12:16 ` rguenth at gcc dot gnu.org
2021-01-08 12:20 ` marxin at gcc dot gnu.org
2021-01-08 13:09 ` cvs-commit at gcc dot gnu.org
2021-01-08 13:09 ` rguenth at gcc dot gnu.org
2021-01-08 14:07 ` martin@mpa-garching.mpg.de
2021-01-08 14:18 ` rguenther at suse dot de

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-98544-4-KdpSETBSnO@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).