Chris Lattner
099ec07a95
Make sure to cannonicalize loops before running indvar simplify
...
llvm-svn: 8502
2003-09-12 16:45:01 +00:00
Chris Lattner
7fdde92b1f
Do not return success after checking only the FIRST USE of a gep instruction.
...
Instead, check all uses.
This fixes bug: ScalarRepl/2003-09-12-IncorrectPromote.ll
This also fixes the miscompilation of Ptrdist/bc
llvm-svn: 8493
2003-09-12 16:02:12 +00:00
Chris Lattner
9a95f2a944
Minor optimization efficiency improvement:
...
- Run mem2reg promotion first
- Only rerun passes if the previous thing changed something
llvm-svn: 8490
2003-09-12 15:36:03 +00:00
Chris Lattner
cce81be1e1
Simplify code
...
Implement InstCombine/mul.ll:test9
llvm-svn: 8488
2003-09-11 22:24:54 +00:00
Misha Brukman
217ca0bcb9
Apostrophes are only used for possession and quoting.
...
llvm-svn: 8473
2003-09-11 16:58:31 +00:00
Chris Lattner
5d8a12e094
Integrate functionality of the mem2reg pass directly into this pass to make
...
the combination more effective
llvm-svn: 8471
2003-09-11 16:45:55 +00:00
Chris Lattner
bb9d03b9c0
Renamed DominatorTree::Node::getNode() -> getBlock()
...
llvm-svn: 8469
2003-09-11 16:26:13 +00:00
Misha Brukman
9b8d339f6e
Spell `definite' correctly.
...
llvm-svn: 8467
2003-09-11 15:32:37 +00:00
Chris Lattner
2158052ac4
Unwind instructions are intrinsically alive, just like returns
...
llvm-svn: 8462
2003-09-10 20:38:14 +00:00
Chris Lattner
216c7b8aed
Fix spell-o's
...
llvm-svn: 8431
2003-09-10 05:29:43 +00:00
Chris Lattner
4e621cd861
Spelling fixes. I think that "cannonical" is ok, but "canonical" appears to
...
be the canonical form for the word
llvm-svn: 8430
2003-09-10 05:24:46 +00:00
Chris Lattner
36257f049e
Fix up file header
...
llvm-svn: 8428
2003-09-10 05:10:34 +00:00
Misha Brukman
4ace48e0ca
Spell `occurrence' correctly.
...
llvm-svn: 8425
2003-09-09 21:54:45 +00:00
Chris Lattner
9c58cf6d03
Add support for the unwind instruction
...
llvm-svn: 8408
2003-09-08 18:54:55 +00:00
Chris Lattner
01a8391236
Do not hoist volatile loads
...
llvm-svn: 8399
2003-09-08 18:17:14 +00:00
Chris Lattner
1c884e18e1
Fix bug: TailDuplicate/2003-08-31-UnreachableBlocks.ll
...
llvm-svn: 8276
2003-08-31 21:17:44 +00:00
Chris Lattner
c817458b66
ScalarRepl does not modify the CFG. Say so!
...
llvm-svn: 8243
2003-08-31 00:45:13 +00:00
Chris Lattner
2887328770
Use new interface, simplifies code
...
llvm-svn: 8242
2003-08-31 00:22:27 +00:00
Chris Lattner
df741d62de
Fix bug: SCCP/2003-08-26-InvokeHandling.ll
...
llvm-svn: 8152
2003-08-27 01:08:35 +00:00
Chris Lattner
f1b1c5ec2f
Fix bug: LowerSwitch/2003-08-23-EmptySwitch.ll
...
llvm-svn: 8087
2003-08-23 22:54:34 +00:00
Chris Lattner
bb4dd7ed34
Fix bug: TailDup/2003-08-23-InvalidatedPointers.ll
...
llvm-svn: 8078
2003-08-23 20:08:30 +00:00
Misha Brukman
be372b91e1
The word `dependent' has no `a'.
...
llvm-svn: 8030
2003-08-21 22:14:26 +00:00
Chris Lattner
a34c477b05
Fix grammar, add comment
...
llvm-svn: 7967
2003-08-18 22:54:06 +00:00
Misha Brukman
7eb05a170a
Spell `necessary' correctly.
...
llvm-svn: 7944
2003-08-18 14:43:39 +00:00
Brian Gaeke
8c14ba96ca
Factory methods for function passes now return type FunctionPass *.
...
llvm-svn: 7839
2003-08-14 06:09:32 +00:00
Chris Lattner
3ac7c26a1c
Implement instcombine optimizations:
...
(A <setcc1> B) logicalop (A <setcc2> B) -> (A <setcc3> B) or true or false
Where setcc[123] is one of the 6 setcc instructions, and logicalop is one of: And, Or, Xor
llvm-svn: 7828
2003-08-13 20:16:26 +00:00
Chris Lattner
b8b97505ba
Generalize some of the add tests to allow for reassociation to take place
...
llvm-svn: 7825
2003-08-13 19:01:45 +00:00
Brian Gaeke
89207943a1
Factory methods for FunctionPasses now return type FunctionPass *.
...
llvm-svn: 7823
2003-08-13 18:18:15 +00:00
Chris Lattner
8ac196dd3b
Assign arguments different ranks so they get grouped together
...
llvm-svn: 7813
2003-08-13 16:16:26 +00:00
Chris Lattner
d07283a2ad
Implement InstCombine/2003-08-12-AllocaNonNull.ll
...
llvm-svn: 7807
2003-08-13 05:38:46 +00:00
Chris Lattner
c992add9fe
Do not cannonicalize (X != 0) into (cast X to bool)
...
llvm-svn: 7806
2003-08-13 05:33:12 +00:00
Chris Lattner
ede3fe05c5
Change cannonicalization rules: add X,X is represented as multiplies, multiplies
...
of a power of two are represented as a shift.
llvm-svn: 7803
2003-08-13 04:18:28 +00:00
Chris Lattner
deaa0dd71a
Allow pulling logical operations through shifts.
...
This implements InstCombine/shift.ll:test14*
llvm-svn: 7793
2003-08-12 21:53:41 +00:00
Chris Lattner
98b3ecddec
Fix bug: Reassociate/2003-08-12-InfiniteLoop.ll
...
llvm-svn: 7792
2003-08-12 21:45:24 +00:00
Chris Lattner
58c7eb60ec
Assign finer grained ranks, make sure to reassociate top-level after reassociating bottom level
...
llvm-svn: 7787
2003-08-12 20:14:27 +00:00
Chris Lattner
01d5639515
Simplify code
...
llvm-svn: 7783
2003-08-12 19:17:27 +00:00
Chris Lattner
812aab7727
Implement testcases InstCombine/or.ll:test16/test17
...
llvm-svn: 7782
2003-08-12 19:11:07 +00:00
Tanya Lattner
dc3c9a8545
Fixed minor bug in SafeToHoist and made some changes suggested by Chris.
...
llvm-svn: 7614
2003-08-05 20:39:02 +00:00
Tanya Lattner
57c03df032
Fixed LICM bug that hoists trapping instructions that are not guaranteed to execute.
...
llvm-svn: 7612
2003-08-05 18:45:46 +00:00
Chris Lattner
8abcd56c74
DEBUG got moved to Support/Debug.h
...
llvm-svn: 7492
2003-08-01 22:15:03 +00:00
Chris Lattner
ab780dfab5
Instcombine: (A >> c1) << c2 for signed integers
...
llvm-svn: 7295
2003-07-24 18:38:56 +00:00
Chris Lattner
3204d4ed4e
Reorganization of code, no functional changes.
...
Now it shoudl be a bit more efficient
llvm-svn: 7292
2003-07-24 17:52:58 +00:00
Chris Lattner
dfae8be3c9
Allow folding several instructions into casts, which can simplify a lot
...
of codes. For example,
short kernel (short t1) {
t1 >>= 8; t1 <<= 8;
return t1;
}
became:
short %kernel(short %t1.1) {
%tmp.3 = shr short %t1.1, ubyte 8 ; <short> [#uses=1]
%tmp.5 = cast short %tmp.3 to int ; <int> [#uses=1]
%tmp.7 = shl int %tmp.5, ubyte 8 ; <int> [#uses=1]
%tmp.8 = cast int %tmp.7 to short ; <short> [#uses=1]
ret short %tmp.8
}
before, now it becomes:
short %kernel(short %t1.1) {
%tmp.3 = shr short %t1.1, ubyte 8 ; <short> [#uses=1]
%tmp.8 = shl short %tmp.3, ubyte 8 ; <short> [#uses=1]
ret short %tmp.8
}
which will become:
short %kernel(short %t1.1) {
%tmp.3 = and short %t1.1, 0xFF00
ret short %tmp.3
}
This implements cast-set.ll:test4 and test5
llvm-svn: 7290
2003-07-24 17:35:25 +00:00
Chris Lattner
bfb1d03159
Add comments
...
llvm-svn: 7283
2003-07-23 21:41:57 +00:00
Chris Lattner
9763859e8d
Remove explicit check for: not (not X) = X, it is already handled because xor is commutative
...
- InstCombine: (X & C1) ^ C2 --> (X & C1) | C2 iff (C1&C2) == 0
- InstCombine: (X | C1) ^ C2 --> (X | C1) & ~C2 iff (C1&C2) == C2
llvm-svn: 7282
2003-07-23 21:37:07 +00:00
Chris Lattner
33217db4d9
InstCombine: (X ^ C1) & C2 --> (X & C2) iff (C1&C2) == 0
...
llvm-svn: 7272
2003-07-23 19:36:21 +00:00
Chris Lattner
16464b36ff
- InstCombine: (X | C1) & C2 --> X & C2 iff C1 & C1 == 0
...
- InstCombine: (X | C) & C --> C
- InstCombine: (X | C1) & C2 --> (X | (C1&C2)) & C2
llvm-svn: 7269
2003-07-23 19:25:52 +00:00
Chris Lattner
8f0d15601a
IC: (X & C1) | C2 --> (X | C2) & (C1|C2)
...
IC: (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2)
We are now guaranteed that all 'or's will be inside of 'and's, and all 'and's
will be inside of 'xor's, if the second operands are constants.
llvm-svn: 7264
2003-07-23 18:29:44 +00:00
Chris Lattner
49b47ae565
IC: (X ^ C1) & C2 --> (X & C2) ^ (C1&C2)
...
Minor code cleanup
llvm-svn: 7262
2003-07-23 17:57:01 +00:00
Chris Lattner
cfbce7c880
InstCombine: (X ^ 4) == 8 --> X == 12
...
llvm-svn: 7260
2003-07-23 17:26:36 +00:00
Chris Lattner
d492a0b7b4
IC: (X & 5) == 13 --> false
...
IC: (X | 8) == 4 --> false
llvm-svn: 7257
2003-07-23 17:02:11 +00:00
Chris Lattner
6077c3195f
Simplify code by using ConstantInt::getRawValue instead of checking to see
...
whether the constant is signed or unsigned, then casting
llvm-svn: 7252
2003-07-23 15:22:26 +00:00
Chris Lattner
d78ebd0c6b
Fix bug: TailDup/2003-07-22-InfiniteLoop.ll
...
llvm-svn: 7243
2003-07-23 03:32:41 +00:00
Chris Lattner
bdb0ce0605
- InstCombine (cast (xor A, B) to bool) ==> (setne A, B)
...
- InstCombine (cast (and X, (1 << size(X)-1)) to bool) ==> x < 0
llvm-svn: 7241
2003-07-22 21:46:59 +00:00
John Criswell
d6dcbc6ce8
Added code that checks to see if a global variable is external before replacing
...
a load of the global variable with the variable's constant value.
llvm-svn: 7216
2003-07-21 19:42:57 +00:00
John Criswell
0643ceafcf
Dinakar and I fixed a bug where we were trying to get the initializer of
...
an external constant. Since external constants don't have initializers, we
were failing on an assert() call in llvm/GlobalVariable.h.
llvm-svn: 7193
2003-07-17 19:06:55 +00:00
Chris Lattner
0f1d8a3947
Add support for elimination of load instruction from global constants
...
llvm-svn: 6912
2003-06-26 05:06:25 +00:00
Chris Lattner
35236d8477
Instcombine: X * -1 -> -X
...
llvm-svn: 6904
2003-06-25 17:09:20 +00:00
Chris Lattner
b396afde26
Fix bug: Mem2Reg/2003-06-26-IterativePromote.ll
...
llvm-svn: 6901
2003-06-25 14:58:56 +00:00
Chris Lattner
ee967711e9
Fix bug: ADCE/2003-06-24-BadSuccessor.ll
...
llvm-svn: 6891
2003-06-24 23:02:45 +00:00
Chris Lattner
834105502d
Do not mark ALL terminators live if any instruciton in the block is live. We only
...
want to mark it live if it is an unconditional branch. This fixes bug:
ADCE/2002-05-28-Crash.ll and makes this pass _much_ more useful.
llvm-svn: 6887
2003-06-24 21:49:45 +00:00
Chris Lattner
7e270580c8
Fix bug: SCCP/2003-06-24-OverdefinedPHIValue.ll
...
llvm-svn: 6883
2003-06-24 20:29:52 +00:00
Chris Lattner
f7544873de
Fix bug: TailDup/2003-06-24-Simpleloop.ll
...
llvm-svn: 6881
2003-06-24 19:48:06 +00:00
Chris Lattner
55d4bda861
Implement new transforms:
...
Replace (cast (sub A, B) to bool) -> (setne A, B)
Replace (cast (add A, B) to bool) -> (setne A, -B)
llvm-svn: 6873
2003-06-23 21:59:52 +00:00
Chris Lattner
92963de6fa
Add paranoia checking
...
llvm-svn: 6856
2003-06-22 20:46:00 +00:00
Chris Lattner
268c1392da
Test change
...
llvm-svn: 6852
2003-06-22 20:25:27 +00:00
Chris Lattner
a5434caa5c
Initial checkin of Tail duplication pass.
...
llvm-svn: 6846
2003-06-22 20:10:28 +00:00
Chris Lattner
d0d51605b2
Instcombine cast (getelementptr Ptr, 0, 0, 0) to ... into: cast Ptr to ...
...
This fixes type safety problems in a variety of benchmarks that were confusing
DSA.
llvm-svn: 6837
2003-06-21 23:12:02 +00:00
Chris Lattner
970c33abb1
Implement the functionality of InstCombine/call.ll
...
llvm-svn: 6783
2003-06-19 17:00:31 +00:00
Chris Lattner
2a8c301c9f
Don't corrupt memory when removing an instruction from the program, but
...
not the worklist
llvm-svn: 6733
2003-06-17 03:57:18 +00:00
Chris Lattner
dc62f1e021
Fix bug: ADCE/2003-06-11-InvalidCFG.ll
...
This was because we were deleting large chunks of functions without an exit block, because the post-dominance
information was not useful. This broke crafty and twolf.
llvm-svn: 6698
2003-06-16 12:10:45 +00:00
Chris Lattner
45789aca97
Fix bug: InstCombine/2003-06-05-BranchInvertInfLoop.ll
...
llvm-svn: 6630
2003-06-05 20:12:51 +00:00
Chris Lattner
e967b348bf
Clean up previous code.
...
Add new combination to turn seteq X, 0 -> not(cast X to bool)
llvm-svn: 6604
2003-06-04 05:10:11 +00:00
Chris Lattner
9eef8a78b4
Implement combination of boolean not with branch
...
llvm-svn: 6599
2003-06-04 04:46:00 +00:00
Chris Lattner
791ac1a4c8
Implement xform: (X != 0) -> (bool)X
...
llvm-svn: 6506
2003-06-01 03:35:25 +00:00
Chris Lattner
0078d9c5bb
Okay totally give up on trying to optimize aggregates that cannot be completely
...
broken up into their elements. Too many programs break because of this.
llvm-svn: 6440
2003-05-30 19:22:14 +00:00
Chris Lattner
d847be0539
add a check that allows the SRoA pass to avoid breaking programs, even if their
...
behavior is technically undefined
llvm-svn: 6438
2003-05-30 18:09:57 +00:00
Chris Lattner
38d88c07f4
Fix bug: ScalarRepl/2003-05-30-MultiLevel.ll
...
llvm-svn: 6428
2003-05-30 05:26:30 +00:00
Chris Lattner
6e5398d69d
Fix bug: ScalarRepl/2003-05-29-ArrayFail.ll
...
llvm-svn: 6425
2003-05-30 04:15:41 +00:00
Chris Lattner
6c81ebc97d
Add comment
...
llvm-svn: 6415
2003-05-29 20:26:30 +00:00
Chris Lattner
3442844742
Fix bug: Instcombine/2003-05-27-ConstExprCrash.ll
...
llvm-svn: 6352
2003-05-27 16:40:51 +00:00
Chris Lattner
c16b210349
* Actually USE the statistic that we made
...
* Implement SRoA for arrays
llvm-svn: 6349
2003-05-27 16:09:27 +00:00
Chris Lattner
fb41a50d15
Implementation of the simple "scalar replacement of aggregates" transformation
...
llvm-svn: 6346
2003-05-27 15:45:27 +00:00
Chris Lattner
196897c424
Fix bug: InstCombine/2003-05-26-CastMiscompile.ll
...
llvm-svn: 6338
2003-05-26 23:41:32 +00:00
Chris Lattner
8d0a71aff8
Remove using declarations
...
llvm-svn: 6306
2003-05-22 22:00:07 +00:00
Chris Lattner
471bd76281
Minor cleanups.
...
This hunk:
- } else if (Src->getNumOperands() == 2 && Src->use_size() == 1) {
+ } else if (Src->getNumOperands() == 2) {
Allows GEP folding to be more aggressive, which reduces the number of instructions
and can dramatically speed up BasicAA in some cases.
llvm-svn: 6286
2003-05-22 19:07:21 +00:00
Misha Brukman
373086db75
Hopefully, the final fix for `[Pp]ropogate'.
...
llvm-svn: 6251
2003-05-20 21:01:22 +00:00
Misha Brukman
e5838c4d72
s/convertable/convertible/g
...
llvm-svn: 6248
2003-05-20 18:45:36 +00:00
Chris Lattner
652e7bf8a8
Fix long standing bug
...
llvm-svn: 6232
2003-05-15 18:25:13 +00:00
Chris Lattner
0895025b30
Fix bug: LoopPreheaders/2003-05-12-PreheaderExitOfChild.ll
...
llvm-svn: 6153
2003-05-12 22:04:34 +00:00
Chris Lattner
b02697210e
Handle va_arg instruction correctly
...
llvm-svn: 6030
2003-05-08 02:50:13 +00:00
Chris Lattner
3666378690
Fix spelling
...
llvm-svn: 5983
2003-05-02 19:26:34 +00:00
Chris Lattner
df7cc91159
Fix Bug: LowerSwitch/2003-05-01-PHIProblem.ll
...
llvm-svn: 5979
2003-05-01 22:21:21 +00:00
Chris Lattner
dd65d863a9
Fix another case where constexprs could cause a crash
...
llvm-svn: 5972
2003-04-30 22:34:06 +00:00
Chris Lattner
9244df60d3
Fix constant folding of constexprs
...
llvm-svn: 5971
2003-04-30 22:19:10 +00:00
Chris Lattner
b68a34eb3f
Fix bug: ADCE/2003-04-25-PHIPostDominateProblem.ll
...
llvm-svn: 5952
2003-04-25 22:53:27 +00:00
Chris Lattner
3c98276168
Fix major problem with PHI node traversal: rechecking PHIs should go into
...
the visit function. The worklist is for when their lattice value changes.
llvm-svn: 5927
2003-04-25 03:35:10 +00:00
Chris Lattner
cccc5c76c8
Minor non-functional changes:
...
* Spell propagate right
* Improve performance of phi node handling
* Delete using directive
* Other minor changes
llvm-svn: 5920
2003-04-25 02:50:03 +00:00
Chris Lattner
889f620841
Remove unnecesary &*'s
...
llvm-svn: 5872
2003-04-23 16:37:45 +00:00
Chris Lattner
1b094a0f2e
New pass to lower switch instructions to branch instructions
...
llvm-svn: 5865
2003-04-23 16:23:59 +00:00