mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 12:06:38 +00:00
parent
efca37fda5
commit
340f06a8d4
@ -1124,7 +1124,7 @@ OpFoldResult DivOp::fold(FoldAdaptor adaptor) {
|
||||
if (!lhs)
|
||||
return nullptr;
|
||||
auto rhs = llvm::dyn_cast_if_present<IntegerAttr>(adaptor.getRhs());
|
||||
if (!rhs)
|
||||
if (!rhs || rhs.getValue().isZero())
|
||||
return nullptr;
|
||||
|
||||
// Division in APInt does not follow floor(lhs, rhs) when the result is
|
||||
|
13
mlir/test/Dialect/Shape/fold-div.mlir
Normal file
13
mlir/test/Dialect/Shape/fold-div.mlir
Normal file
@ -0,0 +1,13 @@
|
||||
// Bug: #131279
|
||||
// RUN: mlir-opt --test-scf-pipelining %s | FileCheck %s
|
||||
// CHECK: fold_div_index_neg_rhs
|
||||
// CHECK-NEXT: %c0 = arith.constant 0 : index
|
||||
// CHECK-NEXT: %0 = shape.div %c0, %c0 : index, index -> index
|
||||
// CHECK-NEXT: return %0 : index
|
||||
module {
|
||||
func.func @fold_div_index_neg_rhs() -> index {
|
||||
%c0 = arith.constant 0 : index
|
||||
%0 = shape.div %c0, %c0 : index, index -> index
|
||||
return %0 : index
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user