1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-28 22:42:52 +01:00
Commit Graph

418 Commits

Author SHA1 Message Date
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
Chris Lattner
1c10a30949 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
bf8c1cb6a3 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
c9d950434b Fix bug: ScalarRepl/2003-05-30-MultiLevel.ll
llvm-svn: 6428
2003-05-30 05:26:30 +00:00
Chris Lattner
0d415b2dd3 Fix bug: ScalarRepl/2003-05-29-ArrayFail.ll
llvm-svn: 6425
2003-05-30 04:15:41 +00:00
Chris Lattner
58c7aaa0e5 Add comment
llvm-svn: 6415
2003-05-29 20:26:30 +00:00
Chris Lattner
416e30b07b Fix bug: Instcombine/2003-05-27-ConstExprCrash.ll
llvm-svn: 6352
2003-05-27 16:40:51 +00:00
Chris Lattner
8a6c3b5cbe * Actually USE the statistic that we made
* Implement SRoA for arrays

llvm-svn: 6349
2003-05-27 16:09:27 +00:00
Chris Lattner
5c093a1a93 Implementation of the simple "scalar replacement of aggregates" transformation
llvm-svn: 6346
2003-05-27 15:45:27 +00:00
Chris Lattner
1fde83c9b5 Fix bug: InstCombine/2003-05-26-CastMiscompile.ll
llvm-svn: 6338
2003-05-26 23:41:32 +00:00
Chris Lattner
e58f6153f4 Remove using declarations
llvm-svn: 6306
2003-05-22 22:00:07 +00:00
Chris Lattner
91c5d68261 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
825e174bf7 Hopefully, the final fix for `[Pp]ropogate'.
llvm-svn: 6251
2003-05-20 21:01:22 +00:00
Misha Brukman
74cf3f5246 s/convertable/convertible/g
llvm-svn: 6248
2003-05-20 18:45:36 +00:00
Chris Lattner
d8234cfa3a Fix long standing bug
llvm-svn: 6232
2003-05-15 18:25:13 +00:00
Chris Lattner
6cb27840a7 Fix bug: LoopPreheaders/2003-05-12-PreheaderExitOfChild.ll
llvm-svn: 6153
2003-05-12 22:04:34 +00:00
Chris Lattner
a7ee27e0fd Handle va_arg instruction correctly
llvm-svn: 6030
2003-05-08 02:50:13 +00:00
Chris Lattner
e006ca4580 Fix spelling
llvm-svn: 5983
2003-05-02 19:26:34 +00:00
Chris Lattner
f13fe891d1 Fix Bug: LowerSwitch/2003-05-01-PHIProblem.ll
llvm-svn: 5979
2003-05-01 22:21:21 +00:00
Chris Lattner
5045ab0fac Fix another case where constexprs could cause a crash
llvm-svn: 5972
2003-04-30 22:34:06 +00:00
Chris Lattner
caa766b40f Fix constant folding of constexprs
llvm-svn: 5971
2003-04-30 22:19:10 +00:00
Chris Lattner
d2960ee802 Fix bug: ADCE/2003-04-25-PHIPostDominateProblem.ll
llvm-svn: 5952
2003-04-25 22:53:27 +00:00
Chris Lattner
c78cd5c758 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
7b67a6e77d 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
db6b7ba364 Remove unnecesary &*'s
llvm-svn: 5872
2003-04-23 16:37:45 +00:00
Chris Lattner
a9eaa10358 New pass to lower switch instructions to branch instructions
llvm-svn: 5865
2003-04-23 16:23:59 +00:00
Chris Lattner
d609c99c87 Minor cleanups
llvm-svn: 5863
2003-04-23 16:18:14 +00:00
Chris Lattner
bb00f755ed Change the interface to constant expressions to allow automatic folding
llvm-svn: 5793
2003-04-16 22:40:51 +00:00
Chris Lattner
731913bab3 Initial checkin of PRE on LLVM. This implementation is still lacking in
several ways:

 * Load expressions are not PRE'd well.  Alias Analysis should be used to
   get accurate information when computing anticipatibility.
 * The expression collection implementation does not handle PHI nodes properly,
   thus the implementation misses many opportunities to PRE.
 * This code could be sped up quite a bit

Despite these flaws, the code seems to work well, and handles PR's as one
would expect.

llvm-svn: 5759
2003-03-31 19:55:43 +00:00
Chris Lattner
b215db890f Move BreakCriticalEdges pass to lib/Transforms/Utils
llvm-svn: 5754
2003-03-21 21:43:19 +00:00
Chris Lattner
c51d7871ee Add the following instcombine xforms:
- Implement simple reassociation: (A|c1)|(B|c2) == (A|B)|(c1|c2)
  - (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
  - (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0

llvm-svn: 5743
2003-03-11 00:12:48 +00:00
Chris Lattner
6eededc41f Implement: -A*-B == A*B
llvm-svn: 5740
2003-03-10 23:23:04 +00:00
Chris Lattner
715b592fc4 Add new transformation: // (~A | ~B) == (~(A & B))
llvm-svn: 5738
2003-03-10 23:13:59 +00:00
Chris Lattner
0f5ab645eb Generalize not and neg comparison testers to allow constant to be considered not'able and neg'able. This
allows optimization of this:
int %test4(int %A, int %B) {
        %a = xor int %A, -1
        %c = and int %a, 5    ; 5 = ~c2
        %d = xor int %c, -1
        ret int %d
}

into this:
int %test4(int %A, int %B) {            ; No predecessors!
        %c.demorgan = or int %A, -6             ; <int> [#uses=1]
        ret int %c.demorgan
}

llvm-svn: 5736
2003-03-10 23:06:50 +00:00
Chris Lattner
3eca9aaa0a Generalize (A+c1)+c2 optimization to work with all associative operators
llvm-svn: 5733
2003-03-10 21:43:22 +00:00
Chris Lattner
9dec4368c0 Minor change, no functionality diff
llvm-svn: 5731
2003-03-10 19:20:30 +00:00
Chris Lattner
5fbfe9b9a8 Fix bug: (x << 100) wasn't folded to 0, but (x >> 100) was (when x is unsigned)
Implement new shift optimizations for shifting the result of a shift.

llvm-svn: 5729
2003-03-10 19:16:08 +00:00
Chris Lattner
5e6fb8b8d5 Implement: (A|B)^B == A & (~B)
llvm-svn: 5728
2003-03-10 18:24:17 +00:00
Chris Lattner
bd009a8938 Implement %test7 in InstCombine/getelementptr.ll
llvm-svn: 5704
2003-03-05 22:33:14 +00:00
Chris Lattner
4eaaa99b93 Convert LICM over to use AliasSetTracker. Besides being nicer, this automatically
allows LICM to use access sizes to help alias analysis be more precise.

llvm-svn: 5693
2003-03-03 23:32:45 +00:00
Chris Lattner
a49e96dda5 Change the mem2reg interface to accept a TargetData argument
llvm-svn: 5685
2003-03-03 17:25:18 +00:00
Chris Lattner
09c35df4e9 Fix bug: LICM/2003-02-28-PromoteDifferentType.ll
llvm-svn: 5675
2003-02-28 19:21:40 +00:00
Chris Lattner
dec7727a9f Fix bug I introduced yesterday :(
llvm-svn: 5669
2003-02-28 16:54:17 +00:00
Chris Lattner
e2aebf5906 Fix bug: LICM/2003-02-27-PreheaderExitNodeUpdate.ll
llvm-svn: 5667
2003-02-28 03:07:54 +00:00
Chris Lattner
d64f135965 Fix bug: 2003-02-27-PreheaderExitNodeUpdate.ll by updating exit node info
llvm-svn: 5664
2003-02-27 22:48:57 +00:00
Chris Lattner
74b9aaa89c Add a new assertion to check that stuff is happening right
Ironically the exit block modification code wasn't updating the exit block
information itself.  Fix this.

llvm-svn: 5659
2003-02-27 22:31:07 +00:00
Chris Lattner
d40fa5ca2f Fix bug: 2003-02-27-StoreSinkPHIs.ll
llvm-svn: 5658
2003-02-27 21:59:36 +00:00
Chris Lattner
e8dda81b22 * Don't forget to update Loop information!
* Remove bogus assertion: there may be a single outside predecessor and
    still need a new loop-preheader if the predecessor has multiple
    successors.  See bug: LICM/2003-02-27-PreheaderProblem.ll

llvm-svn: 5655
2003-02-27 21:50:19 +00:00
Chris Lattner
b078b28fa5 * Significant changes to the preheader insertion pass:
- Now we perform loop exit-block splitting to ensure exit blocks are
     always dominated by the loop header.
   - We now preserve dominance frontier information
   - This fixes bug: LICM/2003-02-26-LoopExitNotDominated.ll

llvm-svn: 5652
2003-02-27 20:27:08 +00:00
Chris Lattner
92a8816086 Convert to work with new AliasAnalysis interface by conservatively assuming all pointers are arbitrarily large accesses
llvm-svn: 5636
2003-02-26 19:28:57 +00:00
Chris Lattner
497c0d443c Rename Instruction::hasSideEffects() -> mayWriteToMemory()
llvm-svn: 5620
2003-02-24 20:48:32 +00:00
Chris Lattner
1c1f11bd3f Initial implementation of Loop invariant memory->scalar promotion
llvm-svn: 5613
2003-02-24 03:52:32 +00:00
Chris Lattner
2e4c1c8640 Split mem2reg promotion into two parts: a function which does the work, and
a pass which wraps the function.  This allows other passes to use the functionality

llvm-svn: 5610
2003-02-22 23:57:48 +00:00
Chris Lattner
c24ffa9297 4 new transformations:
* X*C + X --> X * (C+1)
  * X + X*C --> X * (C+1)
  * X - X*C --> X * (1-C)
  * X*C - X --> X * (C-1)

llvm-svn: 5592
2003-02-18 19:57:07 +00:00
Chris Lattner
8306cc5c5c Add a variety of new transformations:
* A & ~A == 0
  * A / (2^c) == A >> c  if unsigned
  * 0 / A == 0
  * 1.0 * A == A
  * A * (2^c) == A << c
  * A ^ ~A == -1
  * A | ~A == -1
  * 0 % X = 0
  * A % (2^c) == A & (c-1) if unsigned
  * A - (A & B) == A & ~B
  * -1 - A == ~A

llvm-svn: 5587
2003-02-18 19:28:33 +00:00
Chris Lattner
aceb57a289 Fix typo
llvm-svn: 5458
2003-02-01 04:50:59 +00:00
Chris Lattner
7af7b1c82c Fix bug: ADCE/2003-01-22-PredecessorProblem.ll
llvm-svn: 5405
2003-01-23 02:12:18 +00:00
Chris Lattner
61d594690a Fix a huge performance problem in reassociate by introducing a
rank map cache for instruction ranks

llvm-svn: 5030
2002-12-15 03:56:00 +00:00
Chris Lattner
18fe81719d Minor changes:
* Reword comment to make more clear
  * Don't print out BB's after modification made
  * Don't delete and new an instruction when we need to move something, just move it.

llvm-svn: 5029
2002-12-15 03:49:50 +00:00