summaryrefslogtreecommitdiff
path: root/lib/Transforms/Vectorize/BBVectorize.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2012-11-12 23:55:36 +0000
committerHal Finkel <hfinkel@anl.gov>2012-11-12 23:55:36 +0000
commitb2b2469a9178f7e22cd7a69f3093e54d67d6b712 (patch)
treec99426756959a1127c04ebb5bfca9c2c49fc2608 /lib/Transforms/Vectorize/BBVectorize.cpp
parent5090b2d3774c684f5e6f0f61362e522af2e6ea83 (diff)
downloadllvm-b2b2469a9178f7e22cd7a69f3093e54d67d6b712.tar.gz
llvm-b2b2469a9178f7e22cd7a69f3093e54d67d6b712.tar.bz2
llvm-b2b2469a9178f7e22cd7a69f3093e54d67d6b712.tar.xz
BBVectorize: Only some insert element operand pairs are free.
This fixes another infinite recursion case when using target costs. We can only replace insert element input chains that are pure (end with inserting into an undef). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167784 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/BBVectorize.cpp')
-rw-r--r--lib/Transforms/Vectorize/BBVectorize.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/Transforms/Vectorize/BBVectorize.cpp b/lib/Transforms/Vectorize/BBVectorize.cpp
index fb31d91801..32a37bad7f 100644
--- a/lib/Transforms/Vectorize/BBVectorize.cpp
+++ b/lib/Transforms/Vectorize/BBVectorize.cpp
@@ -677,6 +677,19 @@ assert(n < 10 && "hrmm, really?");
return false;
}
+
+ bool isPureIEChain(InsertElementInst *IE) {
+ InsertElementInst *IENext = IE;
+ do {
+ if (!isa<UndefValue>(IENext->getOperand(0)) &&
+ !isa<InsertElementInst>(IENext->getOperand(0))) {
+ return false;
+ }
+ } while ((IENext =
+ dyn_cast<InsertElementInst>(IENext->getOperand(0))));
+
+ return true;
+ }
};
// This function implements one vectorization iteration on the provided
@@ -1854,7 +1867,9 @@ assert(n < 10 && "hrmm, really?");
// folded with other operations.
if (Ty1 == Ty2) {
// If both are insert elements, then both can be widened.
- if (isa<InsertElementInst>(O1) && isa<InsertElementInst>(O2))
+ InsertElementInst *IEO1 = dyn_cast<InsertElementInst>(O1),
+ *IEO2 = dyn_cast<InsertElementInst>(O2);
+ if (IEO1 && IEO2 && isPureIEChain(IEO1) && isPureIEChain(IEO2))
continue;
// If both are extract elements, and both have the same input
// type, then they can be replaced with a shuffle
@@ -2126,18 +2141,7 @@ assert(n < 10 && "hrmm, really?");
if (InsertElementInst *LIE = dyn_cast<InsertElementInst>(LOp)) {
// If we have a pure insertelement chain, then this can be rewritten
// into a chain that directly builds the larger type.
- bool PureChain = true;
- InsertElementInst *LIENext = LIE;
- do {
- if (!isa<UndefValue>(LIENext->getOperand(0)) &&
- !isa<InsertElementInst>(LIENext->getOperand(0))) {
- PureChain = false;
- break;
- }
- } while ((LIENext =
- dyn_cast<InsertElementInst>(LIENext->getOperand(0))));
-
- if (PureChain) {
+ if (isPureIEChain(LIE)) {
SmallVector<Value *, 8> VectElemts(numElemL,
UndefValue::get(ArgTypeL->getScalarType()));
InsertElementInst *LIENext = LIE;