llvm-6502/lib/Target
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
..
CBackend Add support for unreachable and undef 2004-10-16 18:12:13 +00:00
PowerPC Implement bitfield insert by recognizing the following pattern: 2004-10-17 05:19:20 +00:00
Skeleton Update to reflect changes in Makefile rules. 2004-10-13 11:46:52 +00:00
Sparc Add support for unreachable and undef 2004-10-17 02:42:42 +00:00
SparcV8 Add support for unreachable and undef 2004-10-17 02:42:42 +00:00
SparcV9 All of these labels are off by one now that the unreachable instruction exists 2004-10-17 05:37:47 +00:00
X86 Rewrite support for cast uint -> FP. In particular, we used to compile this: 2004-10-17 08:01:28 +00:00
Makefile Fix fix fix 2004-10-16 18:21:50 +00:00
Makefile.am Update to reflect changes in Makefile rules. 2004-10-13 11:46:52 +00:00
MRegisterInfo.cpp Add getAllocatableSet() function. 2004-08-26 22:21:04 +00:00
Target.td Add isLittleEndianEncoding to InstrInfo class, defaults to `off' 2004-10-14 05:53:40 +00:00
TargetData.cpp Changes For Bug 352 2004-09-01 22:55:40 +00:00
TargetFrameInfo.cpp Remove dead methods 2004-08-12 18:37:15 +00:00
TargetInstrInfo.cpp ConstantTypeMustBeLoaded has been incorporated into SparcV9PreSelection, its 2004-07-27 21:43:38 +00:00
TargetMachine.cpp Changes For Bug 352 2004-09-01 22:55:40 +00:00
TargetMachineRegistry.cpp Implement TargetRegistrationListener 2004-07-11 06:03:21 +00:00
TargetSchedInfo.cpp Since we use alloca now make sure we include the proper headers for it. 2004-09-28 02:53:15 +00:00