From 048405f510d873b3987bf65bcd5718f275193784 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 15 Oct 2012 18:21:07 +0000 Subject: [PATCH] Make sure we iterate over newly created instructions. Fixes pr13625. Testcase to follow in one sec. llvm-svn: 165951 --- llvm/lib/CodeGen/PeepholeOptimizer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp index 9099862..a795ac8 100644 --- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp +++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp @@ -527,6 +527,11 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) { SeenMoveImm = true; } else { Changed |= optimizeExtInstr(MI, MBB, LocalMIs); + // optimizeExtInstr might have created new instructions after MI + // and before the already incremented MII. Adjust MII so that the + // next iteration sees the new instructions. + MII = MI; + ++MII; if (SeenMoveImm) Changed |= foldImmediate(MI, MBB, ImmDefRegs, ImmDefMIs); } -- 2.7.4