diff options
author | Philip Reames <listmail@philipreames.com> | 2019-06-25 17:29:18 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-06-25 17:29:18 +0000 |
commit | be0dedb2e134525a9fde84c89f8abb6c453c4e1e (patch) | |
tree | 681aa8951faae11ad3f94bf46e1159237bda8ae0 /llvm/lib/CodeGen/PeepholeOptimizer.cpp | |
parent | 99a44915275f84ceac5583a89b22a066057fd61a (diff) | |
download | bcm5719-llvm-be0dedb2e134525a9fde84c89f8abb6c453c4e1e.tar.gz bcm5719-llvm-be0dedb2e134525a9fde84c89f8abb6c453c4e1e.zip |
[Peephole] Allow folding loads into instructions w/multiple uses (such as test64rr)
Peephole opt has a one use limitation which appears to be accidental. The function being used was incorrectly documented as returning whether the def had one *user*, but instead returned true only when there was one *use*. Add a corresponding hasOneNonDbgUser helper, and adjust peephole-opt to use the appropriate one.
All of the actual folding code handles multiple uses within a single instruction. That codepath is well exercised through instruction selection.
Differential Revision: https://reviews.llvm.org/D63656
llvm-svn: 364336
Diffstat (limited to 'llvm/lib/CodeGen/PeepholeOptimizer.cpp')
-rw-r--r-- | llvm/lib/CodeGen/PeepholeOptimizer.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp index a3f1b83b157..38512e5a1a7 100644 --- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp +++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp @@ -1306,7 +1306,7 @@ bool PeepholeOptimizer::optimizeUncoalescableCopy( /// Check whether MI is a candidate for folding into a later instruction. /// We only fold loads to virtual registers and the virtual register defined -/// has a single use. +/// has a single user. bool PeepholeOptimizer::isLoadFoldable( MachineInstr &MI, SmallSet<unsigned, 16> &FoldAsLoadDefCandidates) { if (!MI.canFoldAsLoad() || !MI.mayLoad()) @@ -1316,12 +1316,12 @@ bool PeepholeOptimizer::isLoadFoldable( return false; unsigned Reg = MI.getOperand(0).getReg(); - // To reduce compilation time, we check MRI->hasOneNonDBGUse when inserting + // To reduce compilation time, we check MRI->hasOneNonDBGUser when inserting // loads. It should be checked when processing uses of the load, since // uses can be removed during peephole. if (!MI.getOperand(0).getSubReg() && TargetRegisterInfo::isVirtualRegister(Reg) && - MRI->hasOneNonDBGUse(Reg)) { + MRI->hasOneNonDBGUser(Reg)) { FoldAsLoadDefCandidates.insert(Reg); return true; } |