public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: optimization/6883: Fails to optimize temporary objects. Date: Sun, 11 May 2003 11:16:00 -0000 [thread overview] Message-ID: <20030511111601.30247.qmail@sources.redhat.com> (raw) The following reply was made to PR optimization/6883; it has been noted by GNATS. From: Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> To: Dara Hazeghi <dhazeghi@yahoo.com> Cc: gcc-gnats@gcc.gnu.org, <rguenth@tat.physik.uni-tuebingen.de> Subject: Re: optimization/6883: Fails to optimize temporary objects. Date: Sun, 11 May 2003 13:13:57 +0200 (CEST) On Sat, 10 May 2003, Dara Hazeghi wrote: > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- > trail&database=gcc&pr=6883 > > Hello, > > this bug was reported against gcc 3.1. Would it be possible to test > your testcase against a more current version of gcc (ie 3.2.3 or 3.3 > prerelease) and report back on the results? Thanks, The problem is the same with g++-3.3 (GCC) 3.3 20030505 (prerelease) the first loop body now gets .L6: movl $1, -104(%ebp) movl -80(%ebp), %eax # <variable>.m_i, <anonymous> movl %esi, -100(%ebp) movl $1, -120(%ebp) leal -1(%eax), %edx movl %esi, -116(%ebp) leal 0(,%eax,8), %ecx incl %eax fldl (%ebx,%eax,8) cmpl %esi, %eax faddl (%ebx,%edx,8) movl %edx, -96(%ebp) # it.m_i movl -140(%ebp), %edx fmull (%ecx,%edi) movl %eax, -112(%ebp) # it.m_i movl %eax, -80(%ebp) # <variable>.m_i fstpl (%ecx,%edx) jle .L6 while the second, manually optimized, version results in the lot better .L23: movl -128(%ebp), %eax # <variable>.m_i, <anonymous> leal 1(%eax), %edx leal 0(,%eax,8), %ecx fldl (%ebx,%edx,8) cmpl %esi, %edx faddl -8(%ebx,%eax,8) movl -140(%ebp), %eax movl %edx, -128(%ebp) # <variable>.m_i fmull (%ecx,%edi) fstpl (%ecx,%eax) jle .L23 Of course this is still not optimal, as the loop iterator itself can be optimized away and turned into a completely int-driven loop (add a operator()(int) to Array class and use int i = 1; do { a(i) = (b(i-1)+b(i+1))*c(i); } while (++i <= 254); to iterate gives .L37: fldl 8(%ebx,%edx) incl %eax # i faddl -8(%ebx,%edx) fmull (%edi,%edx) fstpl (%esi,%edx) addl $8, %edx cmpl $254, %eax # i jle .L37 which seems nearly optimal here (one might use a byte for the loop counter here, or unify it with the array offset %edx). g++-3.4 (GCC) 3.4 20030505 (experimental) for the third and the second case is the same (for the second case it is able to hoist one more movl out of the loop). For the first, inadequately optimized version it does slightly better than 3.3, probably due to the new loop optimizer: .L6: movl -80(%ebp), %eax # <variable>.m_i, <anonymous> leal 0(,%eax,8), %edx #, tmp88 leal -1(%eax), %ecx #, tmp98 movl %ecx, -112(%ebp) # tmp98, it.m_i incl %eax # tmp116 cmpl $254, %eax #, tmp116 fldl (%ebx,%eax,8) #* <anonymous> faddl (%ebx,%ecx,8) #* <anonymous> movl %eax, -144(%ebp) # tmp116, it.m_i movl %eax, -80(%ebp) # tmp116, <variable>.m_i fmull (%edx,%edi) # fstpl (%edx,%esi) # jle .L6 #, but this is still far away from the optimal and the manually optimized version. I.e. it still doesnt avoid creating the temporary iterator object to hold i-1/i+1. So after all, while its getting better, its still not anywhere near to satisfactory. Richard.
next reply other threads:[~2003-05-11 11:16 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-05-11 11:16 Richard Guenther [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-05-11 12:06 Richard Guenther 2003-05-10 23:36 Dara Hazeghi 2002-05-31 3:46 rguenth
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=20030511111601.30247.qmail@sources.redhat.com \ --to=rguenth@tat.physik.uni-tuebingen.de \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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: linkBe 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).