This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [patch] Make fixed-point multiplication results consistent
- From: "Fu, Chao-Ying" <fu at mips dot com>
- To: "Mark Mitchell" <mark at codesourcery dot com>, <gcc-patches at gcc dot gnu dot org>
- Cc: "Thekkath, Radhika" <radhika at mips dot com>, "Stephens, Nigel" <nigel at mips dot com>
- Date: Mon, 17 Sep 2007 16:33:17 -0700
- Subject: RE: [patch] Make fixed-point multiplication results consistent
Mark Mitchell wrote:
>
> > Currently constant folding for fixed-point multiplications
> > is not consistent with MIPS instructions (ex: "mulq_rs.w")
> > due to rounding styles.
>
> What does the draft ISO spec for fixed-point say about this case? Is
> there a standard rounding mode, or is this like floating-point where
> there are a variety of modes?
From the spec (n1169.pdf):
Page 12:
"If the source value cannot be represented exactly by the fixed-point type,
the source value is rounded to either the closest fixed-point value greater
than the source value (rounded up) or to the closest fixed-point value less
than the source value (rounded down)."
Page 13:
"Whether rounding is up or down is implementation-defined and may differ
for different values and different situations; an implementation may
specify that the rounding is indeterminable."
So, each target can have its own rounding mode or even let the rounding
indeterminable.
>
> The reason that I'm asking is that the goal of the fixed-point code
> should not be to match the MIPS processor -- it should be to match the
> spec. At least in principle, that might not be the same
> thing in every
> case. And, if the spec allows multiple modes, then probably the
> emulation code should do so as well.
>
> I'm trying to figure out whether your change is correct as it
> stands, or
> if it needs to be conditionalized in some way.
>
We may use a target hook/macro to conditionally perform one specific
rounding mode for one target in constant folding and emulation.
Thanks!
Regards,
Chao-ying