Commit Graph

1322 Commits

Author SHA1 Message Date
Andrew Lenharth
8ed4c47d70 The wrong parameter was being tested to deturmine i32 vs i64
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31431 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-03 22:45:50 +00:00
Chris Lattner
ffa0a9b7ea remove dead code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31398 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-03 01:34:58 +00:00
Reid Spencer
3ed469ccd7 For PR786:
Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting
fall out by removing unused variables. Remaining warnings have to do with
unused functions (I didn't want to delete code without review) and unused
variables in generated code. Maintainers should clean up the remaining
issues when they see them. All changes pass DejaGnu tests and Olden.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31380 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-02 20:25:50 +00:00
Reid Spencer
0a783f783c For PR950:
Replace the REM instruction with UREM, SREM and FREM.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31369 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-02 01:53:59 +00:00
Devang Patel
e0805a2d36 There can be more than one PHINode at the start of the block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31362 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-01 23:04:45 +00:00
Devang Patel
2c0565f8e0 Handle PHINode with only one incoming value.
This fixes http://llvm.org/bugs/show_bug.cgi?id=979


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31358 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-01 22:26:43 +00:00
Chris Lattner
9c08050ac7 Factor gep instructions through phi nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31346 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-01 07:43:41 +00:00
Chris Lattner
76c7314650 Turn a phi of many loads into a phi of the address and a single load of the
result.  This can significantly shrink code and exposes identities more
aggressively.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31344 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-01 07:13:54 +00:00
Chris Lattner
a90a24c623 Fix a bug in the previous patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31342 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-01 04:55:47 +00:00
Chris Lattner
7da52b295b Fold things like "phi [add (a,b), add(c,d)]" into two phi's and one add.
This triggers thousands of times on multisource.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31341 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-01 04:51:18 +00:00
Chris Lattner
0997fadc37 break edges more intelligently
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31257 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-28 06:45:33 +00:00
Chris Lattner
f6de8ad1a2 SplitCriticalEdge checks to see if an edge is critical, don't check twice
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31255 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-28 06:38:14 +00:00
Chris Lattner
1b9c8e73b5 prepare for a change I'm about to make
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31248 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-28 00:59:20 +00:00
Reid Spencer
811b0cbd6e Simplify code a bit by changing instances of:
InsertNewInstBefore(new CastInst(Val, ValTy, Val->GetName()), I)
into:
   InsertCastBefore(Val, ValTy, I)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31204 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-26 19:19:06 +00:00
Reid Spencer
1628cec4d7 For PR950:
Make necessary changes to support DIV -> [SUF]Div. This changes llvm to
have three division instructions: signed, unsigned, floating point. The
bytecode and assembler are bacwards compatible, however.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31195 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-26 06:15:43 +00:00
Nick Lewycky
7043d00750 Fix 2006-10-25-AddSetCC. A relational operator (like setlt) can never
produce an EQ property.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31193 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-26 02:35:18 +00:00
Nick Lewycky
e63bf95a32 Resurrect r1.25.
Fix and comment the "or", "and" and "xor" transformations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31189 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-25 23:48:24 +00:00
Chris Lattner
b67e8f2263 hide symbols properly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31184 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-25 21:14:31 +00:00
Chris Lattner
ae5d51c9c9 Fix Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31151 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-24 06:26:32 +00:00
Chris Lattner
ef2aa193d6 Revert back to r1.21, which was the last revision of predsimplify that
passes llvm-gcc bootstrap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31146 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-24 00:36:21 +00:00
Chris Lattner
ddaaa37487 Handle fallout from the recent branch-on-undef changes. This fixes
Prolangs-C/agrep and SCCP/2006-10-23-IPSCCP-Crash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31132 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-23 18:57:02 +00:00
Nick Lewycky
c17229d591 Remove the Backwards operation. Resolving now works at the time when a
property is added by running through the list of uses of the value and
adding resolved properties to the property set.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31126 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-23 01:56:02 +00:00
Nick Lewycky
7e189d095e Fix similar missing optimization opportunity in XOR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31123 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-22 22:22:58 +00:00
Nick Lewycky
92a8b71dc1 Whoops! Add missing NULL check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31121 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-22 21:38:24 +00:00
Nick Lewycky
5062250f36 Handle "if ((x|y) != 0)" for ints like we do for bools. Fixes missed
optimization opportunity pointed out by Chris Lattner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31118 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-22 21:36:41 +00:00
Nick Lewycky
802fe27d3e AllocaInst can't return a null pointer. Fixes missed optimization
opportunity pointed out by Andrew Lewycky.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31115 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-22 19:53:27 +00:00
Chris Lattner
32b1e87f11 Add a workaround for PR962, disabling the more aggressive form of this
transformation.  This speeds up a C++ app 2.25x.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31113 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-22 18:42:26 +00:00
Chris Lattner
d2d86703f0 3 Changes:
1. Better document what is going on here.
2. Only hack on one branch per iteration, making the results less conservative.
3. Handle the problematic case by marking edges executable instead of by
   playing with value lattice states.  This is far less pessimistic, and fixes
   SCCP/ipsccp-gvar.ll.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31106 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-22 05:59:17 +00:00
Chris Lattner
6734bffe24 Fix an ugly problem in SCCP. This fixes Benchmarks/Misc-C++/mandel-text.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31073 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-20 20:19:08 +00:00
Chris Lattner
87d8429506 Fix miscompilation of MallocBench/espresso which code review pointed out
but apparently didn't make it into the final patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31070 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-20 18:20:21 +00:00
Reid Spencer
b83eb6447b For PR950:
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31063 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-20 07:07:24 +00:00
Devang Patel
6e7dd9db6b While creating mask, use 1ULL instead of 1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31062 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-20 01:16:56 +00:00
Devang Patel
002e499650 It is OK to remove extra cast if operation is EQ/NE even though source
and destination sign may not match but other conditions are met.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31056 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-19 20:59:13 +00:00
Devang Patel
df308fa7ab Typo Typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31055 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-19 19:21:36 +00:00
Devang Patel
85415ed270 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31054 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-19 19:05:38 +00:00
Devang Patel
6ce890b6ec Fix bug in PR454 resolution. Added new test case.
This fixes llvmAsmParser.cpp miscompile by llvm on PowerPC Darwin.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31053 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-19 18:54:08 +00:00
Reid Spencer
ac5209e5fe Undo Chris' last patch, it caused a regression.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30991 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-16 23:08:08 +00:00
Chris Lattner
02c0e3659f fix a buggy check that accidentally disabled this xform
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30967 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-15 22:42:15 +00:00
Nick Lewycky
078ff41220 Replace custom dispatch code with two uses of InstVisitor. Improves
compile-time performance.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30896 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-12 02:02:44 +00:00
Chris Lattner
c836333c3b Implement SROA of unions with mixed pointers/integers in them. This implements
PR892 and Transforms/ScalarRepl/union-pointer.ll:test2


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30825 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-08 23:53:04 +00:00
Chris Lattner
5b121cc688 Implement Transforms/ScalarRepl/union-pointer.ll:test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30823 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-08 23:28:04 +00:00
Chris Lattner
867b99f845 add a new SimplifyDemandedVectorElts method, which works similarly to
SimplifyDemandedBits.  The idea is that some operations can be simplified if
not all of the computed elements are needed.  Some targets (like x86) have a
large number of intrinsics that operate on a single element, but pass other
elts through unmodified.  If those other elements are not needed, the
intrinsics can be simplified to scalar operations, and insertelement ops can
be removed.

This turns (f.e.):

ushort %Convert_sse(float %f) {
        %tmp = insertelement <4 x float> undef, float %f, uint 0                ; <<4 x float>> [#uses=1]
        %tmp10 = insertelement <4 x float> %tmp, float 0.000000e+00, uint 1             ; <<4 x float>> [#uses=1]
        %tmp11 = insertelement <4 x float> %tmp10, float 0.000000e+00, uint 2           ; <<4 x float>> [#uses=1]
        %tmp12 = insertelement <4 x float> %tmp11, float 0.000000e+00, uint 3           ; <<4 x float>> [#uses=1]
        %tmp28 = tail call <4 x float> %llvm.x86.sse.sub.ss( <4 x float> %tmp12, <4 x float> < float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > )               ; <<4 x float>> [#uses=1]
        %tmp37 = tail call <4 x float> %llvm.x86.sse.mul.ss( <4 x float> %tmp28, <4 x float> < float 5.000000e-01, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > )               ; <<4 x float>> [#uses=1]
        %tmp48 = tail call <4 x float> %llvm.x86.sse.min.ss( <4 x float> %tmp37, <4 x float> < float 6.553500e+04, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00 > )               ; <<4 x float>> [#uses=1]
        %tmp59 = tail call <4 x float> %llvm.x86.sse.max.ss( <4 x float> %tmp48, <4 x float> zeroinitializer )          ; <<4 x float>> [#uses=1]
        %tmp = tail call int %llvm.x86.sse.cvttss2si( <4 x float> %tmp59 )              ; <int> [#uses=1]
        %tmp69 = cast int %tmp to ushort                ; <ushort> [#uses=1]
        ret ushort %tmp69
}

into:

ushort %Convert_sse(float %f) {
entry:
        %tmp28 = sub float %f, 1.000000e+00             ; <float> [#uses=1]
        %tmp37 = mul float %tmp28, 5.000000e-01         ; <float> [#uses=1]
        %tmp375 = insertelement <4 x float> undef, float %tmp37, uint 0         ; <<4 x float>> [#uses=1]
        %tmp48 = tail call <4 x float> %llvm.x86.sse.min.ss( <4 x float> %tmp375, <4 x float> < float 6.553500e+04, float undef, float undef, float undef > )           ; <<4 x float>> [#uses=1]
        %tmp59 = tail call <4 x float> %llvm.x86.sse.max.ss( <4 x float> %tmp48, <4 x float> < float 0.000000e+00, float undef, float undef, float undef > )            ; <<4 x float>> [#uses=1]
        %tmp = tail call int %llvm.x86.sse.cvttss2si( <4 x float> %tmp59 )              ; <int> [#uses=1]
        %tmp69 = cast int %tmp to ushort                ; <ushort> [#uses=1]
        ret ushort %tmp69
}

which improves codegen from:

_Convert_sse:
        movss LCPI1_0, %xmm0
        movss 4(%esp), %xmm1
        subss %xmm0, %xmm1
        movss LCPI1_1, %xmm0
        mulss %xmm0, %xmm1
        movss LCPI1_2, %xmm0
        minss %xmm0, %xmm1
        xorps %xmm0, %xmm0
        maxss %xmm0, %xmm1
        cvttss2si %xmm1, %eax
        andl $65535, %eax
        ret

to:

_Convert_sse:
        movss 4(%esp), %xmm0
        subss LCPI1_0, %xmm0
        mulss LCPI1_1, %xmm0
        movss LCPI1_2, %xmm1
        minss %xmm1, %xmm0
        xorps %xmm1, %xmm1
        maxss %xmm1, %xmm0
        cvttss2si %xmm0, %eax
        andl $65535, %eax
        ret


This is just a first step, it can be extended in many ways.  Testcase here:
Transforms/InstCombine/vec_demanded_elts.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30752 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-05 06:55:50 +00:00
Nick Lewycky
f938099aa1 Simplify logic further.
Ensure that we copy KnownProperties before calling visitBasicBlock, else
we may leak properties into blocks where they don't belong.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30705 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-03 17:36:01 +00:00
Nick Lewycky
a73a654bb4 Simplify, now that predsimplify depends on break-crit-edges.
Fix SwitchInst where dest-block is the same as one of the cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30700 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-03 15:19:11 +00:00
Nick Lewycky
5c8c5d9ace Move break-crit-edges before the predicate simplifier. Allows us to
optimize in more cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30699 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-03 14:52:23 +00:00
Chris Lattner
e831b9a48b Fix a bug from r1.391 of this file, where we checked the size instead of
the alignment when promoting allocations.  This implements
InstCombine/cast.ll:test32


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30682 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-01 19:40:58 +00:00
Chris Lattner
47811b76ca Eliminate ConstantBool::True and ConstantBool::False. Instead, provide
ConstantBool::getTrue() and ConstantBool::getFalse().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30665 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-28 23:35:22 +00:00
Chris Lattner
7514437133 set DEBUG_TYPE right
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30623 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-27 04:58:23 +00:00
Nick Lewycky
8f389d8cd4 Style changes only. Remove dead code, fix a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30588 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-23 15:13:08 +00:00
Chris Lattner
9ba46c13bf Fix Transforms/IndVarsSimplify/2006-09-20-LFTR-Crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30555 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-21 05:12:20 +00:00
Nick Lewycky
009aa1d485 Don't rewrite ConstantExpr::get.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30552 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-21 01:05:35 +00:00
Nick Lewycky
af2f1fe94e Once we're down to "setcc type constant1, constant2", at least come up
with the right answer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30550 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 23:02:24 +00:00
Nick Lewycky
406fc0cb49 Use a total ordering to compare instructions.
Fixes infinite loop in resolve().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30540 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 17:04:01 +00:00
Andrew Lenharth
4563326472 simplify
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30535 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 15:37:57 +00:00
Chris Lattner
b8456460cb We went through all that trouble to compute whether it was safe to transform
this comparison, but never checked it.  Whoops, no wonder we miscompiled
177.mesa!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30511 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 04:44:59 +00:00
Evan Cheng
571c15e38a Back out Chris' last set of changes. This breaks 177.mesa and povray somehow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30505 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 01:39:40 +00:00
Evan Cheng
7df4ad9a7f 80 col.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30504 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 01:10:02 +00:00
Andrew Lenharth
16d7955eb0 If we have an add, do it in the pointer realm, not the int realm. This is critical in the linux kernel for pointer analysis correctness
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30496 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 18:24:51 +00:00
Chris Lattner
733f576d29 implement select.ll:test19-22
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30482 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 06:18:21 +00:00
Nick Lewycky
025f4c0fad Walk down the dominator tree instead of the control flow graph. That means
that we can't modify the CFG any more, at least not until it's possible
to update the dominator tree (PR217).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30469 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 21:09:35 +00:00
Chris Lattner
6d7ca92bbf Fix an infinite loop building the CFE
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30465 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 18:27:05 +00:00
Chris Lattner
e695a3bd32 Implement InstCombine/cast.ll:test31. This speeds up 462.libquantum by 26%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30456 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 05:27:43 +00:00
Chris Lattner
b7363791ed Implement Transforms/InstCombine/shift-sra.ll:test0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30450 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:31:40 +00:00
Chris Lattner
65b72baa59 Rewrite shift/and/compare sequences to promote better licm of the RHS.
Use isLogicalShift/isArithmeticShift to simplify code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30448 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:22:48 +00:00
Chris Lattner
f6bd07c7fe Fix Transforms/InstCombine/2006-09-15-CastToBool.ll and PR913
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30405 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 03:14:10 +00:00
Nick Lewycky
668a1d0fd2 Add some more consistency checks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30305 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-13 19:32:53 +00:00
Nick Lewycky
977be254c6 Fix unionSets so that it can merge correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30304 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-13 19:24:01 +00:00
Nick Lewycky
cf2112a0a0 Erase dead instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30298 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-13 18:55:37 +00:00
Chris Lattner
92f7365740 An sinkable instruction may exist with uses, if those uses are in dead blocks.
Handle this.  This fixes PR908 and Transforms/LICM/2006-09-12-DeadUserOfSunkInstr.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30275 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-12 19:17:09 +00:00
Chris Lattner
63d3220dae Fix PR905 and InstCombine/2006-09-11-EmptyStructCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30266 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-11 21:43:16 +00:00
Nick Lewycky
3fc68ccd83 Skip the linear search if the answer is already known.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30251 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-11 17:23:34 +00:00
Chris Lattner
dfa1af0513 Allow tail duplication in more cases, relaxing the previous restriction a
bit.  This fixes Regression/Transforms/TailDup/MergeTest.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30237 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-10 18:17:58 +00:00
Nick Lewycky
dc08cd56c4 Replace EquivalenceClasses with a custom-built data structure. Many common
operations (like findProperties) should be faster, at the expense of
unionSets being slower in cases that are rare in practise.

Don't erase a dead Instruction. This fixes a memory corruption issue.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30235 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-10 02:27:07 +00:00
Chris Lattner
2a86f3b744 Implement Transforms/InstCombine/hoist_instr.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30234 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-09 22:02:56 +00:00
Chris Lattner
8e49e08f4b Turn div X, (Cond ? Y : 0) -> div X, Y
This implements select.ll::test18.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30230 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-09 20:26:32 +00:00
Chris Lattner
e99c623e75 Throttle back tail duplication to avoid creating really ugly sequences of code.
For Transforms/TailDup/if-tail-dup.ll, f.e., it produces:

_foo:
        movl 8(%esp), %eax
        movl 4(%esp), %ecx
        testl $1, %ecx
        je LBB1_2       #cond_next
LBB1_1: #cond_true
        movl $1, (%eax)
LBB1_2: #cond_next
        testl $2, %ecx
        je LBB1_4       #cond_next10
LBB1_3: #cond_true6
        movl $1, 4(%eax)
LBB1_4: #cond_next10
        testl $4, %ecx
        je LBB1_6       #cond_next18
LBB1_5: #cond_true14
        movl $1, 8(%eax)
LBB1_6: #cond_next18
        testl $8, %ecx
        je LBB1_8       #return
LBB1_7: #cond_true22
        movl $1, 12(%eax)
        ret
LBB1_8: #return
        ret

instead of:

_foo:
        movl 4(%esp), %eax
        testl $2, %eax
        sete %cl
        movl 8(%esp), %edx
        testl $1, %eax
        je LBB1_2       #cond_next
LBB1_1: #cond_true
        movl $1, (%edx)
        testb %cl, %cl
        jne LBB1_4      #cond_next10
        jmp LBB1_3      #cond_true6
LBB1_2: #cond_next
        testb %cl, %cl
        jne LBB1_4      #cond_next10
LBB1_3: #cond_true6
        movl $1, 4(%edx)
        testl $4, %eax
        je LBB1_6       #cond_next18
        jmp LBB1_5      #cond_true14
LBB1_4: #cond_next10
        testl $4, %eax
        je LBB1_6       #cond_next18
LBB1_5: #cond_true14
        movl $1, 8(%edx)
        testl $8, %eax
        je LBB1_8       #return
        jmp LBB1_7      #cond_true22
LBB1_6: #cond_next18
        testl $8, %eax
        je LBB1_8       #return
LBB1_7: #cond_true22
        movl $1, 12(%edx)
        ret
LBB1_8: #return
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30158 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-07 21:30:15 +00:00
Nick Lewycky
a3a68bde21 Improve handling of SelectInst.
Reorder operations to remove duplicated work.
Fix to leave floating-point types out of the optimization.
Add tests to predsimplify.ll for SwitchInst and SelectInst handling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30055 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-02 19:40:38 +00:00
Nick Lewycky
7218c28822 Don't confuse canonicalize and lookup. Fixes predsimplify.reg4.ll. Also
corrects missing optimization opportunity removing cases from a switch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30009 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-01 03:26:35 +00:00
Nick Lewycky
6e39c7ed1e Properties where both Values weren't in the union (as being equal to
another Value) weren't being found by findProperties.

This fixes predsimplify.ll test6, a missed optimization opportunity.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29991 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-31 00:39:16 +00:00
Nick Lewycky
3947a76e21 Move to using the EquivalenceClass ADT. Removes SynSets.
If a branch's condition has become a ConstantBool, simplify it immediately.
Removing the edge saves work and exposes up more optimization opportunities
in the pass.
Add support for SelectInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29970 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-30 02:46:48 +00:00
Devang Patel
4b8f36f106 Do not rely on std::sort and std::erase to get list of unique
exit blocks. The output is dependent on addresses of basic block.

Add and use Loop::getUniqueExitBlocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29966 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-29 22:29:16 +00:00
Owen Anderson
d648e140a5 Clean up a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29950 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-29 06:10:56 +00:00
Nick Lewycky
05450ae128 Add PredicateSimplifier pass. Collapses equal variables into one form
and simplifies expressions. This implements the optimization described
in PR807.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29947 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-28 22:44:55 +00:00
Owen Anderson
59312b19a6 Make LoopUnroll fold excessive BasicBlocks. This results in a significant speedup of
gccas on 252.eon


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29936 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-28 02:09:46 +00:00
Chris Lattner
7f8897f22e eliminate RegisterOpt. It does the same thing as RegisterPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29925 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-27 22:42:52 +00:00
Chris Lattner
a4f0b3a084 s|llvm/Support/Visibility.h|llvm/Support/Compiler.h|
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29911 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-27 12:54:02 +00:00
Owen Anderson
203572552d Fix a crash related to updating Phi nodes in the original header block. This was
causing a crash in 175.vpr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29887 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-25 22:13:55 +00:00
Owen Anderson
eb70591492 Add an assertion to check that we're really preserving LCSSA.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29886 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-25 22:12:36 +00:00
Owen Anderson
ac12322710 Reapply the indvars patch, since nothing blew up last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29874 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-25 17:41:25 +00:00
Owen Anderson
b397d81f03 Revert my previous patch. Since there are some major changes that went in today,
I'm going to wait to put this in HEAD until tomorrow, so as not to clutter the nightly
tester.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29868 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-25 03:45:57 +00:00
Owen Anderson
8a24749cb8 Specify that indvars actually preserve LCSSA. This has been done for a while, but I
forgot to put in the analysis usage.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29867 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-25 03:32:13 +00:00
Owen Anderson
3b53c4ee91 Implement unrolling of multiblock loops. This significantly improves the
utility of the LoopUnroll pass.

Also, add a testcase for multiblock-loop unrolling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29859 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-24 21:28:19 +00:00
Reid Spencer
47a53ac726 Fix a grammaro in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29765 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-18 09:01:07 +00:00
Chris Lattner
df32aac51b Handle single-entry PHI nodes correctly. This fixes PR877 and
Transforms/CondProp/2006-08-14-SingleEntryPhiCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29673 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-14 21:38:05 +00:00
Chris Lattner
7e79b3898d Changes:
1. Update an obsolete comment.
  2. Make the sorting by base an explicit (though still N^2) step, so
     that the code is more clear on what it is doing.
  3. Partition uses so that uses inside the loop are handled before uses
     outside the loop.

Note that none of these changes currently changes the code inserted by LSR,
but they are a stepping stone to getting there.

This code is the result of some crazy pair programming with Nate. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29493 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-03 06:34:50 +00:00
Chris Lattner
ec3c411de8 Minor comment tweaks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29226 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-20 19:06:16 +00:00
Owen Anderson
10d9d9f27c Add an assertion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29199 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-19 05:48:45 +00:00
Owen Anderson
2698a08c23 Make LoopUnroll not die on LCSSA Phis. This makes lencod work again.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29198 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-19 05:45:14 +00:00
Owen Anderson
db5b9cfd86 Fix a error that hadn't yet cause any problems, but I'm sure it would have
somewhere down the road.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29197 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-19 03:51:48 +00:00
Evan Cheng
31e773147b Only reuse a previous IV if it would not require a type conversion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29186 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-18 19:07:58 +00:00