From 57567778b7d91afe7e6325c731d54b313b8b16e9 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Fri, 11 Jul 2025 10:12:17 -0700 Subject: Fix IEEE 754 NaN comparisons in constant folding (#7721) * Fix IEEE 754 NaN comparisons in constant folding Added proper NaN handling in SCCP optimization pass to follow IEEE 754 standard: - NaN \!= any value returns true - All other NaN comparisons return false - Added double precision NaN detection support - Fixed type detection to check operands instead of result type * Avoid differentiating NaN and non-NaN cases * format code (#76) --------- Co-authored-by: slangbot --- source/core/slang-math.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/core') diff --git a/source/core/slang-math.h b/source/core/slang-math.h index e977dc37d..c7e77fce5 100644 --- a/source/core/slang-math.h +++ b/source/core/slang-math.h @@ -106,8 +106,10 @@ public: } static inline int IsNaN(float x) { return std::isnan(x); } + static inline int IsNaN(double x) { return std::isnan(x); } static inline int IsInf(float x) { return std::isinf(x); } + static inline int IsInf(double x) { return std::isinf(x); } static inline unsigned int Ones32(unsigned int x) { -- cgit v1.2.3