From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42238 invoked by alias); 18 Mar 2018 16:03:27 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 41846 invoked by uid 89); 18 Mar 2018 16:03:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=l1, s2, s3, S3 X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 18 Mar 2018 16:03:25 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id w2IG3Nje086132 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 18 Mar 2018 09:03:23 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id w2IG3NOB086131 for fortran@gcc.gnu.org; Sun, 18 Mar 2018 09:03:23 -0700 (PDT) (envelope-from sgk) Date: Sun, 18 Mar 2018 16:03:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org Subject: Re: Odd bug from Stack Overflow Message-ID: <20180318160323.GA86124@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <20180318153958.GB85774@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180318153958.GB85774@troutmask.apl.washington.edu> User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00096.txt.bz2 On Sun, Mar 18, 2018 at 08:39:58AM -0700, Steve Kargl wrote: > So, who knows how the scalarizer works? > > This code > > program test > implicit none > integer, parameter :: n = 65536 > integer, dimension(n) :: y > integer*4 :: i > y = (/ (1, i=1, n) /) > if (y(2) /= 1) stop 1 > end program test > > generates a loops that does the right thing. > > offset.1 = 0; > shadow_loopvar.2 = 1; > while (1) > { > if (shadow_loopvar.2 > 65536) goto L.1; > (*(integer(kind=4)[65536] * restrict) atmp.0.data)[offset.1] = 1; > offset.1 = offset.1 + 1; > shadow_loopvar.2 = shadow_loopvar.2 + 1; > } > L.1:; Whoops left out the copying of atmp to y. { integer(kind=4) S.3; S.3 = 0; while (1) { if (S.3 > 65535) goto L.2; y[S.3] = (*(integer(kind=4)[65536] * restrict) atmp.0.data)[S.3]; S.3 = S.3 + 1; } L.2:; } > > Clearly, 1 is being assigned to each element of the array 'y'. Now > change the type of 'y' to real. > > offset.1 = 0; > (*(real(kind=4)[65536] * restrict) atmp.0.data)[offset.1] = 1.0e+0; > offset.1 = offset.1 + 1; > { > integer(kind=4) S.2; > > S.2 = 0; > while (1) > { > if (S.2 > 65535) goto L.1; > y[S.2] = (*(real(kind=4)[65536] * restrict) atmp.0.data)[S.2]; > S.2 = S.2 + 1; > } > L.1:; > } > > The value of 1.0 is assigned to the first element of atmp, a > temporary array. Then the loop assigns the values from > temporary array 'atmp'. The problem is atmp(2:65536) have > never been set. I was expecting the -fdump-tree-original for > the integer and real codes to look substantially the same. > Something has gone sideways. Anyone have a good guess where? > > -- > Steve -- Steve 20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4 20161221 https://www.youtube.com/watch?v=IbCHE-hONow