aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@arm.com>2013-05-24 12:29:54 +0000
committerJoey Gouly <joey.gouly@arm.com>2013-05-24 12:29:54 +0000
commit4a941316cdcfbc3671c806c9c40df1bad09ba6ad (patch)
tree5ac3f64e9853eaace017dc109c5871e4dd04e54e /lib/Transforms/InstCombine/InstCombineVectorOps.cpp
parent77226a03dca98e6237c1068f2652fe41bea7b687 (diff)
downloadexternal_llvm-4a941316cdcfbc3671c806c9c40df1bad09ba6ad.zip
external_llvm-4a941316cdcfbc3671c806c9c40df1bad09ba6ad.tar.gz
external_llvm-4a941316cdcfbc3671c806c9c40df1bad09ba6ad.tar.bz2
scalarizePHI needs to insert the next ExtractElement in the same block
as the BinaryOperator, *not* in the block where the IRBuilder is currently inserting into. Fixes a bug where scalarizePHI would create instructions that would not dominate all uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182639 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineVectorOps.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 4301ddb..527ddbc 100644
--- a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -146,8 +146,10 @@ Instruction *InstCombiner::scalarizePHI(ExtractElementInst &EI, PHINode *PN) {
// vector operand.
BinaryOperator *B0 = cast<BinaryOperator>(PHIUser);
unsigned opId = (B0->getOperand(0) == PN) ? 1: 0;
- Value *Op = Builder->CreateExtractElement(
- B0->getOperand(opId), Elt, B0->getOperand(opId)->getName()+".Elt");
+ Value *Op = InsertNewInstWith(
+ ExtractElementInst::Create(B0->getOperand(opId), Elt,
+ B0->getOperand(opId)->getName() + ".Elt"),
+ *B0);
Value *newPHIUser = InsertNewInstWith(
BinaryOperator::Create(B0->getOpcode(), scalarPHI,Op),
*B0);