From: tlaronde@polynum.com
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] BUG!!! in Plan9 compiler!
Date: Thu, 22 Apr 2010 17:29:53 +0200 [thread overview]
Message-ID: <20100422152953.GA616@polynum.com> (raw)
So I have finally narrow down and compare the calculus under
NetBSD/i386/gcc and Plan9/i386/ken-cc. And this has nothing to do with
div versus shift...
ken-cc is at fault here and it seems deep; it has apparently to deal
with registerization.
Data:
Under NetBSD/gcc, I have the following values:
before: x1:=5440, x2:=-5843, x3:=78909
after: x1:=5440, x2:=-201, x3:=18166, r:=6827 t:=30232
Under Plan9/gcc, I have the following values:
before: x1:=5440, x2:=-5843, x3:=78909
after: x1:=5440, x2:=2147483447, x3:=1073759990, r:=6827 t:=-1073711592
Uhm... seems to have a `slight' divergence...
In fact, all wrong values depend upon x2, that has the "correct"
value... with 2^31 complement. A positive when it should be negative,
since the offending code is the following:
x2 = half ( x1 + x2 + xicorr ) ;
that is :
x2 = (5440 - 5843 + 1) / 2;
Not exactly pushing things to the limit! And yes, the expected result is
indeed -201.
In fact, if you just extract this kind of expression, and compile a
test, there is no problem.
But the calling function is teratologic: it has 10 parameters and 18
automatic variables.
Since the problem arises in this context, but not if you just add
this isolated in a test program, and call it with these very 3
values (5440, -5843, 1), it is clear that's the way the computation
is handled with huge number of parameters and auto variables
that wreaks havoc.
If I declare all the auto volatile, this does nothing: same result.
If I do the addition, and afterwards take the half, that works:
x2 += x1 + xicorr;
x2 = half(x2); /* works! */
Problem: this is not a solution, but a hack, since this kind of 3
variables handling is common. This one fails. And the others?
Is there a limit about the number of parameters?
--
Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
next reply other threads:[~2010-04-22 15:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 15:29 tlaronde [this message]
2010-04-22 17:03 ` Bakul Shah
2010-04-22 17:36 ` tlaronde
2010-04-22 17:50 ` tlaronde
2010-04-22 19:08 ` geoff
2010-04-22 19:32 ` tlaronde
2010-04-22 20:07 ` Bakul Shah
2010-04-22 21:15 ` tlaronde
2010-04-22 21:26 ` tlaronde
2010-04-22 22:49 ` Bakul Shah
2010-04-23 7:42 ` tlaronde
2010-04-23 18:53 ` C H Forsyth
2010-04-23 18:51 ` tlaronde
2010-04-23 20:08 ` Bakul Shah
2010-04-23 20:46 ` ron minnich
2010-04-23 21:44 ` erik quanstrom
2010-04-23 22:34 ` erik quanstrom
2010-04-24 18:59 ` Bakul Shah
2010-04-24 21:47 ` Charles Forsyth
2010-04-25 0:31 ` erik quanstrom
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=20100422152953.GA616@polynum.com \
--to=tlaronde@polynum.com \
--cc=9fans@9fans.net \
/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 NNTP newsgroup(s).