mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user