@@ -2859,26 +2859,23 @@ static Value *stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
2859
2859
// / strides "a[i*stride]". Returns the symbolic stride, or null otherwise.
2860
2860
static const SCEV *getStrideFromPointer (Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
2861
2861
auto *PtrTy = dyn_cast<PointerType>(Ptr->getType ());
2862
- if (!PtrTy || PtrTy-> isAggregateType () )
2862
+ if (!PtrTy)
2863
2863
return nullptr ;
2864
2864
2865
2865
// Try to remove a gep instruction to make the pointer (actually index at this
2866
2866
// point) easier analyzable. If OrigPtr is equal to Ptr we are analyzing the
2867
2867
// pointer, otherwise, we are analyzing the index.
2868
2868
Value *OrigPtr = Ptr;
2869
2869
2870
- // The size of the pointer access.
2871
- int64_t PtrAccessSize = 1 ;
2872
-
2873
2870
Ptr = stripGetElementPtr (Ptr, SE, Lp);
2874
2871
const SCEV *V = SE->getSCEV (Ptr);
2875
2872
2876
2873
if (Ptr != OrigPtr)
2877
2874
// Strip off casts.
2878
- while (const SCEVIntegralCastExpr *C = dyn_cast<SCEVIntegralCastExpr>(V))
2875
+ while (auto *C = dyn_cast<SCEVIntegralCastExpr>(V))
2879
2876
V = C->getOperand ();
2880
2877
2881
- const SCEVAddRecExpr *S = dyn_cast<SCEVAddRecExpr>(V);
2878
+ auto *S = dyn_cast<SCEVAddRecExpr>(V);
2882
2879
if (!S)
2883
2880
return nullptr ;
2884
2881
@@ -2888,25 +2885,20 @@ static const SCEV *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *L
2888
2885
return nullptr ;
2889
2886
2890
2887
V = S->getStepRecurrence (*SE);
2891
- if (!V)
2892
- return nullptr ;
2893
2888
2894
2889
// Strip off the size of access multiplication if we are still analyzing the
2895
2890
// pointer.
2896
2891
if (OrigPtr == Ptr) {
2897
- if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(V)) {
2898
- if (M->getOperand (0 )->getSCEVType () != scConstant)
2892
+ if (auto *M = dyn_cast<SCEVMulExpr>(V)) {
2893
+ auto *StepConst = dyn_cast<SCEVConstant>(M->getOperand (0 ));
2894
+ if (!StepConst)
2899
2895
return nullptr ;
2900
2896
2901
- const APInt &APStepVal = cast<SCEVConstant>(M->getOperand (0 ))->getAPInt ();
2902
-
2903
- // Huge step value - give up.
2904
- if (APStepVal.getBitWidth () > 64 )
2897
+ auto StepVal = StepConst->getAPInt ().trySExtValue ();
2898
+ // Bail out on a non-unit pointer access size.
2899
+ if (!StepVal || StepVal != 1 )
2905
2900
return nullptr ;
2906
2901
2907
- int64_t StepVal = APStepVal.getSExtValue ();
2908
- if (PtrAccessSize != StepVal)
2909
- return nullptr ;
2910
2902
V = M->getOperand (1 );
2911
2903
}
2912
2904
}
@@ -2920,7 +2912,7 @@ static const SCEV *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *L
2920
2912
if (isa<SCEVUnknown>(V))
2921
2913
return V;
2922
2914
2923
- if (const auto *C = dyn_cast<SCEVIntegralCastExpr>(V))
2915
+ if (auto *C = dyn_cast<SCEVIntegralCastExpr>(V))
2924
2916
if (isa<SCEVUnknown>(C->getOperand ()))
2925
2917
return V;
2926
2918
0 commit comments