Chris Lattner
2b7babcc41
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
7ba3220999
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
77c65be59e
Factory methods for FunctionPasses now return type FunctionPass *.
...
llvm-svn: 7823
2003-08-13 18:18:15 +00:00
Chris Lattner
4e543f7021
Assign arguments different ranks so they get grouped together
...
llvm-svn: 7813
2003-08-13 16:16:26 +00:00
Chris Lattner
374473c778
Implement InstCombine/2003-08-12-AllocaNonNull.ll
...
llvm-svn: 7807
2003-08-13 05:38:46 +00:00
Chris Lattner
f8fbdb5ded
Do not cannonicalize (X != 0) into (cast X to bool)
...
llvm-svn: 7806
2003-08-13 05:33:12 +00:00
Chris Lattner
5c9ccccd96
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
3e52e8ce5a
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
7105c4aad0
Fix bug: Reassociate/2003-08-12-InfiniteLoop.ll
...
llvm-svn: 7792
2003-08-12 21:45:24 +00:00
Chris Lattner
c8d2398084
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
2e2432d69e
Simplify code
...
llvm-svn: 7783
2003-08-12 19:17:27 +00:00
Chris Lattner
c9c1d9f778
Implement testcases InstCombine/or.ll:test16/test17
...
llvm-svn: 7782
2003-08-12 19:11:07 +00:00
Tanya Lattner
6fbe85279f
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
48745a598c
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
686e94e760
DEBUG got moved to Support/Debug.h
...
llvm-svn: 7492
2003-08-01 22:15:03 +00:00
Chris Lattner
c5b0f39c96
Instcombine: (A >> c1) << c2 for signed integers
...
llvm-svn: 7295
2003-07-24 18:38:56 +00:00
Chris Lattner
bf9589bf1f
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
785e8453f0
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
6d10220481
Add comments
...
llvm-svn: 7283
2003-07-23 21:41:57 +00:00
Chris Lattner
ac8a2be5e4
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
f453a39185
InstCombine: (X ^ C1) & C2 --> (X & C2) iff (C1&C2) == 0
...
llvm-svn: 7272
2003-07-23 19:36:21 +00:00
Chris Lattner
80d9c3a900
- 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
76c1da471c
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
4b43cd9700
IC: (X ^ C1) & C2 --> (X & C2) ^ (C1&C2)
...
Minor code cleanup
llvm-svn: 7262
2003-07-23 17:57:01 +00:00
Chris Lattner
ae691a3068
InstCombine: (X ^ 4) == 8 --> X == 12
...
llvm-svn: 7260
2003-07-23 17:26:36 +00:00
Chris Lattner
b07de65646
IC: (X & 5) == 13 --> false
...
IC: (X | 8) == 4 --> false
llvm-svn: 7257
2003-07-23 17:02:11 +00:00
Chris Lattner
6ad460b336
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
74a266d229
Fix bug: TailDup/2003-07-22-InfiniteLoop.ll
...
llvm-svn: 7243
2003-07-23 03:32:41 +00:00
Chris Lattner
7594fa7280
- 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
98946bac5b
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
dbaf5f719c
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
0cc143577c
Add support for elimination of load instruction from global constants
...
llvm-svn: 6912
2003-06-26 05:06:25 +00:00
Chris Lattner
ebbc28f553
Instcombine: X * -1 -> -X
...
llvm-svn: 6904
2003-06-25 17:09:20 +00:00
Chris Lattner
0903331006
Fix bug: Mem2Reg/2003-06-26-IterativePromote.ll
...
llvm-svn: 6901
2003-06-25 14:58:56 +00:00
Chris Lattner
2cd94ee470
Fix bug: ADCE/2003-06-24-BadSuccessor.ll
...
llvm-svn: 6891
2003-06-24 23:02:45 +00:00
Chris Lattner
aac87d1e58
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
867b7661cb
Fix bug: SCCP/2003-06-24-OverdefinedPHIValue.ll
...
llvm-svn: 6883
2003-06-24 20:29:52 +00:00
Chris Lattner
e1051d9fcf
Fix bug: TailDup/2003-06-24-Simpleloop.ll
...
llvm-svn: 6881
2003-06-24 19:48:06 +00:00
Chris Lattner
e1f9e715c6
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
a98d464fd6
Add paranoia checking
...
llvm-svn: 6856
2003-06-22 20:46:00 +00:00
Chris Lattner
99633d8cd2
Test change
...
llvm-svn: 6852
2003-06-22 20:25:27 +00:00
Chris Lattner
6d372c7450
Initial checkin of Tail duplication pass.
...
llvm-svn: 6846
2003-06-22 20:10:28 +00:00
Chris Lattner
9a0da3e531
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
29e8adc038
Implement the functionality of InstCombine/call.ll
...
llvm-svn: 6783
2003-06-19 17:00:31 +00:00
Chris Lattner
2b01ee820e
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
64ec8f36aa
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
1bbfcd901c
Fix bug: InstCombine/2003-06-05-BranchInvertInfLoop.ll
...
llvm-svn: 6630
2003-06-05 20:12:51 +00:00
Chris Lattner
95d21756aa
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
b2ea03d03a
Implement combination of boolean not with branch
...
llvm-svn: 6599
2003-06-04 04:46:00 +00:00
Chris Lattner
eaafbfd2df
Implement xform: (X != 0) -> (bool)X
...
llvm-svn: 6506
2003-06-01 03:35:25 +00:00