Skip to content

Commit 503decc

Browse files
committed
Include immediate users of loaded values in the load/stores dependencies predicate
1 parent 2f8ac01 commit 503decc

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,7 +4811,7 @@ getAppleRuntimeUnrollPreferences(Loop *L, ScalarEvolution &SE,
48114811
if (!isLoopSizeWithinBudget(L, TTI, 9, &Size))
48124812
return;
48134813

4814-
SmallPtrSet<Value *, 8> LoadedValues;
4814+
SmallPtrSet<Value *, 8> LoadedValuesPlus;
48154815
SmallVector<StoreInst *> Stores;
48164816
for (auto *BB : L->blocks()) {
48174817
for (auto &I : *BB) {
@@ -4821,9 +4821,16 @@ getAppleRuntimeUnrollPreferences(Loop *L, ScalarEvolution &SE,
48214821
const SCEV *PtrSCEV = SE.getSCEV(Ptr);
48224822
if (SE.isLoopInvariant(PtrSCEV, L))
48234823
continue;
4824-
if (isa<LoadInst>(&I))
4825-
LoadedValues.insert(&I);
4826-
else
4824+
if (isa<LoadInst>(&I)) {
4825+
LoadedValuesPlus.insert(&I);
4826+
// Included 1st users of loaded values
4827+
for (auto *U : I.users()) {
4828+
auto *Inst = dyn_cast<Instruction>(U);
4829+
if (!Inst || Inst->getParent() != BB)
4830+
continue;
4831+
LoadedValuesPlus.insert(U);
4832+
}
4833+
} else
48274834
Stores.push_back(cast<StoreInst>(&I));
48284835
}
48294836
}
@@ -4846,8 +4853,8 @@ getAppleRuntimeUnrollPreferences(Loop *L, ScalarEvolution &SE,
48464853
UC++;
48474854
}
48484855

4849-
if (BestUC == 1 || none_of(Stores, [&LoadedValues](StoreInst *SI) {
4850-
return LoadedValues.contains(SI->getOperand(0));
4856+
if (BestUC == 1 || none_of(Stores, [&LoadedValuesPlus](StoreInst *SI) {
4857+
return LoadedValuesPlus.contains(SI->getOperand(0));
48514858
}))
48524859
return;
48534860

0 commit comments

Comments
 (0)