[llvm-branch-commits] [mlir] c3f2376 - Revert "[mlir][affine] Admit signless integers for affine.parallel maxs/mins/…"
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Oct 9 06:50:51 PDT 2026
Author: William Moses
Date: 2026-10-09T08:50:45-05:00
New Revision: c3f237649f5f3b84ad1c196109a167ddd27a38c9
URL: https://github.com/llvm/llvm-project/commit/c3f237649f5f3b84ad1c196109a167ddd27a38c9
DIFF: https://github.com/llvm/llvm-project/commit/c3f237649f5f3b84ad1c196109a167ddd27a38c9.diff
LOG: Revert "[mlir][affine] Admit signless integers for affine.parallel maxs/mins/…"
This reverts commit 380fcd8b4334846838412960c1117932b6a60364.
Added:
Modified:
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/test/Conversion/AffineToStandard/lower-affine.mlir
mlir/test/Dialect/Affine/invalid.mlir
mlir/test/Dialect/Affine/ops.mlir
mlir/test/Dialect/Affine/parallelize.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index a58b39ff5aac98..ad9845d8935fa3 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -4279,18 +4279,21 @@ static bool isResultTypeMatchAtomicRMWKind(Type resultType,
case arith::AtomicRMWKind::minimumf:
case arith::AtomicRMWKind::minnumf:
return isa<FloatType>(resultType);
- // The kind carries the signedness of the comparison; the integer is
- // signless (what arith's maxsi/minsi/maxui/minui, which the reduction
- // lowers to, operate on) or of that signedness.
- case arith::AtomicRMWKind::maxs:
+ case arith::AtomicRMWKind::maxs: {
+ auto intType = dyn_cast<IntegerType>(resultType);
+ return intType && intType.isSigned();
+ }
case arith::AtomicRMWKind::mins: {
auto intType = dyn_cast<IntegerType>(resultType);
- return intType && !intType.isUnsigned();
+ return intType && intType.isSigned();
+ }
+ case arith::AtomicRMWKind::maxu: {
+ auto intType = dyn_cast<IntegerType>(resultType);
+ return intType && intType.isUnsigned();
}
- case arith::AtomicRMWKind::maxu:
case arith::AtomicRMWKind::minu: {
auto intType = dyn_cast<IntegerType>(resultType);
- return intType && !intType.isSigned();
+ return intType && intType.isUnsigned();
}
case arith::AtomicRMWKind::ori:
case arith::AtomicRMWKind::andi:
diff --git a/mlir/test/Conversion/AffineToStandard/lower-affine.mlir b/mlir/test/Conversion/AffineToStandard/lower-affine.mlir
index dacbd1c4f7dd6d..09edb404a8375e 100644
--- a/mlir/test/Conversion/AffineToStandard/lower-affine.mlir
+++ b/mlir/test/Conversion/AffineToStandard/lower-affine.mlir
@@ -817,40 +817,6 @@ func.func @affine_parallel_simple_dynamic_bounds(%arg0: memref<?x?xf32>, %arg1:
/////////////////////////////////////////////////////////////////////
-func.func @affine_parallel_with_int_min_max(%arg0: memref<3xi32>) -> (i32, i32, i32, i32) {
- %0:4 = affine.parallel (%k) = (0) to (3) reduce ("maxs", "mins", "maxu", "minu") -> (i32, i32, i32, i32) {
- %1 = affine.load %arg0[%k] : memref<3xi32>
- affine.yield %1, %1, %1, %1 : i32, i32, i32, i32
- }
- return %0#0, %0#1, %0#2, %0#3 : i32, i32, i32, i32
-}
-// CHECK-LABEL: func @affine_parallel_with_int_min_max
-// CHECK: %[[INIT_1:.*]] = arith.constant -2147483648 : i32
-// CHECK-NEXT: %[[INIT_2:.*]] = arith.constant 2147483647 : i32
-// CHECK-NEXT: %[[INIT_3:.*]] = arith.constant 0 : i32
-// CHECK-NEXT: %[[INIT_4:.*]] = arith.constant -1 : i32
-// CHECK-NEXT: %[[RES:.*]]:4 = scf.parallel (%[[I:.*]]) = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) init (%[[INIT_1]], %[[INIT_2]], %[[INIT_3]], %[[INIT_4]]) -> (i32, i32, i32, i32) {
-// CHECK-NEXT: %[[VAL:.*]] = memref.load
-// CHECK-NEXT: scf.reduce(%[[VAL]], %[[VAL]], %[[VAL]], %[[VAL]] : i32, i32, i32, i32) {
-// CHECK-NEXT: ^bb0(%[[LHS:.*]]: i32, %[[RHS:.*]]: i32):
-// CHECK-NEXT: %[[R:.*]] = arith.maxsi %[[LHS]], %[[RHS]] : i32
-// CHECK-NEXT: scf.reduce.return %[[R]] : i32
-// CHECK-NEXT: }, {
-// CHECK-NEXT: ^bb0(%[[LHS:.*]]: i32, %[[RHS:.*]]: i32):
-// CHECK-NEXT: %[[R:.*]] = arith.minsi %[[LHS]], %[[RHS]] : i32
-// CHECK-NEXT: scf.reduce.return %[[R]] : i32
-// CHECK-NEXT: }, {
-// CHECK-NEXT: ^bb0(%[[LHS:.*]]: i32, %[[RHS:.*]]: i32):
-// CHECK-NEXT: %[[R:.*]] = arith.maxui %[[LHS]], %[[RHS]] : i32
-// CHECK-NEXT: scf.reduce.return %[[R]] : i32
-// CHECK-NEXT: }, {
-// CHECK-NEXT: ^bb0(%[[LHS:.*]]: i32, %[[RHS:.*]]: i32):
-// CHECK-NEXT: %[[R:.*]] = arith.minui %[[LHS]], %[[RHS]] : i32
-// CHECK-NEXT: scf.reduce.return %[[R]] : i32
-// CHECK-NEXT: }
-// CHECK-NEXT: }
-// CHECK-NEXT: return %[[RES]]#0, %[[RES]]#1, %[[RES]]#2, %[[RES]]#3 : i32, i32, i32, i32
-
func.func @affine_parallel_with_reductions(%arg0: memref<3x3xf32>, %arg1: memref<3x3xf32>) -> (f32, f32) {
%0:2 = affine.parallel (%kx, %ky) = (0, 0) to (2, 2) reduce ("addf", "mulf") -> (f32, f32) {
%1 = affine.load %arg0[%kx, %ky] : memref<3x3xf32>
diff --git a/mlir/test/Dialect/Affine/invalid.mlir b/mlir/test/Dialect/Affine/invalid.mlir
index 87a40e7382b2ea..3afebfcc076285 100644
--- a/mlir/test/Dialect/Affine/invalid.mlir
+++ b/mlir/test/Dialect/Affine/invalid.mlir
@@ -297,30 +297,6 @@ func.func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
// -----
-func.func @affine_parallel_maxs_unsigned() {
- %0 = memref.alloc() : memref<100x100xui32>
- // expected-error at +1 {{result type cannot match reduction attribute}}
- %1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) reduce ("maxs") -> (ui32) {
- %2 = affine.load %0[%i, %j] : memref<100x100xui32>
- affine.yield %2 : ui32
- }
- return
-}
-
-// -----
-
-func.func @affine_parallel_minu_signed() {
- %0 = memref.alloc() : memref<100x100xsi32>
- // expected-error at +1 {{result type cannot match reduction attribute}}
- %1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) reduce ("minu") -> (si32) {
- %2 = affine.load %0[%i, %j] : memref<100x100xsi32>
- affine.yield %2 : si32
- }
- return
-}
-
-// -----
-
func.func @no_upper_bound_affine_parallel() {
// expected-error at +1 {{expected lower bound map to have at least one result}}
affine.parallel (%arg2) = (max()) to (1) {
diff --git a/mlir/test/Dialect/Affine/ops.mlir b/mlir/test/Dialect/Affine/ops.mlir
index 54e35b9ad06b4b..f5bcb384bc9cd7 100644
--- a/mlir/test/Dialect/Affine/ops.mlir
+++ b/mlir/test/Dialect/Affine/ops.mlir
@@ -192,18 +192,6 @@ func.func @parallel(%A : memref<100x100xf32>, %N : index) {
// -----
-// CHECK-LABEL: func @parallel_int_min_max
-func.func @parallel_int_min_max(%A : memref<100xi32>) {
- // CHECK: affine.parallel (%{{.*}}) = (0) to (100) reduce ("maxs", "mins", "maxu", "minu") -> (i32, i32, i32, i32)
- %0:4 = affine.parallel (%i) = (0) to (100) reduce ("maxs", "mins", "maxu", "minu") -> (i32, i32, i32, i32) {
- %1 = affine.load %A[%i] : memref<100xi32>
- affine.yield %1, %1, %1, %1 : i32, i32, i32, i32
- }
- return
-}
-
-// -----
-
// CHECK-LABEL: @parallel_min_max
// CHECK: %[[A:.*]]: index, %[[B:.*]]: index, %[[C:.*]]: index, %[[D:.*]]: index
func.func @parallel_min_max(%a: index, %b: index, %c: index, %d: index) {
diff --git a/mlir/test/Dialect/Affine/parallelize.mlir b/mlir/test/Dialect/Affine/parallelize.mlir
index 3a85a209135351..17992f0111e9ed 100644
--- a/mlir/test/Dialect/Affine/parallelize.mlir
+++ b/mlir/test/Dialect/Affine/parallelize.mlir
@@ -195,25 +195,6 @@ func.func @iter_args(%in: memref<10xf32>) {
return
}
-// CHECK-LABEL: @iter_args_max
-// REDUCE-LABEL: @iter_args_max
-func.func @iter_args_max(%in: memref<10xi32>) {
- // REDUCE: %[[init:.*]] = arith.constant
- %c0 = arith.constant 0 : i32
- // CHECK-NOT: affine.parallel
- // REDUCE: %[[reduced:.*]] = affine.parallel (%{{.*}}) = (0) to (10) reduce ("maxs") -> (i32)
- %final_red = affine.for %i = 0 to 10 iter_args(%red_iter = %c0) -> (i32) {
- // REDUCE: %[[red_value:.*]] = affine.load
- %ld = affine.load %in[%i] : memref<10xi32>
- // REDUCE-NOT: arith.maxsi
- %max = arith.maxsi %red_iter, %ld : i32
- // REDUCE: affine.yield %[[red_value]]
- affine.yield %max : i32
- }
- // REDUCE: arith.maxsi %[[init]], %[[reduced]]
- return
-}
-
// CHECK-LABEL: @nested_iter_args
// REDUCE-LABEL: @nested_iter_args
func.func @nested_iter_args(%in: memref<20x10xf32>) {
More information about the llvm-branch-commits
mailing list