public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "spop at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/42637] [4.5 Regression][graphite] wrong code for -floop-interchange -ftree-loop-distribution
Date: Fri, 15 Jan 2010 01:20:00 -0000	[thread overview]
Message-ID: <20100115012009.28609.qmail@sourceware.org> (raw)
In-Reply-To: <bug-42637-4503@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from spop at gcc dot gnu dot org  2010-01-15 01:20 -------
The problem here is that the loop invariant motion moves rt(i,j) into
a temporary outside the innermost loop:

   real*8 rt(6,6),r(6,6),rtt(6,6)
      do i=1,6
        do j=1,6
          t = rt(i,j)
          do ia=1,6
            rtt(i,ia)=t*r(j,ia)+rtt(i,ia)
          end do
        end do
      end do

and then we get the cleanup before graphite translating this into an
array:

      do i=1,6
        do j=1,6
          cross_bb[0] = rt(i,j)
          do ia=1,6
            rtt(i,ia)=cross_bb[0]*r(j,ia)+rtt(i,ia)
          end do
        end do
      end do

Then the loop interchange would ask for loop distribution when it
considers the loops 'j' and 'ia', and from the original LST we get:

original_lst (
(root
  0 (loop
    0 (loop
      0 stmt_4
      1 (loop
        0 stmt_5)))))

transformed_lst (
(root
  0 (loop 1
    0 (loop 2
      0 stmt_4)
    1 (loop 3
      0 (loop 4
        0 stmt_5)))))

that is then validated as "legal" by the graphite_legal_transform.

The problem seems to be in the build_lexicographically_gt_constraint
that does not add the information "first instance of stmt_5 is
executed after the last instance of stmt_4 in loop 2".

We would have then a write into cross_bb[0] for all the iterations of
loop 2:

cross_bb[0] = rt(i,0)
cross_bb[0] = rt(i,1)
cross_bb[0] = rt(i,2)
cross_bb[0] = rt(i,3)
cross_bb[0] = rt(i,4)
cross_bb[0] = rt(i,5)

and then only we would read the value of cross_bb[0] in stmt_5:

= cross_bb[0] * ...
= cross_bb[0] * ...
= cross_bb[0] * ...
= cross_bb[0] * ...
= cross_bb[0] * ...
= cross_bb[0] * ...

In the original program we would have had these writes and reads
interleaved like this:

cross_bb[0] = rt(i,0)
= cross_bb[0] * ...
cross_bb[0] = rt(i,1)
= cross_bb[0] * ...
cross_bb[0] = rt(i,2)
= cross_bb[0] * ...
cross_bb[0] = rt(i,3)
= cross_bb[0] * ...
cross_bb[0] = rt(i,4)
= cross_bb[0] * ...
cross_bb[0] = rt(i,5)
= cross_bb[0] * ...

Konrad could you have a look at build_lexicographically_gt_constraint?

Thanks,
Sebastian


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42637


  parent reply	other threads:[~2010-01-15  1:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06 18:25 [Bug tree-optimization/42637] New: " janis at gcc dot gnu dot org
2010-01-06 18:27 ` [Bug tree-optimization/42637] " janis at gcc dot gnu dot org
2010-01-06 19:02 ` [Bug tree-optimization/42637] [4.5 Regression][graphite] " rguenth at gcc dot gnu dot org
2010-01-06 19:19 ` dominiq at lps dot ens dot fr
2010-01-07 14:54 ` rguenth at gcc dot gnu dot org
2010-01-14  8:41 ` spop at gcc dot gnu dot org
2010-01-15  1:20 ` spop at gcc dot gnu dot org [this message]
2010-01-16 22:17 ` spop at gcc dot gnu dot org
2010-01-16 22:31 ` spop at gcc dot gnu dot org
2010-02-06  7:14 ` spop at gcc dot gnu dot org
2010-02-06 16:33 ` spop at gcc dot gnu dot org
2010-02-06 16:44 ` spop at gcc dot gnu dot org
2010-02-06 17:42 ` spop at gcc dot gnu dot org
2010-02-06 17:42 ` spop at gcc dot gnu dot org

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=20100115012009.28609.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).