llvm-6502/lib/Target
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
..
CBackend Fix some unexpected fallout from the config.h changes. Because the CBE no 2004-02-24 18:34:10 +00:00
PowerPC Add back machine code deleter pass until we get a MachineCode pass 2004-02-15 00:03:15 +00:00
SparcV9 FunctionLiveVarInfo.h moved: include/llvm/CodeGen -> lib/Target/Sparc/LiveVar 2004-02-24 19:46:00 +00:00
X86 * Make the previous patch more efficient by not allocating a temporary MachineInstr 2004-02-25 06:13:04 +00:00
Makefile CBackend now lives here 2004-02-13 23:29:20 +00:00
MRegisterInfo.cpp Put all LLVM code into the llvm namespace, as per bug 109. 2003-11-11 22:41:34 +00:00
Target.td Expose the "Other" value type to tablegen targets 2004-02-11 03:08:45 +00:00
TargetData.cpp Adjust to the changed StructType interface. In particular, getElementTypes() is gone. 2004-02-09 04:37:31 +00:00
TargetInstrInfo.cpp Make this assertion more self-explanatory. 2004-01-15 18:15:58 +00:00
TargetMachine.cpp Clean up a lot of the code I added yesterday by exposing the IntrinsicLowering 2003-12-28 21:23:38 +00:00
TargetSchedInfo.cpp Put all LLVM code into the llvm namespace, as per bug 109. 2003-11-11 22:41:34 +00:00