[fixed-point] Patch for c_common_type and type_for_mode
Fu, Chao-Ying
fu@mips.com
Wed Apr 11 00:38:00 GMT 2007
Hi,
This patch fixed c_common_type to follow the sign of the fixed-point type,
if the other one has an integer type, in order to match the spec:
"Clause 6.3.1.8 - Usual arithmetic conversions, after the conversion rule
for conversion to float
Otherwise, if one operand has fixed-point type and the other operand
has integer type, then no conversions are needed; the result type shall
be the fixed-point type."
Having this change may cause wrong comparison when mixing unsigned
fixed-point type and signed integer type. This issue can be caught
by using "-Wsign-compare".
Ex: (bug59.c)
int test(unsigned _Fract a, int b)
{
return a > b;
}
gcc -S bug59.c -Wsign-compare
bug59.c:3: warning: comparison between signed and unsigned
And, this patch fixed two cases of "lang_hooks.types.type_for_mode()"
to pass the saturating flag as the 2nd parameter for fixed-point types.
Thanks!
Regards,
Chao-ying
2007-04-10 Chao-ying Fu <fu@mips.com>
* fold-const.c (make_range): For fixed-point modes, we need to pass the
saturating flag as the 2nd parameter.
* c-typeck.c (c_common_type): Follow the sign of the fixed-point type,
if the other one has an integer type.
* tree-vect-generic.c (type_for_widest_vector_mode): Add one parameter
for the saturating flag. Pass it to type_for_mode for fixed-point
types.
(expand_vector_operations_1): Pass the saturating flag to
type_for_widest_vector_mode.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc.diff
Type: application/octet-stream
Size: 3380 bytes
Desc: gcc.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070411/867c683c/attachment.obj>
More information about the Gcc-patches
mailing list