[Mlir-commits] [mlir] [mlir][test] Ignore NaN sign in test case (PR #194875)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Apr 29 07:46:26 PDT 2026


https://github.com/XYenChi created https://github.com/llvm/llvm-project/pull/194875

IEEE 754-2008 (section 6.3) does not specify the sign bit of a NaN result for most floating-point operations. While certain bitwise operations (e.g., copy, negate, abs, copySign) may define or propagate the sign bit, general arithmetic operations are not required to do so.

This test currently assumes a specific NaN sign, which is not portable across targets. It fails on RISC-V due to differing NaN sign behavior.

Relax the test to ignore the NaN sign.

>From ded8f0d5c21f9cab3f465d25546ce966138441f4 Mon Sep 17 00:00:00 2001
From: XYenChi <oriachiuan at gmail.com>
Date: Sat, 18 Apr 2026 21:33:50 +0800
Subject: [PATCH] [mlir][test] Ignore NaN sign in test case

IEEE 754-2008 (section 6.3) does not specify the sign bit of a NaN
result for most floating-point operations. While certain bitwise
operations (e.g., copy, negate, abs, copySign) may define or propagate
the sign bit, general arithmetic operations are not required to do so.

This test currently assumes a specific NaN sign, which is not portable
across targets. It fails on RISC-V due to differing NaN sign behavior.

Relax the test to ignore the NaN sign.
---
 mlir/test/mlir-runner/test-expand-math-approx.mlir | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/test/mlir-runner/test-expand-math-approx.mlir b/mlir/test/mlir-runner/test-expand-math-approx.mlir
index 06b3171a2349e..5ba0f7106e101 100644
--- a/mlir/test/mlir-runner/test-expand-math-approx.mlir
+++ b/mlir/test/mlir-runner/test-expand-math-approx.mlir
@@ -233,12 +233,12 @@ func.func @powf() {
   %g_p = arith.constant 23598.0 : f64
   call @func_powff64(%g, %g_p) : (f64, f64) -> ()
 
-  // CHECK-NEXT: -nan
+  // CHECK-NEXT: {{-?}}nan
   %h = arith.constant 1.0 : f64
   %h_p = arith.constant 0xfff0000001000000 : f64
   call @func_powff64(%h, %h_p) : (f64, f64) -> ()
 
-  // CHECK-NEXT: -nan
+  // CHECK-NEXT: {{-?}}nan
   %i = arith.constant 1.0 : f32
   %i_p = arith.constant 0xffffffff : f32
   call @func_powff32(%i, %i_p) : (f32, f32) -> ()



More information about the Mlir-commits mailing list