public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/33780] different results between O3 and O0
Date: Thu, 18 Oct 2007 15:23:00 -0000 [thread overview]
Message-ID: <20071018152320.319.qmail@sourceware.org> (raw)
In-Reply-To: <bug-33780-6642@http.gcc.gnu.org/bugzilla/>
------- Comment #4 from dominiq at lps dot ens dot fr 2007-10-18 15:23 -------
> while we expand a constant integral power to an optimal (as of the count of
> multiplications / additions) series of multiplications and additions.
It seems the difference is coming from something else. I'll bet that with -O3
the powers are computed at compile time with some extra precision. At least it
is what I conclude from the following code:
integer :: ia(16) = (/ 1, 1, 2, 2, 3, 3, 4, 4, 6, 5, 6, 6, 10, 7, 9, 8 /)
real(8) :: a(16), b(16), c(16), d(16)
real(16) :: e(16)
real(8), parameter :: r=4.51556282882533D0
a(1) = r
a(2) = a(1)*a(1)
a(3:4) = a(2)*a(1:2)
a(5:8) = a(4)*a(1:4)
a(9:16) = a(8)*a(1:8)
b(1) = r
do i = 2, 16
b(i) = b(ia(i))*b(i-ia(i))
end do
e(1) = r
e(2) = e(1)*e(1)
e(3:4) = e(2)*e(1:2)
e(5:8) = e(4)*e(1:4)
e(9:16) = e(8)*e(1:8)
d = real(e,8)
do i=1, 16
c(i) = r**i
end do
do i=1, 16
print *, a(i)/d(i)-1.0d0, b(i)/d(i)-1.0d0, c(i)/d(i)-1.0d0
end do
print *
print *, sum(abs(a/d-1.0d0)), sum(abs(b/d-1.0d0)), sum(abs(c/d-1.0d0)),
epsilon(r)
end
a stores the powers computed from the usual shift, b those computed from the
"optimal" tree (from gcc/builtins.c, c those computed from the power, and d the
values rounded from values with higher precision. At -O2 the output is:
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.0000000000000000 0.0000000000000000
2.22044604925031308E-016 2.22044604925031308E-016 2.22044604925031308E-016
2.22044604925031308E-016 2.22044604925031308E-016 2.22044604925031308E-016
2.22044604925031308E-016 0.0000000000000000 2.22044604925031308E-016
2.22044604925031308E-016 2.22044604925031308E-016 2.22044604925031308E-016
4.44089209850062616E-016 4.44089209850062616E-016 4.44089209850062616E-016
2.22044604925031308E-016 0.0000000000000000 2.22044604925031308E-016
4.44089209850062616E-016 2.22044604925031308E-016 4.44089209850062616E-016
4.44089209850062616E-016 2.22044604925031308E-016 4.44089209850062616E-016
4.44089209850062616E-016 0.0000000000000000 4.44089209850062616E-016
4.44089209850062616E-016 4.44089209850062616E-016 4.44089209850062616E-016
4.44089209850062616E-016 2.22044604925031308E-016 4.44089209850062616E-016
6.66133814775093924E-016 0.0000000000000000 6.66133814775093924E-016
6.66133814775093924E-016 6.66133814775093924E-016 6.66133814775093924E-016
5.10702591327572009E-015 2.88657986402540701E-015 5.10702591327572009E-015
2.22044604925031308E-016
a and c are equal, while at -O3 the output is
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.0000000000000000 0.0000000000000000
2.22044604925031308E-016 2.22044604925031308E-016 0.0000000000000000
2.22044604925031308E-016 2.22044604925031308E-016 0.0000000000000000
2.22044604925031308E-016 0.0000000000000000 0.0000000000000000
2.22044604925031308E-016 2.22044604925031308E-016 0.0000000000000000
4.44089209850062616E-016 4.44089209850062616E-016 0.0000000000000000
2.22044604925031308E-016 0.0000000000000000 0.0000000000000000
4.44089209850062616E-016 2.22044604925031308E-016 0.0000000000000000
4.44089209850062616E-016 2.22044604925031308E-016 0.0000000000000000
4.44089209850062616E-016 0.0000000000000000 0.0000000000000000
4.44089209850062616E-016 4.44089209850062616E-016 0.0000000000000000
4.44089209850062616E-016 2.22044604925031308E-016 0.0000000000000000
6.66133814775093924E-016 0.0000000000000000 0.0000000000000000
6.66133814775093924E-016 6.66133814775093924E-016 0.0000000000000000
5.10702591327572009E-015 2.88657986402540701E-015 0.0000000000000000
2.22044604925031308E-016
c and d are equal. If the difference were coming only from the "optimal" tree,
c should be equal to b.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33780
next prev parent reply other threads:[~2007-10-18 15:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-15 14:49 [Bug middle-end/33780] New: " jv244 at cam dot ac dot uk
2007-10-15 15:01 ` [Bug middle-end/33780] " rguenth at gcc dot gnu dot org
2007-10-15 15:30 ` jv244 at cam dot ac dot uk
2007-10-15 15:51 ` dominiq at lps dot ens dot fr
2007-10-18 15:23 ` dominiq at lps dot ens dot fr [this message]
2008-02-05 11:09 ` rguenth at gcc dot gnu dot org
2008-02-11 11:26 ` jv244 at cam dot ac dot uk
[not found] <bug-33780-4@http.gcc.gnu.org/bugzilla/>
2024-02-16 5:15 ` pinskia at gcc dot gnu.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=20071018152320.319.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).