Skip to content

Commit 40d0ea5

Browse files
committed
SILOptimizer: Teach loop unrolling about more kinds of increment operations
1 parent 66d601c commit 40d0ea5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/SILOptimizer/LoopTransforms/LoopUnroll.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,21 @@ static Optional<uint64_t> getMaxLoopTripCount(SILLoop *Loop,
163163

164164
SILValue RecNext = Cmp->getArguments()[0];
165165
SILPhiArgument *RecArg;
166+
167+
// Match signed add with overflow, unsigned add with overflow and
168+
// add without overflow.
166169
if (!match(RecNext, m_TupleExtractOperation(
167170
m_ApplyInst(BuiltinValueKind::SAddOver,
168171
m_SILPhiArgument(RecArg), m_One()),
169-
0)))
172+
0)) &&
173+
!match(RecNext, m_TupleExtractOperation(
174+
m_ApplyInst(BuiltinValueKind::UAddOver,
175+
m_SILPhiArgument(RecArg), m_One()),
176+
0)) &&
177+
!match(RecNext, m_ApplyInst(BuiltinValueKind::Add,
178+
m_SILPhiArgument(RecArg), m_One()))) {
170179
return None;
180+
}
171181

172182
if (RecArg->getParent() != Header)
173183
return None;

0 commit comments

Comments
 (0)