this repo has no description
at fixPythonPipStalling 73 lines 1.2 kB view raw
1/* double trunc( double ) 2 * 3 * Reimplemented by Steve Canon, based on Ian Ollmann's implementations 4 * tuned for increased performance on in-order machines (but faster on 5 * out-of-order machines as well). 6 * 7 * Copyright 2009, Apple Inc. 8 */ 9 10#ifdef __i386__ 11 12#ifdef __SSE3__ 13#define TRUNCATE \ 14 fisttpll 4(%esp); \ 15 fildll 4(%esp) 16#else 17#define TRUNCATE \ 18 fnstcw 4(%esp); \ 19 movw 4(%esp), %dx; \ 20 orw $0xc00, 4(%esp); \ 21 fldcw 4(%esp); \ 22 frndint; \ 23 movw %dx, 4(%esp); \ 24 fldcw 4(%esp) 25#endif 26 27.text 28.align 4 29.globl _trunc 30_trunc: 31 movl 8(%esp), %ecx 32 cmpl $0x43300000, %ecx 33 fldl 4(%esp) 34 jae 2f 35 36 TRUNCATE 371: ret 38 392: andl $0x7fffffff, %ecx 40 cmpl $0x43300000, %ecx 41 jge 3f 42 43 fabs 44 TRUNCATE 45 fchs 463: ret 47 48#else //x86_64 49 50.const 51.align 4 52one: .quad 0x3ff0000000000000 53absmask:.quad 0x7fffffffffffffff 54half: .quad 0x3fe0000000000000 55thresh: .quad 0x4330000000000000 56 57.text 58.align 4 59.globl _trunc 60_trunc: 61 movd %xmm0, %rcx 62 andq absmask(%rip), %rcx 63 movsd absmask(%rip), %xmm2 64 cmpq thresh(%rip), %rcx 65 jae 1f 66 67 cvttsd2si %xmm0, %rax 68 andnpd %xmm0, %xmm2 // signbit(x) 69 cvtsi2sd %rax, %xmm0 // trunc(x) 70 orpd %xmm2, %xmm0 711: ret 72 73#endif