Skip to content

Commit d9c65af

Browse files
wsmosesivanradanov
andauthored
[MLIR][GPUToNVVM] Support 32-bit isfinite (#131699)
Co-authored-by: Ivan Radanov Ivanov <[email protected]>
1 parent d1156fc commit d9c65af

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,9 @@ void mlir::populateLibDeviceConversionPatterns(
552552
"__nv_floor");
553553
populateOpPatterns<math::FmaOp>(converter, patterns, benefit, "__nv_fmaf",
554554
"__nv_fma");
555-
// Note: libdevice does not provide `__nv_isfinitef` as of moment of writing.
556-
populateOpPatterns<math::IsFiniteOp>(converter, patterns, benefit, "",
557-
"__nv_isfinited");
555+
// Note: libdevice uses a different name for 32-bit finite checking
556+
populateOpPatterns<math::IsFiniteOp>(converter, patterns, benefit,
557+
"__nv_finitef", "__nv_isfinited");
558558
populateOpPatterns<math::IsInfOp>(converter, patterns, benefit, "__nv_isinff",
559559
"__nv_isinfd");
560560
populateOpPatterns<math::IsNaNOp>(converter, patterns, benefit, "__nv_isnanf",

mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ gpu.module @test_module_54 {
10641064
// CHECK: llvm.func @__nv_isinfd(f64) -> i32
10651065
// CHECK: llvm.func @__nv_isnanf(f32) -> i32
10661066
// CHECK: llvm.func @__nv_isnand(f64) -> i32
1067+
// CHECK: llvm.func @__nv_finitef(f32) -> i32
10671068
// CHECK: llvm.func @__nv_isfinited(f64) -> i32
10681069
// CHECK-LABEL: @fpclassify
10691070
func.func @fpclassify(%f32: f32, %f64: f64) -> (i1, i1, i1, i1, i1, i1) {
@@ -1083,9 +1084,9 @@ gpu.module @test_module_54 {
10831084
// CHECK: llvm.mlir.constant(0
10841085
// CHECK: llvm.icmp "ne"
10851086
%3 = math.isnan %f64 : f64
1086-
// Note: for some reason, libdevice does not provide isfinite for f32, so
1087-
// this should fail to convert.
1088-
// CHECK: math.isfinite {{.*}} : f32
1087+
// CHECK: llvm.call @__nv_finitef(%{{.*}}) : (f32) -> i32
1088+
// CHECK: llvm.mlir.constant(0
1089+
// CHECK: llvm.icmp "ne"
10891090
%4 = math.isfinite %f32 : f32
10901091
// CHECK: llvm.call @__nv_isfinited(%{{.*}}) : (f64) -> i32
10911092
// CHECK: llvm.mlir.constant(0

0 commit comments

Comments
 (0)