From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3796 invoked by alias); 2 Apr 2012 16:12:13 -0000 Received: (qmail 3663 invoked by uid 22791); 2 Apr 2012 16:12:10 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Apr 2012 16:11:58 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/52835] [4.7/4.8 Regression] -O3 wrongly optimizes loop __builtin_memcpy away Date: Mon, 02 Apr 2012 16:12:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: major X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.1 X-Bugzilla-Changed-Fields: Status Keywords Last reconfirmed Component CC Ever Confirmed Summary Target Milestone Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00109.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52835 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Keywords| |wrong-code Last reconfirmed| |2012-04-02 Component|fortran |middle-end CC| |burnus at gcc dot gnu.org Ever Confirmed|0 |1 Summary|Incorrect code generated by |[4.7/4.8 Regression] -O3 |gfortran 4.7.0 |wrongly optimizes loop | |__builtin_memcpy away Target Milestone|--- |4.7.1 --- Comment #1 from Tobias Burnus 2012-04-02 16= :11:37 UTC --- Confirmed - and smells rather like a middle-end issue. (Or a rather convolu= ted FE declaration bug.) Works with my 2011-12-24-r182676 build Fails with my 2012-02-28-r184613 build (Note: Those contained some patches, which shouldn't=E2=84=A2 affect the re= sult.) * * * Works with: gfortran -fdump-tree-optimized -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -finline-functi= ons -fipa-cp-clone -O2 (And fails with -O3 and the -fno-* version of those flags.) Thus, none of t= he specific flags which get enabled with -O3 seems too blame. * * * Looking at the optimized dump, the loop DO IS=3D1,MS ISU(IS)=3D0 ZSPM(IS)=3D' ' RSV(IS) =3D0.0 ENDDO gets replaced by: __builtin_memset (D.1976_27, 0, 12); __builtin_memset (D.1956_11, 0, 12); That's almost fine, however, the ZSPM(is) =3D ' ' is lacking. With -O2 one finds in the loop: __builtin_memcpy (D.2078_113, &" "[0], 8); Note that ZSPM is an array of size 3 of character strings of length 8: character(len=3D8) :: ZSPM(MS) where "MS" is 3. The best (optimized) version would be something like "memset(ZSPM, " ", 3*8= );". In 4.6, one had (with -O3) and expanded loop with the following for [0], [1] and [2]: D.1697_89 =3D &MEM[(character(kind=3D1)[0:D.1598][1:8] *)D.1577_23][0]; __builtin_memcpy (D.1697_89, &" "[0], 8);