Commit Graph

3126 Commits

Author SHA1 Message Date
Chris Lattner 5ee4d0726a Fix Transforms/ScalarRepl/union-pointer.ll
llvm-svn: 35906
2007-04-11 15:45:25 +00:00
Chris Lattner 74ff60ff84 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 d0f7942e23 Simplify some comparisons to arithmetic, this implements:
Transforms/InstCombine/icmp.ll

llvm-svn: 35890
2007-04-11 06:53:04 +00:00
Chris Lattner 20f2372a7c 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 7ddbff090a 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 32104034f8 fix a regression introduced by my last patch.
llvm-svn: 35879
2007-04-11 03:27:24 +00:00
Chris Lattner daa012d1fb 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 467b69cabb 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 3c7867935e 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 3e9690f987 eliminate the last uses of some TLI methods.
llvm-svn: 35844
2007-04-09 23:29:07 +00:00
Owen Anderson f1ca1376d3 Unconst-ify stuff that broke the build.
llvm-svn: 35843
2007-04-09 23:08:26 +00:00
Owen Anderson 5917716146 Const-ify some parameters, and some cosmetic cleanups. No functionality
change.

llvm-svn: 35842
2007-04-09 22:54:50 +00:00
Owen Anderson e0ef5ac6bd Tabs -> Spaces
llvm-svn: 35841
2007-04-09 22:31:43 +00:00
Owen Anderson 83efbc84f7 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 780c009756 switch LSR to use isLegalAddressingMode instead of other simpler hooks
llvm-svn: 35837
2007-04-09 22:20:14 +00:00
Devang Patel bca0d57179 Check _all_ PHINodes.
llvm-svn: 35836
2007-04-09 22:20:10 +00:00
Devang Patel 8eb8eeada9 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 854197884b Preserve canonical loop form.
llvm-svn: 35829
2007-04-09 20:19:46 +00:00
Reid Spencer 8436cdfda2 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 b9af5747a5 Do not create new pre-header. Reuse original pre-header.
llvm-svn: 35825
2007-04-09 19:04:21 +00:00
Devang Patel 03d7ae3a74 Simpler for() loops.
llvm-svn: 35822
2007-04-09 17:09:13 +00:00
Devang Patel d6ba41e02d 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 b28a391a8d More cosmetic changes.
llvm-svn: 35820
2007-04-09 16:21:29 +00:00
Devang Patel 88bc2c6f82 Only cosmetic changes. Zero functionality Change.
llvm-svn: 35819
2007-04-09 16:11:48 +00:00
Chris Lattner a87c9f6114 Fix PR1304 and Transforms/InstCombine/2007-04-08-SingleEltVectorCrash.ll
llvm-svn: 35792
2007-04-09 01:37:55 +00:00
Chris Lattner 4ca9cbb170 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 ae39ca037a 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 aa8ad10c2f Fix a typo that broke SimplifyLibCalls/SPrintF.ll (pr1315)
llvm-svn: 35768
2007-04-08 18:11:26 +00:00
Chris Lattner c8d3788f71 reenable this xform, whoops :)
llvm-svn: 35765
2007-04-08 08:01:49 +00:00
Chris Lattner 7621a031d8 Fix regression on Instcombine/apint-or2.ll
llvm-svn: 35763
2007-04-08 07:55:22 +00:00
Chris Lattner 1150df9cc4 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 5717981e5d 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 e6c64466c7 Remove DominatorSet usage from LoopSimplify. Patch from Owen Anderson.
llvm-svn: 35757
2007-04-08 01:04:30 +00:00
Chris Lattner 182a945fb5 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 08c0b8b3c8 Fix problems in the sprintf optimizer
llvm-svn: 35754
2007-04-07 21:17:51 +00:00
Chris Lattner bed184cbcf 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 898d698d9f 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 f7ebea1b9f 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 d4f51a8ae3 Add support for cast instructions.
llvm-svn: 35734
2007-04-07 15:48:32 +00:00
Owen Anderson 8763ba1b88 Completely purge DomSet. This is the (hopefully) final patch for PR1171.
llvm-svn: 35731
2007-04-07 07:17:27 +00:00
Owen Anderson 706e97049d 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 d03a646f06 BreakCriticalEdges does still preserve DominatorTree.
llvm-svn: 35729
2007-04-07 05:57:09 +00:00
Owen Anderson b39d9ca902 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 f095bf3ac4 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 93f541057b Support NE inequality in ValueRanges.
llvm-svn: 35724
2007-04-07 04:49:12 +00:00
Owen Anderson 910419596e 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 3bb6de85d1 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 12d44abe0f Use TargetData to find the size of a type.
llvm-svn: 35718
2007-04-07 03:16:12 +00:00
Nick Lewycky eeb01b41ef 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 f42389ffe5 Add loop rotation pass.
llvm-svn: 35714
2007-04-07 01:25:15 +00:00
Chris Lattner 0f1509511e fix a miscompilation in printf optimizer.
llvm-svn: 35713
2007-04-07 01:18:36 +00:00
Chris Lattner 6a36d636e9 trunc to bool no longer compares against zero
llvm-svn: 35712
2007-04-07 01:03:46 +00:00
Chris Lattner e8829aa9dd cleanups for strlen optimizer
llvm-svn: 35711
2007-04-07 01:02:00 +00:00
Chris Lattner 485b6415b1 Introduce a new ReplaceCallWith method, which simplifies a lot of code.
llvm-svn: 35710
2007-04-07 00:42:32 +00:00
Chris Lattner 6a6c1f1c30 fixes for strcpy optimizer
llvm-svn: 35709
2007-04-07 00:26:18 +00:00
Chris Lattner f9ee647e86 Fix bugs in strncmp.
llvm-svn: 35708
2007-04-07 00:06:57 +00:00
Chris Lattner c9ccc30212 fix 3 miscompilations and several compielr crashes in strcmp optimizer.
llvm-svn: 35707
2007-04-07 00:01:51 +00:00
Chris Lattner 39f0bb9670 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 56b7fc7768 clean up strcat optimizer, no functionality change.
llvm-svn: 35704
2007-04-06 22:59:33 +00:00
Chris Lattner 9b2b8abd20 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 3dbe65f80a implement Transforms/InstCombine/malloc2.ll and PR1313
llvm-svn: 35700
2007-04-06 18:57:34 +00:00
Chris Lattner 1a9a760318 Fix Transforms/GlobalOpt/2007-04-05-Crash.ll
llvm-svn: 35689
2007-04-05 21:09:42 +00:00
Chris Lattner 108083edff Use a worklist-driven algorithm instead of a recursive one.
llvm-svn: 35680
2007-04-05 01:27:02 +00:00
Dale Johannesen 7c2001d014 Prevent transformConstExprCastCall from generating conversions that assert
elsewhere.

llvm-svn: 35668
2007-04-04 19:16:42 +00:00
Jeff Cohen 5a1c750f31 Fix 2007-04-04-BadFoldBitcastIntoMalloc.ll
llvm-svn: 35665
2007-04-04 16:58:57 +00:00
Duncan Sands f01a47c93c Fix comment.
llvm-svn: 35655
2007-04-04 06:42:45 +00:00
Chris Lattner e5bbb3cb1a 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 a74deafb13 reinstate the previous two patches, with a bugfix :)
ldecod now passes.

llvm-svn: 35626
2007-04-03 17:43:25 +00:00
Evan Cheng 7511fa280d 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 81e0707552 split some code out into a helper function
llvm-svn: 35615
2007-04-03 05:11:24 +00:00
Chris Lattner 64c764cebc Split a whole ton of code out of visitICmpInst into visitICmpInstWithInstAndIntCst.
llvm-svn: 35614
2007-04-03 04:46:52 +00:00
Chris Lattner 8b2ec5f506 Fix PR1253 and xor2.ll:test[01]
llvm-svn: 35612
2007-04-03 01:47:41 +00:00
Chris Lattner f3197a7d53 allow -1 strides to reuse "1" strides.
llvm-svn: 35607
2007-04-02 22:51:58 +00:00
Zhou Sheng 9bc8ab100d 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 56cda95658 Use uint32_t for bitwidth instead of unsigned.
llvm-svn: 35593
2007-04-02 08:20:41 +00:00
Chris Lattner 28e0e4e11e 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 9d5aacee92 Wrap long line
llvm-svn: 35588
2007-04-02 05:48:58 +00:00
Chris Lattner 50490d54f2 use more obvious function name.
llvm-svn: 35587
2007-04-02 05:42:22 +00:00
Chris Lattner b24acc7bee 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 b7b75145f1 reduce use of std::set
llvm-svn: 35576
2007-04-02 01:44:59 +00:00
Chris Lattner c3748562bd 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 8fe3cbe6bd print the type of an inserted IV in -debug mode.
llvm-svn: 35563
2007-04-01 22:21:39 +00:00
Chris Lattner c3eeb42809 simplify this code, make it work for ap ints
llvm-svn: 35561
2007-04-01 20:57:36 +00:00
Zhou Sheng 150f3bbab2 Avoid unnecessary APInt construction.
llvm-svn: 35555
2007-04-01 17:13:37 +00:00
Reid Spencer 6bba6c8143 For PR1297:
Support overloaded intrinsics bswap, ctpop, cttz, ctlz.

llvm-svn: 35547
2007-04-01 07:35:23 +00:00
Chris Lattner 0427799531 Fix InstCombine/2007-03-31-InfiniteLoop.ll
llvm-svn: 35536
2007-04-01 05:36:37 +00:00
Chris Lattner f2836d17b6 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 82c42284f4 Delete dead code.
llvm-svn: 35525
2007-03-31 02:50:26 +00:00
Zhou Sheng 4f16402e0d Use APInt operators to calculate the carry bits, remove this loop.
llvm-svn: 35524
2007-03-31 02:38:39 +00:00
Zhou Sheng fd28a33031 Make sure the use of ConstantInt::getZExtValue() for shift amount safe.
llvm-svn: 35510
2007-03-30 17:20:39 +00:00
Zhou Sheng b25806fa5f 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 5e60a4a6b0 Use APInt operation instead of ConstantExpr::getXX.
llvm-svn: 35503
2007-03-30 05:45:18 +00:00
Zhou Sheng b3a80b1d70 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 444af49cc0 Clean up some codes in InstCombiner::SimplifyDemandedBits().
llvm-svn: 35446
2007-03-29 04:45:55 +00:00
Zhou Sheng a4475575c0 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 4961cf1c06 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 117477e28b Avoid unnecessary APInt construction.
llvm-svn: 35431
2007-03-28 17:38:21 +00:00
Zhou Sheng 23f7a1c947 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 2777a31850 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 c2d3309b99 Use UnknownBIts[BitWidth-1] instead of UnknownBIts & SignBits.
llvm-svn: 35418
2007-03-28 05:15:57 +00:00