From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org
Subject: Re: Odd bug from Stack Overflow
Date: Sun, 18 Mar 2018 16:03:00 -0000 [thread overview]
Message-ID: <20180318160323.GA86124@troutmask.apl.washington.edu> (raw)
In-Reply-To: <20180318153958.GB85774@troutmask.apl.washington.edu>
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
next prev parent reply other threads:[~2018-03-18 16:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-18 15:40 Steve Kargl
2018-03-18 16:03 ` Steve Kargl [this message]
2018-03-18 17:12 ` Thomas König
2018-03-18 17:19 ` Steve Kargl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180318160323.GA86124@troutmask.apl.washington.edu \
--to=sgk@troutmask.apl.washington.edu \
--cc=fortran@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).