1
2 /* This is code generated by xlc -O3 for conversion of a double to an
3 unsigned 32-bit int, in a "floor" style. It relies on doing an
4 fadd with a non-standard rounding mode and so checks that V handles
5 the rounding mode correctly. r will be 1 if that is not so. */
6
7 #include <stdio.h>
8
9 extern unsigned int xlc_double_to_u32 ( double );
10 asm("\n"
11 ".text\n"
12 ".global xlc_double_to_u32\n"
13 ".type xlc_double_to_u32, @function\n"
14 "xlc_double_to_u32:\n"
15 " stwu %r1,-48(%r1)\n"
16 " addis %r4,%r0,.const_dr@ha\n"
17 " addis %r0,%r0,17376\n"
18 " fabs %f0,%f1\n"
19 " addi %r3,%r0,0\n"
20 " mffs %f3\n"
21 " mtfsb1 4*cr7+so\n"
22 " lfs %f2,.const_dr@l(%r4)\n"
23 " fcmpu 0,%f1,%f0\n"
24 " fadd %f0,%f0,%f2\n"
25 " mtfsf 255,%f3\n"
26 " stfd %f0,24(%r1)\n"
27 " bne- $+0x1c\n"
28 " lwz %r3,24(%r1)\n"
29 " subf %r0,%r3,%r0\n"
30 " srawi %r0,%r0,31\n"
31 " ori %r0,%r0,0x0000\n"
32 " lwz %r4,28(%r1)\n"
33 " or %r3,%r4,%r0\n"
34 " addi %r1,%r1,48\n"
35 " blr\n"
36 ".size xlc_double_to_u32, . - xlc_double_to_u32\n"
37 " .long 0\n"
38 " .long 0x00000000\n"
39 " .long 0x00000000\n"
40 ".previous\n"
41 "\n"
42 " .section \".rodata\",\"a\"\n"
43 " .align 3\n"
44 " .type .const_dr,@object\n"
45 " .size .const_dr,20\n"
46 ".const_dr:\n"
47 " .long 0x59804000\n"
48 " .long 0x49424d20\n"
49 " .long 0x3fe66666\n"
50 " .long 0x66666666\n"
51 " .long 0x25640a00\n"
52 ".previous\n"
53 );
54
main(int argc,char ** argv)55 int main (int argc, char** argv)
56 {
57 unsigned int r = xlc_double_to_u32 ( 0.7 );
58 if (r == 0)
59 printf("pass\n");
60 else
61 printf("fail\n");
62
63 return 0;
64 }
65