mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-30 17:33:24 +00:00
SLPVectorizer: Improve the compile time of isConsecutive by reordering the conditions that check GEPs and eliminate two of the calls to accumulateConstantOffset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186731 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
272458bd06
commit
dc4ddd3201
@ -994,19 +994,27 @@ bool BoUpSLP::isConsecutiveAccess(Value *A, Value *B) {
|
||||
Type *Ty = cast<PointerType>(PtrA->getType())->getElementType();
|
||||
int64_t Sz = DL->getTypeStoreSize(Ty);
|
||||
|
||||
// Check if PtrA is the base and PtrB is a constant offset.
|
||||
if (GepB && GepB->getPointerOperand() == PtrA) {
|
||||
APInt Offset(BW, 0);
|
||||
if (GepB->accumulateConstantOffset(*DL, Offset))
|
||||
return Offset.getSExtValue() == Sz;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if PtrB is the base and PtrA is a constant offset.
|
||||
if (GepA && GepA->getPointerOperand() == PtrB) {
|
||||
APInt Offset(BW, 0);
|
||||
if (GepA->accumulateConstantOffset(*DL, Offset))
|
||||
return Offset.getSExtValue() == -Sz;
|
||||
return false;
|
||||
}
|
||||
|
||||
// If both pointers are GEPs:
|
||||
if (GepA && GepB) {
|
||||
// Check that they have the same base pointer.
|
||||
if (GepA->getPointerOperand() != GepB->getPointerOperand())
|
||||
return false;
|
||||
|
||||
// Check if the geps use a constant offset.
|
||||
APInt OffsetA(BW, 0) ,OffsetB(BW, 0);
|
||||
if (GepA->accumulateConstantOffset(*DL, OffsetA) &&
|
||||
GepB->accumulateConstantOffset(*DL, OffsetB))
|
||||
return ((OffsetB.getSExtValue() - OffsetA.getSExtValue()) == Sz);
|
||||
|
||||
if (GepA->getNumIndices() != GepB->getNumIndices())
|
||||
// Check that they have the same base pointer and number of indices.
|
||||
if (GepA->getPointerOperand() != GepB->getPointerOperand() ||
|
||||
GepA->getNumIndices() != GepB->getNumIndices())
|
||||
return false;
|
||||
|
||||
// Try to strip the geps. This makes SCEV faster.
|
||||
@ -1022,17 +1030,6 @@ bool BoUpSLP::isConsecutiveAccess(Value *A, Value *B) {
|
||||
Sz = 1;
|
||||
}
|
||||
|
||||
// Check if PtrA is the base and PtrB is a constant offset.
|
||||
if (GepB && GepB->getPointerOperand() == PtrA) {
|
||||
APInt Offset(BW, 0);
|
||||
if (GepB->accumulateConstantOffset(*DL, Offset))
|
||||
return Offset.getZExtValue() == DL->getTypeStoreSize(Ty);
|
||||
}
|
||||
|
||||
// GepA can't use PtrB as a base pointer.
|
||||
if (GepA && GepA->getPointerOperand() == PtrB)
|
||||
return false;
|
||||
|
||||
ConstantInt *CA = dyn_cast<ConstantInt>(PtrA);
|
||||
ConstantInt *CB = dyn_cast<ConstantInt>(PtrB);
|
||||
if (CA && CB) {
|
||||
|
Loading…
Reference in New Issue
Block a user