From 675da137e5419193f2ce447c47cf171d4e480107 Mon Sep 17 00:00:00 2001 From: Felix Xing Date: Mon, 20 Jan 2025 15:38:03 -0500 Subject: [PATCH] remove obsolete isinff calls --- meson.build | 1 - src/graphene-box.c | 52 +++++++++++++++---------------------------- src/graphene-simd4f.c | 5 ----- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/meson.build b/meson.build index eecd10a..69aa50e 100644 --- a/meson.build +++ b/meson.build @@ -173,7 +173,6 @@ endif math_exts = [ 'sincosf', - 'isinff', 'isnanf', ] diff --git a/src/graphene-box.c b/src/graphene-box.c index d9c6a98..656db45 100644 --- a/src/graphene-box.c +++ b/src/graphene-box.c @@ -427,55 +427,39 @@ graphene_box_get_depth (const graphene_box_t *box) static inline bool graphene_box_is_empty (const graphene_box_t *box) { -#ifdef HAVE_ISINFF float vmin[3], vmax[3]; graphene_simd4f_dup_3f (box->min.value, vmin); graphene_simd4f_dup_3f (box->max.value, vmax); - return (isinff (vmin[0]) == 1 && isinff (vmin[1]) == 1 && isinff (vmin[2]) == 1) && - (isinff (vmax[0]) == -1 && isinff (vmax[1]) == -1 && isinff (vmax[2]) == -1); -#else - graphene_simd4f_t neg_inf = graphene_simd4f_init (-INFINITY, -INFINITY, -INFINITY, 0.f); - graphene_simd4f_t pos_inf = graphene_simd4f_init (INFINITY, INFINITY, INFINITY, 0.f); - - /* This is only every going to be valid for boxes that we have - * initialized ourselves, because we use the same values; the - * bitwise comparison will not hold for infinities generated by - * other operations - */ - int min_cmp = memcmp (&box->min.value, &pos_inf, sizeof (graphene_simd4f_t)); - int max_cmp = memcmp (&box->max.value, &neg_inf, sizeof (graphene_simd4f_t)); - - return min_cmp == 0 && max_cmp == 0; -#endif + bool vmin_valid = (isinf(vmin[0]) && !signbit(vmin[0])) && + (isinf(vmin[1]) && !signbit(vmin[1])) && + (isinf(vmin[2]) && !signbit(vmin[2])); + + bool vmax_valid = (isinf(vmax[0]) && signbit(vmax[0])) && + (isinf(vmax[1]) && signbit(vmax[1])) && + (isinf(vmax[2]) && signbit(vmax[2])); + + return vmin_valid && vmax_valid; } static inline bool graphene_box_is_infinity (const graphene_box_t *box) { -#ifdef HAVE_ISINFF float vmin[3], vmax[3]; graphene_simd4f_dup_3f (box->min.value, vmin); graphene_simd4f_dup_3f (box->max.value, vmax); - return (isinff (vmin[0]) == -1 && isinff (vmin[1]) == -1 && isinff (vmin[2]) == -1) && - (isinff (vmax[0]) == 1 && isinff (vmax[1]) == 1 && isinff (vmax[2]) == 1); -#else - graphene_simd4f_t neg_inf = graphene_simd4f_init (-INFINITY, -INFINITY, -INFINITY, 0.f); - graphene_simd4f_t pos_inf = graphene_simd4f_init (INFINITY, INFINITY, INFINITY, 0.f); - - /* This is only every going to be valid for boxes that we have - * initialized ourselves, because we use the same values; the - * bitwise comparison will not hold for infinities generated by - * other operations - */ - int min_cmp = memcmp (&box->min.value, &neg_inf, sizeof (graphene_simd4f_t)); - int max_cmp = memcmp (&box->max.value, &pos_inf, sizeof (graphene_simd4f_t)); - - return min_cmp == 0 && max_cmp == 0; -#endif + bool vmin_valid = (isinf(vmin[0]) && signbit(vmin[0])) && + (isinf(vmin[1]) && signbit(vmin[1])) && + (isinf(vmin[2]) && signbit(vmin[2])); + + bool vmax_valid = (isinf(vmax[0]) && !signbit(vmax[0])) && + (isinf(vmax[1]) && !signbit(vmax[1])) && + (isinf(vmax[2]) && !signbit(vmax[2])); + + return vmin_valid && vmax_valid; } /** diff --git a/src/graphene-simd4f.c b/src/graphene-simd4f.c index d9f7e99..f9d3db6 100644 --- a/src/graphene-simd4f.c +++ b/src/graphene-simd4f.c @@ -1435,13 +1435,8 @@ approx_equal (float a, float b, float epsilon) { -#ifdef HAVE_ISINFF - if (isinff (a) && isinff (b)) - return true; -#else if (fpclassify (a) == FP_INFINITE && fpclassify (b) == FP_INFINITE) return true; -#endif float diff = fabsf (a - b); if (isnan (diff))