Skip to content

[mlir][affine] Add dependency on UBDialect for PoisonAttr #77691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def Affine_Dialect : Dialect {
let name = "affine";
let cppNamespace = "::mlir::affine";
let hasConstantMaterializer = 1;
let dependentDialects = ["arith::ArithDialect"];
let dependentDialects = ["arith::ArithDialect", "ub::UBDialect"];
}

// Base class for Affine dialect ops.
Expand Down
11 changes: 10 additions & 1 deletion mlir/test/Dialect/Affine/constant-fold.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func.func @affine_min(%variable: index) -> (index, index) {
// -----

func.func @affine_apply_poison_division_zero() {
// This is just for mlir::context to load ub dailect
// This is just for mlir::context to load ub dialect
%ub = ub.poison : index
%c16 = arith.constant 16 : index
%0 = affine.apply affine_map<(d0)[s0] -> (d0 mod (s0 - s0))>(%c16)[%c16]
Expand All @@ -81,3 +81,12 @@ func.func @affine_apply_poison_division_zero() {
// CHECK-NEXT: %[[alloc:.*]] = memref.alloc(%[[poison]], %[[poison]], %[[poison]])
// CHECK-NEXT: %[[load:.*]] = affine.load %[[alloc]][%[[poison]], %[[poison]], %[[poison]]] : memref<?x?x?xi1>
// CHECK-NEXT: affine.store %[[load]], %alloc[%[[poison]], %[[poison]], %[[poison]]] : memref<?x?x?xi1>

// -----

// Check that this doesn't crash because the ub dialect is automatically loaded
func.func @affine_apply_poison_division_zero_2() -> index {
%c16 = arith.constant 16 : index
%0 = affine.apply affine_map<(d0)[s0] -> (d0 mod (s0 - s0))>(%c16)[%c16]
return %0 : index
}