From: David Given <dg@cowlark.com>
To: linux-sparse@vger.kernel.org
Subject: Odd behaviour with OP_SCAST
Date: Sat, 06 Sep 2008 22:14:36 +0100 [thread overview]
Message-ID: <48C2F2BC.9030606@cowlark.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1557 bytes --]
test-unssa.c compiles this:
extern void func(int i, ...);
void foo(int i) { func(0, (float) i, (double) i, i); }
...into this:
fpcast.64 %r3 <- (32) %arg1
scast.64 %r5 <- (32) %arg1
call func, $0, %r3, %r5, %arg1
ret
That's with the default settings. Unfortunately, with Clue,
sizeof(double) == sizeof(int), so that second instruction comes out as:
scast.32 %r5 <- (32) %arg1
This then causes the simplification code in simplify_cast() to discard it:
if (size == orig_size) {
int op = (orig_type->ctype.modifiers & MOD_SIGNED) ? OP_SCAST : OP_CAST;
if (insn->opcode == op)
goto simplify;
}
The end result is that my call statement turns into:
call func, $0, %r3, %arg1, %arg1
...which is wrong.
I assume that Clue's odd configuration is violating some assumption
somewhere, but I'm not well-enough versed with the sparse internals to
know where. It does seem odd to me that it's generating an OP_SCAST to
convert the int to a double, rather than an OP_FPCAST like in the float.
In the mean time, I've commented out the quoted stanza from
simplify_cast() on my setup, which makes things work, but that's not
really very pleasant.
Can anyone shed light on what might be happening here? Could this be a
symptom of some more serious underlying bug?
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "All power corrupts, but we need electricity." --- Diana Wynne Jones,
│ _Archer's Goon_
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
next reply other threads:[~2008-09-06 21:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-06 21:14 David Given [this message]
2008-09-08 21:02 ` Odd behaviour with OP_SCAST Chris Li
2008-09-10 20:48 ` David Given
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=48C2F2BC.9030606@cowlark.com \
--to=dg@cowlark.com \
--cc=linux-sparse@vger.kernel.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 NNTP newsgroup(s).