Skip to content

Commit 52237aa

Browse files
committed
Avoid else-return in splitAggregateLoad.
1 parent f151a96 commit 52237aa

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/SILOptimizer/Utils/CanonicalizeInstruction.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,21 @@ splitAggregateLoad(LoadInst *loadInst, CanonicalizeInstruction &pass) {
195195
for (auto *use : getNonDebugUses(loadInst)) {
196196
auto *user = use->getUser();
197197
if (needsBorrow) {
198-
if (auto *borrow = dyn_cast<BeginBorrowInst>(user)) {
199-
// The transformation below also assumes a single borrow use.
200-
auto *borrowedOper = borrow->getSingleNonEndingUse();
201-
if (!borrowedOper)
202-
return nextII;
203-
204-
borrows.push_back(borrow);
205-
user = borrowedOper->getUser();
206-
207-
} else if (auto *destroy = dyn_cast<DestroyValueInst>(user)) {
198+
if (auto *destroy = dyn_cast<DestroyValueInst>(user)) {
208199
destroys.push_back(destroy);
209200
continue;
210-
} else
201+
}
202+
auto *borrow = dyn_cast<BeginBorrowInst>(user);
203+
if (!borrow)
211204
return nextII;
205+
206+
// The transformation below also assumes a single borrow use.
207+
auto *borrowedOper = borrow->getSingleNonEndingUse();
208+
if (!borrowedOper)
209+
return nextII;
210+
211+
borrows.push_back(borrow);
212+
user = borrowedOper->getUser();
212213
}
213214
// If we have any non SEI, TEI instruction, don't do anything here.
214215
if (!isa<StructExtractInst>(user) && !isa<TupleExtractInst>(user))

0 commit comments

Comments
 (0)