Skip to content

Commit 1dbe5db

Browse files
Apply suggestions from code review
Co-authored-by: Mehdi Amini <[email protected]>
1 parent 30307b6 commit 1dbe5db

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,10 @@ mergeResource(DenseMap<TypeID, std::pair<bool, MemoryEffects::EffectInstance>>
8383

8484
bool conflict = srcHasConflict || srcIsAllocOrFree;
8585

86-
auto dstIt = resourceConflicts.find(srcResourceID);
87-
88-
// if it doesn't already exist, create entry for resource in map
89-
if (dstIt == resourceConflicts.end()) {
90-
resourceConflicts.insert(
86+
auto [dstIt, inserted] = resourceConflicts.insert(
9187
std::make_pair(srcResourceID, std::make_pair(conflict, srcEffect)));
88+
if (inserted)
9289
return;
93-
}
9490

9591
// resource already in use
9692
bool dstHasConflict = dstIt->second.first;
@@ -108,13 +104,11 @@ mergeResource(DenseMap<TypeID, std::pair<bool, MemoryEffects::EffectInstance>>
108104
dstIt->second = std::make_pair(conflict, srcEffect);
109105
}
110106

111-
/// Returns true if any of op's OpOperands are defined outside of loopLike
107+
/// Returns true if any of op's operands is defined inside the loop.
112108
static bool hasLoopVariantInput(LoopLikeOpInterface loopLike, Operation *op) {
113-
for (OpOperand &input : op->getOpOperands())
114-
if (!loopLike.isDefinedOutsideOfLoop(input.get()))
115-
return true;
116-
117-
return false;
109+
return llvm::any_of(op->getOperands(), [] (Value v) {
110+
return !loopLike.isDefinedOutsideOfLoop(v);
111+
});
118112
}
119113

120114
/// Returns true if:

0 commit comments

Comments
 (0)