Chris Lattner
ab0c73a95c
1) add '-debug' output
...
2) Return NULL instead of false in several places for tidiness.
3) fix a bug optimizing sprintf(p, "%c", x)
llvm-svn: 50521
2008-05-01 06:39:12 +00:00
Chris Lattner
be2bafbe92
Delete the IPO simplify-libcalls and completely reimplement it as
...
a FunctionPass. This makes it simpler, fixes dozens of bugs, adds
a couple of minor features, and shrinks is considerably: from
2214 to 1437 lines.
llvm-svn: 50520
2008-05-01 06:25:24 +00:00
Owen Anderson
aaa86b3249
This condition got inverted accidentally.
...
llvm-svn: 50473
2008-04-30 07:16:33 +00:00
Chris Lattner
15195e00ee
move lowering of llvm.memset -> store from simplify libcalls
...
to instcombine.
llvm-svn: 50472
2008-04-30 06:39:11 +00:00
Chris Lattner
844e32537d
use string length computation to generalize several xforms.
...
llvm-svn: 50464
2008-04-30 03:07:53 +00:00
Owen Anderson
cc69e3444e
Revert r50441. The original code was correct. Add some more comments so that I don't make the same mistake in the future.
...
llvm-svn: 50446
2008-04-29 21:51:00 +00:00
Owen Anderson
2caa79ae70
Fix a bug in memcpyopt where the memcpy-memcpy transform was never being applied because
...
we were checking for it in the wrong order. This caused a miscompilation because the
return slot optimization assumes that the call it is dealing with is NOT a memcpy.
llvm-svn: 50444
2008-04-29 21:26:06 +00:00
Owen Anderson
8150660ba3
We should be returning true here since we've changed the function.
...
llvm-svn: 50442
2008-04-29 21:02:46 +00:00
Owen Anderson
9db9df7329
A lot of cleanups and documentation improvements, as well as a few corner case fixes. Most
...
of this was suggested by Chris.
llvm-svn: 50441
2008-04-29 20:59:33 +00:00
Owen Anderson
5b7928f3d2
Rename DeadLoopElimination to LoopDeletion, part 2.
...
llvm-svn: 50437
2008-04-29 20:06:54 +00:00
Owen Anderson
f9e11b8327
Rename DeadLoopElimination to LoopDeletion, part one.
...
llvm-svn: 50436
2008-04-29 19:58:07 +00:00
Chris Lattner
5bd55b0885
don't eliminate load from volatile value on paths where the load is dead.
...
This fixes the second half of PR2262
llvm-svn: 50430
2008-04-29 17:28:22 +00:00
Chris Lattner
7099f3c400
fix a subtle volatile handling bug.
...
llvm-svn: 50428
2008-04-29 17:13:43 +00:00
Chris Lattner
5e47b186a7
Implement more aggressive support for analyzing string length. This
...
generalizes the previous code to handle the case when the string is not
an immediate to the strlen call (for example, crazy stuff like
strlen(c ? "foo" : "bart"+1) -> 3). This implements
gcc.c-torture/execute/builtins/strlen-2.c. I will generalize other
cases in simplifylibcalls to use the same routine later.
llvm-svn: 50408
2008-04-29 06:56:02 +00:00
Owen Anderson
dc1c838b4d
Clarify what we mean by a dead loop.
...
llvm-svn: 50406
2008-04-29 06:34:55 +00:00
Chris Lattner
51fe8415da
don't delete the last store to an alloca if the store is volatile.
...
llvm-svn: 50390
2008-04-29 04:58:38 +00:00
Owen Anderson
45b160745b
Add some more comments.
...
llvm-svn: 50384
2008-04-29 00:45:15 +00:00
Owen Anderson
e0f9e8446b
Remove debugging code.
...
llvm-svn: 50383
2008-04-29 00:39:24 +00:00
Owen Anderson
4cc52fd657
Add dead loop elimination, which removes dead loops for which we can compute
...
the trip count.
llvm-svn: 50382
2008-04-29 00:38:34 +00:00
Dan Gohman
9e4db7f0bd
Fix DSE to not eliminate volatile loads with no uses.
...
llvm-svn: 50370
2008-04-28 19:51:27 +00:00
Dan Gohman
1b7238e6e4
Teach InstCombine's ComputeMaskedBits what SelectionDAG's
...
ComputeMaskedBits knows about cttz, ctlz, and ctpop. Teach
SelectionDAG's ComputeMaskedBits what InstCombine's knows
about SRem. And teach them both some things about high bits
in Mul, UDiv, URem, and Sub. This allows instcombine and
dagcombine to eliminate sign-extension operations in
several new cases.
llvm-svn: 50358
2008-04-28 17:02:21 +00:00
Chris Lattner
ede7e89144
Fix PR2256, yet another miscompilation in simplifycfg of i
...
multiple return values.
Bill, please pull this into Tak.
llvm-svn: 50332
2008-04-28 00:19:07 +00:00
Chris Lattner
39a4281deb
Implement a signficant optimization for inline asm:
...
When choosing between constraints with multiple options,
like "ir", test to see if we can use the 'i' constraint and
go with that if possible. This produces more optimal ASM in
all cases (sparing a register and an instruction to load it),
and fixes inline asm like this:
void test () {
asm volatile (" %c0 %1 " : : "imr" (42), "imr"(14));
}
Previously we would dump "42" into a memory location (which
is ok for the 'm' constraint) which would cause a problem
because the 'c' modifier is not valid on memory operands.
Isn't it great how inline asm turns 'missed optimization'
into 'compile failed'??
Incidentally, this was the todo in
PowerPC/2007-04-24-InlineAsm-I-Modifier.ll
Please do NOT pull this into Tak.
llvm-svn: 50315
2008-04-27 00:37:18 +00:00
Chris Lattner
b83aaaa855
Move a bunch of inline asm code out of line.
...
llvm-svn: 50313
2008-04-27 00:09:47 +00:00
Chris Lattner
2798e42a9f
When SRoA'ing a global variable, make sure the new globals get the
...
appropriate alignment. This fixes a miscompilation of 252.eon on
x86-64 (rdar://5891920).
Bill, please pull this into Tak.
llvm-svn: 50308
2008-04-26 07:40:11 +00:00
Dale Johannesen
cfba8d51b8
change comments per review
...
llvm-svn: 50300
2008-04-25 21:16:07 +00:00
Dan Gohman
c4b6768db4
Remove the code from CodeGenPrepare that moved getresult instructions
...
to the block that defines their operands. This doesn't work in the
case that the operand is an invoke, because invoke is a terminator
and must be the last instruction in a block.
Replace it with support in SelectionDAGISel for copying struct values
into sequences of virtual registers.
llvm-svn: 50279
2008-04-25 18:27:55 +00:00
Nate Begeman
928566cbfe
Feedback from chris
...
llvm-svn: 50271
2008-04-25 17:45:52 +00:00
Nick Lewycky
1f831c0f57
Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
...
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123.
llvm-svn: 50265
2008-04-25 16:53:59 +00:00
Nate Begeman
26b6f640a1
Teach the PruningFunctionCloner how to look through loads with
...
ConstantExpression GEPs pointing into constant globals.
llvm-svn: 50256
2008-04-25 06:37:06 +00:00
Chris Lattner
1a6268f776
Don't infininitely thread branches when a threaded edge
...
goes back to the block, e.g.:
Threading edge through bool from 'bb37.us.thread3829' to 'bb37.us' with cost: 1, across block:
bb37.us: ; preds = %bb37.us.thread3829, %bb37.us, %bb33
%D1361.1.us = phi i32 [ %tmp36, %bb33 ], [ %D1361.1.us, %bb37.us ], [ 0, %bb37.us.thread3829 ] ; <i32> [#uses=2]
%tmp39.us = icmp eq i32 %D1361.1.us, 0 ; <i1> [#uses=1]
br i1 %tmp39.us, label %bb37.us, label %bb42.us
llvm-svn: 50251
2008-04-25 04:12:29 +00:00
Evan Cheng
c532dca878
Adjust inline cost computation to be less aggressive.
...
llvm-svn: 50222
2008-04-24 18:42:47 +00:00
Chris Lattner
a646a59205
code restructuring, not functionality change.
...
llvm-svn: 50203
2008-04-24 00:21:50 +00:00
Chris Lattner
10ffed0ed0
Don't replace multiple result of calls with undef,
...
sccp tracks getresult values, not call values in this
case.
llvm-svn: 50202
2008-04-24 00:19:54 +00:00
Chris Lattner
8c6e641cf4
code cleanup, no functionality change.
...
llvm-svn: 50201
2008-04-24 00:16:28 +00:00
Chris Lattner
be35a0c224
Split some code out of the main SimplifyCFG loop into its own function.
...
Fix said code to handle merging return instructions together correctly
when handling multiple return values.
llvm-svn: 50199
2008-04-24 00:01:19 +00:00
Devang Patel
88251a96f1
Check type instead of no. of operands.
...
llvm-svn: 50179
2008-04-23 20:18:29 +00:00
Dale Johannesen
d70ea13581
Rewrite previous patch to suit Chris's preference.
...
llvm-svn: 50174
2008-04-23 18:34:37 +00:00
Chris Lattner
bc79442313
simplify code for propagation of constant arguments into
...
callees.
llvm-svn: 50142
2008-04-23 06:16:27 +00:00
Chris Lattner
408b51d214
Fix a number of bugs in ipconstantprop, simplify the code, fit in 80 cols,
...
fix read after free bug (PR2238).
llvm-svn: 50141
2008-04-23 05:59:23 +00:00
Chris Lattner
721ea7ca10
Rewrite multiple return value handling in SCCP. Before, the -sccp pass
...
would turn every getresult instruction into undef. This helps with
rdar://5778210
llvm-svn: 50140
2008-04-23 05:38:20 +00:00
Dale Johannesen
3007fc4e1b
Do not change the type of a ByVal argument to a
...
type of a different size.
llvm-svn: 50121
2008-04-23 01:03:05 +00:00
Evan Cheng
680839e258
Don't do: "(X & 4) >> 1 == 2 --> (X & 4) == 4" if there are more than one uses of the shift result.
...
llvm-svn: 50118
2008-04-23 00:38:06 +00:00
Chris Lattner
e304ae5621
Start doing the significantly useful part of jump threading: handle cases
...
where a comparison has a phi input and that phi is a constant. For example,
stuff like:
Threading edge through bool from 'bb2149' to 'bb2231' with cost: 1, across block:
bb2237: ; preds = %bb2231, %bb2149
%tmp2328.rle = phi i32 [ %tmp2232, %bb2231 ], [ %tmp2232439, %bb2149 ] ; <i32> [#uses=2]
%done.0 = phi i32 [ %done.2, %bb2231 ], [ 0, %bb2149 ] ; <i32> [#uses=1]
%tmp2239 = icmp eq i32 %done.0, 0 ; <i1> [#uses=1]
br i1 %tmp2239, label %bb2231, label %bb2327
or
bb38.i298: ; preds = %bb33.i295, %bb1693
%tmp39.i296.rle = phi %struct.ibox* [ null, %bb1693 ], [ %tmp39.i296.rle1109, %bb33.i295 ] ; <%struct.ibox*> [#uses=2]
%minspan.1.i291.reg2mem.1 = phi i32 [ 32000, %bb1693 ], [ %minspan.0.i288, %bb33.i295 ] ; <i32> [#uses=1]
%tmp40.i297 = icmp eq %struct.ibox* %tmp39.i296.rle, null ; <i1> [#uses=1]
br i1 %tmp40.i297, label %implfeeds.exit311, label %bb43.i301
This triggers thousands of times in spec.
llvm-svn: 50110
2008-04-22 21:40:39 +00:00
Chris Lattner
c59cf9c8da
Dig through multiple levels of AND to thread jumps if needed.
...
llvm-svn: 50106
2008-04-22 20:46:09 +00:00
Chris Lattner
dcbc6443ae
Teach jump threading to thread through blocks like:
...
br (and X, phi(Y, Z, false)), label L1, label L2
This triggers once on 252.eon and 6 times on 176.gcc. Blocks
in question often look like this:
bb262: ; preds = %bb261, %bb248
%iftmp.251.0 = phi i1 [ true, %bb261 ], [ false, %bb248 ] ; <i1> [#uses=4]
%tmp270 = icmp eq %struct.rtx_def* %tmp.0.i, null ; <i1> [#uses=1]
%bothcond = or i1 %iftmp.251.0, %tmp270 ; <i1> [#uses=1]
br i1 %bothcond, label %bb288, label %bb273
In this case, it is clear that it doesn't matter if tmp.0.i is null when coming from bb261. When coming from bb248, it is all that matters.
Another random example:
check_asm_operands.exit: ; preds = %check_asm_operands.exit.thr_comm, %bb30.i, %bb12.i, %bb6.i413
%tmp.0.i420 = phi i1 [ true, %bb6.i413 ], [ true, %bb12.i ], [ true, %bb30.i ], [ false, %check_asm_operands.exit.thr_comm ; <i1> [#uses=1]
call void @llvm.stackrestore( i8* %savedstack ) nounwind
%tmp4389 = icmp eq i32 %added_sets_1.0, 0 ; <i1> [#uses=1]
%tmp4394 = icmp eq i32 %added_sets_2.0, 0 ; <i1> [#uses=1]
%bothcond80 = and i1 %tmp4389, %tmp4394 ; <i1> [#uses=1]
%bothcond81 = and i1 %bothcond80, %tmp.0.i420 ; <i1> [#uses=1]
br i1 %bothcond81, label %bb4398, label %bb4397
Here is the case from 252.eon:
bb290.i.i: ; preds = %bb23.i57.i.i, %bb8.i39.i.i, %bb100.i.i, %bb100.i.i, %bb85.i.i110
%myEOF.1.i.i = phi i1 [ true, %bb100.i.i ], [ true, %bb100.i.i ], [ true, %bb85.i.i110 ], [ true, %bb8.i39.i.i ], [ false, %bb23.i57.i.i ] ; <i1> [#uses=2]
%i.4.i.i = phi i32 [ %i.1.i.i, %bb85.i.i110 ], [ %i.0.i.i, %bb100.i.i ], [ %i.0.i.i, %bb100.i.i ], [ %i.3.i.i, %bb8.i39.i.i ], [ %i.3.i.i, %bb23.i57.i.i ] ; <i32> [#uses=3]
%tmp292.i.i = load i8* %tmp16.i.i100, align 1 ; <i8> [#uses=1]
%tmp293.not.i.i = icmp ne i8 %tmp292.i.i, 0 ; <i1> [#uses=1]
%bothcond.i.i = and i1 %tmp293.not.i.i, %myEOF.1.i.i ; <i1> [#uses=1]
br i1 %bothcond.i.i, label %bb202.i.i, label %bb301.i.i
Factoring out 3 common predecessors.
On the path from any blocks other than bb23.i57.i.i, the load and compare
are dead.
llvm-svn: 50096
2008-04-22 07:05:46 +00:00
Chris Lattner
003d69adef
refactor some code, no functionality change.
...
llvm-svn: 50094
2008-04-22 06:36:15 +00:00
Chris Lattner
8837037473
remove dead code.
...
llvm-svn: 50080
2008-04-22 03:21:48 +00:00
Chris Lattner
14be19cf1e
optimize "p != gep p, ..." better. This allows us to compile
...
getelementptr-seteq.ll into:
define i1 @test(i64 %X, %S* %P) {
%C = icmp eq i64 %X, -1 ; <i1> [#uses=1]
ret i1 %C
}
instead of:
define i1 @test(i64 %X, %S* %P) {
%A.idx.mask = and i64 %X, 4611686018427387903 ; <i64> [#uses=1]
%C = icmp eq i64 %A.idx.mask, 4611686018427387903 ; <i1> [#uses=1]
ret i1 %C
}
And fixes the second half of PR2235. This speeds up the insertion sort
case by 45%, from 1.12s to 0.77s. In practice, this will significantly
speed up for loops structured like:
for (double *P = Base + N; P != Base; --P)
...
Which happens frequently for C++ iterators.
llvm-svn: 50079
2008-04-22 02:53:33 +00:00
Chris Lattner
6e88cf849b
fix grammar-o, thanks to Duncan for noticing.
...
llvm-svn: 50047
2008-04-21 18:25:01 +00:00
Owen Anderson
b171c54227
Remove unneeded #include's.
...
llvm-svn: 50035
2008-04-21 07:47:38 +00:00
Owen Anderson
bc6046416f
Refactor memcpyopt based on Chris' suggestions. Consolidate several functions
...
and simplify code that was fallout from the separation of memcpyopt and gvn.
llvm-svn: 50034
2008-04-21 07:45:10 +00:00
Chris Lattner
ca82082080
don't assume that the argument passed to fprintf("%s" is a string. This
...
fixes a crash in opt on 433.milc.
llvm-svn: 50023
2008-04-21 03:18:33 +00:00
Chris Lattner
9a21fbcf81
Use the new SplitBlockPredecessors to implement a todo.
...
llvm-svn: 50022
2008-04-21 02:57:57 +00:00
Chris Lattner
57e11a167d
Move SplitBlockPredecessors out of loopsimplify into BasicBlockUtils.h
...
as a global helper function. At the same type, switch it from taking
a vector of predecessors to an arbitrary sequential input. This allows
us to switch LoopSimplify to use a SmallVector for various temporary
vectors that it passed into SplitBlockPredecessors.
llvm-svn: 50020
2008-04-21 01:28:02 +00:00
Chris Lattner
ba4567c335
Move domtree/frontier updating earlier, allowing us to use it to update phi
...
nodes, removing a hack.
llvm-svn: 50019
2008-04-21 01:05:08 +00:00
Chris Lattner
53fa4554be
Factor dominator tree and frontier updating into SplitBlockPredecessors
...
instead of doing it after every call.
llvm-svn: 50018
2008-04-21 00:54:38 +00:00
Chris Lattner
34894abd7f
fit some more code in 80 cols.
...
llvm-svn: 50016
2008-04-21 00:25:49 +00:00
Chris Lattner
7da61d5766
simplify code, fit in 80 cols.
...
llvm-svn: 50015
2008-04-21 00:23:14 +00:00
Chris Lattner
45b3ace5a3
fit in 80 cols
...
llvm-svn: 50014
2008-04-21 00:19:16 +00:00
Chris Lattner
56fbe56c25
finish the first cut of a jump threading pass implementation.
...
llvm-svn: 50006
2008-04-20 22:39:42 +00:00
Chris Lattner
4037996a0c
replace a slow and verbose version of Instruction::isUsedOutsideOfBlock with
...
a call to Instruction::isUsedOutsideOfBlock.
llvm-svn: 50005
2008-04-20 22:18:22 +00:00
Chris Lattner
c714a8cee8
we can only thread blocks when there is a pred we can determine the succ of.
...
llvm-svn: 50003
2008-04-20 21:18:09 +00:00
Chris Lattner
4fcfb808fb
improve comments, infrastructure, and add some validity checks for threading.
...
Add a cost function.
llvm-svn: 50002
2008-04-20 21:13:06 +00:00
Chris Lattner
c8c74f39db
Add a new Jump Threading pass, which will handle cases
...
such as those in PR2235. Right now the pass is not very
effective. :)
llvm-svn: 50000
2008-04-20 20:35:01 +00:00
Torok Edwin
e038c595c1
g++-4.3 build-fix: CHAR_BIT requires <climits>.
...
llvm-svn: 49989
2008-04-20 08:33:11 +00:00
Chris Lattner
f390d62b7f
Switch to using Simplified ConstantFP::get API.
...
llvm-svn: 49977
2008-04-20 00:41:09 +00:00
Chris Lattner
d299f7b8cf
Allow argpromote to promote struct arguments with a specified number
...
of elements. Patch by Matthijs Kooijman!
llvm-svn: 49962
2008-04-19 19:50:01 +00:00
Owen Anderson
cd1b9c4b43
Make GVN able to remove unnecessary calls to read-only functions again.
...
llvm-svn: 49842
2008-04-17 05:36:50 +00:00
Scott Michel
31b3639a2d
Remove unused variable
...
llvm-svn: 49838
2008-04-17 01:30:44 +00:00
Scott Michel
4b37c88f48
Workaround for PR2207, in which pred_iterator assert gets triggered due to a
...
wee problem in Xcode 2.[45]/gcc 4.0.1.
llvm-svn: 49831
2008-04-16 23:46:39 +00:00
Chuck Rose III
fbfb612c4e
VisualStudio project files updated. #include <algorithm> added to make VisualStudio happy. Also had to undefine setjmp because of #include <csetjmp> turning setjmp into _setjmp in VisualStudio.
...
llvm-svn: 49743
2008-04-15 21:27:11 +00:00
Dan Gohman
77049e31b6
Remove unnecessary <sstream> includes.
...
llvm-svn: 49681
2008-04-14 20:40:47 +00:00
Dan Gohman
3e7d0f3882
Minor whitespace and comment cleanups.
...
llvm-svn: 49671
2008-04-14 18:26:16 +00:00
Owen Anderson
8aaa632351
Revert r49614. As Dan pointed out, some of these aren't correct.
...
llvm-svn: 49657
2008-04-14 17:38:21 +00:00
Owen Anderson
b54defaff0
Replace calls of the form V1->setName(V2->getName()) with V1->takeName(V2),
...
which is significantly more efficient.
llvm-svn: 49614
2008-04-13 19:15:17 +00:00
Owen Anderson
f55bae07b7
Fix PR2213 by simultaneously making GVN more aggressive with the return values
...
of calls and less aggressive with non-readnone calls.
llvm-svn: 49516
2008-04-11 05:11:49 +00:00
Dan Gohman
318d9a6605
Teach InstCombine's ComputeMaskedBits to handle pointer expressions
...
in addition to integer expressions. Rewrite GetOrEnforceKnownAlignment
as a ComputeMaskedBits problem, moving all of its special alignment
knowledge to ComputeMaskedBits as low-zero-bits knowledge.
Also, teach ComputeMaskedBits a few basic things about Mul and PHI
instructions.
This improves ComputeMaskedBits-based simplifications in a few cases,
but more noticeably it significantly improves instcombine's alignment
detection for loads, stores, and memory intrinsics.
llvm-svn: 49492
2008-04-10 18:43:06 +00:00
Chris Lattner
0bd4d7eef1
Disable an xform we've had for a long time, pow(x,0.5) -> sqrt.
...
This is not safe for all inputs.
llvm-svn: 49458
2008-04-10 02:07:51 +00:00
Chris Lattner
be01a5f699
Generalize getUnaryFloatFunction to handle any FP unary function, automatically
...
figuring out the suffix to use. implement pow(2,x) -> exp2(x).
llvm-svn: 49437
2008-04-09 17:48:11 +00:00
Chris Lattner
0eb93cf8d0
use the new ConstantFP::get method to make this work with
...
long double and simplify the code.
llvm-svn: 49435
2008-04-09 17:17:35 +00:00
Devang Patel
47b4a18b75
Be conservative if getresult operand is neither call nor invoke.
...
llvm-svn: 49430
2008-04-09 15:58:24 +00:00
Owen Anderson
ca7e0e21f3
Factor a bunch of functionality related to memcpy and memset transforms out of
...
GVN and into its own pass.
llvm-svn: 49419
2008-04-09 08:23:16 +00:00
Owen Anderson
0d844f6205
Remove accidentally duplicated code.
...
llvm-svn: 49418
2008-04-09 07:55:01 +00:00
Chris Lattner
976ea8990e
many cleanups to the pow optimizer. Allow it to handle powf,
...
add support for pow(x, 2.0) -> x*x.
llvm-svn: 49411
2008-04-09 00:07:45 +00:00
Devang Patel
1cf9e1e337
Fix insert point handling for multiple return values.
...
llvm-svn: 49367
2008-04-08 02:24:08 +00:00
Owen Anderson
4ad5a5201c
Add operator= implementations to SparseBitVector, allowing it to be used in GVN. This results
...
in both time and memory savings for GVN. For example, one testcase went from 10.5s to 6s with
this patch.
llvm-svn: 49345
2008-04-07 17:38:23 +00:00
Duncan Sands
64f15131d8
Use Intrinsic::getDeclaration in more places.
...
llvm-svn: 49338
2008-04-07 13:45:04 +00:00
Duncan Sands
98ed2df5f3
The "stacksave is not nounwind problem" no longer
...
needs to be fixed here - a previous commit made sure
that intrinsics always get the right attributes.
So remove no-longer needed code, and while there use
Intrinsic::getDeclaration rather than getOrInsertFunction.
llvm-svn: 49337
2008-04-07 13:43:58 +00:00
Duncan Sands
9622724bc3
Use Intrinsic::getDeclaration to get hold of
...
intrinsics. Fix up the argument type (should
be i8*, was an array*).
llvm-svn: 49336
2008-04-07 13:41:19 +00:00
Owen Anderson
93ab00f1d9
Make GVN more memory efficient, particularly on code that contains a large number of
...
allocations, which GVN can't optimize anyways.
llvm-svn: 49329
2008-04-07 09:59:07 +00:00
Dale Johannesen
5c2c09c01b
Mark calls to llvm.stacksave, llvm.stackrestore as
...
nounwind. When such calls are inlined into something
else that is invoked, they were getting changed to invokes,
which is badness.
llvm-svn: 49299
2008-04-07 00:08:48 +00:00
Chris Lattner
f8fac07b94
silence a warning when assertions are disabled.
...
llvm-svn: 49283
2008-04-06 21:44:08 +00:00
Gabor Greif
6c6b8a57f3
API changes for class Use size reduction, wave 1.
...
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.
llvm-svn: 49277
2008-04-06 20:25:17 +00:00
David Greene
0ca05878fe
Iterators folloring a SmallVector erased element are invalidated so
...
don't access cached iterators from after the erased element.
Re-apply 49056 with SmallVector support.
llvm-svn: 49106
2008-04-02 18:24:46 +00:00
Evan Cheng
8a61b02bd8
1. Drop default inline threshold back down to 200.
...
2. Do not use # of basic blocks as part of the cost computation since it doesn't really figure into function size.
3. More aggressively inline function with vector code.
llvm-svn: 49061
2008-04-01 23:59:29 +00:00
Tanya Lattner
221aec3ddb
Reverting 49056 due to the build being broken.
...
llvm-svn: 49060
2008-04-01 23:41:44 +00:00
David Greene
f322cc7462
Iterators folloring a SmallVector erased element are invalidated so
...
don't access cached iterators from after the erased element.
llvm-svn: 49056
2008-04-01 22:14:23 +00:00
Dale Johannesen
8813206b7f
Revert 49006 for the moment.
...
llvm-svn: 49046
2008-04-01 20:00:57 +00:00
Dale Johannesen
fa4433be71
Emit exception handling info for functions which are
...
not marked nounwind, or for all functions when -enable-eh
is set, provided the target supports Dwarf EH.
llvm-gcc generates nounwind in the right places; other FEs
will need to do so also. Given such a FE, -enable-eh should
no longer be needed.
llvm-svn: 49006
2008-03-31 23:40:23 +00:00
Nate Begeman
610aa2511c
Don't eliminate bitcast instructions that change the type of a pointer
...
llvm-svn: 48971
2008-03-31 00:22:16 +00:00
Chris Lattner
49e9edd6f6
Fix "Control reaches the end of non-void function" warnings,
...
patch by David Chisnall.
llvm-svn: 48963
2008-03-30 18:22:13 +00:00
Chris Lattner
10e3ff7e5f
change iterator invalidation avoidance to just move the iterator backward
...
when something changes, instead of moving forward. This allows us to
simplify memset lowering, inserting the memset at the end of the range of
stuff we're touching instead of at the start.
This, in turn, allows us to make use of the addressing instructions already
used in the function instead of inserting our own. For example, we now
codegen:
%tmp41 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 0 ; <i8*> [#uses=2]
call void @llvm.memset.i64( i8* %tmp41, i8 -1, i64 8, i32 1 )
instead of:
%tmp20 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 7 ; <i8*> [#uses=1]
%ptroffset = getelementptr i8* %tmp20, i64 -7 ; <i8*> [#uses=1]
call void @llvm.memset.i64( i8* %ptroffset, i8 -1, i64 8, i32 1 )
llvm-svn: 48940
2008-03-29 05:15:47 +00:00
Chris Lattner
48b3859ee9
make the common case of a single store (which clearly shouldn't be turned
...
into a memset!) faster by avoiding an allocation of an std::list node.
llvm-svn: 48939
2008-03-29 04:52:12 +00:00
Chris Lattner
722c9a539f
give form-memset a significantly more sane heuristic, enable it by default.
...
llvm-svn: 48937
2008-03-29 04:36:18 +00:00
Chris Lattner
0a18724a00
make memset inference significantly more powerful: it can now handle
...
memsets that initialize "structs of arrays" and other store sequences
that are not sequential. This is still only enabled if you pass
-form-memset-from-stores. The flag is not heavily tested and I haven't
analyzed the perf regressions when -form-memset-from-stores is passed
either, but this causes no make check regressions.
llvm-svn: 48909
2008-03-28 06:45:13 +00:00
Devang Patel
85770c83ba
PHI->removeIncomingValue may remove PHInode.
...
Increment iterator in advance.
llvm-svn: 48890
2008-03-27 17:32:46 +00:00
Evan Cheng
563b265f37
Handle a special case xor undef, undef -> 0. Technically this should be transformed to undef. But this is such a common idiom (misuse) we are going to handle it.
...
llvm-svn: 48791
2008-03-25 20:07:13 +00:00
Devang Patel
425514c509
Add incoming value from header only if phi node has any use inside the loop.
...
llvm-svn: 48738
2008-03-24 20:16:14 +00:00
Evan Cheng
d01a2a18f8
Increasing the inline limit from (overly conservative) 200 to 300. Given each BB costs 20 and each instruction costs 5, 200 means a 4 BB function + 24 instructions (actually less because caller's size also contributes to it).
...
Furthermore, double the limit when more than 10% of the callee instructions are vector instructions. Multimedia kernels tend to love inlining.
llvm-svn: 48725
2008-03-24 06:37:48 +00:00
Evan Cheng
95cc5fca5c
Temporarily disabling memset forming optimization. Add an option.
...
llvm-svn: 48720
2008-03-24 05:28:38 +00:00
Evan Cheng
1d63708523
Transform (zext (or (icmp), (icmp))) to (or (zext (cimp), (zext icmp))) if at least one of the (zext icmp) can be transformed to eliminate an icmp.
...
llvm-svn: 48715
2008-03-24 00:21:34 +00:00
Anton Korobeynikov
48f56482e8
Preserve calling convention during function cloning
...
llvm-svn: 48708
2008-03-23 16:03:00 +00:00
Chris Lattner
16f62d36e8
implement an initial hack at a straight-line store -> memset optimization.
...
This fires dozens of times across spec and multisource, but I don't know
if it actually speeds stuff up. Hopefully the testers will show something
nice :)
llvm-svn: 48680
2008-03-22 05:37:16 +00:00
Chris Lattner
9a567d824d
implement the logic for memset insertion and store deletion.
...
llvm-svn: 48679
2008-03-22 04:13:49 +00:00
Chris Lattner
9d8b1ee347
This is a partially implemented and currently disabled start of a store
...
merging optimization. Nothing to see here, hopefully more later :)
llvm-svn: 48670
2008-03-22 00:31:52 +00:00
Dan Gohman
a363ba510c
Don't include <map> in Pass.h, which doesn't need it. This requires
...
adding <map> to many files that actually do need it.
llvm-svn: 48667
2008-03-21 23:51:57 +00:00
Chris Lattner
18f7655a45
the size of a smallvector shouldn't be part of the interface to these methods.
...
llvm-svn: 48662
2008-03-21 22:01:16 +00:00
Chris Lattner
15d06c679b
make gvn marginally faster by reallocating the lastSeenLoad map for
...
each basic block.
llvm-svn: 48660
2008-03-21 21:33:23 +00:00
Chris Lattner
b8102d9de3
Minor cleanups and shrinkification.
...
llvm-svn: 48658
2008-03-21 21:14:38 +00:00
Dan Gohman
59aeac6320
Handle getresult instructions in different basic blocks
...
from their aggregate operands by moving the getresult
instructions.
llvm-svn: 48657
2008-03-21 21:01:32 +00:00
Andrew Lenharth
2ff2bcbde8
FunctionExtractorPass has been superceded by GVExtractorPass
...
llvm-svn: 48648
2008-03-21 16:46:53 +00:00
Duncan Sands
530554ab0a
Fix the build for gcc-4.2.
...
llvm-svn: 48639
2008-03-21 08:32:17 +00:00
Chris Lattner
96cdf21ed4
Teach masked value is zero about add and sub, and use MVIZ to
...
simplify things like (X & 4) >> 1 == 2 --> (X & 4) == 4.
since it is obvious that the shift doesn't remove any bits.
llvm-svn: 48631
2008-03-21 05:19:58 +00:00
Devang Patel
192124d0e6
Incorporate feedback.
...
- Fix loop nest.
- Use RetVals.size()
- Check for null return value.
llvm-svn: 48605
2008-03-20 18:30:32 +00:00
Gordon Henriksen
dca0a5c5dc
C and Objective Caml bindings for mem2reg and reg2mem.
...
Patch by Erick Tryzelaar.
llvm-svn: 48602
2008-03-20 17:16:03 +00:00
Zhou Sheng
fc7856f528
Take the old function's name.
...
llvm-svn: 48588
2008-03-20 08:05:05 +00:00
Evan Cheng
c5f34f6463
80 col violation.
...
llvm-svn: 48573
2008-03-20 00:20:23 +00:00
Devang Patel
c9c6d88ee5
Add comment.
...
llvm-svn: 48567
2008-03-19 23:05:52 +00:00
Evan Cheng
5ef962445a
Remove dead options.
...
llvm-svn: 48556
2008-03-19 22:02:26 +00:00
Devang Patel
7efcb7de6b
Update heuritics that estimates cost of call instructions.
...
llvm-svn: 48474
2008-03-17 23:41:20 +00:00
Gordon Henriksen
8c33afc50c
C and Objective Caml bindings for several scalar transforms.
...
Patch originally by Erick Tryzelaar, but has been modified somewhat.
llvm-svn: 48419
2008-03-16 16:32:40 +00:00
Bill Wendling
7d054f8b3f
The inst combining of inttoptr into GEP with one index was using the bit size of
...
the type instead of the byte size. This was causing troublesome mis-compilations.
True to form, this took 2 days to find and is a one-line fix. :-P
llvm-svn: 48354
2008-03-14 05:12:19 +00:00
Owen Anderson
6c2454d9d1
Fix a bug in GVN that Duncan noticed, where we potentially need to insert a
...
pointer bitcast when performing return slot optimization.
llvm-svn: 48343
2008-03-13 22:07:10 +00:00
Nick Lewycky
b827640141
Update -mem2reg to use succ_iterator instead of iterating across TerminatorInst
...
successors. This makes it support nounwind.
llvm-svn: 48320
2008-03-13 02:42:41 +00:00
Chris Lattner
7925cc72c0
Reimplement the parameter attributes support, phase #1 . hilights:
...
1. There is now a "PAListPtr" class, which is a smart pointer around
the underlying uniqued parameter attribute list object, and manages
its refcount. It is now impossible to mess up the refcount.
2. PAListPtr is now the main interface to the underlying object, and
the underlying object is now completely opaque.
3. Implementation details like SmallVector and FoldingSet are now no
longer part of the interface.
4. You can create a PAListPtr with an arbitrary sequence of
ParamAttrsWithIndex's, no need to make a SmallVector of a specific
size (you can just use an array or scalar or vector if you wish).
5. All the client code that had to check for a null pointer before
dereferencing the pointer is simplified to just access the
PAListPtr directly.
6. The interfaces for adding attrs to a list and removing them is a
bit simpler.
Phase #2 will rename some stuff (e.g. PAListPtr) and do other less
invasive changes.
llvm-svn: 48289
2008-03-12 17:45:29 +00:00
Owen Anderson
5887233a3f
Improve the return slot optimization to be both more aggressive (not limited to sret parameters), and
...
safer (when the passed pointer might be invalid). Thanks to Duncan and Chris for the idea behind this,
and extra thanks to Duncan for helping me work out the trap-safety.
llvm-svn: 48280
2008-03-12 07:37:44 +00:00
Devang Patel
0b10747ac8
Check multiple return values.
...
llvm-svn: 48267
2008-03-12 00:32:32 +00:00
Devang Patel
9e4d8236fc
Fix attribute handling.
...
llvm-svn: 48262
2008-03-12 00:07:03 +00:00
Devang Patel
54b2c77a4e
Handle multiple ret values.
...
llvm-svn: 48254
2008-03-11 22:24:29 +00:00
Devang Patel
0fbeba7276
Initialize.
...
llvm-svn: 48253
2008-03-11 22:08:21 +00:00
Dan Gohman
34ea45f10d
Check to see if a two-entry PHI block can be simplified
...
before trying to merge the block into its predecessors.
This allows two-entry-phi-return.ll to be simplified
into a single basic block.
llvm-svn: 48252
2008-03-11 21:53:06 +00:00
Devang Patel
0c7fb89803
Skip functions that return multiple values.
...
llvm-svn: 48233
2008-03-11 18:04:06 +00:00
Devang Patel
cb8f342ea8
Become multiple return value aware.
...
Right now, the pass does not optimize tail recursions
involving multiple return values.
llvm-svn: 48228
2008-03-11 17:33:32 +00:00
Devang Patel
e163bda565
Add TODO reminder.
...
llvm-svn: 48227
2008-03-11 17:32:05 +00:00
Devang Patel
6c189c16b5
Initial multiple return values support.
...
llvm-svn: 48210
2008-03-11 05:46:42 +00:00
Devang Patel
f749084aa3
Restore optimization that merges blocks when inline function
...
has single return value.
llvm-svn: 48162
2008-03-10 18:34:00 +00:00
Devang Patel
0df6cb288f
Simplify
...
llvm-svn: 48161
2008-03-10 18:22:16 +00:00
Devang Patel
f81f0781cb
simplify
...
llvm-svn: 48160
2008-03-10 18:11:41 +00:00
Nick Lewycky
5dd879d5b5
Turn unwind_to into "unwinds to".
...
llvm-svn: 48123
2008-03-10 02:20:00 +00:00
Ted Kremenek
b05e945be4
Fix some compilation errors on msvc:
...
- "Redefinition of I" (iterator masks previous definition)
- include missing header file
Patch by Argiris Kirtzidis!
llvm-svn: 48115
2008-03-09 18:32:50 +00:00
Nick Lewycky
efac6a28b4
And again.
...
llvm-svn: 48112
2008-03-09 17:13:05 +00:00
Nick Lewycky
dd4885aa80
Braces belong here. No functionality change.
...
llvm-svn: 48111
2008-03-09 17:11:18 +00:00
Nick Lewycky
8626cfb86d
SCCP also needs to be taught to follow unwind_to
...
llvm-svn: 48109
2008-03-09 09:44:38 +00:00
Nick Lewycky
1d6b50743f
Don't eliminate blocks that are only reachable by unwind_to.
...
llvm-svn: 48106
2008-03-09 08:50:23 +00:00
Nick Lewycky
4732d3c9b7
Firstly, having a BranchInst isn't exclusive with having an unwind_to.
...
Secondly, we have to check whether the branch is actually pointing to the block
with the unwind in it. We could have gotten here because of the unwind_to alone.
llvm-svn: 48099
2008-03-09 07:50:37 +00:00
Nick Lewycky
e93a1819dc
A BB that unwind_to an "unwind" inst is that same as one that doesn't unwind_to
...
at all.
llvm-svn: 48096
2008-03-09 07:36:38 +00:00
Nick Lewycky
50c8d20ca2
Update the block cloner which fixes bugpoint on code using unwind_to (phew!)
...
and also update the cloning interface's major user, the loop optimizations.
llvm-svn: 48088
2008-03-09 05:24:34 +00:00
Nick Lewycky
d98272094e
Update the inliner and simplifycfg to handle unwind_to.
...
llvm-svn: 48086
2008-03-09 05:10:13 +00:00
Nick Lewycky
c64eb33c52
Two things. Preserve the unwind_to when splitting a BB.
...
Add the ability to remove just one instance of a BB from a phi node. This fixes
the compile error in the tree now.
llvm-svn: 48085
2008-03-09 05:04:48 +00:00
Nick Lewycky
980738baf2
Prune the unwind_to labels on BBs that don't need them. Another step in the
...
removal of invoke, PR1269.
llvm-svn: 48084
2008-03-09 04:55:16 +00:00
Nick Lewycky
e13db2c263
Not all users of a BB are Instructions any more.
...
llvm-svn: 48047
2008-03-08 07:48:41 +00:00
Devang Patel
9543238662
Update inliner to handle functions that return multiple values.
...
llvm-svn: 48020
2008-03-07 20:06:16 +00:00
Andrew Lenharth
6c788376e9
add a pass that can extract all kinds of global values, not just functions. Update llvm-extract to use it and optionally extract a global variable if you want it too
...
llvm-svn: 48015
2008-03-07 19:51:57 +00:00
Gabor Greif
d746841e93
fix typos
...
llvm-svn: 47994
2008-03-06 10:36:00 +00:00
Nick Lewycky
f249c5d5ad
Don't try to simplify urem and srem using arithmetic rules that don't work
...
under modulo (overflow). Fixes PR1933.
llvm-svn: 47987
2008-03-06 06:48:30 +00:00
Devang Patel
63e7d0fe7d
Skip, for now, callsites where use of sret argument is not dominated by callsite.
...
llvm-svn: 47980
2008-03-05 23:39:23 +00:00
Devang Patel
e2c01a6c92
Handle 'ret' with multiple values.
...
llvm-svn: 47965
2008-03-05 21:50:24 +00:00
Devang Patel
4ca594a2d7
Skip functions that return multiple values.
...
llvm-svn: 47924
2008-03-05 00:36:59 +00:00
Devang Patel
844c248410
Use while loop.
...
llvm-svn: 47909
2008-03-04 21:59:49 +00:00
Devang Patel
84e9abbb60
Use cast instead of dyn_cast.
...
Update test to use multiple return value directly, instead of relying on -sretpromotion.
llvm-svn: 47907
2008-03-04 21:45:28 +00:00
Devang Patel
219be17d65
Filter nested structs
...
llvm-svn: 47906
2008-03-04 21:32:09 +00:00
Devang Patel
a14b91d6a3
Handle multiple return values.
...
llvm-svn: 47904
2008-03-04 21:15:15 +00:00
Devang Patel
1e76b493c7
Use appropriate index to get the result value.
...
llvm-svn: 47897
2008-03-04 19:22:54 +00:00
Devang Patel
9eb2e291fb
Skip sret attribute while preparing attribute list for
...
new function and new call sites.
llvm-svn: 47896
2008-03-04 19:12:58 +00:00
Devang Patel
a880f004e8
Increment counter that keeps track of total number of sret promoted.
...
llvm-svn: 47892
2008-03-04 17:48:11 +00:00
Devang Patel
aef77854f9
Skip declarations.
...
llvm-svn: 47890
2008-03-04 17:47:06 +00:00
Devang Patel
e33efc5c23
Process externally visible functions also. Later on code generator will do the right thing.
...
llvm-svn: 47889
2008-03-04 17:46:26 +00:00
Devang Patel
10d720e1ba
Collect statistics.
...
llvm-svn: 47888
2008-03-04 17:44:37 +00:00
Devang Patel
d0d7028a2b
s/isReturnStruct()/hasStructRetAttr()/g
...
llvm-svn: 47857
2008-03-03 21:46:28 +00:00
Devang Patel
f7259bfa0b
Preserve paramater attributes.
...
llvm-svn: 47847
2008-03-03 18:36:03 +00:00
Chris Lattner
1e21cae4cd
allow specified inline threshold to be negative, as the value is
...
itself sometimes negative.
llvm-svn: 47786
2008-03-01 08:09:51 +00:00
Devang Patel
79236a7c7a
Fix cut-n-pasto.
...
llvm-svn: 47777
2008-02-29 23:41:13 +00:00
Devang Patel
cb72d92471
Add pass to promote sret.
...
This pass transforms
%struct._Point = type { i32, i32, i32, i32, i32, i32 }
define internal void @foo(%struct._Point* sret %agg.result)
into
%struct._Point = type { i32, i32, i32, i32, i32, i32 }
define internal %struct._Point @foo()
This pass updates foo() clients appropriately to use
getresult instruction to extract return values.
This pass is not yet ready for prime time.
llvm-svn: 47776
2008-02-29 23:34:08 +00:00
Chris Lattner
75f5d14574
fix a bug Anders ran into where scalarrepl would crash when promoting
...
a union containing a vector and an array whose elements were smaller than
the vector elements. this means we need to compile the load of the
array elements into an extract element plus a truncate.
llvm-svn: 47752
2008-02-29 07:12:06 +00:00
Chris Lattner
8f87e409b2
Refactor some code out of ConvertUsesToScalar into their own methods, no
...
functionality change.
llvm-svn: 47751
2008-02-29 07:03:13 +00:00
Chris Lattner
5aeccb7353
Folding or(fcmp,fcmp) only works if the operands of the fcmps are the same fp type.
...
llvm-svn: 47750
2008-02-29 06:09:11 +00:00
Owen Anderson
eadd074b22
Fix an issue where GVN had the sizes of the two memcpy's reverse, resulting
...
in an invalid transformation.
llvm-svn: 47639
2008-02-26 23:06:17 +00:00
Gabor Greif
2cb16cddf1
fix http://llvm.org/bugs/show_bug.cgi?id=2097
...
llvm-svn: 47615
2008-02-26 19:13:21 +00:00
Eli Friedman
1f2cabfbcf
Fix for pr2093: direct operands aren't necessarily addresses, so don't
...
try to simplify them.
llvm-svn: 47610
2008-02-26 18:37:49 +00:00
Bill Wendling
bd1f1ae160
De-tabify.
...
llvm-svn: 47599
2008-02-26 10:53:30 +00:00
Evan Cheng
6366bbf577
Fix PR2076. CodeGenPrepare now sinks address computation for inline asm memory
...
operands into inline asm block.
llvm-svn: 47589
2008-02-26 02:42:37 +00:00
Owen Anderson
6eafd532ab
Fix an issue where GVN was performing the return slot optimization when it was
...
not safe. This is fixed by more aggressively checking that the return slot is
not used elsewhere in the function.
llvm-svn: 47544
2008-02-25 04:08:09 +00:00
Owen Anderson
432abc0479
Fix an issue where GVN would try to use an instruction before its definition when performing return slot optimization.
...
llvm-svn: 47541
2008-02-25 00:40:41 +00:00
Dale Johannesen
ae08bdb4cf
Split ParameterAttributes.h, putting the complicated
...
stuff into ParamAttrsList.h. Per feedback from
ParamAttrs changes.
llvm-svn: 47504
2008-02-22 22:17:59 +00:00
Zhou Sheng
0742fbfedf
Fixed a typo.
...
llvm-svn: 47478
2008-02-22 10:00:35 +00:00
Dan Gohman
48d03d5a2d
Add explicit keywords.
...
llvm-svn: 47382
2008-02-20 16:44:09 +00:00
Anton Korobeynikov
c41f5b6af4
Fix newly-introduced 4.3 warnings
...
llvm-svn: 47375
2008-02-20 12:07:57 +00:00
Anton Korobeynikov
2523c8be38
Get rid of hash_map. Use StringMap instead
...
llvm-svn: 47373
2008-02-20 11:27:49 +00:00
Anton Korobeynikov
fd6b669c80
Make Transforms to be 4.3 warnings-clean
...
llvm-svn: 47371
2008-02-20 11:26:25 +00:00