[llvm] r205511 - [CodeGen] Fix peephole optimizer bug introduced in r205481. Fixes PR19318.
Lang Hames
lhames at gmail.com
Wed Apr 2 22:03:21 PDT 2014
Author: lhames
Date: Thu Apr 3 00:03:20 2014
New Revision: 205511
URL: http://llvm.org/viewvc/llvm-project?rev=205511&view=rev
Log:
[CodeGen] Fix peephole optimizer bug introduced in r205481. Fixes PR19318.
I should have read that comment a little more carefully. ;)
Regression test in the works, committing in the mean time to un-break people.
Modified:
llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp
Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=205511&r1=205510&r2=205511&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (original)
+++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Thu Apr 3 00:03:20 2014
@@ -630,20 +630,22 @@ bool PeepholeOptimizer::runOnMachineFunc
// earlier load into MI.
if (!isLoadFoldable(MI, FoldAsLoadDefCandidates) &&
!FoldAsLoadDefCandidates.empty()) {
- // We need to fold load after optimizeCmpInstr, since optimizeCmpInstr
- // can enable folding by converting SUB to CMP.
- // Save FoldAsLoadDefReg because optimizeLoadInstr() resets it and we
- // need it for markUsesInDebugValueAsUndef().
const MCInstrDesc &MIDesc = MI->getDesc();
for (unsigned i = MIDesc.getNumDefs(); i != MIDesc.getNumOperands();
++i) {
const MachineOperand &MOp = MI->getOperand(i);
if (!MOp.isReg())
continue;
- unsigned TryFoldReg = MOp.getReg();
- if (FoldAsLoadDefCandidates.count(TryFoldReg)) {
+ unsigned FoldAsLoadDefReg = MOp.getReg();
+ if (FoldAsLoadDefCandidates.count(FoldAsLoadDefReg)) {
+ // We need to fold load after optimizeCmpInstr, since
+ // optimizeCmpInstr can enable folding by converting SUB to CMP.
+ // Save FoldAsLoadDefReg because optimizeLoadInstr() resets it and
+ // we need it for markUsesInDebugValueAsUndef().
+ unsigned FoldedReg = FoldAsLoadDefReg;
MachineInstr *DefMI = 0;
- MachineInstr *FoldMI = TII->optimizeLoadInstr(MI, MRI, TryFoldReg,
+ MachineInstr *FoldMI = TII->optimizeLoadInstr(MI, MRI,
+ FoldAsLoadDefReg,
DefMI);
if (FoldMI) {
// Update LocalMIs since we replaced MI with FoldMI and deleted
@@ -655,8 +657,8 @@ bool PeepholeOptimizer::runOnMachineFunc
LocalMIs.insert(FoldMI);
MI->eraseFromParent();
DefMI->eraseFromParent();
- MRI->markUsesInDebugValueAsUndef(TryFoldReg);
- FoldAsLoadDefCandidates.erase(TryFoldReg);
+ MRI->markUsesInDebugValueAsUndef(FoldedReg);
+ FoldAsLoadDefCandidates.erase(FoldedReg);
++NumLoadFold;
// MI is replaced with FoldMI.
Changed = true;
More information about the llvm-commits
mailing list