Changed back (relative to commit 179786) the operations executed when extract(cast...
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombineVectorOps.cpp
index 79e16f13ad049528d83902439a89f2d6776a093e..de8a3acdbd855150dc49e727295d12a7f97c5bf0 100644 (file)
@@ -279,9 +279,9 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
       // Canonicalize extractelement(cast) -> cast(extractelement)
       // bitcasts can change the number of vector elements and they cost nothing
       if (CI->hasOneUse() && (CI->getOpcode() != Instruction::BitCast)) {
-        Value *EE = InsertNewInstWith(
-                 ExtractElementInst::Create(CI->getOperand(0), EI.getIndexOperand()),
-          *CI);
+        Value *EE = Builder->CreateExtractElement(CI->getOperand(0),
+                                                  EI.getIndexOperand());
+        Worklist.AddValue(EE);
         return CastInst::Create(CI->getOpcode(), EE, EI.getType());
       }
     }