Commit Graph

14960 Commits

Author SHA1 Message Date
Chris Lattner 839abf57a6 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.

llvm-svn: 17083
2004-10-17 08:01:28 +00:00
Chris Lattner 112fd88a05 Unify handling of constant pool indexes with the other code paths, allowing
us to use index registers for CPI's

llvm-svn: 17082
2004-10-17 07:49:45 +00:00
Chris Lattner af19d396ac Give the asmprinter the ability to print memrefs with a constant pool index,
index reg and scale

llvm-svn: 17081
2004-10-17 07:16:32 +00:00
Chris Lattner 653d8663fe fold:
%X = and Y, constantint
  %Z = setcc %X, 0

instead of emitting:

        and %EAX, 3
        test %EAX, %EAX
        je .LBBfoo2_2   # UnifiedReturnBlock

We now emit:

        test %EAX, 3
        je .LBBfoo2_2   # UnifiedReturnBlock

This triggers 581 times on 176.gcc for example.

llvm-svn: 17080
2004-10-17 06:10:40 +00:00
Chris Lattner e234a21488 All of these labels are off by one now that the unreachable instruction exists
llvm-svn: 17079
2004-10-17 05:37:47 +00:00
Nate Begeman 2c873ca365 Implement bitfield insert by recognizing the following pattern:
1. optional shift left
2. and x, immX
3. and y, immY
4. or z, x, y
==> rlwimi z, x, y, shift, mask begin, mask end

where immX == ~immY and immX is a run of set bits. This transformation
fires 32 times on voronoi, once on espresso, and probably several
dozen times on external benchmarks such as gcc.

To put this in terms of actual code generated for
struct B { unsigned a : 3; unsigned b : 2; };
void storeA (struct B *b, int v) { b->a = v;}
void storeB (struct B *b, int v) { b->b = v;}

Old:
_storeA:
        rlwinm r2, r4, 0, 29, 31
        lwz r4, 0(r3)
        rlwinm r4, r4, 0, 0, 28
        or r2, r4, r2
        stw r2, 0(r3)
        blr

_storeB:
        rlwinm r2, r4, 3, 0, 28
        rlwinm r2, r2, 0, 27, 28
        lwz r4, 0(r3)
        rlwinm r4, r4, 0, 29, 26
        or r2, r2, r4
        stw r2, 0(r3)
        blr

New:
_storeA:
        lwz r2, 0(r3)
        rlwimi r2, r4, 0, 29, 31
        stw r2, 0(r3)
        blr

_storeB:
        lwz r2, 0(r3)
        rlwimi r2, r4, 3, 27, 28
        stw r2, 0(r3)
        blr

llvm-svn: 17078
2004-10-17 05:19:20 +00:00
Chris Lattner 192eaccc1a Fix constant folding relational operators with undef operands.
llvm-svn: 17077
2004-10-17 04:01:51 +00:00
Chris Lattner 0e4818c99a Reid added --version to the CommandLine lib. Don't conflict with it.
llvm-svn: 17076
2004-10-17 02:49:08 +00:00
Chris Lattner f6666db032 I forgot that sparc no longer uses the shared asmwriter. Give it support
for undef.

llvm-svn: 17075
2004-10-17 02:44:45 +00:00
Chris Lattner 37b138a00b Add support for unreachable and undef
llvm-svn: 17074
2004-10-17 02:42:42 +00:00
Reid Spencer 94ffa656eb Initial Makefile.am for building with automake
llvm-svn: 17073
2004-10-17 00:24:24 +00:00
Reid Spencer 3d99608cc4 Initial Makefile.am for building with automake.
llvm-svn: 17072
2004-10-17 00:20:42 +00:00
Reid Spencer c0ec7a65a6 Make sure that for systems where the string functions are actually macros
that we undefine the macro before using its name in the definition. This
can happen on Linux if _GNU_SOURCE is defined.

llvm-svn: 17071
2004-10-17 00:17:54 +00:00
Chris Lattner fd7bf724d3 Implement constant folding of undef values.
llvm-svn: 17070
2004-10-16 23:31:32 +00:00
Chris Lattner 67f0545daf Fix a type violation
llvm-svn: 17069
2004-10-16 23:28:04 +00:00
Nate Begeman 29dc5f2a3e Finally fix one of the oldest FIXMEs in the PowerPC backend: correctly
flag rotate left word immediate then mask insert (rlwimi) as a two-address
instruction, and update the ISel usage of the instruction accordingly.

This will allow us to properly schedule rlwimi, and use it to efficiently
codegen bitfield operations.

llvm-svn: 17068
2004-10-16 20:43:38 +00:00
Chris Lattner 684c5c6587 Kill the bogon that slipped into my buffer before I committed.
llvm-svn: 17067
2004-10-16 19:46:33 +00:00
Chris Lattner 6580e09fef Implement InstCombine/getelementptr.ll:test9, which is the source of many
ugly and giant constnat exprs in some programs.

llvm-svn: 17066
2004-10-16 19:44:59 +00:00
Chris Lattner d2c8ed1170 New testcase, rework testcases to fail if there are any gep's other than those
involving %B instead of allowing any geps except %A's.

llvm-svn: 17065
2004-10-16 19:44:23 +00:00
Misha Brukman bbd150eaa7 * Add a space between words
* Wrap at 80 cols

llvm-svn: 17064
2004-10-16 19:13:58 +00:00
Chris Lattner eba3f46b2f Do not erroneously accept revision 6 bytecode files when the format hasn't
been defined yet!

llvm-svn: 17063
2004-10-16 18:56:02 +00:00
Chris Lattner 552663387b Update release notes
llvm-svn: 17062
2004-10-16 18:35:57 +00:00
Chris Lattner 17ce82f71d New testcase
llvm-svn: 17061
2004-10-16 18:28:01 +00:00
Chris Lattner 5a02a3e963 Add support for undef and unreachable
llvm-svn: 17059
2004-10-16 18:24:35 +00:00
Chris Lattner aef20fbbb9 testcases for undefined and unreachable
llvm-svn: 17058
2004-10-16 18:24:11 +00:00
Chris Lattner fcfe78eaf8 Fix fix fix
llvm-svn: 17057
2004-10-16 18:21:50 +00:00
Chris Lattner 98e541457b Add support for unreachable
llvm-svn: 17056
2004-10-16 18:21:33 +00:00
Chris Lattner 61753bf847 Add support for undef
llvm-svn: 17055
2004-10-16 18:19:26 +00:00
Chris Lattner 770709befe Add support for undef, unreachable, and function flags
llvm-svn: 17054
2004-10-16 18:18:16 +00:00
Chris Lattner 4ff314968e Parse undef and unreachable
llvm-svn: 17053
2004-10-16 18:17:13 +00:00
Chris Lattner 2978437b76 Add support
llvm-svn: 17052
2004-10-16 18:16:19 +00:00
Chris Lattner ea9a85abe4 Add support for undef and unreachable
llvm-svn: 17051
2004-10-16 18:14:10 +00:00
Chris Lattner a3f3c8a1ad ADd support for undef and unreachable
llvm-svn: 17050
2004-10-16 18:13:47 +00:00
Chris Lattner e4bea062c7 Teach the X86 backend about unreachable and undef. Among other things, we
now compile:

'foo() {}' into "ret" instead of "mov EAX, 0; ret"

llvm-svn: 17049
2004-10-16 18:13:05 +00:00
Chris Lattner 583dfdcf86 Add support for unreachable and undef
llvm-svn: 17048
2004-10-16 18:12:13 +00:00
Chris Lattner 81a7a23494 Optimize instructions involving undef values. For example X+undef == undef.
llvm-svn: 17047
2004-10-16 18:11:37 +00:00
Chris Lattner 7e6d4a12b5 Add support for UndefValue
llvm-svn: 17046
2004-10-16 18:10:31 +00:00
Chris Lattner c0e2e82477 When promoting mem2reg, make uninitialized values become undef isntead of 0.
llvm-svn: 17045
2004-10-16 18:10:06 +00:00
Chris Lattner 646354bae1 Handle undef values as undefined on the constant lattice
ignore unreachable instructions

llvm-svn: 17044
2004-10-16 18:09:41 +00:00
Chris Lattner 6ac3ef950d Add note
llvm-svn: 17043
2004-10-16 18:09:25 +00:00
Chris Lattner 8e71c6a33d Add support for the undef value. Implement a new optimization based on globals
that are initialized with undef.  When promoting malloc to a global, start out
initialized to undef

llvm-svn: 17042
2004-10-16 18:09:00 +00:00
Chris Lattner 5e0b9f2eec Add support for undef and unreachable
llvm-svn: 17041
2004-10-16 18:08:06 +00:00
Chris Lattner d5f67d8ca6 Implement UndefValue class
llvm-svn: 17040
2004-10-16 18:07:16 +00:00
Chris Lattner 38a6969894 Add support for the unreachable instruction
llvm-svn: 17039
2004-10-16 18:06:43 +00:00
Chris Lattner bcf508cf6f Add new UndefValueVal type
llvm-svn: 17038
2004-10-16 18:06:07 +00:00
Chris Lattner 3384f9ad40 Add new UnreachableInst class
llvm-svn: 17037
2004-10-16 18:05:54 +00:00
Chris Lattner 278e1dab8e Add new unreachable instruction
llvm-svn: 17036
2004-10-16 18:05:37 +00:00
Chris Lattner 9d4d20b71c Add new UndefValue class
llvm-svn: 17035
2004-10-16 18:05:25 +00:00
Chris Lattner d57b37d1fa UndefValue's are constants
llvm-svn: 17034
2004-10-16 18:05:10 +00:00
Chris Lattner 08b7d5b032 Document unreachable instruction
llvm-svn: 17033
2004-10-16 18:04:13 +00:00