public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bartoldeman at users dot sourceforge.net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107254] New: Wrong vectorizer code (GCC 11 only, Fortran)
Date: Thu, 13 Oct 2022 16:28:49 +0000	[thread overview]
Message-ID: <bug-107254-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107254
           Summary: Wrong vectorizer code (GCC 11 only, Fortran)
           Product: gcc
           Version: 11.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bartoldeman at users dot sourceforge.net
  Target Milestone: ---

Created attachment 53703
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53703&action=edit
Test case

The following code gives the wrong result (-1.0000000000000000 instead of
0.0000000000000000) with gfortran 11.3 (also tested with the 11.3.1 20221007
prerelease) when given the options
`-O2 -ftree-vectorize -march=core-avx`
for x86_64.

There's no issue with GCC 9,10, and 12. It could be related to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107212 except that bug also
affects GCC 12.

This issue came up from testing the reference LAPACK with -ftree-vectorize
enabled, where many more tests failed with recent GCC (11/12), see
https://github.com/easybuilders/easybuild-easyconfigs/issues/16380

$ gfortran -O2 -ftree-vectorize -march=core-avx2 dhgeqz2.f90; ./a.out 
  -1.0000000000000000     
$ gfortran -Wall -O2 dhgeqz2.f90; ./a.out 
   0.0000000000000000


subroutine dlartg( f, g, s, r )
  implicit none
  double precision :: f, g, r, s
  double precision :: d, p

  d = sqrt( f*f + g*g )
  p = 1.d0 / d
  if( abs( f ) > 1 ) then
     s = g*sign( p, f )
     r = sign( d, f )
  else
     s = g*sign( p, f )
     r = sign( d, f )
  end if
end subroutine

subroutine dhgeqz( n, h, t )
  implicit none
  integer            n
  double precision   h( n, * ), t( n, * )
  integer            jc
  double precision   c, s, temp, temp2, tempr
  temp2 = 10d0
  call dlartg( 10d0, temp2, s, tempr )
  c = 0.9d0
  s = 1.d0
  do jc = 1, n
     temp = c*h( 1, jc ) + s*h( 2, jc )
     h( 2, jc ) = -s*h( 1, jc ) + c*h( 2, jc )
     h( 1, jc ) = temp
     temp2 = c*t( 1, jc ) + s*t( 2, jc )
     ! t(2,2)=-s*t(1,2)+c*t(2,2)=-0.9*0+1*0=0
     t( 2, jc ) = -s*t( 1, jc ) + c*t( 2, jc )
     t( 1, jc ) = temp2
  enddo
end subroutine dhgeqz

program test
  implicit none
  double precision h(2,2), t(2,2)  
  h = 0
  t(1,1) = 1
  t(2,1) = 0
  t(1,2) = 0
  t(2,2) = 0
  call dhgeqz( 2, h, t )
  print *,t(2,2)
end program test

             reply	other threads:[~2022-10-13 16:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 16:28 bartoldeman at users dot sourceforge.net [this message]
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 ` [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  8:52 ` 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@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).