[PATCH, soft-fp]: Use mode(word) as a return type from soft-fp comparisons

Uros Bizjak ubizjak@gmail.com
Sat Jun 9 09:05:00 GMT 2007


Hello!

This patch fixes the problems exposed with the testcase below. The 
problem is, that soft-fp functions return int value, where gcc expects 
the return from soft-fp functions to be in word mode. On x86_64 target, 
word_mode equals DImode, where int equals SImode, leading to comparison 
failures for certain class of input operands.

The testcase (actually from gcc.gnu.org/PR32286):

--cut here--
void abort(void);

int test_lt(__float128 x, __float128 y)
{
return x < y;
}

int test_gt (__float128 x, __float128 y)
{
return x > y;
}

int main()
{
__float128 a = 0.0;
__float128 b = 1.0;

int r;

r = test_lt (a, b);
if (r != ((double) a < (double) b))
abort();

r = test_gt (a, b);
if (r != ((double) a > (double) b))
abort();

return 0;
--cut here--
}

This testcase aborts with current soft-fp implementation on 
x86_64-pc-linux-gnu (latest SVN gcc-4.3 is needed that includes soft-fp 
library for __float128) and passes with the patch, attached to this message.

2007-06-09  Uros Bizjak  <ubizjak@gmail.com>

        * soft-fp/soft-fp.h (CMPtype): New typedef.
        * soft-fp/eqdf2.c (__eqdf2): Use CMPtype instead of int
        as the return type.
        * soft-fp/eqsf2.c (__eqsf2): Ditto.
        * soft-fp/eqtf2.c (__eqtf2): Ditto.
        * soft-fp/gedf2.c (__gedf2): Ditto.
        * soft-fp/gesf2.c (__gesf2): Ditto.
        * soft-fp/getf2.c (__getf2): Ditto.
        * soft-fp/ledf2.c (__ledf2): Ditto.
        * soft-fp/lesf2.c (__lesf2): Ditto.
        * soft-fp/letf2.c (__letf2): Ditto.
        * soft-fp/unorddf2 (__unorddf2): Ditto.
        * soft-fp/unordsf2 (__unordsf2): Ditto.
        * soft-fp/unordtf2 (__unordtf2): Ditto.

Uros.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libc-cmptype.diff
Type: text/x-patch
Size: 8277 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20070609/588988fe/attachment.bin>


More information about the Libc-alpha mailing list