File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed
mlir/lib/Dialect/Arith/IR Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -580,6 +580,7 @@ void arith::MulUIExtendedOp::getCanonicalizationPatterns(
580580// DivUIOp
581581// ===----------------------------------------------------------------------===//
582582
583+ // / Fold `(a * b) / b -> a`
583584static 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
You can’t perform that action at this time.
0 commit comments