public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107254] New: Wrong vectorizer code (GCC 11 only, Fortran)
@ 2022-10-13 16:28 bartoldeman at users dot sourceforge.net
  2022-10-13 16:31 ` [Bug tree-optimization/107254] [11 Regression] " pinskia at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: bartoldeman at users dot sourceforge.net @ 2022-10-13 16:28 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-01-24 15:23 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

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).