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 fortran/62283] basic-block vectorization fails
Date: Thu, 28 Aug 2014 09:42:00 -0000	[thread overview]
Message-ID: <bug-62283-4-RhOtJrLNb7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-62283-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #6)
> (In reply to Henrik Holst from comment #4)
> > Thank you Richard for looking into this issue.
> > 
> > You probably know already exactly why this bug appeared. I just wanted to
> > stress the severity of this issue, and especially for Fortran which is often
> > used in "number crunching" applications AND subroutine arguments are passed
> > by reference by default.
> > 
> > The following F2008 code works as expected:
> > 
> >       subroutine test1(x,y)
> >       real x(4),y(4)
> >       gamma=3.141593
> >       block
> >         beta=gamma
> >         y(1)=y(1)+beta*x(1)
> >         y(2)=y(2)+beta*x(2)
> >         y(3)=y(3)+beta*x(3)
> >         y(4)=y(4)+beta*x(4)
> >       end block
> >       end
> > 
> > but when `beta=gamma` is replaced with `beta=alpha` it again fails and
> > generates scalar code. So I ask: Does this bug force *ALL* computations
> > which involves directly or indirectly parameter values to subroutines and
> > functions, to be done in scalar? If so, its pretty bad.
> 
> For basic-block vectorization?  It depends whether the first use of
> the indirect parameter is in the same basic-block that is supposed
> to be vectorized or not ...
> 
> > Related or not, the following codes also generates scalar code:
> > 
> >       subroutine test2(x,y)
> >       real x(4),y(4)
> >       beta=3.141593
> >       do i=1,4
> >         y(i)=y(i)+beta*x(i)
> >       end do
> >       end
> 
> That's because we decide to peel for alignment and then decide the
> result is not profitable to vectorize.  With -fno-vect-cost-model
> the loop is vectorized (but in an awkward way).  You may want to
> file a separate bug about this.
> 
> > and
> > 
> >       subroutine test3(x,y)
> >       real x(4),y(4)
> >       beta=3.141593
> >       y=y+beta*x
> >       end
> 
> Same issue (add it as another testcase to the new bug).
> 
> It is of course pointless to peel for alignment if the remaining loop
> will always run less than the vectorization factor.  Versioning for
> alignment may still be applied here.

I have a simple patch for this.

> > as well. I can create another bug for this if you think they are unrelated.


  parent reply	other threads:[~2014-08-28  9:42 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27 11:49 [Bug fortran/62283] New: SSE optimization fails holst at matmech dot com
2014-08-27 11:52 ` [Bug fortran/62283] " holst at matmech dot com
2014-08-27 12:00 ` [Bug fortran/62283] basic-block vectorization fails rguenth at gcc dot gnu.org
2014-08-27 12:43 ` rguenth at gcc dot gnu.org
2014-08-27 14:26 ` holst at matmech dot com
2014-08-27 14:52 ` holst at matmech dot com
2014-08-28  9:17 ` rguenth at gcc dot gnu.org
2014-08-28  9:42 ` rguenth at gcc dot gnu.org [this message]
2014-08-28 13:14 ` rguenth at gcc dot gnu.org
2014-08-28 13:14 ` rguenth at gcc dot gnu.org
2014-09-01 13:33 ` ro at gcc dot gnu.org
2014-09-01 13:35 ` rguenther at suse dot de
2014-09-01 13:37 ` ro at gcc dot gnu.org
2014-09-01 14:11 ` rguenth at gcc dot gnu.org
2014-09-01 14:29 ` ro at CeBiTec dot Uni-Bielefeld.DE
2014-09-01 14:41 ` rguenther at suse dot de
2014-09-02 11:08 ` ro at gcc dot gnu.org
2014-09-02 11:08 ` ro at gcc dot gnu.org
2014-09-02 11:12 ` ro at CeBiTec dot Uni-Bielefeld.DE
2014-09-02 12:11 ` rguenth at gcc dot gnu.org
2014-09-02 12:17 ` rguenth at gcc dot gnu.org
2015-04-28  8:31 ` rguenth at gcc dot gnu.org
2015-04-28  8:32 ` rguenth at gcc dot gnu.org
2015-05-04 14:43 ` ro at gcc dot gnu.org
2015-05-04 14:44 ` ro at gcc dot gnu.org
2015-05-06  6:47 ` rguenth at gcc dot gnu.org
2015-05-06  6:48 ` rguenth at gcc dot gnu.org
2015-05-06  6:48 ` rguenth at gcc dot gnu.org
2015-05-06 11:31 ` ro at gcc dot gnu.org
2015-05-06 12:18 ` rguenther at suse dot de
2015-05-06 12:21 ` rguenth at gcc dot gnu.org
2024-02-28 14:59 ` ro at gcc dot gnu.org
2024-02-28 15:01 ` ro at gcc dot gnu.org
2024-03-15 21:27 ` anlauf at gcc dot gnu.org
2024-03-15 21:41 ` [Bug tree-optimization/62283] " pinskia 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-62283-4-RhOtJrLNb7@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).