From: "Fu, Chao-Ying" <fu@mips.com>
To: "Mark Mitchell" <mark@codesourcery.com>
Cc: <gcc-patches@gcc.gnu.org>, "Thekkath, Radhika" <radhika@mips.com>,
"Stephens, Nigel" <nigel@mips.com>
Subject: RE: [ping][patch] Fixed-point patch 2/10
Date: Mon, 06 Aug 2007 17:35:00 -0000 [thread overview]
Message-ID: <3CB54817FDF733459B230DD27C690CEC03EE8EFD@Exchange.mips.com> (raw)
In-Reply-To: <46B69A83.4070301@codesourcery.com>
Mark Mitchell wrote:
>
> Fu, Chao-Ying wrote:
>
> > gcc/ChangeLog
> > 2007-08-01 Chao-ying Fu <fu@mips.com>
> >
> > * fixed-value.h: New file.
> > * fixed-value.c: New file.
> > * Makefile.in (OBJS-common): Add fixed-value.o.
> > (fixed-value.o): New rule.
> > (GTFILES): Add fixed-value.h.
> > * double-int.c (double_int_scmp): Use casts of
> unsigned HOST_WIDE_INT
> > to compare a.low and b.low.
> > * gengtype.c (main): Handle FIXED_VALUE_TYPE type
> as scalar typedef.
>
> This is OK -- except that I do not understand the change to
> double_int_scmp. That function explicitly assumes that the double int
> is signed, as opposed to double_int_ucmp, which assumes that it is
> unsigned. Please explain.
I think the sign bit is in the "high" part, so we need to
compare the "low" part as unsigned for "double_int_scmp".
Ex 1: If A.high and B.high are 0, A and B are positive numbers.
Then, when we compare A.low and B.low, we should use unsigned compare.
A.high = 0 and A.low = 0x8000000000000000
B.high = 0 and B.low = 0x0000000000000001
=> A > B,
because A.high == B.high and
(unsigned HOST_WIDE_INT) a.low > (unsigned HOST_WIDE_INT) b.low
Ex 2: (A and B are negative. )
A.high = 0xffffffffffffffff and A.low = 0x8000000000000000
B.high = 0xffffffffffffffff and B.low = 0x0000000000000001
=> A > B,
because A.high == B.high and
(unsigned HOST_WIDE_INT) a.low > (unsigned HOST_WIDE_INT) b.low
Thanks!
Regards,
Chao-ying
next prev parent reply other threads:[~2007-08-06 17:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-01 23:24 Fu, Chao-Ying
2007-08-06 3:50 ` Mark Mitchell
2007-08-06 17:35 ` Fu, Chao-Ying [this message]
2007-08-06 18:08 ` Mark Mitchell
2007-08-06 19:17 ` Nigel Stephens
2007-08-06 19:56 ` Mark Mitchell
2007-08-06 22:04 ` Fu, Chao-Ying
2007-08-06 23:20 ` Fu, Chao-Ying
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=3CB54817FDF733459B230DD27C690CEC03EE8EFD@Exchange.mips.com \
--to=fu@mips.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mark@codesourcery.com \
--cc=nigel@mips.com \
--cc=radhika@mips.com \
/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).