Owen Anderson
bd844014fa
Add a test for my previous PRE fix.
...
llvm-svn: 60394
2008-12-02 04:25:42 +00:00
Bill Wendling
a6e7dd2299
Use m_Specific() instead of double matching.
...
llvm-svn: 60341
2008-12-01 08:09:47 +00:00
Chris Lattner
e6c7ed156f
simplify these patterns using m_Specific. No need to grep for
...
xor in testcase (or is a substring).
llvm-svn: 60328
2008-12-01 05:16:26 +00:00
Chris Lattner
0e03e40a76
Teach inst combine to merge GEPs through PHIs. This is really
...
important because it is sinking the loads using the GEPs, but
not the GEPs themselves. This triggers 647 times on 403.gcc
and makes the .s file much much nicer. For example before:
je LBB1_87 ## bb78
LBB1_62: ## bb77
leal 84(%esi), %eax
LBB1_63: ## bb79
movl (%eax), %eax
...
LBB1_87: ## bb78
movl $0, 4(%esp)
movl %esi, (%esp)
call L_make_decl_rtl$stub
jmp LBB1_62 ## bb77
after:
jne LBB1_63 ## bb79
LBB1_62: ## bb78
movl $0, 4(%esp)
movl %esi, (%esp)
call L_make_decl_rtl$stub
LBB1_63: ## bb79
movl 84(%esi), %eax
The input code was (and the GEPs are merged and
the PHI is now eliminated by instcombine):
br i1 %tmp233, label %bb78, label %bb77
bb77:
%tmp234 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22
br label %bb79
bb78:
call void @make_decl_rtl(%struct.tree_node* %t_addr.3, i8* null) nounwind
%tmp235 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22
br label %bb79
bb79:
%iftmp.12.0.in = phi %struct.rtx_def** [ %tmp235, %bb78 ], [ %tmp234, %bb77 ]
%iftmp.12.0 = load %struct.rtx_def** %iftmp.12.0.in
llvm-svn: 60322
2008-12-01 02:34:36 +00:00
Chris Lattner
01150dce74
testcase for my previous commit.
...
llvm-svn: 60315
2008-12-01 01:42:03 +00:00
Bill Wendling
23684a026c
Implement ((A|B)&1)|(B&-2) -> (A&1) | B transformation. This also takes care of
...
permutations of this pattern.
llvm-svn: 60312
2008-12-01 01:07:11 +00:00
Bill Wendling
66a7442059
Add instruction combining for ((A&~B)|(~A&B)) -> A^B and all permutations.
...
llvm-svn: 60291
2008-11-30 13:52:49 +00:00
Bill Wendling
3e27ac16a6
Implement (A&((~A)|B)) -> A&B transformation in the instruction combiner. This
...
takes care of all permutations of this pattern.
llvm-svn: 60290
2008-11-30 13:08:13 +00:00
Bill Wendling
97ad688c1b
getSExtValue() doesn't work for ConstantInts with bitwidth > 64 bits. Use all
...
APInt calls instead.
This fixes PR3144.
llvm-svn: 60288
2008-11-30 12:38:24 +00:00
Eli Friedman
2bc3921ce2
Optimize memmove and memset into the LLVM builtins. Note that these
...
only show up in code from front-ends besides llvm-gcc, like clang.
llvm-svn: 60287
2008-11-30 08:32:11 +00:00
Bill Wendling
5020e916ef
Strengthen check for div inst-combining.
...
llvm-svn: 60276
2008-11-30 04:33:53 +00:00
Bill Wendling
ac11f7d37e
Instcombine was illegally transforming -X/C into X/-C when either X or C
...
overflowed on negation. This commit checks to make sure that neithe C nor X
overflows. This requires that the RHS of X (a subtract instruction) be a
constant integer.
llvm-svn: 60275
2008-11-30 03:42:12 +00:00
Chris Lattner
203a3299e9
don't require GVN to work on dead values, just make the
...
test return the loaded value.
llvm-svn: 60252
2008-11-29 21:21:48 +00:00
Chris Lattner
f3e49f038c
Fix a thinko that manifested as a crash on clamav last night.
...
llvm-svn: 60251
2008-11-29 20:29:04 +00:00
Chris Lattner
494758e720
Fix PR3141 by ensuring that MemoryDependenceAnalysis::removeInstruction
...
properly updates the reverse dependency map when it installs updated
dependencies for instructions that depend on the removed instruction.
llvm-svn: 60222
2008-11-28 22:51:08 +00:00
Chris Lattner
a854ab3760
don't call MergeBasicBlockIntoOnlyPred on a block whose only
...
predecessor is itself. This doesn't make sense, and this is
a dead infinite loop anyway.
llvm-svn: 60210
2008-11-28 19:54:49 +00:00
Nick Lewycky
40db216722
Chris prefers icmp/select over udiv!
...
llvm-svn: 60187
2008-11-27 22:41:10 +00:00
Nick Lewycky
882443585d
Add a couple of missed optimizations on integer vectors. Multiply and divide
...
by 1, as well as multiply by -1.
llvm-svn: 60182
2008-11-27 20:21:08 +00:00
Chris Lattner
73b251b3bf
Fix PR3138: if we merge the entry block into another block, make sure to
...
move the other block back up into the entry position!
llvm-svn: 60179
2008-11-27 19:25:19 +00:00
Chris Lattner
532458b89f
Make jump threading substantially more powerful, in the following ways:
...
1. Make it fold blocks separated by an unconditional branch. This enables
jump threading to see a broader scope.
2. Make jump threading able to eliminate locally redundant loads when they
feed the branch condition of a block. This frequently occurs due to
reg2mem running.
3. Make jump threading able to eliminate *partially redundant* loads when
they feed the branch condition of a block. This is common in code with
lots of loads and stores like C++ code and 255.vortex.
This implements thread-loads.ll and rdar://6402033.
Per the fixme's, several pieces of this should be moved into Transforms/Utils.
llvm-svn: 60148
2008-11-27 05:07:53 +00:00
Evan Cheng
c11d7e324f
convertToSignExtendedInteger should return opInvalidOp instead of asserting if sematics of float does not allow arithmetics.
...
llvm-svn: 60042
2008-11-25 19:00:29 +00:00
Chris Lattner
a07ad05059
reenable test
...
llvm-svn: 59986
2008-11-24 21:27:20 +00:00
Bill Wendling
36ee715e71
Temporarily XFAIL this test. r59976 and r59972 broke it.
...
llvm-svn: 59981
2008-11-24 20:43:33 +00:00
Chris Lattner
e5bf93e61f
Fix 3113: If we have a dead cyclic PHI, replace the whole thing
...
with an undef.
llvm-svn: 59972
2008-11-24 19:25:36 +00:00
Nick Lewycky
2fbf26fe70
Optimize (x/y)*y into x-(x%y) in general. Div and rem are about the same, and
...
a subtract is cheaper than a multiply. This generalizes an existing transform.
llvm-svn: 59800
2008-11-21 07:33:58 +00:00
Devang Patel
2a0aa9fa51
Give SIToFPInst preference over UIToFPInst because it is faster on platforms that are widely used.
...
llvm-svn: 59476
2008-11-18 00:40:02 +00:00
Devang Patel
705f88d5b5
While handling floating point IVs lift restrictions on initial value and increment value.
...
llvm-svn: 59471
2008-11-17 23:27:13 +00:00
Chris Lattner
21f18c9760
Handle the case where there is no "not". It is possible it got
...
folded into the select.
llvm-svn: 59389
2008-11-16 04:25:26 +00:00
Chris Lattner
4f8153d48f
make this actually test what it is trying to.
...
llvm-svn: 59386
2008-11-16 04:21:51 +00:00
Devang Patel
f0d6bd18d5
If the sign of exit condition and split condition does not match
...
then do not split loop index.
llvm-svn: 58995
2008-11-10 19:48:34 +00:00
Bill Wendling
436d4cce83
If the LHS of the FCMP is coming from a UIToFP instruction, then we don't want
...
to generate signed ICMP instructions to replace the FCMP. This would violate
the following:
define i1 @test1(i32 %val) {
%1 = uitofp i32 %val to double
%2 = fcmp ole double %1, 0.000000e+00
ret i1 %2
}
would be transformed into:
define i1 @test1(i32 %val) {
%1 = icmp slt i33 %val, 1
ret i1 %1
}
which is obviously wrong. This patch modifes InstCombiner::FoldFCmp_IntToFP_Cst
to handle when the LHS comes from UIToFP.
llvm-svn: 58929
2008-11-09 04:26:50 +00:00
Devang Patel
9600e3e1b2
Add PR number.
...
llvm-svn: 58765
2008-11-05 18:41:15 +00:00
Devang Patel
5ca10e5295
New test case.
...
llvm-svn: 58745
2008-11-05 01:40:30 +00:00
Dan Gohman
c162a200ad
Add a new pass to simplify specific half_powr function calls. This is
...
a specialized pass that it not likely to be generally useful.
llvm-svn: 58732
2008-11-04 23:41:45 +00:00
Anton Korobeynikov
169173000f
Fix tests not to emit IR output
...
llvm-svn: 58729
2008-11-04 23:02:39 +00:00
Devang Patel
c959b4dbd3
Ignore conditions that are outside the loop.
...
llvm-svn: 58631
2008-11-03 19:38:07 +00:00
Devang Patel
78b7de25d1
Turn floating point IVs into integer IVs where possible.
...
This allows SCEV users to effectively calculate trip count.
LSR later on transforms back integer IVs to floating point IVs
later on to avoid int-to-float casts inside the loop.
llvm-svn: 58625
2008-11-03 18:32:19 +00:00
Nick Lewycky
49abbde699
Changes from Duncan's review:
...
* merge two weak functions by making them both alias a third non-weak fn
* don't reimplement CallSite::hasArgument
* whitelist the safe linkage types
llvm-svn: 58568
2008-11-02 16:46:26 +00:00
Nick Lewycky
15a23d029c
Add a new MergeFunctions pass. It finds identical functions and merges them.
...
This triggers only 60 times in llvm-test (look at .llvm.bc, not .linked.rbc)
and so it probably wont be turned on by default. Also, may of those are likely
to go away when PR2973 is fixed.
llvm-svn: 58557
2008-11-02 05:52:50 +00:00
Nick Lewycky
bcadcbb1ec
Fix demanded bits analysis with srem by negative number. Based on a patch
...
by Richard Osborne.
llvm-svn: 58555
2008-11-02 02:41:50 +00:00
Dan Gohman
1f1ebc5389
Fix this recently moved code to use the correct type. CI is now a
...
ConstantInt, and SI is the original cast instruction. This fixes
PR2996.
llvm-svn: 58549
2008-11-02 00:17:33 +00:00
Dan Gohman
50061675c5
Canonicalize sext(i1) to i1?-1:0, and update various instcombine
...
optimizations accordingly.
llvm-svn: 58457
2008-10-30 20:40:10 +00:00
Daniel Dunbar
097da598fb
Add InlineCost class for represent the estimated cost of inlining a
...
function.
- This explicitly models the costs for functions which should
"always" or "never" be inlined. This fixes bugs where such costs
were not previously respected.
llvm-svn: 58450
2008-10-30 19:26:59 +00:00
Chris Lattner
4af91a146a
Fix PR2967 by not deleting volatile load/stores that occur before unreachable.
...
I don't really see this as being needed, but there is little harm from doing
it.
llvm-svn: 58385
2008-10-29 17:46:26 +00:00
Dan Gohman
3ceee36545
(A & sext(C)) | (B & ~sext(C) -> C ? A : B
...
llvm-svn: 58351
2008-10-28 22:38:57 +00:00
Chris Lattner
a57ac16183
no need to print output
...
llvm-svn: 58228
2008-10-27 06:56:35 +00:00
Nick Lewycky
44356e13da
Don't try to create a mask when we don't need one. Fixes a crash.
...
llvm-svn: 58075
2008-10-24 06:14:27 +00:00
Chris Lattner
3048ccc1f9
apply Eli's patch for PR2165 and provide a testcase.
...
llvm-svn: 57625
2008-10-16 05:26:51 +00:00
Dan Gohman
6f40163d83
Teach instcombine's visitLoad to scan back several instructions
...
to find opportunities for store-to-load forwarding or load CSE,
in the same way that visitStore scans back to do DSE. Also, define
a new helper function for testing whether the addresses of two
memory accesses are known to have the same value, and use it in
both visitStore and visitLoad.
These two changes allow instcombine to eliminate loads in code
produced by front-ends that frequently emit obviously redundant
addressing for memory references.
llvm-svn: 57608
2008-10-15 23:19:35 +00:00
Evan Cheng
591baeed7c
Combine (fcmp cc0 x, y) | (fcmp cc1 x, y) into a single fcmp when possible.
...
llvm-svn: 57515
2008-10-14 18:44:08 +00:00