Commit Graph

3310 Commits

Author SHA1 Message Date
Dan Gohman
d9efdb2012 Correct a few comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37034 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-14 14:31:17 +00:00
Chris Lattner
79cfddf646 Fix Transforms/GlobalOpt/2007-05-13-Crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37020 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-13 21:28:07 +00:00
Chris Lattner
7d8ed8a941 significantly improve debug output of lsr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36996 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-11 22:40:34 +00:00
Dan Gohman
23d9d27c26 Fix typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36994 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-11 21:10:54 +00:00
Dan Gohman
c767844fc9 This patch extends the LoopUnroll pass to be able to unroll loops
with unknown trip counts. This is left off by default, and a
command-line option enables it. It also begins to separate loop
unrolling into a utility routine; eventually it might be made usable
from other passes.

It currently works by inserting conditional branches between each
unrolled iteration, unless it proves that the trip count is a
multiple of a constant integer > 1, which it currently only does in
the rare case that the trip count expression is a Mul operator with
a ConstantInt operand. Eventually this information might be provided
by other sources, for example by a pass that peels/splits the loop
for this purpose.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36990 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-11 20:53:41 +00:00
Chris Lattner
3aea1bdca5 fix regressions from my previous checking, including
Transforms/InstCombine/2006-12-08-ICmp-Combining.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36989 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-11 16:58:45 +00:00
Chris Lattner
8885887b9c fix Transforms/InstCombine/2007-05-10-icmp-or.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36984 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-11 05:55:56 +00:00
Devang Patel
fd98dc9a76 Fix PR1333
Testcases :
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070507/049451.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070507/049452.html


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36955 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-09 08:24:12 +00:00
Dan Gohman
1cc0096d55 Fix various whitespace inconsistencies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36936 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-08 15:19:19 +00:00
Dan Gohman
f742c2363c Correct the comment for ApproximateLoopSize to reflect what it actually does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36935 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-08 15:14:19 +00:00
Dale Johannesen
6603a1bff0 Don't generate branch to entry block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36917 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-08 01:01:04 +00:00
Chris Lattner
1ce6f8da72 Fix PR1395, by passing the ID correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36894 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 23:13:56 +00:00
Nick Lewycky
ecd94c804a Fix typo in comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36873 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 13:37:16 +00:00
Chris Lattner
6f6f5125e2 Fix a bug in my previous patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36857 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-06 07:24:03 +00:00
Chris Lattner
8c756c1fff Implement Transforms/InstCombine/cast_ptr.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36809 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-05 22:41:33 +00:00
Chris Lattner
d717c1859a wrap long lines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36807 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-05 22:32:24 +00:00
Chris Lattner
caccc996e2 Fix Transforms/LoopUnroll/2007-05-05-UnrollMiscomp.ll and PR1385.
If we have a LCSSA, only modify the input value if the inval was defined
by an instruction in the loop.  If defined by something before the loop,
it is still valid.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36784 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-05 18:49:57 +00:00
Chris Lattner
a0c54f3ada make a temporary for *SI, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36782 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-05 18:36:36 +00:00
Chris Lattner
c42e226f08 Fix InstCombine/2007-05-04-Crash.ll and PR1384
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36775 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-05 01:59:31 +00:00
Dan Gohman
e5b01bea7b Use IntrinsicInst to test for prefetch instructions, which is ever so
slightly nicer than using CallInst with an extra check; thanks Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36743 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-04 14:59:09 +00:00
Dan Gohman
2acc760165 Allow strength reduction to make use of addressing modes for the
address operand in a prefetch intrinsic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36713 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-03 23:20:33 +00:00
Devang Patel
1997473cf7 Drop 'const'
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36662 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-03 01:11:54 +00:00
Devang Patel
3e15bf33e0 Use 'static const char' instead of 'static const int'.
Due to darwin gcc bug, one version of darwin linker coalesces
static const int, which defauts PassID based pass identification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36652 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-02 21:39:20 +00:00
Lauro Ramos Venancio
c718288f49 Fix build error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36648 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-02 20:37:47 +00:00
Devang Patel
794fd75c67 Do not use typeinfo to identify pass in pass manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36632 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-01 21:15:47 +00:00
Anton Korobeynikov
c6c98af9e5 Implement review feedback
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36564 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-29 18:02:48 +00:00
Anton Korobeynikov
a80e1181b7 Implement review feedback. Aliasees can be either GlobalValue's or
bitcasts of them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36537 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-28 13:45:00 +00:00
Chris Lattner
7f3c4d49df fix a bug triggered by 403.gcc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36527 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-28 05:27:36 +00:00
Chris Lattner
e62f021c8c Fix several latent bugs in EmitGEPOffset that didn't manifest with its
previous clients.  This fixes MallocBench/gs


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36525 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-28 04:52:43 +00:00
Chris Lattner
53c22fc7c6 uhn zap cvs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36523 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-28 03:50:56 +00:00
Chris Lattner
9bc1464094 Implement PR1345 and Transforms/InstCombine/bitcast-gep.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36521 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-28 00:57:34 +00:00
Chris Lattner
d3e28347e5 refactor some code relating to pointer cast xforms, pulling it out of the codepath
for unrelated casts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36511 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-27 17:44:50 +00:00
Zhou Sheng
c125c00e68 Using APInt more efficiently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36475 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-26 16:42:07 +00:00
Devang Patel
68c01b3cf3 Mem2Reg does not need TargetData.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36444 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 18:32:35 +00:00
Devang Patel
41968df51e Remove unused function argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36441 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 17:15:20 +00:00
Anton Korobeynikov
8b0a8c84da Implement aliases. This fixes PR1017 and it's dependent bugs. CFE part
will follow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36435 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 14:27:10 +00:00
Chris Lattner
79b3bd395d If an alloca only has two types of uses: 1) reads 2) a memcpy/memmove that
copies from a constant global, then we can change the reads to read from the
global instead of from the alloca.  This eliminates the alloca and the memcpy,
and promotes secondary optimizations (because the loads are now loads from
a constant global).

This is important for a common C idiom:

void foo() {
   int A[] = {1,2,3,4,5,6,7,8,9...};
   ... only reads of A ...
}

For some reason, people forget to mark the array static or const.

This triggers on these multisource benchmarks:
JM/ldecode: block_pos, [3 x [4 x [4 x i32]]]
FreeBench/mason: m, [18 x i32], inlined 4 times
MiBench/office-stringsearch: search_strings, [1332 x i8*]
MiBench/office-stringsearch: find_strings, [1333 x i8*]
Prolangs-C++/city: dirs, [9 x i8*], inlined 4 places

and these spec benchmarks:
177.mesa: message, [8 x [32 x i8]]
186.crafty: bias_rl45, [64 x i32]
186.crafty: diag_sq, [64 x i32]
186.crafty: empty, [9 x i8]
186.crafty: xlate, [15 x i8]
186.crafty: status, [13 x i8]
186.crafty: bdinfo, [25 x i8]
445.gobmk: routines, [16 x i8*]
458.sjeng: piece_rep, [14 x i8*]
458.sjeng: t, [13 x i32], inlined 4 places.
464.h264ref: block8x8_idx, [3 x [4 x [4 x i32]]]
464.h264ref: block_pos, [3 x [4 x [4 x i32]]]
464.h264ref: j_off_tab, [12 x i32]

This implements Transforms/ScalarRepl/memcpy-from-global.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36429 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 06:40:51 +00:00
Chris Lattner
a10b29b84b refactor the SROA code out into its own method, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36426 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 05:02:56 +00:00
Owen Anderson
ab0e4d38f0 Undo my previous changes. Since my approach to this problem is being revised,
this approach is no longer appropriate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36421 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 04:18:54 +00:00
Devang Patel
75abc1ed06 Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048376.html


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36417 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 00:37:04 +00:00
Owen Anderson
3a2b58f3ad Rollback some changes that adversely affected performance. I'm currently rethinking
my approach to this, so hopefully I'll find a way to do this without making this slower.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36392 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-24 06:40:39 +00:00
Devang Patel
2a5fa18997 Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048333.html


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36380 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-23 22:42:03 +00:00
Owen Anderson
1b7f584fd8 Make PredicateSimplifier not use DominatorTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36300 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-21 07:38:12 +00:00
Owen Anderson
cdacc498e4 Fix a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36299 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-21 07:12:44 +00:00
Jeff Cohen
09b362cee6 Comment out usage of write() for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36287 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-20 22:40:10 +00:00
Devang Patel
58d7fbf250 Avoid recursion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36272 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-20 20:04:37 +00:00
Owen Anderson
df07335b46 Move more passes to using ETForest instead of DominatorTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36271 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-20 06:27:13 +00:00
Zhou Sheng
843f0767ac Make use of ConstantInt::isZero instead of ConstantInt::isNullValue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36261 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-19 05:39:12 +00:00
Zhou Sheng
223d65b651 Make the operations of APInt variables more efficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36260 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-19 05:35:00 +00:00
Evan Cheng
cc045d5df8 Revert Owen's last check-in. This is breaking Mac OS X / PPC llvm-gcc bootstrap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36258 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-18 22:39:00 +00:00
Owen Anderson
a65064bb3d Revert changes that caused breakage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36255 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-18 06:46:57 +00:00
Owen Anderson
325171eed8 Switch more uses of DominatorTree over to ETForest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36254 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-18 05:43:13 +00:00
Owen Anderson
fb4b3d117f Use ETForest instead of DominatorTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36252 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-18 05:25:43 +00:00
Owen Anderson
ca2563d2d8 Use ETForest instead of DominatorTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36249 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-18 04:55:33 +00:00
Owen Anderson
ee6dcaf906 Use new ETForest accessor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36248 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-18 04:46:35 +00:00
Owen Anderson
26c37b1fdc Use ETForest instead of DominatorTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36247 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-18 04:39:32 +00:00
Dan Gohman
747603e39e Spell doFinalization right, so that it is a proper virtual override and
gets called.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36208 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-17 18:21:36 +00:00
Chris Lattner
261cdfbe5e remove use of BasicBlock::getNext
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36205 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-17 18:09:47 +00:00
Chris Lattner
e24c92a698 remove use of BasicBlock::getNext
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36202 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-17 17:54:12 +00:00
Chris Lattner
a0e1b0e98d eliminate use of Instruction::getNext()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36200 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-17 17:51:03 +00:00
Chris Lattner
decb0ca18b remove use of Instruction::getNext
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36199 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-17 17:47:54 +00:00
Devang Patel
ac58516cdc Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070416/047888.html


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36182 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-16 23:03:45 +00:00
Anton Korobeynikov
bed2946a96 Removed tabs everywhere except autogenerated & external files. Add make
target for tabs checking.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36146 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-16 18:10:23 +00:00
Chris Lattner
a6a996d319 Fix PR1335 and Transforms/Inline/2007-04-15-InlineEH.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36090 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-15 21:38:06 +00:00
Owen Anderson
3dc6776b33 Remove ImmediateDominator analysis. The same information can be obtained from DomTree. A lot of code for
constructing ImmediateDominator is now folded into DomTree construction.

This is part of the ongoing work for PR217.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36063 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-15 08:47:27 +00:00
Chris Lattner
83ae2fcacc fix SimplifyLibCalls/IsDigit.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36047 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-15 05:38:40 +00:00
Chris Lattner
31755a024d Extend store merging to support the 'if/then' version in addition to if/then/else.
This sinks the two stores in this example into a single store in cond_next.  In this
case, it allows elimination of the load as well:

        store double 0.000000e+00, double* @s.3060
        %tmp3 = fcmp ogt double %tmp1, 5.000000e-01             ; <i1> [#uses=1]
        br i1 %tmp3, label %cond_true, label %cond_next
cond_true:              ; preds = %entry
        store double 1.000000e+00, double* @s.3060
        br label %cond_next
cond_next:              ; preds = %entry, %cond_true
        %tmp6 = load double* @s.3060            ; <double> [#uses=1]

This implements Transforms/InstCombine/store-merge.ll:test2


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36040 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-15 01:02:18 +00:00
Chris Lattner
3284d1f18a refactor some code, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36037 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-15 00:07:55 +00:00
Chris Lattner
e34e9a29dc fix long lines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36031 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 23:32:02 +00:00
Chris Lattner
b7300fa8d2 Implement Transforms/InstCombine/vec_extract_elt.ll, transforming:
define i32 @test(float %f) {
        %tmp7 = insertelement <4 x float> undef, float %f, i32 0
        %tmp17 = bitcast <4 x float> %tmp7 to <4 x i32>
        %tmp19 = extractelement <4 x i32> %tmp17, i32 0
        ret i32 %tmp19
}

into:

define i32 @test(float %f) {
        %tmp19 = bitcast float %f to i32                ; <i32> [#uses=1]
        ret i32 %tmp19
}

On PPC, this is the difference between:

_test:
        mfspr r2, 256
        oris r3, r2, 8192
        mtspr 256, r3
        stfs f1, -16(r1)
        addi r3, r1, -16
        addi r4, r1, -32
        lvx v2, 0, r3
        stvx v2, 0, r4
        lwz r3, -32(r1)
        mtspr 256, r2
        blr

and:

_test:
        stfs f1, -4(r1)
        nop
        nop
        nop
        lwz r3, -4(r1)
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36025 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 23:02:14 +00:00
Chris Lattner
6987833651 Implement InstCombine/vec_demanded_elts.ll:test2. This allows us to turn
unsigned test(float f) {
 return _mm_cvtsi128_si32( (__m128i) _mm_set_ss( f*f ));
}

into:

_test:
        movss 4(%esp), %xmm0
        mulss %xmm0, %xmm0
        movd %xmm0, %eax
        ret

instead of:

_test:
        movss 4(%esp), %xmm0
        mulss %xmm0, %xmm0
        xorps %xmm1, %xmm1
        movss %xmm0, %xmm1
        movd %xmm1, %eax
        ret

GCC gets:

_test:
        subl    $28, %esp
        movss   32(%esp), %xmm0
        mulss   %xmm0, %xmm0
        xorps   %xmm1, %xmm1
        movss   %xmm0, %xmm1
        movaps  %xmm1, %xmm0
        movd    %xmm0, 12(%esp)
        movl    12(%esp), %eax
        addl    $28, %esp
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36020 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 22:29:23 +00:00
Chris Lattner
d6b7a1648c avoid copying sets and vectors around.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36017 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 22:10:17 +00:00
Chris Lattner
ae143ceb83 avoid iterator invalidation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36002 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 18:06:52 +00:00
Jeff Cohen
98a72203d7 An even better fix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35998 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 17:18:29 +00:00
Jeff Cohen
e4aee1d3a4 Fix recent regression that broke several llvm-tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35996 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 16:55:19 +00:00
Chris Lattner
35b9b49fd1 Implement a few missing xforms: printf("foo\n") -> puts. printf("x") -> putchar
printf("") -> noop.  Still need to do the xforms for fprintf.

This implements Transforms/SimplifyLibCalls/Printf.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35984 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 01:17:48 +00:00
Chris Lattner
8264a9fcca in addition to merging, constantmerge should also delete trivially dead globals,
in order to clean up after simplifylibcalls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35982 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 01:11:54 +00:00
Chris Lattner
6fe5541003 Implement PR1201 and test/Transforms/InstCombine/malloc-free-delete.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 00:20:02 +00:00
Chris Lattner
f25646bfb3 use an accessor to simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35979 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-14 00:17:39 +00:00
Chris Lattner
c5494af8a9 Now that codegen prepare isn't defeating me, I can finally fix what I set
out to do! :)

This fixes a problem where LSR would insert a bunch of code into each MBB
that uses a particular subexpression (e.g. IV+base+C).  The problem is that
this code cannot be CSE'd back together if inserted into different blocks.

This patch changes LSR to attempt to insert a single copy of this code and
share it, allowing codegenprepare to duplicate the code if it can be sunk
into various addressing modes.  On CodeGen/ARM/lsr-code-insertion.ll,
for example, this gives us code like:

        add r8, r0, r5
        str r6, [r8, #+4]
..
        ble LBB1_4      @cond_next
LBB1_3: @cond_true
        str r10, [r8, #+4]
LBB1_4: @cond_next
...
LBB1_5: @cond_true55
        ldr r6, LCPI1_1
        str r6, [r8, #+4]

instead of:

        add r10, r0, r6
        str r8, [r10, #+4]
...
        ble LBB1_4      @cond_next
LBB1_3: @cond_true
        add r8, r0, r6
        str r10, [r8, #+4]
LBB1_4: @cond_next
...
LBB1_5: @cond_true55
        add r8, r0, r6
        ldr r10, LCPI1_1
        str r10, [r8, #+4]

Besides being smaller and more efficient, this makes it immediately
obvious that it is profitable to predicate LBB1_3 now :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35972 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 20:42:26 +00:00
Chris Lattner
dd77df3cbc Completely rewrite addressing-mode related sinking of code. In particular,
this fixes problems where codegenprepare would sink expressions into load/stores
that are not valid, and fixes cases where it would miss important valid ones.

This fixes several serious codesize and perf issues, particularly on targets
with complex addressing modes like arm and x86.  For example, now we compile
CodeGen/X86/isel-sink.ll to:

_test:
        movl 8(%esp), %eax
        movl 4(%esp), %ecx
        cmpl $1233, %eax
        ja LBB1_2       #F
LBB1_1: #T
        movl $4, (%ecx,%eax,4)
        movl $141, %eax
        ret
LBB1_2: #F
        movl (%ecx,%eax,4), %eax
        ret

instead of:

_test:
        movl 8(%esp), %eax
        leal (,%eax,4), %ecx
        addl 4(%esp), %ecx
        cmpl $1233, %eax
        ja LBB1_2       #F
LBB1_1: #T
        movl $4, (%ecx)
        movl $141, %eax
        ret
LBB1_2: #F
        movl (%ecx), %eax
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35970 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 20:30:56 +00:00
Devang Patel
4beccb897d Remove use of SlowOperationInformer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35967 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 18:58:18 +00:00
Devang Patel
60b0d84594 Undo previous check-in.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35966 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 18:35:15 +00:00
Devang Patel
02c768608a Hello uses LLVMSupport.a (SlowerOperationInformer)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35965 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-13 18:28:23 +00:00
Lauro Ramos Venancio
c763552299 Implement the "thread_local" keyword.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35950 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-12 18:32:50 +00:00
Reid Spencer
3234b3e1f2 Build Hello by default so it can be used in test cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35922 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 21:03:37 +00:00
Chris Lattner
ab46275683 Fix Transforms/ScalarRepl/union-pointer.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35906 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 15:45:25 +00:00
Chris Lattner
8a9f571052 Turn stuff like:
icmp slt i32 %X, 0              ; <i1>:0 [#uses=1]
        sext i1 %0 to i32               ; <i32>:1 [#uses=1]

into:

        %X.lobit = ashr i32 %X, 31              ; <i32> [#uses=1]

This implements InstCombine/icmp.ll:test[34]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35891 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 06:57:46 +00:00
Chris Lattner
a2e2c9bbf3 Simplify some comparisons to arithmetic, this implements:
Transforms/InstCombine/icmp.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35890 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 06:53:04 +00:00
Chris Lattner
ba41783dbb canonicalize (x <u 2147483648) -> (x >s -1) and (x >u 2147483647) -> (x <s 0)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35886 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 06:12:58 +00:00
Chris Lattner
66bc325bff fix a miscompilation of:
define i32 @test(i32 %X) {
entry:
        %Y = and i32 %X, 4              ; <i32> [#uses=1]
        icmp eq i32 %Y, 0               ; <i1>:0 [#uses=1]
        sext i1 %0 to i32               ; <i32>:1 [#uses=1]
        ret i32 %1
}

by moving code out of commonIntCastTransforms into visitZExt.  Simplify the
APInt gymnastics in it etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35885 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 05:45:39 +00:00
Chris Lattner
ed4e51e58e fix a regression introduced by my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35879 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 03:27:24 +00:00
Chris Lattner
f4b1818728 Simplify SROA conversion to integer in some ways, make it more general in others.
We now tolerate small amounts of undefined behavior, better emulating what
would happen if the transaction actually occurred in memory.  This fixes
SingleSource/UnitTests/2007-04-10-BitfieldTest.c on PPC, at least until
Devang gets a chance to fix the CFE from doing undefined things with bitfields :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35875 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-11 00:57:54 +00:00
Chris Lattner
81973ef7cb Strengthen the boundary conditions of this fold, implementing
InstCombine/set.ll:test25


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35852 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 23:52:13 +00:00
Owen Anderson
cc221cdf0c Re-constify things that don't break the build. Last patch in this
series, I promise.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35848 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 23:38:18 +00:00
Chris Lattner
9fda270e2c eliminate the last uses of some TLI methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35844 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 23:29:07 +00:00
Owen Anderson
f7c83188cd Unconst-ify stuff that broke the build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35843 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 23:08:26 +00:00
Owen Anderson
ad19014591 Const-ify some parameters, and some cosmetic cleanups. No functionality
change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35842 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 22:54:50 +00:00
Owen Anderson
0cd0461873 Tabs -> Spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35841 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 22:31:43 +00:00
Owen Anderson
17cba6d232 Improve some _slow_ behavior introduced in my patches the last few days.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35839 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 22:25:09 +00:00
Chris Lattner
579633cd10 switch LSR to use isLegalAddressingMode instead of other simpler hooks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35837 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 22:20:14 +00:00
Devang Patel
6c36157f3d Check _all_ PHINodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35836 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 22:20:10 +00:00
Devang Patel
c415afc726 Insert new pre-header before new header. Original pre-header may
happen to be an entry, in such case, it is not a good idea to
insert new block before entry.

Also fix typo in assertion check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35833 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 21:40:43 +00:00
Devang Patel
5464b96073 Preserve canonical loop form.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35829 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 20:19:46 +00:00
Reid Spencer
9101d8647f Don't link against System or Support library. These things will already
be in the opt tool.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35827 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 19:17:47 +00:00
Devang Patel
e98815469c Do not create new pre-header. Reuse original pre-header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35825 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 19:04:21 +00:00
Devang Patel
4522c8a44c Simpler for() loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35822 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 17:09:13 +00:00
Devang Patel
cfde9594d1 Fix future bug. Of course, Chris spotted this.
Handle Argument or Undef as an incoming PHI value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35821 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 16:41:46 +00:00
Devang Patel
24a1c49172 More cosmetic changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35820 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 16:21:29 +00:00
Devang Patel
322313376a Only cosmetic changes. Zero functionality Change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35819 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 16:11:48 +00:00
Chris Lattner
8546409d1b Fix PR1304 and Transforms/InstCombine/2007-04-08-SingleEltVectorCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35792 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 01:37:55 +00:00
Chris Lattner
599ded1a7f Eliminate useless insertelement instructions. This implements
Transforms/InstCombine/vec_insertelt.ll and fixes PR1286.

We now compile the code from that bug into:

_foo:
        movl 4(%esp), %eax
        movdqa (%eax), %xmm0
        movl 8(%esp), %ecx
        psllw (%ecx), %xmm0
        movdqa %xmm0, (%eax)
        ret

instead of:

_foo:
        subl $4, %esp
        movl %ebp, (%esp)
        movl %esp, %ebp
        movl 12(%ebp), %eax
        movdqa (%eax), %xmm0
        #IMPLICIT_DEF %eax
        pinsrw $2, %eax, %xmm0
        xorl %ecx, %ecx
        pinsrw $3, %ecx, %xmm0
        pinsrw $4, %eax, %xmm0
        pinsrw $5, %ecx, %xmm0
        pinsrw $6, %eax, %xmm0
        pinsrw $7, %ecx, %xmm0
        movl 8(%ebp), %eax
        movdqa (%eax), %xmm1
        psllw %xmm0, %xmm1
        movdqa %xmm1, (%eax)
        movl %ebp, %esp
        popl %ebp
        ret

woo :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35788 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 01:11:16 +00:00
Owen Anderson
558fc740da Cleanup some from my DomSet-removal changes. Add a new
isReachableFromEntry
test to ETForest to factor a common test out of code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35786 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-09 00:52:49 +00:00
Chris Lattner
51047859ed Fix a typo that broke SimplifyLibCalls/SPrintF.ll (pr1315)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35768 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-08 18:11:26 +00:00
Chris Lattner
044e5337f5 reenable this xform, whoops :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35765 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-08 08:01:49 +00:00
Chris Lattner
6cae0e06ac Fix regression on Instcombine/apint-or2.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35763 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-08 07:55:22 +00:00
Chris Lattner
c5e7ea49eb Generalize the code that handles (A&B)|(A&C) to work where B/C are not constants.
Add a new xform to simplify (A&B)|(~A&C).  THis implements InstCombine/or2.ll:test1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35760 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-08 07:47:01 +00:00
Chris Lattner
5cef3c6eb7 implement a fixme: move optimizations for fwrite out of fputs into a new
fwrite optimizer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35758 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-08 07:00:35 +00:00
Nick Lewycky
a397ce1cc2 Remove DominatorSet usage from LoopSimplify. Patch from Owen Anderson.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35757 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-08 01:04:30 +00:00
Chris Lattner
0cd3a23d2a Significantly simplify the clients of GetConstantStringInfo, by having it
just return the string itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35755 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 21:58:02 +00:00
Chris Lattner
73f5d42a97 Fix problems in the sprintf optimizer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35754 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 21:17:51 +00:00
Chris Lattner
3492cda48f Change CastToCStr to take a pointer instead of a reference.
Fix some miscompilations in fprintf optimizer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35753 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 21:04:50 +00:00
Chris Lattner
af33e6579a Fix an off-by-one error that broke Prolangs/deriv2 with llc on x86
and Prolangs-C/cdecl


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35749 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 20:19:08 +00:00
Owen Anderson
e9ed4452bc Add DomSet back, and revert the changes to LoopSimplify. Apparently the
ETForest updating mechanisms don't work as I thought they did.  These changes
will be reapplied once the issue is worked out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35741 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 18:23:27 +00:00
Nick Lewycky
ac4d664d45 Add support for cast instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35734 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 15:48:32 +00:00
Owen Anderson
ba43963e96 Completely purge DomSet. This is the (hopefully) final patch for PR1171.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35731 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 07:17:27 +00:00
Owen Anderson
4f9e58ecdf Completely purge DomSet from LoopSimplify. This is part of the
continuing work on PR1171.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35730 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 06:56:47 +00:00
Owen Anderson
a3ca0b648c BreakCriticalEdges does still preserve DominatorTree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35729 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 05:57:09 +00:00
Owen Anderson
2d43519454 Expunge DomSet from BreakCriticalEdges. This is part of the continuing
work for PR 1171.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35728 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 05:49:29 +00:00
Owen Anderson
c6fcf29e81 Expunge DomSet from CodeExtractor. This is part of the continuing work
on PR1171.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35726 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 05:31:27 +00:00
Nick Lewycky
a995d920d5 Support NE inequality in ValueRanges.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35724 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 04:49:12 +00:00
Owen Anderson
d44008ae40 Expunge a bunch of uses of DomSet from LoopSimplify. Many more remain.
This is the beginning of work for PR1171.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35720 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 04:37:14 +00:00
Nick Lewycky
f3a9e368f6 Cleanup. Refactor out the applying of value ranges to its own method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35719 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 03:36:51 +00:00
Nick Lewycky
b01c77e137 Use TargetData to find the size of a type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35718 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 03:16:12 +00:00
Nick Lewycky
8ac40dd747 Strengthen icmp snuggling by doing 'compare-or-equal-to' to 'compare'
first and then range testing second.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35715 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 02:30:14 +00:00
Devang Patel
c4625da483 Add loop rotation pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35714 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 01:25:15 +00:00
Chris Lattner
045af54275 fix a miscompilation in printf optimizer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35713 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 01:18:36 +00:00
Chris Lattner
ef4fd35726 trunc to bool no longer compares against zero
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35712 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 01:03:46 +00:00
Chris Lattner
71bf3e2ef9 cleanups for strlen optimizer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35711 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 01:02:00 +00:00
Chris Lattner
679d7188c7 Introduce a new ReplaceCallWith method, which simplifies a lot of code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35710 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 00:42:32 +00:00
Chris Lattner
db895b82a3 fixes for strcpy optimizer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35709 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 00:26:18 +00:00
Chris Lattner
7b50c8f278 Fix bugs in strncmp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35708 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 00:06:57 +00:00
Chris Lattner
ceb375ecf2 fix 3 miscompilations and several compielr crashes in strcmp optimizer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35707 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-07 00:01:51 +00:00
Chris Lattner
6897fe5861 Fix several nasty bugs in the strchr optimizer, this fixes
SimplifyLibCalls/2007-04-06-strchr-miscompile.ll and PR1307


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35706 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-06 23:38:55 +00:00
Chris Lattner
09c11aa7f5 clean up strcat optimizer, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35704 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-06 22:59:33 +00:00
Chris Lattner
c8e1741bb9 rename getConstantStringLength -> GetConstantStringInfo. Make it return
the start index of the array as well as the length.  No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35703 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-06 22:54:17 +00:00
Chris Lattner
4802d90ca8 implement Transforms/InstCombine/malloc2.ll and PR1313
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35700 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-06 18:57:34 +00:00
Chris Lattner
4913bf47fd Fix Transforms/GlobalOpt/2007-04-05-Crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35689 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-05 21:09:42 +00:00
Chris Lattner
1984a32867 Use a worklist-driven algorithm instead of a recursive one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35680 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-05 01:27:02 +00:00
Dale Johannesen
16ff304e2c Prevent transformConstExprCastCall from generating conversions that assert
elsewhere.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35668 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 19:16:42 +00:00
Jeff Cohen
86796bec50 Fix 2007-04-04-BadFoldBitcastIntoMalloc.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35665 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 16:58:57 +00:00
Duncan Sands
0091bf2439 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35655 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 06:42:45 +00:00
Chris Lattner
7305084156 Fix a bug I introduced with my patch yesterday which broke Qt (I converted
some constant exprs to apints).

Thanks to Anton for tracking down a small testcase that triggered this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35633 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 23:29:39 +00:00
Chris Lattner
01deb9d91c reinstate the previous two patches, with a bugfix :)
ldecod now passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35626 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 17:43:25 +00:00
Evan Cheng
d89f41e9bb Reverting back to 1.723. The last two commits broke JM (and possibily others) on ARM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 08:11:50 +00:00
Chris Lattner
aed01d1931 split some code out into a helper function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35615 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 05:11:24 +00:00
Chris Lattner
01d8c107ac Split a whole ton of code out of visitICmpInst into visitICmpInstWithInstAndIntCst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35614 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 04:46:52 +00:00
Chris Lattner
44ad43033e Fix PR1253 and xor2.ll:test[01]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35612 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 01:47:41 +00:00
Chris Lattner
1d31290634 allow -1 strides to reuse "1" strides.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35607 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 22:51:58 +00:00
Zhou Sheng
4a1822a6d8 1. Make use of APInt operation instead of using ConstantExpr::getXXX.
2. Use cheaper APInt methods.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35594 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 13:45:30 +00:00
Zhou Sheng
4351c649b2 Use uint32_t for bitwidth instead of unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35593 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 08:20:41 +00:00
Chris Lattner
1ebd89eb6b Pass the type of the store access, not the type of the store, into the
target hook.  This allows us to codegen a loop as:

LBB1_1: @cond_next
        mov r2, #0
        str r2, [r0, +r3, lsl #2]
        add r3, r3, #1
        cmn r3, #1
        bne LBB1_1      @cond_next

instead of:

LBB1_1: @cond_next
        mov r2, #0
        str r2, [r0], #+4
        add r3, r3, #1
        cmn r3, #1
        bne LBB1_1      @cond_next

This looks the same, but has one fewer induction variable (and therefore,
one fewer register) live in the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35592 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 06:34:44 +00:00
Chris Lattner
cd1d6d5b03 Wrap long line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35588 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 05:48:58 +00:00
Chris Lattner
acf4e074a9 use more obvious function name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35587 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 05:42:22 +00:00
Chris Lattner
5c6e2db0c4 simplify (x+c)^signbit as (x+c+signbit), pointed out by PR1288. This implements
test/Transforms/InstCombine/xor.ll:test28


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35584 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 05:36:22 +00:00
Chris Lattner
c995123182 reduce use of std::set
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35576 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 01:44:59 +00:00
Chris Lattner
d9c3a0d7cc Various passes before isel split edges and do other CFG-restructuring changes.
isel has its own particular features that it wants in the CFG, in order to
reduce the number of times a constant is computed, etc.  Make sure that we
clean up the CFG before doing any other things for isel.  Doing so can
dramatically reduce the number of split edges and reduce the number of
places that constants get computed.  For example, this shrinks
CodeGen/Generic/phi-immediate-factoring.ll from 44 to 37 instructions on X86,
and from 21 to 17 MBB's in the output.  This is primarily a code size win,
not a performance win.

This implements CodeGen/Generic/phi-immediate-factoring.ll and PR1296.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35575 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 01:35:34 +00:00
Chris Lattner
fe35555d09 print the type of an inserted IV in -debug mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35563 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 22:21:39 +00:00
Chris Lattner
55fc8c4c39 simplify this code, make it work for ap ints
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35561 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 20:57:36 +00:00
Zhou Sheng
3a507fda84 Avoid unnecessary APInt construction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35555 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 17:13:37 +00:00
Reid Spencer
e9391fd9b5 For PR1297:
Support overloaded intrinsics bswap, ctpop, cttz, ctlz.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35547 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 07:35:23 +00:00
Chris Lattner
6abbdf90dd Fix InstCombine/2007-03-31-InfiniteLoop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35536 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 05:36:37 +00:00
Chris Lattner
dbe0deca33 Split the sdisel code munging stuff out into its own opt-pass, CodeGenPrepare.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35528 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-31 04:06:36 +00:00
Zhou Sheng
1c5d163634 Delete dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35525 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-31 02:50:26 +00:00
Zhou Sheng
b9cb95f8e3 Use APInt operators to calculate the carry bits, remove this loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35524 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-31 02:38:39 +00:00
Zhou Sheng
302748dd30 Make sure the use of ConstantInt::getZExtValue() for shift amount safe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35510 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-30 17:20:39 +00:00
Zhou Sheng
0e2d3ac0f8 1. Make sure the use of ConstantInt::getZExtValue() for getting shift
amount is safe.
2. Use new method on ConstantInt instead of (? :) operator.
3. Use new method uge() on ConstantInt to simplify codes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35505 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-30 09:29:48 +00:00
Zhou Sheng
90b9681886 Use APInt operation instead of ConstantExpr::getXX.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35503 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-30 05:45:18 +00:00
Zhou Sheng
290bec5c15 1. Make more use of APInt::getHighBitsSet/getLowBitsSet.
2. Let APInt variable do the binary operation stuff instead of using
   ConstantExpr::getXXX.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35450 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 08:15:12 +00:00
Zhou Sheng
d48653a3ab Clean up some codes in InstCombiner::SimplifyDemandedBits().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35446 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 04:45:55 +00:00
Zhou Sheng
01542f3d80 Clean up codes in InstCombiner::SimplifyDemandedBits():
1. Line out nested call of APInt::zext/trunc.
2. Make more use of APInt::getHighBitsSet/getLowBitsSet.
3. Use APInt[] operator instead of expression like "APIntVal & SignBit".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35444 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 02:26:30 +00:00
Zhou Sheng
97b52c260f 1. Make the APInt variable do the binary operation stuff if possible
instead of using ConstantExpr::getXX.
2. Use constant reference to APInt if possible instead of expensive
   APInt copy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35443 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 01:57:21 +00:00
Zhou Sheng
34a4b38cbd Avoid unnecessary APInt construction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35431 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 17:38:21 +00:00
Zhou Sheng
e9e03f6b76 1. Make more use of getLowBitsSet/getHighBitsSet.
2. Use APInt[] instead of "X & SignBit".
3. Clean up some codes.
4. Make the expression like "ShiftAmt = ShiftAmtC->getZExtValue()" safe.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35424 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 15:02:20 +00:00
Zhou Sheng
e82fca09bf 1. Make more use of getLowBitsSet/getHighBitsSet.
2. Make the APInt value do the zext/trunc stuff instead of using
   ConstantExpr::getZExt().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35422 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 09:19:01 +00:00
Zhou Sheng
4acf155af3 Use UnknownBIts[BitWidth-1] instead of UnknownBIts & SignBits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 05:15:57 +00:00
Zhou Sheng
b32c00603b Remove unused APInt variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35414 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 03:02:21 +00:00
Zhou Sheng
aa305ab5e8 Clean up codes in ComputeMaskedBits():
1. Line out nested use of zext/trunc.
2. Make more use of getHighBitsSet/getLowBitsSet.
3. Use APInt[] != 0 instead of "(APInt & SignBit) != 0".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35408 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 02:19:03 +00:00
Reid Spencer
35c3885ba1 For PR1280:
When converting an add/xor/and triplet into a trunc/sext, only do so if the
intermediate integer type is a bitwidth that the targets can handle.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35400 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 01:36:16 +00:00
Evan Cheng
c7baf687ba Unbreaks non-debug builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35383 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-27 16:44:48 +00:00
Reid Spencer
6eb0d99f5f Implement some minor review feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35373 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 23:58:26 +00:00
Reid Spencer
68d27cf84e For PR1271:
Fix another incorrectly converted shift mask.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35371 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 23:45:51 +00:00
Devang Patel
d64d3a1d28 Reduce malloc/free traffic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35370 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 23:19:29 +00:00
Chris Lattner
0e5444bb20 eliminate use of std::set
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35361 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 20:40:50 +00:00
Reid Spencer
a9b8101333 Get better debug output by having modified instructions print both the
original and new instruction. A slight performance hit with ostringstream
but it is only for debug.
Also, clean up an uninitialized variable warning noticed in a release build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35358 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 17:44:01 +00:00
Reid Spencer
d5e30f0a01 Get the number of bits to set in a mask correct for a shl/lshr transform.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35357 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 17:18:58 +00:00
Reid Spencer
1be1284fe6 For PR1271:
Fix SingleSource/Regression/C/2003-05-21-UnionBitFields.c by changing a
getHighBitsSet call to getLowBitsSet call that was incorrectly converted
from the original lshr constant expression.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35348 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 05:25:00 +00:00
Dale Johannesen
da91f49751 Look through bitcast when finding IVs. (Chris' patch really.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35347 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 03:01:27 +00:00
Reid Spencer
55702aaa52 For PR1271:
Remove a use of getLowBitsSet that caused the mask used for replacement of
shl/lshr pairs with an AND instruction to be computed incorrectly. Its not
clear exactly why this is the case. This solves the disappearing shifts
problem, but it doesn't fix Regression/C/2003-05-21-UnionBitFields. It
seems there is more going on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35342 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 21:11:44 +00:00
Chris Lattner
db9654e284 implement Transforms/InstCombine/cast2.ll:test3 and PR1263
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35341 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 20:43:09 +00:00