[llvm-branch-commits] [llvm-branch] r82055 - in /llvm/branches/Apple/Bender-SWB: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/phi-merge-gep.ll

Bill Wendling isanbard at gmail.com
Wed Sep 16 10:33:36 PDT 2009


Author: void
Date: Wed Sep 16 12:33:35 2009
New Revision: 82055

URL: http://llvm.org/viewvc/llvm-project?rev=82055&view=rev
Log:
$ svn merge -c 81993 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r81993 into '.':
A    test/Transforms/InstCombine/phi-merge-gep.ll
U    lib/Transforms/Scalar/InstructionCombining.cpp


Added:
    llvm/branches/Apple/Bender-SWB/test/Transforms/InstCombine/phi-merge-gep.ll
      - copied unchanged from r81993, llvm/trunk/test/Transforms/InstCombine/phi-merge-gep.ll
Modified:
    llvm/branches/Apple/Bender-SWB/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/branches/Apple/Bender-SWB/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Bender-SWB/lib/Transforms/Scalar/InstructionCombining.cpp?rev=82055&r1=82054&r2=82055&view=diff

==============================================================================
--- llvm/branches/Apple/Bender-SWB/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/branches/Apple/Bender-SWB/lib/Transforms/Scalar/InstructionCombining.cpp Wed Sep 16 12:33:35 2009
@@ -10377,6 +10377,10 @@
   // This is true if all GEP bases are allocas and if all indices into them are
   // constants.
   bool AllBasePointersAreAllocas = true;
+
+  // We don't want to replace this phi if the replacement would require
+  // more than one phi.
+  bool NeededPhi = false;
   
   // Scan to see if all operands are the same opcode, all have one use, and all
   // kill their operands (i.e. the operands have one use).
@@ -10408,7 +10412,16 @@
       
       if (FirstInst->getOperand(op)->getType() !=GEP->getOperand(op)->getType())
         return 0;
+
+      // If we already needed a PHI for an earlier operand, and another operand
+      // also requires a PHI, we'd be introducing more PHIs than we're
+      // eliminating, which increases register pressure on entry to the PHI's
+      // block.
+      if (NeededPhi)
+        return 0;
+
       FixedOperands[op] = 0;  // Needs a PHI.
+      NeededPhi = true;
     }
   }
   





More information about the llvm-branch-commits mailing list