File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1124,7 +1124,7 @@ OpFoldResult DivOp::fold(FoldAdaptor adaptor) {
11241124 if (!lhs)
11251125 return nullptr ;
11261126 auto rhs = llvm::dyn_cast_if_present<IntegerAttr>(adaptor.getRhs ());
1127- if (!rhs)
1127+ if (!rhs || rhs. getValue (). isZero () )
11281128 return nullptr ;
11291129
11301130 // Division in APInt does not follow floor(lhs, rhs) when the result is
Original file line number Diff line number Diff line change 1+ // Bug: #131279
2+ // RUN: mlir-opt --test-scf-pipelining %s | FileCheck %s
3+ // CHECK: fold_div_index_neg_rhs
4+ // CHECK-NEXT: %c0 = arith.constant 0 : index
5+ // CHECK-NEXT: %0 = shape.div %c0, %c0 : index, index -> index
6+ // CHECK-NEXT: return %0 : index
7+ module {
8+ func.func @fold_div_index_neg_rhs () -> index {
9+ %c0 = arith.constant 0 : index
10+ %0 = shape.div %c0 , %c0 : index , index -> index
11+ return %0 : index
12+ }
13+ }
You can’t perform that action at this time.
0 commit comments