Skip to content

Commit 6da7d4c

Browse files
committed
[LAA] strip dead code, simplify logic (NFC)
733b8b2 ([LAA] Simplify identification of speculatable strides [nfc]) refactored getStrideFromPointer() to compute directly on SCEVs, and return an SCEV expression instead of a Value. However, it left behind a call to getUniqueCastUse(), which is completely unnecessary. Remove this dead code, and simplify the surrounding program logic.
1 parent e3ca558 commit 6da7d4c

File tree

1 file changed

+7
-29
lines changed

1 file changed

+7
-29
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,7 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
26562656
SymbolicStrides, UncomputablePtr, false);
26572657
if (!CanDoRTIfNeeded) {
26582658
auto *I = dyn_cast_or_null<Instruction>(UncomputablePtr);
2659-
recordAnalysis("CantIdentifyArrayBounds", I)
2659+
recordAnalysis("CantIdentifyArrayBounds", I)
26602660
<< "cannot identify array bounds";
26612661
LLVM_DEBUG(dbgs() << "LAA: We can't vectorize because we can't find "
26622662
<< "the array bounds.\n");
@@ -2873,21 +2873,6 @@ static Value *stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
28732873
return GEP->getOperand(InductionOperand);
28742874
}
28752875

2876-
/// If a value has only one user that is a CastInst, return it.
2877-
static Value *getUniqueCastUse(Value *Ptr, Loop *Lp, Type *Ty) {
2878-
Value *UniqueCast = nullptr;
2879-
for (User *U : Ptr->users()) {
2880-
CastInst *CI = dyn_cast<CastInst>(U);
2881-
if (CI && CI->getType() == Ty) {
2882-
if (!UniqueCast)
2883-
UniqueCast = CI;
2884-
else
2885-
return nullptr;
2886-
}
2887-
}
2888-
return UniqueCast;
2889-
}
2890-
28912876
/// Get the stride of a pointer access in a loop. Looks for symbolic
28922877
/// strides "a[i*stride]". Returns the symbolic stride, or null otherwise.
28932878
static const SCEV *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
@@ -2950,21 +2935,14 @@ static const SCEV *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *L
29502935
return nullptr;
29512936

29522937
// Look for the loop invariant symbolic value.
2953-
const SCEVUnknown *U = dyn_cast<SCEVUnknown>(V);
2954-
if (!U) {
2955-
const auto *C = dyn_cast<SCEVIntegralCastExpr>(V);
2956-
if (!C)
2957-
return nullptr;
2958-
U = dyn_cast<SCEVUnknown>(C->getOperand());
2959-
if (!U)
2960-
return nullptr;
2938+
if (isa<SCEVUnknown>(V))
2939+
return V;
29612940

2962-
// Match legacy behavior - this is not needed for correctness
2963-
if (!getUniqueCastUse(U->getValue(), Lp, V->getType()))
2964-
return nullptr;
2965-
}
2941+
if (const auto *C = dyn_cast<SCEVIntegralCastExpr>(V))
2942+
if (isa<SCEVUnknown>(C->getOperand()))
2943+
return V;
29662944

2967-
return V;
2945+
return nullptr;
29682946
}
29692947

29702948
void LoopAccessInfo::collectStridedAccess(Value *MemAccess) {

0 commit comments

Comments
 (0)