xlc_dbl_u32.c revision 9bea4c13fca0e3bb4b719dcb3ed63d47d479294e
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 9extern unsigned int xlc_double_to_u32 ( double ); 10asm("\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"\n" 41" .section \".rodata\",\"a\"\n" 42" .align 3\n" 43" .type .const_dr,@object\n" 44" .size .const_dr,20\n" 45".const_dr:\n" 46" .long 0x59804000\n" 47" .long 0x49424d20\n" 48" .long 0x3fe66666\n" 49" .long 0x66666666\n" 50" .long 0x25640a00\n" 51); 52 53int main (int argc, char** argv) 54{ 55 unsigned int r = xlc_double_to_u32 ( 0.7 ); 56 if (r == 0) 57 printf("pass\n"); 58 else 59 printf("fail\n"); 60 61 return 0; 62} 63