Generate much more efficient code in programs like pifft
authorChris Lattner <sabre@nondot.org>
Mon, 23 Feb 2004 21:46:58 +0000 (21:46 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 23 Feb 2004 21:46:58 +0000 (21:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11775 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 0b4716399700b0cf65f7cf718bc62d8e67ff6a02..fb7dc9849235706ceacbca8d9186c6d8bd891d68 100644 (file)
@@ -2163,6 +2163,14 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
       // Replace: gep (gep %P, long B), long A, ...
       // With:    T = long A+B; gep %P, T, ...
       //
+      // Note that if our source is a gep chain itself that we wait for that
+      // chain to be resolved before we perform this transformation.  This
+      // avoids us creating a TON of code in some cases.
+      //
+      if (isa<GetElementPtrInst>(Src->getOperand(0)) &&
+          cast<Instruction>(Src->getOperand(0))->getNumOperands() == 2)
+        return 0;   // Wait until our source is folded to completion.
+
       Value *Sum = BinaryOperator::create(Instruction::Add, Src->getOperand(1),
                                           GEP.getOperand(1),
                                           Src->getName()+".sum", &GEP);