From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8D12E3858C60; Thu, 29 Jun 2023 14:39:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D12E3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688049578; bh=z2NUsins1BbjTjChAX+MYbOxTWi9yiNzPIwYQgB2psw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BSwSX+LT+27ruhvfSb3J9ef0qlaFwd2+vyRJ1YCJT9xSoCwLvxSu02mx5Z3QgmPAr 4GOGg547I/+qQtb8WTABSmpUKNgzO10nQa4MdCb2U5vyXa5y9atMIguMLR5TAPqp0o bsGJlpcMqhdrW87tnnN5DU0ASkkooOOqV/kx7INk= From: "juergen.reuter at desy dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110311] [14 Regression] regression in tree-optimizer Date: Thu, 29 Jun 2023 14:39:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: juergen.reuter at desy dot de 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: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D110311 --- Comment #24 from J=C3=BCrgen Reuter --- Here is a first reproducer without the need for OCaml, unfortunately a bit = too big to be uploaded, here is the link: https://www.desy.de/~reuter/downloads/repro001.tar.xz the tarball contains Fortran files that compile to two binaries, ./whizard = and ./whizard_check. After compilation, perform ./whizard r1.sin=20 to run the program. There will be NaNs generated in our RNG stream random number generator. They originate from an erroneous optimization by the gcc/gfortran tree-optimizer. This code resides in rng_stream_sub.f90, in the function mult_mod. Eliminating the intrinsic function mod and explicitly do= ing the calculation makes the problem go away. function mult_mod (a, b, c, m) result (v) real(default), intent(in) :: a real(default), intent(in) :: b real(default), intent(in) :: c real(default), intent(in) :: m real(default) :: v integer :: a1 real(default) :: a2 v =3D a * b + c if (v >=3D two53 .or. v <=3D -two53) then a1 =3D int (a / two17) a2 =3D a - a1 * two17 v =3D mmm_mod (a1 * b, m) v =3D v * two17 + a2 * b + c end if v =3D mmm_mod (v, m) if (v < 0.0_default) v =3D v + m contains elemental function mmm_mod (x1, x2) result (res) real(default), intent(in) :: x1, x2 real(default) :: res res =3D x1 - int(x1/x2) * x2 end function mmm_mod end function mult_mod=