Chris Lattner
7cb257551f
more refactoring. Use early exits instead of really complex logic.
...
No functionality change.
llvm-svn: 53532
2008-07-13 22:04:41 +00:00
Chris Lattner
a4a80e0092
improve comments.
...
llvm-svn: 53531
2008-07-13 21:55:46 +00:00
Chris Lattner
824fbca1ee
factor another large hunk of code out into its own function.
...
No functionality change.
llvm-svn: 53530
2008-07-13 21:53:26 +00:00
Chris Lattner
67bf4acd15
Final bit of simplification for FoldBranchToCommonDest.
...
llvm-svn: 53528
2008-07-13 21:20:19 +00:00
Chris Lattner
3346d311c7
simplify logic a bit
...
llvm-svn: 53527
2008-07-13 21:15:11 +00:00
Chris Lattner
2ac1854097
Refactor some code out into its own helper function, getting rid of crazy multiline
...
conditionals and commenting the code better.
No functionality change.
llvm-svn: 53526
2008-07-13 21:12:01 +00:00
Nick Lewycky
3fb5816774
Enhance analysis of srem.
...
Remove dead code analyzing urem. 'urem' of power-of-2 is canonicalized to an
'and' instruction.
llvm-svn: 53506
2008-07-12 05:04:38 +00:00
Dan Gohman
d1342570f2
Use find instead of lower_bound.
...
llvm-svn: 53474
2008-07-11 20:58:19 +00:00
Owen Anderson
cc861329ee
Don't call lookupNumber more than we have to.
...
llvm-svn: 53470
2008-07-11 20:05:13 +00:00
Nick Lewycky
cafc3d583d
Document 'mask' in this calculation.
...
llvm-svn: 53454
2008-07-11 08:16:26 +00:00
Nick Lewycky
12c88a28f5
Remove misleading constant from comment.
...
llvm-svn: 53452
2008-07-11 07:36:19 +00:00
Nick Lewycky
8cd0f2058e
Add another optimization from PR2330. Also catch some missing cases that are
...
similar.
llvm-svn: 53451
2008-07-11 07:20:53 +00:00
Chris Lattner
07bfade2d4
a missed optimization that Eli spotted
...
llvm-svn: 53449
2008-07-11 06:40:29 +00:00
Chris Lattner
34b0895d4d
another bug in the same line.
...
llvm-svn: 53448
2008-07-11 06:38:16 +00:00
Chris Lattner
3cdb6789b9
fix a bug spotted by Eli's eagle eyes
...
llvm-svn: 53447
2008-07-11 06:36:01 +00:00
Chris Lattner
3d40848bfd
simplify and merge a bunch of code. Instead of comparing against
...
the min/max values for an integer type, compare against the min/max
values we can prove contain the input. This might be a tighter bound,
so this is general goodness.
llvm-svn: 53446
2008-07-11 05:40:05 +00:00
Chris Lattner
d1198896ae
fold away (x <= cst) earlier, allowing us to not have to
...
handle them in some code.
llvm-svn: 53445
2008-07-11 05:08:55 +00:00
Chris Lattner
16b8ae98c1
Fix folding of icmp's of i1 where the comparison is signed. The code
...
was using the algorithm for folding unsigned comparisons which is
completely wrong. This has been broken since the signless types change.
llvm-svn: 53444
2008-07-11 04:20:58 +00:00
Chris Lattner
f3f6b6d7af
Fix a bogus optimization: folding (slt (zext i1 A to i32), 1) -> (slt i1 A, true)
...
This cause a regression in InstCombine/JavaCompare, which was doing the right
thing on accident. To handle the missed case, generalize the comparisons based
on masked bits a little bit to handle comparisons against the max value. For
example, we can now xform (slt i32 (and X, 4), 4) -> (setne i32 (and X, 4), 4)
llvm-svn: 53443
2008-07-11 04:09:09 +00:00
Matthijs Kooijman
ca5124a630
Restructure dead argument elimination, try #3 :-)
...
Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of
dependencies between return values and/or arguments. Also make the handling of
arguments and return values the same.
The pass now looks properly inside returned structs, but only at the first
level (ie, not inside nested structs).
This version fixed a few more bugs and was cleaned up a bit. It now passes all
of LLVM's testing, and should still pass SPEC2006. There is still a minor bug
with regard to returning nested structs. Since there is currently nothing that
emits such IR, I will fix that in a seperate commit (partly because it requires
a non-trivial fix).
llvm-svn: 53400
2008-07-10 10:24:08 +00:00
Nick Lewycky
26ccb8e9a8
Fix overzealous optimization. Thanks to Duncan Sands for pointing out my error!
...
llvm-svn: 53393
2008-07-10 05:51:40 +00:00
Nick Lewycky
a7d102aca3
Simplify, suggested by Chris Lattner.
...
llvm-svn: 53283
2008-07-09 07:35:26 +00:00
Nick Lewycky
6341c5a7ec
Fold (a < 8) && (b < 8) into (a|b) < 8 for unsigned less or greater than.
...
llvm-svn: 53282
2008-07-09 07:29:11 +00:00
Nick Lewycky
38fa84fa12
Fold ((1 << a) & 1) to (a == 0).
...
llvm-svn: 53276
2008-07-09 05:20:13 +00:00
Nick Lewycky
2a6469c9a5
Reduce x - y to -y when we know the 'x' part will get masked off anyways.
...
llvm-svn: 53271
2008-07-09 04:32:37 +00:00
Devang Patel
2b56d5281d
If loop induction variable's start value is less then its exit value then do not split the loop.
...
llvm-svn: 53265
2008-07-09 00:12:01 +00:00
Chris Lattner
c144216d78
Fix PR2496, a really nasty bug which involved sinking volatile loads
...
into phis. This is actually the same bug as PR2262 /
2008-04-29-VolatileLoadDontMerge.ll, but I missed checking the first
predecessor for multiple successors. Testcase here:
InstCombine/2008-07-08-VolatileLoadMerge.ll
llvm-svn: 53240
2008-07-08 17:18:32 +00:00
Evan Cheng
cf3a4ad46d
Fix two serious LSR bugs.
...
1. LSR runOnLoop is always returning false regardless if any transformation is made.
2. AddUsersIfInteresting can create new instructions that are added to DeadInsts. But there is a later early exit which prevents them from being freed.
llvm-svn: 53193
2008-07-07 19:51:32 +00:00
Dan Gohman
c97817aac3
Make DenseMap's insert return a pair, to more closely resemble std::map.
...
llvm-svn: 53177
2008-07-07 17:46:23 +00:00
Nick Lewycky
94f9c5a42e
Fix missed optimization opportunity when analyzing cast of mul and select.
...
llvm-svn: 53151
2008-07-05 21:19:34 +00:00
Owen Anderson
035bf4d2ca
Use information already present in the ValueTable to fast-fail when we know there won't be a value number match. This speeds up GVN on a case where there are very few redundancies by ~25%.
...
llvm-svn: 53108
2008-07-03 17:44:33 +00:00
Devang Patel
dcfd567cc5
Do not try to update dominator info while manipulating CFG. This code does not handle all cases and keeps invalid dom info around some cases, which misleads other passes down stream.
...
Right now, dom info is recaluclated in the end if the loop is switched.
llvm-svn: 53106
2008-07-03 17:37:52 +00:00
Owen Anderson
1acfb69ad7
Remove the ability for ADCE to remove unreachable blocks in loop nests, because, as Eli pointed out, SimplifyCFG already does this.
...
llvm-svn: 53104
2008-07-03 17:21:41 +00:00
Bill Wendling
c4b5d8e1c3
Remove unused function.
...
llvm-svn: 53090
2008-07-03 07:10:03 +00:00
Devang Patel
6dd6992a45
Preserve dom info.
...
llvm-svn: 53089
2008-07-03 07:04:22 +00:00
Devang Patel
7a65306299
Remove extra FIXME
...
llvm-svn: 53087
2008-07-03 06:50:04 +00:00
Devang Patel
889fe6f848
Reconstruct dom info, if loop is unswitched.
...
llvm-svn: 53086
2008-07-03 06:48:21 +00:00
Devang Patel
f999e47e64
LoopUnswitch does not preserve dominator info in all cases.
...
llvm-svn: 53085
2008-07-03 05:55:03 +00:00
Devang Patel
f9e8484756
Undo previous patch. It is not that simple to fix dom info here.
...
llvm-svn: 53062
2008-07-03 00:08:13 +00:00
Devang Patel
db4a6944ec
Preserve dom info while simplifing loop after the unswitch.
...
llvm-svn: 53052
2008-07-02 22:58:54 +00:00
Owen Anderson
9a7d657786
Use df_ext_iterator to capture the reachable set without allocating an extra set.
...
Also, move large sets and vectors out of instance variables and onto the stack,
and give them more reasonable sizes.
llvm-svn: 53044
2008-07-02 18:41:09 +00:00
Owen Anderson
0b0017e514
Avoid a redundant call.
...
llvm-svn: 53040
2008-07-02 18:15:31 +00:00
Owen Anderson
e20158affb
Add support to ADCE for pruning unreachable blocks. This addresses the final
...
part of PR2509.
llvm-svn: 53038
2008-07-02 18:05:19 +00:00
Owen Anderson
764fe3df94
Use DenseSet rather than SmallPtrSet for the alive set. Using SmallPtrSet
...
with a huge "size" parameter is actually quite inefficient.
llvm-svn: 53034
2008-07-02 17:32:04 +00:00
Owen Anderson
5747d627e0
A better fix for PR2503 that doesn't pessimize GVN in the presence of unreachable blocks.
...
llvm-svn: 53032
2008-07-02 17:20:16 +00:00
Devang Patel
5d8e832471
reuse vectors.
...
llvm-svn: 53007
2008-07-02 01:44:29 +00:00
Devang Patel
9140e998b4
Fix comment.
...
llvm-svn: 53006
2008-07-02 01:31:19 +00:00
Devang Patel
68d9a25bcd
Preserve loop data so that it is not fetched everytime it is needed.
...
Keep track of currentLoop.
llvm-svn: 53005
2008-07-02 01:18:13 +00:00
Evan Cheng
2005804de6
- Re-apply 52748 and friends with fix. GetConstantStringInfo() returns an empty string for ConstantAggregateZero case which surprises selectiondag.
...
- Correctly handle memcpy from constant string which is zero-initialized.
llvm-svn: 52891
2008-06-30 07:31:25 +00:00
Anton Korobeynikov
6f260767ec
Revert (52748 and friends):
...
Move GetConstantStringInfo to lib/Analysis. Remove
string output routine from Constant. Update all
callers. Change debug intrinsic api slightly to
accomodate move of routine, these now return values
instead of strings.
This unbreaks llvm-gcc bootstrap.
llvm-svn: 52884
2008-06-29 17:57:03 +00:00