1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

3343 Commits

Author SHA1 Message Date
Dan Gohman
a97484da91 Use IntrinsicInst to test for prefetch instructions, which is ever so
slightly nicer than using CallInst with an extra check; thanks Chris.

llvm-svn: 36743
2007-05-04 14:59:09 +00:00
Dan Gohman
e4d5ae9fcd Allow strength reduction to make use of addressing modes for the
address operand in a prefetch intrinsic.

llvm-svn: 36713
2007-05-03 23:20:33 +00:00
Devang Patel
cd45427a87 Drop 'const'
llvm-svn: 36662
2007-05-03 01:11:54 +00:00
Devang Patel
8ee9065162 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.

llvm-svn: 36652
2007-05-02 21:39:20 +00:00
Lauro Ramos Venancio
57d03e112b Fix build error.
llvm-svn: 36648
2007-05-02 20:37:47 +00:00
Devang Patel
38a66bc82e Do not use typeinfo to identify pass in pass manager.
llvm-svn: 36632
2007-05-01 21:15:47 +00:00
Anton Korobeynikov
cb2004f82c Implement review feedback
llvm-svn: 36564
2007-04-29 18:02:48 +00:00
Anton Korobeynikov
45162c6dad Implement review feedback. Aliasees can be either GlobalValue's or
bitcasts of them.

llvm-svn: 36537
2007-04-28 13:45:00 +00:00
Chris Lattner
5cb586acf5 fix a bug triggered by 403.gcc
llvm-svn: 36527
2007-04-28 05:27:36 +00:00
Chris Lattner
13b1e24f41 Fix several latent bugs in EmitGEPOffset that didn't manifest with its
previous clients.  This fixes MallocBench/gs

llvm-svn: 36525
2007-04-28 04:52:43 +00:00
Chris Lattner
22d3205e80 uhn zap cvs
llvm-svn: 36523
2007-04-28 03:50:56 +00:00
Chris Lattner
56ac7ba950 Implement PR1345 and Transforms/InstCombine/bitcast-gep.ll
llvm-svn: 36521
2007-04-28 00:57:34 +00:00
Chris Lattner
e0fe3b5c35 refactor some code relating to pointer cast xforms, pulling it out of the codepath
for unrelated casts.

llvm-svn: 36511
2007-04-27 17:44:50 +00:00
Zhou Sheng
8c150f133c Using APInt more efficiently.
llvm-svn: 36475
2007-04-26 16:42:07 +00:00
Devang Patel
e5765bd115 Mem2Reg does not need TargetData.
llvm-svn: 36444
2007-04-25 18:32:35 +00:00
Devang Patel
b6ef7bc5d9 Remove unused function argument.
llvm-svn: 36441
2007-04-25 17:15:20 +00:00
Anton Korobeynikov
25dc9a61cb Implement aliases. This fixes PR1017 and it's dependent bugs. CFE part
will follow.

llvm-svn: 36435
2007-04-25 14:27:10 +00:00
Chris Lattner
e0e5106141 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

llvm-svn: 36429
2007-04-25 06:40:51 +00:00
Chris Lattner
cf27f9705f refactor the SROA code out into its own method, no functionality change.
llvm-svn: 36426
2007-04-25 05:02:56 +00:00
Owen Anderson
d0af582609 Undo my previous changes. Since my approach to this problem is being revised,
this approach is no longer appropriate.

llvm-svn: 36421
2007-04-25 04:18:54 +00:00
Devang Patel
938e0db5e3 Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048376.html

llvm-svn: 36417
2007-04-25 00:37:04 +00:00
Owen Anderson
df3ece8561 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.

llvm-svn: 36392
2007-04-24 06:40:39 +00:00
Devang Patel
6a9016dcf7 Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048333.html

llvm-svn: 36380
2007-04-23 22:42:03 +00:00
Owen Anderson
2be28af998 Make PredicateSimplifier not use DominatorTree.
llvm-svn: 36300
2007-04-21 07:38:12 +00:00
Owen Anderson
9813f7fa80 Fix a comment.
llvm-svn: 36299
2007-04-21 07:12:44 +00:00
Jeff Cohen
2afa206eb3 Comment out usage of write() for now.
llvm-svn: 36287
2007-04-20 22:40:10 +00:00
Devang Patel
3c304ecdc9 Avoid recursion.
llvm-svn: 36272
2007-04-20 20:04:37 +00:00
Owen Anderson
41b527b75f Move more passes to using ETForest instead of DominatorTree.
llvm-svn: 36271
2007-04-20 06:27:13 +00:00
Zhou Sheng
9339daf407 Make use of ConstantInt::isZero instead of ConstantInt::isNullValue.
llvm-svn: 36261
2007-04-19 05:39:12 +00:00
Zhou Sheng
2cb77f2d6c Make the operations of APInt variables more efficient.
llvm-svn: 36260
2007-04-19 05:35:00 +00:00
Evan Cheng
91e0637ed3 Revert Owen's last check-in. This is breaking Mac OS X / PPC llvm-gcc bootstrap.
llvm-svn: 36258
2007-04-18 22:39:00 +00:00
Owen Anderson
16d1fd6ec8 Revert changes that caused breakage.
llvm-svn: 36255
2007-04-18 06:46:57 +00:00
Owen Anderson
781cbecd34 Switch more uses of DominatorTree over to ETForest.
llvm-svn: 36254
2007-04-18 05:43:13 +00:00
Owen Anderson
c3aa967684 Use ETForest instead of DominatorTree.
llvm-svn: 36252
2007-04-18 05:25:43 +00:00
Owen Anderson
c07f29d206 Use ETForest instead of DominatorTree.
llvm-svn: 36249
2007-04-18 04:55:33 +00:00
Owen Anderson
d8bb3aca7b Use new ETForest accessor.
llvm-svn: 36248
2007-04-18 04:46:35 +00:00
Owen Anderson
909895b564 Use ETForest instead of DominatorTree.
llvm-svn: 36247
2007-04-18 04:39:32 +00:00
Dan Gohman
a7e1f3c85b Spell doFinalization right, so that it is a proper virtual override and
gets called.

llvm-svn: 36208
2007-04-17 18:21:36 +00:00
Chris Lattner
8e28e7654d remove use of BasicBlock::getNext
llvm-svn: 36205
2007-04-17 18:09:47 +00:00
Chris Lattner
d503b61318 remove use of BasicBlock::getNext
llvm-svn: 36202
2007-04-17 17:54:12 +00:00
Chris Lattner
e5d747e0be eliminate use of Instruction::getNext()
llvm-svn: 36200
2007-04-17 17:51:03 +00:00
Chris Lattner
7b6a5d7956 remove use of Instruction::getNext
llvm-svn: 36199
2007-04-17 17:47:54 +00:00
Devang Patel
7d868316fd Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070416/047888.html

llvm-svn: 36182
2007-04-16 23:03:45 +00:00
Anton Korobeynikov
f3e62a428a Removed tabs everywhere except autogenerated & external files. Add make
target for tabs checking.

llvm-svn: 36146
2007-04-16 18:10:23 +00:00
Chris Lattner
601aa5b489 Fix PR1335 and Transforms/Inline/2007-04-15-InlineEH.ll
llvm-svn: 36090
2007-04-15 21:38:06 +00:00
Owen Anderson
ea857029ea 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.

llvm-svn: 36063
2007-04-15 08:47:27 +00:00
Chris Lattner
798749cafe fix SimplifyLibCalls/IsDigit.ll
llvm-svn: 36047
2007-04-15 05:38:40 +00:00
Chris Lattner
fe00dd8315 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

llvm-svn: 36040
2007-04-15 01:02:18 +00:00
Chris Lattner
ecd0fda993 refactor some code, no functionality change.
llvm-svn: 36037
2007-04-15 00:07:55 +00:00
Chris Lattner
022c2bc0c3 fix long lines
llvm-svn: 36031
2007-04-14 23:32:02 +00:00
Chris Lattner
9764a3cf09 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

llvm-svn: 36025
2007-04-14 23:02:14 +00:00
Chris Lattner
3553a131d0 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

llvm-svn: 36020
2007-04-14 22:29:23 +00:00
Chris Lattner
7928216e38 avoid copying sets and vectors around.
llvm-svn: 36017
2007-04-14 22:10:17 +00:00
Chris Lattner
3cebebfdd4 avoid iterator invalidation.
llvm-svn: 36002
2007-04-14 18:06:52 +00:00
Jeff Cohen
6e724c5338 An even better fix.
llvm-svn: 35998
2007-04-14 17:18:29 +00:00
Jeff Cohen
114799eab9 Fix recent regression that broke several llvm-tests.
llvm-svn: 35996
2007-04-14 16:55:19 +00:00
Chris Lattner
a283acb406 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

llvm-svn: 35984
2007-04-14 01:17:48 +00:00
Chris Lattner
25f2c932b7 in addition to merging, constantmerge should also delete trivially dead globals,
in order to clean up after simplifylibcalls.

llvm-svn: 35982
2007-04-14 01:11:54 +00:00
Chris Lattner
6f64f54168 Implement PR1201 and test/Transforms/InstCombine/malloc-free-delete.ll
llvm-svn: 35981
2007-04-14 00:20:02 +00:00
Chris Lattner
b97ff21db2 use an accessor to simplify code.
llvm-svn: 35979
2007-04-14 00:17:39 +00:00
Chris Lattner
8477dd1722 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 :)

llvm-svn: 35972
2007-04-13 20:42:26 +00:00
Chris Lattner
bc03b6c341 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

llvm-svn: 35970
2007-04-13 20:30:56 +00:00
Devang Patel
d86d04983a Remove use of SlowOperationInformer.
llvm-svn: 35967
2007-04-13 18:58:18 +00:00
Devang Patel
d01bb17f76 Undo previous check-in.
llvm-svn: 35966
2007-04-13 18:35:15 +00:00
Devang Patel
bfd8480bad Hello uses LLVMSupport.a (SlowerOperationInformer)
llvm-svn: 35965
2007-04-13 18:28:23 +00:00
Lauro Ramos Venancio
a76c2806de Implement the "thread_local" keyword.
llvm-svn: 35950
2007-04-12 18:32:50 +00:00
Reid Spencer
2afe5c8354 Build Hello by default so it can be used in test cases.
llvm-svn: 35922
2007-04-11 21:03:37 +00:00
Chris Lattner
f7451ea3c2 Fix Transforms/ScalarRepl/union-pointer.ll
llvm-svn: 35906
2007-04-11 15:45:25 +00:00
Chris Lattner
27a80589de 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]

llvm-svn: 35891
2007-04-11 06:57:46 +00:00
Chris Lattner
b659c04f13 Simplify some comparisons to arithmetic, this implements:
Transforms/InstCombine/icmp.ll

llvm-svn: 35890
2007-04-11 06:53:04 +00:00
Chris Lattner
50a7c8f34e canonicalize (x <u 2147483648) -> (x >s -1) and (x >u 2147483647) -> (x <s 0)
llvm-svn: 35886
2007-04-11 06:12:58 +00:00
Chris Lattner
cbd4a7e79c 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.

llvm-svn: 35885
2007-04-11 05:45:39 +00:00
Chris Lattner
c7c7a4712e fix a regression introduced by my last patch.
llvm-svn: 35879
2007-04-11 03:27:24 +00:00
Chris Lattner
4ea7a156ba 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 :)

llvm-svn: 35875
2007-04-11 00:57:54 +00:00
Chris Lattner
fe1860b138 Strengthen the boundary conditions of this fold, implementing
InstCombine/set.ll:test25

llvm-svn: 35852
2007-04-09 23:52:13 +00:00
Owen Anderson
5d0148ae7c Re-constify things that don't break the build. Last patch in this
series, I promise.

llvm-svn: 35848
2007-04-09 23:38:18 +00:00
Chris Lattner
78fffcb81b eliminate the last uses of some TLI methods.
llvm-svn: 35844
2007-04-09 23:29:07 +00:00
Owen Anderson
94e3511ef6 Unconst-ify stuff that broke the build.
llvm-svn: 35843
2007-04-09 23:08:26 +00:00
Owen Anderson
3d132f812a Const-ify some parameters, and some cosmetic cleanups. No functionality
change.

llvm-svn: 35842
2007-04-09 22:54:50 +00:00
Owen Anderson
148566d2e3 Tabs -> Spaces
llvm-svn: 35841
2007-04-09 22:31:43 +00:00
Owen Anderson
6f5fe179cc Improve some _slow_ behavior introduced in my patches the last few days.
llvm-svn: 35839
2007-04-09 22:25:09 +00:00
Chris Lattner
87c89cafb2 switch LSR to use isLegalAddressingMode instead of other simpler hooks
llvm-svn: 35837
2007-04-09 22:20:14 +00:00
Devang Patel
70205cceea Check _all_ PHINodes.
llvm-svn: 35836
2007-04-09 22:20:10 +00:00
Devang Patel
5392489e86 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.

llvm-svn: 35833
2007-04-09 21:40:43 +00:00
Devang Patel
cdea453adb Preserve canonical loop form.
llvm-svn: 35829
2007-04-09 20:19:46 +00:00
Reid Spencer
60da7b09e7 Don't link against System or Support library. These things will already
be in the opt tool.

llvm-svn: 35827
2007-04-09 19:17:47 +00:00
Devang Patel
9263a797b3 Do not create new pre-header. Reuse original pre-header.
llvm-svn: 35825
2007-04-09 19:04:21 +00:00
Devang Patel
e038420dc6 Simpler for() loops.
llvm-svn: 35822
2007-04-09 17:09:13 +00:00
Devang Patel
dd269ce747 Fix future bug. Of course, Chris spotted this.
Handle Argument or Undef as an incoming PHI value.

llvm-svn: 35821
2007-04-09 16:41:46 +00:00
Devang Patel
ba5018aaff More cosmetic changes.
llvm-svn: 35820
2007-04-09 16:21:29 +00:00
Devang Patel
f66f3dd962 Only cosmetic changes. Zero functionality Change.
llvm-svn: 35819
2007-04-09 16:11:48 +00:00
Chris Lattner
218d43af10 Fix PR1304 and Transforms/InstCombine/2007-04-08-SingleEltVectorCrash.ll
llvm-svn: 35792
2007-04-09 01:37:55 +00:00
Chris Lattner
b3d105a4f9 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 :)

llvm-svn: 35788
2007-04-09 01:11:16 +00:00
Owen Anderson
f9a432a613 Cleanup some from my DomSet-removal changes. Add a new
isReachableFromEntry
test to ETForest to factor a common test out of code.

llvm-svn: 35786
2007-04-09 00:52:49 +00:00
Chris Lattner
4ed32d0891 Fix a typo that broke SimplifyLibCalls/SPrintF.ll (pr1315)
llvm-svn: 35768
2007-04-08 18:11:26 +00:00
Chris Lattner
1a1b798eb5 reenable this xform, whoops :)
llvm-svn: 35765
2007-04-08 08:01:49 +00:00
Chris Lattner
1760b42378 Fix regression on Instcombine/apint-or2.ll
llvm-svn: 35763
2007-04-08 07:55:22 +00:00
Chris Lattner
d435e0bfd2 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

llvm-svn: 35760
2007-04-08 07:47:01 +00:00
Chris Lattner
34464bdf2b implement a fixme: move optimizations for fwrite out of fputs into a new
fwrite optimizer.

llvm-svn: 35758
2007-04-08 07:00:35 +00:00
Nick Lewycky
71592d1ef2 Remove DominatorSet usage from LoopSimplify. Patch from Owen Anderson.
llvm-svn: 35757
2007-04-08 01:04:30 +00:00
Chris Lattner
16fe035aa4 Significantly simplify the clients of GetConstantStringInfo, by having it
just return the string itself.

llvm-svn: 35755
2007-04-07 21:58:02 +00:00
Chris Lattner
5b3be230d4 Fix problems in the sprintf optimizer
llvm-svn: 35754
2007-04-07 21:17:51 +00:00
Chris Lattner
99a7ea0b00 Change CastToCStr to take a pointer instead of a reference.
Fix some miscompilations in fprintf optimizer.

llvm-svn: 35753
2007-04-07 21:04:50 +00:00
Chris Lattner
fcc6fe0a9c Fix an off-by-one error that broke Prolangs/deriv2 with llc on x86
and Prolangs-C/cdecl

llvm-svn: 35749
2007-04-07 20:19:08 +00:00
Owen Anderson
7cf9d12f2e 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.

llvm-svn: 35741
2007-04-07 18:23:27 +00:00
Nick Lewycky
e6cb3e2433 Add support for cast instructions.
llvm-svn: 35734
2007-04-07 15:48:32 +00:00
Owen Anderson
85b0e20f2a Completely purge DomSet. This is the (hopefully) final patch for PR1171.
llvm-svn: 35731
2007-04-07 07:17:27 +00:00
Owen Anderson
177b1a6aea Completely purge DomSet from LoopSimplify. This is part of the
continuing work on PR1171.

llvm-svn: 35730
2007-04-07 06:56:47 +00:00
Owen Anderson
e2add101a4 BreakCriticalEdges does still preserve DominatorTree.
llvm-svn: 35729
2007-04-07 05:57:09 +00:00
Owen Anderson
eb184ee17b Expunge DomSet from BreakCriticalEdges. This is part of the continuing
work for PR 1171.

llvm-svn: 35728
2007-04-07 05:49:29 +00:00
Owen Anderson
41bf50021d Expunge DomSet from CodeExtractor. This is part of the continuing work
on PR1171.

llvm-svn: 35726
2007-04-07 05:31:27 +00:00
Nick Lewycky
3e77af40ff Support NE inequality in ValueRanges.
llvm-svn: 35724
2007-04-07 04:49:12 +00:00
Owen Anderson
54c7efee4d Expunge a bunch of uses of DomSet from LoopSimplify. Many more remain.
This is the beginning of work for PR1171.

llvm-svn: 35720
2007-04-07 04:37:14 +00:00
Nick Lewycky
7fbec59fb4 Cleanup. Refactor out the applying of value ranges to its own method.
llvm-svn: 35719
2007-04-07 03:36:51 +00:00
Nick Lewycky
80cf96b3f8 Use TargetData to find the size of a type.
llvm-svn: 35718
2007-04-07 03:16:12 +00:00
Nick Lewycky
3ddf638983 Strengthen icmp snuggling by doing 'compare-or-equal-to' to 'compare'
first and then range testing second.

llvm-svn: 35715
2007-04-07 02:30:14 +00:00
Devang Patel
562df7f986 Add loop rotation pass.
llvm-svn: 35714
2007-04-07 01:25:15 +00:00
Chris Lattner
dbf5d6cf68 fix a miscompilation in printf optimizer.
llvm-svn: 35713
2007-04-07 01:18:36 +00:00
Chris Lattner
9aa0d009c1 trunc to bool no longer compares against zero
llvm-svn: 35712
2007-04-07 01:03:46 +00:00
Chris Lattner
312c204869 cleanups for strlen optimizer
llvm-svn: 35711
2007-04-07 01:02:00 +00:00
Chris Lattner
5f27ea3613 Introduce a new ReplaceCallWith method, which simplifies a lot of code.
llvm-svn: 35710
2007-04-07 00:42:32 +00:00
Chris Lattner
fba13c72ef fixes for strcpy optimizer
llvm-svn: 35709
2007-04-07 00:26:18 +00:00
Chris Lattner
02ae7ab94f Fix bugs in strncmp.
llvm-svn: 35708
2007-04-07 00:06:57 +00:00
Chris Lattner
d8a16e67ab fix 3 miscompilations and several compielr crashes in strcmp optimizer.
llvm-svn: 35707
2007-04-07 00:01:51 +00:00
Chris Lattner
c61ff0afc0 Fix several nasty bugs in the strchr optimizer, this fixes
SimplifyLibCalls/2007-04-06-strchr-miscompile.ll and PR1307

llvm-svn: 35706
2007-04-06 23:38:55 +00:00
Chris Lattner
bfad67243a clean up strcat optimizer, no functionality change.
llvm-svn: 35704
2007-04-06 22:59:33 +00:00
Chris Lattner
d03767c332 rename getConstantStringLength -> GetConstantStringInfo. Make it return
the start index of the array as well as the length.  No functionality change.

llvm-svn: 35703
2007-04-06 22:54:17 +00:00
Chris Lattner
03c84be56b implement Transforms/InstCombine/malloc2.ll and PR1313
llvm-svn: 35700
2007-04-06 18:57:34 +00:00
Chris Lattner
19b9e90f9c Fix Transforms/GlobalOpt/2007-04-05-Crash.ll
llvm-svn: 35689
2007-04-05 21:09:42 +00:00
Chris Lattner
997967979f Use a worklist-driven algorithm instead of a recursive one.
llvm-svn: 35680
2007-04-05 01:27:02 +00:00
Dale Johannesen
fb15913194 Prevent transformConstExprCastCall from generating conversions that assert
elsewhere.

llvm-svn: 35668
2007-04-04 19:16:42 +00:00
Jeff Cohen
01d4afe6da Fix 2007-04-04-BadFoldBitcastIntoMalloc.ll
llvm-svn: 35665
2007-04-04 16:58:57 +00:00
Duncan Sands
de998e6599 Fix comment.
llvm-svn: 35655
2007-04-04 06:42:45 +00:00
Chris Lattner
974e931689 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!

llvm-svn: 35633
2007-04-03 23:29:39 +00:00
Chris Lattner
bfe18d29f9 reinstate the previous two patches, with a bugfix :)
ldecod now passes.

llvm-svn: 35626
2007-04-03 17:43:25 +00:00
Evan Cheng
e30cfe8e9e Reverting back to 1.723. The last two commits broke JM (and possibily others) on ARM.
llvm-svn: 35620
2007-04-03 08:11:50 +00:00
Chris Lattner
4302c8bcdb split some code out into a helper function
llvm-svn: 35615
2007-04-03 05:11:24 +00:00
Chris Lattner
23d58bde29 Split a whole ton of code out of visitICmpInst into visitICmpInstWithInstAndIntCst.
llvm-svn: 35614
2007-04-03 04:46:52 +00:00
Chris Lattner
9b66a372c8 Fix PR1253 and xor2.ll:test[01]
llvm-svn: 35612
2007-04-03 01:47:41 +00:00
Chris Lattner
3df2382275 allow -1 strides to reuse "1" strides.
llvm-svn: 35607
2007-04-02 22:51:58 +00:00
Zhou Sheng
98c161c290 1. Make use of APInt operation instead of using ConstantExpr::getXXX.
2. Use cheaper APInt methods.

llvm-svn: 35594
2007-04-02 13:45:30 +00:00
Zhou Sheng
47311533a7 Use uint32_t for bitwidth instead of unsigned.
llvm-svn: 35593
2007-04-02 08:20:41 +00:00
Chris Lattner
d7c96e25e4 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.

llvm-svn: 35592
2007-04-02 06:34:44 +00:00
Chris Lattner
aaf29d3b5e Wrap long line
llvm-svn: 35588
2007-04-02 05:48:58 +00:00
Chris Lattner
7208dd1001 use more obvious function name.
llvm-svn: 35587
2007-04-02 05:42:22 +00:00
Chris Lattner
35ece02bea simplify (x+c)^signbit as (x+c+signbit), pointed out by PR1288. This implements
test/Transforms/InstCombine/xor.ll:test28

llvm-svn: 35584
2007-04-02 05:36:22 +00:00
Chris Lattner
d59b6b3d90 reduce use of std::set
llvm-svn: 35576
2007-04-02 01:44:59 +00:00
Chris Lattner
2f94a80322 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.

llvm-svn: 35575
2007-04-02 01:35:34 +00:00
Chris Lattner
ac77daac29 print the type of an inserted IV in -debug mode.
llvm-svn: 35563
2007-04-01 22:21:39 +00:00
Chris Lattner
a66a97908c simplify this code, make it work for ap ints
llvm-svn: 35561
2007-04-01 20:57:36 +00:00
Zhou Sheng
8b2b6b9e36 Avoid unnecessary APInt construction.
llvm-svn: 35555
2007-04-01 17:13:37 +00:00
Reid Spencer
88fb617695 For PR1297:
Support overloaded intrinsics bswap, ctpop, cttz, ctlz.

llvm-svn: 35547
2007-04-01 07:35:23 +00:00
Chris Lattner
aa4b06bdae Fix InstCombine/2007-03-31-InfiniteLoop.ll
llvm-svn: 35536
2007-04-01 05:36:37 +00:00
Chris Lattner
579b1c63d5 Split the sdisel code munging stuff out into its own opt-pass, CodeGenPrepare.
llvm-svn: 35528
2007-03-31 04:06:36 +00:00
Zhou Sheng
967239685a Delete dead code.
llvm-svn: 35525
2007-03-31 02:50:26 +00:00
Zhou Sheng
ebf4c32f0b Use APInt operators to calculate the carry bits, remove this loop.
llvm-svn: 35524
2007-03-31 02:38:39 +00:00
Zhou Sheng
67bcf1cfb6 Make sure the use of ConstantInt::getZExtValue() for shift amount safe.
llvm-svn: 35510
2007-03-30 17:20:39 +00:00
Zhou Sheng
d667b5db0c 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.

llvm-svn: 35505
2007-03-30 09:29:48 +00:00
Zhou Sheng
382723d8b4 Use APInt operation instead of ConstantExpr::getXX.
llvm-svn: 35503
2007-03-30 05:45:18 +00:00
Zhou Sheng
ac2b833c7a 1. Make more use of APInt::getHighBitsSet/getLowBitsSet.
2. Let APInt variable do the binary operation stuff instead of using
   ConstantExpr::getXXX.

llvm-svn: 35450
2007-03-29 08:15:12 +00:00
Zhou Sheng
684c2133f2 Clean up some codes in InstCombiner::SimplifyDemandedBits().
llvm-svn: 35446
2007-03-29 04:45:55 +00:00
Zhou Sheng
067efd7806 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".

llvm-svn: 35444
2007-03-29 02:26:30 +00:00
Zhou Sheng
74db84591c 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.

llvm-svn: 35443
2007-03-29 01:57:21 +00:00
Zhou Sheng
a098617383 Avoid unnecessary APInt construction.
llvm-svn: 35431
2007-03-28 17:38:21 +00:00
Zhou Sheng
8fecc8c3a0 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.

llvm-svn: 35424
2007-03-28 15:02:20 +00:00
Zhou Sheng
cf7d99a731 1. Make more use of getLowBitsSet/getHighBitsSet.
2. Make the APInt value do the zext/trunc stuff instead of using
   ConstantExpr::getZExt().

llvm-svn: 35422
2007-03-28 09:19:01 +00:00
Zhou Sheng
2dc7cf0114 Use UnknownBIts[BitWidth-1] instead of UnknownBIts & SignBits.
llvm-svn: 35418
2007-03-28 05:15:57 +00:00
Zhou Sheng
e43a68551e Remove unused APInt variable.
llvm-svn: 35414
2007-03-28 03:02:21 +00:00
Zhou Sheng
7245616070 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".

llvm-svn: 35408
2007-03-28 02:19:03 +00:00
Reid Spencer
3b614f9dad 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.

llvm-svn: 35400
2007-03-28 01:36:16 +00:00
Evan Cheng
a23cc41b11 Unbreaks non-debug builds.
llvm-svn: 35383
2007-03-27 16:44:48 +00:00
Reid Spencer
e4b331a4f2 Implement some minor review feedback.
llvm-svn: 35373
2007-03-26 23:58:26 +00:00
Reid Spencer
0cdfe48fc8 For PR1271:
Fix another incorrectly converted shift mask.

llvm-svn: 35371
2007-03-26 23:45:51 +00:00
Devang Patel
c2708c8ccb Reduce malloc/free traffic.
llvm-svn: 35370
2007-03-26 23:19:29 +00:00
Chris Lattner
16700ef424 eliminate use of std::set
llvm-svn: 35361
2007-03-26 20:40:50 +00:00
Reid Spencer
73d778edb7 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.

llvm-svn: 35358
2007-03-26 17:44:01 +00:00
Reid Spencer
3fea170ecd Get the number of bits to set in a mask correct for a shl/lshr transform.
llvm-svn: 35357
2007-03-26 17:18:58 +00:00
Reid Spencer
a6a4dbd24e 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.

llvm-svn: 35348
2007-03-26 05:25:00 +00:00
Dale Johannesen
43fc14d6e4 Look through bitcast when finding IVs. (Chris' patch really.)
llvm-svn: 35347
2007-03-26 03:01:27 +00:00
Reid Spencer
4d3d7d0f2a 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.

llvm-svn: 35342
2007-03-25 21:11:44 +00:00
Chris Lattner
26cfd91db8 implement Transforms/InstCombine/cast2.ll:test3 and PR1263
llvm-svn: 35341
2007-03-25 20:43:09 +00:00
Reid Spencer
1677543a3a Some cleanup from review:
* Don't assume shift amounts are <= 64 bits
* Avoid creating an extra APInt in SubOne and AddOne by using -- and ++
* Add another use of getLowBitsSet
* Convert a series of if statements to a switch

llvm-svn: 35339
2007-03-25 19:55:33 +00:00
Reid Spencer
8449e5fa0e Refactor several ConstantExpr::getXXX calls with ConstantInt arguments
using the facilities of APInt. While this duplicates a tiny fraction of
the constant folding code, it also makes the code easier to read and
avoids large ConstantExpr overhead for simple, known computations.

llvm-svn: 35335
2007-03-25 05:33:51 +00:00
Zhou Sheng
3312a86598 1. Avoid unnecessary APInt construction if possible.
2. Use isStrictlyPositive() instead of isPositive() in two places where
   they need APInt value > 0 not only >=0.

llvm-svn: 35333
2007-03-25 05:01:29 +00:00
Reid Spencer
e601991a5e Make more uses of getHighBitsSet and get rid of some pointless & of an
APInt with its type mask.

llvm-svn: 35325
2007-03-25 04:26:16 +00:00
Reid Spencer
676eeb9c94 More APIntification:
* Convert the last use of a uint64_t that should have been an APInt.
* Change ComputeMaskedBits to have a const reference argument for the Mask
  so that recursions don't cause unneeded temporaries. This causes temps
  to be needed in other places (where the mask has to change) but this
  change optimizes for the recursion which is more frequent.
* Remove two instances of &ing a Mask with getAllOnesValue. Its not
  needed any more because APInt is accurate in its bit computations.
* Start using the getLowBitsSet and getHighBits set methods on APInt
  instead of shifting. This makes it more clear in the code what is
  going on.

llvm-svn: 35321
2007-03-25 02:03:12 +00:00
Chris Lattner
3f71a6b498 fix a regression on vector or instructions.
llvm-svn: 35314
2007-03-24 23:56:43 +00:00
Zhou Sheng
ce8c7becec Make some codes more efficient.
llvm-svn: 35297
2007-03-24 15:34:37 +00:00
Reid Spencer
b03fc33244 For PR1205:
Convert some calls to ConstantInt::getZExtValue() into getValue() and
use APInt facilities in the subsequent computations.

llvm-svn: 35294
2007-03-24 00:42:08 +00:00
Reid Spencer
01d252add1 For PR1205:
* APIntify visitAdd and visitSelectInst
* Remove unused uint64_t versions of utility functions that have been
  replaced with APInt versions.
This completes most of the changes for APIntification of InstCombine. This
passes llvm-test and llvm/test/Transforms/InstCombine/APInt.

Patch by Zhou Sheng.

llvm-svn: 35287
2007-03-23 21:24:59 +00:00
Reid Spencer
da8ec61ec4 For PR1205:
APIntify visitDiv, visitMul and visitRem.

Patch by Zhou Sheng.

llvm-svn: 35283
2007-03-23 20:05:17 +00:00
Chris Lattner
04baffb0c5 switch AddReachableCodeToWorklist from being recursive to being iterative.
llvm-svn: 35282
2007-03-23 19:17:18 +00:00
Reid Spencer
1fd12cf9f6 For PR1205:
APIntify several utility functions supporting logical operators and shift
operators.

Patch by Zhou Sheng.

llvm-svn: 35281
2007-03-23 18:46:34 +00:00
Zhou Sheng
e706d8f56d Make the "KnownZero ^ TypeMask" computation just once.
llvm-svn: 35276
2007-03-23 03:13:21 +00:00
Zhou Sheng
6b7b4945f1 Simplify the code.
llvm-svn: 35275
2007-03-23 02:39:25 +00:00
Reid Spencer
9881580cec For PR1205:
APInt support for logical operators in visitAnd, visitOr, and visitXor.

Patch by Zhou Sheng.

llvm-svn: 35273
2007-03-22 22:19:58 +00:00
Reid Spencer
74288268d3 For PR1205:
* APIntify commonIntCastTransforms
* APIntify visitTrunc
* APIntify visitZExt

Patch by Zhou Sheng.

llvm-svn: 35271
2007-03-22 20:56:53 +00:00
Reid Spencer
b6c09a009e For PR1205:
* Re-enable the APInt version of MaskedValueIsZero.
* APIntify the Comput{Un}SignedMinMaxValuesFromKnownBits functions
* APIntify visitICmpInst.

llvm-svn: 35270
2007-03-22 20:36:03 +00:00
Dan Gohman
d0a0ea9916 Change uses of Function::front to Function::getEntryBlock for readability.
llvm-svn: 35265
2007-03-22 16:38:57 +00:00
Nick Lewycky
428523f51a Fix broken optimization disabled by a logic bug.
Analyze GEPs. If the indices are all zero, transfer whether the pointer is
known to be not null through the GEP.

Add a few more cases for xor and shift instructions.

llvm-svn: 35257
2007-03-22 02:02:51 +00:00
Reid Spencer
bdfbda05fb For PR1248:
* Fix some indentation and comments in InsertRangeTest
* Add an "IsSigned" parameter to AddWithOverflow and make it handle signed
  additions. Also, APIntify this function so it works with any bitwidth.
* For the icmp pred ([us]div %X, C1), C2 transforms, exit early if the
  div instruction's RHS is zero.
* Finally, for icmp pred (sdiv %X, C1), -C2, fix an off-by-one error. The
  HiBound needs to be incremented in order to get the range test correct.

llvm-svn: 35247
2007-03-21 23:19:50 +00:00
Dale Johannesen
3e422e3b49 do not share old induction variables when this would result in invalid
instructions (that would have to be split later)

llvm-svn: 35227
2007-03-20 21:54:54 +00:00
Jeff Cohen
8dea6ada6f Fix some VC++ warnings.
llvm-svn: 35224
2007-03-20 20:43:18 +00:00
Devang Patel
18146cf2a2 LoopSimplify::FindPHIToPartitionLoops()
Use ETForest instead of DominatorSet.

llvm-svn: 35221
2007-03-20 20:18:12 +00:00
Zhou Sheng
0ae1c9e1ad Simplify isHighOnes().
llvm-svn: 35211
2007-03-20 12:49:06 +00:00
Dale Johannesen
516d98c710 use types of loads and stores, not address, in CheckForIVReuse
llvm-svn: 35197
2007-03-20 00:47:50 +00:00
Reid Spencer
2f1ee85f90 Make isOneBitSet faster by using APInt::isPowerOf2. Thanks Chris.
llvm-svn: 35194
2007-03-20 00:16:52 +00:00
Reid Spencer
a792b71ab3 APIntify the isHighOnes utility function.
llvm-svn: 35190
2007-03-19 21:29:50 +00:00
Reid Spencer
4009f1eacb Implement isMaxValueMinusOne in terms of APInt instead of uint64_t.
Patch by Sheng Zhou.

llvm-svn: 35188
2007-03-19 21:10:28 +00:00
Reid Spencer
57a15f4445 Implement isMinValuePlusOne using facilities of APInt instead of uint64_t
Patch by Zhou Sheng.

llvm-svn: 35187
2007-03-19 21:08:07 +00:00
Reid Spencer
1985e3645b Implement isOneBitSet in terms of APInt::countPopulation.
llvm-svn: 35186
2007-03-19 21:04:43 +00:00
Reid Spencer
367a2917c0 1. Use APInt::getSignBit to reduce clutter (patch by Sheng Zhou)
2. Replace uses of the "isPositive" utility function with APInt::isPositive

llvm-svn: 35185
2007-03-19 20:58:18 +00:00
Reid Spencer
49ea42b719 Remove a redundant clause in an if statement.
Patch by Sheng Zhou.

llvm-svn: 35184
2007-03-19 20:47:50 +00:00
Chris Lattner
5f1d3ac7e4 fix ScalarRepl/2007-03-19-CanonicalizeMemcpy.ll
llvm-svn: 35169
2007-03-19 18:25:57 +00:00
Chris Lattner
5e2e3ddb7e implement the next chunk of SROA with memset/memcpy's of aggregates. This
implements Transforms/ScalarRepl/memset-aggregate-byte-leader.ll

llvm-svn: 35150
2007-03-19 00:16:43 +00:00
Nick Lewycky
2a51ea0c0e Clean up this code and fix subtract miscompile.
llvm-svn: 35146
2007-03-18 22:58:46 +00:00
Chris Lattner
adf7003452 Implement InstCombine/and-xor-merge.ll:test[12].
Rearrange some code to simplify it now that shifts are binops

llvm-svn: 35145
2007-03-18 22:51:34 +00:00
Nick Lewycky
41f13d431a Propagate ValueRanges across equality.
Add some more micro-optimizations: x * 0 = 0, a - x = a --> x = 0.

llvm-svn: 35138
2007-03-18 01:09:32 +00:00
Anton Korobeynikov
b34e09291b Silence warning
llvm-svn: 35137
2007-03-17 14:48:06 +00:00
Nick Lewycky
de44438e24 Add more comments and update to new asm syntax.
Add new micro-optimizations.

Add icmp predicate snuggling. Given %x ULT 4, "icmp ugt %x, 2" becomes
"icmp eq %x, 3". This doesn't apply in any non-trivial cases yet due to missing
support for NE values in ValueRanges.

llvm-svn: 35119
2007-03-16 02:37:39 +00:00
Zhou Sheng
5c6399dab7 ShiftAmt might equal to zero. Handle this situation.
llvm-svn: 35094
2007-03-14 09:07:33 +00:00
Zhou Sheng
4415c2647e Enable KnownZero/One.clear().
llvm-svn: 35093
2007-03-14 03:21:24 +00:00
Evan Cheng
bd964bd8eb Correct type info for isLegalAddressImmediate() check.
llvm-svn: 35086
2007-03-13 20:34:37 +00:00
Chris Lattner
efc2339bd7 ifdef out some dead code.
Fix PR1244 and Transforms/InstCombine/2007-03-13-CompareMerge.ll

llvm-svn: 35082
2007-03-13 14:27:42 +00:00
Zhou Sheng
7cf2811ab3 For expression like
"APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth)",
to handle ShiftAmt == BitWidth situation, use zextOrCopy() instead of
zext().

llvm-svn: 35080
2007-03-13 06:40:59 +00:00
Zhou Sheng
14cef9ec74 In APInt version ComputeMaskedBits():
1. Ensure VTy, KnownOne and KnownZero have same bitwidth.
  2. Make code more efficient.

llvm-svn: 35078
2007-03-13 02:23:10 +00:00
Evan Cheng
1fcdd7e1e5 Use new TargetLowering addressing modes hooks.
llvm-svn: 35072
2007-03-12 23:27:37 +00:00
Jeff Cohen
91930bc4d4 Unbreak VC++ build. Do not use identifiers starting with _ as they are reserved and
can collide with system defined names.  Windows defines _BB, for example.

llvm-svn: 35066
2007-03-12 17:56:27 +00:00
Reid Spencer
d59425085f Add an APInt version of SimplifyDemandedBits.
Patch by Zhou Sheng.

llvm-svn: 35064
2007-03-12 17:25:59 +00:00
Reid Spencer
b18f916bbe Add an APInt version of ShrinkDemandedConstant.
Patch by Zhou Sheng.

llvm-svn: 35063
2007-03-12 17:15:10 +00:00
Zhou Sheng
c8583ff888 Avoid to assert on "(KnownZero & KnownOne) == 0".
llvm-svn: 35062
2007-03-12 16:54:56 +00:00
Zhou Sheng
c9c53385b8 In function ComputeMaskedBits():
1. Replace getSignedMinValue() with getSignBit() for better code readability.
  2. Replace APIntOps::shl() with operator<<= for convenience.
  3. Make APInt construction more effective.

llvm-svn: 35060
2007-03-12 05:44:52 +00:00
Nick Lewycky
8a08bcfbe7 Add value ranges. Currently inefficient in both execution time and
optimization power.

llvm-svn: 35058
2007-03-10 18:12:48 +00:00
Anton Korobeynikov
0c2d312725 Use range tests in LowerSwitch, where possible
llvm-svn: 35057
2007-03-10 16:46:28 +00:00
Devang Patel
20b8163ad3 Remove dead comments.
llvm-svn: 35053
2007-03-09 23:41:03 +00:00
Devang Patel
8a26f4caa0 Avoid recursion. Use iterative algorithm for RenamePass().
llvm-svn: 35052
2007-03-09 23:39:14 +00:00
Devang Patel
ca60446cb4 Increment iterator now because IVUseShouldUsePostIncValue may remove
User from the list of I users.

llvm-svn: 35051
2007-03-09 21:19:53 +00:00
Zhou Sheng
acc59870f7 Fix a bug in function ComputeMaskedBits().
llvm-svn: 35027
2007-03-08 15:15:18 +00:00
Chris Lattner
66843dbef9 This appears correct, enable it so we can see perf changes on testers
llvm-svn: 35024
2007-03-08 07:03:55 +00:00
Chris Lattner
049f21257d Second half of PR1226. This is currently still disabled, until I have a chance to
do the correctness/performance analysis testing.

llvm-svn: 35023
2007-03-08 06:36:54 +00:00
Zhou Sheng
37cb2e2d53 Fix a bug in APIntified ComputeMaskedBits().
llvm-svn: 35022
2007-03-08 05:42:00 +00:00
Reid Spencer
c3f0724204 For PR1205:
Provide an APIntified version of MaskedValueIsZero. This will (temporarily)
cause a "defined but not used" message from the compiler. It will be used
in the next patch in this series.

Patch by Sheng Zhou.

llvm-svn: 35019
2007-03-08 01:52:58 +00:00
Reid Spencer
6a924d1a1d For PR1205:
Add a new ComputeMaskedBits function that is APIntified. We'll slowly
convert things over to use this version. When its all done, we'll remove
the existing version.

llvm-svn: 35018
2007-03-08 01:46:38 +00:00
Devang Patel
6a56e3c1a0 Now IndVarSimplify is a LoopPass.
llvm-svn: 35003
2007-03-07 06:39:01 +00:00
Devang Patel
16107bb71b Now LICM is a LoopPass.
llvm-svn: 35001
2007-03-07 04:41:30 +00:00
Devang Patel
3a24891f80 Now LoopUnroll is a LoopPass.
llvm-svn: 34996
2007-03-07 01:38:05 +00:00
Devang Patel
c35610b9f9 Now LoopUnswitch is a LoopPass.
llvm-svn: 34992
2007-03-07 00:26:10 +00:00
Devang Patel
0b82378a28 Now LoopStrengthReduce is a LoopPass.
llvm-svn: 34984
2007-03-06 21:14:09 +00:00
Reid Spencer
db1c09aef1 Remove an unnecessary if statement and adjust indentation.
llvm-svn: 34939
2007-03-05 23:36:13 +00:00
Chris Lattner
b0de2b2a9c This is the first major step of implementing PR1226. We now successfully
scalarrepl things down to elements, but mem2reg can't promote elements that
are memset/memcpy'd.  Until then, the code is disabled "0 &&".

llvm-svn: 34924
2007-03-05 07:52:57 +00:00