Commit Graph

710 Commits

Author SHA1 Message Date
Chris Lattner
83c4ec0372 Fix two bugs: one where a condition was mistakenly swapped, and another
where we folded (X & 254) -> X < 1 instead of X < 2.  These problems were
latent problems exposed by the latest patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16528 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-27 19:29:18 +00:00
Chris Lattner
f63f647345 Fold: (setcc (shr X, ShAmt), CI), where 'cc' is eq or ne. This xform
triggers often, for example:

6x in povray, 1x in gzip, 279x in gcc, 1x in crafty, 8x in eon, 11x in perlbmk,
362x in gap, 4x in vortex, 14 in m88ksim, 211x in 126.gcc, 1x in compress,
11x in ijpeg, and 4x in 147.vortex.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16521 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-27 16:18:50 +00:00
Chris Lattner
0c96766c90 Implement shift-and combinations, implementing InstCombine/and.ll:test19-21
These combinations trigger 4 times in povray, 7x in gcc, 4x in gap, and 2x in bzip2.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16508 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-24 15:21:34 +00:00
Chris Lattner
648e3bc39c Move LHSI->hasOneUse() into the arms of the conditional, reindenting code.
No functionality changes here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16505 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-23 21:52:49 +00:00
Chris Lattner
b20ba0a83f Implement Transforms/InstCombine/and.ll:test18, a case that occurs 20 times
in perlbmk


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16504 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-23 21:46:38 +00:00
Chris Lattner
684fe210a9 Implement select.ll:test16: fold load (select C, X, null) -> load X
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16499 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-23 15:46:00 +00:00
Chris Lattner
3d834bf2c3 Do not fold (X + C1 != C2) if there are other users of the add. Doing
this transformation used to take a loop like this:

int Array[1000];
void test(int X) {
  int i;
  for (i = 0; i < 1000; ++i)
    Array[i] += X;
}

Compiled to LLVM is:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ]            ; <uint> [#uses=2]
        %tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar                ; <int*> [#uses=2]
        %tmp.7 = load int* %tmp.4               ; <int> [#uses=1]
        %tmp.9 = add int %tmp.7, %X             ; <int> [#uses=1]
        store int %tmp.9, int* %tmp.4
***     %indvar.next = add uint %indvar, 1              ; <uint> [#uses=2]
***     %exitcond = seteq uint %indvar.next, 1000               ; <bool> [#uses=1]
        br bool %exitcond, label %return, label %no_exit

and turn it into a loop like this:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ]            ; <uint> [#uses=3]
        %tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar                ; <int*> [#uses=2]
        %tmp.7 = load int* %tmp.4               ; <int> [#uses=1]
        %tmp.9 = add int %tmp.7, %X             ; <int> [#uses=1]
        store int %tmp.9, int* %tmp.4
***     %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
***     %exitcond = seteq uint %indvar, 999             ; <bool> [#uses=1]
        br bool %exitcond, label %return, label %no_exit

Note that indvar.next and indvar can no longer be coallesced.  In machine
code terms, this patch changes this code:

.LBBtest_1:     # no_exit
        mov %EDX, OFFSET Array
        mov %ESI, %EAX
        add %ESI, DWORD PTR [%EDX + 4*%ECX]
        mov %EDX, OFFSET Array
        mov DWORD PTR [%EDX + 4*%ECX], %ESI
        mov %EDX, %ECX
        inc %EDX
        cmp %ECX, 999
        mov %ECX, %EDX
        jne .LBBtest_1  # no_exit

into this:

.LBBtest_1:     # no_exit
        mov %EDX, OFFSET Array
        mov %ESI, %EAX
        add %ESI, DWORD PTR [%EDX + 4*%ECX]
        mov %EDX, OFFSET Array
        mov DWORD PTR [%EDX + 4*%ECX], %ESI
        inc %ECX
        cmp %ECX, 1000
        jne .LBBtest_1  # no_exit

We need better instruction selection to get this:

.LBBtest_1:     # no_exit
        add DWORD PTR [Array + 4*%ECX], EAX
        inc %ECX
        cmp %ECX, 1000
        jne .LBBtest_1  # no_exit

... but at least there is less register juggling


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16473 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-21 21:35:23 +00:00
Chris Lattner
79f0c8e4ee Fix potential miscompilations: InstCombine/2004-09-20-BadLoadCombine*.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16447 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-20 10:15:10 +00:00
Alkis Evlogimenos
7b6ec600c5 Fix loop condition so that we don't decrement off the beginning of the
list.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16440 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-20 06:42:58 +00:00
Chris Lattner
4b50156049 Prototype these functions more accurately
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16432 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-20 04:43:15 +00:00
Chris Lattner
8a37520f80 Make isSafeToLoadUnconditionally a bit smarter, implementing PR362 and
Regression/Transforms/InstCombine/CPP_min_max.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16409 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-19 19:18:10 +00:00
Chris Lattner
c10acedb2d Make instruction combining a bit more aggressive in the face of volatile
loads, and implement two new transforms: InstCombine/load.ll:test[56].


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16404 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-19 18:43:46 +00:00
Reid Spencer
2da5c3dda6 Convert code to compile with vc7.1.
Patch contributed by Paolo Invernizzi. Thanks Paolo!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16368 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-15 17:06:42 +00:00
Chris Lattner
bdacd87957 Fix a bug in the previous checkin that broke 255.vortex
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16355 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-15 02:34:40 +00:00
Chris Lattner
fb3ee1930b Make sure to update alias analysis information as we transform the function.
This fixes PR420 and Regression/Transforms/LICM/2004-09-14-AliasAnalysisInvalidate.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16348 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-15 01:04:07 +00:00
Chris Lattner
b50f1f13e2 Remove a long-dead pass. Actually, this pass was never used at all.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16337 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-14 16:33:01 +00:00
Alkis Evlogimenos
20aa474f8f Fixes to make LLVM compile with vc7.1.
Patch contributed by Paolo Invernizzi!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16152 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-03 18:19:51 +00:00
Reid Spencer
551ccae044 Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-01 22:55:40 +00:00
Reid Spencer
42e83feba7 Initial checkin of a pass to lower packed operations to scalars operations.
This also registers the pass with opt with a -lower-packed command line
option.

Patch contributed by Brad Jones.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15987 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-21 21:39:24 +00:00
Chris Lattner
5dbef2207e Fix InstCombine/2004-08-10-BoolSetCC.ll, a bug that is miscompiling
176.gcc.  Note that this is apparently not the only bug miscompiling gcc
though. :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15639 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-11 00:50:51 +00:00
Chris Lattner
b49f306bdf Fix InstCombine/2004-08-09-RemInfLoop.llx
This should go into the 1.3 branch


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15593 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-09 21:05:48 +00:00
Alkis Evlogimenos
15876bb28c Stop using getValues().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15487 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-04 08:44:43 +00:00
Chris Lattner
1484089bbf Fix a regression in InstCombine/xor.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15410 91177308-0d34-0410-b5e6-96231b3b80d8
2004-08-01 19:42:59 +00:00
Misha Brukman
cb6267bc60 Fix De Morgan's name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15343 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-30 12:50:08 +00:00
Chris Lattner
acd1f0fcb3 Start using the PatternMatcher a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15342 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-30 07:50:03 +00:00
Misha Brukman
47b14a4a6a Fix #includes of i*.h => Instructions.h as per PR403.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15334 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-29 17:30:56 +00:00
Misha Brukman
d8e1eea678 Fix #includes of i*.h => Instructions.h as per PR403.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15328 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-29 17:05:13 +00:00
Robert Bocchino
71698285e8 This change fixed a bug in the function visitMul. The prior version
assumed that a constant on the RHS of a multiplication was either an
IntConstant or an FPConstant.  It checked for an IntConstant and then,
if it did not find one, did a hard cast to an FPConstant.  That code
would crash if the RHS were a ConstantExpr that was neither an
IntConstant nor an FPConstant.  This version replaces the hard cast
with a dyn_cast.  It performs the same way for IntConstants and
FPConstants but does nothing, instead of crashing, for constant
expressions.

The regression test for this change is 2004-07-27-ConstantExprMul.ll.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15291 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-27 21:02:21 +00:00
Brian Gaeke
96d4bf7aee Make the create...() functions for some of these passes return a FunctionPass *.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15276 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-27 17:43:21 +00:00
Chris Lattner
eaa243039b Fix hoisting of void typed values, e.g. calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15263 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-27 07:38:32 +00:00
Chris Lattner
a000279a7d Implement DeadStoreElim/alloca.llx by observing that allocas are dead at the
end of the function (either return or unwind)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15232 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-26 06:14:11 +00:00
Chris Lattner
595ee7ec26 Throttle back indvar substitution from creating multiplies in loops. This is bad bad bad.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15227 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-26 02:47:12 +00:00
Chris Lattner
70e9b59b0e * Substantially simplify how free instructions are handled (potentially fixing
a bug in DSE).
* Delete dead operand uses iteratively instead of recursively, using a
  SetVector.
* Defer deletion of dead operand uses until the end of processing, which means
  we don't have to bother with updating the AliasSetTracker.  This speeds up
  DSE substantially.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15204 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-25 11:09:56 +00:00
Chris Lattner
a9e2f3d0ab Free instructions kill values too. This implements DeadStoreElim/free.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15199 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-25 07:58:38 +00:00
Chris Lattner
c47b6677ae obvious fix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15162 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-24 07:51:27 +00:00
Chris Lattner
0fb56afab1 This is a trivial dead store elimination pass. It very very simple and
can be improved in many ways.  But: stop laughing, even with -basicaa it
deletes 15% of the stores in 252.eon :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15101 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-22 08:00:28 +00:00
Chris Lattner
93c9587fbb Update GC intrinsics to take a pointer to the object as well as a pointer
to the field being updated.  Patch contributed by Tobias Nurmiranta


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15097 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-22 05:51:13 +00:00
Chris Lattner
f0cacc0ae7 * Further cleanup.
* Test for whether bits are shifted out during the optzn.

If so, the fold is illegal, though it can be handled explicitly for setne/seteq

This fixes the miscompilation of 254.gap last night, which was a latent bug
exposed by other optimizer improvements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15085 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-21 20:14:10 +00:00
Chris Lattner
5eb919405c Make cast-cast code a bit more defensive
"simplify" a bit of code for comparison/and folding


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15082 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-21 19:50:44 +00:00
Chris Lattner
e8a7e593e6 Remove special casing of pointers and treat them generically as integers of
the appopriate size.  This gives us the ability to eliminate int -> ptr -> int


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15063 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-21 04:27:24 +00:00
Chris Lattner
59a20773f8 Implement Transforms/InstCombine/IntPtrCast.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15029 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-20 05:21:00 +00:00
Chris Lattner
67769e5efa Implement InstCombine/GEPIdxCanon.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15024 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-20 01:48:15 +00:00
Chris Lattner
bee7e7644b Rewrite cast->cast elimination code completely based on the information we
actually care about.  Someday when the cast instruction is gone, we can do
better here, but this will do for now.  This implements
instcombine/cast.ll:test17/18 as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15018 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-20 00:59:32 +00:00
Chris Lattner
9db07b9307 Minor cleanup, no functionality change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14972 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 18:59:44 +00:00
Reid Spencer
c88920df66 Delete a redundant if branch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14967 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 08:34:52 +00:00
Reid Spencer
c3c2fdf5a8 Expand the coercion of constants to include the newly constant Globals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14966 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 08:34:19 +00:00
Reid Spencer
5f0eb64079 Delete a no-op loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14965 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 08:32:43 +00:00
Reid Spencer
c3c92d834a Expand the scope to include global values because they are now constants
too.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14964 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 08:32:10 +00:00
Reid Spencer
8863f1814b bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14950 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:38:32 +00:00
Reid Spencer
460f16c625 bug 122:
- Minimize redundant isa<GlobalValue> usage


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14948 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:32:14 +00:00
Reid Spencer
21cb67e16a bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Correct isa<Constant> for GlobalValue subclass


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14947 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:31:05 +00:00
Reid Spencer
48dc46a512 bug 122:
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14946 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:29:57 +00:00
Chris Lattner
80b2d6c8c4 This patch was contributed by Daniel Berlin!
Speed up SCCP substantially by processing overdefined values quickly.  This
patch speeds up SCCP by about 30-40% on large testcases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14861 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-15 23:36:43 +00:00
Chris Lattner
2fc1230dd6 Fixes working towards PR341
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14839 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-15 01:50:47 +00:00
Chris Lattner
b89e071aea Factor some code to handle "load (constantexpr cast foo)" just like
"load (cast foo)".  This allows us to compile C++ code like this:

class Bclass {
  public: virtual int operator()() { return 666; }
};

class Dclass: public Bclass {
  public: virtual int operator()() { return 667; }
} ;

int main(int argc, char** argv) {
  Dclass x;
  return x();
}

Into this:

int %main(int %argc, sbyte** %argv) {
entry:
        call void %__main( )
        ret int 667
}

Instead of this:

int %main(int %argc, sbyte** %argv) {
entry:
        %x = alloca "struct.std::bad_typeid"            ; <"struct.std::bad_typeid"*> [#uses=3]
        call void %__main( )
        %tmp.1.i.i = getelementptr "struct.std::bad_typeid"* %x, uint 0, uint 0, uint 0         ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Bclass, int 0, long 2), int (...)*** %tmp.1.i.i
        %tmp.3.i = getelementptr "struct.std::bad_typeid"* %x, int 0, uint 0, uint 0            ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2), int (...)*** %tmp.3.i
        %tmp.5 = load int ("struct.std::bad_typeid"*)** cast (int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2) to int
("struct.std::bad_typeid"*)**)          ; <int ("struct.std::bad_typeid"*)*> [#uses=1]
        %tmp.6 = call int %tmp.5( "struct.std::bad_typeid"* %x )                ; <int> [#uses=1]
	ret int %tmp.6
        ret int 0
}

In order words, we now resolve the virtual function call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14783 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-13 01:49:43 +00:00
Chris Lattner
fae1010218 Check to make sure types are sized before calling getTypeSize on them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14649 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 19:28:42 +00:00
Brian Gaeke
08cc64ebfe It doesn't matter what the 2nd operand is; if the GEP has 2 operands and
the first is a zero, we should leave it alone.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14648 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 19:24:47 +00:00
Brian Gaeke
10585d92da Add helper function.
Don't touch GEPs for which DecomposeArrayRef is not going to do anything
special (e.g., < 2 indices, or 2 indices and the last one is a constant.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14647 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 18:15:39 +00:00
Chris Lattner
3571b72606 Implement rem.ll:test3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14640 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 07:38:18 +00:00
Chris Lattner
1e3564ef05 Fix a minor bug where we would go into infinite loops on some constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14638 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 07:11:42 +00:00
Chris Lattner
5b73c08896 Implement InstCombine/sub.ll:test15: X % -Y === X % Y
Also, remove X % -1 = 0, because it's not true for unsigneds, and the
signed case is superceeded by this new handling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14637 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 07:01:22 +00:00
Reid Spencer
954da37bb4 Add #include <iostream> since Value.h does not #include it any more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14622 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-04 12:19:56 +00:00
Chris Lattner
46238a6150 Implement add.ll:test22, a common case in MSIL files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14587 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-03 00:26:11 +00:00
Chris Lattner
cf27afb64e Do not call getTypeSize on a type that has no size
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14584 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-02 22:55:47 +00:00
Brian Gaeke
1c4b6de4e7 Get rid of a dead variable, and fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14560 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-02 05:30:01 +00:00
Brian Gaeke
a9160a064f Make this pass use a more specific debug message than "Processing:".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14541 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-01 19:27:10 +00:00
Chris Lattner
15d58b638a Implement InstCombine/add.ll:test21
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14443 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-27 22:51:36 +00:00
Chris Lattner
9dc1b2ae9b New constant expression lowering pass to simplify your instruction selection needs.
Contributed by Vladimir Prus!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14399 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-25 07:48:09 +00:00
Chris Lattner
a25502acd7 Two fixes. First, stop using the ugly shouldSubstituteIndVar method.
Second, disable substitution of quadratic addrec expressions to avoid putting
multiplies in loops!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14358 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-24 06:49:18 +00:00
Chris Lattner
c5c5e6afe5 Make use of BinaryOperator::create* methods to shrinkify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14262 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-20 05:04:01 +00:00
Chris Lattner
56b7ee20da Now that dominator tree children are built in determinstic order, this horrible code
can go away


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14254 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 20:23:35 +00:00
Chris Lattner
2b994c7206 Fix a nasty bug, noticed by Reid
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14249 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 18:15:50 +00:00
Chris Lattner
edb8433c91 Fix one source of nondeterminism in the -licm pass: the hoist pass
was processing blocks in whatever order they happened to end up in the
dominator tree data structure.  Force an ordering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14248 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 08:56:43 +00:00
Chris Lattner
8430a4545c Do not loop over uses as we delete them. This causes iterators to be
invalidated out from under us.  This bug goes back to revision 1.1: scary.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14242 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 02:02:22 +00:00
Chris Lattner
5b62aa743d Implement Transforms/InstCombine/and.ll:test17, a common case that
occurs due to unordered comparison macros in math.h


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14221 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-18 06:07:51 +00:00
Chris Lattner
5dd04027c7 Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
Delete two functions that are now methods on the Type class


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14200 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-17 18:16:02 +00:00
Brian Gaeke
802daf8b7d Fix typo in DEBUG printout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14196 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-17 07:26:52 +00:00
Chris Lattner
3285a6f426 Fix a bug in my checkin from last night that caused miscompilations of
186.crafty, fhourstones and 132.ijpeg.

Bugpoint makes really nasty miscompilations embarassingly easy to find.  It
narrowed it down to the instcombiner and this testcase (from fhourstones):

bool %l7153_l4706_htstat_loopentry_2E_4_no_exit_2E_4(int* %i, [32 x int]* %works, int* %tmp.98.out) {
newFuncRoot:
        %tmp.96 = load int* %i          ; <int> [#uses=1]
        %tmp.97 = getelementptr [32 x int]* %works, long 0, int %tmp.96         ; <int*> [#uses=1]
        %tmp.98 = load int* %tmp.97             ; <int> [#uses=2]
        %tmp.99 = load int* %i          ; <int> [#uses=1]
        %tmp.100 = and int %tmp.99, 7           ; <int> [#uses=1]
        %tmp.101 = seteq int %tmp.100, 7                ; <bool> [#uses=2]
        %tmp.102 = cast bool %tmp.101 to int            ; <int> [#uses=0]
        br bool %tmp.101, label %codeRepl4.exitStub, label %codeRepl3.exitStub

codeRepl4.exitStub:             ; preds = %newFuncRoot
        store int %tmp.98, int* %tmp.98.out
        ret bool true

codeRepl3.exitStub:             ; preds = %newFuncRoot
        store int %tmp.98, int* %tmp.98.out
        ret bool false
}

... which only has one combination performed on it:

$ llvm-as < t.ll | opt -instcombine -debug | llvm-dis
IC: Old =       %tmp.101 = seteq int %tmp.100, 7                ; <bool> [#uses=1]
    New =       setne int %tmp.100, 0           ; <bool>:<badref> [#uses=0]
IC: MOD =       br bool %tmp.101, label %codeRepl3.exitStub, label %codeRepl4.exitStub
IC: MOD =       %tmp.97 = getelementptr [32 x int]* %works, uint 0, int %tmp.96         ; <int*> [#uses=1]

It doesn't get much better than this.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14109 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-10 02:33:20 +00:00
Chris Lattner
448c323cba More minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14108 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-10 02:12:35 +00:00
Chris Lattner
48595f18cf Eliminate many occurrances of Instruction::
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14107 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-10 02:07:29 +00:00
Chris Lattner
457dd829ad Implement InstCombine/select.ll:test15*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14095 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-09 07:59:58 +00:00
Chris Lattner
f523d06816 Be more careful about the order we put stuff onto the worklist. This allow us to
collapse this:
bool %le(int %A, int %B) {
        %c1 = setgt int %A, %B
        %tmp = select bool %c1, int 1, int 0
        %c2 = setlt int %A, %B
        %result = select bool %c2, int -1, int %tmp
        %c3 = setle int %result, 0
        ret bool %c3
}

into:

bool %le(int %A, int %B) {
        %c3 = setle int %A, %B          ; <bool> [#uses=1]
        ret bool %c3
}

which is handy, because the Java FE makes these sequences all over the place.

This is tested as: test/Regression/Transforms/InstCombine/JavaCompare.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14086 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-09 05:08:07 +00:00
Chris Lattner
2be51ae22d Implement select.ll:test14*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14083 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-09 04:24:29 +00:00
Chris Lattner
e1368aef23 Fix InstCombine/load.ll & PR347.
This code hadn't been updated after the "structs with more than 256 elements"
related changes to the GEP instruction.  Also it was not handling the
ConstantAggregateZero class.

Now it does!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13834 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 17:30:27 +00:00
Reid Spencer
c8a1fcdb48 Remove unused header file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13750 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:51:36 +00:00
Reid Spencer
3f0635e012 Make this pass simply invoke SymbolTable::strip().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13749 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:51:25 +00:00
Chris Lattner
3c6a0d4ae2 Implement InstCombine:shift.ll:test16, which turns (X >> C1) & C2 != C3
into (X & (C2 << C1)) != (C3 << C1), where the shift may be either left or
right and the compare may be any one.

This triggers 1546 times in 176.gcc alone, as it is a common pattern that
occurs for bitfield accesses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13740 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 06:32:08 +00:00
Chris Lattner
a710ddc9c4 Implement instcombine/cast.ll:test16:
Canonicalize cast X to bool into a setne instruction


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13736 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 04:29:21 +00:00
Chris Lattner
f52988a92d Spelling people's names right is kinda important
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13702 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:27:29 +00:00
Chris Lattner
2741c97104 Adjust to the changes in the AliasSetTracker interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13690 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:20:19 +00:00
Chris Lattner
057f78ab4e Add support for replacement of formal arguments with simpler expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13689 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:19:55 +00:00
Chris Lattner
08005dfdc9 Implement the -lowergc pass which is used by code generators (like the CBE)
that do not have builtin support for garbage collection.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13688 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:19:22 +00:00
Chris Lattner
fa28bb4601 This was not meant to be committed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13565 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 20:56:34 +00:00
Chris Lattner
82fec4e31d Fix a nasty bug that caused us to unroll EXTREMELY large loops due to overflow
in the size calculation.

This is not something you want to see:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - UNROLLING!

The problem was that 2*2147483648 == 0.

Now we get:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - TOO LARGE: 4294967296>100

Thanks to some anonymous person playing with the demo page that repeatedly
caused zion to go into swapping land.  That's one way to ensure you'll get
a quick bugfix.  :)

Testcase here: Transforms/LoopUnroll/2004-05-13-DontUnrollTooMuch.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13564 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 20:43:31 +00:00
Chris Lattner
be97b4e9ab Fix stupid bug in my checkin yesterday
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13429 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 22:41:42 +00:00
Chris Lattner
620ce14666 Implement folding of GEP's like:
%tmp.0 = getelementptr [50 x sbyte]* %ar, uint 0, int 5         ; <sbyte*> [#uses=2]
        %tmp.7 = getelementptr sbyte* %tmp.0, int 8             ; <sbyte*> [#uses=1]

together.  This patch actually allows us to simplify and generalize the code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13415 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 22:09:22 +00:00
Chris Lattner
546516c3c0 Fix PR336: The instcombine pass asserts when visiting load instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13400 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 15:35:56 +00:00
Chris Lattner
b9110c61fb Do not mark instructions in unreachable sections of the function as live.
This fixes PR332 and ADCE/2004-05-04-UnreachableBlock.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13349 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 17:00:46 +00:00
Chris Lattner
32ed46b36e Minor efficiency tweak, suggested by Patrick Meredith
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13341 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 15:19:33 +00:00
Chris Lattner
00d513182d Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13309 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 23:27:23 +00:00