Devang Patel
92f8619923
Use isVoidTy()
...
llvm-svn: 84118
2009-10-14 17:29:00 +00:00
Chris Lattner
6b9044db01
make instcombine's instruction sinking more aggressive in the
...
presence of PHI nodes.
llvm-svn: 84103
2009-10-14 15:21:58 +00:00
Devang Patel
a677136900
Check void type before using RAUWd.
...
llvm-svn: 84049
2009-10-13 22:56:32 +00:00
Devang Patel
115741ba79
Do not check use_empty() before replaceAllUsesWith(). This gives ValueHandles a chance to get properly updated.
...
llvm-svn: 84033
2009-10-13 21:41:20 +00:00
Dan Gohman
2dc6f8de03
Use the new CodeMetrics class to compute code size instead of
...
manually counting instructions.
llvm-svn: 84016
2009-10-13 20:12:23 +00:00
Ted Kremenek
113d959f1b
Update CMake file.
...
llvm-svn: 84001
2009-10-13 18:48:07 +00:00
Dan Gohman
54463e837a
Commit the removal of this file, which is now moved to lib/Analysis.
...
llvm-svn: 83999
2009-10-13 18:37:20 +00:00
Dan Gohman
4552e3cd73
Move the InlineCost code from Transforms/Utils to Analysis.
...
llvm-svn: 83998
2009-10-13 18:30:07 +00:00
Dan Gohman
5b3e05bcaa
Start refactoring the inline cost estimation code so that it can be used
...
for purposes other than inlining.
llvm-svn: 83997
2009-10-13 18:24:11 +00:00
Chris Lattner
19788ca686
change simplifycfg to not duplicate 'unwind' instructions. Hopefully
...
this will increase the likelihood of common code getting sunk towards
the unwind.
llvm-svn: 83996
2009-10-13 18:13:05 +00:00
Dan Gohman
71ca652475
Make LoopUnswitch's cost estimation count Instructions, rather than
...
BasicBlocks, so that it doesn't blindly procede in the presence of
large individual BasicBlocks. This addresses a class of code-size
expansion problems.
llvm-svn: 83992
2009-10-13 17:50:43 +00:00
Evan Cheng
f815861591
Make licm debug message readable.
...
llvm-svn: 83908
2009-10-12 22:25:23 +00:00
Dale Johannesen
4c9f0e8f53
Fix warning.
...
llvm-svn: 83870
2009-10-12 18:45:32 +00:00
Chris Lattner
8abd572dae
populate instcombine's initial worklist more carefully, causing
...
it to visit instructions from the start of the function to the
end of the function in the first path. This greatly speeds up
some pathological cases (e.g. PR5150).
Try #3 , this time with some unneeded debug info stuff removed
which was causing dead pointers to be added to the worklist.
llvm-svn: 83818
2009-10-12 03:58:40 +00:00
Chris Lattner
8ce6b36c86
revert r83814 for now, it is making the llvm-gcc bootstrap unhappy.
...
llvm-svn: 83817
2009-10-11 23:56:08 +00:00
Chris Lattner
78d6310429
populate instcombine's initial worklist more carefully, causing
...
it to visit instructions from the start of the function to the
end of the function in the first path. This greatly speeds up
some pathological cases (e.g. PR5150).
llvm-svn: 83814
2009-10-11 23:17:43 +00:00
Chris Lattner
2c2deae5ac
remove some harmful code that would turn an insertelement on an undef
...
into a shuffle even if it was used by another insertelement. If the
visitation order of instcombine was wrong, this would turn a chain of
insertelements into a chain of shufflevectors, which was quite painful.
Since CollectShuffleElements handles these cases, the code can just
be nuked.
llvm-svn: 83810
2009-10-11 23:02:46 +00:00
Chris Lattner
c6cdbfbfdd
teach instcombine to simplify xor's harder, catching the
...
new testcase.
llvm-svn: 83799
2009-10-11 22:22:13 +00:00
Chris Lattner
6e6ac47125
cleanups
...
llvm-svn: 83797
2009-10-11 22:00:32 +00:00
Chris Lattner
1639234775
cleanup, no functionality change.
...
llvm-svn: 83795
2009-10-11 21:36:10 +00:00
Chris Lattner
fd27f8a5b3
generalize a transformation even more: we don't care whether the
...
input the the mul is a zext from bool, just that it is all zeros
other than the low bit. This fixes some phase ordering issues
that would cause us to miss some xforms in mul.ll when the worklist
is visited differently.
llvm-svn: 83794
2009-10-11 21:29:45 +00:00
Chris Lattner
406cb75c6b
simplify a transformation by making it more general.
...
llvm-svn: 83792
2009-10-11 21:22:21 +00:00
Chris Lattner
f39f4f928a
temporarily revert previous patch
...
llvm-svn: 83791
2009-10-11 21:05:34 +00:00
Chris Lattner
bb058d3a23
populate instcombine's initial worklist more carefully, causing
...
it to visit instructions from the start of the function to the
end of the function in the first path. This greatly speeds up
some pathological cases (e.g. PR5150).
llvm-svn: 83790
2009-10-11 21:04:37 +00:00
Torok Edwin
8b3081350e
Remove CleanupDbgInfo, instcombine does this and its not worth duplicating it
...
here.
llvm-svn: 83789
2009-10-11 19:58:35 +00:00
Torok Edwin
907ec36943
LICM shouldn't sink/delete debug information. Fix this and add a testcase.
...
For now the metadata of sinked/hoisted instructions is still wrong, but that'll
be fixed when instructions will have debug metadata directly attached.
llvm-svn: 83786
2009-10-11 19:15:54 +00:00
Chris Lattner
85c85c5e04
when folding duplicate conditions, delete the
...
now-probably-dead instruction tree feeding it.
llvm-svn: 83778
2009-10-11 18:39:58 +00:00
Chris Lattner
e374382b8f
implement rdar://7293527, a trivial instcombine that llvm-gcc
...
gets but clang doesn't, because it is implemented in GCC's
fold routine.
llvm-svn: 83761
2009-10-11 07:53:15 +00:00
Chris Lattner
97b1405207
implement a transformation in jump threading that is currently
...
done by condprop, but do it in a much more general form. The
basic idea is that we can do a limited form of tail duplication
in the case when we have a branch on a phi. Moving the branch
up in to the predecessor block makes instruction selection
much easier and encourages chained jump threadings.
llvm-svn: 83759
2009-10-11 07:24:57 +00:00
Chris Lattner
6ce85e85f5
restructure some code, no functionality change.
...
llvm-svn: 83756
2009-10-11 04:40:21 +00:00
Chris Lattner
f466bc84c9
factor some code better and move a function, no functionality change.
...
llvm-svn: 83755
2009-10-11 04:33:43 +00:00
Chris Lattner
f99a74e24b
make jump threading on a phi with undef inputs happen.
...
llvm-svn: 83754
2009-10-11 04:18:15 +00:00
Chris Lattner
71d353dd48
rewrite LCSSA to use SSAUpdate, to only return true if it modifies
...
the IR, and to implement the FIXME'd optimization.
llvm-svn: 83748
2009-10-11 02:53:37 +00:00
Chris Lattner
101dde30ed
clean up and simplify some code. Don't use setvector when things will be
...
inserted only once, just use vector. Don't compute ExitBlocks unless we
need it, change std::sort to array_pod_sort.
llvm-svn: 83747
2009-10-11 01:07:15 +00:00
Chris Lattner
b6c65faa64
switch GVN to use SSAUpdater. Besides removing a lot of complexity
...
from GVN, this also speeds it up, inserts fewer PHI nodes (see the
testcase) and allows it to remove more loads (due to fewer PHI nodes
standing in the way).
llvm-svn: 83746
2009-10-10 23:50:30 +00:00
Chris Lattner
9c382cebc5
add a simple helper method.
...
llvm-svn: 83745
2009-10-10 23:41:48 +00:00
Chris Lattner
249265de06
add ability for clients of SSAUpdater to find out about the
...
PHI nodes inserted.
llvm-svn: 83744
2009-10-10 23:15:24 +00:00
Chris Lattner
89d2a5c4f3
remove dead code
...
llvm-svn: 83742
2009-10-10 23:04:12 +00:00
Chris Lattner
67cdd8b567
add the ability to get a rewritten value from the middle of a block,
...
not just at the end. Add a big comment explaining when this could
be useful (which never happens for jump threading).
llvm-svn: 83741
2009-10-10 23:00:11 +00:00
Chris Lattner
e474a8d3a7
rename GetValueInBlock -> GetValueAtEndOfBlock to better reflect
...
what it does.
llvm-svn: 83740
2009-10-10 22:41:58 +00:00
Chris Lattner
65e69a77e1
use a typedef instead of spelling out an insane type. Yay for auto someday.
...
llvm-svn: 83707
2009-10-10 09:09:20 +00:00
Chris Lattner
84095071ea
Change jump threading to use the new SSAUpdater class instead of
...
DemoteRegToStack. This makes it more efficient (because it isn't
creating a ton of load/stores that are eventually removed by a later
mem2reg), and more slightly more effective (because those load/stores
don't get in the way of threading).
llvm-svn: 83706
2009-10-10 09:05:58 +00:00
Chris Lattner
60d4e69c81
Implement an efficient and fully general SSA update mechanism that
...
works on unstructured CFGs. This implements PR217, our oldest open PR.
llvm-svn: 83705
2009-10-10 09:04:27 +00:00
Chris Lattner
f30a2b0c86
random tidying
...
llvm-svn: 83701
2009-10-10 06:22:45 +00:00
Dale Johannesen
96a5b87ae2
Use names instead of numbers for some of the magic
...
constants used in inlining heuristics (especially
those used in more than one file). No functional change.
llvm-svn: 83675
2009-10-09 21:42:02 +00:00
Dale Johannesen
3059924bdd
When considering whether to inline Callee into Caller,
...
and that will make Caller too big to inline, see if it
might be better to inline Caller into its callers instead.
This situation is described in PR 2973, although I haven't
tried the specific case in SPASS.
llvm-svn: 83602
2009-10-09 00:11:32 +00:00
Dan Gohman
09984279fd
Add a form of addPreserved which takes a string argument, to allow passes
...
to declare that they preserve other passes without needing to pull in
additional header file or library dependencies. Convert MachineFunctionPass
and CodeGenLICM to make use of this.
llvm-svn: 83555
2009-10-08 17:00:02 +00:00
Jeffrey Yasskin
dafd08ea7e
In instcombine's debug output, avoid printing ADD for instructions that are
...
already on the worklist, and print Visited when an instruction is about to be
visited. Net, on one input, this reduced the output size by at least 9x.
llvm-svn: 83510
2009-10-08 00:12:24 +00:00
Eric Christopher
5b741f3d14
80-column and whitespace fixes.
...
llvm-svn: 83489
2009-10-07 21:14:25 +00:00
Eric Christopher
e666bc9f64
Add FreeInst to the "is a call" check for Insts that are calls, but
...
not intrinsics.
llvm-svn: 83441
2009-10-07 00:54:08 +00:00
Eric Christopher
6ba26317ce
While we still have a MallocInst treat it as a call like any other
...
for inlining.
When MallocInst goes away this code will be subsumed as part of
calls and work just fine...
llvm-svn: 83434
2009-10-07 00:02:18 +00:00
Ted Kremenek
2275a7dfef
Update CMake file.
...
llvm-svn: 83404
2009-10-06 19:45:38 +00:00
Chris Lattner
a893f5bdf5
remove predicate simplifier, it never got the last bugs beaten
...
out of it, and jump threading, condprop and gvn are now getting
most of the benefit. This was approved by Nicholas and Nicolas.
llvm-svn: 83390
2009-10-06 16:59:46 +00:00
Duncan Sands
9ed7b16bf3
Introduce and use convenience methods for getting pointer types
...
where the element is of a basic builtin type. For example, to get
an i8* use getInt8PtrTy.
llvm-svn: 83379
2009-10-06 15:40:36 +00:00
Dan Gohman
e525d9ddc0
Remove an unnnecessary LLVMContext argument in
...
ConstantFoldLoadThroughGEPConstantExpr.
llvm-svn: 83311
2009-10-05 16:36:26 +00:00
Dan Gohman
238cf49812
Use Use::operator= instead of Use::set, for consistency.
...
llvm-svn: 83310
2009-10-05 16:31:55 +00:00
Chris Lattner
fdd8790718
strength reduce a ton of type equality tests to check the typeid (Through
...
the new predicates I added) instead of going through a context and doing a
pointer comparison. Besides being cheaper, this allows a smart compiler
to turn the if sequence into a switch.
llvm-svn: 83297
2009-10-05 05:54:46 +00:00
Chris Lattner
463716d559
instcombine shouldn't delete all null checks for mallocs.
...
This fixes PR5130.
llvm-svn: 83290
2009-10-05 02:47:47 +00:00
Owen Anderson
b5049bebb3
Do away with the strange use of BitVectors in SSI, and just use normal sets. This makes the code much more C++/LLVM-ish.
...
llvm-svn: 83286
2009-10-04 18:49:55 +00:00
Owen Anderson
286feb16a9
Fix a typo in the comment.
...
llvm-svn: 83283
2009-10-04 17:52:13 +00:00
Owen Anderson
a62bf10651
SSI needs to require DT and DF transitively, since it uses them outside of its runOnFunction.
...
Similarly, it can be marked setPreservesAll, since it does no work in its runOnFunction.
llvm-svn: 83282
2009-10-04 17:47:39 +00:00
Evan Cheng
bb4ed2394b
Allow -inline-threshold override default threshold even if compiling to optimize for size.
...
llvm-svn: 83274
2009-10-04 06:13:54 +00:00
Douglas Gregor
d846fbf20d
Remove GVNPRE.cpp from the CMake makefile
...
llvm-svn: 83194
2009-10-01 05:30:05 +00:00
Chris Lattner
5f3cc06cd2
remove the GVNPRE pass. It has been subsumed by the GVN pass.
...
Ok'd by Owen.
llvm-svn: 83193
2009-10-01 02:18:36 +00:00
Dan Gohman
ea0bb8f555
Fix this code so that it doesn't try to iterate through a std::vector
...
while calling changeImmediateDominator, which removes elements from the
vector. This fixes PR5097.
llvm-svn: 83166
2009-09-30 20:54:16 +00:00
Dan Gohman
7d3b0be05b
Remove a redundant #ifndef and add an assertion string.
...
llvm-svn: 82991
2009-09-28 14:38:19 +00:00
Dan Gohman
9a7320c711
Convert LoopSimplify and LoopExtractor from FunctionPass to LoopPass.
...
llvm-svn: 82990
2009-09-28 14:37:51 +00:00
Chris Lattner
0261b5d2d2
The select instruction is not neccesarily in the same block as the
...
phi nodes. Make sure to phi translate from the right block.
This fixes a llvm-building-llvm failure on GVN-PRE.cpp
llvm-svn: 82970
2009-09-28 06:49:44 +00:00
Chris Lattner
4425660b1f
simplify some code.
...
llvm-svn: 82936
2009-09-27 21:46:50 +00:00
Chris Lattner
b2e88cd01c
The bitcast case is not needed here: instcombine turns icmp(bitcast(x), null) -> icmp(x, null) already.
...
llvm-svn: 82935
2009-09-27 21:42:46 +00:00
Chris Lattner
8b4d3dfbbf
calls are already unmovable, malloc doesn't need a special case.
...
llvm-svn: 82933
2009-09-27 21:36:19 +00:00
Chris Lattner
f9e0c7f84b
calls to external functions are already marked overdefined, special casing
...
malloc isn't needed.
llvm-svn: 82932
2009-09-27 21:35:11 +00:00
Chris Lattner
5abb1e4cd2
calls are already handled, malloc doesn't need a special case.
...
llvm-svn: 82931
2009-09-27 21:33:46 +00:00
Chris Lattner
466d57f6c1
calls are rejected above, no need to special case malloc here.
...
llvm-svn: 82929
2009-09-27 21:31:39 +00:00
Chris Lattner
43d0db70ac
remove special handling of bitcast(malloc), it will be handled
...
when the loop inspects the bitcast operand.
llvm-svn: 82928
2009-09-27 21:29:28 +00:00
Chris Lattner
a8627272c1
unlike the malloc instruction, "malloc" calls do not claim to be readonly, just nounwind.
...
llvm-svn: 82927
2009-09-27 21:23:38 +00:00
Chris Lattner
b391e87263
allow pushing icmps through phis with multiple uses and across critical edges.
...
These are important to push up to encourage jump threading. This shrinks 176.gcc a bit.
llvm-svn: 82923
2009-09-27 20:46:36 +00:00
Chris Lattner
ae289632ef
Enhance the previous fix for PR4895 to allow more values than just
...
simple constants for the true/false value of the select. We now
do phi translation etc. This really fixes PR4895 :)
llvm-svn: 82917
2009-09-27 20:18:49 +00:00
Chris Lattner
facb867af3
implement PR4895, by making FoldOpIntoPhi handle select conditions
...
that are phi nodes. Also tighten up FoldOpIntoPhi to treat constantexpr
operands to phis just like other variables, avoiding moving constantexpr
computations around.
Patch by Daniel Dunbar.
llvm-svn: 82913
2009-09-27 19:57:57 +00:00
Dan Gohman
0e70af36c0
Grab an LLVM Context from an instruction that exists rather than one
...
that is deleted in some situations. This fixes a use-after-free.
llvm-svn: 82903
2009-09-27 16:10:30 +00:00
Dan Gohman
fc20b67e80
Tell ScalarEvolution to forget everything it knows about a loop before
...
rotating the loop, since loop rotation is a very significant change.
llvm-svn: 82901
2009-09-27 15:37:03 +00:00
Nick Lewycky
42fb7452df
Instruction::clone does not need to take an LLVMContext&. Remove that and
...
update all the callers.
llvm-svn: 82889
2009-09-27 07:38:41 +00:00
Dan Gohman
62995c71a2
Fix SimplifyLibCalls to transfer attributes from callees rather than
...
calls, since direct calls don't always reflect the attributes of their
callees.
llvm-svn: 82867
2009-09-26 18:10:13 +00:00
Dan Gohman
394468dc8e
Rename ConstantFP's getInf to getInfinity.
...
llvm-svn: 82823
2009-09-25 23:40:21 +00:00
Dan Gohman
5ffd53892d
Transform pow(x, 0.5) to (x == -inf ? inf : fabs(sqrt(x))), which is
...
typically faster then doing a general pow.
llvm-svn: 82819
2009-09-25 23:10:17 +00:00
Torok Edwin
21bd8c9fc5
Constant propagating byval pointer is safe if function is readonly.
...
llvm-svn: 82700
2009-09-24 18:33:42 +00:00
Torok Edwin
f95a450ef9
Don't constant propagate byval pointers, since they are not really pointers, but
...
rather structs passed by value.
This fixes PR5038.
llvm-svn: 82689
2009-09-24 09:47:18 +00:00
Dale Johannesen
fb1b55bc9c
A minor improvment in accuracy to inline cost
...
computation, and some cosmetics.
llvm-svn: 82660
2009-09-23 22:05:24 +00:00
Chris Lattner
e3ce1e2a37
tidy up
...
llvm-svn: 82488
2009-09-21 22:26:02 +00:00
Chris Lattner
247053867e
big endian systems shift by bits too, hopefully this will fix the ppc
...
bootstrap problems.
llvm-svn: 82464
2009-09-21 17:55:47 +00:00
Dan Gohman
43d6830ea0
Nick pointed out that DominanceFrontier and DominanceTree are preserved
...
by setPreservesCFG().
llvm-svn: 82463
2009-09-21 17:54:42 +00:00
Dan Gohman
af57ae3da4
Remove the special-case for constants in PHI nodes; it's not really
...
helpful, and it didn't correctly handle the case of constants input
to PHIs for backedges.
llvm-svn: 82462
2009-09-21 17:53:35 +00:00
Chris Lattner
9045f235d2
fix PR5016, a crash I introduced in GVN handing first class
...
arrays and structs, which cannot be bitcast to integers.
llvm-svn: 82460
2009-09-21 17:24:04 +00:00
Chris Lattner
4d8af2f1ae
enable non-local analysis and PRE of large store -> little load.
...
This doesn't kick in too much because of phi translation issues,
but this can be resolved in the future.
llvm-svn: 82447
2009-09-21 06:48:08 +00:00
Chris Lattner
0cdc17eb50
convert an std::pair to an explicit struct.
...
llvm-svn: 82446
2009-09-21 06:30:24 +00:00
Chris Lattner
d28f90897a
move some functions, add a comment.
...
llvm-svn: 82444
2009-09-21 06:24:16 +00:00
Chris Lattner
9d7fb29522
split HandleLoadFromClobberingStore in two pieces: one that does the
...
analysis, one that does the xform.
llvm-svn: 82443
2009-09-21 06:22:46 +00:00
Chris Lattner
0a9616d906
Improve GVN to be able to forward substitute a small load
...
from a piece of a large store when both are in the same block.
This allows clang to compile the testcase in PR4216 to this code:
_test_bitfield:
movl 4(%esp), %eax
movl %eax, %ecx
andl $-65536, %ecx
orl $32962, %eax
andl $40186, %eax
orl %ecx, %eax
ret
This is not ideal, but is a whole lot better than the code produced
by llvm-gcc:
_test_bitfield:
movw $-32574, %ax
orw 4(%esp), %ax
andw $-25350, %ax
movw %ax, 4(%esp)
movw 7(%esp), %cx
shlw $8, %cx
movzbl 6(%esp), %edx
orw %cx, %dx
movzwl %dx, %ecx
shll $16, %ecx
movzwl %ax, %eax
orl %ecx, %eax
ret
and dramatically better than that produced by gcc 4.2:
_test_bitfield:
pushl %ebx
call L3
"L00000000001$pb":
L3:
popl %ebx
movl 8(%esp), %eax
leal 0(,%eax,4), %edx
sarb $7, %dl
movl %eax, %ecx
andl $7168, %ecx
andl $-7201, %ebx
movzbl %dl, %edx
andl $1, %edx
sall $5, %edx
orl %ecx, %ebx
orl %edx, %ebx
andl $24, %eax
andl $-58336, %ebx
orl %eax, %ebx
orl $32962, %ebx
movl %ebx, %eax
popl %ebx
ret
llvm-svn: 82439
2009-09-21 05:57:11 +00:00
Chris Lattner
1eefa9c427
formatting cleanups, no functionality change.
...
llvm-svn: 82426
2009-09-21 02:42:51 +00:00
Chris Lattner
a0aa8fb6a6
Move CoerceAvailableValueToLoadType earlier in GVN.cpp. Hook it up
...
so that nonlocal and partially redundant loads can use it as well.
The testcase shows examples of craziness this can handle. This triggers
*many* times in 176.gcc.
llvm-svn: 82403
2009-09-20 20:09:34 +00:00