Skip to content

Commit 9835e16

Browse files
committed
Address review comments
1 parent 75a25e4 commit 9835e16

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,16 @@ struct UModSimplification final : OpRewritePattern<spirv::UModOp> {
345345
// not, fail the transformation.
346346
bool isApplicable = false;
347347
if (auto prevInt = dyn_cast<IntegerAttr>(prevValue)) {
348-
auto currInt = dyn_cast<IntegerAttr>(currValue);
348+
auto currInt = cast<IntegerAttr>(currValue);
349349
isApplicable = prevInt.getValue().urem(currInt.getValue()) == 0;
350350
} else if (auto prevVec = dyn_cast<DenseElementsAttr>(prevValue)) {
351-
auto currVec = dyn_cast<DenseElementsAttr>(currValue);
352-
isApplicable = llvm::all_of(
353-
llvm::zip(prevVec.getValues<APInt>(), currVec.getValues<APInt>()),
354-
[](const auto &pair) {
355-
return std::get<0>(pair).urem(std::get<1>(pair)) == 0;
356-
});
351+
auto currVec = cast<DenseElementsAttr>(currValue);
352+
isApplicable = llvm::all_of(llvm::zip_equal(prevVec.getValues<APInt>(),
353+
currVec.getValues<APInt>()),
354+
[](const auto &pair) {
355+
auto &[prev, curr] = pair;
356+
return prev.urem(curr) == 0;
357+
});
357358
}
358359

359360
if (!isApplicable)

0 commit comments

Comments
 (0)