1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 04:52:54 +02:00
Commit Graph

198 Commits

Author SHA1 Message Date
Chris Lattner
7896144611 Minor efficiency tweak, suggested by Patrick Meredith
llvm-svn: 13341
2004-05-04 15:19:33 +00:00
Chris Lattner
eb59aec632 Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination.

llvm-svn: 13309
2004-05-01 23:27:23 +00:00
Chris Lattner
f5a5668cf6 Make sure the instruction combiner doesn't lose track of instructions
when replacing them, missing the opportunity to do simplifications

llvm-svn: 13308
2004-05-01 23:19:52 +00:00
Chris Lattner
9b53c7c797 Fix a major pessimization in the instcombiner. If an allocation instruction
is only used by a cast, and the casted type is the same size as the original
allocation, it would eliminate the cast by folding it into the allocation.

Unfortunately, it was placing the new allocation instruction right before
the cast, which could pull (for example) alloca instructions into the body
of a function.  This turns statically allocatable allocas into expensive
dynamically allocated allocas, which is bad bad bad.

This fixes the problem by placing the new allocation instruction at the same
place the old one was, duh. :)

llvm-svn: 13289
2004-04-30 04:37:52 +00:00
Chris Lattner
02c65b5395 Changes to fix up the inst_iterator to pass to boost iterator checks. This
patch was graciously contributed by Vladimir Prus.

llvm-svn: 13185
2004-04-27 15:13:33 +00:00
Chris Lattner
5bad19bde7 Instcombine X/-1 --> 0-X
llvm-svn: 13172
2004-04-26 14:01:59 +00:00
Chris Lattner
bcb690dc9b Fix a HUGE pessimization on X86. The indvars pass was taking this
(familiar) function:

int _strlen(const char *str) {
    int len = 0;
    while (*str++) len++;
    return len;
}

And transforming it to use a ulong induction variable, because the type of
the pointer index was left as a constant long.  This is obviously very bad.

The fix is to shrink long constants in getelementptr instructions to intptr_t,
making the indvars pass insert a uint induction variable, which is much more
efficient.

Here's the before code for this function:

int %_strlen(sbyte* %str) {
entry:
        %tmp.13 = load sbyte* %str              ; <sbyte> [#uses=1]
        %tmp.24 = seteq sbyte %tmp.13, 0                ; <bool> [#uses=1]
        br bool %tmp.24, label %loopexit, label %no_exit

no_exit:                ; preds = %entry, %no_exit
***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=2]
***     %indvar = phi ulong [ %indvar.next, %no_exit ], [ 0, %entry ]           ; <ulong> [#uses=2]
        %indvar1 = cast ulong %indvar to uint           ; <uint> [#uses=1]
        %inc.02.sum = add uint %indvar1, 1              ; <uint> [#uses=1]
        %inc.0.0 = getelementptr sbyte* %str, uint %inc.02.sum          ; <sbyte*> [#uses=1]
        %tmp.1 = load sbyte* %inc.0.0           ; <sbyte> [#uses=1]
        %tmp.2 = seteq sbyte %tmp.1, 0          ; <bool> [#uses=1]
        %indvar.next = add ulong %indvar, 1             ; <ulong> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.2, label %loopexit.loopexit, label %no_exit

loopexit.loopexit:              ; preds = %no_exit
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %inc.1 = add int %indvar, 1             ; <int> [#uses=1]
        ret int %inc.1

loopexit:               ; preds = %entry
        ret int 0
}


Here's the after code:

int %_strlen(sbyte* %str) {
entry:
        %inc.02 = getelementptr sbyte* %str, uint 1             ; <sbyte*> [#uses=1]
        %tmp.13 = load sbyte* %str              ; <sbyte> [#uses=1]
        %tmp.24 = seteq sbyte %tmp.13, 0                ; <bool> [#uses=1]
        br bool %tmp.24, label %loopexit, label %no_exit

no_exit:                ; preds = %entry, %no_exit
***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %inc.0.0 = getelementptr sbyte* %inc.02, uint %indvar           ; <sbyte*> [#uses=1]
        %inc.1 = add int %indvar, 1             ; <int> [#uses=1]
        %tmp.1 = load sbyte* %inc.0.0           ; <sbyte> [#uses=1]
        %tmp.2 = seteq sbyte %tmp.1, 0          ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.2, label %loopexit, label %no_exit

loopexit:               ; preds = %entry, %no_exit
        %len.0.1 = phi int [ 0, %entry ], [ %inc.1, %no_exit ]          ; <int> [#uses=1]
        ret int %len.0.1
}

llvm-svn: 13016
2004-04-17 18:16:10 +00:00
Chris Lattner
ed423cc09d Fix some really nasty dominance bugs that were exposed by my patch to
make the verifier more strict.  This fixes building zlib

llvm-svn: 13002
2004-04-16 18:08:07 +00:00
Chris Lattner
6fcf8c7402 ADd a trivial instcombine: load null -> null
llvm-svn: 12940
2004-04-14 03:28:36 +00:00
Chris Lattner
ca1428e01c Fix a bug in my select transformation
llvm-svn: 12826
2004-04-11 01:39:19 +00:00
Chris Lattner
96fca8de3d Implement InstCombine/select.ll:test13*
llvm-svn: 12821
2004-04-10 22:21:27 +00:00
Chris Lattner
618c89d5eb Implement InstCombine/add.ll:test20
Canonicalize add of sign bit constant into a xor

llvm-svn: 12819
2004-04-10 22:01:55 +00:00
Chris Lattner
22c22de2f0 Fix spurious warning in release mode
llvm-svn: 12816
2004-04-10 19:15:56 +00:00
Chris Lattner
306540a2f4 Implement select.ll:test12*
This transforms code like this:

   %C = or %A, %B
   %D = select %cond, %C, %A
into:
   %C = select %cond, %B, 0
   %D = or %A, %C

Since B is often a constant, the select can often be eliminated.  In any case,
this reduces the usage count of A, allowing subsequent optimizations to happen.

This xform applies when the operator is any of:
  add, sub, mul, or, xor, and, shl, shr

llvm-svn: 12800
2004-04-09 23:46:01 +00:00
Chris Lattner
3a6e4b9a35 Fold binary operators with a constant operand into select instructions
that have a constant operand.  This implements
add.ll:test19, shift.ll:test15*, and others that are not tested

llvm-svn: 12794
2004-04-09 19:05:30 +00:00
Chris Lattner
0e1f5553df Implement select.ll:test11
llvm-svn: 12793
2004-04-09 18:19:44 +00:00
Chris Lattner
0ca3cbfa5e Implement InstCombine/cast-propagate.ll
llvm-svn: 12784
2004-04-08 20:39:49 +00:00
Chris Lattner
cf8117ccbd Implement InstCombine/select.ll:test[7-10]
llvm-svn: 12769
2004-04-08 04:43:23 +00:00
Chris Lattner
2e89e48999 Implement test/Regression/Transforms/InstCombine/getelementptr_index.ll
llvm-svn: 12762
2004-04-07 18:38:20 +00:00
Chris Lattner
c92af54ed5 Fix a bug in yesterdays checkins which broke siod. siod is a great testcase! :)
llvm-svn: 12659
2004-04-05 16:02:41 +00:00
Chris Lattner
6c961339a3 Fix InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll
llvm-svn: 12658
2004-04-05 02:10:19 +00:00
Chris Lattner
9236135e8f Support getelementptr instructions which use uint's to index into structure
types and can have arbitrary 32- and 64-bit integer types indexing into
sequential types.

llvm-svn: 12653
2004-04-05 01:30:19 +00:00
Chris Lattner
b6612acb18 Implement select.ll:test[3-6]
llvm-svn: 12544
2004-03-30 19:37:13 +00:00
Chris Lattner
d191e5625c X % -1 == X % 1 == 0
llvm-svn: 12520
2004-03-26 16:11:24 +00:00
Chris Lattner
e15fb6ac61 Two changes:
#1 is to unconditionally strip constantpointerrefs out of
instruction operands where they are absolutely pointless and inhibit
optimization.  GRRR!

#2 is to implement InstCombine/getelementptr_const.ll

llvm-svn: 12519
2004-03-25 22:59:29 +00:00
Chris Lattner
078f97b50d Teach the optimizer to delete zero sized alloca's (but not mallocs!)
llvm-svn: 12507
2004-03-19 06:08:10 +00:00
Chris Lattner
52ac108b28 Add some debugging output
Fix InstCombine/2004-03-13-InstCombineInfLoop.ll which caused an infinite
loop compiling (I think) povray.

llvm-svn: 12365
2004-03-13 23:54:27 +00:00
Chris Lattner
e10c6cd509 Implement sub.ll:test14
llvm-svn: 12355
2004-03-13 00:11:49 +00:00
Chris Lattner
284e9ab607 Implement InstCombine/sub.ll:test12 & test13
llvm-svn: 12353
2004-03-12 23:53:13 +00:00
Chris Lattner
41801f046e Add trivial optimizations for select instructions
llvm-svn: 12317
2004-03-12 05:52:32 +00:00
Chris Lattner
7872171767 Rename AddUsesToWorkList -> AddUsersToWorkList, as that is what it does.
Create a new AddUsesToWorkList method
optimize memmove/set/cpy of zero bytes to a noop.

llvm-svn: 11941
2004-02-28 05:22:00 +00:00
Chris Lattner
192d8413d3 Turn 'free null' into nothing
llvm-svn: 11940
2004-02-28 04:57:37 +00:00
Chris Lattner
ffae67bae8 Implement test/Regression/Transforms/InstCombine/canonicalize_branch.ll
This is a really minor thing, but might help out the 'switch statement induction'
code in simplifycfg.

llvm-svn: 11900
2004-02-27 06:27:46 +00:00
Chris Lattner
fc15346b60 Fix a faulty optimization on FP values
llvm-svn: 11801
2004-02-24 18:10:14 +00:00
Chris Lattner
78800ae270 Generate much more efficient code in programs like pifft
llvm-svn: 11775
2004-02-23 21:46:58 +00:00
Chris Lattner
7fa6519e07 Fix a small typeo in my checkin last night that broke vortex and other programs :(
llvm-svn: 11774
2004-02-23 21:46:42 +00:00
Chris Lattner
253f77f2a7 Fix InstCombine/2004-02-23-ShiftShiftOverflow.ll
Also, turn 'shr int %X, 1234' into 'shr int %X, 31'

llvm-svn: 11768
2004-02-23 20:30:06 +00:00
Chris Lattner
74418a30aa Implement cast.ll::test14/15
llvm-svn: 11742
2004-02-23 07:16:20 +00:00
Chris Lattner
a65e5e3df1 Refactor some code. In the mul - setcc folding case, we really care about
whether this is the sign bit or not, so check unsigned comparisons as well.

llvm-svn: 11740
2004-02-23 06:38:22 +00:00
Chris Lattner
9ecc3fc3c1 Implement mul.ll:test11
llvm-svn: 11737
2004-02-23 06:00:11 +00:00
Chris Lattner
51b37305d9 Implement "strength reduction" of X <= C and X >= C
llvm-svn: 11735
2004-02-23 05:47:48 +00:00
Chris Lattner
c31a2e26ab Implement InstCombine/mul.ll:test10, which is a case that occurs when dealing
with "predication"

llvm-svn: 11734
2004-02-23 05:39:21 +00:00
Chris Lattner
69bb1545d1 Implement Transforms/InstCombine/cast.ll:test13, a case which occurs in a
hot 164.gzip loop.

llvm-svn: 11702
2004-02-22 05:25:17 +00:00
Chris Lattner
9affa63dc6 Fold PHI nodes of constants which are only used by a single cast. This implements
phi.ll:test4

llvm-svn: 11494
2004-02-16 05:07:08 +00:00
Chris Lattner
011b98cec4 Teach LLVM to unravel the "swap idiom". This implements:
Regression/Transforms/InstCombine/xor.ll:test20

llvm-svn: 11492
2004-02-16 03:54:20 +00:00
Chris Lattner
71154f0931 Implement Transforms/InstCombine/xor.ll:test19
llvm-svn: 11490
2004-02-16 01:20:27 +00:00
Chris Lattner
28131460da Adjustments to support the new ConstantAggregateZero class
llvm-svn: 11474
2004-02-15 05:55:15 +00:00
Chris Lattner
68fdb35576 rename the "exceptional" destination of an invoke instruction to the 'unwind' dest
llvm-svn: 11202
2004-02-08 21:44:31 +00:00
Chris Lattner
f2a481f7f8 Disable (x - (y - z)) => (x + (z - y)) optimization for floating point.
llvm-svn: 11083
2004-02-02 20:09:56 +00:00
Chris Lattner
f149ec635a Fix InstCombine/2004-01-13-InstCombineInvokePHI.ll, which also fixes lots
of C++ programs in Shootout-C++, including lists1 and moments, etc

llvm-svn: 10845
2004-01-14 06:06:08 +00:00