LocalStackSlotAllocation: Turn one-iteration loop into if.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 23 Feb 2014 13:34:21 +0000 (13:34 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 23 Feb 2014 13:34:21 +0000 (13:34 +0000)
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201974 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LocalStackSlotAllocation.cpp

index 08f0cc2f0116a3882c4108b49f83b833714a8a92..6cf164b9e4fefbc5e016e4daac5b8faaaf837e4a 100644 (file)
@@ -377,18 +377,11 @@ bool LocalStackSlotPass::insertFrameReferenceRegisters(MachineFunction &Fn) {
       // processed all FrameRefs before this one, just check whether or not
       // the next FrameRef will be able to reuse this new register. If not,
       // then don't bother creating it.
-      bool CanReuse = false;
-      for (int refn = ref + 1; refn < e; ++refn) {
-        FrameRef &FRN = FrameReferenceInsns[refn];
-        MachineBasicBlock::iterator J = FRN.getMachineInstr();
-        MachineInstr *MIN = J;
-
-        CanReuse = lookupCandidateBaseReg(BaseOffset, FrameSizeAdjust,
-                                          FRN.getLocalOffset(), MIN, TRI);
-        break;
-      }
-
-      if (!CanReuse) {
+      if (ref + 1 >= e ||
+          !lookupCandidateBaseReg(
+              BaseOffset, FrameSizeAdjust,
+              FrameReferenceInsns[ref + 1].getLocalOffset(),
+              FrameReferenceInsns[ref + 1].getMachineInstr(), TRI)) {
         BaseOffset = PrevBaseOffset;
         continue;
       }