]> granicus.if.org Git - llvm/commitdiff
[InstCombine] remove redundant fold for extractelement; NFC
authorSanjay Patel <spatel@rotateright.com>
Thu, 23 May 2019 23:33:38 +0000 (23:33 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 23 May 2019 23:33:38 +0000 (23:33 +0000)
The out-of-bounds index pattern is handled by InstSimplify,
so the extractelement should be eliminated next time it is
visited.

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

lib/Transforms/InstCombine/InstCombineVectorOps.cpp

index 063175b45cba7574b00316830cf4d6a882cdc39b..c3fd612a9d0071eb9731b4ab2808270943727368 100644 (file)
@@ -884,10 +884,6 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
   if (match(IdxOp, m_ConstantInt(InsertedIdx)) &&
       match(ScalarOp, m_ExtractElement(m_Value(ExtVecOp),
                                        m_ConstantInt(ExtractedIdx)))) {
-    unsigned NumExtractVectorElts = ExtVecOp->getType()->getVectorNumElements();
-    if (ExtractedIdx >= NumExtractVectorElts) // Out of range extract.
-      return replaceInstUsesWith(IE, VecOp);
-
     // If we are extracting a value from a vector, then inserting it right
     // back into the same place, just use the input vector.
     if (ExtVecOp == VecOp && ExtractedIdx == InsertedIdx)