diff options
author | Zaara Syeda <syzaara@ca.ibm.com> | 2018-04-09 14:50:02 +0000 |
---|---|---|
committer | Zaara Syeda <syzaara@ca.ibm.com> | 2018-04-09 14:50:02 +0000 |
commit | 935474fef57d9bf57cd7faca0deb1f2b0ce3e8c3 (patch) | |
tree | 96def8cd421544ba3d39c84ca11dc408524af6b2 /llvm/lib/CodeGen | |
parent | f0029a77382483aeede05c5d0ac8423a5eba7f7a (diff) | |
download | bcm5719-llvm-935474fef57d9bf57cd7faca0deb1f2b0ce3e8c3.tar.gz bcm5719-llvm-935474fef57d9bf57cd7faca0deb1f2b0ce3e8c3.zip |
[MachineLICM] Re-enable hoisting of constant stores
This patch fixes an issue exposed on the SystemZ build bots when committing
https://reviews.llvm.org/rL327856. The hoisting was temporarily disabled with
an option. This patch now re-enables hoisting and checks that we only hoist a
store instruction when all its operands are either constant caller preserved
registers or immediates.
Differential Revision: https://reviews.llvm.org/D45286
llvm-svn: 329577
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 |