llvm-6502/lib
Chris Lattner b6bac51351 * Make the previous patch more efficient by not allocating a temporary MachineInstr
to do analysis.

*** FOLD getelementptr instructions into loads and stores when possible,
    making use of some of the crazy X86 addressing modes.

For example, the following C++ program fragment:

struct complex {
    double re, im;
    complex(double r, double i) : re(r), im(i) {}
};
inline complex operator+(const complex& a, const complex& b) {
    return complex(a.re+b.re, a.im+b.im);
}
complex addone(const complex& arg) {
    return arg + complex(1,0);
}

Used to be compiled to:
_Z6addoneRK7complex:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %ECX, DWORD PTR [%ESP + 8]
***     mov %EDX, %ECX
        fld QWORD PTR [%EDX]
        fld1
        faddp %ST(1)
***     add %ECX, 8
        fld QWORD PTR [%ECX]
        fldz
        faddp %ST(1)
***     mov %ECX, %EAX
        fxch %ST(1)
        fstp QWORD PTR [%ECX]
***     add %EAX, 8
        fstp QWORD PTR [%EAX]
        ret

Now it is compiled to:
_Z6addoneRK7complex:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %ECX, DWORD PTR [%ESP + 8]
        fld QWORD PTR [%ECX]
        fld1
        faddp %ST(1)
        fld QWORD PTR [%ECX + 8]
        fldz
        faddp %ST(1)
        fxch %ST(1)
        fstp QWORD PTR [%EAX]
        fstp QWORD PTR [%EAX + 8]
        ret

Other programs should see similar improvements, across the board.  Note that
in addition to reducing instruction count, this also reduces register pressure
a lot, always a good thing on X86.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11819 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-25 06:13:04 +00:00
..
Analysis Add support for 'rename' 2004-02-24 22:17:00 +00:00
Archive
AsmParser
Bytecode Adjustments to support the new ConstantAggregateZero class 2004-02-15 05:55:15 +00:00
CodeGen FunctionLiveVarInfo.h moved: include/llvm/CodeGen -> lib/Target/Sparc/LiveVar 2004-02-24 19:46:00 +00:00
Debugger
ExecutionEngine Make the JIT zero out globals with memset instead of an element at a time. This 2004-02-15 05:54:06 +00:00
Linker Include Config/config.h for SHLIBEXT. 2004-02-23 22:42:51 +00:00
Support `cat' is usually in /bin, not /usr/bin, at least on our systems. 2004-02-21 21:51:41 +00:00
Target * Make the previous patch more efficient by not allocating a temporary MachineInstr 2004-02-25 06:13:04 +00:00
Transforms Fix a faulty optimization on FP values 2004-02-24 18:10:14 +00:00
VMCore Make the verifier a little more explicit about this problem. 2004-02-24 22:06:07 +00:00
Makefile