Chris Lattner
9482cc5b16
revert previous two patches. They cause miscompilation of MultiSource/Applications/Burg
...
llvm-svn: 30397
2006-09-15 17:24:45 +00:00
Owen Anderson
edadd3faee
Revert my previous work on ArgumentPromotion. Further investigation has revealed these
...
changes to be incorrect. They just weren't showing up in any of our current testcases.
llvm-svn: 30385
2006-09-15 05:22:51 +00:00
Anton Korobeynikov
d61d39ec53
Adding dllimport, dllexport and external weak linkage types.
...
DLL* linkages got full (I hope) codegeneration support in C & both x86
assembler backends.
External weak linkage added for future use, we don't provide any
codegeneration, etc. support for it.
llvm-svn: 30374
2006-09-14 18:23:27 +00:00
Chris Lattner
237ccf2a51
Second half of the fix for Transforms/Inline/inline_cleanup.ll
...
This folds unconditional branches that are often produced by code
specialization.
llvm-svn: 30307
2006-09-13 21:27:00 +00:00
Nick Lewycky
12efffc96b
Add some more consistency checks.
...
llvm-svn: 30305
2006-09-13 19:32:53 +00:00
Nick Lewycky
51ce8d6b46
Fix unionSets so that it can merge correctly.
...
llvm-svn: 30304
2006-09-13 19:24:01 +00:00
Chris Lattner
6ef6d06d21
Implement the first half of Transforms/Inline/inline_cleanup.ll
...
llvm-svn: 30303
2006-09-13 19:23:57 +00:00
Nick Lewycky
3a4dc7b489
Erase dead instructions.
...
llvm-svn: 30298
2006-09-13 18:55:37 +00:00
Devang Patel
fab4972a6e
Initialize DontInternalize.
...
llvm-svn: 30281
2006-09-13 01:02:26 +00:00
Chris Lattner
1d7ec20a4d
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
llvm-svn: 30275
2006-09-12 19:17:09 +00:00
Chris Lattner
d28627009a
Fix PR905 and InstCombine/2006-09-11-EmptyStructCrash.ll
...
llvm-svn: 30266
2006-09-11 21:43:16 +00:00
Nick Lewycky
e94f42a740
Skip the linear search if the answer is already known.
...
llvm-svn: 30251
2006-09-11 17:23:34 +00:00
Chris Lattner
d1f8e07808
Allow tail duplication in more cases, relaxing the previous restriction a
...
bit. This fixes Regression/Transforms/TailDup/MergeTest.ll
llvm-svn: 30237
2006-09-10 18:17:58 +00:00
Nick Lewycky
9a22d7b60f
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.
llvm-svn: 30235
2006-09-10 02:27:07 +00:00
Chris Lattner
0468987592
Implement Transforms/InstCombine/hoist_instr.ll
...
llvm-svn: 30234
2006-09-09 22:02:56 +00:00
Chris Lattner
27ff96d87a
Make inlining costs more accurate.
...
llvm-svn: 30231
2006-09-09 20:40:44 +00:00
Chris Lattner
d79dc79831
Turn div X, (Cond ? Y : 0) -> div X, Y
...
This implements select.ll::test18.
llvm-svn: 30230
2006-09-09 20:26:32 +00:00
Chris Lattner
c465046e65
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
llvm-svn: 30158
2006-09-07 21:30:15 +00:00
Chris Lattner
845b223da4
Fix Duraid's changes to work when TLI is null. This fixes the failing
...
lowerinvoke regtests.
llvm-svn: 30115
2006-09-05 17:48:07 +00:00
Duraid Madina
cf6749e4c0
add setJumpBufSize() and setJumpBufAlignment() to target-lowering.
...
Call these from your backend to enjoy setjmp/longjmp goodness, see
lib/Target/IA64/IA64ISelLowering.cpp for an example
llvm-svn: 30095
2006-09-04 06:21:35 +00:00
Owen Anderson
19b80e76df
Make ArgumentPromotion handle recursive functions that pass pointers in their recursive calls.
...
llvm-svn: 30057
2006-09-02 21:19:44 +00:00
Nick Lewycky
8e5599354a
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.
llvm-svn: 30055
2006-09-02 19:40:38 +00:00
Nick Lewycky
f6f529d008
Don't confuse canonicalize and lookup. Fixes predsimplify.reg4.ll. Also
...
corrects missing optimization opportunity removing cases from a switch.
llvm-svn: 30009
2006-09-01 03:26:35 +00:00
Nick Lewycky
08674ab707
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.
llvm-svn: 29991
2006-08-31 00:39:16 +00:00
Nick Lewycky
5f8f9af65c
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.
llvm-svn: 29970
2006-08-30 02:46:48 +00:00
Devang Patel
f489d0f85c
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.
llvm-svn: 29966
2006-08-29 22:29:16 +00:00
Owen Anderson
a8a2e5c666
Clean up a bit.
...
llvm-svn: 29950
2006-08-29 06:10:56 +00:00
Nick Lewycky
b2e8ae1700
Add PredicateSimplifier pass. Collapses equal variables into one form
...
and simplifies expressions. This implements the optimization described
in PR807.
llvm-svn: 29947
2006-08-28 22:44:55 +00:00
Owen Anderson
62c84fe371
Make LoopUnroll fold excessive BasicBlocks. This results in a significant speedup of
...
gccas on 252.eon
llvm-svn: 29936
2006-08-28 02:09:46 +00:00
Chris Lattner
97c9f20c52
simplify AnalysisGroup registration, eliminating one typeid call.
...
llvm-svn: 29932
2006-08-28 00:42:29 +00:00
Chris Lattner
c2d3d3112e
eliminate RegisterOpt. It does the same thing as RegisterPass.
...
llvm-svn: 29925
2006-08-27 22:42:52 +00:00
Chris Lattner
3d27be1333
s|llvm/Support/Visibility.h|llvm/Support/Compiler.h|
...
llvm-svn: 29911
2006-08-27 12:54:02 +00:00
Owen Anderson
403b95af47
Fix a crash related to updating Phi nodes in the original header block. This was
...
causing a crash in 175.vpr
llvm-svn: 29887
2006-08-25 22:13:55 +00:00
Owen Anderson
8e4b029573
Add an assertion to check that we're really preserving LCSSA.
...
llvm-svn: 29886
2006-08-25 22:12:36 +00:00
Owen Anderson
8cca95cf5d
Reapply the indvars patch, since nothing blew up last night.
...
llvm-svn: 29874
2006-08-25 17:41:25 +00:00
Owen Anderson
94446a4267
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.
llvm-svn: 29868
2006-08-25 03:45:57 +00:00
Owen Anderson
15a6423431
Specify that indvars actually preserve LCSSA. This has been done for a while, but I
...
forgot to put in the analysis usage.
llvm-svn: 29867
2006-08-25 03:32:13 +00:00
Owen Anderson
e001d811ba
Implement unrolling of multiblock loops. This significantly improves the
...
utility of the LoopUnroll pass.
Also, add a testcase for multiblock-loop unrolling.
llvm-svn: 29859
2006-08-24 21:28:19 +00:00
Reid Spencer
5495fe8dd6
Fix a grammaro in a comment.
...
llvm-svn: 29765
2006-08-18 09:01:07 +00:00
Chris Lattner
6441cf93c9
Handle single-entry PHI nodes correctly. This fixes PR877 and
...
Transforms/CondProp/2006-08-14-SingleEntryPhiCrash.ll
llvm-svn: 29673
2006-08-14 21:38:05 +00:00
Chris Lattner
f18b396cc2
Don't attempt to split subloops out of a loop with a huge number of backedges.
...
Not only will this take huge amounts of compile time, the resultant loop nests
won't be useful for optimization. This reduces loopsimplify time on
Transforms/LoopSimplify/2006-08-11-LoopSimplifyLongTime.ll from ~32s to ~0.4s
with a debug build of llvm on a 2.7Ghz G5.
llvm-svn: 29647
2006-08-12 05:25:00 +00:00
Chris Lattner
85d9944f9a
Reimplement the loopsimplify code which deletes edges from unreachable
...
blocks that target loop blocks.
Before, the code was run once per loop, and depended on the number of
predecessors each block in the loop had. Unfortunately, scanning preds can
be really slow when huge numbers of phis exist or when phis with huge numbers
of inputs exist.
Now, the code is run once per function and scans successors instead of preds,
which is far faster. In addition, the new code is simpler and is goto free,
woo.
This change speeds up a nasty testcase Duraid provided me from taking hours to
taking ~72s with a debug build. The functionality this implements is already
tested in the testsuite as Transforms/CodeExtractor/2004-03-13-LoopExtractorCrash.ll.
llvm-svn: 29644
2006-08-12 04:51:20 +00:00
Reid Spencer
2b6d18a64f
Make this example pass use some things from lib/Support (EscapeString,
...
SlowOperatingInfo, Statistics). Besides providing an example of how to
use these facilities, it also serves to debug problems with runtime linking
when dlopening a loadable module. These three support facilities exercise
different combinations of Text/Weak Weak/Text and Text/Text linking
between the executable and the module.
llvm-svn: 29552
2006-08-07 23:17:24 +00:00
Reid Spencer
e6458c3fb2
For PR780:
...
1. Change the usage of LOADABLE_MODULE so that it implies all the things
necessary to make a loadable module. This reduces the user's burdern to
get a loadable module correctly built.
2. Document the usage of LOADABLE_MODULE in the MakefileGuide
3. Adjust the makefile for lib/Transforms/Hello to use the new specification
for building loadable modules
4. Adjust the sample project to not attempt to build a shared library for
its little library. This was just wasteful and not instructive at all.
llvm-svn: 29551
2006-08-07 23:12:15 +00:00
Chris Lattner
c9009d917d
Fix PR867 (and maybe 868) and testcsae:
...
Transforms/SimplifyCFG/2006-08-03-Crash.ll
llvm-svn: 29515
2006-08-03 21:40:24 +00:00
Chris Lattner
3ff620178b
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. :)
llvm-svn: 29493
2006-08-03 06:34:50 +00:00
Chris Lattner
38b6e8382a
Add special check to avoid isLoop call. Simple, but doesn't seem to speed
...
up lcssa much in practice.
llvm-svn: 29465
2006-08-02 00:16:47 +00:00
Chris Lattner
5a2bc786be
Replace the SSA update code in LCSSA with a bottom-up approach instead of a top
...
down approach, inspired by discussions with Tanya.
This approach is significantly faster, because it does not need dominator
frontiers and it does not insert extraneous unused PHI nodes. For example, on
252.eon, in a release-asserts build, this speeds up LCSSA (which is the slowest
pass in gccas) from 9.14s to 0.74s on my G5. This code is also slightly smaller
and significantly simpler than the old code.
Amusingly, in a normal Release build (which includes the
"assert(L->isLCSSAForm());" assertion), asserting that the result of LCSSA
is in LCSSA form is actually slower than the LCSSA transformation pass
itself on 252.eon. I will see if Loop::isLCSSAForm can be sped up next.
llvm-svn: 29463
2006-08-02 00:06:09 +00:00
Chris Lattner
85ea83e821
Add some advice
...
llvm-svn: 29324
2006-07-27 04:24:14 +00:00
Chris Lattner
1b928478aa
Minor comment tweaks
...
llvm-svn: 29226
2006-07-20 19:06:16 +00:00
Devang Patel
edd2f9952e
Make it fit into 80 cols.
...
llvm-svn: 29223
2006-07-20 18:03:39 +00:00
Devang Patel
839d9260f0
Add new constructor to accept vector of exported names while creating
...
InternalizePass.
llvm-svn: 29222
2006-07-20 17:48:05 +00:00
Owen Anderson
8ef4c92ef8
Add an assertion.
...
llvm-svn: 29199
2006-07-19 05:48:45 +00:00
Owen Anderson
aba8c199dd
Make LoopUnroll not die on LCSSA Phis. This makes lencod work again.
...
llvm-svn: 29198
2006-07-19 05:45:14 +00:00
Owen Anderson
00b974cdbc
Fix a error that hadn't yet cause any problems, but I'm sure it would have
...
somewhere down the road.
llvm-svn: 29197
2006-07-19 03:51:48 +00:00
Chris Lattner
fea3974133
silence warnings in a release build
...
llvm-svn: 29189
2006-07-18 21:48:57 +00:00
Evan Cheng
e9c68f52e1
Only reuse a previous IV if it would not require a type conversion.
...
llvm-svn: 29186
2006-07-18 19:07:58 +00:00
Chris Lattner
19247f36ea
eliminate some ugly code, using ConstantExpr::getWithOperands instead.
...
llvm-svn: 29149
2006-07-14 22:21:31 +00:00
Owen Anderson
bea70ee1de
Hopefully the final attempt at making IndVars preserve LCSSA.
...
This should fix PR 831.
llvm-svn: 29141
2006-07-14 18:49:15 +00:00
Chris Lattner
9b6c02ebe4
Revert this patch temporarily until PR831 is fixed.
...
llvm-svn: 29134
2006-07-13 19:05:20 +00:00
Chris Lattner
b3c64f7ab3
Handle instructions in the map, but that map to a null pointer.
...
This unbreaks smg2000.
llvm-svn: 29127
2006-07-12 21:37:11 +00:00
Owen Anderson
dea9202e3b
IndVars now (correctly) preserves LCSSA form.
...
llvm-svn: 29126
2006-07-12 21:29:14 +00:00
Chris Lattner
6148456ec2
In addition to deleting calls, the inliner can constant fold them as well.
...
Handle this case, which doesn't require a new callgraph edge. This fixes
a crash compiling MallocBench/gs.
llvm-svn: 29121
2006-07-12 18:37:18 +00:00
Chris Lattner
5de3b8b262
Change the callgraph representation to store the callsite along with the
...
target CG node. This allows the inliner to properly update the callgraph
when using the pruning inliner. The pruning inliner may not copy over all
call sites from a callee to a caller, so the edges corresponding to those
call sites should not be copied over either.
This fixes PR827 and Transforms/Inline/2006-07-12-InlinePruneCGUpdate.ll
llvm-svn: 29120
2006-07-12 18:29:36 +00:00
Chris Lattner
091b6ea847
Silence a warning produced in assertions-disabled mode
...
llvm-svn: 29108
2006-07-11 18:31:26 +00:00
Owen Anderson
15b1f7d2cd
Revert my indvars changes because they were breaking things. Unfortunately this
...
didn't start showing up until after the recent instcombine fixes.
llvm-svn: 29102
2006-07-11 07:25:33 +00:00
Owen Anderson
bbf8990ef7
Add a comment, and fix a typo that broke the build.
...
llvm-svn: 29094
2006-07-10 22:15:25 +00:00
Owen Anderson
ae8aa646f1
Don't indent the entire function.
...
llvm-svn: 29093
2006-07-10 22:03:18 +00:00
Chris Lattner
b7845d69db
Recognize 16-bit bswaps by relaxing overconstrained pattern.
...
This implements Transforms/InstCombine/bswap.ll:test[34].
llvm-svn: 29087
2006-07-10 20:25:24 +00:00
Owen Anderson
a6968f83b2
Make instcombine not remove Phi nodes when LCSSA is live.
...
llvm-svn: 29083
2006-07-10 19:03:49 +00:00
Owen Anderson
fe6e97d275
Fix typo in the comment.
...
llvm-svn: 29078
2006-07-09 21:35:40 +00:00
Owen Anderson
aecaabb6e1
Add a fix for an issue where LCSSA would fail to insert undef's in some corner
...
cases. Ideally, this issue will go away in the future as LCSSA gets smarter
about which Phi nodes it inserts.
llvm-svn: 29076
2006-07-09 08:14:06 +00:00
Chris Lattner
fd2e13b107
Fix PR820 and Transforms/GlobalOpt/2006-07-07-InlineAsmCrash.ll
...
llvm-svn: 29071
2006-07-07 21:37:01 +00:00
Chris Lattner
996795b0dd
Use hidden visibility to make symbols in an anonymous namespace get
...
dropped. This shrinks libllvmgcc.dylib another 67K
llvm-svn: 28975
2006-06-28 23:17:24 +00:00
Chris Lattner
4a4c7fe7fa
Shrink libllvmgcc.dylib by another 23K
...
llvm-svn: 28972
2006-06-28 22:08:15 +00:00
Owen Anderson
18e816f356
Switch to a very conservative heuristic for determining when loop-unswitching
...
will be profitable. This is mainly to remove some cases where excessive
unswitching would result in long compile times and/or huge generated code.
Once someone comes up with a better heuristic that avoids these cases, this
should be switched out.
llvm-svn: 28962
2006-06-28 17:47:50 +00:00
Chris Lattner
3fda386965
Fix Transforms/InstCombine/2006-06-28-infloop.ll
...
llvm-svn: 28961
2006-06-28 17:34:50 +00:00
Chris Lattner
0a2e11260e
Don't unswitch really large loops even if they are mostly filled with empty
...
blocks.
llvm-svn: 28959
2006-06-28 16:38:55 +00:00
Andrew Lenharth
ebfa24ee9a
Catch more function pointer casting problems
...
Remove the Function pointer cast in these calls, converting it to
a cast of argument.
%tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( int 10 )
%tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( uint %tmp51 )
llvm-svn: 28953
2006-06-28 01:01:52 +00:00
Owen Anderson
bb3ae5eb8f
Fix for 2006-06-27-DeadSwitchCase.ll
...
Be more careful when updating Phi nodes after eliminating dead switch cases. Fix
proposed by Chris.
llvm-svn: 28947
2006-06-27 22:26:09 +00:00
Chris Lattner
c4998a0138
Fix Transforms/DeadArgElim/2006-06-27-struct-ret.ll. -deadargelim should not
...
remove the struct return argument of a csret function, even if it is obviously
dead.
llvm-svn: 28943
2006-06-27 21:05:04 +00:00
Owen Anderson
b659bb4196
De-pessimize the handling of LCSSA Phi nodes in IndVarSimplify. Hopefully this
...
will make Shootout-C/nestedloop faster.
llvm-svn: 28924
2006-06-27 02:17:08 +00:00
Chris Lattner
49771a0462
random code cleanups, no functionality change
...
llvm-svn: 28914
2006-06-26 19:10:05 +00:00
Owen Anderson
f52351e50f
Make LoopUnswitch able to unswitch loops with live-out values by taking advantage
...
of LCSSA. This results several times the number of unswitchings occurring on
tests such and timberwolfmc, unix-tbl, and ldecod.
llvm-svn: 28912
2006-06-26 07:44:36 +00:00
Chris Lattner
053fb9319d
Fix IndVarsSimplify/2006-06-16-Indvar-LCSSA-Crash.ll, a case where a
...
"LCSSA" phi node causes indvars to break dominance properties. This fixes
causes indvars to avoid inserting aggressive code in this case, instead
indvars should be fixed to be more aggressive in the face of lcssa phi's.
llvm-svn: 28850
2006-06-17 01:02:31 +00:00
Evan Cheng
8a417a2fde
Add missing casts. This fixed some regressions.
...
llvm-svn: 28834
2006-06-16 18:37:15 +00:00
Evan Cheng
1fc4025a9c
More libcall transformations:
...
printf("%s\n", str) -> puts(str)
printf("%c", c) -> putchar(c)
Also fixed fprintf(file, "%c", c) -> fputc(c, file)
llvm-svn: 28815
2006-06-16 08:36:35 +00:00
Evan Cheng
f2ea587aa2
Simplify fprintf(file, "%s", str) to fputs(str, file).
...
llvm-svn: 28814
2006-06-16 04:52:30 +00:00
Chris Lattner
c482a9e31a
Implement Transforms/InstCombine/bswap.ll, turning common shift/and/or bswap
...
idioms into bswap intrinsics.
llvm-svn: 28803
2006-06-15 19:07:26 +00:00
Chris Lattner
0c4f5a655a
Fix Transforms/LoopUnswitch/2006-06-13-SingleEntryPHI.ll, a loop unswitch
...
bug exposed by the recent lcssa work.
llvm-svn: 28779
2006-06-14 04:46:17 +00:00
Chris Lattner
e3abb14503
Use the PotDoms map to memoize 'dominating value' lookup. With this patch,
...
LCSSA is still the slowest pass when gccas'ing 252.eon, but now it only takes
39s instead of 289s. :)
llvm-svn: 28776
2006-06-14 01:13:57 +00:00
Owen Anderson
e714a5c549
Fix another instance where PHI nodes need special treatment.
...
llvm-svn: 28774
2006-06-13 20:50:09 +00:00
Owen Anderson
3f8ff0449a
Fix a bug that was causing major slowdowns in povray. This was due to LCSSA
...
not handling PHI nodes correctly when determining if a value was live-out.
This patch reduces the number of detected live-out variables in the testcase
from 6565 to 485.
llvm-svn: 28771
2006-06-13 19:37:18 +00:00
Owen Anderson
fd0a3d6e5c
Reapply my 6/9 changes. The bug Evan saw no longer occurs.
...
llvm-svn: 28759
2006-06-12 21:49:21 +00:00
Chris Lattner
b5c9d7a0af
Fix an infinite loop on Transforms/SimplifyCFG/2006-06-12-InfLoop.ll
...
llvm-svn: 28758
2006-06-12 20:18:01 +00:00
Owen Anderson
0ac336965e
Fix for 2006-06-26-MultipleExitsSingleBlock.
...
If a single exit block has multiple predecessors within the loop, it will
appear in the exit blocks list more than once. LCSSA needs to take that into
account so that it doesn't double process that exit block.
llvm-svn: 28750
2006-06-12 07:10:16 +00:00
Owen Anderson
b538f14d2a
Re-commit the safe parts of my 6/9 patch. Still working on fixing the unsafe parts.
...
llvm-svn: 28748
2006-06-11 19:22:28 +00:00
Evan Cheng
1b6e310e6f
Back out Owen's 6/9 changes. They broke MultiSource/Benchmarks/Prolangs-C/bison (and perhaps others).
...
llvm-svn: 28747
2006-06-11 09:32:57 +00:00
Owen Anderson
b1dc1d44f8
Add LCSSA as a requirement for LoopUnswitch, and assert that LoopUnswitch preserves
...
LCSSA.
llvm-svn: 28739
2006-06-09 18:40:32 +00:00
Owen Anderson
505adff3f0
Make Loop able to verify that it is in LCSSA-form, and have the LCSSA pass assert
...
on this.
llvm-svn: 28738
2006-06-09 18:33:30 +00:00
Evan Cheng
398f70292c
RewriteExpr, either the new PHI node of induction variable or the
...
post-increment value, should be first cast to the appropriated type (to the
type of the common expr). Otherwise, the rewrite of a use based on (common +
iv) may end up with an incorrect type.
llvm-svn: 28735
2006-06-09 00:12:42 +00:00
Owen Anderson
5d029264ec
Update some comments, and expose LCSSAID in preparation for having other passes
...
require LCSSA.
llvm-svn: 28734
2006-06-08 20:02:53 +00:00
Reid Spencer
d4b795902c
Fix a spello in a comment.
...
llvm-svn: 28714
2006-06-07 21:24:10 +00:00
Chris Lattner
95cebb082f
Fix a bug in a recent patch. This fixes UnitTests/Vector/Altivec/casts.c on
...
PPC/altivec
llvm-svn: 28698
2006-06-06 22:26:02 +00:00
Owen Anderson
ac601b4c4b
Fix some formatting, and use inLoop() when appropriate.
...
llvm-svn: 28694
2006-06-06 04:36:36 +00:00
Owen Anderson
9e81c1bb03
Stop a memory leak, and update some comments.
...
llvm-svn: 28693
2006-06-06 04:28:30 +00:00
Owen Anderson
766f90b08e
Some more clean-up, and squash an IDF-Phi related bug.
...
llvm-svn: 28680
2006-06-04 00:55:19 +00:00
Owen Anderson
eb33815f1b
Various clean-ups suggested by Chris.
...
llvm-svn: 28678
2006-06-04 00:02:23 +00:00
Owen Anderson
d00eacc4f9
Fix a bug in Phi-noded insertion. Also, update some comments to reflect what's
...
actually going on.
llvm-svn: 28677
2006-06-03 23:22:50 +00:00
Chris Lattner
540886f0ae
Remove unneeded hook. Patch by Anton K. Thanks!
...
llvm-svn: 28664
2006-06-02 19:11:46 +00:00
Chris Lattner
02e0b4ddb7
Force anything that #includes llvm/Transforms/Utils/UnifyFunctionExitNodes.h
...
to link in the implementation. Thanks to Anton Korobeynikov for figuring out
what was going on here.
llvm-svn: 28660
2006-06-02 18:40:06 +00:00
Chris Lattner
cdf2b1fc30
Remove dead #include
...
llvm-svn: 28642
2006-06-01 20:02:28 +00:00
Chris Lattner
cc340c02a4
Make the "pruning cloner" smarter. As it propagates constants through the
...
code (while cloning) it often gets the branch/switch instructions. Since it
knows that edges of the CFG are dead, it need not clone (or even look) at
the obviously dead blocks. This should speed up the inliner substantially on
code where there are lots of inlinable calls to functions with constant
arguments. On C++ code in particular, this kicks in.
llvm-svn: 28641
2006-06-01 19:19:23 +00:00
Chris Lattner
f905a7b994
Silence a -pedantic warning.
...
llvm-svn: 28632
2006-06-01 17:16:21 +00:00
Owen Anderson
619e4ba57f
Remove a FIXME that was fixed with my last patch.
...
llvm-svn: 28619
2006-06-01 06:07:40 +00:00
Owen Anderson
cd76fa04a1
More cleanups. Also, add a special case for updating PHI nodes, and
...
reimplement getValueDominatingFunction to walk the DominanceTree rather than
just searching blindly.
llvm-svn: 28618
2006-06-01 06:05:47 +00:00
Chris Lattner
1df0e98ac2
Swap the order of operands created here. For +&|^, the order doesn't matter,
...
but for sub, it really does! Fix fixes a miscompilation of fibheap_cut in
llvmgcc4.
llvm-svn: 28600
2006-05-31 21:14:00 +00:00
Owen Anderson
dad8c57340
Extract a huge loop into a helper method. Fix a few iterator-invalidation bugs.
...
llvm-svn: 28599
2006-05-31 20:55:06 +00:00
Owen Anderson
8a8f278f15
Add Use replacement. Assuming there is nothing horribly wrong with this, LCSSA
...
is now theoretically feature-complete. It has not, however, been thoroughly
test, and is still considered experimental.
llvm-svn: 28529
2006-05-29 01:00:00 +00:00
Owen Anderson
152d063ccb
Major think-o. Iterate over all live out-of-loop values, and perform the
...
other calculations on each individually, rather than trying to delay it and do
them all at the end.
llvm-svn: 28527
2006-05-28 19:33:28 +00:00
Owen Anderson
1310e42803
Make LCSSA insert proper Phi nodes throughout the rest of the CFG by computing
...
the iterated Dominance Frontier of the loop-closure Phi's. This is the
second phase of the LCSSA pass. The third phase (coming soon) will be to
update all uses of loop variables to use the loop-closure Phi's instead.
llvm-svn: 28524
2006-05-27 18:47:11 +00:00
Chris Lattner
67c424e010
Fix some regression from the inliner patch I committed last night. This fixes
...
ldecod, lencod, and SPASS.
llvm-svn: 28523
2006-05-27 17:28:13 +00:00
Chris Lattner
be853d77e9
Switch the inliner over to using CloneAndPruneFunctionInto. This effectively
...
makes it so that it constant folds instructions on the fly. This is good
for several reasons:
0. Many instructions are constant foldable after inlining, particularly if
inlining a call with constant arguments.
1. Without this, the inliner has to allocate memory for all of the instructions
that can be constant folded, then a subsequent pass has to delete them. This
gets the job done without this extra work.
2. This makes the inliner *pass* a bit more aggressive: in particular, it
partially solves a phase order issue where the inliner would inline lots
of code that folds away to nothing, but think that the resultant function
is big because of this code that will be gone. Now the code never exists.
This is the first part of a 2-step process. The second part will be smart
enough to see when this implicit constant folding propagates a constant into
a branch or switch instruction, making CFG edges dead.
This implements Transforms/Inline/inline_constprop.ll
llvm-svn: 28521
2006-05-27 01:28:04 +00:00
Chris Lattner
3df13f4f22
Implement a new method, CloneAndPruneFunctionInto, as documented.
...
llvm-svn: 28519
2006-05-27 01:22:24 +00:00
Chris Lattner
bc3c879fcf
Refactor some code to expose an interface to constant fold and instruction given it's opcode, typeand operands.
...
llvm-svn: 28517
2006-05-27 01:18:04 +00:00
Owen Anderson
b4e16996f1
A few small clean-ups, and the addition of an LCSSA statistic.
...
llvm-svn: 28512
2006-05-27 00:31:37 +00:00
Owen Anderson
6e047ab8fc
Fix a copy-and-paste-o that would break some compilers.
...
llvm-svn: 28507
2006-05-26 21:19:17 +00:00
Owen Anderson
f3dd3e2bfd
Clean up and refactor LCSSA a bunch. It should also run faster now, though
...
there's still a lot of work to be done on it.
llvm-svn: 28506
2006-05-26 21:11:53 +00:00
Chris Lattner
dab43b2b0e
Implement Transforms/InstCombine/store.ll:test2.
...
llvm-svn: 28503
2006-05-26 19:19:20 +00:00
Owen Anderson
8eca8910b6
Skeletal LCSSA pass. This is currently non-functional. Expect functionality
...
and documentation updates soo.
llvm-svn: 28495
2006-05-26 13:58:26 +00:00
Chris Lattner
0e47716e69
Transform things like (splat(splat)) -> splat
...
llvm-svn: 28490
2006-05-26 00:29:06 +00:00
Chris Lattner
12249be286
Introduce a helper function that simplifies interpretation of shuffle masks.
...
No functionality change.
llvm-svn: 28489
2006-05-25 23:48:38 +00:00
Chris Lattner
99155be33f
Turn (cast (shuffle (cast)) -> shuffle (cast) if it reduces the # casts in
...
the program. This exposes more opportunities for the instcombiner, and implements
vec_shuffle.ll:test6
llvm-svn: 28487
2006-05-25 23:24:33 +00:00
Chris Lattner
83f6578b0c
extract element from a shuffle vector can be trivially turned into an
...
extractelement from the SV's source. This implement vec_shuffle.ll:test[45]
llvm-svn: 28485
2006-05-25 22:53:38 +00:00
Chris Lattner
0853700582
Revert a patch that is unsafe, due to out of range array accesses in inner
...
array scopes possibly accessing valid memory in outer subscripts.
llvm-svn: 28478
2006-05-25 21:25:12 +00:00
Chris Lattner
a643d528bd
Patch for a new instcombine xform, patch contributed by Nick Lewycky!
...
This implements Transforms/InstCombine/2006-05-10-InvalidIndexUndef.ll
llvm-svn: 28450
2006-05-24 17:34:30 +00:00
Chris Lattner
aa2372562e
Patches to make the LLVM sources more -pedantic clean. Patch provided
...
by Anton Korobeynikov! This is a step towards closing PR786.
llvm-svn: 28447
2006-05-24 17:04:05 +00:00
Chris Lattner
d0622b6894
Silence a bogus gcc warning
...
llvm-svn: 28422
2006-05-20 23:14:03 +00:00
Reid Spencer
2452c94df4
Fix a doxygen problem and break lines at 80 columns
...
llvm-svn: 28395
2006-05-19 19:09:46 +00:00
Chris Lattner
e4cb4768fa
Declare that lowerinvoke doesn't interact with other lowering passes.
...
Patch written by Domagoj Babic!
llvm-svn: 28367
2006-05-17 21:05:27 +00:00
Chris Lattner
2e266807c3
Add a CloneModule call that exposes the mapping of values from the old module
...
to the new module. Patch provided by Nick Lewycky!
llvm-svn: 28349
2006-05-17 18:05:35 +00:00
Chris Lattner
35515557c7
remove some dead code identified by coverity
...
llvm-svn: 28289
2006-05-14 18:45:44 +00:00
Chris Lattner
3237da073e
remove dead variables
...
llvm-svn: 28286
2006-05-14 18:33:57 +00:00
Evan Cheng
18d0438148
Backing out last check-in for now. It's causing an infinite loop gccas lencode.
...
llvm-svn: 28284
2006-05-14 06:46:03 +00:00
Chris Lattner
3987a8532d
Add/Sub/Mul are safe to promote here as well. Incrementing a single-bit
...
bitfield now gives this code:
_plus:
lwz r2, 0(r3)
rlwimi r2, r2, 0, 1, 31
xoris r2, r2, 32768
stw r2, 0(r3)
blr
instead of this:
_plus:
lwz r2, 0(r3)
srwi r4, r2, 31
slwi r4, r4, 31
addis r4, r4, -32768
rlwimi r2, r4, 0, 0, 0
stw r2, 0(r3)
blr
this can obviously still be improved.
llvm-svn: 28275
2006-05-13 02:16:08 +00:00
Chris Lattner
1ebbe6a22e
Implement simple promotion for cast elimination in instcombine. This is
...
currently very limited, but can be extended in the future. For example,
we now compile:
uint %test30(uint %c1) {
%c2 = cast uint %c1 to ubyte
%c3 = xor ubyte %c2, 1
%c4 = cast ubyte %c3 to uint
ret uint %c4
}
to:
_xor:
movzbl 4(%esp), %eax
xorl $1, %eax
ret
instead of:
_xor:
movb $1, %al
xorb 4(%esp), %al
movzbl %al, %eax
ret
More impressively, we now compile:
struct B { unsigned bit : 1; };
void xor(struct B *b) { b->bit = b->bit ^ 1; }
To (X86/PPC):
_xor:
movl 4(%esp), %eax
xorl $-2147483648, (%eax)
ret
_xor:
lwz r2, 0(r3)
xoris r2, r2, 32768
stw r2, 0(r3)
blr
instead of (X86/PPC):
_xor:
movl 4(%esp), %eax
movl (%eax), %ecx
movl %ecx, %edx
shrl $31, %edx
# TRUNCATE movb %dl, %dl
xorb $1, %dl
movzbl %dl, %edx
andl $2147483647, %ecx
shll $31, %edx
orl %ecx, %edx
movl %edx, (%eax)
ret
_xor:
lwz r2, 0(r3)
srwi r4, r2, 31
xori r4, r4, 1
rlwimi r2, r4, 31, 0, 0
stw r2, 0(r3)
blr
This implements InstCombine/cast.ll:test30.
llvm-svn: 28273
2006-05-13 02:06:03 +00:00
Chris Lattner
cd60d38b30
Remove some dead variables.
...
Fix a nasty bug in the memcmp optimizer where we used the wrong variable!
llvm-svn: 28269
2006-05-12 23:35:26 +00:00
Chris Lattner
94acc47654
Remove dead stuff
...
llvm-svn: 28268
2006-05-12 23:32:01 +00:00
Chris Lattner
1443bc52be
Refactor some code, making it simpler.
...
When doing the initial pass of constant folding, if we get a constantexpr,
simplify the constant expr like we would do if the constant is folded in the
normal loop.
This fixes the missed-optimization regression in
Transforms/InstCombine/getelementptr.ll last night.
llvm-svn: 28224
2006-05-11 17:11:52 +00:00
Chris Lattner
a36ee4ea34
Two changes:
...
1. Implement InstCombine/deadcode.ll by not adding instructions in unreachable
blocks (due to constants in conditional branches/switches) to the worklist.
This causes them to be deleted before instcombine starts up, leading to
better optimization.
2. In the prepass over instructions, do trivial constprop/dce as we go. This
has the effect of improving the effectiveness of #1 . In addition, it
*significantly* speeds up instcombine on test cases with large amounts of
constant folding code (for example, that produced by code specialization
or partial evaluation). In one example, it speeds up instcombine from
0.0589s to 0.0224s with a release build (a 2.6x speedup).
llvm-svn: 28215
2006-05-10 19:00:36 +00:00
Chris Lattner
4fe87d67c4
Patch to make some xforms preserve each other. Patch contributed by
...
Domagoj Babic!
llvm-svn: 28181
2006-05-09 04:13:41 +00:00
Chris Lattner
1d441adfbf
Move some code around.
...
Make the "fold (and (cast A), (cast B)) -> (cast (and A, B))" transformation
only apply when both casts really will cause code to be generated. If one or
both doesn't, then this xform doesn't remove a cast.
This fixes Transforms/InstCombine/2006-05-06-Infloop.ll
llvm-svn: 28141
2006-05-06 09:00:16 +00:00
Chris Lattner
e745c7de0e
Fix an infinite loop compiling oggenc last night.
...
llvm-svn: 28128
2006-05-05 20:51:30 +00:00
Chris Lattner
3af1053488
Implement InstCombine/cast.ll:test29
...
llvm-svn: 28126
2006-05-05 06:39:07 +00:00
Chris Lattner
fb29692055
Fix Transforms/InstCombine/2006-05-04-DemandedBitCrash.ll
...
llvm-svn: 28101
2006-05-04 17:33:35 +00:00
Chris Lattner
2d3a02725d
Add pass ID's for various passes, so they can be AddRequiredID. Patch by
...
Domagoj Babic!
llvm-svn: 28048
2006-05-02 04:24:36 +00:00
Chris Lattner
655d08fda8
Fix InstCombine/2006-04-28-ShiftShiftLongLong.ll
...
llvm-svn: 28019
2006-04-28 22:21:41 +00:00
Chris Lattner
e63d808b6e
Fix Transforms/Reassociate/2006-04-27-ReassociateVector.ll
...
llvm-svn: 28007
2006-04-28 04:14:49 +00:00
Chris Lattner
b6cb64b7e6
Add support for inserting undef into a vector. This implements
...
Transforms/InstCombine/vec_insert_to_shuffle.ll
llvm-svn: 27997
2006-04-27 21:14:21 +00:00
Chris Lattner
f98b4aa2e7
Fix some nondeterminstic behavior in the mem2reg pass that (in addition to
...
nondeterminism being bad) could cause some trivial missed optimizations (dead
phi nodes being left around for later passes to clean up).
With this, llvm-gcc4 now bootstraps and correctly compares. I don't know
why I never tried to do it before... :)
llvm-svn: 27984
2006-04-27 01:14:43 +00:00
Chris Lattner
dae49df407
Fix Transforms/ScalarRepl/2006-04-20-PromoteCrash.ll
...
llvm-svn: 27912
2006-04-20 20:48:50 +00:00
Andrew Lenharth
f89e630b2f
Make code match cvs commit message :)
...
llvm-svn: 27881
2006-04-20 15:41:37 +00:00
Andrew Lenharth
61eae29ad6
If we can convert the return pointer type into an integer that IntPtrType
...
can be converted to losslessly, we can continue the conversion to a direct call.
llvm-svn: 27880
2006-04-20 14:56:47 +00:00
Chris Lattner
36dd7c98d1
Turn x86 unaligned load/store intrinsics into aligned load/store instructions
...
if the pointer is known aligned.
llvm-svn: 27781
2006-04-17 22:26:56 +00:00
Chris Lattner
9095186deb
Fix a bug in the 'shuffle(undef,x,mask) -> shuffle(x, undef,mask')' xform
...
Make the insert/extract elt -> shuffle code more aggressive.
This fixes CodeGen/PowerPC/vec_shuffle.ll
llvm-svn: 27728
2006-04-16 00:51:47 +00:00
Chris Lattner
34cebe785d
Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask').
...
llvm-svn: 27727
2006-04-16 00:03:56 +00:00
Chris Lattner
39fac448d6
significant cleanups to code that uses insert/extractelt heavily. This builds
...
maximal shuffles out of them where possible.
llvm-svn: 27717
2006-04-15 01:39:45 +00:00
Chris Lattner
3323ce165d
Teach scalarrepl to promote unions of vectors and floats, producing
...
insert/extractelement operations. This implements
Transforms/ScalarRepl/vector_promote.ll
llvm-svn: 27710
2006-04-14 21:42:41 +00:00
Andrew Lenharth
92cf71f6d7
linear -> constant time
...
llvm-svn: 27652
2006-04-13 13:43:31 +00:00
Reid Spencer
13a1a7a4a6
Get rid of a signed/unsigned compare warning.
...
llvm-svn: 27625
2006-04-12 19:28:15 +00:00
Chris Lattner
b19a5c661b
Turn casts into getelementptr's when possible. This enables SROA to be more
...
aggressive in some cases where LLVMGCC 4 is inserting casts for no reason.
This implements InstCombine/cast.ll:test27/28.
llvm-svn: 27620
2006-04-12 18:09:35 +00:00
Chris Lattner
2d37f920ad
Implement vec_shuffle.ll:test3
...
llvm-svn: 27573
2006-04-10 23:06:36 +00:00
Chris Lattner
fbb77a408b
Implement InstCombine/vec_shuffle.ll:test[12]
...
llvm-svn: 27571
2006-04-10 22:45:52 +00:00
Andrew Lenharth
a9cdcca3c3
Add a simple pass to make sure that all (non-library) calls to malloc and free
...
are visible to analysis as intrinsics. That is, make sure someone doesn't pass
free around by address in some struct (as happens in say 176.gcc).
This doesn't get rid of any indirect calls, just ensure calls to free and malloc
are always direct.
llvm-svn: 27560
2006-04-10 19:26:09 +00:00
Chris Lattner
17bd60588c
Add supprot for shufflevector
...
llvm-svn: 27513
2006-04-08 01:19:12 +00:00
Chris Lattner
8ec0205de4
Fix inlining of insert/extract element constantexprs
...
llvm-svn: 27478
2006-04-07 04:41:03 +00:00
Chris Lattner
e79d249c29
Lower vperm(x,y, mask) -> shuffle(x,y,mask) if mask is constant. This allows
...
us to compile oh-so-realistic stuff like this:
vec_vperm(A, B, (vector unsigned char){14});
to:
vspltb v0, v0, 14
instead of:
vspltisb v0, 14
vperm v0, v2, v1, v0
llvm-svn: 27452
2006-04-06 19:19:17 +00:00
Chris Lattner
caba72b6ff
vector casts of casts are eliminable. Transform this:
...
%tmp = cast <4 x uint> %tmp to <4 x int> ; <<4 x int>> [#uses=1]
%tmp = cast <4 x int> %tmp to <4 x float> ; <<4 x float>> [#uses=1]
into:
%tmp = cast <4 x uint> %tmp to <4 x float> ; <<4 x float>> [#uses=1]
llvm-svn: 27355
2006-04-02 05:43:13 +00:00
Chris Lattner
ebca476b27
Allow transforming this:
...
%tmp = cast <4 x uint>* %testData to <4 x int>* ; <<4 x int>*> [#uses=1]
%tmp = load <4 x int>* %tmp ; <<4 x int>> [#uses=1]
to this:
%tmp = load <4 x uint>* %testData ; <<4 x uint>> [#uses=1]
%tmp = cast <4 x uint> %tmp to <4 x int> ; <<4 x int>> [#uses=1]
llvm-svn: 27353
2006-04-02 05:37:12 +00:00
Chris Lattner
f42d0aeda1
Turn altivec lvx/stvx intrinsics into loads and stores. This allows the
...
elimination of one load from this:
int AreSecondAndThirdElementsBothNegative( vector float *in ) {
#define QNaN 0x7FC00000
const vector unsigned int testData = (vector unsigned int)( QNaN, 0, 0, QNaN );
vector float test = vec_ld( 0, (float*) &testData );
return ! vec_any_ge( test, *in );
}
Now generating:
_AreSecondAndThirdElementsBothNegative:
mfspr r2, 256
oris r4, r2, 49152
mtspr 256, r4
li r4, lo16(LCPI1_0)
lis r5, ha16(LCPI1_0)
addi r6, r1, -16
lvx v0, r5, r4
stvx v0, 0, r6
lvx v1, 0, r3
vcmpgefp. v0, v0, v1
mfcr r3, 2
rlwinm r3, r3, 27, 31, 31
xori r3, r3, 1
cntlzw r3, r3
srwi r3, r3, 5
mtspr 256, r2
blr
llvm-svn: 27352
2006-04-02 05:30:25 +00:00
Chris Lattner
70ec96fa32
Adjust to change in Intrinsics.gen interface.
...
llvm-svn: 27344
2006-04-02 03:35:01 +00:00
Chris Lattner
1b2436a624
add valuemapper support for inline asm
...
llvm-svn: 27332
2006-04-01 23:17:11 +00:00
Chris Lattner
6cf4914fd4
Fix InstCombine/2006-04-01-InfLoop.ll
...
llvm-svn: 27330
2006-04-01 22:05:01 +00:00
Chris Lattner
dcd0792622
Fold A^(B&A) -> (B&A)^A
...
Fold (B&A)^A == ~B & A
This implements InstCombine/xor.ll:test2[56]
llvm-svn: 27328
2006-04-01 08:03:55 +00:00
Chris Lattner
8d1d8d364c
If we can look through vector operations to find the scalar version of an
...
extract_element'd value, do so.
llvm-svn: 27323
2006-03-31 23:01:56 +00:00
Chris Lattner
92346c315e
extractelement(undef,x) -> undef
...
llvm-svn: 27300
2006-03-31 18:25:14 +00:00
Chris Lattner
612fa8e6f3
Fix Transforms/InstCombine/2006-03-30-ExtractElement.ll
...
llvm-svn: 27261
2006-03-30 22:02:40 +00:00
Chris Lattner
42e0ba09aa
teach the inliner to work with packed constants
...
llvm-svn: 27161
2006-03-27 05:50:18 +00:00
Chris Lattner
d70d9f5b24
Don't crash on packed logical ops
...
llvm-svn: 27125
2006-03-25 21:58:26 +00:00
Chris Lattner
f365f5f0c1
Fix spello
...
llvm-svn: 27052
2006-03-24 07:14:34 +00:00
Chris Lattner
5821a6a17a
add the actual cost to the debug info
...
llvm-svn: 27051
2006-03-24 07:14:00 +00:00
Jim Laskey
8f64426f5c
Strip changes to llvm.dbg intrinsics.
...
llvm-svn: 26993
2006-03-23 18:11:33 +00:00
Jim Laskey
83f99115db
Can't combine anymore - we don't have a chain through llvm.dbg intrinsics.
...
llvm-svn: 26992
2006-03-23 18:10:42 +00:00
Chris Lattner
7d80b4f366
silence a bogus gcc warning
...
llvm-svn: 26953
2006-03-22 17:27:24 +00:00
Chris Lattner
d783c76c18
Teach cee to propagate through switch statements. This implements
...
Transforms/CorrelatedExprs/switch.ll
Patch contributed by Eric Kidd!
llvm-svn: 26872
2006-03-19 19:37:24 +00:00
Evan Cheng
c28282bd87
- Fixed a bogus if condition.
...
- Added more debugging info.
- Allow reuse of IV of negative stride. e.g. -4 stride == 2 * iv of -2 stride.
llvm-svn: 26841
2006-03-18 08:03:12 +00:00
Evan Cheng
f09f0ebd48
Sort StrideOrder so we can process the smallest strides first. This allows
...
for more IV reuses.
llvm-svn: 26837
2006-03-18 00:44:49 +00:00
Evan Cheng
4520698820
Allow users of iv / stride to be rewritten with expression that is a multiply
...
of a smaller stride even if they have a common loop invariant expression part.
llvm-svn: 26828
2006-03-17 19:52:23 +00:00
Evan Cheng
3df447d354
For each loop, keep track of all the IV expressions inserted indexed by
...
stride. For a set of uses of the IV of a stride which is a multiple
of another stride, do not insert a new IV expression. Rather, reuse the
previous IV and rewrite the uses as uses of IV expression multiplied by
the factor.
e.g.
x = 0 ...; x ++
y = 0 ...; y += 4
then use of y can be rewritten as use of 4*x for x86.
llvm-svn: 26803
2006-03-16 21:53:05 +00:00
Chris Lattner
6d6084fd04
Teach the strip pass to strip type names in addition to value names. This
...
is fallout from the type/value split in the symtab long long ago :)
llvm-svn: 26785
2006-03-15 19:22:41 +00:00
Chris Lattner
c5f866bb4a
Implement a FIXME, recusively reassociating
...
A*A*B + A*A*C --> A*(A*B+A*C) --> A*(A*(B+C))
This implements Reassociate/mul-factor3.ll
llvm-svn: 26757
2006-03-14 16:04:29 +00:00
Chris Lattner
2fc319d444
extract some code into a method, no functionality change
...
llvm-svn: 26755
2006-03-14 07:11:11 +00:00
Chris Lattner
d6bde46d85
Promote shifts by a constant to multiplies so that we can reassociate
...
(x<<1)+(y<<1) -> (X+Y)<<1. This implements
Transforms/Reassociate/shift-factor.ll
llvm-svn: 26753
2006-03-14 06:55:18 +00:00
Evan Cheng
c567c4efbb
Added target lowering hooks which LSR consults to make more intelligent
...
transformation decisions.
llvm-svn: 26738
2006-03-13 23:14:23 +00:00
Jim Laskey
acb6e34277
Handle the removal of the debug chain.
...
llvm-svn: 26729
2006-03-13 13:07:37 +00:00
Chris Lattner
60f6833376
use autogenerated side-effect information
...
llvm-svn: 26673
2006-03-09 22:38:10 +00:00
Chris Lattner
6b7847a5bc
fix a pasto
...
llvm-svn: 26627
2006-03-09 06:09:41 +00:00
Chris Lattner
fc34f8bb48
Fix a miscompilation of 188.ammp with the new CFE. 188.ammp is accessing
...
arrays out of range in a horrible way, but we shouldn't break it anyway.
Details in the comments.
llvm-svn: 26606
2006-03-08 01:05:29 +00:00
Jim Laskey
69effa2325
Switch to using a numeric id for anchors.
...
llvm-svn: 26598
2006-03-07 20:53:47 +00:00
Chris Lattner
7b87fd53f9
Fix ConstantMerge/2006-03-07-DontMergeDiffSections.ll, a problem Jim
...
hypotheticalized about, where we would incorrectly merge two globals in
different sections.
llvm-svn: 26597
2006-03-07 17:56:59 +00:00
Chris Lattner
53ef5a032c
Teach the alignment handling code to look through constant expr casts and GEPs
...
llvm-svn: 26580
2006-03-07 01:28:57 +00:00
Chris Lattner
82f2ef20b6
Teach instcombine to increase the alignment of memset/memcpy/memmove when
...
the pointer is known to come from either a global variable, alloca or
malloc. This allows us to compile this:
P = malloc(28);
memset(P, 0, 28);
into explicit stores on PPC instead of a memset call.
llvm-svn: 26577
2006-03-06 20:18:44 +00:00
Chris Lattner
6bc98653c2
Make vector narrowing more effective, implementing
...
Transforms/InstCombine/vec_narrow.ll. This add support for narrowing
extract_element(insertelement) also.
llvm-svn: 26538
2006-03-05 00:22:33 +00:00
Chris Lattner
4c065091d8
Add factoring of multiplications, e.g. turning A*A+A*B into A*(A+B).
...
Testcase here: Transforms/Reassociate/mulfactor.ll
llvm-svn: 26524
2006-03-04 09:31:13 +00:00
Chris Lattner
32c01df299
Canonicalize (X+C1)*C2 -> X*C2+C1*C2
...
This implements Transforms/InstCombine/add.ll:test31
llvm-svn: 26519
2006-03-04 06:04:02 +00:00
Chris Lattner
681ef2f083
Change this to work with renamed intrinsics.
...
llvm-svn: 26484
2006-03-03 01:34:17 +00:00
Chris Lattner
ea7986aeca
Make this work with renamed intrinsics.
...
llvm-svn: 26482
2006-03-03 01:30:23 +00:00
Chris Lattner
85dda9a2bd
Generalize the REM folding code to handle another case Nick Lewycky
...
pointed out: realize the AND can provide factors and look through Casts.
llvm-svn: 26469
2006-03-02 06:50:58 +00:00
Chris Lattner
c5b6c9a12a
Fix a regression in a patch from a couple of days ago. This fixes
...
Transforms/InstCombine/2006-02-28-Crash.ll
llvm-svn: 26427
2006-02-28 19:47:20 +00:00
Chris Lattner
b70f141893
Implement rem.ll:test[7-9] and PR712
...
llvm-svn: 26415
2006-02-28 05:49:21 +00:00
Chris Lattner
2a7c7b8bab
Simplify some code now that the RHS of a rem can't be 0
...
llvm-svn: 26413
2006-02-28 05:40:55 +00:00
Chris Lattner
0de4a8d7b7
Rearrange some code, fold "rem X, 0", implementing rem.ll:test6
...
llvm-svn: 26411
2006-02-28 05:30:45 +00:00
Chris Lattner
c7bfed0f7b
Merge two almost-identical pieces of code.
...
Make this code more powerful by using ComputeMaskedBits instead of looking
for an AND operand. This lets us fold this:
int %test23(int %a) {
%tmp.1 = and int %a, 1
%tmp.2 = seteq int %tmp.1, 0
%tmp.3 = cast bool %tmp.2 to int ;; xor tmp1, 1
ret int %tmp.3
}
into: xor (and a, 1), 1
llvm-svn: 26396
2006-02-27 02:38:23 +00:00
Chris Lattner
f5c8a0b83f
Fold (A^B) == A -> B == 0
...
and (A-B) == A -> B == 0
llvm-svn: 26394
2006-02-27 01:44:11 +00:00
Chris Lattner
f78df7c14d
Fold (X|C1)^C2 -> X^(C1|C2) when possible. This implements
...
InstCombine/or.ll:test23.
llvm-svn: 26385
2006-02-26 19:57:54 +00:00
Chris Lattner
b580d26e7d
Fix a problem that Nate noticed that boils down to an over conservative check
...
in the code that does "select C, (X+Y), (X-Y) --> (X+(select C, Y, (-Y)))".
We now compile this loop:
LBB1_1: ; no_exit
add r6, r2, r3
subf r3, r2, r3
cmpwi cr0, r2, 0
addi r7, r5, 4
lwz r2, 0(r5)
addi r4, r4, 1
blt cr0, LBB1_4 ; no_exit
LBB1_3: ; no_exit
mr r3, r6
LBB1_4: ; no_exit
cmpwi cr0, r4, 16
mr r5, r7
bne cr0, LBB1_1 ; no_exit
into this instead:
LBB1_1: ; no_exit
srawi r6, r2, 31
add r2, r2, r6
xor r6, r2, r6
addi r7, r5, 4
lwz r2, 0(r5)
addi r4, r4, 1
add r3, r3, r6
cmpwi cr0, r4, 16
mr r5, r7
bne cr0, LBB1_1 ; no_exit
llvm-svn: 26356
2006-02-24 18:05:58 +00:00
Chris Lattner
e5521db5bc
Fix Regression/Transforms/LoopUnswitch/2006-02-22-UnswitchCrash.ll, which
...
caused SPASS to fail building last night.
We can't trivially unswitch a loop if the exit block has phi nodes in it,
because we don't know which predecessor to use.
llvm-svn: 26320
2006-02-22 23:55:00 +00:00
Chris Lattner
8a5a324dac
Add some comments, simplify some code, and fix a bug that caused rewriting
...
to rewrite with the wrong value.
llvm-svn: 26311
2006-02-22 06:37:14 +00:00
Chris Lattner
c2e3a7a4ce
improved support for branch folding, still not enabled.
...
llvm-svn: 26289
2006-02-18 07:57:38 +00:00
Jeff Cohen
0add83e969
Fix bugs identified by VC++.
...
llvm-svn: 26287
2006-02-18 03:20:33 +00:00
Chris Lattner
19fa8ac938
Implement deletion of dead blocks, currently disabled.
...
llvm-svn: 26285
2006-02-18 02:42:34 +00:00
Chris Lattner
cb853de534
a previous patch completely disabled trivial unswitching, this fixees it.
...
Thanks to nate for pointing this out :)
llvm-svn: 26280
2006-02-18 01:32:04 +00:00
Chris Lattner
29f771ba21
initial trivial support for folding branches that have now-constant destinations.
...
llvm-svn: 26279
2006-02-18 01:27:45 +00:00
Chris Lattner
8e44ff50b0
When unswitching a loop, make sure to update loop info with exit blocks in
...
the right loop.
llvm-svn: 26277
2006-02-18 00:55:32 +00:00
Chris Lattner
d95665188b
Fix Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll
...
llvm-svn: 26275
2006-02-18 00:33:17 +00:00
Chris Lattner
baddba41c7
Fix loops where the header has an exit, fixing a loop-unswitch crash on crafty
...
llvm-svn: 26258
2006-02-17 06:39:56 +00:00
Chris Lattner
6fd136239b
start of some new simplification code, not thoroughly tested, use at your own
...
risk :)
llvm-svn: 26248
2006-02-17 00:31:07 +00:00
Nate Begeman
8a77efe4f7
Rework the SelectionDAG-based implementations of SimplifyDemandedBits
...
and ComputeMaskedBits to match the new improved versions in instcombine.
Tested against all of multisource/benchmarks on ppc.
llvm-svn: 26238
2006-02-16 21:11:51 +00:00
Chris Lattner
fa335f6083
Change SplitBlock to increment a BasicBlock::iterator, not an Instruction*. Apparently they do different things :)
...
This fixes a testcase that nate reduced from spass.
Also included are a couple minor code changes that don't affect the generated
code at all.
llvm-svn: 26235
2006-02-16 19:36:22 +00:00
Jeff Cohen
55f63f1b53
Fix VC++ warning.
...
llvm-svn: 26228
2006-02-16 04:07:37 +00:00
Chris Lattner
ff42e81028
fix a bug where we unswitched the wrong way
...
llvm-svn: 26225
2006-02-16 01:24:41 +00:00
Chris Lattner
fdff0bb43e
Implement trivial unswitching for switch stmts. This allows us to trivial
...
unswitch this loop on 2 before sweating to unswitch on 1/3.
void test4(int N, int i, int C, int*P, int*Q) {
int j;
for (j = 0; j < N; ++j) {
switch (C) { // general unswitching.
default: P[i+j] = 0; break;
case 1: Q[i+j] = 0; break;
case 3: P[i+j] = Q[i+j]; break;
case 2: break; // TRIVIAL UNSWITCH on C==2
}
}
}
llvm-svn: 26223
2006-02-15 22:52:05 +00:00
Chris Lattner
e5cb76d744
make "trivial" unswitching significantly more general. It can now handle
...
this for example:
for (j = 0; j < N; ++j) { // trivial unswitch
if (C)
P[i+j] = 0;
}
turning it into the obvious code without bothering to duplicate an empty loop.
llvm-svn: 26220
2006-02-15 22:03:36 +00:00
Andrew Lenharth
47da60130a
fix a bunch of alpha regressions. see bug 709
...
llvm-svn: 26218
2006-02-15 21:13:37 +00:00
Chris Lattner
65152d80ec
Checking the wrong value. This caused us to emit silly code like
...
Y = seteq bool X, true
instead of just using X :)
llvm-svn: 26215
2006-02-15 19:05:52 +00:00
Chris Lattner
01db04efb0
more refactoring, no functionality change.
...
llvm-svn: 26194
2006-02-15 01:44:42 +00:00
Chris Lattner
b0cbe7106e
pull some code out into a function
...
llvm-svn: 26191
2006-02-15 00:07:43 +00:00
Chris Lattner
9c5693fb2a
Canonicalize inner loops before outer loops. Inner loop canonicalization
...
can provide work for the outer loop to canonicalize.
This fixes a case that breaks unswitching.
llvm-svn: 26189
2006-02-14 23:06:02 +00:00
Chris Lattner
cffbbee8d1
When splitting exit edges to canonicalize loops, make sure to put the new
...
block in the appropriate loop nest.
Third time is the charm, right?
llvm-svn: 26187
2006-02-14 22:34:08 +00:00
Chris Lattner
0b8ec1a132
Use statistics to keep track of what flavors of loops we are unswitching
...
llvm-svn: 26157
2006-02-14 01:01:41 +00:00