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
Chris Lattner
7c62d8a1a8
change the interface to CoerceAvailableValueToLoadType to be
...
more generic.
llvm-svn: 82402
2009-09-20 19:31:14 +00:00
Chris Lattner
1dd48c34e5
enhance GVN to forward substitute a stored value to a load
...
(and load -> load) when the base pointers must alias but when
they are different types. This occurs very very frequently in
176.gcc and other code that uses bitfields a lot.
llvm-svn: 82399
2009-09-20 19:03:47 +00:00
Daniel Dunbar
7d6781b0fe
Tabs -> spaces, and remove trailing whitespace.
...
llvm-svn: 82355
2009-09-20 02:20:51 +00:00
Nick Lewycky
1303c0ab86
Remove the default value for ConstantStruct::get's isPacked parameter and
...
update the code which was broken by this.
llvm-svn: 82327
2009-09-19 20:30:26 +00:00
Victor Hernandez
5d034499ad
Enhance transform passes so that they apply the same tranforms to malloc calls as to MallocInst.
...
Reviewed by Dan Gohman.
llvm-svn: 82300
2009-09-18 22:35:49 +00:00
Victor Hernandez
788eaabd18
Update malloc call creation code (AllocType is now the element type of the malloc, not the resulting type).
...
In getMallocArraySize(), fix bug in the case that array size is the product of 2 constants.
Extend isArrayMalloc() and getMallocArraySize() to handle case where malloc is used as char array.
Ensure that ArraySize in LowerAllocations::runOnBasicBlock() is correct type.
Extend Instruction::isSafeToSpeculativelyExecute() to handle malloc calls.
Add verification for malloc calls.
Reviewed by Dan Gohman.
llvm-svn: 82257
2009-09-18 19:20:02 +00:00