llvm-6502/lib
Chris Lattner 56a31c69c8 Rewrite support for cast uint -> FP. In particular, we used to compile this:
double %test(uint %X) {
        %tmp.1 = cast uint %X to double         ; <double> [#uses=1]
        ret double %tmp.1
}

into:

test:
        sub %ESP, 8
        mov %EAX, DWORD PTR [%ESP + 12]
        mov %ECX, 0
        mov DWORD PTR [%ESP], %EAX
        mov DWORD PTR [%ESP + 4], %ECX
        fild QWORD PTR [%ESP]
        add %ESP, 8
        ret

... which basically zero extends to 8 bytes, then does an fild for an
8-byte signed int.

Now we generate this:


test:
        sub %ESP, 4
        mov %EAX, DWORD PTR [%ESP + 8]
        mov DWORD PTR [%ESP], %EAX
        fild DWORD PTR [%ESP]
        shr %EAX, 31
        fadd DWORD PTR [.CPItest_0 + 4*%EAX]
        add %ESP, 4
        ret

        .section .rodata
        .align  4
.CPItest_0:
        .quad   5728578726015270912

This does a 32-bit signed integer load, then adds in an offset if the sign
bit of the integer was set.

It turns out that this is substantially faster than the preceeding sequence.
Consider this testcase:

unsigned a[2]={1,2};
volatile double G;

void main() {
    int i;
    for (i=0; i<100000000; ++i )
        G += a[i&1];
}

On zion (a P4 Xeon, 3Ghz), this patch speeds up the testcase from 2.140s
to 0.94s.

On apoc, an athlon MP 2100+, this patch speeds up the testcase from 1.72s
to 1.34s.

Note that the program takes 2.5s/1.97s on zion/apoc with GCC 3.3 -O3
-fomit-frame-pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17083 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-17 08:01:28 +00:00
..
Analysis Add support for unreachable 2004-10-16 18:21:33 +00:00
Archive Changes For Bug 352 2004-09-01 22:55:40 +00:00
AsmParser Parse undef and unreachable 2004-10-16 18:17:13 +00:00
Bytecode Do not erroneously accept revision 6 bytecode files when the format hasn't 2004-10-16 18:56:02 +00:00
CodeGen Add support for undef 2004-10-16 18:19:26 +00:00
Debugger Update to reflect changes in Makefile rules. 2004-10-13 11:46:52 +00:00
ExecutionEngine Add support for unreachable 2004-10-16 18:21:33 +00:00
Linker Add support for undef and unreachable 2004-10-16 18:08:06 +00:00
Support Update to reflect changes in Makefile rules. 2004-10-13 11:46:52 +00:00
System Allow this file to compile on Darwin. 2004-10-14 03:33:25 +00:00
Target Rewrite support for cast uint -> FP. In particular, we used to compile this: 2004-10-17 08:01:28 +00:00
Transforms Fix a type violation 2004-10-16 23:28:04 +00:00
VMCore Fix constant folding relational operators with undef operands. 2004-10-17 04:01:51 +00:00
Makefile Wrap long line 2004-09-15 01:34:42 +00:00
Makefile.am Update to reflect changes in Makefile rules. 2004-10-13 11:46:52 +00:00