llvm-6502/lib/Target/X86
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
..
.cvsignore Tell CVS to ignore all .inc files 2003-08-03 15:50:17 +00:00
Makefile Add support for the -x86-asm-syntax flag, which can be used to choose between 2004-10-03 20:36:57 +00:00
Makefile.am Update to reflect changes in Makefile rules. 2004-10-13 11:46:52 +00:00
X86.h Add -sse[,2,3] arguments to LLC 2004-08-24 08:18:44 +00:00
X86.td Add support for the -x86-asm-syntax flag, which can be used to choose between 2004-10-03 20:36:57 +00:00
X86AsmPrinter.cpp Give the asmprinter the ability to print memrefs with a constant pool index, 2004-10-17 07:16:32 +00:00
X86CodeEmitter.cpp Unify handling of constant pool indexes with the other code paths, allowing 2004-10-17 07:49:45 +00:00
X86FloatingPoint.cpp Changes For Bug 352 2004-09-01 22:55:40 +00:00
X86InstrBuilder.h Allow X86 addressing modes to represent globals with offsets. Patch contributed 2004-10-15 04:43:20 +00:00
X86InstrInfo.cpp Fix a warning 2004-08-01 19:31:30 +00:00
X86InstrInfo.h Remove a bunch of ad-hoc target-specific flags that were only used by the 2004-08-11 07:12:04 +00:00
X86InstrInfo.td Remove debugging code, fix encoding problem. This fixes the problems 2004-10-06 14:31:50 +00:00
X86ISelPattern.cpp Disable the pattern isel 2004-08-15 23:02:17 +00:00
X86ISelSimple.cpp Rewrite support for cast uint -> FP. In particular, we used to compile this: 2004-10-17 08:01:28 +00:00
X86JITInfo.h Clean up a lot of the code I added yesterday by exposing the IntrinsicLowering 2003-12-28 21:23:38 +00:00
X86PeepholeOpt.cpp Add some new instructions. Fix the asm string for sbb32rr 2004-10-06 04:01:02 +00:00
X86RegisterInfo.cpp Add some new instructions. Fix the asm string for sbb32rr 2004-10-06 04:01:02 +00:00
X86RegisterInfo.h Code insertion methods now return void instead of an int. 2004-08-15 22:15:11 +00:00
X86RegisterInfo.td The real x87 floating point registers should not be allocatable. They 2004-09-21 21:22:11 +00:00
X86TargetMachine.cpp The person who was planning to add SSE support isn't anymore, so disable 2004-10-08 22:41:46 +00:00
X86TargetMachine.h Auto-registrate target 2004-07-11 02:48:49 +00:00