Skip to content

Commit c67b426

Browse files
committed
comment
1 parent bdf8ed0 commit c67b426

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mlir/lib/Dialect/Arith/IR/ArithOps.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ void arith::MulUIExtendedOp::getCanonicalizationPatterns(
580580
// DivUIOp
581581
//===----------------------------------------------------------------------===//
582582

583+
/// Fold `(a * b) / b -> a`
583584
static Value foldDivMul(Value lhs, Value rhs,
584585
arith::IntegerOverflowFlags ovfFlags) {
585586
auto mul = lhs.getDefiningOp<mlir::arith::MulIOp>();
@@ -600,6 +601,7 @@ OpFoldResult arith::DivUIOp::fold(FoldAdaptor adaptor) {
600601
if (matchPattern(adaptor.getRhs(), m_One()))
601602
return getLhs();
602603

604+
// (a * b) / b -> a
603605
if (Value val = foldDivMul(getLhs(), getRhs(), IntegerOverflowFlags::nuw))
604606
return val;
605607

@@ -639,6 +641,7 @@ OpFoldResult arith::DivSIOp::fold(FoldAdaptor adaptor) {
639641
if (matchPattern(adaptor.getRhs(), m_One()))
640642
return getLhs();
641643

644+
// (a * b) / b -> a
642645
if (Value val = foldDivMul(getLhs(), getRhs(), IntegerOverflowFlags::nsw))
643646
return val;
644647

0 commit comments

Comments
 (0)