aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-10 23:08:24 +0000
committerChris Lattner <sabre@nondot.org>2008-01-10 23:08:24 +0000
commitc8226f32e9751a98dbec442c49756f1ec2c39970 (patch)
tree4c366c6f225afdb6a8b232705402cc2b0fd1c77f /llvm/lib/CodeGen/MachineSink.cpp
parentaf5d80cba5a5940ec22846d9b250d9fec10eb25f (diff)
downloadllvm-c8226f32e9751a98dbec442c49756f1ec2c39970.zip
llvm-c8226f32e9751a98dbec442c49756f1ec2c39970.tar.gz
llvm-c8226f32e9751a98dbec442c49756f1ec2c39970.tar.bz2
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
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index b83d844..dc3e364 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -133,19 +133,21 @@ bool MachineSinking::SinkInstruction(MachineInstr *MI) {
const TargetInstrDesc &TID = MI->getDesc();
// Ignore stuff that we obviously can't sink.
- if (TID.mayStore() || TID.isCall() || TID.isReturn() || TID.isBranch())
+ if (TID.mayStore() || TID.isCall() || TID.isReturn() || TID.isBranch() ||
+ TID.hasUnmodeledSideEffects())
return false;
- if (TID.mayLoad())
- return false;
-
- // Don't sink things with side-effects we don't understand.
- if (TII->hasUnmodelledSideEffects(MI))
- return false;
-
- // FIXME: we should be able to sink loads with no other side effects if there
- // is nothing that can change memory from here until the end of block. This
- // is a trivial form of alias analysis.
+ if (TID.mayLoad()) {
+ // Okay, this instruction does a load. As a refinement, allow the target
+ // to decide whether the loaded value is actually a constant. If so, we
+ // can actually use it as a load.
+ if (!TII->isInvariantLoad(MI)) {
+ // FIXME: we should be able to sink loads with no other side effects if
+ // there is nothing that can change memory from here until the end of
+ // block. This is a trivial form of alias analysis.
+ return false;
+ }
+ }
// FIXME: This should include support for sinking instructions within the
// block they are currently in to shorten the live ranges. We often get