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(
580
580
// DivUIOp
581
581
// ===----------------------------------------------------------------------===//
582
582
583
+ // / Fold `(a * b) / b -> a`
583
584
static Value foldDivMul (Value lhs, Value rhs,
584
585
arith::IntegerOverflowFlags ovfFlags) {
585
586
auto mul = lhs.getDefiningOp <mlir::arith::MulIOp>();
@@ -600,6 +601,7 @@ OpFoldResult arith::DivUIOp::fold(FoldAdaptor adaptor) {
600
601
if (matchPattern (adaptor.getRhs (), m_One ()))
601
602
return getLhs ();
602
603
604
+ // (a * b) / b -> a
603
605
if (Value val = foldDivMul (getLhs (), getRhs (), IntegerOverflowFlags::nuw))
604
606
return val;
605
607
@@ -639,6 +641,7 @@ OpFoldResult arith::DivSIOp::fold(FoldAdaptor adaptor) {
639
641
if (matchPattern (adaptor.getRhs (), m_One ()))
640
642
return getLhs ();
641
643
644
+ // (a * b) / b -> a
642
645
if (Value val = foldDivMul (getLhs (), getRhs (), IntegerOverflowFlags::nsw))
643
646
return val;
644
647
You can’t perform that action at this time.
0 commit comments