Fix Transforms/InstCombine/2006-03-30-ExtractElement.ll
authorChris Lattner <sabre@nondot.org>
Thu, 30 Mar 2006 22:02:40 +0000 (22:02 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 30 Mar 2006 22:02:40 +0000 (22:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27261 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 397c6d6ecd6aa9522a647defcb75260106a9118e..cd734568ba5618604f59e1e8a9bdd36f0e0c151d 100644 (file)
@@ -6704,9 +6704,13 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
         if (IE->getOperand(2) == EI.getOperand(1))
           return ReplaceInstUsesWith(EI, IE->getOperand(1));
         // If the inserted and extracted elements are constants, they must not
-        // be the same value, replace with the pre-inserted value.
-        if (isa<Constant>(IE->getOperand(2)) && isa<Constant>(EI.getOperand(1)))
-          return ReplaceInstUsesWith(EI, IE->getOperand(0));
+        // be the same value, extract from the pre-inserted value instead.
+        if (isa<Constant>(IE->getOperand(2)) &&
+            isa<Constant>(EI.getOperand(1))) {
+          AddUsesToWorkList(EI);
+          EI.setOperand(0, IE->getOperand(0));
+          return &EI;
+        }
       }
     }
   return 0;