diff options
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MachineLICM.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp index ce0a1b41cc0..d3a77ab4945 100644 --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -74,7 +74,7 @@ SinkInstsToAvoidSpills("sink-insts-to-avoid-spills", static cl::opt<bool> HoistConstStores("hoist-const-stores", cl::desc("Hoist invariant stores"), - cl::init(false), cl::Hidden); + cl::init(true), cl::Hidden); STATISTIC(NumHoisted, "Number of machine instructions hoisted out of loops"); @@ -902,10 +902,13 @@ static bool mayLoadFromGOTOrConstantPool(MachineInstr &MI) { // This means, the value being stored and the address where it is being stored // is constant throughout the body of the function (not including prologue and // epilogue). When called with an MI that isn't a store, it returns false. +// A future improvement can be to check if the store registers are constant +// throughout the loop rather than throughout the funtion. static bool isInvariantStore(const MachineInstr &MI, const TargetRegisterInfo *TRI, const MachineRegisterInfo *MRI) { + bool FoundCallerPresReg = false; if (!MI.mayStore() || MI.hasUnmodeledSideEffects() || (MI.getNumOperands() == 0)) return false; @@ -922,9 +925,13 @@ static bool isInvariantStore(const MachineInstr &MI, return false; if (!TRI->isCallerPreservedPhysReg(Reg, *MI.getMF())) return false; + else + FoundCallerPresReg = true; + } else if (!MO.isImm()) { + return false; } } - return true; + return FoundCallerPresReg; } // Return true if the input MI is a copy instruction that feeds an invariant |