Skip to content

Commit 389e865

Browse files
committed
address comments
1 parent ed43bae commit 389e865

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,23 +1566,34 @@ LogicalResult NVVM::ClusterLaunchControlQueryCancelOp::verify() {
15661566
LogicalResult NVVM::ReduxOp::verify() {
15671567
mlir::Type reduxType = getType();
15681568

1569-
if (!reduxType.isF32() && getAbs())
1570-
return emitOpError("abs attribute is supported only for f32 type");
1571-
1572-
if (!reduxType.isF32() && getNan())
1573-
return emitOpError("nan attribute is supported only for f32 type");
1569+
if (!reduxType.isF32()) {
1570+
if (getAbs())
1571+
return emitOpError("abs attribute is supported only for f32 type");
1572+
if (getNan())
1573+
return emitOpError("nan attribute is supported only for f32 type");
1574+
}
15741575

15751576
NVVM::ReduxKind kind = getKind();
15761577
switch (kind) {
1578+
case NVVM::ReduxKind::ADD:
1579+
case NVVM::ReduxKind::AND:
1580+
case NVVM::ReduxKind::OR:
1581+
case NVVM::ReduxKind::XOR:
1582+
case NVVM::ReduxKind::MAX:
1583+
case NVVM::ReduxKind::MIN:
1584+
case NVVM::ReduxKind::UMAX:
1585+
case NVVM::ReduxKind::UMIN:
1586+
if (!reduxType.isInteger(32))
1587+
return emitOpError("'")
1588+
<< stringifyEnum(kind) << "' redux kind unsupported with "
1589+
<< getType() << " type. Only supported type is 'i32'.";
1590+
break;
15771591
case NVVM::ReduxKind::FMIN:
15781592
case NVVM::ReduxKind::FMAX:
15791593
if (!reduxType.isF32())
1580-
return emitOpError("fmin and fmax redux kind must be used with f32 type");
1581-
break;
1582-
default:
1583-
if (reduxType.isF32())
1584-
return emitOpError(
1585-
"only fmin and fmax redux kinds are supported for f32 type");
1594+
return emitOpError("'")
1595+
<< stringifyEnum(kind) << "' redux kind unsupported with "
1596+
<< getType() << " type. Only supported type is 'f32'.";
15861597
break;
15871598
}
15881599

mlir/test/Target/LLVMIR/nvvm/redux-sync-invalid.mlir

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,23 @@ llvm.func @redux_sync_i32_with_nan(%value: i32, %offset: i32) {
1919
// -----
2020

2121
llvm.func @redux_sync_f32_with_invalid_kind(%value: f32, %offset: i32) {
22-
// expected-error@+1 {{only fmin and fmax redux kinds are supported for f32 type}}
22+
// expected-error@+1 {{'add' redux kind unsupported with 'f32' type. Only supported type is 'i32'.}}
2323
%res = nvvm.redux.sync add %value, %offset: f32 -> f32
2424
llvm.return
2525
}
2626

2727
// -----
2828

29+
llvm.func @redux_sync_f32_with_invalid_kind(%value: f32, %offset: i32) {
30+
// expected-error@+1 {{'and' redux kind unsupported with 'f32' type. Only supported type is 'i32'.}}
31+
%res = nvvm.redux.sync and %value, %offset: f32 -> f32
32+
llvm.return
33+
}
34+
35+
// -----
36+
2937
llvm.func @redux_sync_i32_with_invalid_kind(%value: i32, %offset: i32) {
30-
// expected-error@+1 {{fmin and fmax redux kind must be used with f32 type}}
38+
// expected-error@+1 {{'fmin' redux kind unsupported with 'i32' type. Only supported type is 'f32'.}}
3139
%res = nvvm.redux.sync fmin %value, %offset: i32 -> i32
3240
llvm.return
3341
}

0 commit comments

Comments
 (0)