Dan Gohman
303190c3a2
Don't unconditionally suppress hoisting of instructions with implicit
...
defs or uses. The regular def and use checking below covers them, and
can be more precise. It's safe to hoist an instruction with a dead
implicit def if the register isn't live into the loop header.
llvm-svn: 97352
2010-02-28 00:08:44 +00:00
Chris Lattner
7acf9be6c4
move target-independent opcodes out of TargetInstrInfo
...
into TargetOpcodes.h. #include the new TargetOpcodes.h
into MachineInstr. Add new inline accessors (like isPHI())
to MachineInstr, and start using them throughout the
codebase.
llvm-svn: 95687
2010-02-09 19:54:29 +00:00
David Greene
f1e49c30ee
Change errs() to dbgs().
...
llvm-svn: 92547
2010-01-05 00:03:48 +00:00
Dan Gohman
0f8f7f179d
Add Loop contains utility methods for testing whether a loop
...
contains another loop, or an instruction. The loop form is
substantially more efficient on large loops than the typical
code it replaces.
llvm-svn: 91654
2009-12-18 01:24:09 +00:00
Evan Cheng
9828118adf
Enable hoisting load from constant memories.
...
llvm-svn: 89510
2009-11-20 23:31:34 +00:00
Evan Cheng
92a81f9ffc
Add option -licm-const-load to hoist all loads from constant memory.
...
llvm-svn: 89477
2009-11-20 19:55:37 +00:00
Jakob Stoklund Olesen
ab8e8a9bc9
Add MachineBasicBlock::getName, and use it in place of getBasicBlock()->getName.
...
Fix debug code that assumes getBasicBlock never returns NULL.
llvm-svn: 89428
2009-11-20 01:17:03 +00:00
Evan Cheng
e1439535ac
Fix comment.
...
llvm-svn: 89129
2009-11-17 19:19:01 +00:00
Evan Cheng
8eaaffb9da
- Add TargetInstrInfo::isIdentical(). It's similar to MachineInstr::isIdentical
...
except it doesn't care if the definitions' virtual registers differ. This is
used by machine LICM and other MI passes to perform CSE.
- Teach Thumb2InstrInfo::isIdentical() to check two t2LDRpci_pic are identical.
Since pc relative constantpool entries are always different, this requires it
it check if the values can actually the same.
llvm-svn: 86328
2009-11-07 03:52:02 +00:00
Evan Cheng
3a05d1d9bb
Code refactoring.
...
llvm-svn: 86085
2009-11-05 00:51:13 +00:00
Evan Cheng
d783406059
Re-apply 85799. It turns out my code isn't buggy.
...
llvm-svn: 85947
2009-11-03 21:40:02 +00:00
Evan Cheng
ca5847665b
Revert 85799 for now. It might be breaking llvm-gcc driver.
...
llvm-svn: 85827
2009-11-02 21:49:14 +00:00
Evan Cheng
ec5cb0cdbd
Initilize the machine LICM CSE map upon the first time an instruction is hoisted to
...
the loop preheader. Add instructions which are already in the preheader block that
may be common expressions of those that are hoisted out. These does get a few more
instructions CSE'ed.
llvm-svn: 85799
2009-11-02 08:09:49 +00:00
Dan Gohman
ad6c6a3d33
Fix MachineLICM to use the correct virtual register class when
...
unfolding loads for hoisting. getOpcodeAfterMemoryUnfold returns the
opcode of the original operation without the load, not the load
itself, MachineLICM needs to know the operand index in order to get
the correct register class. Extend getOpcodeAfterMemoryUnfold to
return this information.
llvm-svn: 85622
2009-10-30 22:18:41 +00:00
Dan Gohman
4620ed7bb7
Refactor the code for unfolding a load into a separate function.
...
llvm-svn: 85515
2009-10-29 17:47:20 +00:00
Dan Gohman
a43a2a10a1
Simplify this code: if the unfolded load can't be hoisted, just delete
...
the new instructions and leave the old one in place.
llvm-svn: 85393
2009-10-28 15:23:36 +00:00
Dan Gohman
076a3b5e25
Teach MachineLICM to unfold loads from constant memory from
...
otherwise unhoistable instructions in order to allow the loads
to be hoisted.
llvm-svn: 85364
2009-10-28 03:21:57 +00:00
Nick Lewycky
2b8400628d
Remove includes of Support/Compiler.h that are no longer needed after the
...
VISIBILITY_HIDDEN removal.
llvm-svn: 85043
2009-10-25 06:57:41 +00:00
Nick Lewycky
711c726c97
Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.
...
Chris claims we should never have visibility_hidden inside any .cpp file but
that's still not true even after this commit.
llvm-svn: 85042
2009-10-25 06:33:48 +00:00
Dan Gohman
5bfc2416fe
Factor out LiveIntervalAnalysis' code to determine whether an instruction
...
is trivially rematerializable and integrate it into
TargetInstrInfo::isTriviallyReMaterializable. This way, all places that
need to know whether an instruction is rematerializable will get the
same answer.
This enables the useful parts of the aggressive-remat option by
default -- using AliasAnalysis to determine whether a memory location
is invariant, and removes the questionable parts -- rematting operations
with virtual register inputs that may not be live everywhere.
llvm-svn: 83687
2009-10-09 23:27:56 +00:00
Dan Gohman
3005d6bf9f
isTriviallyReMaterializable checks the
...
TargetInstrDesc::isRematerializable flag, so it isn't necessary to do
this check in its callers.
llvm-svn: 83671
2009-10-09 21:02:10 +00:00
Evan Cheng
ec853b9ba5
Give Dan and my recent changes, machine LICM is now code size neutral.
...
llvm-svn: 83624
2009-10-09 06:31:25 +00:00
Evan Cheng
439044f330
Fix a logic error that caused non-rematable loop invariants loads to be licm'ed out of loop.
...
llvm-svn: 83622
2009-10-09 06:21:52 +00:00
Dan Gohman
b95136e649
Replace TargetInstrInfo::isInvariantLoad and its target-specific
...
implementations with a new MachineInstr::isInvariantLoad, which uses
MachineMemOperands and is target-independent. This brings MachineLICM
and other functionality to targets which previously lacked an
isInvariantLoad implementation.
llvm-svn: 83475
2009-10-07 17:38:06 +00:00
Dan Gohman
7f73a0c1e4
Don't hoist or sink instructions with physreg uses if the physreg is
...
allocatable. Even if it doesn't appear to have any defs, it may latter
on after register allocation.
llvm-svn: 82834
2009-09-26 02:34:00 +00:00
Dan Gohman
487152872b
Unbreak MachineLICM for instructions that reference RIP on x86-64 too.
...
llvm-svn: 82825
2009-09-25 23:58:45 +00:00
Bill Wendling
6dff651660
Convert DOUT to DEBUG(errs()...).
...
llvm-svn: 79754
2009-08-22 20:25:44 +00:00
Dan Gohman
24939b2c4f
Tidy #includes.
...
llvm-svn: 78677
2009-08-11 16:02:12 +00:00
Daniel Dunbar
8496064116
More migration to raw_ostream, the water has dried up around the iostream hole.
...
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
"magic" DOUT behavior which avoided calling printing functions when the
statement was disabled. In addition to being unnecessary magic, it had the
downside of leaving code in -Asserts builds, and of hiding potentially
unnecessary computations.
llvm-svn: 77019
2009-07-25 00:23:56 +00:00
Evan Cheng
0ca6e3dba5
MachineLICM CSE should match destination register classes; avoid hoisting implicit_def's.
...
llvm-svn: 65592
2009-02-27 00:02:22 +00:00
Evan Cheng
078ac6071d
Machine LICM increases register pressure and it almost always increase code size. For now, disable it for optimizing for size.
...
llvm-svn: 63856
2009-02-05 08:51:13 +00:00
Evan Cheng
5087dd8359
Teach machine licm to CSE hoisted instructions.
...
llvm-svn: 63854
2009-02-05 08:45:46 +00:00
Evan Cheng
ed9464bdec
Don't call isInvariantLoad twice.
...
llvm-svn: 63729
2009-02-04 09:21:58 +00:00
Evan Cheng
d80609a7b3
Don't bother hoisting out a "cheap" instruction if all of its uses are PHIs. LICM "cheap" instructions are not particularly beneficial to start with. This will just end up making the copies harder to coalesce.
...
llvm-svn: 63728
2009-02-04 09:19:56 +00:00
Evan Cheng
68f918e570
For now, only hoist re-materilizable instructions. LICM will increase register pressure. We want to avoid spilling more instructions if it's possible.
...
llvm-svn: 63725
2009-02-04 07:17:49 +00:00
Dan Gohman
23a5f63b21
Simplify the MachineLICM pass by having it only traverse outer
...
loops, hoisting instructions all the way out in one step rather
than hoisting them one nest level at a time. Also, make a few
other code simplifications. This speeds up MachineLICM
by several fold.
llvm-svn: 62283
2009-01-15 22:01:38 +00:00
Dan Gohman
8271066844
Tidy up #includes, deleting a bunch of unnecessary #includes.
...
llvm-svn: 61715
2009-01-05 17:59:02 +00:00
Dan Gohman
1c1b281cd5
Use isTerminator() instead of isBranch()||isReturn() in
...
several places. isTerminator() returns true for a superset
of cases, and includes things like FP_REG_KILL, which are
nither return or branch but aren't safe to move/remat/etc.
llvm-svn: 61373
2008-12-23 17:28:50 +00:00
Dan Gohman
fae8a30dce
Give MachineLICM a name, for -time-passes etc.
...
llvm-svn: 61184
2008-12-18 01:37:56 +00:00
Dan Gohman
30c5ce1b7d
Switch the MachineOperand accessors back to the short names like
...
isReg, etc., from isRegister, etc.
llvm-svn: 57006
2008-10-03 15:45:36 +00:00
Dan Gohman
e1f9be27bc
Tidy up several unbeseeming casts from pointer to intptr_t.
...
llvm-svn: 55779
2008-09-04 17:05:41 +00:00
Bill Wendling
4a9ded80e2
Cosmetic changes to Machine LICM. No functionality change.
...
llvm-svn: 55578
2008-08-31 02:30:23 +00:00
Bill Wendling
42a2073ed4
Don't hoist instructions that define a physical register.
...
llvm-svn: 55074
2008-08-20 20:32:05 +00:00
Bill Wendling
12569b3697
Don't hoist instructions that have implicit uses or defines. Before, it was
...
hoisting out some "test" and "cmp" instructions. This was obvious badness.
llvm-svn: 54908
2008-08-18 00:33:49 +00:00
Bill Wendling
d6bd5ea0b7
Prevent option name conflict.
...
llvm-svn: 53166
2008-07-07 05:42:27 +00:00
Dan Gohman
bab18cae46
Clean up the use of static and anonymous namespaces. This turned up
...
several things that were neither in an anonymous namespace nor static
but not intended to be global.
llvm-svn: 51017
2008-05-13 00:00:25 +00:00
Bill Wendling
f3c4b7fbb5
Revert the previous commit. Go ahead and hoist rematerializable instructions.
...
llvm-svn: 50990
2008-05-12 19:47:18 +00:00
Bill Wendling
74cabebb44
One real change - don't hoist something that's trivially rematerializable. It's
...
possible for it to produce worse code than before.
The rest of this patch is code cleanup.
llvm-svn: 50987
2008-05-12 19:38:32 +00:00
Bill Wendling
91ff268a77
Minor cleanup. No functionality change.
...
llvm-svn: 48142
2008-03-10 08:13:01 +00:00
Bill Wendling
8fb166bf6c
Rename PrintableName to Name.
...
llvm-svn: 47629
2008-02-26 21:47:57 +00:00
Bill Wendling
50f5c4be14
Change "Name" to "AsmName" in the target register info. Gee, a refactoring tool
...
would have been a Godsend here!
llvm-svn: 47625
2008-02-26 21:11:01 +00:00
Dan Gohman
cabaec582f
Rename MRegisterInfo to TargetRegisterInfo.
...
llvm-svn: 46930
2008-02-10 18:45:23 +00:00
Chris Lattner
bfffa4f21e
Simplify the side effect stuff a bit more and make licm/sinking
...
both work right according to the new flags.
This removes the TII::isReallySideEffectFree predicate, and adds
TII::isInvariantLoad.
It removes NeverHasSideEffects+MayHaveSideEffects and adds
UnmodeledSideEffects as machine instr flags. Now the clients
can decide everything they need.
I think isRematerializable can be implemented in terms of the
flags we have now, though I will let others tackle that.
llvm-svn: 45843
2008-01-10 23:08:24 +00:00
Chris Lattner
f83aae613c
rename TargetInstrDescriptor -> TargetInstrDesc.
...
Make MachineInstr::getDesc return a reference instead
of a pointer, since it can never be null.
llvm-svn: 45695
2008-01-07 07:27:27 +00:00
Chris Lattner
f7f96d818f
Rename MachineInstr::getInstrDescriptor -> getDesc(), which reflects
...
that it is cheap and efficient to get.
Move a variety of predicates from TargetInstrInfo into
TargetInstrDescriptor, which makes it much easier to query a predicate
when you don't have TII around. Now you can use MI->getDesc()->isBranch()
instead of going through TII, and this is much more efficient anyway. Not
all of the predicates have been moved over yet.
Update old code that used MI->getInstrDescriptor()->Flags to use the
new predicates in many places.
llvm-svn: 45674
2008-01-07 01:56:04 +00:00
Bill Wendling
2017097bb8
Add that this preserves some analyses.
...
llvm-svn: 45573
2008-01-04 08:48:49 +00:00
Bill Wendling
13eb1bfc08
Move option to enable machine LICM into LLVMTargetMachine.cpp.
...
llvm-svn: 45572
2008-01-04 08:11:03 +00:00
Bill Wendling
da5d32e248
Call the parent's getAnalysisUsage.
...
llvm-svn: 45571
2008-01-04 07:50:05 +00:00
Chris Lattner
b02b90a8f6
remove dead #includes and reorder the rest.
...
llvm-svn: 45569
2008-01-04 06:41:45 +00:00
Bill Wendling
c677923991
Use the correct MachineRegisterInfo object.
...
llvm-svn: 45499
2008-01-02 21:10:54 +00:00
Bill Wendling
005b47c20c
Remove dead code.
...
llvm-svn: 45496
2008-01-02 20:47:37 +00:00
Bill Wendling
5843183ca2
Use the new architecture to get the containing machine basic block for a machine
...
instruction. Also, use "splice" to move the new instruction instead of
remove/insert (where it was leaking memory anyway).
llvm-svn: 45492
2008-01-02 19:32:43 +00:00
Chris Lattner
ad9a6ccb83
Remove attribution from file headers, per discussion on llvmdev.
...
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Bill Wendling
cba1938285
Updated comments to reflect what "side effects" means in this situation.
...
llvm-svn: 45245
2007-12-20 01:08:10 +00:00
Bill Wendling
fe0e399130
Add debugging info. Use the newly created "hasUnmodelledSideEffects" method.
...
llvm-svn: 45178
2007-12-18 21:38:04 +00:00
Bill Wendling
20a11adc5e
Need to grow the indexed map. Added debug statements.
...
llvm-svn: 44892
2007-12-11 23:27:51 +00:00
Bill Wendling
c92c27f928
Simplify slightly.
...
llvm-svn: 44881
2007-12-11 22:22:22 +00:00
Bill Wendling
9f0bcd67cf
Blark! How in the world did this work without this?!
...
llvm-svn: 44874
2007-12-11 19:40:06 +00:00
Bill Wendling
30281897da
- Update the virtual reg to machine instruction map when hoisting.
...
- Fix subtle bug when creating initially creating this map.
llvm-svn: 44873
2007-12-11 19:17:04 +00:00
Bill Wendling
9f02f24469
Checking for "zero operands" during the "CanHoistInst()" method isn't necessary
...
because those with side effects will be caught by other checks in here.
Also, simplify the check for a BB in a sub loop.
llvm-svn: 44871
2007-12-11 18:45:11 +00:00
Bill Wendling
8d8d9a2f5e
Reverting 44702. It wasn't correct to rename them.
...
llvm-svn: 44727
2007-12-08 23:58:46 +00:00
Bill Wendling
d10837def7
Renaming:
...
isTriviallyReMaterializable -> hasNoSideEffects
isReallyTriviallyReMaterializable -> isTriviallyReMaterializable
llvm-svn: 44702
2007-12-08 07:17:56 +00:00
Bill Wendling
3c6bac9686
Incorporated comments from Evan and Chris:
...
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071203/056043.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071203/056048.html
llvm-svn: 44696
2007-12-08 01:47:01 +00:00
Bill Wendling
c08dedb060
Initial commit of the machine code LICM pass. It successfully hoists this:
...
_foo:
li r2, 0
LBB1_1: ; bb
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmplw cr0, r2, r4
bne cr0, LBB1_1 ; bb
LBB1_2: ; return
blr
to:
_foo:
li r2, 0
li r5, 0
LBB1_1: ; bb
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmplw cr0, r2, r4
bne cr0, LBB1_1 ; bb
LBB1_2: ; return
blr
ZOMG!! :-)
Moar to come...
llvm-svn: 44687
2007-12-07 21:42:31 +00:00