diff options
author | dim <dim@FreeBSD.org> | 2016-02-13 14:57:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-02-13 14:57:10 +0000 |
commit | 97a7b8a20a989eb4cf3d9465e1451de6cd05fa41 (patch) | |
tree | 0daaa3c98a8029d259c5918dfa1c13c9d4fe7971 /lib/Transforms/InstCombine/InstCombineVectorOps.cpp | |
parent | 44c4732640f764c943d7814138396141c0f4646b (diff) | |
download | FreeBSD-src-97a7b8a20a989eb4cf3d9465e1451de6cd05fa41.zip FreeBSD-src-97a7b8a20a989eb4cf3d9465e1451de6cd05fa41.tar.gz |
Vendor import of llvm release_38 branch r260756:
https://llvm.org/svn/llvm-project/llvm/branches/release_38@260756
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 5cde31a..bc4c0eb 100644 --- a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -380,6 +380,23 @@ static void replaceExtractElements(InsertElementInst *InsElt, ExtendMask.push_back(UndefValue::get(IntType)); Value *ExtVecOp = ExtElt->getVectorOperand(); + auto *ExtVecOpInst = dyn_cast<Instruction>(ExtVecOp); + BasicBlock *InsertionBlock = (ExtVecOpInst && !isa<PHINode>(ExtVecOpInst)) + ? ExtVecOpInst->getParent() + : ExtElt->getParent(); + + // TODO: This restriction matches the basic block check below when creating + // new extractelement instructions. If that limitation is removed, this one + // could also be removed. But for now, we just bail out to ensure that we + // will replace the extractelement instruction that is feeding our + // insertelement instruction. This allows the insertelement to then be + // replaced by a shufflevector. If the insertelement is not replaced, we can + // induce infinite looping because there's an optimization for extractelement + // that will delete our widening shuffle. This would trigger another attempt + // here to create that shuffle, and we spin forever. + if (InsertionBlock != InsElt->getParent()) + return; + auto *WideVec = new ShuffleVectorInst(ExtVecOp, UndefValue::get(ExtVecType), ConstantVector::get(ExtendMask)); @@ -387,7 +404,6 @@ static void replaceExtractElements(InsertElementInst *InsElt, // (as long as it's not a PHI) or at the start of the basic block of the // extract, so any subsequent extracts in the same basic block can use it. // TODO: Insert before the earliest ExtractElementInst that is replaced. - auto *ExtVecOpInst = dyn_cast<Instruction>(ExtVecOp); if (ExtVecOpInst && !isa<PHINode>(ExtVecOpInst)) WideVec->insertAfter(ExtVecOpInst); else |