From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C6F2E3858C56; Thu, 13 Oct 2022 16:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6F2E3858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665678532; bh=NG55oRKjww4pv5mnmTQIFFJesX1AmmcLi0EWhWaeU/w=; h=From:To:Subject:Date:From; b=l1wQG/ZC10I0M9HPpt97yUCf3MR6hI/mh1FeUlvVig47WZ3+rvB142VLJQv2Y6dxf Ig7n3lajFpi6BvXmYaemNCQCvnE4q/8MUVA9P6GzjLOYz5tLMHY6vELG0tECXAM4yu lG2twp2SpE+QJWavJR84LdF4EEkZLSkhJCzLaQ1U= From: "bartoldeman at users dot sourceforge.net" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bartoldeman at users dot sourceforge.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107254 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=3D53703&action=3Dedit 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=3Dcore-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=3D107212 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=3Dcore-avx2 dhgeqz2.f90; ./a.out=20 -1.0000000000000000=20=20=20=20=20 $ gfortran -Wall -O2 dhgeqz2.f90; ./a.out=20 0.0000000000000000 subroutine dlartg( f, g, s, r ) implicit none double precision :: f, g, r, s double precision :: d, p d =3D sqrt( f*f + g*g ) p =3D 1.d0 / d if( abs( f ) > 1 ) then s =3D g*sign( p, f ) r =3D sign( d, f ) else s =3D g*sign( p, f ) r =3D 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 =3D 10d0 call dlartg( 10d0, temp2, s, tempr ) c =3D 0.9d0 s =3D 1.d0 do jc =3D 1, n temp =3D c*h( 1, jc ) + s*h( 2, jc ) h( 2, jc ) =3D -s*h( 1, jc ) + c*h( 2, jc ) h( 1, jc ) =3D temp temp2 =3D c*t( 1, jc ) + s*t( 2, jc ) ! t(2,2)=3D-s*t(1,2)+c*t(2,2)=3D-0.9*0+1*0=3D0 t( 2, jc ) =3D -s*t( 1, jc ) + c*t( 2, jc ) t( 1, jc ) =3D temp2 enddo end subroutine dhgeqz program test implicit none double precision h(2,2), t(2,2)=20=20 h =3D 0 t(1,1) =3D 1 t(2,1) =3D 0 t(1,2) =3D 0 t(2,2) =3D 0 call dhgeqz( 2, h, t ) print *,t(2,2) end program test=