Reid Spencer
fec48b0d9d
Convert to SymbolTable's new iteration interface.
...
llvm-svn: 13754
2004-05-25 08:53:40 +00:00
Reid Spencer
e6cf613d2a
Convert to SymbolTable's new iteration interface. Remove tabs.
...
llvm-svn: 13753
2004-05-25 08:53:29 +00:00
Reid Spencer
e6e0da0b9f
Completely rewrote the class. SymbolTable now separates Type* from Value* in preparation\
...
for making Type not derive from Value. There are now separate interfaces \
for looking up, finding, and inserting Types and Values. There are also \
three separate iterator interfaces, one for type planes, one for the types \
(type type plane), and one for values within a type plane. See the \
documentation in the Header file.
llvm-svn: 13752
2004-05-25 08:52:42 +00:00
Reid Spencer
08e75b22a5
Convert to SymbolTable's new lookup and iteration interfaces.
...
llvm-svn: 13751
2004-05-25 08:52:20 +00:00
Reid Spencer
09c1dbce28
Remove unused header file.
...
llvm-svn: 13750
2004-05-25 08:51:36 +00:00
Reid Spencer
169865d831
Make this pass simply invoke SymbolTable::strip().
...
llvm-svn: 13749
2004-05-25 08:51:25 +00:00
Reid Spencer
65559ced22
Remove use of Type::TypeTy from an assert. It will go away soon.
...
llvm-svn: 13748
2004-05-25 08:50:52 +00:00
Reid Spencer
63530c743e
Get rid of a wart: useless getFILE function is now a cast macro.
...
llvm-svn: 13747
2004-05-25 08:46:15 +00:00
Vikram S. Adve
6026f572eb
Recognize memalign and friends, and handle them specially.
...
llvm-svn: 13741
2004-05-25 08:14:52 +00:00
Chris Lattner
66f55c8e78
Implement InstCombine:shift.ll:test16, which turns (X >> C1) & C2 != C3
...
into (X & (C2 << C1)) != (C3 << C1), where the shift may be either left or
right and the compare may be any one.
This triggers 1546 times in 176.gcc alone, as it is a common pattern that
occurs for bitfield accesses.
llvm-svn: 13740
2004-05-25 06:32:08 +00:00
Chris Lattner
84431acbf1
Implement some helpers
...
llvm-svn: 13738
2004-05-25 05:32:43 +00:00
Chris Lattner
b8fb5e789b
Implement instcombine/cast.ll:test16:
...
Canonicalize cast X to bool into a setne instruction
llvm-svn: 13736
2004-05-25 04:29:21 +00:00
Tanya Lattner
7cf16701f7
Moved MachineBasicBlock deconstructor to cpp file and removed it from LeakDetector to fix memory leak bug.
...
llvm-svn: 13718
2004-05-24 07:14:35 +00:00
Chris Lattner
79409ebc27
Fix a bug in my previous checkin
...
llvm-svn: 13717
2004-05-24 06:24:46 +00:00
Tanya Lattner
aabaaec037
Added MachineFunction parent* to MachineBasicBlock. Customized ilist template
...
to set the parent when a MachineBasicBlock is added to a MachineFunction.
llvm-svn: 13716
2004-05-24 06:11:51 +00:00
Chris Lattner
f38d51ea42
Eliminate an explicit use of the LLVM basic block, using getParent instead,
...
which simplifies the code
llvm-svn: 13707
2004-05-24 03:44:52 +00:00
Tanya Lattner
55477a5af1
Changed clone to be const.
...
Changed copy constructor to set parent, prev, and next pointers to null.
llvm-svn: 13706
2004-05-24 03:14:18 +00:00
Chris Lattner
52e7345268
Spelling people's names right is kinda important
...
llvm-svn: 13702
2004-05-23 21:27:29 +00:00
Chris Lattner
1e22b42cb6
Add support for accurate garbage collection to the LLVM code generators
...
llvm-svn: 13696
2004-05-23 21:23:35 +00:00
Chris Lattner
85f19c7b3f
Add some notes to myself, no functional changes
...
llvm-svn: 13695
2004-05-23 21:23:12 +00:00
Chris Lattner
5862899c44
minor wording change
...
llvm-svn: 13694
2004-05-23 21:22:55 +00:00
Chris Lattner
fbdf40f86a
Fix cases where we missed inlining some more obvious candidates because the
...
caller was in an SCC.
llvm-svn: 13693
2004-05-23 21:22:17 +00:00
Chris Lattner
bf8b81252f
Simplify the interface and remove an unneeded #include
...
llvm-svn: 13692
2004-05-23 21:21:35 +00:00
Chris Lattner
fee8ce6131
Fairly substantial changes to update the alias analysis we are querying as
...
we make the transformation. This allows us to use interprocedural alias
analyses successfully.
llvm-svn: 13691
2004-05-23 21:21:17 +00:00
Chris Lattner
cf81f974b8
Adjust to the changes in the AliasSetTracker interface
...
llvm-svn: 13690
2004-05-23 21:20:19 +00:00
Chris Lattner
33de90e8c6
Add support for replacement of formal arguments with simpler expressions.
...
llvm-svn: 13689
2004-05-23 21:19:55 +00:00
Chris Lattner
f113f6a630
Implement the -lowergc pass which is used by code generators (like the CBE)
...
that do not have builtin support for garbage collection.
llvm-svn: 13688
2004-05-23 21:19:22 +00:00
Chris Lattner
5f65590915
Recognize and verify the new GC intrinsics.
...
llvm-svn: 13687
2004-05-23 21:16:51 +00:00
Chris Lattner
dd4c06d2bf
Changes to work with the changes to the AliasAnalysis interface. The -no-aa
...
class is now in the BasicAliasAnalysis.cpp file
llvm-svn: 13684
2004-05-23 21:15:48 +00:00
Chris Lattner
7ccc4c2ed9
Move the -no-aa AA implementation into this file since both of these
...
alias analysis implementations are special: they do not autoforward to a
chained implementation of alias analysis
llvm-svn: 13683
2004-05-23 21:15:12 +00:00
Chris Lattner
1336a3f17a
Updates to work with the new auto-forwarding AA interface changes
...
llvm-svn: 13682
2004-05-23 21:14:27 +00:00
Chris Lattner
0e1a543d88
Fix a really nasty bug with the -disable-ds-field-sensitivity option
...
llvm-svn: 13681
2004-05-23 21:14:09 +00:00
Chris Lattner
89353483d6
Update to match the autochaining interface that the AA interface uses
...
llvm-svn: 13680
2004-05-23 21:13:51 +00:00
Chris Lattner
6c71895a16
Implement the interfaces to update value numbering information. Add an
...
assert.
llvm-svn: 13679
2004-05-23 21:13:24 +00:00
Chris Lattner
0588bd19d2
Rename a method
...
llvm-svn: 13676
2004-05-23 21:10:58 +00:00
Chris Lattner
fa5d566d95
Add a simple implementation of Andersen's interprocedural pointer analysis
...
llvm-svn: 13666
2004-05-23 21:00:47 +00:00
Tanya Lattner
e755fc6689
Fixed up my changes to add support for cloning Machine Instructions.
...
llvm-svn: 13665
2004-05-23 20:58:02 +00:00
Tanya Lattner
2848065a29
Adding support to clone MachineInstr
...
llvm-svn: 13661
2004-05-23 19:35:12 +00:00
Vikram S. Adve
cf685da276
Inline both direct and indirect callees in the CBU phase because
...
a direct callee may have indirect callees and so may have changed.
llvm-svn: 13649
2004-05-23 08:00:34 +00:00
Brian Gaeke
12ab4a0357
Fix a typo in a comment.
...
llvm-svn: 13643
2004-05-23 05:10:06 +00:00
Chris Lattner
30cc4edfc3
Fix for PR340: Verifier misses malformed switch instruction
...
llvm-svn: 13618
2004-05-21 16:47:21 +00:00
Chris Lattner
b92b7d2050
Fix to make the CBE always emit comparisons inline. Hopefully this will
...
fix the really bad code we're getting on PPC.
llvm-svn: 13609
2004-05-20 20:25:50 +00:00
Brian Gaeke
ac9ce5d851
Fix a bug in outputting branches to constant PCs. Since the PC is supplied as
...
a full 64-bit address, it must be adjusted to fit in the branch instruction's
immediate field. (This is only used in the reoptimizer, for now.)
llvm-svn: 13608
2004-05-20 07:43:40 +00:00
Brian Gaeke
1d6c0881ce
Minor simplification: eliminate a dyn_cast.
...
Fix a typo in a debug message.
llvm-svn: 13607
2004-05-19 21:30:01 +00:00
Brian Gaeke
16bd3c5d34
Add CloneTraceInto(), which is based on (and has mostly the same
...
effects as) CloneFunctionInto().
llvm-svn: 13601
2004-05-19 09:08:14 +00:00
Brian Gaeke
9adf9d8bfc
Move RemapInstruction() to ValueMapper, so that it can be shared with
...
CloneTrace, and because it is primarily an operation on ValueMaps. It
is now a global (non-static) function which can be pulled in using
ValueMapper.h.
llvm-svn: 13600
2004-05-19 09:08:12 +00:00
Brian Gaeke
5d639ac9f3
Fold two assertions with backwards error messages into one with a
...
correct error message.
llvm-svn: 13590
2004-05-17 21:15:18 +00:00
Brian Gaeke
b41b628afd
Clean up this pass somewhat:
...
Add better comments, including a better head-of-file comment.
Prune #includes.
Fix a FIXME that Chris put here by using doInitialization().
Use DEBUG() to print out debug msgs.
Give names to basic blocks inserted by this pass.
Expand tabs.
Use InsertProfilingInitCall() from ProfilingUtils to insert the initialize call.
llvm-svn: 13581
2004-05-14 21:21:52 +00:00
Brian Gaeke
e5736bf986
Don't keep track of references to LLVM BasicBlocks while emitting; use
...
MachineBasicBlocks instead.
llvm-svn: 13568
2004-05-14 06:54:58 +00:00
Brian Gaeke
a25a10e73b
Support MachineBasicBlock operands on RawFrm instructions.
...
Get rid of separate numbering for LLVM BasicBlocks; use the automatically
generated MachineBasicBlock numbering.
llvm-svn: 13567
2004-05-14 06:54:57 +00:00
Brian Gaeke
a17301ca8b
Generate branch machine instructions with MachineBasicBlock operands instead of
...
LLVM BasicBlock operands.
llvm-svn: 13566
2004-05-14 06:54:56 +00:00
Chris Lattner
729d1ba904
This was not meant to be committed
...
llvm-svn: 13565
2004-05-13 20:56:34 +00:00
Chris Lattner
b296747100
Fix a nasty bug that caused us to unroll EXTREMELY large loops due to overflow
...
in the size calculation.
This is not something you want to see:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - UNROLLING!
The problem was that 2*2147483648 == 0.
Now we get:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - TOO LARGE: 4294967296>100
Thanks to some anonymous person playing with the demo page that repeatedly
caused zion to go into swapping land. That's one way to ensure you'll get
a quick bugfix. :)
Testcase here: Transforms/LoopUnroll/2004-05-13-DontUnrollTooMuch.ll
llvm-svn: 13564
2004-05-13 20:43:31 +00:00
Chris Lattner
269da7901a
Two more improvements for null pointer handling: storing a null pointer
...
and passing a null pointer into a function.
For this testcase:
void %test(int** %X) {
store int* null, int** %X
call void %test(int** null)
ret void
}
we now generate this:
test:
sub %ESP, 12
mov %EAX, DWORD PTR [%ESP + 16]
mov DWORD PTR [%EAX], 0
mov DWORD PTR [%ESP], 0
call test
add %ESP, 12
ret
instead of this:
test:
sub %ESP, 12
mov %EAX, DWORD PTR [%ESP + 16]
mov %ECX, 0
mov DWORD PTR [%EAX], %ECX
mov %EAX, 0
mov DWORD PTR [%ESP], %EAX
call test
add %ESP, 12
ret
llvm-svn: 13558
2004-05-13 15:26:48 +00:00
Chris Lattner
dc8e8484e5
Second half of my fixed-sized-alloca patch. This folds the LEA to compute
...
the alloca address into common operations like loads/stores.
In a simple testcase like this (which is just designed to excersize the
alloca A, nothing more):
int %test(int %X, bool %C) {
%A = alloca int
store int %X, int* %A
store int* %A, int** %G
br bool %C, label %T, label %F
T:
call int %test(int 1, bool false)
%V = load int* %A
ret int %V
F:
call int %test(int 123, bool true)
%V2 = load int* %A
ret int %V2
}
We now generate:
test:
sub %ESP, 12
mov %EAX, DWORD PTR [%ESP + 16]
mov %CL, BYTE PTR [%ESP + 20]
*** mov DWORD PTR [%ESP + 8], %EAX
mov %EAX, OFFSET G
lea %EDX, DWORD PTR [%ESP + 8]
mov DWORD PTR [%EAX], %EDX
test %CL, %CL
je .LBB2 # PC rel: F
.LBB1: # T
mov DWORD PTR [%ESP], 1
mov DWORD PTR [%ESP + 4], 0
call test
*** mov %EAX, DWORD PTR [%ESP + 8]
add %ESP, 12
ret
.LBB2: # F
mov DWORD PTR [%ESP], 123
mov DWORD PTR [%ESP + 4], 1
call test
*** mov %EAX, DWORD PTR [%ESP + 8]
add %ESP, 12
ret
Instead of:
test:
sub %ESP, 20
mov %EAX, DWORD PTR [%ESP + 24]
mov %CL, BYTE PTR [%ESP + 28]
*** lea %EDX, DWORD PTR [%ESP + 16]
*** mov DWORD PTR [%EDX], %EAX
mov %EAX, OFFSET G
mov DWORD PTR [%EAX], %EDX
test %CL, %CL
*** mov DWORD PTR [%ESP + 12], %EDX
je .LBB2 # PC rel: F
.LBB1: # T
mov DWORD PTR [%ESP], 1
mov %EAX, 0
mov DWORD PTR [%ESP + 4], %EAX
call test
*** mov %EAX, DWORD PTR [%ESP + 12]
*** mov %EAX, DWORD PTR [%EAX]
add %ESP, 20
ret
.LBB2: # F
mov DWORD PTR [%ESP], 123
mov %EAX, 1
mov DWORD PTR [%ESP + 4], %EAX
call test
*** mov %EAX, DWORD PTR [%ESP + 12]
*** mov %EAX, DWORD PTR [%EAX]
add %ESP, 20
ret
llvm-svn: 13557
2004-05-13 15:12:43 +00:00
Chris Lattner
94de563118
Substantially improve code generation for address exposed locals (aka fixed
...
sized allocas in the entry block). Instead of generating code like this:
entry:
reg1024 = ESP+1234
... (much later)
*reg1024 = 17
Generate code that looks like this:
entry:
(no code generated)
... (much later)
t = ESP+1234
*t = 17
The advantage being that we DRAMATICALLY reduce the register pressure for these
silly temporaries (they were all being spilled to the stack, resulting in very
silly code). This is actually a manual implementation of rematerialization :)
I have a patch to fold the alloca address computation into loads & stores, which
will make this much better still, but just getting this right took way too much time
and I'm sleepy.
llvm-svn: 13554
2004-05-13 07:40:27 +00:00
Chris Lattner
f29acd5214
Fix a really nasty bug from my changes on Monday to PHIElim. These changes
...
broke obsequi and a lot of other things. It all boiled down to MBB being
overloaded in an inner scope and me confusing it with the one in the outer
scope. Ugh!
llvm-svn: 13517
2004-05-12 21:47:57 +00:00
Brian Gaeke
79c7de0723
Start NextMBBNumber out at zero.
...
llvm-svn: 13515
2004-05-12 21:35:23 +00:00
Brian Gaeke
6009468edd
Add non-const MachineBasicBlock::getParent() accessor method.
...
MBBs start out as #-1. When a MBB is added to a MachineFunction, it
gets the next available unique MBB number. If it is removed from a
MachineFunction, it goes back to being #-1.
llvm-svn: 13514
2004-05-12 21:35:22 +00:00
Chris Lattner
a19bb14155
Pass boolean constants into function calls more efficiently, generating:
...
mov DWORD PTR [%ESP + 4], 1
instead of:
mov %EAX, 1
mov DWORD PTR [%ESP + 4], %EAX
llvm-svn: 13494
2004-05-12 16:35:04 +00:00
Chris Lattner
f97ef5191a
Do not pass in the same argument to the extracted function more than once, and
...
give the extracted function a more useful name than just foo_code.
llvm-svn: 13493
2004-05-12 16:26:18 +00:00
Chris Lattner
645130ed0e
Implement support for code extracting basic blocks that have a return
...
instruction in them.
llvm-svn: 13490
2004-05-12 16:07:41 +00:00
Chris Lattner
ed40ce44d6
Implement splitting of PHI nodes, allowing block extraction of BB's that have
...
PHI node entries from multiple outside-the-region blocks. This also fixes
extraction of the entry block in a function. Yaay.
This has successfully block extracted all (but one) block from the score_move
function in obsequi (out of 33). Hrm, I wonder which block the bug is in. :)
llvm-svn: 13489
2004-05-12 15:29:13 +00:00
Chris Lattner
3ee79b93d7
* Pull some code out into the definedInRegion/definedInCaller methods
...
* Add a stub for the severSplitPHINodes which will allow us to bbextract
bb's with PHI nodes in them soon.
* Remove unused arguments from findInputsOutputs
* Dramatically simplify the code in findInputsOutputs. In particular,
nothing really cares whether or not a PHI node is using something.
* Move moveCodeToFunction to after emitCallAndSwitchStatement as that's the
order they get called.
* Fix a bug where we would code extract a region that included a call to
vastart. Like 'alloca', calls to vastart must stay in the function that
they are defined in.
* Add some comments.
llvm-svn: 13482
2004-05-12 06:01:40 +00:00
Chris Lattner
67e58adb41
Generate substantially better code when there are a limited number of exits
...
from the extracted region. If the return has 0 or 1 exit blocks, the new
function returns void. If it has 2 exits, it returns bool, otherwise it
returns a ushort as before.
This allows us to use a conditional branch instruction when there are two
exit blocks, as often happens during block extraction.
llvm-svn: 13481
2004-05-12 04:14:24 +00:00
Chris Lattner
7f4cd3b0be
Two minor improvements:
...
1. Get rid of the silly abort block. When doing bb extraction, we get one
abort block for every block extracted, which is kinda annoying.
2. If the switch ends up having a single destination, turn it into an
unconditional branch.
I would like to add support for conditional branches, but to do this we will
want to have the function return a bool instead of a ushort.
llvm-svn: 13478
2004-05-12 03:22:33 +00:00
Chris Lattner
279d8e8e2d
Switch this from using an std::map to using a DenseMap. This speeds up
...
phi-elimination from 0.6 to 0.54s on kc++.
llvm-svn: 13454
2004-05-10 19:17:36 +00:00
Chris Lattner
3fb5488b5e
Use a new VRegPHIUseCount to compute uses of PHI values by other phi values
...
in the basic block being processed. This fixes PhiElimination on kimwitu++
from taking 105s to taking a much more reasonable 0.6s (in a debug build).
llvm-svn: 13453
2004-05-10 19:06:37 +00:00
Chris Lattner
8b57a31ff4
Now that we use an ilist of machine instructions, iterators are more robust
...
than before. Because this is the case, we can compute the first non-phi
instruction once when de-phi'ing a block. This shaves ~4s off of
phielimination of _Z7yyparsev in kimwitu++ from 109s -> 105s. There are
still much more important gains to come.
llvm-svn: 13452
2004-05-10 18:47:18 +00:00
Chris Lattner
a407338e12
Fix a fairly serious pessimizaion that was preventing us from efficiently
...
compiling things like 'add long %X, 1'. The problem is that we were switching
the order of the operands for longs even though we can't fold them yet.
llvm-svn: 13451
2004-05-10 15:15:55 +00:00
Chris Lattner
b37490a331
Patch to fix PR337. Make sure to mark all aliased physical registers as used
...
when we see a read of a register. This is important in cases like:
AL = ...
AH = ...
= AX
The read of AX must make both the AL and AH defs live until the use.
llvm-svn: 13444
2004-05-10 05:12:43 +00:00
Chris Lattner
0962db8f10
Fix some comments, avoid sign extending booleans when zero extend works fine
...
llvm-svn: 13440
2004-05-09 23:16:33 +00:00
Chris Lattner
d18c637a37
Generate more efficient code for casting booleans to integers (no sign extension required)
...
llvm-svn: 13439
2004-05-09 22:28:45 +00:00
Chris Lattner
8ccfc21a0f
syntactically loopify natural loops so that the GCC loop optimizer can find them. This should *dramatically* improve the performance of CBE compiled code on targets that depend on GCC's loop optimizations (like PPC)
...
llvm-svn: 13438
2004-05-09 20:41:32 +00:00
Chris Lattner
c6a63660e6
Do not emit prototypes for setjmp/longjmp, as they are handled specially
...
llvm-svn: 13437
2004-05-09 16:03:29 +00:00
Chris Lattner
7c723ecb57
Fine grainify namespacification
...
llvm-svn: 13436
2004-05-09 06:22:29 +00:00
Chris Lattner
4926af5c32
Make the floating point constant pools local to each function, split the
...
FindUsedTypes manipulation stuff out to be a seperate pass, and make the
main CWriter be a function pass now!
llvm-svn: 13435
2004-05-09 06:20:51 +00:00
Chris Lattner
37abb037bf
Get this looking more like a function pass.
...
llvm-svn: 13433
2004-05-09 04:30:20 +00:00
Chris Lattner
da4ac5d876
Implement the AddPrototypes method
...
llvm-svn: 13432
2004-05-09 04:29:57 +00:00
Chris Lattner
99b7c2b532
Print all PHI copies for successor blocks before the terminator, whether it be a conditional branch or switch.
...
llvm-svn: 13430
2004-05-09 03:42:48 +00:00
Chris Lattner
0efd1cb264
Fix stupid bug in my checkin yesterday
...
llvm-svn: 13429
2004-05-08 22:41:42 +00:00
Tanya Lattner
b6ecf521da
Changed CPUResource to allow access to maxnum users.
...
llvm-svn: 13425
2004-05-08 16:12:50 +00:00
Tanya Lattner
57339f67d6
Updating my versions of ModuloScheduling in cvs. Still not complete.
...
llvm-svn: 13424
2004-05-08 16:12:10 +00:00
Brian Gaeke
7cc5d0f106
Add support for widening integral casts.
...
Flesh out the SetCC support... which currently ends in a little bit
of unfinished code (which is probably completely hilarious) for
generating the condition value splitting the basic block up into 4
blocks, like this (clearly a better API is needed for this!):
BB
cond. branch
/ / R1=1 R2=0
\ /
\ /
R=phi(R1,R2)
Other minor edits.
llvm-svn: 13423
2004-05-08 06:36:14 +00:00
Brian Gaeke
58fd2b0e4a
Add a bunch more branches
...
llvm-svn: 13422
2004-05-08 06:08:29 +00:00
Brian Gaeke
faf41642ca
Flesh out GEP support
...
llvm-svn: 13421
2004-05-08 05:27:20 +00:00
Brian Gaeke
e44dbd4a39
Add ADD with immediate
...
llvm-svn: 13420
2004-05-08 05:26:55 +00:00
Brian Gaeke
5861a59506
Add forms of CMP, SUBCC, and a few branches, and some comments.
...
llvm-svn: 13419
2004-05-08 04:21:32 +00:00
Brian Gaeke
eaf8a021e3
Add stub support for GEPs.
...
Add support for branches (based loosely on X86/InstSelectSimple).
Add support for not visiting phi nodes in the first pass.
Add support for loading bools.
Flesh out support for stores.
llvm-svn: 13418
2004-05-08 04:21:17 +00:00
Alkis Evlogimenos
76be543a64
Add required header
...
llvm-svn: 13417
2004-05-08 03:50:03 +00:00
Alkis Evlogimenos
6022169db7
Remove unneeded header
...
llvm-svn: 13416
2004-05-08 03:49:35 +00:00
Chris Lattner
e3b3e333b0
Implement folding of GEP's like:
...
%tmp.0 = getelementptr [50 x sbyte]* %ar, uint 0, int 5 ; <sbyte*> [#uses=2]
%tmp.7 = getelementptr sbyte* %tmp.0, int 8 ; <sbyte*> [#uses=1]
together. This patch actually allows us to simplify and generalize the code.
llvm-svn: 13415
2004-05-07 22:09:22 +00:00
Brian Gaeke
0d477a958f
Add support for copying bool constants to registers.
...
Disable the code that copies long constants to registers - it looks fishy.
Implement some simple casts: integral, smaller than longs, and equal-width
or narrowing only.
llvm-svn: 13413
2004-05-07 21:39:30 +00:00
Chris Lattner
67c21e74ec
Codegen floating point stores of constants into integer instructions. This
...
allows us to compile:
store float 10.0, float* %P
into:
mov DWORD PTR [%EAX], 1092616192
instead of:
.CPItest_0: # float 0x4024000000000000
.long 1092616192 # float 10
...
fld DWORD PTR [.CPItest_0]
fstp DWORD PTR [%EAX]
llvm-svn: 13409
2004-05-07 21:18:15 +00:00
Chris Lattner
2021030378
Make comparisons against the null pointer as efficient as integer comparisons
...
against zero. In particular, don't emit:
mov %ESI, 0
cmp %ECX, %ESI
instead, emit:
test %ECX, %ECX
llvm-svn: 13407
2004-05-07 19:55:55 +00:00
Chris Lattner
6340390476
Fix PR336: The instcombine pass asserts when visiting load instruction
...
llvm-svn: 13400
2004-05-07 15:35:56 +00:00
John Criswell
ec6d378d21
Don't call getForwardedType() twice, as recommended by Chris.
...
llvm-svn: 13391
2004-05-06 22:15:47 +00:00
Chris Lattner
88706ea172
Implement the new cl::PositionalEatsArgs flag, refactor code a bit
...
llvm-svn: 13388
2004-05-06 22:04:31 +00:00
John Criswell
2d7c5ae892
Fix for PR#330.
...
When looking at getelementptr instructions, make sure to use a forwarded
type. We want to do this because a DerivedType may drop its uses and then
refine its users, who may then use another user who hasn't been refined yet.
By getting the forwarded type, we always ensure that we're looking at a
Type that isn't in a halfway refined state.
Now, I should be able to put this stuff in PATypeHandle, but it doesn't work
for some reason. This should do for now.
llvm-svn: 13386
2004-05-06 21:18:08 +00:00
Chris Lattner
5f18bec9e6
numeric_limits::infinity() apparently does not work on all systems. As a
...
workaround, use the C HUGE_VAL macro instead.
llvm-svn: 13377
2004-05-06 16:25:59 +00:00
Brian Gaeke
dfe0d9af07
Move the stuff that fixes the size, orientation & fonts of graphs to
...
the debugging functions that call "dot". These fixed settings have
various problems: for example, the fixed size that is set in the graph
traits classes is not appropriate for turning the dot file into a PNG,
and if TrueType font rendering is being used, the 'Courier' TrueType font
may not be installed. It seems easy enough to specify these things on the
command line, anyhow.
llvm-svn: 13366
2004-05-05 06:10:06 +00:00
Brian Gaeke
2165451812
Apply simplification suggested by Chris: why assign() when operator = will do?
...
llvm-svn: 13364
2004-05-04 22:02:41 +00:00
John Criswell
b51e979c2c
Fixed inconsistent indentation.
...
llvm-svn: 13363
2004-05-04 21:46:05 +00:00
Brian Gaeke
c9ca9d6625
Missing piece of fix for Bug 333
...
llvm-svn: 13362
2004-05-04 21:41:45 +00:00
Brian Gaeke
28d81c4d0d
Correctly mangle function names when they are used as part of a
...
constant pool member's name.
This is intended to address Bug 333.
Also, fix an anachronistic usage of "M" as a parameter of type Function *.
llvm-svn: 13357
2004-05-04 21:09:02 +00:00
Brian Gaeke
ba26360c7e
Add "Args" optional argument to AbstractInterpreter factory methods, which
...
fills in a ToolArgs vector in the AbstractInterpreter if it is set. This
ToolArgs vector is used to pass additional arguments to LLI and/or LLC.
This is intended to address Bug 40.
Also, make -debug-only=toolrunner work for the LLC and CBE
AbstractInterpreters.
llvm-svn: 13356
2004-05-04 21:09:01 +00:00
Chris Lattner
42e602b94f
Remove unneeded check
...
llvm-svn: 13355
2004-05-04 19:35:11 +00:00
Chris Lattner
dac54ebbee
Improve signed division by power of 2 *dramatically* from this:
...
div:
mov %EDX, DWORD PTR [%ESP + 4]
mov %ECX, 64
mov %EAX, %EDX
sar %EDX, 31
idiv %ECX
ret
to this:
div:
mov %EAX, DWORD PTR [%ESP + 4]
mov %ECX, %EAX
sar %ECX, 5
shr %ECX, 26
mov %EDX, %EAX
add %EDX, %ECX
sar %EAX, 6
ret
Note that the intel compiler is currently making this:
div:
movl 4(%esp), %edx #3.5
movl %edx, %eax #4.14
sarl $5, %eax #4.14
shrl $26, %eax #4.14
addl %edx, %eax #4.14
sarl $6, %eax #4.14
ret #4.14
Which has one less register->register copy. (hint hint alkis :)
llvm-svn: 13354
2004-05-04 19:33:58 +00:00
Brian Gaeke
f3b62c562e
Add stub support for reading BBTraces.
...
llvm-svn: 13352
2004-05-04 17:11:14 +00:00
Chris Lattner
05f657f5c2
Do not mark instructions in unreachable sections of the function as live.
...
This fixes PR332 and ADCE/2004-05-04-UnreachableBlock.llx
llvm-svn: 13349
2004-05-04 17:00:46 +00:00
Brian Gaeke
ae8607e56a
Share ProfilingType enum with the C profiling runtime libraries.
...
llvm-svn: 13346
2004-05-04 16:53:07 +00:00
Chris Lattner
cb9a614ea4
Improve code generated for integer multiplications by 2,3,5,9
...
llvm-svn: 13342
2004-05-04 15:47:14 +00:00
Chris Lattner
7896144611
Minor efficiency tweak, suggested by Patrick Meredith
...
llvm-svn: 13341
2004-05-04 15:19:33 +00:00
Brian Gaeke
a5b32230db
Fix typo
...
llvm-svn: 13340
2004-05-03 23:52:07 +00:00
Brian Gaeke
dcfc3c580e
In InsertProfilingInitCall(), make it legal to pass in a null array, in
...
which case you'll get a null array and zero passed to the profiling function.
llvm-svn: 13336
2004-05-03 22:06:33 +00:00
Brian Gaeke
c8cd0e9092
Add initial implementation of basic-block tracing instrumentation pass.
...
llvm-svn: 13335
2004-05-03 22:06:32 +00:00
Chris Lattner
f5f6f8c0de
Fix a problem with double freeing memory. For some reason, CallGraph is not
...
acting like a normal pass. :(
llvm-svn: 13318
2004-05-02 16:06:18 +00:00
Chris Lattner
099edda1b1
Plug a minor memory leak
...
llvm-svn: 13317
2004-05-02 07:31:34 +00:00
Chris Lattner
d8345001fa
Do not clone arbitrary condition instructions.
...
llvm-svn: 13316
2004-05-02 05:19:36 +00:00
Chris Lattner
da2d746a3b
Do not infinitely "unroll" single BB loops.
...
llvm-svn: 13315
2004-05-02 05:02:03 +00:00
Chris Lattner
5f393764c8
Dont' merge terminators that are needed to select PHI node values.
...
llvm-svn: 13312
2004-05-02 01:00:44 +00:00
Chris Lattner
bd705d7776
Implement SimplifyCFG/branch-cond-merge.ll
...
Turning "if (A < B && B < C)" into "if (A < B & B < C)"
llvm-svn: 13311
2004-05-01 23:35:43 +00:00
Chris Lattner
eb59aec632
Make sure to reprocess instructions used by deleted instructions to avoid
...
missing opportunities for combination.
llvm-svn: 13309
2004-05-01 23:27:23 +00:00
Chris Lattner
f5a5668cf6
Make sure the instruction combiner doesn't lose track of instructions
...
when replacing them, missing the opportunity to do simplifications
llvm-svn: 13308
2004-05-01 23:19:52 +00:00
Chris Lattner
911e21e8ca
Fix my missing parens
...
llvm-svn: 13307
2004-05-01 22:41:51 +00:00
Chris Lattner
82278b599b
Implement SimplifyCFG/branch-cond-prop.ll
...
llvm-svn: 13306
2004-05-01 22:36:37 +00:00
Chris Lattner
4b5d4eb5b1
Remove unused #include
...
llvm-svn: 13304
2004-05-01 21:29:16 +00:00
Chris Lattner
ffbf667718
Iterate over the Machine CFG that Brian added instead of the LLVM CFG.
...
Look at all of the pretty minuses. :)
llvm-svn: 13303
2004-05-01 21:27:53 +00:00
Chris Lattner
c09a94de9e
Operate on the Machine CFG instead of on the LLVM CFG
...
llvm-svn: 13302
2004-05-01 21:24:39 +00:00
Chris Lattner
769668c09a
Stop LiveVariables from using BasicBlocks as part of the mapping, instead
...
use MachineBasicBlocks. To do this, we traverse the Machine CFG instead of
the LLVM CFG, which is also *MUCH* more efficient by having fewer levels of
indirections and mappings.
llvm-svn: 13301
2004-05-01 21:24:24 +00:00
Chris Lattner
5f29db9741
Add a constructor that got lost
...
llvm-svn: 13297
2004-05-01 11:17:13 +00:00
Brian Gaeke
aaeb4c4d23
Generalize the strlen size_t hack, for the benefit of the other external
...
functions with wrappers that either take or return size_ts.
llvm-svn: 13296
2004-05-01 06:42:15 +00:00
Tanya Lattner
077c819d5a
Removing MachineResource class.
...
llvm-svn: 13291
2004-04-30 20:40:38 +00:00
Chris Lattner
9b53c7c797
Fix a major pessimization in the instcombiner. If an allocation instruction
...
is only used by a cast, and the casted type is the same size as the original
allocation, it would eliminate the cast by folding it into the allocation.
Unfortunately, it was placing the new allocation instruction right before
the cast, which could pull (for example) alloca instructions into the body
of a function. This turns statically allocatable allocas into expensive
dynamically allocated allocas, which is bad bad bad.
This fixes the problem by placing the new allocation instruction at the same
place the old one was, duh. :)
llvm-svn: 13289
2004-04-30 04:37:52 +00:00
Misha Brukman
f5e334783a
Wrapped code and comments at 80 cols; doxygenified some comments.
...
llvm-svn: 13264
2004-04-29 04:05:30 +00:00
Misha Brukman
9c4c92c40c
Reorder #includes as per style guide.
...
llvm-svn: 13263
2004-04-29 04:04:47 +00:00
Misha Brukman
5f5f6ca775
class AssemblyWriter:
...
* Make contained ostream pointer, not reference
* Allow setting of that ostream via setStream()
class CachedWriter:
* setStream() in turn calls setStream() on the AssemblyWriter
llvm-svn: 13247
2004-04-28 19:24:28 +00:00
Misha Brukman
f8b734296e
Send text and numbers directly to CachedWriter's contained ostream.
...
llvm-svn: 13243
2004-04-28 18:52:43 +00:00
Misha Brukman
fad1a41fce
Squelch compile-time warning (profile build).
...
llvm-svn: 13228
2004-04-28 15:32:09 +00:00
Misha Brukman
d408a510b8
* Add ability to print out type as symbolic
...
* Add Module accessor to AssemblyWriter
llvm-svn: 13227
2004-04-28 15:31:21 +00:00
Brian Gaeke
bfb4fe5109
Make RequiresFPRegKill() take a MachineBasicBlock arg.
...
In InsertFPRegKills(), just check the MachineBasicBlock for successors
instead of its corresponding BasicBlock.
llvm-svn: 13213
2004-04-28 04:45:55 +00:00
Brian Gaeke
74ed24c9de
In InsertFPRegKills(), use the machine-CFG itself rather than the
...
LLVM CFG when trying to find the successors of BB.
llvm-svn: 13212
2004-04-28 04:34:16 +00:00
Brian Gaeke
6c03805717
Update the machine-CFG edges whenever we see a branch.
...
llvm-svn: 13211
2004-04-28 04:19:37 +00:00
Brian Gaeke
7ce5ef244a
Integrate the rest of my random sparcv9 scribblings into this file
...
llvm-svn: 13204
2004-04-27 22:04:03 +00:00
Chris Lattner
cc929742a1
Fix warning building in optimized mode
...
llvm-svn: 13190
2004-04-27 18:24:38 +00:00
Chris Lattner
02c65b5395
Changes to fix up the inst_iterator to pass to boost iterator checks. This
...
patch was graciously contributed by Vladimir Prus.
llvm-svn: 13185
2004-04-27 15:13:33 +00:00
Brian Gaeke
217515996f
Add functions that return instances of these printer passes
...
llvm-svn: 13175
2004-04-26 16:27:08 +00:00
Chris Lattner
430a61e786
If an object is not in the scalar map then it must be a global from another
...
graph.
llvm-svn: 13173
2004-04-26 14:44:08 +00:00
Chris Lattner
5bad19bde7
Instcombine X/-1 --> 0-X
...
llvm-svn: 13172
2004-04-26 14:01:59 +00:00
Brian Gaeke
1e049bdc77
Fix file header comments and include guards -- many files have been moved or
...
renamed since they were last spiffed up, or they just never had proper comments
in the first place.
llvm-svn: 13148
2004-04-25 07:04:49 +00:00
Brian Gaeke
c3857275f9
Add a getRegisterInfo() accessor just like on the X86 target.
...
llvm-svn: 13147
2004-04-25 06:32:28 +00:00
Brian Gaeke
6e21a0858c
Regularize file header comment and include guard.
...
Include SparcV9RegisterInfo.h.
Add a getRegisterInfo() accessor and SparcV9RegisterInfo instance, just like
on the X86 target.
llvm-svn: 13146
2004-04-25 06:32:16 +00:00
Brian Gaeke
a36743c473
Add MRegisterInfo subclass for the SparcV9 target (containing only stub
...
functions for now). This automatically turns on the printing of machine
registers using their own real names, instead of goofy things like %mreg(42),
and allows us to migrate code incrementally to the new interface as we see fit.
The register file description it uses is hand-written, so that the register
numbers will match the ones that the SparcV9 target already uses.
Perhaps someday we'll tablegen it.
llvm-svn: 13145
2004-04-25 06:32:05 +00:00
Misha Brukman
144b5572e1
* Allow aggregating extracted function arguments (controlled by flag)
...
* Commandline option (for now) controls that flag that is passed in
llvm-svn: 13141
2004-04-23 23:54:17 +00:00
Brian Gaeke
6ed3b116bc
Fix a typo.
...
llvm-svn: 13136
2004-04-23 21:45:02 +00:00
Chris Lattner
b72fa5f541
Move the scev expansion code into this pass, where it belongs. There is
...
still room for cleanup, but at least the code modification is out of the
analysis now.
llvm-svn: 13135
2004-04-23 21:29:48 +00:00
Chris Lattner
f4eb9eb0f2
Eliminate all of the SCEV Expansion code which is really part of the
...
IndVars pass, not part of SCEV *analysis*.
llvm-svn: 13134
2004-04-23 21:29:03 +00:00
Brian Gaeke
7fba37bb96
Merge TargetRegInfo.h into SparcV9RegInfo.h, which is its only subclass.
...
This prepares us to be able to de-virtualize and de-abstract it, and
take the register allocator bits out and move them into the register allocator
proper...
llvm-svn: 13127
2004-04-23 18:15:48 +00:00
Brian Gaeke
40c7e110a5
Include SparcV9RegInfo.h instead of TargetRegInfo.h.
...
llvm-svn: 13126
2004-04-23 18:15:47 +00:00
Brian Gaeke
1b07a2282a
Include SparcV9RegInfo.h instead of TargetRegInfo.h. This serves as a bit of
...
documentation that this module needs to be made independent of the
register file description of the current target.
llvm-svn: 13125
2004-04-23 18:15:46 +00:00
Brian Gaeke
07344c1367
Get rid of the old byte-at-a-time emission code used when the Sparc JIT was
...
being tested on X86, as per Chris's request.
llvm-svn: 13124
2004-04-23 18:10:38 +00:00
Brian Gaeke
96889991bb
Go back to the interpreter main loop after performing intrinsic lowering,
...
because 1) the first instruction might not be a call site, and
2) CS and SF.Caller were not getting set to point to the new call site
anyway (resulting in a crash on e.g. call %llvm.memset).
llvm-svn: 13122
2004-04-23 18:05:28 +00:00
Brian Gaeke
0db103b4b3
Use emitWordAt() to emit forward-branch fixups.
...
llvm-svn: 13120
2004-04-23 17:11:16 +00:00
Brian Gaeke
255d0d9b26
Emit SPARC machine code a word at a time instead of a byte at a time.
...
Use emitWordAt() to emit forward-branch fixups.
llvm-svn: 13119
2004-04-23 17:11:15 +00:00
Brian Gaeke
3cde72d6e2
Implement emitWordAt() for the JIT emitter.
...
llvm-svn: 13118
2004-04-23 17:11:14 +00:00
Brian Gaeke
bc25b3b28a
Implement emitWordAt() for the debug emitter and the file printer emitter. (I
...
am not so sure about the file printer emitter, but the debug emitter change
should be harmless.)
llvm-svn: 13117
2004-04-23 17:11:13 +00:00
Misha Brukman
1dc8e19185
Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete
...
the function instead of isolating it. This also means the condition is reversed.
llvm-svn: 13112
2004-04-22 23:00:51 +00:00
Misha Brukman
ddace6ecbe
Add a flag to choose between isolating a function or deleting the function from
...
the Module. The default behavior keeps functionality as before: the chosen
function is the one that remains.
llvm-svn: 13111
2004-04-22 22:52:22 +00:00
Chris Lattner
6716bcd0cc
Disable a previous patch that was causing indvars to loop infinitely :(
...
llvm-svn: 13108
2004-04-22 15:12:36 +00:00
Chris Lattner
507ba1c3c3
Fix an extremely serious thinko I made in revision 1.60 of this file.
...
llvm-svn: 13106
2004-04-22 14:59:40 +00:00
Chris Lattner
d1906e2ace
Implement a todo, rewriting all possible scev expressions inside of the
...
loop. This eliminates the extra add from the previous case, but it's
not clear that this will be a performance win overall. Tommorows test
results will tell. :)
llvm-svn: 13103
2004-04-21 23:36:08 +00:00
Chris Lattner
96752d27f4
This code really wants to iterate over the OPERANDS of an instruction, not
...
over its USES. If it's dead it doesn't have any uses! :)
Thanks to the fabulous and mysterious Bill Wendling for pointing this out. :)
llvm-svn: 13102
2004-04-21 22:29:37 +00:00
Chris Lattner
a3e2004609
Implement a fixme. The helps loops that have induction variables of different
...
types in them. Instead of creating an induction variable for all types, it
creates a single induction variable and casts to the other sizes. This generates
this code:
no_exit: ; preds = %entry, %no_exit
%indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; <uint> [#uses=4]
*** %j.0.0 = cast uint %indvar to short ; <short> [#uses=1]
%indvar = cast uint %indvar to int ; <int> [#uses=1]
%tmp.7 = getelementptr short* %P, uint %indvar ; <short*> [#uses=1]
store short %j.0.0, short* %tmp.7
%inc.0 = add int %indvar, 1 ; <int> [#uses=2]
%tmp.2 = setlt int %inc.0, %N ; <bool> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.2, label %no_exit, label %loopexit
instead of:
no_exit: ; preds = %entry, %no_exit
%indvar = phi ushort [ %indvar.next, %no_exit ], [ 0, %entry ] ; <ushort> [#uses=2]
*** %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; <uint> [#uses=3]
%indvar = cast uint %indvar to int ; <int> [#uses=1]
%indvar = cast ushort %indvar to short ; <short> [#uses=1]
%tmp.7 = getelementptr short* %P, uint %indvar ; <short*> [#uses=1]
store short %indvar, short* %tmp.7
%inc.0 = add int %indvar, 1 ; <int> [#uses=2]
%tmp.2 = setlt int %inc.0, %N ; <bool> [#uses=1]
%indvar.next = add uint %indvar, 1
*** %indvar.next = add ushort %indvar, 1
br bool %tmp.2, label %no_exit, label %loopexit
This is an improvement in register pressure, but probably doesn't happen that
often.
The more important fix will be to get rid of the redundant add.
llvm-svn: 13101
2004-04-21 22:22:01 +00:00
Chris Lattner
7d02bae5d8
Fix an incredibly nasty iterator invalidation problem. I am too spoiled by ilists :)
...
Eventually it would be nice if CallGraph maintained an ilist of CallGraphNode's instead
of a vector of pointers to them, but today is not that day.
llvm-svn: 13100
2004-04-21 20:44:33 +00:00
Misha Brukman
7d2413f9ec
I'm allergic to the word `stuff'.
...
llvm-svn: 13096
2004-04-21 18:27:56 +00:00
Brian Gaeke
51b16fc65a
Make SparcV9RegInfo::getRegType() return the right answer for registers
...
of IntCC, FloatCC, and Special types.
Make SparcV9RegInfo::getRegClassIDOfRegType() return the right answer
if you ask for the class corresponding to SpecialRegType.
llvm-svn: 13095
2004-04-21 17:53:58 +00:00
Alkis Evlogimenos
904f4f9a21
Include cerrno (gcc-3.4 fix)
...
llvm-svn: 13091
2004-04-21 16:11:40 +00:00
Chris Lattner
ade6ddc694
Fix typeo
...
llvm-svn: 13089
2004-04-21 14:23:18 +00:00
Chris Lattner
15eb3c1f39
REALLY fix PR324: don't delete linkonce functions until after the SCC traversal
...
is done, which avoids invalidating iterators in the SCC traversal routines
llvm-svn: 13088
2004-04-20 22:06:53 +00:00
Chris Lattner
e340657a23
Pass the callgraph not the module
...
llvm-svn: 13087
2004-04-20 21:52:26 +00:00
Chris Lattner
c3714a870c
Add the ability for SCC passes to initialize and finalize themselves
...
llvm-svn: 13084
2004-04-20 21:30:06 +00:00
Chris Lattner
602146eea1
Fix PR325
...
llvm-svn: 13081
2004-04-20 20:26:03 +00:00
Chris Lattner
5a1e3f099f
Fix PR324 and testcase: Inline/2004-04-20-InlineLinkOnce.llx
...
llvm-svn: 13080
2004-04-20 20:20:59 +00:00
Brian Gaeke
3727c760ed
Make it legal to ask for the type of a specialreg
...
llvm-svn: 13078
2004-04-20 20:12:57 +00:00
Chris Lattner
8b841e0e35
Add support for the select instruction
...
llvm-svn: 13076
2004-04-20 16:43:21 +00:00
Brian Gaeke
047739f8d8
Make it legal to request a load or store of %fsr.
...
llvm-svn: 13073
2004-04-19 19:12:12 +00:00
Brian Gaeke
3dfe9f19ea
Regularize include guards and remove some excess whitespace.
...
llvm-svn: 13071
2004-04-19 18:53:44 +00:00
Brian Gaeke
d7fa9142a3
Tighten up SparcV9FloatCCRegClass::getRegName()'s assertion - if you ask it for
...
the name of %fsr (as the comment in SparcV9RegClassInfo.h used to suggest)
you would walk off the end of the FloatCCRegName array.
llvm-svn: 13070
2004-04-19 18:53:43 +00:00
Brian Gaeke
5bcbc23fc1
Regularize include guards, remove some excess whitespace and fix some comments.
...
Remove the extra %fsr register from SparcV9FloatCCRegClass.
llvm-svn: 13069
2004-04-19 18:53:42 +00:00
Chris Lattner
29f69938e7
Initial checkin of a simple loop unswitching pass. It still needs work,
...
but it's a start, and seems to do it's basic job.
llvm-svn: 13068
2004-04-19 18:07:02 +00:00
Chris Lattner
710a51d72b
It's not just a printer, it's actually an analysis too
...
llvm-svn: 13064
2004-04-19 03:42:32 +00:00
Chris Lattner
69d4611250
Remove code to update loop depths
...
llvm-svn: 13058
2004-04-19 03:02:09 +00:00
Chris Lattner
1849aa8b1f
Add #include
...
llvm-svn: 13057
2004-04-19 03:01:23 +00:00
Chris Lattner
ab6502f058
Move isLoopInvariant to the Loop class
...
llvm-svn: 13051
2004-04-18 22:46:08 +00:00
Chris Lattner
509116ec78
Add new method
...
llvm-svn: 13050
2004-04-18 22:45:27 +00:00
Chris Lattner
5a0ed18724
Correct rewriting of exit blocks after my last patch
...
llvm-svn: 13048
2004-04-18 22:27:10 +00:00
Chris Lattner
06e17bb6f7
Fix computation of exit blocks
...
llvm-svn: 13047
2004-04-18 22:21:41 +00:00
Chris Lattner
8e42c6f409
Loop exit sets are no longer explicitly held, they are dynamically computed on demand.
...
llvm-svn: 13046
2004-04-18 22:15:13 +00:00
Chris Lattner
7174acca00
Change the ExitBlocks list from being explicitly contained in the Loop
...
structure to being dynamically computed on demand. This makes updating
loop information MUCH easier.
llvm-svn: 13045
2004-04-18 22:14:10 +00:00
Chris Lattner
13140766df
Reduce the unrolling limit
...
llvm-svn: 13040
2004-04-18 18:06:14 +00:00
Chris Lattner
430968ac2f
If the preheader of the loop was the entry block of the function, make sure
...
that the exit block of the loop becomes the new entry block of the function.
This was causing a verifier assertion on 252.eon.
llvm-svn: 13039
2004-04-18 17:38:42 +00:00
Chris Lattner
199b58db3f
Be much more careful about how we update instructions outside of the loop
...
using instructions inside of the loop. This should fix the MishaTest failure
from last night.
llvm-svn: 13038
2004-04-18 17:32:39 +00:00
Chris Lattner
08232425a0
Implement method
...
llvm-svn: 13036
2004-04-18 06:54:48 +00:00
Chris Lattner
33ec7f2f9f
After unrolling our single basic block loop, fold it into the preheader and exit
...
block. The primary motivation for doing this is that we can now unroll nested loops.
This makes a pretty big difference in some cases. For example, in 183.equake,
we are now beating the native compiler with the CBE, and we are a lot closer
with LLC.
I'm now going to play around a bit with the unroll factor and see what effect
it really has.
llvm-svn: 13034
2004-04-18 06:27:43 +00:00
Chris Lattner
f2045a8c05
Fix a bug: this does not preserve the CFG!
...
While we're at it, add support for updating loop information correctly.
llvm-svn: 13033
2004-04-18 05:38:37 +00:00
Chris Lattner
6606b526f6
Add a new method, add a check missing that caused a segfault if a loop didn't
...
have a canonical indvar
llvm-svn: 13032
2004-04-18 05:38:05 +00:00
Chris Lattner
b0d23bf99d
Initial checkin of a simple loop unroller. This pass is extremely basic and
...
limited. Even in it's extremely simple state (it can only *fully* unroll single
basic block loops that execute a constant number of times), it already helps improve
performance a LOT on some benchmarks, particularly with the native code generators.
llvm-svn: 13028
2004-04-18 05:20:17 +00:00
Chris Lattner
e0f56972f0
Make the tail duplication threshold accessible from the command line instead of hardcoded
...
llvm-svn: 13025
2004-04-18 00:52:43 +00:00
Chris Lattner
22ca3df5b1
Fix a memory leak. We leaked the vector holding the entries in switch tables.
...
llvm-svn: 13023
2004-04-17 23:49:15 +00:00
Chris Lattner
b5ee2bcb62
Add the ability to compute exit values for complex loop using unanalyzable
...
operations. This allows us to compile this testcase:
int main() {
int h = 1;
do h = 3 * h + 1; while (h <= 256);
printf("%d\n", h);
return 0;
}
into this:
int %main() {
entry:
call void %__main( )
%tmp.6 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([4 x sbyte]* %.str_1, long 0, long 0), int 364 ) ; <int> [#uses=0]
ret int 0
}
This testcase was taken directly from 256.bzip2, believe it or not.
This code is not as general as I would like. Next up is to refactor it
a bit to handle more cases.
llvm-svn: 13019
2004-04-17 22:58:41 +00:00
Chris Lattner
740ae78ae6
If the loop executes a constant number of times, try a bit harder to replace
...
exit values.
llvm-svn: 13018
2004-04-17 18:44:09 +00:00
Chris Lattner
9a73de2ba2
Add the ability to compute trip counts that are only controlled by constants
...
even if the loop is using expressions that we can't compute as a closed-form.
This allows us to calculate that this function always returns 55:
int test() {
double X;
int Count = 0;
for (X = 100; X > 1; X = sqrt(X), ++Count)
/*empty*/;
return Count;
}
And allows us to compute trip counts for loops like:
int h = 1;
do h = 3 * h + 1; while (h <= 256);
(which occurs in bzip2), and for this function, which occurs after inlining
and other optimizations:
int popcount()
{
int x = 666;
int result = 0;
while (x != 0) {
result = result + (x & 0x1);
x = x >> 1;
}
return result;
}
We still cannot compute the exit values of result or h in the two loops above,
which means we cannot delete the loop, but we are getting closer. Being able to
compute a constant trip count for these two loops will allow us to unroll them
completely though.
llvm-svn: 13017
2004-04-17 18:36:24 +00:00
Chris Lattner
bcb690dc9b
Fix a HUGE pessimization on X86. The indvars pass was taking this
...
(familiar) function:
int _strlen(const char *str) {
int len = 0;
while (*str++) len++;
return len;
}
And transforming it to use a ulong induction variable, because the type of
the pointer index was left as a constant long. This is obviously very bad.
The fix is to shrink long constants in getelementptr instructions to intptr_t,
making the indvars pass insert a uint induction variable, which is much more
efficient.
Here's the before code for this function:
int %_strlen(sbyte* %str) {
entry:
%tmp.13 = load sbyte* %str ; <sbyte> [#uses=1]
%tmp.24 = seteq sbyte %tmp.13, 0 ; <bool> [#uses=1]
br bool %tmp.24, label %loopexit, label %no_exit
no_exit: ; preds = %entry, %no_exit
*** %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; <uint> [#uses=2]
*** %indvar = phi ulong [ %indvar.next, %no_exit ], [ 0, %entry ] ; <ulong> [#uses=2]
%indvar1 = cast ulong %indvar to uint ; <uint> [#uses=1]
%inc.02.sum = add uint %indvar1, 1 ; <uint> [#uses=1]
%inc.0.0 = getelementptr sbyte* %str, uint %inc.02.sum ; <sbyte*> [#uses=1]
%tmp.1 = load sbyte* %inc.0.0 ; <sbyte> [#uses=1]
%tmp.2 = seteq sbyte %tmp.1, 0 ; <bool> [#uses=1]
%indvar.next = add ulong %indvar, 1 ; <ulong> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.2, label %loopexit.loopexit, label %no_exit
loopexit.loopexit: ; preds = %no_exit
%indvar = cast uint %indvar to int ; <int> [#uses=1]
%inc.1 = add int %indvar, 1 ; <int> [#uses=1]
ret int %inc.1
loopexit: ; preds = %entry
ret int 0
}
Here's the after code:
int %_strlen(sbyte* %str) {
entry:
%inc.02 = getelementptr sbyte* %str, uint 1 ; <sbyte*> [#uses=1]
%tmp.13 = load sbyte* %str ; <sbyte> [#uses=1]
%tmp.24 = seteq sbyte %tmp.13, 0 ; <bool> [#uses=1]
br bool %tmp.24, label %loopexit, label %no_exit
no_exit: ; preds = %entry, %no_exit
*** %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; <uint> [#uses=3]
%indvar = cast uint %indvar to int ; <int> [#uses=1]
%inc.0.0 = getelementptr sbyte* %inc.02, uint %indvar ; <sbyte*> [#uses=1]
%inc.1 = add int %indvar, 1 ; <int> [#uses=1]
%tmp.1 = load sbyte* %inc.0.0 ; <sbyte> [#uses=1]
%tmp.2 = seteq sbyte %tmp.1, 0 ; <bool> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.2, label %loopexit, label %no_exit
loopexit: ; preds = %entry, %no_exit
%len.0.1 = phi int [ 0, %entry ], [ %inc.1, %no_exit ] ; <int> [#uses=1]
ret int %len.0.1
}
llvm-svn: 13016
2004-04-17 18:16:10 +00:00
Chris Lattner
5c85946417
Even if there are not any induction variables in the loop, if we can compute
...
the trip count for the loop, insert one so that we can canonicalize the exit
condition.
llvm-svn: 13015
2004-04-17 18:08:33 +00:00
Chris Lattner
6d5decd7d4
Add support for evaluation of exp/log/log10/pow
...
llvm-svn: 13011
2004-04-16 22:35:33 +00:00
Chris Lattner
ed423cc09d
Fix some really nasty dominance bugs that were exposed by my patch to
...
make the verifier more strict. This fixes building zlib
llvm-svn: 13002
2004-04-16 18:08:07 +00:00
Misha Brukman
cb5de6bca6
Fix retriving parent Function.
...
llvm-svn: 13001
2004-04-16 17:37:12 +00:00
Brian Gaeke
4b9f67c638
Include <cmath> for compatibility with gcc 3.0.x (the system compiler on
...
Debian.)
llvm-svn: 12986
2004-04-16 15:57:32 +00:00
Misha Brukman
aadcd46d25
Assert if deleting BasicBlock before removing it from Function.
...
llvm-svn: 12983
2004-04-16 15:47:21 +00:00
Chris Lattner
bc458be5f9
Fix some of the strange CBE-only failures that happened last night.
...
llvm-svn: 12980
2004-04-16 06:03:17 +00:00
Chris Lattner
644ad23b21
Make sure to check for a very bad class of errors: an instruction
...
that does not dominate all of its users, but is in the same basic block as
its users. This class of error is what caused the mysterious CBE only
failures last night.
llvm-svn: 12979
2004-04-16 05:51:47 +00:00
Chris Lattner
8f8bd7daac
Bugpoint was not correctly capturing stderr! This caused it to "find" bugs
...
that didn't exist, missing the ones that do :(
llvm-svn: 12978
2004-04-16 05:35:58 +00:00
Chris Lattner
06eda01d1b
Fix Inline/2004-04-15-InlineDeletesCall.ll
...
Basically we were using SimplifyCFG as a huge sledgehammer for a simple
optimization. Because simplifycfg does so many things, we can't use it
for this purpose.
llvm-svn: 12977
2004-04-16 05:17:59 +00:00
Chris Lattner
ac2b465cb4
Fix a bug in the previous checkin: if the exit block is not the same as
...
the back-edge block, we must check the preincremented value.
llvm-svn: 12968
2004-04-15 20:26:22 +00:00
Brian Gaeke
e708b1d5ef
Give SparcV9CodeEmitter a head-of-file comment and a PassName.
...
llvm-svn: 12967
2004-04-15 20:23:13 +00:00
Chris Lattner
dcf2ca93e6
Change the canonical induction variable that we insert.
...
Instead of producing code like this:
Loop:
X = phi 0, X2
...
X2 = X + 1
if (X != N-1) goto Loop
We now generate code that looks like this:
Loop:
X = phi 0, X2
...
X2 = X + 1
if (X2 != N) goto Loop
This has two big advantages:
1. The trip count of the loop is now explicit in the code, allowing
the direct implementation of Loop::getTripCount()
2. This reduces register pressure in the loop, and allows X and X2 to be
put into the same register.
As a consequence of the second point, the code we generate for loops went
from:
.LBB2: # no_exit.1
...
mov %EDI, %ESI
inc %EDI
cmp %ESI, 2
mov %ESI, %EDI
jne .LBB2 # PC rel: no_exit.1
To:
.LBB2: # no_exit.1
...
inc %ESI
cmp %ESI, 3
jne .LBB2 # PC rel: no_exit.1
... which has two fewer moves, and uses one less register.
llvm-svn: 12961
2004-04-15 15:21:43 +00:00
Chris Lattner
a86cf626b5
add some helpful methods. Rearrange #includes to proper order
...
llvm-svn: 12960
2004-04-15 15:16:02 +00:00
Chris Lattner
e0156bd979
Factor a bunch of classes out into a public header
...
llvm-svn: 12958
2004-04-15 15:07:24 +00:00
Chris Lattner
ff600e280d
Unbreak the build
...
llvm-svn: 12956
2004-04-15 14:17:43 +00:00
Chris Lattner
276a6e102c
Implement a FIXME: if we're going to insert a cast, we might as well only
...
insert it once!
llvm-svn: 12955
2004-04-14 22:01:22 +00:00
John Criswell
8a4525ae64
Remove code to adjust the iterator for llvm.readio and llvm.writeio.
...
The iterator is pointing at the next instruction which should not disappear
when doing the load/store replacement.
llvm-svn: 12954
2004-04-14 21:27:56 +00:00
Brian Gaeke
8e2fb33172
Fix typo.
...
llvm-svn: 12953
2004-04-14 21:21:56 +00:00
Chris Lattner
7f5e4b6d55
This is a trivial tweak to the addrec insertion code: insert the increment
...
at the bottom of the loop instead of the top. This reduces the number of
overlapping live ranges a lot, for example, eliminating a spill in an important
loop in 183.equake with linear scan.
I still need to make the exit comparison of the loop use the post-incremented
version of this variable, but this is an easy first step.
llvm-svn: 12952
2004-04-14 21:11:25 +00:00
Brian Gaeke
2c02798e86
Add a TargetData to the PassManager regardless of the TargetMachine.
...
This should unbreak the Sparc JIT again.
llvm-svn: 12949
2004-04-14 17:45:52 +00:00
John Criswell
bed6463449
Remove the return type check for llvm.readio. This check is done for all
...
functions and is not needed here.
Simplify the pointer type check per Chris's suggestions.
llvm-svn: 12945
2004-04-14 15:06:48 +00:00
John Criswell
e00ecd7e84
Added code to verify that llvm.readio's pointer argument returns something
...
that matches its return type.
llvm-svn: 12944
2004-04-14 14:49:36 +00:00
John Criswell
11f7f60028
Finish adding the llvm.readio and llvm.writeio intrinsics.
...
Sorry these didn't get in yesterday.
llvm-svn: 12942
2004-04-14 13:46:52 +00:00
Chris Lattner
6fcf8c7402
ADd a trivial instcombine: load null -> null
...
llvm-svn: 12940
2004-04-14 03:28:36 +00:00
Chris Lattner
64431dbce7
This is the real fix for Codegen/X86/2004-04-13-FPCMOV-Crash.llx which works
...
even when the "optimization" I added before is turned off. It generates this
extremely pointless code:
test:
fld QWORD PTR [%ESP + 4]
mov %AL, 0
test %AL, %AL
fcmove %ST(0), %ST(0)
ret
Good thing the optimizer will have removed this before code generation
anyway. :)
llvm-svn: 12939
2004-04-14 02:42:32 +00:00
John Criswell
94de925685
Added support for the llvm.readio and llvm.writeio intrinsics.
...
On x86, memory operations occur in-order, so these are just lowered into
volatile loads and stores.
llvm-svn: 12936
2004-04-13 22:13:14 +00:00
Chris Lattner
2ba048528f
Implement a small optimization, which papers over the problem in
...
X86/2004-04-13-FPCMOV-Crash.llx
A more robust fix is to follow.
llvm-svn: 12935
2004-04-13 21:56:09 +00:00
Chris Lattner
545e77c9d5
Add SCCP support for constant folding calls, implementing:
...
test/Regression/Transforms/SCCP/calltest.ll
llvm-svn: 12921
2004-04-13 19:43:54 +00:00
Chris Lattner
778f09027f
Add a simple call constant propagation interface.
...
llvm-svn: 12919
2004-04-13 19:28:52 +00:00
Chris Lattner
8c0e9c95e9
Constant propagation should remove the dead instructions
...
llvm-svn: 12917
2004-04-13 19:28:20 +00:00
Brian Gaeke
336b83623a
I don't think we have to have 4 extra allocated (but unused) bytes on the stack.
...
llvm-svn: 12905
2004-04-13 18:28:37 +00:00
Brian Gaeke
6d8a362874
I started working on casts, but I don't have anything compilable yet.
...
llvm-svn: 12903
2004-04-13 18:27:46 +00:00
Chris Lattner
8b6bc380e3
Emit the immediate form of in/out when possible.
...
Fix several bugs in the intrinsics:
1. Make sure to copy the input registers before the instructions that use them
2. Make sure to copy the value returned by 'in' out of EAX into the register
it is supposed to be in.
This fixes assertions when using in/out and linear scan.
llvm-svn: 12896
2004-04-13 17:20:37 +00:00
Chris Lattner
15ac62827e
Add immediate forms of in/out. Use let to shorten lines
...
llvm-svn: 12895
2004-04-13 17:19:31 +00:00
Chris Lattner
ecbade26d5
Add support for new instruction type
...
llvm-svn: 12894
2004-04-13 17:18:51 +00:00
Chris Lattner
e8e60bf45f
Add support for the printImplicitDefsBefore flag
...
llvm-svn: 12893
2004-04-13 17:18:39 +00:00